diff --git a/crates/eips/src/eip1559/helpers.rs b/crates/eips/src/eip1559/helpers.rs index a37bac89097..056f25f722b 100644 --- a/crates/eips/src/eip1559/helpers.rs +++ b/crates/eips/src/eip1559/helpers.rs @@ -44,17 +44,18 @@ pub fn calc_next_block_base_fee( + (core::cmp::max( // Ensure a minimum increase of 1. 1, - base_fee * (gas_used - gas_target) - / (gas_target * base_fee_params.max_change_denominator as u64), - )) + base_fee as u128 * (gas_used - gas_target) as u128 + / (gas_target as u128 * base_fee_params.max_change_denominator), + ) as u64) } // If the gas used in the current block is less than the gas target, calculate a new // decreased base fee. core::cmp::Ordering::Less => { // Calculate the decrease in base fee based on the formula defined by EIP-1559. base_fee.saturating_sub( - base_fee * (gas_target - gas_used) - / (gas_target * base_fee_params.max_change_denominator as u64), + (base_fee as u128 * (gas_target - gas_used) as u128 + / (gas_target as u128 * base_fee_params.max_change_denominator)) + as u64, ) } }