Skip to content

Commit 026b351

Browse files
Rimeeeeeemattsse
andauthored
replaced default with calculate (#10236)
* replaced default with calculate * fmt * fmt fixes * fixes * fmt * touchups --------- Co-authored-by: Matthias Seitz <[email protected]>
1 parent cc50b16 commit 026b351

File tree

1 file changed

+22
-8
lines changed
  • crates/anvil/src/eth/backend/mem

1 file changed

+22
-8
lines changed

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ use crate::{
3636
};
3737
use alloy_chains::NamedChain;
3838
use alloy_consensus::{
39-
transaction::Recovered, Account, BlockHeader, Header, Receipt, ReceiptWithBloom, Signed,
39+
proofs::{calculate_receipt_root, calculate_transaction_root},
40+
transaction::Recovered,
41+
Account, BlockHeader, Header, Receipt, ReceiptWithBloom, Signed,
4042
Transaction as TransactionTrait, TxEnvelope,
4143
};
4244
use alloy_eips::{eip1559::BaseFeeParams, eip4844::MAX_BLOBS_PER_BLOCK};
@@ -45,7 +47,8 @@ use alloy_network::{
4547
EthereumWallet, UnknownTxEnvelope, UnknownTypedTransaction,
4648
};
4749
use alloy_primitives::{
48-
address, hex, keccak256, utils::Unit, Address, Bytes, TxHash, TxKind, B256, U256, U64,
50+
address, hex, keccak256, logs_bloom, utils::Unit, Address, Bytes, TxHash, TxKind, B256, U256,
51+
U64,
4952
};
5053
use alloy_rpc_types::{
5154
anvil::Forking,
@@ -1512,6 +1515,8 @@ impl Backend {
15121515
let mut log_index = 0;
15131516
let mut gas_used = 0;
15141517
let mut transactions = Vec::with_capacity(calls.len());
1518+
let mut receipts = Vec::new();
1519+
let mut logs= Vec::new();
15151520
// apply state overrides before executing the transactions
15161521
if let Some(state_overrides) = state_overrides {
15171522
state::apply_cached_db_state_override(state_overrides, &mut cache_db)?;
@@ -1617,7 +1622,7 @@ impl Backend {
16171622
message: "execution failed".to_string(),
16181623
}
16191624
}),
1620-
logs: result
1625+
logs: result.clone()
16211626
.into_logs()
16221627
.into_iter()
16231628
.enumerate()
@@ -1634,15 +1639,24 @@ impl Backend {
16341639
})
16351640
.collect(),
16361641
};
1637-
1642+
let receipt = Receipt {
1643+
status: result.is_success().into(),
1644+
cumulative_gas_used: result.gas_used(),
1645+
logs:sim_res.logs.clone()
1646+
};
1647+
receipts.push(receipt.with_bloom());
1648+
logs.extend(sim_res.logs.clone().iter().map(|log| log.inner.clone()));
16381649
log_index += sim_res.logs.len();
16391650
call_res.push(sim_res);
16401651
}
1641-
1652+
let transactions_envelopes: Vec<AnyTxEnvelope> = transactions
1653+
.iter()
1654+
.map(|tx| AnyTxEnvelope::from(tx.clone()))
1655+
.collect();
16421656
let header = Header {
1643-
logs_bloom: Default::default(),
1644-
transactions_root: Default::default(),
1645-
receipts_root: Default::default(),
1657+
logs_bloom:logs_bloom(logs.iter()),
1658+
transactions_root: calculate_transaction_root(&transactions_envelopes),
1659+
receipts_root: calculate_receipt_root(&transactions_envelopes),
16461660
parent_hash: Default::default(),
16471661
ommers_hash: Default::default(),
16481662
beneficiary: block_env.coinbase,

0 commit comments

Comments
 (0)