Skip to content

refactor: extract post-seal side-effects into PostSealHook trait#518

Open
julio4 wants to merge 2 commits into
mainfrom
refactor/extract-post-seal-hooks
Open

refactor: extract post-seal side-effects into PostSealHook trait#518
julio4 wants to merge 2 commits into
mainfrom
refactor/extract-post-seal-hooks

Conversation

@julio4
Copy link
Copy Markdown
Member

@julio4 julio4 commented May 15, 2026

Move ws publication, p2p forwarding, engine propagation, and per-flashblock metrics out of the building loop behind a PostSealHook trait. Hooks are constructed once and dispatched after each sealed candidate (fallback + every flashblock).

build_next_flashblock no longer performs side-effects: it returns FlashblockBuildResult struct and the async loop handles dispatch.

@akundaz
Copy link
Copy Markdown
Contributor

akundaz commented May 19, 2026

I do want a hook system, but it's not clear to me this is the right design for it. For the time being it would be better to not have the new trait and context types, and instead extract the side-effects a different way where each one only has the minimal amount of information for it to run.

@julio4 julio4 force-pushed the refactor/extract-post-seal-hooks branch from d945cae to 7edeb12 Compare May 21, 2026 10:20
@julio4
Copy link
Copy Markdown
Member Author

julio4 commented May 21, 2026

I do want a hook system, but it's not clear to me this is the right design for it. For the time being it would be better to not have the new trait and context types, and instead extract the side-effects a different way where each one only has the minimal amount of information for it to run.

Hm yes I agree that the ctx is encapsulating too much here. I tried to rework this by adding a more immutable Slot Metadata and derive more information directly from the payload built itself.

julio4 added 2 commits May 22, 2026 23:07
Move WS publication, p2p forwarding, engine propagation, and per-flashblock
metrics out of the building loop and behind a PostSealHook trait. Hooks
are constructed once in OpPayloadBuilder::new() and dispatched after each
sealed candidate (fallback + every flashblock).

build_next_flashblock no longer performs side-effects: it returns a
FlashblockBuildResult struct and the async loop handles dispatch. The
side-effect call sites in the fallback path and the FB iteration are
collapsed to a single dispatch_post_seal call each.

p2p and engine forwarders are unified as ChannelHook(name, sender) since
they only differ in the failure log label.
@julio4 julio4 force-pushed the refactor/extract-post-seal-hooks branch from 7edeb12 to 849ba74 Compare May 22, 2026 15:07
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