Add fast_confirmation SSE event (beacon-APIs#598) - #77
Closed
samcm wants to merge 4 commits into
Closed
Conversation
Emits a `fast_confirmation` event on /eth/v1/events?topics=fast_confirmation
whenever FCR advances confirmed_root. Payload matches the spec:
data: {"block": "0x...", "slot": "12345"}
Implementation:
- common/eth2: SseFastConfirmation struct, EventKind + EventTopic variants,
Display + FromStr + from_sse_bytes wiring.
- beacon_chain/events.rs: broadcast channel + subscribe/has_subscribers.
- canonical_head.rs: registers the event when confirmed_root != old_confirmed
and we have an in-fork-choice proto_array slot for the new root.
- http_api: subscribes the new topic onto the SSE stream.
Gated on has_fast_confirmation_subscribers() so it costs nothing when
no client is subscribed.
Author
|
@dapplion This is purely vibe coded, i barely know rust, but just in case its useful! |
Each fast_confirmation event now carries a 'chain' field containing all blocks newly confirmed by this advancement, ordered oldest-to-newest. Consumers can act on every confirmed block without maintaining their own parent tree of unconfirmed blocks.
This reverts commit 32e35b4.
When FCR advances confirmed_root by more than one block in a single pass (e.g. after a slot where it couldn't reach quorum in time), walk the ancestors from the previous confirmed_root to the new one and register one event per block, oldest-to-newest. Keeps the spec payload shape unchanged — consumers just see N events instead of needing a chain tree to fill the gap.
Owner
|
Given recent changes to only emit the most recent will implement manually. Thanks for the contribution tho! ethereum/beacon-APIs#611 (review) |
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.
Implements beacon-APIs#598 — a
fast_confirmationevent on/eth/v1/events?topics=fast_confirmationthat fires whenever FCR advancesconfirmed_root. Payload follows the spec verbatim:{"block": "0x...", "slot": "N"}.When FCR advances over more than one slot in a single pass (e.g. a late block missed quorum in slot N, then slot N+1's attestations confirm both), we walk the ancestors from the previous confirmed_root to the new one and fire one event per block in chronological order, so consumers see every confirmed slot without having to maintain their own tree of unconfirmed blocks. Walk is bounded to 4096 ancestors as a safety cap for the pruned-old-root edge case.
Registered inside the existing FCR OK branch in
canonical_head.rs(gated onhas_fast_confirmation_subscribersso it costs nothing when nobody's listening), with the usual EventTopic/EventKind/broadcast-channel/http_api plumbing. Deployed on a mainnet observer node and confirmed firing every slot.