fix: ignore stale finalized payloads in fork choice#820
Open
latifkasuli wants to merge 1 commit into
Open
Conversation
492992f to
02cd39b
Compare
02cd39b to
94ee5a1
Compare
tcoratger
reviewed
Jun 2, 2026
Collaborator
tcoratger
left a comment
There was a problem hiding this comment.
Thanks a lot!
Please let me know when the PR is ready for review?
I think that you PRs are on draft, please put them as ready for review when you feel they are ready so that someone can have a look :)
Comment on lines
+437
to
+446
| def _fork_choice_payloads( | ||
| self, | ||
| store: LstarStore, | ||
| aggregated_payloads: dict[AttestationData, set[SingleMessageAggregate]], | ||
| ) -> dict[AttestationData, set[SingleMessageAggregate]]: | ||
| return { | ||
| attestation_data: proofs | ||
| for attestation_data, proofs in aggregated_payloads.items() | ||
| if attestation_data.target.slot > store.latest_finalized.slot | ||
| } |
Collaborator
There was a problem hiding this comment.
Can we avoid having a super small function like this in the spec? I think from a readability standpoint (even if this is a bit of code duplication), in the spec context, this is better to just inline the logic at the 3 appropriate locations?
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
Fixes a fork-choice vote extraction edge case where a stale aggregated payload targeting an already-finalized block could mask the same validator's still-relevant vote above
latest_finalized.Fork-choice consumers now filter payloads whose target slot is at or below the finalized slot before doing the per-validator latest-message selection. The general
extract_attestations_from_aggregated_payloads()decoder remains unchanged so block import, gossip, and pool validation can still inspect payloads before pruning.Root Cause
Fork choice extracts one latest attestation per validator by comparing
AttestationData.slot. If a validator has:the stale payload previously won the latest-message comparison. Since fork-choice weight accumulation stops at
latest_finalized, that selected stale payload contributes no weight above the finalized boundary, effectively hiding the fresh vote.Validation
weights == {}uv run pytest tests/lean_spec/spec/forks/lstar/forkchoice/test_compute_block_weights.py -k stale_latest_message -q --no-covuv run pytest tests/lean_spec/spec/forks/lstar/forkchoice/test_store_attestations.py::test_on_block_processes_multi_validator_aggregations -q --no-covuv run pytest tests/lean_spec/spec/forks/lstar/forkchoice/test_compute_block_weights.py tests/lean_spec/spec/forks/lstar/forkchoice/test_store_pruning.py tests/lean_spec/spec/forks/lstar/forkchoice/test_attestation_target.py tests/lean_spec/spec/forks/lstar/forkchoice/test_store_attestations.py -q --no-covuv run --group test fill tests/consensus/lstar/fc/test_store_pruning.py::test_finalization_prunes_stale_aggregated_payloads --fork=Lstar --clean -quv run pytest tests/lean_spec/spec/forks/lstar/forkchoice/test_validator.py tests/lean_spec/spec/forks/lstar/state/test_state_aggregation.py -q --no-covuv run --group lint ruff check src/lean_spec/spec/forks/lstar/fork_choice.py tests/lean_spec/spec/forks/lstar/forkchoice/test_compute_block_weights.pyuv run --group lint ruff format --check src/lean_spec/spec/forks/lstar/fork_choice.py tests/lean_spec/spec/forks/lstar/forkchoice/test_compute_block_weights.pyuv run --group lint ty check src/lean_spec/spec/forks/lstar/fork_choice.py tests/lean_spec/spec/forks/lstar/forkchoice/test_compute_block_weights.pygit diff --check