Skip to content

fix: don't publish flashblock after payload cancellation#525

Merged
akundaz merged 1 commit into
mainfrom
payload-publish-cancellation-main
Jun 9, 2026
Merged

fix: don't publish flashblock after payload cancellation#525
akundaz merged 1 commit into
mainfrom
payload-publish-cancellation-main

Conversation

@avalonche

@avalonche avalonche commented May 21, 2026

Copy link
Copy Markdown
Collaborator

📝 Summary

Prevents a cancelled payload job from publishing locally built payloads into the payload handler after the job has already been resolved (by newPayload).

It also renames PayloadJobCancellation::cancelled() to wait_for_cancellation() so async wait sites are easier to distinguish from immediate is_cancelled() checks.

💡 Motivation and Context

  1. forkchoiceUpdated starts a payload job.
  2. The job builds fallback and flashblock payloads.
  3. Built payloads are sent through local channels to the PayloadHandler.
  4. The handler emits Events::BuiltPayload, which updates reth's engine tree with the local payload.

build_next_flashblock() was a blocking job that previously performed side effects such as publishing. Reth could then see a stale local same-height payload after the job had already been resolved. Now:

  • build_next_flashblock() builds and returns BuiltFlashblockOutput.
  • The async outer loop owns publication.
  • The outer loop checks cancellation after the blocking task returns and before publishing.
  • publish_flashblock_payload() performs one final cancellation check before websocket publish and channel sends.

✅ I have completed the following steps:

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

@julio4 julio4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We were already checking for block cancel before calling all publish side effects in sync, so this is mostly refactor to extract publish side effects outside of build_next_flashblock it seems?

@julio4

julio4 commented May 21, 2026

Copy link
Copy Markdown
Member

Also please see #518

Comment thread crates/op-rbuilder/src/builder/payload.rs
@akundaz akundaz merged commit 0531f05 into main Jun 9, 2026
4 checks passed
@akundaz akundaz deleted the payload-publish-cancellation-main branch June 9, 2026 14:24
@avalonche avalonche mentioned this pull request Jun 16, 2026
4 tasks
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