fix: fetch unknown blocks referenced by attestations#112
Draft
MegaRedHand wants to merge 4 commits intomainfrom
Draft
fix: fetch unknown blocks referenced by attestations#112MegaRedHand wants to merge 4 commits intomainfrom
MegaRedHand wants to merge 4 commits intomainfrom
Conversation
Resolve conflict: adapt contains_block → get_block_header after storage header/body split refactor.
Conflicts resolved: - crates/blockchain/src/lib.rs: kept main's iterative queue-based block processing (VecDeque + process_or_pend_block + collect_pending_children) and integrated PR's pending attestation system on top. pending_blocks uses main's HashMap<H256, HashSet<H256>> type (block data in DB). process_pending_attestations called after collect_pending_children in process_or_pend_block. - docs/checkpoint_sync.md: kept main's reviewed version.
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.
Motivation
Closes #91
Currently, attestations that reference blocks we don't have are rejected outright. This causes attestation loss during normal operation — when blocks arrive slightly out of order or when a node is catching up, valid attestations get discarded simply because the referenced block hasn't been processed yet.
This is particularly impactful during sync: a node receiving attestations before their referenced blocks loses fork choice weight that could help it converge to the correct head faster.
Description
Replace the "reject unknown" behavior with a pending attestation queue. When an attestation references a block we don't have (target or head), buffer it and retry processing after the missing block arrives.
How it works
Queuing:
Processing:
on_gossip_attestationflow (including signature verification)Cleanup (three paths):
DoS protection
Pre-validation filters garbage before queuing: slot range check, known source, non-finalized target, valid validator ID.
Integration with block processing
Pending attestations are processed inside
process_or_pend_block, aftercollect_pending_children. The pending attestation system is fully independent of the pending block system — it only touchesself.pending_attestationsandself.store, not the block processing queue.How to test
The feature exercises a code path that requires out-of-order block/attestation arrival, which the current spec test fixtures don't cover. Full validation requires a multi-client devnet where attestations routinely arrive before their referenced blocks.