test: add fork choice and block production test vectors for non-zero finality and equivocation#690
Open
uink45 wants to merge 1 commit intoleanEthereum:mainfrom
Open
Conversation
…tion Add 3 new fork choice test vectors covering attestation target selection, block production, and equivocation handling. All tests use the ForkChoiceTestFiller pattern, generating JSON fixtures for client implementations.
Contributor
Author
|
Hi @tcoratger, I have just created this PR adding three test vectors useful for client implementations aligning with the specification. Let me know if there is any feedback. Thanks |
Contributor
Author
|
Also, I wanted to add I am also aware that two outstanding PRs (#638 and #682) would involve changes to this PR. Happy to rebase and adjust once either is merged. |
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.
🗒️ Description
Add 3 new test vectors covering attestation target selection, block production, and equivocation handling. All tests use the
ForkChoiceTestFillerpattern, generating JSON fixtures for client implementations.New tests
test_attestation_target_selection_after_finality_has_movedOnce slot 1 is finalized and slot 7 is the latest justified block, the store should return block 7 as the attestation target at slots 9, 10, and 11.
If the walkback used genesis instead of the current finalized slot, the returned target could fall behind the latest justified block, and any vote using that target would be silently rejected during state transition.
test_block_builder_recovers_finality_after_non_zero_boundary_stallTwo supermajority aggregates arrive for slot 12, the first with
source = block 7andtarget = block 10, the second withsource = block 10andtarget = block 11. The second is only valid after the first is included, since block 10 becomes justified only once the first is processed.Without this loop, only the first aggregate is included and finality stalls at slot 7 instead of advancing to slot 10.
test_same_slot_equivocating_attesters_count_onceValidators 0 and 1 sign attestations at slot 4 for both
fork_aandfork_b. The store keeps only the first vote per validator when two attestations share a slot, sofork_aholds 3 votes andfork_bholds 2; the head stays onfork_a.If this rule were relaxed and the later vote overwrote the first,
fork_bwould jump to 4 votes and become the head. Without it, equivocators could change their effective vote after observing the network's response, manipulating fork choice via gossip timing.Spec lines covered per test
test_attestation_target_selection_after_finality_has_moved: forkchoice/store.py#L1184-L1197, containers/slot.py#L30-L75test_block_builder_recovers_finality_after_non_zero_boundary_stall: state/state.py#L676-L727, state/state.py#L425-L430, state/state.py#L514-L523, state/state.py#L539-L545, forkchoice/store.py#L1299-L1347test_same_slot_equivocating_attesters_count_once: forkchoice/store.py#L594-L601, forkchoice/store.py#L685-L719🔗 Related Issues or PRs
N/A
✅ Checklist
toxchecks to avoid unnecessary CI fails:uvx tox