Skip to content

feat: add explicit backrun bundle cancellation via 0-tx submissions#423

Open
dvush wants to merge 2 commits intomainfrom
backruns_cancellations
Open

feat: add explicit backrun bundle cancellation via 0-tx submissions#423
dvush wants to merge 2 commits intomainfrom
backruns_cancellations

Conversation

@dvush
Copy link
Contributor

@dvush dvush commented Mar 3, 2026

📝 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:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

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.
Copilot AI review requested due to automatic review settings March 3, 2026 15:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 UuidEntry enum (Bundle | Cancellation) to unify bundle and cancellation state under the same per-UUID tracking map in the global pool, adds cancel_bundle public API, and refactors repeated pool insertion/removal logic into helpers.
  • Adds cancellation path in the send_backrun_bundle RPC handler: routes 0-tx submissions to cancel_bundle, returning B256::ZERO as the bundle hash.
  • Adds unit tests (test_cancellation, extended test_on_canonical_state_change) and an integration test (backrun_cancellation), along with a send_backrun_cancellation test 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<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a test for cancellations expiring after CANCELLATION_MAX_BLOCK_RANGE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants