Skip to content

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

Open
avalonche wants to merge 1 commit into
mainfrom
payload-publish-cancellation-main
Open

fix: don't publish flashblock after payload cancellation#525
avalonche wants to merge 1 commit into
mainfrom
payload-publish-cancellation-main

Conversation

@avalonche
Copy link
Copy Markdown
Collaborator

@avalonche avalonche commented May 21, 2026

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

Copy link
Copy Markdown
Member

@julio4 julio4 left a comment

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
Copy link
Copy Markdown
Member

julio4 commented May 21, 2026

Also please see #518

build_duration,
} = built_flashblock;

if payload_cancel.is_cancelled() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aren't we checking for cancellation just before we call this publish function? So this seems unnecessary here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I believe we check is_resolved but is_cancelled() can also be true if deadline / error is reached. but yes I believe it can be refactored better

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