refactor: fan out flashblock publication#559
Open
julio4 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors flashblock publication so post-build side effects (websocket publish, p2p forwarding, engine feedback) are decoupled from the payload build path and handled by dedicated subscriber tasks consuming a fanout broadcast bus. This isolates transient publication failures (e.g., websocket disconnects) from aborting payload construction and replaces “send failed” counters with per-subscriber lag/drop counters.
Changes:
- Introduces a broadcast-based fanout bus (
fanout.rs) and subscriber tasks for websocket publish, p2p forward, and engine feedback. - Updates the builder/service wiring so built payloads are emitted once onto the bus;
PayloadHandlernow only processes peer-received payloads. - Improves slot-offset timing robustness (saturating pre-UNIX-epoch case) and adds a regression test; updates task metrics + lag counters.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/op-rbuilder/src/tokio_metrics.rs | Adds task monitors/recording for the new subscriber tasks. |
| crates/op-rbuilder/src/metrics.rs | Replaces built-payload send-failure counters with per-subscriber lag/drop counters. |
| crates/op-rbuilder/src/builder/timing.rs | Uses saturating subtraction for slot start calculation; adds test. |
| crates/op-rbuilder/src/builder/service.rs | Wires up the fanout bus and spawns websocket/p2p/engine subscriber tasks. |
| crates/op-rbuilder/src/builder/payload.rs | Emits FlashblockEvents onto the fanout bus instead of doing side effects inline. |
| crates/op-rbuilder/src/builder/payload_handler.rs | Narrows responsibility to handling peer-received payloads only. |
| crates/op-rbuilder/src/builder/mod.rs | Registers the new fanout module. |
| crates/op-rbuilder/src/builder/fanout.rs | New fanout bus + subscribers with lag handling and targeted tests. |
| crates/op-rbuilder/src/builder/continuous/publish.rs | Routes continuous candidate publication through the fanout bus. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+662
to
+668
| let _ = self.flashblock_tx.send(FlashblockEvent { | ||
| fb_payload: Arc::new(fb_payload), | ||
| built: Arc::new(payload), | ||
| attributes_timestamp_secs: config.attributes.timestamp(), | ||
| ws_eligible: !ctx.attributes().no_tx_pool, | ||
| tx_trace_total_txs: info.executed_transactions.len(), | ||
| }); |
Comment on lines
1048
to
1049
| // After this point, all side effects are synchronous. If cancellation wins the race after | ||
| // this check, still publish the local payload so getPayload can include this flashblock. |
Comment on lines
+1053
to
+1057
| let _ = self.flashblock_tx.send(FlashblockEvent { | ||
| fb_payload: Arc::new(fb_payload), | ||
| built: Arc::new(new_payload), | ||
| attributes_timestamp_secs: ctx.attributes().timestamp(), | ||
| ws_eligible: true, |
Comment on lines
+120
to
+126
| let _ = self.flashblock_tx().send(FlashblockEvent { | ||
| fb_payload: Arc::new(fb_payload_delta.clone()), | ||
| built: Arc::new(new_payload.clone()), | ||
| attributes_timestamp_secs: ctx.attributes().timestamp(), | ||
| ws_eligible: true, | ||
| tx_trace_total_txs: candidate.info.executed_transactions.len(), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Publication side effects (ws publish, p2p forward, engine feedback) now decoupled from the build path.
Every built payload (fallback, flashblock, continuous candidate) is sent once on a broadcast bus (
fanout.rs), consumed by dedicated subscriber tasks with fanout guarantees.PayloadHandlernow only handles payloads received from peers.Changes:
built_*_send_failedcounters from feat(observability): count dropped built-payload channel sends #555 are replaced by per-subscriberws_publish_lagged/p2p_forward_lagged/engine_feedback_laggedcounters.Supersede / Close #518