Skip to content

Add fast_confirmation SSE event (beacon-APIs#598) - #77

Closed
samcm wants to merge 4 commits into
dapplion:fcrfrom
samcm:fcr-event-stream-upstream
Closed

Add fast_confirmation SSE event (beacon-APIs#598)#77
samcm wants to merge 4 commits into
dapplion:fcrfrom
samcm:fcr-event-stream-upstream

Conversation

@samcm

@samcm samcm commented May 13, 2026

Copy link
Copy Markdown

Implements beacon-APIs#598 — a fast_confirmation event on /eth/v1/events?topics=fast_confirmation that fires whenever FCR advances confirmed_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 on has_fast_confirmation_subscribers so 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.

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.
@samcm

samcm commented May 13, 2026

Copy link
Copy Markdown
Author

@dapplion This is purely vibe coded, i barely know rust, but just in case its useful!

samcm added 3 commits May 18, 2026 13:23
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.
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.
@dapplion

dapplion commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Given recent changes to only emit the most recent will implement manually. Thanks for the contribution tho! ethereum/beacon-APIs#611 (review)

@dapplion dapplion closed this Jun 1, 2026
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.

2 participants