feat(events): add attestation and aggregate chain events#534
feat(events): add attestation and aggregate chain events#534MegaRedHand wants to merge 2 commits into
Conversation
Add the two high-rate topics to the /lean/v0/events stream, emitted only for messages the store accepted (passed data + signature validation) so subscribers see the same votes fork choice does. attestation: a single validator vote seen on gossip, carrying its AttestationData and attester id. The ~3 KB XMSS signature is omitted as too heavy for a high-rate stream. aggregate: a committee-signature aggregate, carrying its AttestationData and participant ids (SNARK proof omitted). Fires at two sites: our own freshly produced aggregate (AggregateProduced) and aggregates accepted from gossip; a node never receives its own aggregate back. The shared broadcast channel capacity is bumped 256 -> 8192 to widen the lag window against the attestation rate, since all topics share one ring buffer. Emission uses the plain no-subscriber-guarded emit.
51184e6 to
5be589f
Compare
🤖 Codex Code Review
No consensus-state-transition, fork-choice, XMSS verification, or SSZ logic changed in this PR; my concerns are confined to the new event-stream behavior. I couldn’t run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Greptile SummaryThis PR adds high-rate attestation and aggregate events to the chain event stream. The main changes are:
Confidence Score: 5/5This looks safe to merge, with a scaling concern for large aggregates and many SSE subscribers.
crates/blockchain/src/events.rs
|
| Filename | Overview |
|---|---|
| crates/blockchain/src/events.rs | Adds both event topics, payload variants, topic mappings, tests, and a larger shared channel. |
| crates/blockchain/src/lib.rs | Emits events after successful gossip validation and after applying locally produced aggregates. |
| crates/net/rpc/src/events.rs | Adds SSE coverage for the nested attestation payload. |
| docs/rpc.md | Documents the new topics, payloads, and shared-channel lag behavior. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
crates/blockchain/src/events.rs:111-114
**Large Aggregates Multiply Serialization Work**
An aggregate can contain up to 4096 participant IDs, producing a large JSON frame that each SSE subscriber serializes independently. With many subscribers or a burst of aggregates, those tasks can fall behind the shared channel and lose unrelated low-rate events such as `head`; consider serializing each event once or using per-topic channels.
Reviews (1): Last reviewed commit: "feat(events): add attestation and aggreg..." | Re-trigger Greptile
🤖 Claude Code ReviewI have what I need to write the review. Review: PR 534 — add
|
Continues the chain-event pub-sub series (#516 / #517 / #518, all merged). Adds the two high-rate topics.
Events added
attestation{ validator_id, data: AttestationData }aggregate{ participants: [u64], data: AttestationData }Both fire only for messages the store accepted (data + signature validation), so subscribers see the same votes fork choice does. A node never receives its own aggregate back over gossip, so
aggregatefires at two sites: the locally producedAggregateProducedpath and the gossip-received path.Design points
capacity / total_event_rate(dominated by the attestation rate), not per-topic. A per-topic split behind theEventBusfacade remains the escape hatch if real devnet rates show the shared window biting — see the note indocs/rpc.md.emit. Consequence: the per-voteAttestationDatais cloned even when nobody is subscribed (the guard only skips the send). If that actor-hot-path cost proves material, a payload-deferral helper can be added in a follow-up.Testing
cargo fmt,cargo clippy -p ethlambda-blockchain -p ethlambda-rpc(clean), blockchain + rpc lib tests pass, includingevents_streams_attestation_with_nested_data(verifies the untaggeddata:nesting over the wire).Independent PR, based off
main. One of three sibling PRs continuing the series — alongside #533 (chain_reorg/safe_target) and #535 (block_gossip), each independently based offmain. They touch overlapping regions ofevents.rs/docs/rpc.md, so whichever two merge later will each need a small conflict rebase.