feat: add sequencer/rpc mode for flashblock preconfirmations#214
feat: add sequencer/rpc mode for flashblock preconfirmations#214fridrik01 wants to merge 5 commits intorezbera/use-modular-flashblocksfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
26dfe7d to
1ddecc8
Compare
This PR adds flashblock preconfirmation support to bera-reth. It supersedes #202 and #214 which depended on an upstream reth PR ([paradigmxyz/reth#20122](paradigmxyz/reth#20122)) for the consumer plumbing. That created a hard dependency on an external merge timeline, and the upstream PR was ultimately closed after reth removed the optimism directory. This PR implements the entire pipeline natively within bera-reth so that all preconf and flashblock logic now lives entirely within bera-reth with no external dependencies or forks. In the preconf system, a node can run as either a sequencer (produces flashblocks) or an RPC consumer (subscribes to them), controlled by CLI flags. ## Sequencer A sequencer node builds blocks and streams progress over WebSocket. During block building, the payload builder executes transactions from the mempool in a loop and every 200 ms publishes a signed flashblock containing the transactions added since the last emission. When the engine calls `getPayload`, the deadline expires, or the gas limit is hit, the loop exits and a final flashblock is emitted with `is_last: true`. Each flashblock is BLS-signed over a message binding it to a specific chain, block number, payload ID, and index — not just the diff — so consumers can authenticate the stream without trusting the transport. The sequencer does not include computed roots (state root, receipts root) in the diff per BRIP-0007; consumers reconstruct those locally. Flags: `--sequencer-enabled`, `--flashblock-signing-key <path>`, `--flashblock-ws-addr <addr>` (default `0.0.0.0:8548`), `--flashblock-interval-ms <ms>` (default `200`). ## RPC consumer An RPC node connects to a sequencer's WebSocket endpoint (`--flashblocks-url <URL>`), receives the flashblock stream, assembles incoming diffs into in-progress block state, and re-executes transactions locally to compute state. The Eth JSON-RPC layer is then overridden so that methods like `eth_getTransactionReceipt`, `eth_getBlockByNumber`, `eth_call`, and `eth_gasPrice` serve flashblock-derived data for `latest` and `pending` queries. A staleness check ties flashblock data to the current canonical tip, preventing stale results during reorgs. The WebSocket client handles both raw JSON and brotli-compressed messages and automatically reconnects on disconnect. State root computation is deferred until near the end of the block time window to avoid redundant work on intermediate flashblocks. ## Test plan - See test plan in berachain/beacon-kit#3005
|
Replaced with #228 |
This PR adds flashblock support to bera-reth and introduces two modes:
Sequencer mode (
--sequencer-enabled)--flashblock-signing-key <path>Path to BLS secret key file (required)--flashblock-ws-addr <addr>WebSocket bind address (default:0.0.0.0:8548)--flashblock-interval-ms <ms>Emission interval (default:200)The payload builder runs a loop that (as in line with preconf notion doc):
--builder.deadline)Each flashblock contains:
Also, a single publisher broadcasts to all connected WebSocket subscribers.
RPC consumer mode (--flashblocks-url )
RPC nodes connect to a sequencer's WebSocket endpoint and subscribe to flashblocks. Incoming flashblocks are processed and used to override the Eth JSON-RPC layer so that latest and pending queries reflect sub-block state. Blocks, transaction counts, receipts, state, gas price, and call execution all serve in-progress flashblock data without the node needing to run as a sequencer.
Test plan
See test plan in berachain/beacon-kit#3005