feat(relay): support relaying all bundles from a tx with --all#27
Open
vibelyova wants to merge 3 commits intomm-zk-codex:mainfrom
Open
feat(relay): support relaying all bundles from a tx with --all#27vibelyova wants to merge 3 commits intomm-zk-codex:mainfrom
vibelyova wants to merge 3 commits intomm-zk-codex:mainfrom
Conversation
Previously `bundle relay` only processed the first InteropBundleSent
event in a tx, silently ignoring any additional bundles. Transactions
that emit multiple bundles (batched operations) would have all but
the first bundle stranded on the source chain.
Changes:
- Add `--all` flag to `bundle relay`; when set, every InteropBundleSent
event in the receipt is relayed in sequence.
- Extract `find_bundle_log_positions` to compute the correct msg_index
for each bundle by counting L1MessageSent events from 0x8008 in log
order — matching the logic already used by `auto-relay`.
- Extract `extract_bundles` which pairs ABI decoding with the index
computation; used by the relay command.
- Without `--all`, the existing `--msg-index` flag (default 0) selects
a specific bundle; an actionable error is emitted if not found.
- Output artifacts (bundle.hex, proof.json, relay_summary.json) are
written with a `_{msg_index}` suffix when multiple bundles are relayed
so the files don't overwrite each other.
- Add 9 unit tests covering `find_bundle_log_positions` edge cases.
Also fix pre-existing clippy warnings across the codebase so the
project passes `cargo clippy -- -D warnings`.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Make write_relay_outputs a sync fn (it does no async work) - Remove unnecessary calldata.clone() in dry-run branch Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace unwrap/expect on user input with proper error propagation (root_wait parse_b256, abi decode_bundle_status/decode_call_status) - Fix tx_show using hardcoded INTEROP_CENTER_ADDRESS instead of resolved AddressBook (--center override and config had no effect) - Fix relay not waiting for destination tx receipt (tx could revert silently; now waits and checks receipt status like send/token do) - Fix bundle extract only extracting first bundle; add --all and --msg-index flags to match relay command behavior - Fix send.rs require_signer_or_dry_run being dead code (called after dry_run branch already returned); move check before branch - Add --private-key-env to auto-relay (was the only command without it, forcing users to pass keys on the command line) - Move debug println in tx_show and bundle_action to eprintln to avoid corrupting --json output - Remove unused INTEROP_CENTER_ADDRESS constant Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bundle relayonly ever processed the firstInteropBundleSentevent in a transaction. Any transaction that emits multiple bundles (e.g. a batched operation sending to several destination chains) would have all bundles after the first one permanently stranded — with no error or warning.The
--msg-indexflag existed to pick a specific bundle, but the bundle-selection code always selected the firstInteropBundleSentregardless of the flag's value, so it had no real effect.Solution
--allflag tobundle relay. When set, everyInteropBundleSentin the receipt is relayed in sequence (proof → root → execute/verify for each).--msg-indexto actually select the bundle with that index. If no bundle matches, a clear error suggests using--all.find_bundle_log_positions— the core function that scans logs in order, countsL1MessageSentevents from0x8008, and derives the correctmsg_indexfor each bundle. This matches the logic already used byauto-relaybut was missing from the relay command.Usage
Relay all bundles from a tx (new):
Relay a specific bundle by index (fixed):
When using
--allwith--out-dir, each bundle's artifacts are written with a_{msg_index}suffix (bundle_0.hex,proof_0.json, etc.) to avoid overwrites.Tests
9 unit tests added for
find_bundle_log_positionscovering:Additional fixes (code review follow-up)
Critical
root_waitcalled.unwrap()onparse_b256from--expected-root(panics on bad hex);abi.rscalled.unwrap()onU256→u64conversion indecode_bundle_status/decode_call_status. Both now use?error propagation.tx showignoring--centeroverrides: was hardcoded toINTEROP_CENTER_ADDRESSconstant instead of using the resolvedAddressBook, so config and CLI overrides had no effect.relaynot waiting for destination tx receipt: sent the handler tx and reported success without checking if it reverted on-chain. Now waits for receipt and bails on revert, matchingsendandtokencommands.Important
bundle extractonly extracting the first bundle: silently ignored multi-bundle transactions. Added--alland--msg-indexflags reusing the sameextract_bundleslogic from relay.require_signer_or_dry_runinsend.rs: the check was called after thedry_runbranch had already returned, making it unreachable. Moved before the branch so it actually validates.--private-key-envtoauto-relay: was the only command without it, forcing users to pass keys on the command line (visible inpsand shell history).Minor
println!corrupting--jsonoutput:tx_showprinted "Decoding L1MessageSent event..." to stdout;bundle_actionprinted debug messages to stdout. Moved toeprintlnor removed.write_relay_outputsunnecessaryasync: function did only synchronousfs::writecalls.calldata.clone()in relay dry-run branch.INTEROP_CENTER_ADDRESSconstant fromtypes.rs.cargo clippy -- -D warningserrors (redundant closures,cloneonCopytypes, dead code branch indoctor.rs, import hygiene, etc.).🤖 Generated with Claude Code