diff --git a/configs/local/driver.toml b/configs/local/driver.toml index 3f58c4f155..5309fd6c10 100644 --- a/configs/local/driver.toml +++ b/configs/local/driver.toml @@ -1,3 +1,5 @@ +tx-gas-limit = 45000000 + [[solver]] name = "baseline" # Arbitrary name given to this solver, must be unique endpoint = "http://baseline" diff --git a/crates/driver/example.toml b/crates/driver/example.toml index 06a294a813..41573385ea 100644 --- a/crates/driver/example.toml +++ b/crates/driver/example.toml @@ -1,3 +1,4 @@ +tx-gas-limit = "45000000" [[solver]] name = "mysolver" # Arbitrary name given to this solver, must be unique endpoint = "http://0.0.0.0:7872" diff --git a/crates/driver/src/infra/blockchain/mod.rs b/crates/driver/src/infra/blockchain/mod.rs index 52ce057aae..7eca82b195 100644 --- a/crates/driver/src/infra/blockchain/mod.rs +++ b/crates/driver/src/infra/blockchain/mod.rs @@ -2,7 +2,7 @@ use { self::contracts::ContractAt, crate::{boundary, domain::eth}, chain::Chain, - ethcontract::errors::ExecutionError, + ethcontract::{U256, errors::ExecutionError}, ethrpc::{Web3, block_stream::CurrentBlockWatcher}, shared::{ account_balances::{BalanceSimulator, SimulationError}, @@ -82,6 +82,7 @@ struct Inner { current_block: CurrentBlockWatcher, balance_simulator: BalanceSimulator, balance_overrider: Arc, + tx_gas_limit: U256, } impl Ethereum { @@ -96,6 +97,7 @@ impl Ethereum { addresses: contracts::Addresses, gas: Arc, archive_node_url: Option<&Url>, + tx_gas_limit: U256, ) -> Self { let Rpc { web3, chain, args } = rpc; @@ -136,6 +138,7 @@ impl Ethereum { gas, balance_simulator, balance_overrider, + tx_gas_limit, }), web3, } @@ -190,32 +193,7 @@ impl Ethereum { CallRequest: From, { let mut tx: CallRequest = tx.into(); - // Specifically set high gas because some nodes don't pick a sensible value if - // omitted. And since we are only interested in access lists a very high - // value is fine. - tx.gas = Some(match self.inner.chain { - // Arbitrum has an exceptionally high block gas limit (1,125,899,906,842,624), - // making it unsuitable for this use case. To address this, we use a - // fixed gas limit of 100,000,000, which is sufficient - // for all solution types, while avoiding the "insufficient funds for gas * price + - // value" error that could occur when a large amount of ETH is - // needed to simulate the transaction, due to high transaction gas limit. - // - // If a new network is added, ensure its block gas limit is checked and handled - // appropriately to maintain compatibility with this logic. - Chain::ArbitrumOne => 100_000_000.into(), - Chain::Mainnet => self.block_gas_limit().0, - Chain::Goerli => self.block_gas_limit().0, - Chain::Gnosis => self.block_gas_limit().0, - Chain::Sepolia => self.block_gas_limit().0, - Chain::Base => self.block_gas_limit().0, - Chain::Bnb => self.block_gas_limit().0, - Chain::Optimism => self.block_gas_limit().0, - Chain::Avalanche => self.block_gas_limit().0, - Chain::Polygon => self.block_gas_limit().0, - Chain::Lens => self.block_gas_limit().0, - Chain::Hardhat => self.block_gas_limit().0, - }); + tx.gas = Some(self.inner.tx_gas_limit); tx.gas_price = self.simulation_gas_price().await; let json = self diff --git a/crates/driver/src/infra/config/file/load.rs b/crates/driver/src/infra/config/file/load.rs index 840a1c7d20..ffea52ec69 100644 --- a/crates/driver/src/infra/config/file/load.rs +++ b/crates/driver/src/infra/config/file/load.rs @@ -407,5 +407,6 @@ pub async fn load(chain: Chain, path: &Path) -> infra::Config { archive_node_url: config.archive_node_url, simulation_bad_token_max_age: config.simulation_bad_token_max_age, app_data_fetching: config.app_data_fetching, + tx_gas_limit: config.tx_gas_limit, } } diff --git a/crates/driver/src/infra/config/file/mod.rs b/crates/driver/src/infra/config/file/mod.rs index 55721d58a1..27898f578e 100644 --- a/crates/driver/src/infra/config/file/mod.rs +++ b/crates/driver/src/infra/config/file/mod.rs @@ -87,9 +87,8 @@ struct Config { #[serde(default)] flashloans_enabled: bool, - #[allow(dead_code)] - #[serde_as(as = "Option")] - tx_gas_limit: Option, + #[serde_as(as = "HexOrDecimalU256")] + tx_gas_limit: eth::U256, } #[serde_as] diff --git a/crates/driver/src/infra/config/mod.rs b/crates/driver/src/infra/config/mod.rs index c71623f995..389857b6f5 100644 --- a/crates/driver/src/infra/config/mod.rs +++ b/crates/driver/src/infra/config/mod.rs @@ -33,4 +33,5 @@ pub struct Config { pub archive_node_url: Option, pub simulation_bad_token_max_age: Duration, pub app_data_fetching: AppDataFetching, + pub tx_gas_limit: eth::U256, } diff --git a/crates/driver/src/run.rs b/crates/driver/src/run.rs index f33e686a89..ed7f8b7083 100644 --- a/crates/driver/src/run.rs +++ b/crates/driver/src/run.rs @@ -171,6 +171,7 @@ async fn ethereum(config: &infra::Config, ethrpc: blockchain::Rpc) -> Ethereum { config.contracts.clone(), gas, config.archive_node_url.as_ref(), + config.tx_gas_limit, ) .await } diff --git a/crates/driver/src/tests/setup/driver.rs b/crates/driver/src/tests/setup/driver.rs index 94ba6729cc..f40b55c7da 100644 --- a/crates/driver/src/tests/setup/driver.rs +++ b/crates/driver/src/tests/setup/driver.rs @@ -221,6 +221,7 @@ async fn create_config_file( ) .unwrap(); writeln!(file, "flashloans-enabled = true").unwrap(); + writeln!(file, "tx-gas-limit = \"45000000\"").unwrap(); write!( file, r#"[contracts] diff --git a/crates/driver/src/tests/setup/solver.rs b/crates/driver/src/tests/setup/solver.rs index 8a2c8baf22..ce715550ab 100644 --- a/crates/driver/src/tests/setup/solver.rs +++ b/crates/driver/src/tests/setup/solver.rs @@ -484,6 +484,7 @@ impl Solver { }, gas, None, + 45_000_000.into(), ) .await; diff --git a/crates/e2e/src/setup/colocation.rs b/crates/e2e/src/setup/colocation.rs index a7425f0973..d705bbbc71 100644 --- a/crates/e2e/src/setup/colocation.rs +++ b/crates/e2e/src/setup/colocation.rs @@ -200,6 +200,7 @@ factory = "{:?}" app-data-fetching-enabled = true orderbook-url = "http://localhost:8080" flashloans-enabled = true +tx-gas-limit = "45000000" [gas-estimator] estimator = "web3"