@@ -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 ,
@@ -438,21 +438,26 @@ pub mod pallet {
438438 }
439439
440440 #[ pallet:: genesis_build]
441- impl < T : Config > GenesisBuild < T > for GenesisConfig {
441+ impl < T : Config > GenesisBuild < T > for GenesisConfig
442+ where
443+ U256 : UniqueSaturatedInto < BalanceOf < T > > ,
444+ {
442445 fn build ( & self ) {
446+ const MAX_ACCOUNT_NONCE : usize = 100 ;
447+
443448 for ( address, account) in & self . accounts {
444449 let account_id = T :: AddressMapping :: into_account_id ( * address) ;
445450
446451 // ASSUME: in one single EVM transaction, the nonce will not increase more than
447452 // `u128::max_value()`.
448- for _ in 0 ..account. nonce . low_u128 ( ) {
453+ for _ in 0 ..min (
454+ MAX_ACCOUNT_NONCE ,
455+ UniqueSaturatedInto :: < usize > :: unique_saturated_into ( account. nonce ) ,
456+ ) {
449457 frame_system:: Pallet :: < T > :: inc_account_nonce ( & account_id) ;
450458 }
451459
452- T :: Currency :: deposit_creating (
453- & account_id,
454- account. balance . low_u128 ( ) . unique_saturated_into ( ) ,
455- ) ;
460+ T :: Currency :: deposit_creating ( & account_id, account. balance . unique_saturated_into ( ) ) ;
456461
457462 Pallet :: < T > :: create_account ( * address, account. code . clone ( ) ) ;
458463
@@ -735,6 +740,7 @@ where
735740 Opposite = C :: PositiveImbalance ,
736741 > ,
737742 OU : OnUnbalanced < NegativeImbalanceOf < C , T > > ,
743+ U256 : UniqueSaturatedInto < <C as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance > ,
738744{
739745 // Kept type as Option to satisfy bound of Default
740746 type LiquidityInfo = Option < NegativeImbalanceOf < C , T > > ;
@@ -746,7 +752,7 @@ where
746752 let account_id = T :: AddressMapping :: into_account_id ( * who) ;
747753 let imbalance = C :: withdraw (
748754 & account_id,
749- fee. low_u128 ( ) . unique_saturated_into ( ) ,
755+ fee. unique_saturated_into ( ) ,
750756 WithdrawReasons :: FEE ,
751757 ExistenceRequirement :: AllowDeath ,
752758 )
@@ -766,7 +772,7 @@ where
766772 // Calculate how much refund we should return
767773 let refund_amount = paid
768774 . peek ( )
769- . saturating_sub ( corrected_fee. low_u128 ( ) . unique_saturated_into ( ) ) ;
775+ . saturating_sub ( corrected_fee. unique_saturated_into ( ) ) ;
770776 // refund to the account that paid the fees. If this fails, the
771777 // account might have dropped below the existential balance. In
772778 // that case we don't refund anything.
@@ -797,7 +803,7 @@ where
797803 . same ( )
798804 . unwrap_or_else ( |_| C :: NegativeImbalance :: zero ( ) ) ;
799805
800- let ( base_fee, tip) = adjusted_paid. split ( base_fee. low_u128 ( ) . unique_saturated_into ( ) ) ;
806+ let ( base_fee, tip) = adjusted_paid. split ( base_fee. unique_saturated_into ( ) ) ;
801807 // Handle base fee. Can be either burned, rationed, etc ...
802808 OU :: on_unbalanced ( base_fee) ;
803809 return Some ( tip) ;
@@ -821,7 +827,10 @@ impl<T> OnChargeEVMTransaction<T> for ()
821827 <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: PositiveImbalance :
822828 Imbalance < <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance , Opposite = <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: NegativeImbalance > ,
823829 <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: NegativeImbalance :
824- Imbalance < <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance , Opposite = <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: PositiveImbalance > , {
830+ Imbalance < <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance , Opposite = <T :: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: PositiveImbalance > ,
831+ U256 : UniqueSaturatedInto < BalanceOf < T > > ,
832+
833+ {
825834 // Kept type as Option to satisfy bound of Default
826835 type LiquidityInfo = Option < NegativeImbalanceOf < T :: Currency , T > > ;
827836
0 commit comments