From 650d42fea6124d80b60a8270a303d72ad6ac741e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Grze=C5=9Bkiewicz?= Date: Fri, 27 Sep 2024 15:26:47 +0200 Subject: [PATCH] feat(eth-sender): add a cap to time_in_mempool (#2978) Signed-off-by: tomg10 --- core/node/eth_sender/src/eth_fees_oracle.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/node/eth_sender/src/eth_fees_oracle.rs b/core/node/eth_sender/src/eth_fees_oracle.rs index 0c708fee369..2c87848dcc3 100644 --- a/core/node/eth_sender/src/eth_fees_oracle.rs +++ b/core/node/eth_sender/src/eth_fees_oracle.rs @@ -82,7 +82,9 @@ impl GasAdjusterFeesOracle { previous_sent_tx: &Option, time_in_mempool: u32, ) -> Result { - let mut base_fee_per_gas = self.gas_adjuster.get_base_fee(time_in_mempool); + // cap it at 6h to not allow nearly infinite values when a tx is stuck for a long time + let capped_time_in_mempool = min(time_in_mempool, 1800); + let mut base_fee_per_gas = self.gas_adjuster.get_base_fee(capped_time_in_mempool); self.assert_fee_is_not_zero(base_fee_per_gas, "base"); if let Some(previous_sent_tx) = previous_sent_tx { self.verify_base_fee_not_too_low_on_resend(