From e1146fc893f4a801d6f980d0cbbc45bd7ec1c9c6 Mon Sep 17 00:00:00 2001 From: Ivan Schasny <31857042+ischasny@users.noreply.github.com> Date: Tue, 20 Aug 2024 20:16:10 +0100 Subject: [PATCH] fix: use lower fair l2 gas price for cbt (#2690) this PR reduces fair l2 gas price for chains that use custom base token. This is needed because CBT quote might fluctuate a lot for volatile tokens. By the time a transaction reaches the server, it could have already changed. Such transactions might fail validation without even getting into the mempool. --- core/node/api_server/src/tx_sender/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/node/api_server/src/tx_sender/mod.rs b/core/node/api_server/src/tx_sender/mod.rs index 18c500c0ed0..cec2e14ddb2 100644 --- a/core/node/api_server/src/tx_sender/mod.rs +++ b/core/node/api_server/src/tx_sender/mod.rs @@ -517,7 +517,12 @@ impl TxSender { ); return Err(SubmitTxError::GasLimitIsTooBig); } - if tx.common_data.fee.max_fee_per_gas < fee_input.fair_l2_gas_price().into() { + + // At the moment fair_l2_gas_price is rarely changed for ETH-based chains. But for CBT + // chains it gets changed every few blocks because of token price change. We want to avoid + // situations when transactions with low gas price gets into mempool and sit there for a + // long time, so we require max_fee_per_gas to be at least current_l2_fair_gas_price / 2 + if tx.common_data.fee.max_fee_per_gas < (fee_input.fair_l2_gas_price() / 2).into() { tracing::info!( "Submitted Tx is Unexecutable {:?} because of MaxFeePerGasTooLow {}", tx.hash(),