@@ -57,6 +57,7 @@ use sp_runtime::transaction_validity::{
5757use sp_runtime:: {
5858 generic:: DigestItem ,
5959 traits:: { One , SaturatedConversion , Saturating , Zero } ,
60+ ConsensusEngineId ,
6061} ;
6162use sp_std:: prelude:: * ;
6263use subspace_core_primitives:: { crypto, RootBlock , PIECE_SIZE , RANDOMNESS_LENGTH , SALT_SIZE } ;
@@ -200,11 +201,6 @@ mod pallet {
200201 #[ pallet:: constant]
201202 type RecordedHistorySegmentSize : Get < u32 > ;
202203
203- /// Replication factor, defines minimum desired number of replicas of the blockchain to be
204- /// stored by the network.
205- #[ pallet:: constant]
206- type ReplicationFactor : Get < u16 > ;
207-
208204 /// Subspace requires some logic to be triggered on every block to query for whether an epoch
209205 /// has ended and to perform the transition to the next epoch.
210206 ///
@@ -698,14 +694,15 @@ impl<T: Config> Pallet<T> {
698694
699695 // TODO: Temporary testnet hack, we don't update solution range for the first 15_000 blocks
700696 // in order to seed the blockchain with data quickly
701- #[ cfg( all( feature = "no-early-solution-range-updates" , not( test) ) ) ]
702- let solution_range = if block_number < 15_000_u32 . into ( ) {
703- previous_solution_range
697+ let solution_range = if cfg ! ( all( feature = "no-early-solution-range-updates" , not( test) ) ) {
698+ if block_number < 15_000_u32 . into ( ) {
699+ previous_solution_range
700+ } else {
701+ ( previous_solution_range as f64 * adjustment_factor) . round ( ) as u64
702+ }
704703 } else {
705704 ( previous_solution_range as f64 * adjustment_factor) . round ( ) as u64
706705 } ;
707- #[ cfg( not( all( feature = "no-early-solution-range-updates" , not( test) ) ) ) ]
708- let solution_range = ( previous_solution_range as f64 * adjustment_factor) . round ( ) as u64 ;
709706
710707 SolutionRange :: < T > :: put ( solution_range) ;
711708 EraStartSlot :: < T > :: put ( current_slot) ;
@@ -1110,6 +1107,23 @@ impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
11101107 }
11111108}
11121109
1110+ impl < T : Config > frame_support:: traits:: FindAuthor < T :: AccountId > for Pallet < T > {
1111+ fn find_author < ' a , I > ( digests : I ) -> Option < T :: AccountId >
1112+ where
1113+ I : ' a + IntoIterator < Item = ( ConsensusEngineId , & ' a [ u8 ] ) > ,
1114+ {
1115+ digests. into_iter ( ) . find_map ( |( id, mut data) | {
1116+ if id == SUBSPACE_ENGINE_ID {
1117+ PreDigest :: decode ( & mut data)
1118+ . map ( |pre_digest| pre_digest. solution . public_key )
1119+ . ok ( )
1120+ } else {
1121+ None
1122+ }
1123+ } )
1124+ }
1125+ }
1126+
11131127impl < T : Config > frame_support:: traits:: Lateness < T :: BlockNumber > for Pallet < T > {
11141128 fn lateness ( & self ) -> T :: BlockNumber {
11151129 Self :: lateness ( )
0 commit comments