Skip to content

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
Pier-Two:test/fc-non-zero-finality-and-equivocation
Open

test: add fork choice and block production test vectors for non-zero finality and equivocation#690
uink45 wants to merge 1 commit intoleanEthereum:mainfrom
Pier-Two:test/fc-non-zero-finality-and-equivocation

Conversation

@uink45
Copy link
Copy Markdown
Contributor

@uink45 uink45 commented Apr 28, 2026

🗒️ Description

Add 3 new test vectors covering attestation target selection, block production, and equivocation handling. All tests use the ForkChoiceTestFiller pattern, generating JSON fixtures for client implementations.

New tests

Test Description
test_attestation_target_selection_after_finality_has_moved Verifies that attestation target selection uses the current finalized slot.

Once 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_stall Verifies that the block builder repeats its inclusion check after each accepted attestation, allowing finality to advance multiple steps within a single block.

Two supermajority aggregates arrive for slot 12, the first with source = block 7 and target = block 10, the second with source = block 10 and target = 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_once Verifies that equivocating validators are counted only once in fork choice.

Validators 0 and 1 sign attestations at slot 4 for both fork_a and fork_b. The store keeps only the first vote per validator when two attestations share a slot, so fork_a holds 3 votes and fork_b holds 2; the head stays on fork_a.

If this rule were relaxed and the later vote overwrote the first, fork_b would 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

🔗 Related Issues or PRs

N/A

✅ Checklist

  • Ran tox checks to avoid unnecessary CI fails:
    uvx tox
  • Considered adding appropriate tests for the changes.
  • Considered updating the online docs in the ./docs/ directory.

…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.
@uink45 uink45 marked this pull request as ready for review April 28, 2026 04:57
@uink45
Copy link
Copy Markdown
Contributor Author

uink45 commented Apr 28, 2026

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

@uink45 uink45 changed the title test: add fork choice test vectors for non-zero finality and equivocation test: add fork choice and block production test vectors for non-zero finality and equivocation Apr 28, 2026
@uink45
Copy link
Copy Markdown
Contributor Author

uink45 commented Apr 28, 2026

Also, I wanted to add test_attestation_target_selection_after_finality_has_moved as a separate test rather than extending existing tests like test_mid_block_finalized_slot_visibility or test_finalization_advances_mid_attestation_processing so it is possible for clients to precisely identify failures.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant