feat: add explicit backrun bundle cancellation via 0-tx submissions#423
feat: add explicit backrun bundle cancellation via 0-tx submissions#423
Conversation
Sending eth_sendBackrunBundle with 0 transactions, a replacementUuid, and a replacementNonce cancels the active bundle for that UUID. The cancellation uses the same nonce semantics as replacements: strictly higher nonce wins. Cancellations expire after CANCELLATION_MAX_BLOCK_RANGE=2 blocks.
There was a problem hiding this comment.
Pull request overview
This PR adds explicit backrun bundle cancellation support via 0-transaction eth_sendBackrunBundle submissions. When a caller sends a bundle with 0 transactions along with a replacementUuid and replacementNonce, the active bundle for that UUID is removed from all block payload pools. The same strictly-higher-nonce semantics used for bundle replacements apply to cancellations. Cancellation entries expire after CANCELLATION_MAX_BLOCK_RANGE (2) blocks from the current tip.
Changes:
- Introduces
UuidEntryenum (Bundle|Cancellation) to unify bundle and cancellation state under the same per-UUID tracking map in the global pool, addscancel_bundlepublic API, and refactors repeated pool insertion/removal logic into helpers. - Adds cancellation path in the
send_backrun_bundleRPC handler: routes 0-tx submissions tocancel_bundle, returningB256::ZEROas the bundle hash. - Adds unit tests (
test_cancellation, extendedtest_on_canonical_state_change) and an integration test (backrun_cancellation), along with asend_backrun_cancellationtest helper.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/op-rbuilder/src/backrun_bundle/global_pool.rs |
Introduces UuidEntry enum, cancel_bundle method, remove_bundle_from_pools/insert_bundle_into_pools helpers, and updated canonical state cleanup. |
crates/op-rbuilder/src/backrun_bundle/rpc.rs |
Adds the 0-tx cancellation path in send_backrun_bundle and removes the now-obsolete 0-tx rejection test case. Adds test_cancel_requires_uuid_and_nonce. |
crates/op-rbuilder/src/tests/framework/txs.rs |
Adds send_backrun_cancellation test helper. |
crates/op-rbuilder/src/tests/backrun.rs |
Adds backrun_cancellation integration test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, | ||
| ..Default::default() | ||
| })] | ||
| async fn backrun_cancellation(rbuilder: LocalInstance) -> eyre::Result<()> { |
There was a problem hiding this comment.
is there a test for cancellations expiring after CANCELLATION_MAX_BLOCK_RANGE?
There was a problem hiding this comment.
cancellation expiration is tested here https://github.com/flashbots/op-rbuilder/pull/423/changes#diff-bb1901a42309ca5fa0a7f7ad29c0fadcbd36b7cf6e9460791a94dffd85fb4855L336
📝 Summary
Sending eth_sendBackrunBundle with 0 transactions, a replacementUuid, and a replacementNonce cancels the active bundle for that UUID. The cancellation uses the same nonce semantics as replacements: strictly higher nonce wins.
Cancellations expire after CANCELLATION_MAX_BLOCK_RANGE=2 blocks.
💡 Motivation and Context
✅ I have completed the following steps:
make lintmake test