Skip to content

Commit 75151e9

Browse files
authored
refactor(anvil): use alloy's effective_gas_price in Backend::mined_transaction_receipt (#12639)
* refactor(anvil): use alloy's `effective_gas_price` in `Backend::mined_transaction_receipt` * fix: base_fee from block header
1 parent 3a38e02 commit 75151e9

File tree

1 file changed

+1
-20
lines changed
  • crates/anvil/src/eth/backend/mem

1 file changed

+1
-20
lines changed

crates/anvil/src/eth/backend/mem/mod.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,26 +3120,7 @@ impl Backend {
31203120
alloy_eips::eip4844::calc_blob_gasprice(excess_blob_gas.unwrap_or_default());
31213121
let blob_gas_used = transaction.blob_gas_used();
31223122

3123-
let effective_gas_price = match transaction.transaction {
3124-
TypedTransaction::Legacy(t) => t.tx().gas_price,
3125-
TypedTransaction::EIP2930(t) => t.tx().gas_price,
3126-
TypedTransaction::EIP1559(t) => block
3127-
.header
3128-
.base_fee_per_gas
3129-
.map_or(self.base_fee() as u128, |g| g as u128)
3130-
.saturating_add(t.tx().max_priority_fee_per_gas),
3131-
TypedTransaction::EIP4844(t) => block
3132-
.header
3133-
.base_fee_per_gas
3134-
.map_or(self.base_fee() as u128, |g| g as u128)
3135-
.saturating_add(t.tx().tx().max_priority_fee_per_gas),
3136-
TypedTransaction::EIP7702(t) => block
3137-
.header
3138-
.base_fee_per_gas
3139-
.map_or(self.base_fee() as u128, |g| g as u128)
3140-
.saturating_add(t.tx().max_priority_fee_per_gas),
3141-
TypedTransaction::Deposit(_) => 0_u128,
3142-
};
3123+
let effective_gas_price = transaction.effective_gas_price(block.header.base_fee_per_gas);
31433124

31443125
let receipts = self.get_receipts(block.body.transactions.iter().map(|tx| tx.hash()));
31453126
let next_log_index = receipts[..index].iter().map(|r| r.logs().len()).sum::<usize>();

0 commit comments

Comments
 (0)