Skip to content

Commit

Permalink
fix(builder): saturating sub when comparing block numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Feb 18, 2025
1 parent 27b690c commit 1bffaa4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/builder/src/bundle_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ where
if let Some(underpriced_info) = inner.underpriced_info {
// If we are here, there are UOs in the pool that may be correctly priced, but are being blocked by an underpriced replacement
// after a fee increase. If we repeatedly get into this state, initiate a cancellation.
if block_number - underpriced_info.since_block
if block_number.saturating_sub(underpriced_info.since_block)
>= self.settings.max_replacement_underpriced_blocks
{
warn!("No operations available, but last replacement underpriced, moving to cancelling state. Round: {}. Since block {}. Current block {}. Max underpriced blocks: {}", underpriced_info.rounds, underpriced_info.since_block, block_number, self.settings.max_replacement_underpriced_blocks);
Expand Down Expand Up @@ -564,7 +564,7 @@ where
if let Some(last_idle_block) = state.last_idle_block {
metrics
.builder_idle_blocks
.increment(block_number - last_idle_block);
.increment(block_number.saturating_sub(last_idle_block));
}
state.last_idle_block = Some(block_number);
};
Expand Down

0 comments on commit 1bffaa4

Please sign in to comment.