From fca0a6c5ed3576a692c2444ec459e0ee5321e3e5 Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 15 Jun 2023 15:05:58 -0400 Subject: [PATCH] fix(anvil): treat 0 basefee as constant (#5163) --- anvil/src/eth/fees.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/anvil/src/eth/fees.rs b/anvil/src/eth/fees.rs index ff665aa2cf84..5b1e54679a4f 100644 --- a/anvil/src/eth/fees.rs +++ b/anvil/src/eth/fees.rs @@ -123,6 +123,12 @@ impl FeeManager { gas_limit: U256, last_fee_per_gas: U256, ) -> u64 { + // It's naturally impossible for base fee to be 0; + // It means it was set by the user deliberately and therefore we treat it as a constant. + // Therefore, we skip the base fee calculation altogether and we return 0. + if self.base_fee() == U256::zero() { + return 0 + } calculate_next_block_base_fee( gas_used.as_u64(), gas_limit.as_u64(),