Repository navigation
fix(p2p): park votes for a block still importing, and check them again once it lands - #899
Open
MegaRedHand wants to merge 4 commits into
Open
MegaRedHand wants to merge 4 commits into
MegaRedHand wants to merge 4 commits into
Conversation
…n once it lands
A subnet attestation or aggregate whose vote block is not stored yet, or has
no cached post-state yet, was reported Ignore(UnknownBlock/StateUnavailable)
at once. Validators vote as soon as the block reaches them, so the first votes
for every block arrive while this node is still waiting for its columns or
running its state transition, and all of them were dropped: not relayed, not
pooled for an aggregator here, and never received again, since every peer
sends the same message id.
Such a vote is now parked under the voted block's root with its verdict
withheld, so gossipsub keeps holding the message. The chain actor's import
sends BlockChainToP2P::block_state_ready once the post-state is cached, and
p2p runs the parked votes' stateful checks again, in blocking batches of 64
on one permit each, reporting whatever they answer. This is lighthouse's
reprocess queue; the specification allows it.
Bounds: one retry per vote; 16,384 parked at most (lighthouse's cap); a vote
still parked 2.5 s after arriving gets its first verdict, inside gossipsub's
3.5 to 4.2 s window. A root announced just before its vote's verdict reaches
the actor is remembered (last 64 roots), so that vote is checked again at
once rather than waiting out its deadline.
New metrics: lean_beacon_gossip_parked_votes_total{kind,result} and
lean_beacon_gossip_parked_votes.
…rked aggregates Review round 1 on #899: - A released root started every batch at once, each taking a permit from the attestation pool with try_acquire. At the cap that is 256 batches against 128 permits: the batches past the last permit were ignored as overloaded, and the votes arriving meanwhile found no permit either, the loss parking is there to prevent. Rechecks now run on a pool of their own (RECHECK_PERMITS, 32, pool="recheck"), and a batch waits for a permit rather than failing without one. - A vote's deadline was checked once, when its batch was spawned. It is now checked again right before each vote's turn, so one reached too late (after a long wait for a permit, or a slow batch) gets its first verdict, which can still reach gossipsub, instead of a second that cannot. "rechecked" now counts only votes whose checks ran again. - The cap counted votes alone, and an electra aggregate parked before its signature check can carry 16 KiB of bits, so junk aggregates naming roots that never import could keep about 256 MiB resident. Aggregates now have a cap of their own, MAX_PARKED_AGGREGATES (2,048, two slots of an honest network's), about 32 MiB at most. - A missing post-state was read as "still importing", but it also means a block imported earlier whose state has left the cache, for which no release ever comes. When the block has a stored state, the first check runs once more at once and the vote is not parked. That also covers a state that landed while the check ran. - Tests: the aggregate cap, and a recheck that never parks again and keeps its first outcome once past its deadline.
Review round 2 on #899: - Round 1's has_state probe ran outside guarded. has_state panics on a storage error (its reads expect rather than return one), so a failing read would have unwound the blocking task with no verdict sent, and gossipsub would have held the message until its cache evicted it. The probe and the second check now run inside the same guarded closure as the first, so a panic there is Ignore(Internal) like any other. - A batch of rechecked votes was timed under its votes' own kind, mixing 64-check batches with single first checks in the blocking-task histograms. Batches are timed under beacon_attestation_recheck and beacon_aggregate_and_proof_recheck. - The deadline test compared against a literal 5 * 700 ms. Gossipsub's heartbeat and history length are now named constants (GOSSIPSUB_HEARTBEAT, GOSSIPSUB_HISTORY_LENGTH) that build_swarm and the test both read. - Docs: docs/metrics.md says which votes the two ignore reasons count, that rechecked/expired include votes checked again at once, and the recheck timing labels; docs/beacon_wire.md and CLAUDE.md give the aggregate cap, the recheck pool and the evicted-state rule. Not changed: a smaller cap for UnknownBlock votes. Those include votes for a block held in memory while its columns arrive, the case this PR is for, and the shared cap matches lighthouse's with no regression against main.
MegaRedHand
added a commit
that referenced
this pull request
Nov 27, 2026
…n once it lands (#899) Port of #899 (main) onto pq-devnet-0: a subnet attestation or aggregate whose first stateful check answers Ignore(UnknownBlock | StateUnavailable) is parked under the voted block's root with its verdict withheld, and checked again once the chain actor's import announces that root's post-state (BlockChainToP2P::block_state_ready). Bounded by a 2.5 s deadline, one retry, 16,384 parked votes and 2,048 parked aggregates. PQ: subnet attestations park too (parkable_root matches PqValidated::Attestation). On pq-devnet-0 geth-1 ignored 1.3% of all votes as unknown_block, about three a slot, and 28 of 46 of our aggregates left votes out (2.3 on average) while Dora saw almost none of them arrive late. PQ aggregates do not park: each carries a ~180 KiB proof, and they go out more than half a slot after their block.
MegaRedHand
added a commit
that referenced
this pull request
Nov 27, 2026
…n once it lands (#899) Validators vote as soon as the slot's block reaches them, so the first subnet attestations and aggregates for a block reached this node while it was still importing that block. Their stateful checks read the voted block's cached post-state and answered Ignore(StateUnavailable) or Ignore(UnknownBlock), and the vote was lost for good: not relayed, not pooled, and no later copy, since every peer sends the same message id. On an 8-participant devnet that was 5 to 8% of the subnet votes each ethlambda node received; lighthouse, prysm and teku lost none. Such a vote is now parked under the voted block's root with its verdict withheld (beacon/parked_votes.rs, lighthouse's reprocess queue), and the chain actor's import sends block_state_ready(root), on which p2p checks the root's parked votes once more and settles, reports and forwards each as usual. Rechecks run in 64-vote batches on a permit pool of their own (32, pool="recheck"), so a big release takes no permit from the votes arriving meanwhile. A vote is parked once, for at most 2.5 s (inside gossipsub's ~4.2 s cache window), with at most 16,384 parked and 2,048 of them aggregates; past either it gets its first verdict at once. A vote whose block was imported but whose state has left the cache is checked again at once and not parked, since no release would come for it. New metrics count parked, full, rechecked and expired votes, and recheck batches are timed under their own labels. Applied as the PR's own diff against its merge base with main (4989419), since its branch carries main merges. It applied without conflicts.
MegaRedHand
added a commit
that referenced
this pull request
Nov 27, 2026
…ork (#902) The validator client had no network config of its own: it ran on whatever chain the first beacon node to answer was on, created its slashing protection record on that chain, and followed an outdated fork schedule without a word when every node served one. ethlambda validator now takes an optional --network (mainnet, sepolia, hoodi, plataberget, or a directory of published network files), resolved by the same network module ethlambda beacon uses. With no flag nothing changes. The network holds the chain's identity: a node whose preset, genesis time, genesis validators root, slot duration or genesis fork version differs from it is never the reference and is skipped like any incompatible node, and startup fails once every configured node has answered and none is on the network (it waits while one has not answered). The fork schedule only warns, once an epoch, naming both values, since either side can be the stale one: the beacon nodes, or --network's config (this binary's for a built-in network, the directory's config.yaml otherwise). The named network is only compared against; the client still runs on the reference node's config, and list order still picks the reference among the nodes on the network. Applied as the PR's own diff against its merge base with main (4989419), since its branch carries main merges, on top of #899. Resolved against #871, #873, #874 and #877: ValidatorConfig and its construction keep #874's distributed and #877's shut_down_when_slashed next to this PR's network, with --broadcast where nightly has it; the imports keep #871's GraffitiFile, and drop DEFAULT_GAS_LIMIT as #873 did; chain_check::run takes #873's settings and this PR's network, and each round hands over the gas limit schedule before the schedule warning.
This branch has not been deployed
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.
Problem
Validators vote as soon as the slot's block reaches them, so the first votes for every block reach this node while it is still importing that block: waiting for its custody columns, or running its state transition. The
beacon_attestation_{subnet_id}andbeacon_aggregate_and_proofstateful checks read the voted block's own cached post-state, so in that window they answerIgnore(StateUnavailable), orIgnore(UnknownBlock)if the block is not stored at all. The vote was reported at once and was then lost for good:Measured on an 8-participant kurtosis devnet (lighthouse, prysm, teku and ethlambda BNs; fulu; 12 s slots; imports of ~130 ms) by recording
single_attestationevents from all eight BNs for 63 slots:That is 5 to 8% of every subnet vote each ethlambda node received, and
lean_beacon_gossip_validation_total{reason="state_unavailable"}matched the count. No participation was lost there, only because other aggregators covered each committee.What lighthouse and prysm do
57c2abc1): anUnknownHeadBlockattestation or aggregate goes into the reprocess queue with no verdict sent to gossipsub. It stays there up to 12 s, with at most 16,384 queued, and is released on that root'sBlockImportedto run the checks again, so an accepted vote propagates as the original message. It also asks sync to fetch the block. A block counts as known once it is in fork choice or inearly_attester_cache, which holds a block that has its data and its post-state but is not yet written to the database.e625ddd1): returnsValidationIgnoreand parks the vote: at most 32,768, dropped after an epoch. After importing the block it checks the parked votes in a batch, pools them and publishes them itself. It also asks the votes' senders for the block by root.This change: lighthouse's shape
Ignore(UnknownBlock | StateUnavailable),verdict::receive_verdictparks it under the voted block's root (beacon/parked_votes.rs) and reports nothing yet. AStateUnavailablefor a block that has a stored state (imported earlier, its state since evicted from the cache, or landed during the check) is checked once more at once and not parked, since no release would come for it. The rules crate is unchanged.Importedarm, next todrain_sidecars_awaiting_parent, the chain actor sends the newBlockChainToP2P::block_state_ready(root)(beacon only). p2p runs the stateful checks of the root's parked votes again, in blocking batches of 64 votes of one kind. The batches run on a permit pool of their own (RECHECK_PERMITS, 32,pool="recheck"), so a released burst takes no permit from the votes arriving meanwhile, and a batch waits for a permit rather than coming backIgnore(Overloaded). Each vote's deadline is checked again right before its turn. Each vote then goes through the usualsettle_message,reportandforward.lean_beacon_gossip_parked_votes_total{kind,result}, withresultone ofparked,full,recheckedorexpired.lean_beacon_gossip_parked_votes, a gauge of how many are parked now.lean_beacon_gossip_validation_secondsfor these two kinds now includes the wait.docs/beacon_wire.md,docs/metrics.mdandCLAUDE.md.Left out
state_unavailable(the block was already stored), against 3unknown_blockan hour. A lookup per unverified vote is also a fetch amplifier, so it is worth its own change.payload_envelope_unseenis still reported at once here.Overlap
#771 (batched gossip checks) rewrites the same stateful-check dispatch and keeps both
Ignores, so whichever merges second has to bring parking across.Testing
receive_verdict(what parks and what is reported at once, the immediate recheck, the sweep reporting expired votes), and forrecheck(a recheck never parks again, and keeps its first outcome once past its deadline).beacon-spec-tests) that importing a gloas block sends it for that root.state_unavailabledrops to near zero and thatlean_beacon_gossip_verdict_expired_totalstays at zero.