@@ -754,9 +754,8 @@ pub struct BackedCandidate<H = Hash> {
754754 candidate : CommittedCandidateReceipt < H > ,
755755 /// The validity votes themselves, expressed as signatures.
756756 validity_votes : Vec < ValidityAttestation > ,
757- /// The indices of the validators within the group, expressed as a bitfield. May be extended
758- /// beyond the backing group size to contain the assigned core index, if ElasticScalingMVP is
759- /// enabled.
757+ /// The indices of the validators within the group, expressed as a bitfield. Is extended
758+ /// beyond the backing group size to contain the assigned core index.
760759 validator_indices : BitVec < u8 , bitvec:: order:: Lsb0 > ,
761760}
762761
@@ -766,12 +765,10 @@ impl<H> BackedCandidate<H> {
766765 candidate : CommittedCandidateReceipt < H > ,
767766 validity_votes : Vec < ValidityAttestation > ,
768767 validator_indices : BitVec < u8 , bitvec:: order:: Lsb0 > ,
769- core_index : Option < CoreIndex > ,
768+ core_index : CoreIndex ,
770769 ) -> Self {
771770 let mut instance = Self { candidate, validity_votes, validator_indices } ;
772- if let Some ( core_index) = core_index {
773- instance. inject_core_index ( core_index) ;
774- }
771+ instance. inject_core_index ( core_index) ;
775772 instance
776773 }
777774
@@ -814,20 +811,13 @@ impl<H> BackedCandidate<H> {
814811 /// Get a copy of the validator indices and the assumed core index, if any.
815812 pub fn validator_indices_and_core_index (
816813 & self ,
817- core_index_enabled : bool ,
818814 ) -> ( & BitSlice < u8 , bitvec:: order:: Lsb0 > , Option < CoreIndex > ) {
819- // This flag tells us if the block producers must enable Elastic Scaling MVP hack.
820- // It extends `BackedCandidate::validity_indices` to store a 8 bit core index.
821- if core_index_enabled {
822- let core_idx_offset = self . validator_indices . len ( ) . saturating_sub ( 8 ) ;
823- if core_idx_offset > 0 {
824- let ( validator_indices_slice, core_idx_slice) =
825- self . validator_indices . split_at ( core_idx_offset) ;
826- return (
827- validator_indices_slice,
828- Some ( CoreIndex ( core_idx_slice. load :: < u8 > ( ) as u32 ) ) ,
829- ) ;
830- }
815+ // `BackedCandidate::validity_indices` are extended to store a 8 bit core index.
816+ let core_idx_offset = self . validator_indices . len ( ) . saturating_sub ( 8 ) ;
817+ if core_idx_offset > 0 {
818+ let ( validator_indices_slice, core_idx_slice) =
819+ self . validator_indices . split_at ( core_idx_offset) ;
820+ return ( validator_indices_slice, Some ( CoreIndex ( core_idx_slice. load :: < u8 > ( ) as u32 ) ) ) ;
831821 }
832822
833823 ( & self . validator_indices , None )
@@ -2311,60 +2301,35 @@ pub mod tests {
23112301 dummy_committed_candidate_receipt ( ) ,
23122302 vec ! [ ] ,
23132303 initial_validator_indices. clone ( ) ,
2314- None ,
2304+ CoreIndex ( 10 ) ,
23152305 ) ;
23162306
2317- // No core index supplied, ElasticScalingMVP is off.
2318- let ( validator_indices, core_index) = candidate. validator_indices_and_core_index ( false ) ;
2319- assert_eq ! ( validator_indices, initial_validator_indices. as_bitslice( ) ) ;
2320- assert ! ( core_index. is_none( ) ) ;
2321-
2322- // No core index supplied, ElasticScalingMVP is on. Still, decoding will be ok if backing
2323- // group size is <= 8, to give a chance to parachains that don't have multiple cores
2324- // assigned.
2325- let ( validator_indices, core_index) = candidate. validator_indices_and_core_index ( true ) ;
2307+ // No core index supplied.
2308+ candidate
2309+ . set_validator_indices_and_core_index ( initial_validator_indices. clone ( ) . into ( ) , None ) ;
2310+ let ( validator_indices, core_index) = candidate. validator_indices_and_core_index ( ) ;
23262311 assert_eq ! ( validator_indices, initial_validator_indices. as_bitslice( ) ) ;
23272312 assert ! ( core_index. is_none( ) ) ;
23282313
2329- let encoded_validator_indices = candidate. validator_indices . clone ( ) ;
2330- candidate. set_validator_indices_and_core_index ( validator_indices. into ( ) , core_index) ;
2331- assert_eq ! ( candidate. validator_indices, encoded_validator_indices) ;
2332-
2333- // No core index supplied, ElasticScalingMVP is on. Decoding is corrupted if backing group
2314+ // No core index supplied. Decoding is corrupted if backing group
23342315 // size larger than 8.
2335- let candidate = BackedCandidate :: new (
2336- dummy_committed_candidate_receipt ( ) ,
2337- vec ! [ ] ,
2338- bitvec ! [ u8 , bitvec:: order:: Lsb0 ; 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 ] ,
2316+ candidate. set_validator_indices_and_core_index (
2317+ bitvec ! [ u8 , bitvec:: order:: Lsb0 ; 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 ] . into ( ) ,
23392318 None ,
23402319 ) ;
2341- let ( validator_indices, core_index) = candidate. validator_indices_and_core_index ( true ) ;
2320+
2321+ let ( validator_indices, core_index) = candidate. validator_indices_and_core_index ( ) ;
23422322 assert_eq ! ( validator_indices, bitvec![ u8 , bitvec:: order:: Lsb0 ; 0 ] . as_bitslice( ) ) ;
23432323 assert ! ( core_index. is_some( ) ) ;
23442324
2345- // Core index supplied, ElasticScalingMVP is off. Core index will be treated as normal
2346- // validator indices. Runtime will check against this.
2347- let candidate = BackedCandidate :: new (
2348- dummy_committed_candidate_receipt ( ) ,
2349- vec ! [ ] ,
2350- bitvec ! [ u8 , bitvec:: order:: Lsb0 ; 0 , 1 , 0 , 1 ] ,
2351- Some ( CoreIndex ( 10 ) ) ,
2352- ) ;
2353- let ( validator_indices, core_index) = candidate. validator_indices_and_core_index ( false ) ;
2354- assert_eq ! (
2355- validator_indices,
2356- bitvec![ u8 , bitvec:: order:: Lsb0 ; 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 ]
2357- ) ;
2358- assert ! ( core_index. is_none( ) ) ;
2359-
2360- // Core index supplied, ElasticScalingMVP is on.
2325+ // Core index supplied.
23612326 let mut candidate = BackedCandidate :: new (
23622327 dummy_committed_candidate_receipt ( ) ,
23632328 vec ! [ ] ,
23642329 bitvec ! [ u8 , bitvec:: order:: Lsb0 ; 0 , 1 , 0 , 1 ] ,
2365- Some ( CoreIndex ( 10 ) ) ,
2330+ CoreIndex ( 10 ) ,
23662331 ) ;
2367- let ( validator_indices, core_index) = candidate. validator_indices_and_core_index ( true ) ;
2332+ let ( validator_indices, core_index) = candidate. validator_indices_and_core_index ( ) ;
23682333 assert_eq ! ( validator_indices, bitvec![ u8 , bitvec:: order:: Lsb0 ; 0 , 1 , 0 , 1 ] ) ;
23692334 assert_eq ! ( core_index, Some ( CoreIndex ( 10 ) ) ) ;
23702335
0 commit comments