@@ -77,7 +77,7 @@ use sp_runtime::{
7777 traits:: { BadOrigin , Saturating , UniqueSaturatedInto , Zero } ,
7878 AccountId32 , DispatchErrorWithPostInfo ,
7979} ;
80- use sp_std:: vec:: Vec ;
80+ use sp_std:: { cmp :: min , vec:: Vec } ;
8181
8282pub use evm:: {
8383 Config as EvmConfig , Context , ExitError , ExitFatal , ExitReason , ExitRevert , ExitSucceed ,
@@ -410,21 +410,26 @@ pub mod pallet {
410410 }
411411
412412 #[ pallet:: genesis_build]
413- impl < T : Config > GenesisBuild < T > for GenesisConfig {
413+ impl < T : Config > GenesisBuild < T > for GenesisConfig
414+ where
415+ U256 : UniqueSaturatedInto < BalanceOf < T > > ,
416+ {
414417 fn build ( & self ) {
418+ const MAX_ACCOUNT_NONCE : usize = 100 ;
419+
415420 for ( address, account) in & self . accounts {
416421 let account_id = T :: AddressMapping :: into_account_id ( * address) ;
417422
418423 // ASSUME: in one single EVM transaction, the nonce will not increase more than
419424 // `u128::max_value()`.
420- for _ in 0 ..account. nonce . low_u128 ( ) {
425+ for _ in 0 ..min (
426+ MAX_ACCOUNT_NONCE ,
427+ UniqueSaturatedInto :: < usize > :: unique_saturated_into ( account. nonce ) ,
428+ ) {
421429 frame_system:: Pallet :: < T > :: inc_account_nonce ( & account_id) ;
422430 }
423431
424- T :: Currency :: deposit_creating (
425- & account_id,
426- account. balance . low_u128 ( ) . unique_saturated_into ( ) ,
427- ) ;
432+ T :: Currency :: deposit_creating ( & account_id, account. balance . unique_saturated_into ( ) ) ;
428433
429434 Pallet :: < T > :: create_account ( * address, account. code . clone ( ) ) ;
430435
@@ -707,6 +712,7 @@ where
707712 Opposite = C :: PositiveImbalance ,
708713 > ,
709714 OU : OnUnbalanced < NegativeImbalanceOf < C , T > > ,
715+ U256 : UniqueSaturatedInto < <C as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance > ,
710716{
711717 // Kept type as Option to satisfy bound of Default
712718 type LiquidityInfo = Option < NegativeImbalanceOf < C , T > > ;
@@ -718,7 +724,7 @@ where
718724 let account_id = T :: AddressMapping :: into_account_id ( * who) ;
719725 let imbalance = C :: withdraw (
720726 & account_id,
721- fee. low_u128 ( ) . unique_saturated_into ( ) ,
727+ fee. unique_saturated_into ( ) ,
722728 WithdrawReasons :: FEE ,
723729 ExistenceRequirement :: AllowDeath ,
724730 )
@@ -738,7 +744,7 @@ where
738744 // Calculate how much refund we should return
739745 let refund_amount = paid
740746 . peek ( )
741- . saturating_sub ( corrected_fee. low_u128 ( ) . unique_saturated_into ( ) ) ;
747+ . saturating_sub ( corrected_fee. unique_saturated_into ( ) ) ;
742748 // refund to the account that paid the fees. If this fails, the
743749 // account might have dropped below the existential balance. In
744750 // that case we don't refund anything.
@@ -769,7 +775,7 @@ where
769775 . same ( )
770776 . unwrap_or_else ( |_| C :: NegativeImbalance :: zero ( ) ) ;
771777
772- let ( base_fee, tip) = adjusted_paid. split ( base_fee. low_u128 ( ) . unique_saturated_into ( ) ) ;
778+ let ( base_fee, tip) = adjusted_paid. split ( base_fee. unique_saturated_into ( ) ) ;
773779 // Handle base fee. Can be either burned, rationed, etc ...
774780 OU :: on_unbalanced ( base_fee) ;
775781 return Some ( tip) ;
@@ -793,7 +799,10 @@ impl<T> OnChargeEVMTransaction<T> for ()
793799 <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: PositiveImbalance :
794800 Imbalance < <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance , Opposite = <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: NegativeImbalance > ,
795801 <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: NegativeImbalance :
796- Imbalance < <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance , Opposite = <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: PositiveImbalance > , {
802+ Imbalance < <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance , Opposite = <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: PositiveImbalance > ,
803+ U256 : UniqueSaturatedInto < BalanceOf < T > > ,
804+
805+ {
797806 // Kept type as Option to satisfy bound of Default
798807 type LiquidityInfo = Option < NegativeImbalanceOf < T :: Currency , T > > ;
799808
0 commit comments