fix(lean): make equal-slot equivocation tie-break deterministic#1497
Open
perfogic wants to merge 1 commit into
Open
fix(lean): make equal-slot equivocation tie-break deterministic#1497perfogic wants to merge 1 commit into
perfogic wants to merge 1 commit into
Conversation
bd52532 to
f06129c
Compare
f06129c to
1d09a41
Compare
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.
What was wrong?
Address leanSpec #1181 (issue #1172)
TL;DR:
(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_payloadsfunction inreamalready sorted by(attestation_data.slot, data_root)=> So no changes need.select_round_based, attestation candidates fromavailable_signed_attestationsare sorted by(attestation_data.slot, data_root)through new added functionsort_block_attestation_candidates.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
latest_known_attestations_provideris not used anywhere, soavailable_signed_attestations's always empty.To-Do