From 36ee3a96b2dd6ae62010cde99824d1c82600b36f Mon Sep 17 00:00:00 2001 From: dancoombs Date: Mon, 7 Oct 2024 16:28:12 -0500 Subject: [PATCH] feat: move limits to providers, add da to limit --- bin/rundler/src/cli/mod.rs | 11 +-- crates/builder/src/bundle_proposer.rs | 21 ++--- crates/builder/src/task.rs | 12 +-- crates/pool/src/task.rs | 12 +-- crates/provider/src/alloy/entry_point/v0_6.rs | 88 +++++++++++++------ crates/provider/src/alloy/entry_point/v0_7.rs | 72 ++++++++++----- crates/provider/src/traits/entry_point.rs | 10 +-- crates/provider/src/traits/test_utils.rs | 16 +--- crates/rpc/src/eth/router.rs | 17 +--- crates/rpc/src/rundler.rs | 8 +- crates/rpc/src/task.rs | 1 - .../sim/src/estimation/estimate_call_gas.rs | 4 - .../estimation/estimate_verification_gas.rs | 2 - crates/sim/src/estimation/v0_6.rs | 56 +++--------- crates/sim/src/estimation/v0_7.rs | 34 +------ crates/sim/src/simulation/mod.rs | 17 +--- crates/sim/src/simulation/simulator.rs | 13 +-- crates/sim/src/simulation/unsafe_sim.rs | 22 +---- crates/sim/src/simulation/v0_6/context.rs | 2 - crates/sim/src/simulation/v0_6/tracer.rs | 11 +-- crates/sim/src/simulation/v0_7/context.rs | 2 - crates/sim/src/simulation/v0_7/tracer.rs | 11 +-- crates/types/src/user_operation/v0_6.rs | 1 - crates/types/src/user_operation/v0_7.rs | 1 - 24 files changed, 174 insertions(+), 270 deletions(-) diff --git a/bin/rundler/src/cli/mod.rs b/bin/rundler/src/cli/mod.rs index 3f04b2d2f..c84055873 100644 --- a/bin/rundler/src/cli/mod.rs +++ b/bin/rundler/src/cli/mod.rs @@ -396,8 +396,6 @@ impl TryFrom<&CommonArgs> for SimulationSettings { Ok(Self::new( value.min_unstake_delay, U256::from(value.min_stake_value), - value.max_simulate_handle_ops_gas, - value.max_verification_gas, value.tracer_timeout.clone(), )) } @@ -419,7 +417,6 @@ impl TryFrom<&CommonArgs> for RundlerApiSettings { value.priority_fee_mode_value, )?, bundle_priority_fee_overhead_percent: value.bundle_priority_fee_overhead_percent, - max_verification_gas: value.max_verification_gas, }) } } @@ -559,7 +556,9 @@ pub fn construct_providers( None } else { Some(AlloyEntryPointV0_6::new( - chain_spec, + chain_spec.clone(), + args.max_verification_gas, + args.max_simulate_handle_ops_gas, args.max_simulate_handle_ops_gas, provider.clone(), )) @@ -569,7 +568,9 @@ pub fn construct_providers( None } else { Some(AlloyEntryPointV0_7::new( - chain_spec, + chain_spec.clone(), + args.max_verification_gas, + args.max_simulate_handle_ops_gas, args.max_simulate_handle_ops_gas, provider.clone(), )) diff --git a/crates/builder/src/bundle_proposer.rs b/crates/builder/src/bundle_proposer.rs index 9b1f75eb3..71c243437 100644 --- a/crates/builder/src/bundle_proposer.rs +++ b/crates/builder/src/bundle_proposer.rs @@ -720,7 +720,7 @@ where .call_handle_ops( context.to_ops_per_aggregator(), self.settings.beneficiary, - gas, + Some(gas), ) .await .context("should call handle ops with candidate bundle")?; @@ -745,7 +745,7 @@ where } HandleOpsOut::PostOpRevert => { warn!("PostOpShortRevert error during gas estimation due to bug in the 0.6 entry point contract. Removing the offending op from the bundle."); - self.process_post_op_revert(context, gas).await?; + self.process_post_op_revert(context).await?; Ok(None) } } @@ -869,7 +869,6 @@ where async fn process_post_op_revert( &self, context: &mut ProposalContext, - gas: u64, ) -> anyhow::Result<()> { let agg_groups = context.to_ops_per_aggregator(); let mut op_index = 0; @@ -880,7 +879,7 @@ where if agg_group.aggregator.is_zero() { for op in agg_group.user_ops { futures.push(Box::pin( - self.check_for_post_op_revert_single_op(op, gas, op_index), + self.check_for_post_op_revert_single_op(op, op_index), )); op_index += 1; } @@ -888,7 +887,7 @@ where // For aggregated ops, re-simulate the group let len = agg_group.user_ops.len(); futures.push(Box::pin( - self.check_for_post_op_revert_agg_ops(agg_group, gas, op_index), + self.check_for_post_op_revert_agg_ops(agg_group, op_index), )); op_index += len; } @@ -919,12 +918,7 @@ where Ok(()) } - async fn check_for_post_op_revert_single_op( - &self, - op: UO, - gas: u64, - op_index: usize, - ) -> Vec { + async fn check_for_post_op_revert_single_op(&self, op: UO, op_index: usize) -> Vec { let op_hash = self.op_hash(&op); let bundle = vec![UserOpsPerAggregator { aggregator: Address::ZERO, @@ -933,7 +927,7 @@ where }]; let ret = self .entry_point - .call_handle_ops(bundle, self.settings.beneficiary, gas) + .call_handle_ops(bundle, self.settings.beneficiary, None) .await; match ret { Ok(out) => { @@ -958,7 +952,6 @@ where async fn check_for_post_op_revert_agg_ops( &self, group: UserOpsPerAggregator, - gas: u64, start_index: usize, ) -> Vec { let len = group.user_ops.len(); @@ -966,7 +959,7 @@ where let bundle = vec![group]; let ret = self .entry_point - .call_handle_ops(bundle, self.settings.beneficiary, gas) + .call_handle_ops(bundle, self.settings.beneficiary, None) .await; match ret { Ok(out) => { diff --git a/crates/builder/src/task.rs b/crates/builder/src/task.rs index 58f49ed36..8a2b94b83 100644 --- a/crates/builder/src/task.rs +++ b/crates/builder/src/task.rs @@ -225,11 +225,7 @@ where i + ep.bundle_builder_index_offset, self.provider.clone(), ep_v0_6.clone(), - UnsafeSimulator::new( - self.provider.clone(), - ep_v0_6.clone(), - self.args.sim_settings.clone(), - ), + UnsafeSimulator::new(self.provider.clone(), ep_v0_6.clone()), pk_iter, ) .await? @@ -277,11 +273,7 @@ where i + ep.bundle_builder_index_offset, self.provider.clone(), ep_v0_7.clone(), - UnsafeSimulator::new( - self.provider.clone(), - ep_v0_7.clone(), - self.args.sim_settings.clone(), - ), + UnsafeSimulator::new(self.provider.clone(), ep_v0_7.clone()), pk_iter, ) .await? diff --git a/crates/pool/src/task.rs b/crates/pool/src/task.rs index d8867117b..a70494107 100644 --- a/crates/pool/src/task.rs +++ b/crates/pool/src/task.rs @@ -208,11 +208,7 @@ where .context("entry point v0.6 not supplied")?; if unsafe_mode { - let simulator = UnsafeSimulator::new( - self.provider.clone(), - ep.clone(), - pool_config.sim_settings.clone(), - ); + let simulator = UnsafeSimulator::new(self.provider.clone(), ep.clone()); Self::create_mempool( task_spawner, chain_spec, @@ -255,11 +251,7 @@ where .context("entry point v0.7 not supplied")?; if unsafe_mode { - let simulator = UnsafeSimulator::new( - self.provider.clone(), - ep.clone(), - pool_config.sim_settings.clone(), - ); + let simulator = UnsafeSimulator::new(self.provider.clone(), ep.clone()); Self::create_mempool( task_spawner, chain_spec, diff --git a/crates/provider/src/alloy/entry_point/v0_6.rs b/crates/provider/src/alloy/entry_point/v0_6.rs index 328300bc5..6e34a3742 100644 --- a/crates/provider/src/alloy/entry_point/v0_6.rs +++ b/crates/provider/src/alloy/entry_point/v0_6.rs @@ -29,8 +29,8 @@ use rundler_contracts::v0_6::{ UserOperation as ContractUserOperation, UserOpsPerAggregator as UserOpsPerAggregatorV0_6, }; use rundler_types::{ - chain::ChainSpec, v0_6::UserOperation, GasFees, UserOpsPerAggregator, ValidationOutput, - ValidationRevert, + chain::ChainSpec, v0_6::UserOperation, GasFees, UserOperation as _, UserOpsPerAggregator, + ValidationOutput, ValidationRevert, }; use super::DAGasOracle; @@ -45,7 +45,10 @@ use crate::{ pub struct EntryPointProvider { i_entry_point: IEntryPointInstance, da_gas_oracle: DAGasOracle, + max_verification_gas: u64, + max_simulate_handle_op_gas: u64, max_aggregation_gas: u64, + chain_spec: ChainSpec, } impl EntryPointProvider @@ -54,11 +57,20 @@ where AP: AlloyProvider, { /// Create a new `EntryPoint` instance for v0.6 - pub fn new(chain_spec: &ChainSpec, max_aggregation_gas: u64, provider: AP) -> Self { + pub fn new( + chain_spec: ChainSpec, + max_verification_gas: u64, + max_simulate_handle_op_gas: u64, + max_aggregation_gas: u64, + provider: AP, + ) -> Self { Self { i_entry_point: IEntryPointInstance::new(chain_spec.entry_point_address_v0_6, provider), - da_gas_oracle: DAGasOracle::new(chain_spec), + da_gas_oracle: DAGasOracle::new(&chain_spec), + max_verification_gas, + max_simulate_handle_op_gas, max_aggregation_gas, + chain_spec, } } } @@ -133,12 +145,20 @@ where ops: Vec, ) -> ProviderResult> { let aggregator = IAggregator::new(aggregator_address, self.i_entry_point.provider()); + let ops_len = ops.len(); + let da_gas: u64 = ops + .iter() + .map(|op: &UserOperation| { + op.pre_verification_da_gas_limit(&self.chain_spec, Some(ops_len)) + }) + .sum::() + .try_into() + .unwrap_or(u64::MAX); let ops: Vec = ops.into_iter().map(Into::into).collect(); - // TODO(danc): HERE let result = aggregator .aggregateSignatures(ops) - .gas(self.max_aggregation_gas) + .gas(self.max_aggregation_gas.saturating_add(da_gas)) .call() .await; @@ -159,13 +179,16 @@ where &self, aggregator_address: Address, user_op: Self::UO, - gas_cap: u64, ) -> ProviderResult { let aggregator = IAggregator::new(aggregator_address, self.i_entry_point.provider()); + let da_gas: u64 = user_op + .pre_verification_da_gas_limit(&self.chain_spec, Some(1)) + .try_into() + .unwrap_or(u64::MAX); let result = aggregator .validateUserOpSignature(user_op.into()) - .gas(gas_cap) + .gas(self.max_verification_gas.saturating_add(da_gas)) .call() .await; @@ -198,9 +221,15 @@ where &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: Option, ) -> ProviderResult { - let tx = get_handle_ops_call(&self.i_entry_point, ops_per_aggregator, beneficiary, gas); + let gas_limit = gas_limit.unwrap_or(self.max_simulate_handle_op_gas); + let tx = get_handle_ops_call( + &self.i_entry_point, + ops_per_aggregator, + beneficiary, + gas_limit, + ); let res = self.i_entry_point.provider().call(&tx).await; match res { @@ -256,12 +285,17 @@ where &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: u64, gas_fees: GasFees, ) -> TransactionRequest { - get_handle_ops_call(&self.i_entry_point, ops_per_aggregator, beneficiary, gas) - .max_fee_per_gas(gas_fees.max_fee_per_gas) - .max_priority_fee_per_gas(gas_fees.max_priority_fee_per_gas) + get_handle_ops_call( + &self.i_entry_point, + ops_per_aggregator, + beneficiary, + gas_limit, + ) + .max_fee_per_gas(gas_fees.max_fee_per_gas) + .max_priority_fee_per_gas(gas_fees.max_priority_fee_per_gas) } } @@ -311,16 +345,15 @@ where fn get_tracer_simulate_validation_call( &self, user_op: UserOperation, - max_validation_gas: u64, ) -> ProviderResult<(TransactionRequest, StateOverride)> { - let pvg: u64 = user_op - .pre_verification_gas + let da_gas: u64 = user_op + .pre_verification_da_gas_limit(&self.chain_spec, Some(1)) .try_into() - .context("pre verification gas larger than u64")?; + .unwrap_or(u64::MAX); let call = self .i_entry_point .simulateValidation(user_op.into()) - .gas(max_validation_gas + pvg) + .gas(self.max_verification_gas.saturating_add(da_gas)) .into_transaction_request(); Ok((call, StateOverride::default())) } @@ -328,17 +361,16 @@ where async fn simulate_validation( &self, user_op: UserOperation, - max_validation_gas: u64, block_id: Option, ) -> ProviderResult> { - let pvg: u64 = user_op - .pre_verification_gas + let da_gas: u64 = user_op + .pre_verification_da_gas_limit(&self.chain_spec, Some(1)) .try_into() - .context("pre verification gas larger than u64")?; + .unwrap_or(u64::MAX); let blockless = self .i_entry_point .simulateValidation(user_op.into()) - .gas(max_validation_gas + pvg); + .gas(self.max_verification_gas.saturating_add(da_gas)); let call = match block_id { Some(block_id) => blockless.block(block_id), None => blockless, @@ -397,14 +429,18 @@ where target: Address, target_call_data: Bytes, block_id: BlockId, - gas: u64, state_override: StateOverride, ) -> ProviderResult> { + let da_gas: u64 = op + .pre_verification_da_gas_limit(&self.chain_spec, Some(1)) + .try_into() + .unwrap_or(u64::MAX); + let contract_error = self .i_entry_point .simulateHandleOp(op.into(), target, target_call_data) .block(block_id) - .gas(gas) + .gas(self.max_simulate_handle_op_gas.saturating_add(da_gas)) .state(state_override) .call() .await diff --git a/crates/provider/src/alloy/entry_point/v0_7.rs b/crates/provider/src/alloy/entry_point/v0_7.rs index 0978efd34..f84c1aa0a 100644 --- a/crates/provider/src/alloy/entry_point/v0_7.rs +++ b/crates/provider/src/alloy/entry_point/v0_7.rs @@ -36,8 +36,8 @@ use rundler_contracts::v0_7::{ ENTRY_POINT_SIMULATIONS_V0_7_DEPLOYED_BYTECODE, }; use rundler_types::{ - chain::ChainSpec, v0_7::UserOperation, GasFees, UserOpsPerAggregator, ValidationOutput, - ValidationRevert, + chain::ChainSpec, v0_7::UserOperation, GasFees, UserOperation as _, UserOpsPerAggregator, + ValidationOutput, ValidationRevert, }; use super::DAGasOracle; @@ -52,7 +52,10 @@ use crate::{ pub struct EntryPointProvider { i_entry_point: IEntryPointInstance, da_gas_oracle: DAGasOracle, + max_verification_gas: u64, + max_simulate_handle_ops_gas: u64, max_aggregation_gas: u64, + chain_spec: ChainSpec, } impl EntryPointProvider @@ -61,11 +64,20 @@ where AP: AlloyProvider, { /// Create a new `EntryPoint` instance for v0.7 - pub fn new(chain_spec: &ChainSpec, max_aggregation_gas: u64, provider: AP) -> Self { + pub fn new( + chain_spec: ChainSpec, + max_verification_gas: u64, + max_simulate_handle_ops_gas: u64, + max_aggregation_gas: u64, + provider: AP, + ) -> Self { Self { i_entry_point: IEntryPointInstance::new(chain_spec.entry_point_address_v0_7, provider), - da_gas_oracle: DAGasOracle::new(chain_spec), + da_gas_oracle: DAGasOracle::new(&chain_spec), + max_verification_gas, + max_simulate_handle_ops_gas, max_aggregation_gas, + chain_spec, } } } @@ -142,12 +154,21 @@ where ) -> ProviderResult> { let aggregator = IAggregator::new(aggregator_address, self.i_entry_point.provider()); + let ops_len = ops.len(); + let da_gas: u64 = ops + .iter() + .map(|op: &UserOperation| { + op.pre_verification_da_gas_limit(&self.chain_spec, Some(ops_len)) + }) + .sum::() + .try_into() + .unwrap_or(u64::MAX); + let packed_ops = ops.into_iter().map(|op| op.pack()).collect(); - // TODO(danc): HERE let result = aggregator .aggregateSignatures(packed_ops) - .gas(self.max_aggregation_gas) + .gas(self.max_aggregation_gas.saturating_add(da_gas)) .call() .await; @@ -168,13 +189,16 @@ where &self, aggregator_address: Address, user_op: Self::UO, - gas_cap: u64, ) -> ProviderResult { let aggregator = IAggregator::new(aggregator_address, self.i_entry_point.provider()); + let da_gas: u64 = user_op + .pre_verification_da_gas_limit(&self.chain_spec, Some(1)) + .try_into() + .unwrap_or(u64::MAX); let result = aggregator .validateUserOpSignature(user_op.pack()) - .gas(gas_cap) + .gas(self.max_verification_gas.saturating_add(da_gas)) .call() .await; @@ -207,9 +231,15 @@ where &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: Option, ) -> ProviderResult { - let tx = get_handle_ops_call(&self.i_entry_point, ops_per_aggregator, beneficiary, gas); + let gas_limit = gas_limit.unwrap_or(self.max_simulate_handle_ops_gas); + let tx = get_handle_ops_call( + &self.i_entry_point, + ops_per_aggregator, + beneficiary, + gas_limit, + ); let res = self.i_entry_point.provider().call(&tx).await; match res { @@ -304,13 +334,13 @@ where fn get_tracer_simulate_validation_call( &self, user_op: Self::UO, - max_validation_gas: u64, ) -> ProviderResult<(TransactionRequest, StateOverride)> { let addr = *self.i_entry_point.address(); - let pvg: u64 = user_op - .pre_verification_gas + let da_gas: u64 = user_op + .pre_verification_da_gas_limit(&self.chain_spec, Some(1)) .try_into() - .context("pre verification gas larger than u64")?; + .unwrap_or(u64::MAX); + let mut override_ep = StateOverride::default(); add_simulations_override(&mut override_ep, addr); @@ -319,7 +349,7 @@ where let call = ep_simulations .simulateValidation(user_op.pack()) - .gas(max_validation_gas + pvg) + .gas(self.max_verification_gas.saturating_add(da_gas)) .into_transaction_request(); Ok((call, override_ep)) @@ -328,11 +358,9 @@ where async fn simulate_validation( &self, user_op: Self::UO, - max_validation_gas: u64, block_id: Option, ) -> ProviderResult> { - let (tx, overrides) = - self.get_tracer_simulate_validation_call(user_op, max_validation_gas)?; + let (tx, overrides) = self.get_tracer_simulate_validation_call(user_op)?; let mut call = self.i_entry_point.provider().call(&tx); if let Some(block_id) = block_id { call = call.block(block_id); @@ -380,9 +408,13 @@ where target: Address, target_call_data: Bytes, block_id: BlockId, - gas: u64, mut state_override: StateOverride, ) -> ProviderResult> { + let da_gas: u64 = op + .pre_verification_da_gas_limit(&self.chain_spec, Some(1)) + .try_into() + .unwrap_or(u64::MAX); + add_simulations_override(&mut state_override, *self.i_entry_point.address()); let ep_simulations = IEntryPointSimulations::new( *self.i_entry_point.address(), @@ -391,7 +423,7 @@ where let res = ep_simulations .simulateHandleOp(op.pack(), target, target_call_data) .block(block_id) - .gas(gas) + .gas(self.max_simulate_handle_ops_gas.saturating_add(da_gas)) .state(state_override) .call() .await; diff --git a/crates/provider/src/traits/entry_point.rs b/crates/provider/src/traits/entry_point.rs index 27b992fcb..3a1fbeb91 100644 --- a/crates/provider/src/traits/entry_point.rs +++ b/crates/provider/src/traits/entry_point.rs @@ -121,7 +121,6 @@ pub trait SignatureAggregator: Send + Sync { &self, aggregator_address: Address, user_op: Self::UO, - gas_cap: u64, ) -> ProviderResult; } @@ -133,11 +132,13 @@ pub trait BundleHandler: Send + Sync { type UO: UserOperation; /// Call the entry point contract's `handleOps` function + /// + /// If `gas_limit` is `None`, the maximum gas limit is used. async fn call_handle_ops( &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: Option, ) -> ProviderResult; /// Construct the transaction to send a bundle of operations to the entry point contract @@ -145,7 +146,7 @@ pub trait BundleHandler: Send + Sync { &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: u64, gas_fees: GasFees, ) -> TransactionRequest; } @@ -181,14 +182,12 @@ pub trait SimulationProvider: Send + Sync { fn get_tracer_simulate_validation_call( &self, user_op: Self::UO, - max_validation_gas: u64, ) -> ProviderResult<(TransactionRequest, StateOverride)>; /// Call the entry point contract's `simulateValidation` function. async fn simulate_validation( &self, user_op: Self::UO, - max_validation_gas: u64, block_id: Option, ) -> ProviderResult>; @@ -203,7 +202,6 @@ pub trait SimulationProvider: Send + Sync { target: Address, target_call_data: Bytes, block_hash: BlockId, - gas: u64, state_override: StateOverride, ) -> ProviderResult>; diff --git a/crates/provider/src/traits/test_utils.rs b/crates/provider/src/traits/test_utils.rs index ef38e7ede..548973542 100644 --- a/crates/provider/src/traits/test_utils.rs +++ b/crates/provider/src/traits/test_utils.rs @@ -134,7 +134,6 @@ mockall::mock! { &self, aggregator_address: Address, user_op: v0_6::UserOperation, - gas_cap: u64, ) -> ProviderResult; } @@ -144,12 +143,10 @@ mockall::mock! { fn get_tracer_simulate_validation_call( &self, user_op: v0_6::UserOperation, - max_validation_gas: u64, ) -> ProviderResult<(TransactionRequest, StateOverride)>; async fn simulate_validation( &self, user_op: v0_6::UserOperation, - max_validation_gas: u64, block_id: Option ) -> ProviderResult>; fn get_simulate_handle_op_call( @@ -163,7 +160,6 @@ mockall::mock! { target: Address, target_call_data: Bytes, block_id: BlockId, - gas: u64, state_override: StateOverride, ) -> ProviderResult>; fn decode_simulate_handle_ops_revert( @@ -190,13 +186,13 @@ mockall::mock! { &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: Option, ) -> ProviderResult; fn get_send_bundle_transaction( &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: u64, gas_fees: GasFees, ) -> TransactionRequest; } @@ -226,7 +222,6 @@ mockall::mock! { &self, aggregator_address: Address, user_op: v0_7::UserOperation, - gas_cap: u64, ) -> ProviderResult; } @@ -236,12 +231,10 @@ mockall::mock! { fn get_tracer_simulate_validation_call( &self, user_op: v0_7::UserOperation, - max_validation_gas: u64, ) -> ProviderResult<(TransactionRequest, StateOverride)>; async fn simulate_validation( &self, user_op: v0_7::UserOperation, - max_validation_gas: u64, block_id: Option ) -> ProviderResult>; fn get_simulate_handle_op_call( @@ -255,7 +248,6 @@ mockall::mock! { target: Address, target_call_data: Bytes, block_id: BlockId, - gas: u64, state_override: StateOverride, ) -> ProviderResult>; fn decode_simulate_handle_ops_revert( @@ -282,13 +274,13 @@ mockall::mock! { &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: Option, ) -> ProviderResult; fn get_send_bundle_transaction( &self, ops_per_aggregator: Vec>, beneficiary: Address, - gas: u64, + gas_limit: u64, gas_fees: GasFees, ) -> TransactionRequest; } diff --git a/crates/rpc/src/eth/router.rs b/crates/rpc/src/eth/router.rs index d59c0a03f..0c6bfb2e0 100644 --- a/crates/rpc/src/eth/router.rs +++ b/crates/rpc/src/eth/router.rs @@ -191,10 +191,9 @@ impl EntryPointRouter { &self, entry_point: &Address, uo: UserOperationVariant, - max_verification_gas: u64, ) -> EthResult { self.check_and_get_route(entry_point, &uo)? - .check_signature(uo, max_verification_gas) + .check_signature(uo) .await .map_err(Into::into) } @@ -245,11 +244,7 @@ pub(crate) trait EntryPointRoute: Send + Sync { state_override: Option, ) -> Result; - async fn check_signature( - &self, - uo: UserOperationVariant, - max_verification_gas: u64, - ) -> anyhow::Result; + async fn check_signature(&self, uo: UserOperationVariant) -> anyhow::Result; } #[derive(Debug)] @@ -298,14 +293,10 @@ where .await } - async fn check_signature( - &self, - uo: UserOperationVariant, - max_verification_gas: u64, - ) -> anyhow::Result { + async fn check_signature(&self, uo: UserOperationVariant) -> anyhow::Result { let output = self .entry_point - .simulate_validation(uo.into(), max_verification_gas, None) + .simulate_validation(uo.into(), None) .await??; Ok(!output.return_info.account_sig_failed) diff --git a/crates/rpc/src/rundler.rs b/crates/rpc/src/rundler.rs index 028b54d32..62cf69a37 100644 --- a/crates/rpc/src/rundler.rs +++ b/crates/rpc/src/rundler.rs @@ -32,8 +32,6 @@ pub struct Settings { /// If using a bundle priority fee, the percentage to add to the network/oracle /// provided value as a safety margin for fast inclusion. pub bundle_priority_fee_overhead_percent: u32, - /// Max verification gas - pub max_verification_gas: u64, } #[rpc(client, server, namespace = "rundler")] @@ -60,7 +58,6 @@ pub trait RundlerApi { pub(crate) struct RundlerApi { chain_spec: ChainSpec, - settings: Settings, fee_estimator: F, pool_server: P, entry_point_router: EntryPointRouter, @@ -103,11 +100,9 @@ where entry_point_router: EntryPointRouter, pool_server: P, fee_estimator: F, - settings: Settings, ) -> Self { Self { chain_spec: chain_spec.clone(), - settings, entry_point_router, pool_server, fee_estimator, @@ -143,10 +138,9 @@ where Err(EthRpcError::InvalidParams("Invalid user operation for drop: preVerificationGas, callGasLimit, callData, and maxFeePerGas must be zero".to_string()))?; } - // TODO(danc): HERE let valid = self .entry_point_router - .check_signature(&entry_point, uo, self.settings.max_verification_gas) + .check_signature(&entry_point, uo) .await?; if !valid { Err(EthRpcError::InvalidParams( diff --git a/crates/rpc/src/task.rs b/crates/rpc/src/task.rs index 85e180851..3a49e097d 100644 --- a/crates/rpc/src/task.rs +++ b/crates/rpc/src/task.rs @@ -276,7 +276,6 @@ where entry_point_router, self.pool.clone(), fee_estimator, - self.args.rundler_api_settings, ) .into_rpc(), )?; diff --git a/crates/sim/src/estimation/estimate_call_gas.rs b/crates/sim/src/estimation/estimate_call_gas.rs index 8180e6a5a..6f968e81d 100644 --- a/crates/sim/src/estimation/estimate_call_gas.rs +++ b/crates/sim/src/estimation/estimate_call_gas.rs @@ -126,8 +126,6 @@ where *self.entry_point.address(), target_call_data, block_hash.into(), - // TODO(danc): HERE - self.settings.max_simulate_handle_ops_gas, state_override.clone(), ) .await? @@ -219,8 +217,6 @@ where *self.entry_point.address(), target_call_data, block_hash.into(), - // TODO(danc): HERE - self.settings.max_simulate_handle_ops_gas, state_override.clone(), ) .await? diff --git a/crates/sim/src/estimation/estimate_verification_gas.rs b/crates/sim/src/estimation/estimate_verification_gas.rs index 858bdcdef..933d6e274 100644 --- a/crates/sim/src/estimation/estimate_verification_gas.rs +++ b/crates/sim/src/estimation/estimate_verification_gas.rs @@ -127,8 +127,6 @@ where Address::ZERO, Bytes::new(), block_hash.into(), - // TODO(danc): HERE - self.settings.max_simulate_handle_ops_gas, state_override, ) .await? diff --git a/crates/sim/src/estimation/v0_6.rs b/crates/sim/src/estimation/v0_6.rs index 528b2a14e..19ff3bdd7 100644 --- a/crates/sim/src/estimation/v0_6.rs +++ b/crates/sim/src/estimation/v0_6.rs @@ -190,15 +190,6 @@ where &self, optional_op: &UserOperationOptionalGas, ) -> Result<(), GasEstimationError> { - // TODO(danc): HERE - if let Some(pvg) = optional_op.pre_verification_gas { - if pvg > self.settings.max_verification_gas { - return Err(GasEstimationError::GasFieldTooLarge( - "preVerificationGas", - self.settings.max_verification_gas, - )); - } - } if let Some(vl) = optional_op.verification_gas_limit { if vl > self.settings.max_verification_gas { return Err(GasEstimationError::GasFieldTooLarge( @@ -796,7 +787,7 @@ mod tests { }); entry .expect_simulate_handle_op() - .returning(move |op, _b, _c, _d, _e, _f| { + .returning(move |op, _b, _c, _d, _e| { if op.total_verification_gas_limit() < gas_usage { return Ok(Err(ValidationRevert::EntryPoint("AA23".to_string()))); } @@ -855,7 +846,7 @@ mod tests { }); entry .expect_simulate_handle_op() - .returning(|_a, _b, _c, _d, _e, _f| { + .returning(|_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: EstimateCallGasResult { gasEstimate: U256::from(10000), @@ -910,7 +901,7 @@ mod tests { }); entry .expect_simulate_handle_op() - .returning(|_a, _b, _c, _d, _e, _f| { + .returning(|_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: EstimateCallGasResult { gasEstimate: U256::from(10000), @@ -958,7 +949,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(|_a, _b, _c, _d, _e, _f| { + .returning(|_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: EstimateCallGasResult { gasEstimate: U256::from(100), @@ -1009,7 +1000,7 @@ mod tests { //this mocked response causes error entry .expect_simulate_handle_op() - .returning(|_a, _b, _c, _d, _e, _f| Err(anyhow!("Invalid spoof error").into())); + .returning(|_a, _b, _c, _d, _e| Err(anyhow!("Invalid spoof error").into())); provider.expect_get_gas_used().returning(move |_a| { Ok(GasUsedResult { @@ -1049,7 +1040,7 @@ mod tests { // this should always revert instead of return success entry .expect_simulate_handle_op() - .returning(|_a, _b, _c, _d, _e, _f| { + .returning(|_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: EstimateCallGasResult { gasEstimate: U256::from(10000), @@ -1083,7 +1074,7 @@ mod tests { let gas_estimate = 100_000; entry .expect_simulate_handle_op() - .returning(move |_a, _b, _c, _d, _e, _f| { + .returning(move |_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: EstimateCallGasResult { gasEstimate: U256::from(gas_estimate), @@ -1121,7 +1112,7 @@ mod tests { // for a successful gas estimation entry .expect_simulate_handle_op() - .returning(|_a, _b, _c, _d, _e, _f| { + .returning(|_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: EstimateCallGasRevertAtMax { revertData: Bytes::new(), @@ -1158,7 +1149,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(|_a, _b, _c, _d, _e, _f| { + .returning(|_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: EstimateCallGasContinuation { minGas: U256::from(100), @@ -1174,7 +1165,7 @@ mod tests { .times(1); entry .expect_simulate_handle_op() - .returning(|_a, _b, _c, _d, _e, _f| { + .returning(|_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: EstimateCallGasResult { gasEstimate: U256::from(200), @@ -1213,7 +1204,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(move |op, _b, _c, _d, _e, _f| { + .returning(move |op, _b, _c, _d, _e| { if op.total_verification_gas_limit() < gas_usage { return Ok(Err(ValidationRevert::EntryPoint("AA23".to_string()))); } @@ -1316,25 +1307,6 @@ mod tests { ); } - #[tokio::test] - async fn test_pvg_over_max() { - let (entry, provider) = create_base_config(); - let (estimator, _) = create_estimator(entry, provider); - - let optional_op = demo_user_op_optional_gas(Some(TEST_MAX_GAS_LIMITS + 1)); - - let estimation = estimator - .estimate_op_gas(optional_op, StateOverride::default()) - .await - .err() - .unwrap(); - - assert!(matches!( - estimation, - GasEstimationError::GasFieldTooLarge("preVerificationGas", TEST_MAX_GAS_LIMITS) - )); - } - #[tokio::test] async fn test_vgl_over_max() { let (entry, provider) = create_base_config(); @@ -1385,7 +1357,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(move |_a, _b, _c, _d, _e, _f| { + .returning(move |_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: TestCallGasResult { success: true, @@ -1439,7 +1411,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(move |_a, _b, _c, _d, _e, _f| { + .returning(move |_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: TestCallGasResult { success: false, @@ -1481,7 +1453,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(move |_a, _b, _c, _d, _e, _f| { + .returning(move |_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: TestCallGasResult { success: true, diff --git a/crates/sim/src/estimation/v0_7.rs b/crates/sim/src/estimation/v0_7.rs index 59911967e..f66c85294 100644 --- a/crates/sim/src/estimation/v0_7.rs +++ b/crates/sim/src/estimation/v0_7.rs @@ -208,15 +208,6 @@ where &self, optional_op: &UserOperationOptionalGas, ) -> Result<(), GasEstimationError> { - if let Some(pvg) = optional_op.pre_verification_gas { - // TODO(danc): HERE - if pvg > self.settings.max_verification_gas { - return Err(GasEstimationError::GasFieldTooLarge( - "preVerificationGas", - self.settings.max_verification_gas, - )); - } - } if let Some(vl) = optional_op.verification_gas_limit { if vl > self.settings.max_verification_gas { return Err(GasEstimationError::GasFieldTooLarge( @@ -623,25 +614,6 @@ mod tests { } } - #[tokio::test] - async fn test_pvg_over_max() { - let (entry, provider) = create_base_config(); - let (estimator, _) = create_estimator(entry, provider); - - let optional_op = demo_user_op_optional_gas(Some(TEST_MAX_GAS_LIMITS + 1)); - - let estimation = estimator - .estimate_op_gas(optional_op, StateOverride::default()) - .await - .err() - .unwrap(); - - assert!(matches!( - estimation, - GasEstimationError::GasFieldTooLarge("preVerificationGas", TEST_MAX_GAS_LIMITS) - )); - } - #[tokio::test] async fn test_vgl_over_max() { let (entry, provider) = create_base_config(); @@ -735,7 +707,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(move |_a, _b, _c, _d, _e, _f| { + .returning(move |_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: TestCallGasResult { success: true, @@ -796,7 +768,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(move |_a, _b, _c, _d, _e, _f| { + .returning(move |_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: TestCallGasResult { success: false, @@ -834,7 +806,7 @@ mod tests { entry .expect_simulate_handle_op() - .returning(move |_a, _b, _c, _d, _e, _f| { + .returning(move |_a, _b, _c, _d, _e| { Ok(Ok(ExecutionResult { target_result: TestCallGasResult { success: true, diff --git a/crates/sim/src/simulation/mod.rs b/crates/sim/src/simulation/mod.rs index 8394bb126..020947beb 100644 --- a/crates/sim/src/simulation/mod.rs +++ b/crates/sim/src/simulation/mod.rs @@ -168,10 +168,6 @@ pub struct Settings { /// The minimum amount of stake that a staked entity must have on the entry point /// contract in order to be considered staked. pub min_stake_value: U256, - /// The maximum amount of gas that can be used during the simulation call - pub max_simulate_handle_ops_gas: u64, - /// The maximum amount of verification gas that can be used during the simulation call - pub max_verification_gas: u64, /// The max duration of the custom javascript tracer. Must be in a format parseable by the /// ParseDuration function on an ethereum node. See Docs: https://pkg.go.dev/time#ParseDuration pub tracer_timeout: String, @@ -179,18 +175,10 @@ pub struct Settings { impl Settings { /// Create new settings - pub fn new( - min_unstake_delay: u32, - min_stake_value: U256, - max_simulate_handle_ops_gas: u64, - max_verification_gas: u64, - tracer_timeout: String, - ) -> Self { + pub fn new(min_unstake_delay: u32, min_stake_value: U256, tracer_timeout: String) -> Self { Self { min_unstake_delay, min_stake_value, - max_simulate_handle_ops_gas, - max_verification_gas, tracer_timeout, } } @@ -204,9 +192,6 @@ impl Default for Settings { min_unstake_delay: 84600, // 10^18 wei = 1 eth min_stake_value: uint!(1_000_000_000_000_000_000_U256), - // 550 million gas: currently the defaults for Alchemy eth_call - max_simulate_handle_ops_gas: 550_000_000, - max_verification_gas: 5_000_000, tracer_timeout: "10s".to_string(), } } diff --git a/crates/sim/src/simulation/simulator.rs b/crates/sim/src/simulation/simulator.rs index 47052f550..9e7f3a871 100644 --- a/crates/sim/src/simulation/simulator.rs +++ b/crates/sim/src/simulation/simulator.rs @@ -160,7 +160,6 @@ where &self, op: UO, aggregator_address: Option
, - gas_cap: u64, ) -> Result { let Some(aggregator_address) = aggregator_address else { return Ok(AggregatorOut::NotNeeded); @@ -168,7 +167,7 @@ where Ok(self .entry_point - .validate_user_op_signature(aggregator_address, op, gas_cap) + .validate_user_op_signature(aggregator_address, op) .await .context("should call validate user op signature")?) } @@ -421,12 +420,8 @@ where ) .map_err(|e| SimulationError::from(anyhow::anyhow!("should call get_code_hash {e:?}"))); - // TODO(danc): HERE - let aggregator_signature_future = self.validate_aggregator_signature( - op, - aggregator_address, - self.sim_settings.max_verification_gas, - ); + let aggregator_signature_future = + self.validate_aggregator_signature(op, aggregator_address); let (code_hash, aggregator_out) = tokio::try_join!(code_hash_future, aggregator_signature_future)?; @@ -897,7 +892,7 @@ mod tests { entry_point .expect_validate_user_op_signature() - .returning(|_, _, _| Ok(AggregatorOut::NotNeeded)); + .returning(|_, _| Ok(AggregatorOut::NotNeeded)); let user_operation = UserOperationBuilder::new(&ChainSpec::default(),UserOperationRequiredFields { sender: address!("b856dbd4fa1a79a46d426f537455e7d3e79ab7c4"), diff --git a/crates/sim/src/simulation/unsafe_sim.rs b/crates/sim/src/simulation/unsafe_sim.rs index f7807717c..7bff702d0 100644 --- a/crates/sim/src/simulation/unsafe_sim.rs +++ b/crates/sim/src/simulation/unsafe_sim.rs @@ -19,9 +19,7 @@ use rundler_provider::{ }; use rundler_types::{pool::SimulationViolation, EntityInfos, UserOperation, ValidTimeRange}; -use crate::{ - SimulationError, SimulationResult, SimulationSettings as Settings, Simulator, ViolationError, -}; +use crate::{SimulationError, SimulationResult, Simulator, ViolationError}; /// An unsafe simulator that can be used in place of a regular simulator /// to extract the information needed from simulation while avoiding the use @@ -32,17 +30,15 @@ use crate::{ pub struct UnsafeSimulator { provider: P, entry_point: E, - sim_settings: Settings, _uo_type: PhantomData, } impl UnsafeSimulator { /// Creates a new unsafe simulator - pub fn new(provider: P, entry_point: E, sim_settings: Settings) -> Self { + pub fn new(provider: P, entry_point: E) -> Self { Self { provider, entry_point, - sim_settings, _uo_type: PhantomData, } } @@ -81,15 +77,10 @@ where } }; - // TODO(danc): HERE // simulate the validation let validation_result = self .entry_point - .simulate_validation( - op.clone(), - self.sim_settings.max_verification_gas, - Some(block_hash.into()), - ) + .simulate_validation(op.clone(), Some(block_hash.into())) .await?; let validation_result = match validation_result { @@ -128,14 +119,9 @@ where let mut violations = vec![]; let aggregator = if let Some(aggregator_info) = validation_result.aggregator_info { - // TODO(danc): HERE let agg_out = self .entry_point - .validate_user_op_signature( - aggregator_info.address, - op, - self.sim_settings.max_verification_gas, - ) + .validate_user_op_signature(aggregator_info.address, op) .await?; match agg_out { diff --git a/crates/sim/src/simulation/v0_6/context.rs b/crates/sim/src/simulation/v0_6/context.rs index 14b958db5..a68e12003 100644 --- a/crates/sim/src/simulation/v0_6/context.rs +++ b/crates/sim/src/simulation/v0_6/context.rs @@ -183,11 +183,9 @@ where /// Creates a new `ValidationContextProvider` for entry point v0.6 with the given provider and entry point. pub(crate) fn new(provider: P, entry_point: E, sim_settings: SimulationSettings) -> Self { Self { - // TODO(danc): HERE simulate_validation_tracer: SimulateValidationTracerImpl::new( provider, entry_point, - sim_settings.max_verification_gas, sim_settings.tracer_timeout.clone(), ), sim_settings, diff --git a/crates/sim/src/simulation/v0_6/tracer.rs b/crates/sim/src/simulation/v0_6/tracer.rs index ede87f214..2f713578c 100644 --- a/crates/sim/src/simulation/v0_6/tracer.rs +++ b/crates/sim/src/simulation/v0_6/tracer.rs @@ -51,7 +51,6 @@ pub(super) trait SimulateValidationTracer: Send + Sync { pub(crate) struct SimulateValidationTracerImpl { provider: P, entry_point: E, - max_validation_gas: u64, tracer_timeout: String, } @@ -71,7 +70,7 @@ where ) -> anyhow::Result { let (tx, state_override) = self .entry_point - .get_tracer_simulate_validation_call(op, self.max_validation_gas) + .get_tracer_simulate_validation_call(op) .context("should get simulate validation call")?; TracerOutput::try_from( @@ -98,16 +97,10 @@ where impl SimulateValidationTracerImpl { /// Creates a new instance of the bundler's custom tracer. - pub(crate) fn new( - provider: P, - entry_point: E, - max_validation_gas: u64, - tracer_timeout: String, - ) -> Self { + pub(crate) fn new(provider: P, entry_point: E, tracer_timeout: String) -> Self { Self { provider, entry_point, - max_validation_gas, tracer_timeout, } } diff --git a/crates/sim/src/simulation/v0_7/context.rs b/crates/sim/src/simulation/v0_7/context.rs index 06c774520..d5e511498 100644 --- a/crates/sim/src/simulation/v0_7/context.rs +++ b/crates/sim/src/simulation/v0_7/context.rs @@ -465,11 +465,9 @@ where pub(crate) fn new(provider: P, entry_point: E, sim_settings: SimulationSettings) -> Self { Self { entry_point_address: *entry_point.address(), - // TODO(danc): HERE simulate_validation_tracer: SimulateValidationTracerImpl::new( provider, entry_point, - sim_settings.max_verification_gas, sim_settings.tracer_timeout.clone(), ), sim_settings, diff --git a/crates/sim/src/simulation/v0_7/tracer.rs b/crates/sim/src/simulation/v0_7/tracer.rs index 81a2c3799..66a31dad7 100644 --- a/crates/sim/src/simulation/v0_7/tracer.rs +++ b/crates/sim/src/simulation/v0_7/tracer.rs @@ -125,7 +125,6 @@ pub(super) trait SimulateValidationTracer: Send + Sync { pub(crate) struct SimulateValidationTracerImpl { provider: P, entry_point: E, - max_validation_gas: u64, tracer_timeout: String, } @@ -145,7 +144,7 @@ where ) -> anyhow::Result { let (tx, state_override) = self .entry_point - .get_tracer_simulate_validation_call(op, self.max_validation_gas) + .get_tracer_simulate_validation_call(op) .context("should get tracer simulate validation call")?; let out = self @@ -173,16 +172,10 @@ where impl SimulateValidationTracerImpl { /// Creates a new instance of the bundler's custom tracer. - pub(crate) fn new( - provider: P, - entry_point: E, - max_validation_gas: u64, - tracer_timeout: String, - ) -> Self { + pub(crate) fn new(provider: P, entry_point: E, tracer_timeout: String) -> Self { Self { provider, entry_point, - max_validation_gas, tracer_timeout, } } diff --git a/crates/types/src/user_operation/v0_6.rs b/crates/types/src/user_operation/v0_6.rs index 98b97f9a1..bd3296900 100644 --- a/crates/types/src/user_operation/v0_6.rs +++ b/crates/types/src/user_operation/v0_6.rs @@ -453,7 +453,6 @@ impl UserOperationOptionalGas { let cgl = super::default_if_none_or_equal(self.call_gas_limit, max_call_gas, 0); let vgl = super::default_if_none_or_equal(self.verification_gas_limit, max_verification_gas, 0); - // TODO(danc): HERE let pvg = super::default_if_none_or_equal(self.pre_verification_gas, max_call_gas, 0); let required = UserOperationRequiredFields { diff --git a/crates/types/src/user_operation/v0_7.rs b/crates/types/src/user_operation/v0_7.rs index 170fb3b7b..ca83c7456 100644 --- a/crates/types/src/user_operation/v0_7.rs +++ b/crates/types/src/user_operation/v0_7.rs @@ -429,7 +429,6 @@ impl UserOperationOptionalGas { max_paymaster_verification_gas, 0, ); - // TODO(danc): HERE let pvg = super::default_if_none_or_equal(self.pre_verification_gas, max_call_gas, 0); let mut builder = UserOperationBuilder::new(