@@ -62,7 +62,11 @@ pub mod pallet {
6262
6363 /// Configure the pallet by specifying the parameters and types on which it depends.
6464 #[ pallet:: config]
65- pub trait Config : frame_system:: Config + pallet_transaction_payment:: Config {
65+ pub trait Config :
66+ frame_system:: Config
67+ + pallet_transaction_payment:: Config
68+ + cumulus_pallet_parachain_system:: Config
69+ {
6670 // `targeted_length_fee_adjustment` parameters
6771 #[ pallet:: constant]
6872 type TransactionByteFee : Get < <<Self as pallet_transaction_payment:: Config >:: OnChargeTransaction as OnChargeTransaction < Self > >:: Balance > ;
@@ -217,16 +221,14 @@ pub mod pallet {
217221 impl < T : Config > OnSystemEvent for Pallet < T > {
218222 fn on_validation_data ( data : & PersistedValidationData ) {
219223 let relay_block_number = data. relay_parent_number ;
224+ let prev_relay_block_number =
225+ cumulus_pallet_parachain_system:: Pallet :: < T > :: last_relay_block_number ( ) ;
220226
221- let prev_relay_block_number = PrevRelayBlockNumber :: < T > :: get ( ) ;
222- PrevRelayBlockNumber :: < T > :: put ( relay_block_number) ;
223-
224- // if nothing was already present then this is the first block to
225- // be executed with the fee adjustment so nothing should be done
226- let prev_relay_block_number = match prev_relay_block_number {
227- Some ( prev) => prev,
228- None => return ,
229- } ;
227+ // a value of zero here implies this is the first block of the parachain. no need
228+ // to do a massive fee update.
229+ if prev_relay_block_number == Zero :: zero ( ) {
230+ return ;
231+ }
230232
231233 // It should never be negative because the relay_block_number is surely
232234 // greater than the para_block_number.
0 commit comments