Skip to content

Commit 5339b9a

Browse files
authored
chore: reuse some code (#12395)
1 parent 65f96cf commit 5339b9a

File tree

1 file changed

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

1 file changed

+3
-20
lines changed

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3851,23 +3851,8 @@ pub fn transaction_build(
38513851
}
38523852
}
38533853

3854-
let mut transaction = eth_transaction.into_rpc_transaction();
3855-
3856-
let effective_gas_price = if !transaction.inner.is_dynamic_fee() {
3857-
transaction.effective_gas_price(base_fee)
3858-
} else if block.is_none() && info.is_none() {
3859-
// transaction is not mined yet, gas price is considered just `max_fee_per_gas`
3860-
transaction.max_fee_per_gas()
3861-
} else {
3862-
// if transaction is already mined, gas price is considered base fee + priority
3863-
// fee: the effective gas price.
3864-
let base_fee = base_fee.map_or(0u128, |g| g as u128);
3865-
let max_priority_fee_per_gas = transaction.max_priority_fee_per_gas().unwrap_or(0);
3866-
3867-
base_fee.saturating_add(max_priority_fee_per_gas)
3868-
};
3869-
3870-
transaction.effective_gas_price = Some(effective_gas_price);
3854+
let transaction = eth_transaction.into_rpc_transaction();
3855+
let effective_gas_price = transaction.effective_gas_price(base_fee);
38713856

38723857
let envelope = transaction.inner;
38733858
let from = envelope.signer();
@@ -3909,9 +3894,7 @@ pub fn transaction_build(
39093894

39103895
let tx = Transaction {
39113896
inner: Recovered::new_unchecked(envelope, from),
3912-
block_hash: block
3913-
.as_ref()
3914-
.map(|block| B256::from(keccak256(alloy_rlp::encode(&block.header)))),
3897+
block_hash: block.as_ref().map(|block| block.header.hash_slow()),
39153898
block_number: block.as_ref().map(|block| block.header.number),
39163899
transaction_index: info.as_ref().map(|info| info.transaction_index),
39173900
// deprecated

0 commit comments

Comments
 (0)