Skip to content

fix(lean): make equal-slot equivocation tie-break deterministic - #1497

Merged
shariqnaiyer merged 1 commit into
ReamLabs:masterfrom
perfogic:feat/lean-equivocation-tiebreak
Jul 10, 2026
Merged

fix(lean): make equal-slot equivocation tie-break deterministic#1497
shariqnaiyer merged 1 commit into
ReamLabs:masterfrom
perfogic:feat/lean-equivocation-tiebreak

Conversation

@perfogic

@perfogic perfogic commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

What was wrong?

Address leanSpec #1181 (issue #1172)

TL;DR:

  • Latest-vote extraction now orders attestations by (slot, attestation_data_root): higher slot wins, and same-slot equivocations pick the larger canonical data root.

Before the implementation, if a validator had two different votes at the same slot, the first one seen stayed as the winner, so the result depended on arrival order.
Specifically, vote arrival order could make honest nodes assign the same equivocator’s weight to different fork branches, causing them to choose different heads.
The fix removes the old arrival-order dependency, so nodes with the same votes resolve the same winner. => Problem solved.

How was it fixed?

  • extract_attestations_from_aggregated_payloads function in ream already sorted by (attestation_data.slot, data_root) => So no changes need.
  • on select_round_based, attestation candidates from available_signed_attestations are sorted by (attestation_data.slot, data_root) through new added function sort_block_attestation_candidates.
  • Four tests are added:
    • test_equal_slot_equivocation_resolves_to_larger_data_root: verifies that same-slot equivocations resolve to the vote with the larger attestation-data root.
    • test_higher_slot_beats_larger_data_root: verifies that a higher-slot vote still wins even if the lower-slot vote has a larger root.
    • test_equivocation_head_independent_of_arrival_order_a_then_b: verifies that fork choice selects the same canonical head when vote A arrives before vote B.
    • test_equivocation_head_independent_of_arrival_order_b_then_a: verifies the same head result when the same votes arrive in the opposite order.

What's to notice

  • our current function latest_known_attestations_provider is not used anywhere, so available_signed_attestations's always empty.

To-Do

@perfogic
perfogic force-pushed the feat/lean-equivocation-tiebreak branch from bd52532 to f06129c Compare July 6, 2026 10:48
@perfogic perfogic self-assigned this Jul 6, 2026
@perfogic
perfogic marked this pull request as ready for review July 6, 2026 11:42
@perfogic
perfogic force-pushed the feat/lean-equivocation-tiebreak branch 2 times, most recently from 1d09a41 to ca092cb Compare July 9, 2026 07:28
Comment thread crates/common/fork_choice/lean/src/store.rs Outdated
@perfogic
perfogic force-pushed the feat/lean-equivocation-tiebreak branch from ca092cb to 4760266 Compare July 10, 2026 03:19

@shariqnaiyer shariqnaiyer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@shariqnaiyer
shariqnaiyer merged commit 85cf400 into ReamLabs:master Jul 10, 2026
26 of 39 checks passed
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.

3 participants