fix(poststate): duplicate receipts (#2632)

This commit is contained in:
Roman Krasiuk
2023-05-12 20:31:01 +03:00
committed by GitHub
parent 047f1e513c
commit 8c1a1e0e06
8 changed files with 107 additions and 72 deletions

View File

@ -223,7 +223,7 @@ where
self.init_env(&block.header, total_difficulty);
let mut cumulative_gas_used = 0;
let mut post_state = PostState::with_tx_capacity(block.body.len());
let mut post_state = PostState::with_tx_capacity(block.number, block.body.len());
for (transaction, sender) in block.body.iter().zip(senders.into_iter()) {
// The sum of the transactions gas limit, Tg, and the gas utilised in this block prior,
// must be no greater than the blocks gasLimit.
@ -249,15 +249,18 @@ where
cumulative_gas_used += result.gas_used();
// Push transaction changeset and calculate header bloom filter for receipt.
post_state.add_receipt(Receipt {
tx_type: transaction.tx_type(),
// Success flag was added in `EIP-658: Embedding transaction status code in
// receipts`.
success: result.is_success(),
cumulative_gas_used,
// convert to reth log
logs: result.into_logs().into_iter().map(into_reth_log).collect(),
});
post_state.add_receipt(
block.number,
Receipt {
tx_type: transaction.tx_type(),
// Success flag was added in `EIP-658: Embedding transaction status code in
// receipts`.
success: result.is_success(),
cumulative_gas_used,
// convert to reth log
logs: result.into_logs().into_iter().map(into_reth_log).collect(),
},
);
}
Ok((post_state, cumulative_gas_used))
@ -311,7 +314,7 @@ where
verify_receipt(
block.header.receipts_root,
block.header.logs_bloom,
post_state.receipts().iter(),
post_state.receipts(block.number).iter(),
)?;
}