Skip to content

Commit

Permalink
fix(eth-sender): add bump of min 10% when resending txs to avoid "rep…
Browse files Browse the repository at this point in the history
…lacement transaction underpriced" (#2422)

Signed-off-by: tomg10 <[email protected]>
  • Loading branch information
tomg10 authored Jul 10, 2024
1 parent 9cdee2c commit a7bcf5d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/node/eth_sender/src/eth_fees_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl GasAdjusterFeesOracle {
previous_sent_tx: &Option<TxHistory>,
time_in_mempool: u32,
) -> Result<EthFees, EthSenderError> {
let base_fee_per_gas = self.gas_adjuster.get_base_fee(time_in_mempool);
let mut base_fee_per_gas = self.gas_adjuster.get_base_fee(time_in_mempool);
if let Some(previous_sent_tx) = previous_sent_tx {
self.verify_base_fee_not_too_low_on_resend(
previous_sent_tx.id,
Expand All @@ -84,6 +84,12 @@ impl GasAdjusterFeesOracle {
priority_fee_per_gas,
(previous_sent_tx.priority_fee_per_gas * 6) / 5 + 1,
);

// same for base_fee_per_gas but 10%
base_fee_per_gas = max(
base_fee_per_gas,
previous_sent_tx.base_fee_per_gas + (previous_sent_tx.base_fee_per_gas / 10) + 1,
);
}

// Extra check to prevent sending transaction will extremely high priority fee.
Expand Down

0 comments on commit a7bcf5d

Please sign in to comment.