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
1 change: 1 addition & 0 deletions crates/e2e/tests/e2e/quote_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ async fn test_bypass_verification_for_rfq_quotes(web3: Web3) {
*onchain.contracts().weth.address(),
BigDecimal::zero(),
Default::default(),
12_000_000,
)
.await
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions crates/price-estimation/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl<'a> PriceEstimatorFactory<'a> {
network.native_token,
args.quote_inaccuracy_limit.clone(),
args.tokens_without_verification.iter().cloned().collect(),
args.max_gas_per_tx,
)
.await?;
Ok(Some(Arc::new(verifier)))
Expand Down
9 changes: 9 additions & 0 deletions crates/price-estimation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ pub struct Arguments {
/// (e.g. private liquidity that exists but can't be verified).
#[clap(long, env, value_delimiter = ',')]
pub tokens_without_verification: Vec<Address>,

/// How much gas a single tx may consume at most. Any quote using more than
/// this will fail during the verification.
/// Defaults to the maximum transaction gas limit of ethereum introduced
/// in the Fusaka hardfork.
Comment thread
MartinquaXD marked this conversation as resolved.
#[clap(long, env, default_value_t = 16777215)]
pub max_gas_per_tx: u64,
}

#[derive(clap::Parser)]
Expand Down Expand Up @@ -178,6 +185,7 @@ impl Display for Arguments {
quote_timeout,
balance_overrides,
tokens_without_verification,
max_gas_per_tx,
} = self;

write!(f, "{tenderly}")?;
Expand Down Expand Up @@ -227,6 +235,7 @@ impl Display for Arguments {
f,
"tokens_without_verification: {tokens_without_verification:?}"
)?;
writeln!(f, "max_gas_per_tx: {max_gas_per_tx}")?;

Ok(())
}
Expand Down
6 changes: 4 additions & 2 deletions crates/price-estimation/src/trade_verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ pub struct TradeVerifier {
quote_inaccuracy_limit: BigRational,
domain_separator: DomainSeparator,
tokens_without_verification: HashSet<Address>,
gas_limit: u64,
}

impl TradeVerifier {
const DEFAULT_GAS: u64 = 12_000_000;
const SPARDOSE: Address = address!("0000000000000000000000000000000000020000");
const TRADER_IMPL: Address = address!("0000000000000000000000000000000000010000");

Expand All @@ -94,6 +94,7 @@ impl TradeVerifier {
native_token: Address,
quote_inaccuracy_limit: BigDecimal,
tokens_without_verification: HashSet<Address>,
gas_limit: u64,
) -> Result<Self> {
let settlement_contract =
GPv2Settlement::GPv2Settlement::new(settlement, web3.provider.clone());
Expand All @@ -110,6 +111,7 @@ impl TradeVerifier {
web3,
domain_separator,
tokens_without_verification,
gas_limit,
})
}

Expand Down Expand Up @@ -176,7 +178,7 @@ impl TradeVerifier {
// Initiate tx as solver so gas doesn't get deducted from user's ETH.
.from(solver_address)
.to(solver_address)
.gas(Self::DEFAULT_GAS)
.gas(self.gas_limit)
// Use a high enough non-zero gas price to catch tokens with special logic
// for gas_price == 0 but also avoid reverts due to too low gas price.
// The exact price is not important since we are only interested in the used
Expand Down
Loading