17
17
18
18
//! EVM stack-based runner.
19
19
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
+ } ;
20
25
use evm:: {
21
26
backend:: Backend as BackendT ,
22
27
executor:: stack:: { Accessed , StackExecutor , StackState as StackStateT , StackSubstateMetadata } ,
@@ -47,12 +52,6 @@ use fp_evm::{
47
52
ACCOUNT_STORAGE_PROOF_SIZE , IS_EMPTY_CHECK_PROOF_SIZE , WRITE_PROOF_SIZE ,
48
53
} ;
49
54
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
-
56
55
#[ cfg( feature = "forbid-evm-reentrancy" ) ]
57
56
environmental:: thread_local_impl!( static IN_EVM : environmental:: RefCell <bool > = environmental:: RefCell :: new( false ) ) ;
58
57
@@ -371,8 +370,10 @@ where
371
370
let ( base_fee, mut weight) = T :: FeeCalculator :: min_gas_price ( ) ;
372
371
let ( source_account, inner_weight) = Pallet :: < T > :: account_basic ( & source) ;
373
372
weight = weight. saturating_add ( inner_weight) ;
373
+ let nonce = nonce. unwrap_or ( source_account. nonce ) ;
374
374
375
- let _ = fp_evm:: CheckEvmTransaction :: < Self :: Error > :: new (
375
+ let mut v = fp_evm:: CheckEvmTransaction :: < Self :: Error > :: new (
376
+ source_account,
376
377
fp_evm:: CheckEvmTransactionConfig {
377
378
evm_config,
378
379
block_gas_limit : T :: BlockGasLimit :: get ( ) ,
@@ -384,7 +385,7 @@ where
384
385
chain_id : Some ( T :: ChainId :: get ( ) ) ,
385
386
to : target,
386
387
input,
387
- nonce : nonce . unwrap_or ( source_account . nonce ) ,
388
+ nonce,
388
389
gas_limit : gas_limit. into ( ) ,
389
390
gas_price : None ,
390
391
max_fee_per_gas,
@@ -394,11 +395,15 @@ where
394
395
} ,
395
396
weight_limit,
396
397
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 } ) ?;
402
407
Ok ( ( ) )
403
408
}
404
409
0 commit comments