File tree Expand file tree Collapse file tree
crates/common/consensus/lean/src
testing/lean-spec-tests/src/types Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -497,13 +497,6 @@ impl LeanState {
497497 if is_target_next_valid_justifiable_slot {
498498 let delta = ( attestation. source ( ) . slot - self . latest_finalized . slot ) as usize ;
499499 if delta > 0 {
500- ensure ! (
501- justifications_map
502- . keys( )
503- . all( |root| root_to_slot. contains_key( root) ) ,
504- "Justification root missing from root_to_slot"
505- ) ;
506-
507500 let mut new_bitlist =
508501 BitList :: with_capacity ( self . justified_slots . len ( ) - delta)
509502 . map_err ( |err| anyhow ! ( "Failed to create BitList: {err:?}" ) ) ?;
@@ -517,6 +510,8 @@ impl LeanState {
517510 }
518511 self . justified_slots = new_bitlist;
519512
513+ // Drop pending tallies for roots that are no longer on the canonical
514+ // finalized window. Roots outside root_to_slot are off-chain here.
520515 justifications_map. retain ( |root, _| match root_to_slot. get ( root) {
521516 Some ( slots) => * slots > attestation. source ( ) . slot ,
522517 None => false ,
Original file line number Diff line number Diff line change @@ -127,22 +127,16 @@ impl TryFrom<State> for LeanState {
127127 . map_err ( |err| anyhow ! ( "Failed to create justifications_roots VariableList: {err}" ) ) ?;
128128
129129 let justifications_validators = {
130- let validator_count = validators. len ( ) ;
131- let total_bits = state. justifications_validators . data . len ( ) * validator_count;
130+ let bits = & state. justifications_validators . data ;
132131
133- let mut bitlist = ssz_types:: BitList :: with_capacity ( total_bits ) . map_err ( |err| {
132+ let mut bitlist = ssz_types:: BitList :: with_capacity ( bits . len ( ) ) . map_err ( |err| {
134133 anyhow ! ( "Failed to create BitList for justifications_validators: {err:?}" )
135134 } ) ?;
136135
137- for ( root_index, validator_list) in
138- state. justifications_validators . data . iter ( ) . enumerate ( )
139- {
140- for & validator_index in validator_list {
141- let flat_index = root_index * validator_count + validator_index as usize ;
142- bitlist. set ( flat_index, true ) . map_err ( |err| {
143- anyhow ! ( "Failed to set bit at flat index {flat_index}: {err:?}" )
144- } ) ?;
145- }
136+ for ( index, & bit) in bits. iter ( ) . enumerate ( ) {
137+ bitlist
138+ . set ( index, bit)
139+ . map_err ( |err| anyhow ! ( "Failed to set bit at index {index}: {err:?}" ) ) ?;
146140 }
147141 bitlist
148142 } ;
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ pub struct State {
161161 pub justified_slots : DataList < bool > ,
162162 pub validators : DataList < Validator > ,
163163 pub justifications_roots : DataList < B256 > ,
164- pub justifications_validators : DataList < Vec < u64 > > ,
164+ pub justifications_validators : DataList < bool > ,
165165}
166166
167167impl < T > DataList < T > {
You can’t perform that action at this time.
0 commit comments