Skip to content

Commit 7b18dc8

Browse files
authored
fix: populate missing fields for eth simulate (#10682)
* fix: populate missing fields for eth simulate * fmt
1 parent 62ce5bc commit 7b18dc8

File tree

1 file changed

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

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,7 @@ impl Backend {
16801680
request,
16811681
Signature::new(Default::default(), Default::default(), false),
16821682
)?;
1683+
let tx_hash = tx.hash();
16831684
let rpc_tx = transaction_build(
16841685
None,
16851686
MaybeImpersonatedTransaction::impersonated(tx, from),
@@ -1713,20 +1714,22 @@ impl Backend {
17131714
removed: false,
17141715

17151716
block_hash: None,
1716-
transaction_hash: None,
1717+
transaction_hash: Some(tx_hash),
17171718
})
17181719
.collect(),
17191720
};
1721+
17201722
let receipt = Receipt {
17211723
status: result.is_success().into(),
17221724
cumulative_gas_used: result.gas_used(),
1723-
logs:sim_res.logs.clone()
1725+
logs: sim_res.logs.clone()
17241726
};
17251727
receipts.push(receipt.with_bloom());
17261728
logs.extend(sim_res.logs.clone().iter().map(|log| log.inner.clone()));
17271729
log_index += sim_res.logs.len();
17281730
call_res.push(sim_res);
17291731
}
1732+
17301733
let transactions_envelopes: Vec<AnyTxEnvelope> = transactions
17311734
.iter()
17321735
.map(|tx| AnyTxEnvelope::from(tx.clone()))
@@ -1736,7 +1739,6 @@ impl Backend {
17361739
transactions_root: calculate_transaction_root(&transactions_envelopes),
17371740
receipts_root: calculate_receipt_root(&transactions_envelopes),
17381741
parent_hash: Default::default(),
1739-
ommers_hash: Default::default(),
17401742
beneficiary: block_env.beneficiary,
17411743
state_root: Default::default(),
17421744
difficulty: Default::default(),
@@ -1753,6 +1755,7 @@ impl Backend {
17531755
excess_blob_gas: None,
17541756
parent_beacon_block_root: None,
17551757
requests_hash: None,
1758+
..Default::default()
17561759
};
17571760
let mut block = alloy_rpc_types::Block {
17581761
header: AnyRpcHeader {
@@ -1770,6 +1773,12 @@ impl Backend {
17701773
block.transactions.convert_to_hashes();
17711774
}
17721775

1776+
for res in &mut call_res {
1777+
res.logs.iter_mut().for_each(|log| {
1778+
log.block_hash = Some(block.header.hash);
1779+
});
1780+
}
1781+
17731782
let simulated_block = SimulatedBlock {
17741783
inner: AnyRpcBlock::new(WithOtherFields::new(block)),
17751784
calls: call_res,

0 commit comments

Comments
 (0)