From 59028a998393873bcaea6791778dbeb52b71c150 Mon Sep 17 00:00:00 2001 From: dancoombs Date: Tue, 29 Oct 2024 15:36:32 -0500 Subject: [PATCH] fix(da): fix gas price for da gas estimation to be UO gas price --- crates/builder/src/bundle_proposer.rs | 7 +++---- crates/pool/src/mempool/pool.rs | 2 +- crates/provider/src/alloy/da/optimism.rs | 4 ++++ crates/sim/src/gas/gas.rs | 15 +++------------ 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/crates/builder/src/bundle_proposer.rs b/crates/builder/src/bundle_proposer.rs index 6fd04ee78..b43d33f96 100644 --- a/crates/builder/src/bundle_proposer.rs +++ b/crates/builder/src/bundle_proposer.rs @@ -394,7 +394,7 @@ where da_gas_oracle.calc_da_gas_sync( &op.da_gas_data, da_block_data, - required_op_fees.max_fee_per_gas, + op.uo.gas_price(base_fee), ) } else { match self @@ -403,7 +403,7 @@ where .calc_da_gas( op.uo.clone().into(), block_hash.into(), - required_op_fees.max_fee_per_gas, + op.uo.gas_price(base_fee), ) .await { @@ -2512,9 +2512,8 @@ mod tests { .returning(move |_| Ok(bd_cloned.clone())); da_oracle .expect_calc_da_gas_sync() - .returning(move |_, bd, gp| { + .returning(move |_, bd, _| { assert_eq!(*bd, block_data); - assert_eq!(gp, base_fee + max_priority_fee_per_gas); 100_000 }); diff --git a/crates/pool/src/mempool/pool.rs b/crates/pool/src/mempool/pool.rs index 919e2b681..2357adbae 100644 --- a/crates/pool/src/mempool/pool.rs +++ b/crates/pool/src/mempool/pool.rs @@ -266,7 +266,7 @@ where let required_da_gas = da_gas_oracle.calc_da_gas_sync( &op.po.da_gas_data, block_da_data, - candidate_gas_price, + op.uo().gas_price(base_fee), ); let required_pvg = op.uo().required_pre_verification_gas( diff --git a/crates/provider/src/alloy/da/optimism.rs b/crates/provider/src/alloy/da/optimism.rs index 2c409e760..22d9dc2d0 100644 --- a/crates/provider/src/alloy/da/optimism.rs +++ b/crates/provider/src/alloy/da/optimism.rs @@ -65,6 +65,10 @@ where block: BlockHashOrNumber, gas_price: u128, ) -> ProviderResult<(u128, DAGasUOData, DAGasBlockData)> { + if gas_price == 0 { + Err(anyhow::anyhow!("gas price cannot be zero"))?; + } + let l1_fee: u128 = self .oracle .getL1Fee(data) diff --git a/crates/sim/src/gas/gas.rs b/crates/sim/src/gas/gas.rs index ccc5678d9..2cf6de75c 100644 --- a/crates/sim/src/gas/gas.rs +++ b/crates/sim/src/gas/gas.rs @@ -11,9 +11,9 @@ // You should have received a copy of the GNU General Public License along with Rundler. // If not, see https://www.gnu.org/licenses/. -use std::{cmp, fmt::Debug}; +use std::fmt::Debug; -use anyhow::{bail, Context}; +use anyhow::Context; #[cfg(feature = "test-utils")] use mockall::automock; use rundler_provider::{BlockHashOrNumber, DAGasProvider, EvmProvider}; @@ -68,17 +68,8 @@ pub async fn calc_required_pre_verification_gas anyhow::Result<(u128, DAGasUOData)> { let (da_gas, uo_data) = if chain_spec.da_pre_verification_gas { - let gas_price = cmp::min( - base_fee + op.max_priority_fee_per_gas(), - op.max_fee_per_gas(), - ); - - if gas_price == 0 { - bail!("Gas price cannot be zero") - } - let (da_gas, uo_data, _) = entry_point - .calc_da_gas(op.clone(), block, gas_price) + .calc_da_gas(op.clone(), block, op.gas_price(base_fee)) .await?; (da_gas, uo_data) } else {