Skip to content

Hold a Waggle peer to one aggregate per slot and aggregator (announce-and-pull) - #988

Merged
pablodeymo merged 3 commits into
pq-devnet-2-waggle-announce-pullfrom
waggle-duplicate-aggregate-id-announce-pull
Dec 5, 2026
Merged

pablodeymo merged 3 commits into
pq-devnet-2-waggle-announce-pullfrom
waggle-duplicate-aggregate-id-announce-pull

Conversation

@pablodeymo

@pablodeymo pablodeymo commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

The same commit as #987, cherry-picked onto the announce-and-pull branch. The two branches differ only in PUSH_PHASE / REQUEST_DELAY and one CLAUDE.md sentence, and the diff between the two PR heads is exactly that. Tests were run again on this branch with its constants.

What

EIP-8529's draft gained a validation rule on 04.12 (ethereum/EIPs#12792, commit b541c27f85):

[REJECT] No other AggregateID with the same slot and aggregator_index has been received from the sender. The node has received such an AggregateID when a previous message carrying it passed the checks above.

This implements it in the Waggle dissemination service, in both directions.

Receiving. The service remembers the first aggregate each peer sent a message about, per slot and aggregator. A message from that peer about another one is dropped, before the header of another aggregate we may hold is looked at, as the EIP orders the checks. The record is kept by peer, not by connection, so reconnecting does not reset it, and is dropped with the slot's tracking window.

Sending. Once the node holds the header of an aggregate (a peer's header passed, or it publishes its own), it sends nothing about that aggregate to the peers that sent it another one of the slot and aggregator. It may have requested chunks of theirs from them, and they would drop and penalize the second ID. Those peers have no use for it: a peer only sends messages about an aggregate it holds the header of, or to peers that announced it. A published aggregate is now held before it is pushed, for the same reason.

bound_headerless_aggregates is removed: it let a peer count for the aggregate it named last, and a peer can no longer name a second one.

Penalty

Each such message is dropped and its sender penalized (MidTolerance, waggle_second_aggregate_id), as the EIP's [REJECT] says, and counted in lean_beacon_aggregate_dissemination_second_ids_rejected_total. A node on an earlier draft breaks the rule when an aggregator signs two headers (it requests the one a peer announced, then announces the other to every peer), so such nodes are penalized by this one in that case.

Tests

  • a_peer_sends_one_aggregate_per_slot_and_aggregator: second IDs are dropped with their chunk and header, the peer is penalized for each, other peers and other aggregators are unaffected, reconnecting does not reset the record, and the record goes with the tracking window.
  • a_peer_is_sent_one_aggregate_per_slot_and_aggregator and a_published_aggregate_is_not_sent_to_a_peer_that_named_another: the send side.
  • one_header_is_held_per_slot_and_aggregator: a peer whose first message is dropped because another header is held is still held to that ID.

Each of the three new tests fails when its half of the change is disabled. cargo test -p ethlambda-p2p -p ethlambda-telemetry, cargo fmt --check and make lint pass. Not run on a devnet.

Review follow-up

The AI security review found two gaps, both closed in the last commit:

  • A peer whose first message of a slot and aggregator names another aggregate after the node holds a header was recorded but still sent the held aggregate. It is now kept out of it from that message on.
  • A message of a peer's previous connection, delivered after the node heard of the new one, was dropped before its ID was recorded, so the peer could name another aggregate on the new connection. The message is still ignored, but its ID is recorded (and a second one penalized) like any other.

The same commit fixes the docs build, which failed on _[REJECT]_ in docs/beacon_pq.md.

EIP-8529's draft added a rule (b541c27f85): a message naming a second
AggregateID with the slot and aggregator of one the sender already sent
is dropped, and its sender penalized.

The service now remembers the first aggregate each peer sent a message
about, per slot and aggregator, by peer rather than by connection and
for as long as the slot is tracked. A message of that peer about another
one is dropped before the header of another aggregate we may hold is
looked at, as the EIP orders it. The peer is penalized for the first
such message only (waggle_second_aggregate_id): a peer on an earlier
draft breaks the rule in every announcement when an aggregator signed
two headers.

The node keeps to the rule itself. Once it holds the header of an
aggregate, by a peer's header passing or by publishing its own, it sends
nothing about it to the peers that sent it another aggregate of the slot
and aggregator: it may have requested chunks of theirs from them. A
published aggregate is now held before it is pushed, for that reason.

The rule replaces bound_headerless_aggregates, which let a peer count
for the aggregate it named last: a peer can no longer name a second one.
The sender of a second AggregateID for a slot and aggregator was
penalized for the first such message only. The EIP's REJECT penalizes
the sender of each, so each is penalized now.
@pablodeymo

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

AI security review: 2 finding(s) to check

Reviewed by GPT, Kimi, DeepSeek. A judge model checked every one of the findings against the code.
GLM (error, see the run log), Opus (error, see the run log) did not finish; GPT, Kimi, DeepSeek reviewed the whole PR. Comment /review continue to retry, with a new budget; reviewers that finished are reused.

# Finding Severity Status Found by Where
M2 Peers first naming a conflicting aggregate after a header is held are not excluded from sends low Bug DeepSeek, Kimi (2/3) crates/net/p2p/src/beacon/waggle_aggregates.rs:1881
M1 Reconnect can evade per-peer AggregateID record when a stale message is dropped before recording low Bug DeepSeek (1/3) crates/net/p2p/src/beacon/waggle_aggregates.rs:1208
Details

M2. Peers first naming a conflicting aggregate after a header is held are not excluded from sends (low, logic)

  • Trigger: A peer's first message for a slot and aggregator names aggregate B after this node has already held the header of aggregate A. A later announcement flush, chunk push, subscription event, or reconnect then considers sending A to that peer.
  • Mechanism: The late B message is recorded by note_received_id, after which handle_message returns through IdCheck::OtherHeld. The conflicting peer is only marked banned on A by this one-time iteration in on_header_held, which already ran and therefore could not see the late record. All announcement, push, request, and serve paths rely on that per-aggregate banned flag, so the newly recorded conflict is never applied to A.
  • Impact: The node can continue announcing or pushing A to a peer known to have named B, contrary to the new send-side invariant. A peer holding B drops these messages, wasting its send queue and network bandwidth instead of suppressing them as intended.
  • Judge: A peer's first conflicting ID is recorded even when another aggregate's header is already held, but the OtherHeld branch returns without banning that peer on the held aggregate. The ban is populated only during on_header_held, so later announcements and pushes can still target the peer. Both reports describe this same ordering gap.

M1. Reconnect can evade per-peer AggregateID record when a stale message is dropped before recording (low, logic)

  • Trigger: A peer sends a message carrying AggregateID B on connection C1, then reconnects. A newer connection event (TopicEvent::Opened or PeerSubscribed) for C2 updates self.peers before the delayed C1 TopicEvent::Pieces is processed, so the stale-connection check drops the old pieces event; the peer then sends a different AggregateID on C2.
  • Mechanism: The stale-connection check returns before Message::try_from and handle_message, so note_received_id never sees AggregateID B. Although the field docs and PR intend that records are kept by PeerId so reconnecting cannot reset the first ID, enforcement only operates on messages that reach handle_message; a delayed previous-connection message that arrives after newer connection state is discarded before the record is created.
  • Impact: In this reordering, the peer's first per-(slot, aggregator) ID can be lost across a reconnect, allowing a different ID to be treated as the first. That defeats the new uniqueness rejection/penalty for this case and can let the node track a different aggregate from the same peer after reconnect.
  • Judge: A newer PeerSubscribed event can be processed before queued C1 pieces because the application mailbox has priority. It updates the connection ID, causing C1's message to return before ID recording; a different ID on C2 is then accepted as the first. This bypass affects an unprocessed first message, not an already-recorded ID, which does survive reconnects.

Cost of this review: ~$0.82 of a $30 budget (estimated from token counts).

…uild

Both are from the AI security review of this pull request.

A peer whose first message of a slot and aggregator named another
aggregate after we held a header was recorded but not kept out of the
aggregate we hold: only on_header_held marked such peers, and it had
already run. note_received_id now marks the peer too, so it is sent
nothing more about the held aggregate.

A message of a peer's previous connection that was delivered after we
heard of its new one was dropped before its ID was recorded, so the peer
could name another aggregate on the new connection. The message is
still ignored, but its ID is received like any other.

The docs build failed on `_[REJECT]_`, which the link checker reads as
a link without a target.
@pablodeymo

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

AI security review: 0 finding(s) to check

Reviewed by GPT, Kimi, DeepSeek.
GLM (error, see the run log), Opus (error, see the run log) did not finish; GPT, Kimi, DeepSeek reviewed the whole PR. Comment /review continue to retry, with a new budget; reviewers that finished are reused.

No findings to check.

Cost of this review: ~$0.63 of a $30 budget (estimated from token counts).

@pablodeymo
pablodeymo merged commit c9aebfb into pq-devnet-2-waggle-announce-pull Dec 5, 2026
14 checks passed
@pablodeymo
pablodeymo deleted the waggle-duplicate-aggregate-id-announce-pull branch December 5, 2026 01:25
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.

1 participant