feat(op-reth): Canyon receipts root RLP fix (#5504)

This commit is contained in:
clabby
2023-11-27 11:05:41 -05:00
committed by GitHub
parent 462ea82f91
commit 7debf93f36
9 changed files with 375 additions and 239 deletions

View File

@ -333,6 +333,7 @@ impl StorageInner {
bundle_state: &BundleStateWithReceipts,
client: &S,
gas_used: u64,
#[cfg(feature = "optimism")] chain_spec: &ChainSpec,
) -> Result<Header, BlockExecutionError> {
let receipts = bundle_state.receipts_by_block(header.number);
header.receipts_root = if receipts.is_empty() {
@ -344,7 +345,13 @@ impl StorageInner {
.collect::<Vec<ReceiptWithBloom>>();
header.logs_bloom =
receipts_with_bloom.iter().fold(Bloom::ZERO, |bloom, r| bloom | r.bloom);
proofs::calculate_receipt_root(&receipts_with_bloom)
proofs::calculate_receipt_root(
&receipts_with_bloom,
#[cfg(feature = "optimism")]
chain_spec,
#[cfg(feature = "optimism")]
header.timestamp,
)
};
header.gas_used = gas_used;
@ -382,7 +389,7 @@ impl StorageInner {
.with_database_boxed(Box::new(StateProviderDatabase::new(client.latest().unwrap())))
.with_bundle_update()
.build();
let mut executor = EVMProcessor::new_with_state(chain_spec, db);
let mut executor = EVMProcessor::new_with_state(chain_spec.clone(), db);
let (bundle_state, gas_used) = self.execute(&block, &mut executor, senders)?;
@ -392,7 +399,14 @@ impl StorageInner {
trace!(target: "consensus::auto", ?bundle_state, ?header, ?body, "executed block, calculating state root and completing header");
// fill in the rest of the fields
let header = self.complete_header(header, &bundle_state, client, gas_used)?;
let header = self.complete_header(
header,
&bundle_state,
client,
gas_used,
#[cfg(feature = "optimism")]
chain_spec.as_ref(),
)?;
trace!(target: "consensus::auto", root=?header.state_root, ?body, "calculated root");