1717
1818//! EVM stack-based runner.
1919
20+ use crate :: {
21+ runner:: Runner as RunnerT , AccountCodes , AccountCodesMetadata , AccountStorages , AddressMapping ,
22+ BalanceOf , BlockHashMapping , Config , Error , Event , FeeCalculator , OnChargeEVMTransaction ,
23+ OnCheckEvmTransaction , OnCreate , Pallet , RunnerError ,
24+ } ;
2025use evm:: {
2126 backend:: Backend as BackendT ,
2227 executor:: stack:: { Accessed , StackExecutor , StackState as StackStateT , StackSubstateMetadata } ,
@@ -47,12 +52,6 @@ use fp_evm::{
4752 ACCOUNT_STORAGE_PROOF_SIZE , IS_EMPTY_CHECK_PROOF_SIZE , WRITE_PROOF_SIZE ,
4853} ;
4954
50- use crate :: {
51- runner:: Runner as RunnerT , AccountCodes , AccountCodesMetadata , AccountStorages , AddressMapping ,
52- BalanceOf , BlockHashMapping , Config , Error , Event , FeeCalculator , OnChargeEVMTransaction ,
53- OnCreate , Pallet , RunnerError ,
54- } ;
55-
5655#[ cfg( feature = "forbid-evm-reentrancy" ) ]
5756environmental:: thread_local_impl!( static IN_EVM : environmental:: RefCell <bool > = environmental:: RefCell :: new( false ) ) ;
5857
@@ -371,8 +370,10 @@ where
371370 let ( base_fee, mut weight) = T :: FeeCalculator :: min_gas_price ( ) ;
372371 let ( source_account, inner_weight) = Pallet :: < T > :: account_basic ( & source) ;
373372 weight = weight. saturating_add ( inner_weight) ;
373+ let nonce = nonce. unwrap_or ( source_account. nonce ) ;
374374
375- let _ = fp_evm:: CheckEvmTransaction :: < Self :: Error > :: new (
375+ let mut v = fp_evm:: CheckEvmTransaction :: < Self :: Error > :: new (
376+ source_account,
376377 fp_evm:: CheckEvmTransactionConfig {
377378 evm_config,
378379 block_gas_limit : T :: BlockGasLimit :: get ( ) ,
@@ -384,7 +385,7 @@ where
384385 chain_id : Some ( T :: ChainId :: get ( ) ) ,
385386 to : target,
386387 input,
387- nonce : nonce . unwrap_or ( source_account . nonce ) ,
388+ nonce,
388389 gas_limit : gas_limit. into ( ) ,
389390 gas_price : None ,
390391 max_fee_per_gas,
@@ -394,11 +395,15 @@ where
394395 } ,
395396 weight_limit,
396397 proof_size_base_cost,
397- )
398- . validate_in_block_for ( & source_account)
399- . and_then ( |v| v. with_base_fee ( ) )
400- . and_then ( |v| v. with_balance_for ( & source_account) )
401- . map_err ( |error| RunnerError { error, weight } ) ?;
398+ ) ;
399+
400+ T :: OnCheckEvmTransaction :: < Error < T > > :: on_check_evm_transaction ( & mut v, & source)
401+ . map_err ( |error| RunnerError { error, weight } ) ?;
402+
403+ v. validate_in_block ( )
404+ . and_then ( |v| v. with_base_fee ( ) )
405+ . and_then ( |v| v. with_balance ( ) )
406+ . map_err ( |error| RunnerError { error, weight } ) ?;
402407 Ok ( ( ) )
403408 }
404409
0 commit comments