Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions configs/local/driver.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tx-gas-limit = 45000000

[[solver]]
name = "baseline" # Arbitrary name given to this solver, must be unique
endpoint = "http://baseline"
Expand Down
1 change: 1 addition & 0 deletions crates/driver/example.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
32 changes: 5 additions & 27 deletions crates/driver/src/infra/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -82,6 +82,7 @@ struct Inner {
current_block: CurrentBlockWatcher,
balance_simulator: BalanceSimulator,
balance_overrider: Arc<dyn BalanceOverriding>,
tx_gas_limit: U256,
}

impl Ethereum {
Expand All @@ -96,6 +97,7 @@ impl Ethereum {
addresses: contracts::Addresses,
gas: Arc<GasPriceEstimator>,
archive_node_url: Option<&Url>,
tx_gas_limit: U256,
) -> Self {
let Rpc { web3, chain, args } = rpc;

Expand Down Expand Up @@ -136,6 +138,7 @@ impl Ethereum {
gas,
balance_simulator,
balance_overrider,
tx_gas_limit,
}),
web3,
}
Expand Down Expand Up @@ -190,32 +193,7 @@ impl Ethereum {
CallRequest: From<T>,
{
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
Expand Down
1 change: 1 addition & 0 deletions crates/driver/src/infra/config/file/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
5 changes: 2 additions & 3 deletions crates/driver/src/infra/config/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ struct Config {
#[serde(default)]
flashloans_enabled: bool,

#[allow(dead_code)]
#[serde_as(as = "Option<HexOrDecimalU256>")]
tx_gas_limit: Option<eth::U256>,
#[serde_as(as = "HexOrDecimalU256")]
tx_gas_limit: eth::U256,
}

#[serde_as]
Expand Down
1 change: 1 addition & 0 deletions crates/driver/src/infra/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ pub struct Config {
pub archive_node_url: Option<Url>,
pub simulation_bad_token_max_age: Duration,
pub app_data_fetching: AppDataFetching,
pub tx_gas_limit: eth::U256,
}
1 change: 1 addition & 0 deletions crates/driver/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions crates/driver/src/tests/setup/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions crates/driver/src/tests/setup/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ impl Solver {
},
gas,
None,
45_000_000.into(),
)
.await;

Expand Down
1 change: 1 addition & 0 deletions crates/e2e/src/setup/colocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading