@@ -53,6 +53,7 @@ pub struct EntryPointProvider<AP, D> {
5353 da_gas_oracle : D ,
5454 max_verification_gas : u64 ,
5555 max_simulate_handle_op_gas : u64 ,
56+ max_gas_estimation_gas : u64 ,
5657 max_aggregation_gas : u64 ,
5758 chain_spec : ChainSpec ,
5859}
6768 chain_spec : ChainSpec ,
6869 max_verification_gas : u64 ,
6970 max_simulate_handle_op_gas : u64 ,
71+ max_gas_estimation_gas : u64 ,
7072 max_aggregation_gas : u64 ,
7173 provider : AP ,
7274 da_gas_oracle : D ,
7981 da_gas_oracle,
8082 max_verification_gas,
8183 max_simulate_handle_op_gas,
84+ max_gas_estimation_gas,
8285 max_aggregation_gas,
8386 chain_spec,
8487 }
@@ -455,40 +458,19 @@ where
455458 target : Address ,
456459 target_call_data : Bytes ,
457460 block_id : BlockId ,
458- mut state_override : StateOverride ,
461+ state_override : StateOverride ,
459462 ) -> ProviderResult < Result < ExecutionResult , ValidationRevert > > {
460- let da_gas: u64 = op
461- . pre_verification_da_gas_limit ( & self . chain_spec , Some ( 1 ) )
462- . try_into ( )
463- . unwrap_or ( u64:: MAX ) ;
464-
465- if let Some ( authorization) = op. authorization_tuple ( ) {
466- authorization_utils:: apply_7702_overrides (
467- & mut state_override,
468- op. sender ( ) ,
469- authorization. address ,
470- ) ;
471- }
472-
473- let contract_error = self
474- . i_entry_point
475- . simulateHandleOp ( op. into ( ) , target, target_call_data)
476- . block ( block_id)
477- . gas ( self . max_simulate_handle_op_gas . saturating_add ( da_gas) )
478- . state ( state_override)
479- . call ( )
480- . await
481- . err ( )
482- . context ( "simulateHandleOp succeeded, but should always revert" ) ?;
483- match contract_error {
484- ContractError :: TransportError ( TransportError :: ErrorResp ( resp) ) => {
485- match resp. as_revert_data ( ) {
486- Some ( err_bytes) => Ok ( Self :: decode_simulate_handle_ops_revert ( & err_bytes) ?) ,
487- None => Ok ( Err ( ValidationRevert :: Unknown ( Bytes :: default ( ) ) ) ) ,
488- }
489- }
490- _ => Err ( contract_error. into ( ) ) ,
491- }
463+ simulate_handle_op_inner :: < Self , AP > (
464+ & self . chain_spec ,
465+ self . max_simulate_handle_op_gas ,
466+ & self . i_entry_point ,
467+ op,
468+ target,
469+ target_call_data,
470+ block_id,
471+ state_override,
472+ )
473+ . await
492474 }
493475
494476 #[ instrument( skip_all) ]
@@ -500,8 +482,17 @@ where
500482 block_id : BlockId ,
501483 state_override : StateOverride ,
502484 ) -> ProviderResult < Result < ExecutionResult , ValidationRevert > > {
503- self . simulate_handle_op ( op, target, target_call_data, block_id, state_override)
504- . await
485+ simulate_handle_op_inner :: < Self , AP > (
486+ & self . chain_spec ,
487+ self . max_gas_estimation_gas ,
488+ & self . i_entry_point ,
489+ op,
490+ target,
491+ target_call_data,
492+ block_id,
493+ state_override,
494+ )
495+ . await
505496 }
506497
507498 fn decode_simulate_handle_ops_revert (
@@ -660,6 +651,50 @@ pub fn decode_ops_from_calldata(
660651 }
661652}
662653
654+ #[ allow( clippy:: too_many_arguments) ]
655+ async fn simulate_handle_op_inner < S : SimulationProvider , AP : AlloyProvider > (
656+ chain_spec : & ChainSpec ,
657+ execution_gas_limit : u64 ,
658+ entry_point : & IEntryPointInstance < AP , AnyNetwork > ,
659+ op : UserOperation ,
660+ target : Address ,
661+ target_call_data : Bytes ,
662+ block_id : BlockId ,
663+ mut state_override : StateOverride ,
664+ ) -> ProviderResult < Result < ExecutionResult , ValidationRevert > > {
665+ let da_gas: u64 = op
666+ . pre_verification_da_gas_limit ( chain_spec, Some ( 1 ) )
667+ . try_into ( )
668+ . unwrap_or ( u64:: MAX ) ;
669+
670+ if let Some ( authorization) = op. authorization_tuple ( ) {
671+ authorization_utils:: apply_7702_overrides (
672+ & mut state_override,
673+ op. sender ( ) ,
674+ authorization. address ,
675+ ) ;
676+ }
677+
678+ let contract_error = entry_point
679+ . simulateHandleOp ( op. into ( ) , target, target_call_data)
680+ . block ( block_id)
681+ . gas ( execution_gas_limit. saturating_add ( da_gas) )
682+ . state ( state_override)
683+ . call ( )
684+ . await
685+ . err ( )
686+ . context ( "simulateHandleOp succeeded, but should always revert" ) ?;
687+ match contract_error {
688+ ContractError :: TransportError ( TransportError :: ErrorResp ( resp) ) => {
689+ match resp. as_revert_data ( ) {
690+ Some ( err_bytes) => Ok ( S :: decode_simulate_handle_ops_revert ( & err_bytes) ?) ,
691+ None => Err ( TransportError :: ErrorResp ( resp) . into ( ) ) ,
692+ }
693+ }
694+ _ => Err ( contract_error. into ( ) ) ,
695+ }
696+ }
697+
663698impl TryFrom < ExecutionResultV0_6 > for ExecutionResult {
664699 type Error = anyhow:: Error ;
665700
0 commit comments