fix: enforce attestation checkpoint ancestry#833
Open
latifkasuli wants to merge 1 commit into
Open
Conversation
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.
Summary
Reject attestations whose checkpoints are slot-ordered but not on the same chain.
This enforces the topology implied by
source <= target <= headin two places:source -> target -> headancestry through the fork-choice store's block treeRoot Cause
validate_attestation()checked that source, target, and head blocks were known and that their checkpoint slots matched the block slots. It did not check that target was actually an ancestor of head, or that source was an ancestor of target.Because fork choice weights by
attestation_data.head.root, accepting a known but siblingheadlets a validator present a canonicalsource -> targetFFG vote while injecting LMD-GHOST weight into a non-canonical branch._accumulate_ancestor_weights()walks upward from the attested head and gives weight to that branch's ancestors, so this is a fork-choice vote-splitting vector.attestation_data_matches_chain()is the state-transition complement. Justification is still keyed ontarget.root, so a sibling head does not justify a non-canonical target. Checkingheadthere keeps counted votes internally consistent: no decoupled FFG vote on the canonical chain with an LMD head on a sibling fork.The two checks use different reference frames intentionally: gossip validation has the fork-choice store tree available, while state transition validates against the linear canonical
historical_block_hashesview.Validation
uv run pytest tests/lean_spec/spec/forks/lstar/forkchoice tests/lean_spec/spec/forks/lstar/state/test_state_process_attestations.py tests/lean_spec/spec/forks/lstar/test_block_production.py -q --no-covuv run --group test fill tests/consensus/lstar/fc/test_gossip_attestation_validation.py tests/consensus/lstar/fc/test_gossip_aggregated_attestation_validation.py tests/consensus/lstar/state_transition/test_justification.py --fork=Lstar --clean -quv run --group lint ruff check src/lean_spec/spec/forks/lstar/fork_choice.py src/lean_spec/spec/forks/lstar/state_transition.py tests/lean_spec/spec/forks/lstar/forkchoice/test_validate_attestation.py tests/lean_spec/spec/forks/lstar/state/test_state_process_attestations.pyuv run --group lint ruff format --check src/lean_spec/spec/forks/lstar/fork_choice.py src/lean_spec/spec/forks/lstar/state_transition.py tests/lean_spec/spec/forks/lstar/forkchoice/test_validate_attestation.py tests/lean_spec/spec/forks/lstar/state/test_state_process_attestations.pyuv run --group lint ty check src/lean_spec/spec/forks/lstar/fork_choice.py src/lean_spec/spec/forks/lstar/state_transition.py tests/lean_spec/spec/forks/lstar/forkchoice/test_validate_attestation.py tests/lean_spec/spec/forks/lstar/state/test_state_process_attestations.pygit diff --check