-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(rpc): preserve nested bundle structure in mev_simBundle logs #20565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add build_bundle_logs() to recursively build SimBundleLogs tree - Add raw_tx_hash field to FlattenedBundleItem for consistent hash matching - Use HashMap to map transaction hashes to logs - Add unit tests for nested bundle log collection Signed-off-by: Hwangjae Lee <[email protected]>
Signed-off-by: Hwangjae Lee <[email protected]>
does that mean that txLogs and bundeLogs are mutually exclusive? |
mattsse
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, all of this makes sense
but I believe we can also populate the logs if use smth like a stack of logs instead because I'd like to avoid having recursive calls here
Yes, |
- Replace recursive build_bundle_logs() with stack-based iteration - Add bundle_path to FlattenedBundleItem for tracking item position - Revert formatting changes per review feedback - Update tests to use iterative approach Signed-off-by: Hwangjae Lee <[email protected]>
Signed-off-by: Hwangjae Lee <[email protected]>
|
@mattsse I have updated the code based on your suggestion and ran the tests using the same approach as before. |
Summary
Fix log collection in
mev_simBundleto preserve the hierarchical structure of nested bundles.Problem
When MEV searchers simulate nested bundles using
mev_simBundle, the response logs were flattened into a single array. This made it impossible to determine which transactions belonged to which nested bundle.Example: Arbitrage strategy with backrun
Before (Flattened - Structure Lost)
{ "logs": [ { "txLogs": ["tx1 logs"], "bundleLogs": null }, { "txLogs": ["tx2 logs"], "bundleLogs": null }, { "txLogs": ["tx3 logs"], "bundleLogs": null }, { "txLogs": ["tx4 logs"], "bundleLogs": null } ] }→ Cannot identify tx2, tx3 belong to Backrun Bundle
After (Hierarchical - Structure Preserved)
{ "logs": [ { "txLogs": ["tx1 logs"], "bundleLogs": null }, { "txLogs": null, "bundleLogs": [ { "txLogs": ["tx2 logs"], "bundleLogs": null }, { "txLogs": ["tx3 logs"], "bundleLogs": null } ]}, { "txLogs": ["tx4 logs"], "bundleLogs": null } ] }→ Backrun Bundle clearly identified via
bundleLogsNote:
txLogsandbundleLogsare mutually exclusive by design - aSimBundleLogsentry represents either a transaction (withtxLogs) or a nested bundle (withbundleLogs), never both.User Benefits
SimBundleLogs.bundle_logsfield now works as intendedChanges
build_bundle_logs()using stack-based iteration to reconstruct log hierarchy (avoids recursive calls)bundle_pathfield toFlattenedBundleItemto track each transaction's position in the bundle hierarchyHashMapduring execution for structure reconstruction