From 9a84f6e2b2bec12d802c2f752bf34e7273dbc8f1 Mon Sep 17 00:00:00 2001 From: dancoombs Date: Wed, 26 Jun 2024 16:16:51 -0500 Subject: [PATCH] fix(pool): fix crash when block height goes backwards --- crates/builder/src/transaction_tracker.rs | 6 ++++-- crates/pool/src/mempool/pool.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/builder/src/transaction_tracker.rs b/crates/builder/src/transaction_tracker.rs index fcc5a2c3a..582ab6f69 100644 --- a/crates/builder/src/transaction_tracker.rs +++ b/crates/builder/src/transaction_tracker.rs @@ -267,8 +267,10 @@ where self.validate_transaction(&tx)?; let gas_fees = GasFees::from(&tx); info!( - "Sending transaction with nonce: {:?} gas fees: {:?}", - self.nonce, gas_fees + "Sending transaction with nonce: {:?} gas fees: {:?} gas limit: {:?}", + self.nonce, + gas_fees, + tx.gas() ); let sent_tx = self.sender.send_transaction(tx, expected_storage).await; diff --git a/crates/pool/src/mempool/pool.rs b/crates/pool/src/mempool/pool.rs index a5f2eb022..e3a0f0595 100644 --- a/crates/pool/src/mempool/pool.rs +++ b/crates/pool/src/mempool/pool.rs @@ -173,8 +173,8 @@ impl PoolInner { .duration_since(UNIX_EPOCH) .expect("time should be after epoch"); - let block_delta_time = sys_block_time - self.prev_sys_block_time; - let block_delta_height = block_number - self.prev_block_number; + let block_delta_time = sys_block_time.saturating_sub(self.prev_sys_block_time); + let block_delta_height = block_number.saturating_sub(self.prev_block_number); let candidate_gas_price = base_fee + candidate_gas_fees.max_priority_fee_per_gas; let mut expired = Vec::new(); let mut num_candidates = 0;