From eaf96f0c92a5f5258085160101d3e1973977c30c Mon Sep 17 00:00:00 2001 From: Mablr <59505383+mablr@users.noreply.github.com> Date: Sat, 22 Nov 2025 22:38:08 +0100 Subject: [PATCH 1/2] refactor(anvil): use alloy's `effective_gas_price` in `Backend::mined_transaction_receipt` --- crates/anvil/src/eth/backend/mem/mod.rs | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 650caa8ba53bb..1ee1cedf39c71 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -3120,26 +3120,7 @@ impl Backend { alloy_eips::eip4844::calc_blob_gasprice(excess_blob_gas.unwrap_or_default()); let blob_gas_used = transaction.blob_gas_used(); - let effective_gas_price = match transaction.transaction { - TypedTransaction::Legacy(t) => t.tx().gas_price, - TypedTransaction::EIP2930(t) => t.tx().gas_price, - TypedTransaction::EIP1559(t) => block - .header - .base_fee_per_gas - .map_or(self.base_fee() as u128, |g| g as u128) - .saturating_add(t.tx().max_priority_fee_per_gas), - TypedTransaction::EIP4844(t) => block - .header - .base_fee_per_gas - .map_or(self.base_fee() as u128, |g| g as u128) - .saturating_add(t.tx().tx().max_priority_fee_per_gas), - TypedTransaction::EIP7702(t) => block - .header - .base_fee_per_gas - .map_or(self.base_fee() as u128, |g| g as u128) - .saturating_add(t.tx().max_priority_fee_per_gas), - TypedTransaction::Deposit(_) => 0_u128, - }; + let effective_gas_price = transaction.effective_gas_price(Some(self.base_fee())); let receipts = self.get_receipts(block.body.transactions.iter().map(|tx| tx.hash())); let next_log_index = receipts[..index].iter().map(|r| r.logs().len()).sum::(); From 480e9b84d1fd81a930fadd6781fa32970f713b01 Mon Sep 17 00:00:00 2001 From: Mablr <59505383+mablr@users.noreply.github.com> Date: Sun, 23 Nov 2025 19:34:04 +0100 Subject: [PATCH 2/2] fix: base_fee from block header --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 1ee1cedf39c71..fe8e22f02d340 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -3120,7 +3120,7 @@ impl Backend { alloy_eips::eip4844::calc_blob_gasprice(excess_blob_gas.unwrap_or_default()); let blob_gas_used = transaction.blob_gas_used(); - let effective_gas_price = transaction.effective_gas_price(Some(self.base_fee())); + let effective_gas_price = transaction.effective_gas_price(block.header.base_fee_per_gas); let receipts = self.get_receipts(block.body.transactions.iter().map(|tx| tx.hash())); let next_log_index = receipts[..index].iter().map(|r| r.logs().len()).sum::();