feat(builder): observe beacon node blocks - #9931
Open
krisoshea-eth wants to merge 20 commits into
Open
Conversation
…-events-and-retrieve-fork-correct
…-events-and-retrieve-fork-correct
…-events-and-retrieve-fork-correct
…2-api-02-consume-bn-block-events-and-retrieve-fork-correct # Conflicts: # packages/builder/src/builder.ts
…2-api-02-consume-bn-block-events-and-retrieve-fork-correct # Conflicts: # packages/builder/src/builder.ts
…2-api-02-consume-bn-block-events-and-retrieve-fork-correct
…2-api-02-consume-bn-block-events-and-retrieve-fork-correct
…2-api-02-consume-bn-block-events-and-retrieve-fork-correct
…2-api-02-consume-bn-block-events-and-retrieve-fork-correct
…2-api-02-consume-bn-block-events-and-retrieve-fork-correct
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03d4ebd1b4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…-events-and-retrieve-fork-correct
…-events-and-retrieve-fork-correct
This was referenced Aug 30, 2026
Contributor
|
checked 1d23805, new changes look good |
17 tasks
…-events-and-retrieve-fork-correct
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.
Motivation
The Lodestar Builder needs a source beacon node API path for learning whether its bid was selected without joining libp2p. This PR implements the standard
blockSSE topic plusgetBlockV2as a bounded compatibility path.Beacon APIs #630 and merged Lodestar #9832 also forward the signed winning block directly to the selected external Builder. The main purpose of that flow is to let the Builder help disseminate the block, with timely win notification as an additional benefit. Maintainer input is requested on whether this observer should remain as a compatibility fallback alongside direct delivery.
Changes
blockSSE topic.getBlockV2.BUILDER_INDEX_SELF_BUILD.runOnBlockcallbacks.The existing API-client request timeout is unchanged. This PR bounds attempts and explicit retry delays, not total wall-clock or slot-relative time. Selection and reveal code will own deadline policy.
The observer starts after the existing genesis, configuration, readiness, Gloas, and Builder identity gates. It joins the clock and
BuilderStatusTrackeras a long-lived Builder duty and shares their abort controller.This PR does not add p2p,
block_gossip, canonical-chain filtering, local-bid matching, reveal behavior, metrics, reconnect, replay, restart recovery, multi-BN failover, or a new API endpoint.The observer intentionally evaluates blocks before SELECT-01 registers its first production consumer so this compatibility path remains active and evidenced. Event-time
executionOptimisticcomes from the triggering event, while the response metadata is authoritative for the fork. Terminally failed roots remain consumed until FIFO eviction; REL-01 owns controlled reconciliation. Aggregate retrieval concurrency, observer-specific metrics, and block-root recomputation before financial decisions are tracked in SEC-01, QA-01, and SELECT-01 respectively.API behavior and compatibility
The standard
blockevent contains the slot, beacon block root, and execution optimism.getBlockV2supplies the signed fork-correct block andEth-Consensus-Versionmetadata. Imported non-head blocks remain valid observations, soheadandhead_v2are not substitutes.Lodestar emits
blockafter state transition and fork-choice import. Root lookup checks fork choice for presence, then serves the block from the seen-block input cache or database. This ordering provides no expected Lodestar event-before-block window, but the Beacon API does not require equivalent ordering across clients, so bounded 404 retry remains a cross-client precaution.The implementation audit is recorded in merged Builder docs PR #13. The current direct-Engine planning reconciliation is in draft Builder docs PR #18, and the reproducible real-BN and shutdown evidence is in draft Builder docs PR #19. Implementation evidence was posted to beacon-APIs #599. Marco's open Lodestar PoCs #9854, #9875, #9876, and #9896 explore optional event improvements separately.
The API-02 diff is limited to five Builder files and is based on current
unstable, including merged #9832. The combined code passes the Builder type-check and focused observer tests.Current
unstablebase:1e9a530f98.Specification baseline: consensus-specs
v1.7.0-alpha.14.Project issue: krisoshea-eth/lodestar#12.
Testing
Validated with Node 24.13.0 and pnpm 11.0.0:
git diff --check.Coverage includes SSE wiring, cancellation, startup and shutdown wiring, Gloas and Heze output, exact signed-bid identity, slot consistency, duplicate suppression, bounded retry, decoding and structural failures, FIFO eviction, self-builds, stream failures, and callback isolation.
AI assistance disclosure