Commit e9faefa
fix(forks/lstar): harden build_block filter against crashes and duplicates (leanEthereum#718)
* fix(forks/lstar): harden build_block filter against crashes and duplicates
Reorder filters so chain-match runs first.
A source slot beyond the candidate slot no longer crashes
the producer with IndexError on the justified-slot bitfield.
Restore the processed_att_data dedup guard.
Without it, attestations whose target fails to justify get
re-selected on every fixed-point iteration and appended as
duplicates to the candidate block body.
Add state-transition parity filters with a genesis-anchor bypass.
Target must be strictly after source.
Target must fall on a slot the state transition accepts.
Without these, gossip-pool entries the STF will silently drop
can starve real votes out of MAX_ATTESTATIONS_DATA.
Make the chain-match helper a staticmethod.
Swap its parameter order to (data, chain).
Widen its chain parameter to Sequence[Bytes32] so callers can
pass plain lists without reconstructing SSZ list instances.
Use full-Checkpoint equality in the new test per testing-style.md.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(forks/lstar): drop STF-parity filters that strip fork-choice signal
Remove two filters added in the previous commit:
- target.slot > source.slot
- target.slot.is_justifiable_after(current_finalized_slot)
Both are enforced by the state transition, but the state transition
is not the only consumer of body attestations. Block processing also
merges every body attestation into the known aggregated payload pool,
which is what fork choice reads for head votes.
Filtering these entries at production time hides head votes that the
producer's chain would otherwise have seen. The MAX_ATTESTATIONS_DATA
cap test and the deep-fork-split / reorg tests rely on this behavior:
without the filters they pass, with them they shrink the body or
move the head away from the expected subtree.
The chain-match-first reorder, the processed_att_data dedup guard,
the target-already-justified check with its genesis self-vote bypass,
and the helper signature changes are unaffected and remain.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 00556d8 commit e9faefa
2 files changed
Lines changed: 120 additions & 119 deletions
File tree
- src/lean_spec/forks/lstar
- tests/lean_spec/forks/lstar/forkchoice
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
357 | 358 | | |
358 | | - | |
359 | | - | |
360 | 359 | | |
| 360 | + | |
361 | 361 | | |
362 | | - | |
| 362 | + | |
363 | 363 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
368 | 368 | | |
369 | | - | |
370 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
371 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
372 | 378 | | |
373 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
374 | 384 | | |
375 | 385 | | |
376 | 386 | | |
377 | 387 | | |
378 | 388 | | |
379 | 389 | | |
| 390 | + | |
| 391 | + | |
380 | 392 | | |
381 | 393 | | |
382 | 394 | | |
| |||
472 | 484 | | |
473 | 485 | | |
474 | 486 | | |
475 | | - | |
476 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
477 | 494 | | |
478 | | - | |
| 495 | + | |
479 | 496 | | |
480 | 497 | | |
481 | 498 | | |
| |||
676 | 693 | | |
677 | 694 | | |
678 | 695 | | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
683 | 700 | | |
684 | 701 | | |
685 | 702 | | |
686 | 703 | | |
687 | 704 | | |
688 | | - | |
689 | | - | |
690 | | - | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
691 | 711 | | |
692 | | - | |
693 | | - | |
| 712 | + | |
| 713 | + | |
694 | 714 | | |
695 | 715 | | |
696 | 716 | | |
| |||
701 | 721 | | |
702 | 722 | | |
703 | 723 | | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
708 | 728 | | |
709 | 729 | | |
710 | 730 | | |
711 | 731 | | |
712 | 732 | | |
713 | | - | |
714 | | - | |
715 | | - | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
716 | 739 | | |
717 | 740 | | |
718 | 741 | | |
719 | | - | |
720 | | - | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
721 | 745 | | |
722 | 746 | | |
723 | 747 | | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
730 | 764 | | |
731 | 765 | | |
732 | 766 | | |
| |||
763 | 797 | | |
764 | 798 | | |
765 | 799 | | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
766 | 805 | | |
767 | 806 | | |
768 | 807 | | |
| |||
Lines changed: 44 additions & 82 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 1 | + | |
10 | 2 | | |
11 | 3 | | |
12 | 4 | | |
| |||
28 | 20 | | |
29 | 21 | | |
30 | 22 | | |
31 | | - | |
32 | | - | |
| 23 | + | |
33 | 24 | | |
34 | | - | |
| 25 | + | |
35 | 26 | | |
36 | | - | |
37 | | - | |
| 27 | + | |
| 28 | + | |
38 | 29 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
64 | 36 | | |
65 | 37 | | |
66 | 38 | | |
67 | 39 | | |
68 | 40 | | |
| 41 | + | |
69 | 42 | | |
70 | 43 | | |
71 | 44 | | |
72 | 45 | | |
73 | 46 | | |
74 | 47 | | |
75 | | - | |
76 | | - | |
77 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
78 | 51 | | |
79 | 52 | | |
80 | 53 | | |
81 | 54 | | |
82 | | - | |
| 55 | + | |
83 | 56 | | |
84 | 57 | | |
85 | 58 | | |
86 | 59 | | |
87 | | - | |
| 60 | + | |
| 61 | + | |
88 | 62 | | |
89 | 63 | | |
90 | 64 | | |
| |||
100 | 74 | | |
101 | 75 | | |
102 | 76 | | |
103 | | - | |
104 | | - | |
| 77 | + | |
| 78 | + | |
105 | 79 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
109 | 83 | | |
110 | 84 | | |
111 | 85 | | |
| |||
121 | 95 | | |
122 | 96 | | |
123 | 97 | | |
124 | | - | |
| 98 | + | |
125 | 99 | | |
126 | | - | |
127 | | - | |
128 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
129 | 103 | | |
130 | 104 | | |
131 | 105 | | |
| |||
142 | 116 | | |
143 | 117 | | |
144 | 118 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
158 | 122 | | |
159 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
160 | 131 | | |
161 | | - | |
162 | | - | |
163 | | - | |
| 132 | + | |
164 | 133 | | |
165 | 134 | | |
166 | 135 | | |
167 | 136 | | |
168 | 137 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 138 | + | |
| 139 | + | |
173 | 140 | | |
174 | 141 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 142 | + | |
| 143 | + | |
181 | 144 | | |
| 145 | + | |
| 146 | + | |
182 | 147 | | |
183 | 148 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | 149 | | |
0 commit comments