Skip to content

Commit 3876113

Browse files
committed
fix(chain-1992): enforce minimum base fee
1 parent 7b8603f commit 3876113

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

solana/programs/base_relayer/src/internal/eip_1559.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Eip1559 {
6767
}
6868

6969
// Update state for new window
70-
self.current_base_fee = current_base_fee;
70+
self.current_base_fee = current_base_fee.max(self.config.minimum_base_fee);
7171
self.current_window_gas_used = 0;
7272
self.window_start_time = current_timestamp;
7373

@@ -104,10 +104,7 @@ impl Eip1559 {
104104
/ self.config.target
105105
/ self.config.denominator;
106106

107-
// Ensure base fee doesn't go below the configurable minimum
108-
self.current_base_fee
109-
.checked_sub(base_fee_delta)
110-
.unwrap_or(self.config.minimum_base_fee)
107+
self.current_base_fee.saturating_sub(base_fee_delta)
111108
}
112109
}
113110

solana/programs/bridge/src/common/state/bridge.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl Eip1559 {
9999
}
100100

101101
// Update state for new window
102-
self.current_base_fee = current_base_fee;
102+
self.current_base_fee = current_base_fee.max(self.config.minimum_base_fee);
103103
self.current_window_gas_used = 0;
104104
self.window_start_time = current_timestamp;
105105

@@ -136,11 +136,7 @@ impl Eip1559 {
136136
/ self.config.target
137137
/ self.config.denominator;
138138

139-
// Note: This implementation only clamps to `minimum_base_fee` on underflow.
140-
// If the subtraction does not underflow, the result may be below `minimum_base_fee`.
141-
self.current_base_fee
142-
.checked_sub(base_fee_delta)
143-
.unwrap_or(self.config.minimum_base_fee)
139+
self.current_base_fee.saturating_sub(base_fee_delta)
144140
}
145141
}
146142

0 commit comments

Comments
 (0)