mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(op-reth): Canyon receipts root RLP fix (#5504)
This commit is contained in:
@ -333,6 +333,7 @@ impl StorageInner {
|
|||||||
bundle_state: &BundleStateWithReceipts,
|
bundle_state: &BundleStateWithReceipts,
|
||||||
client: &S,
|
client: &S,
|
||||||
gas_used: u64,
|
gas_used: u64,
|
||||||
|
#[cfg(feature = "optimism")] chain_spec: &ChainSpec,
|
||||||
) -> Result<Header, BlockExecutionError> {
|
) -> Result<Header, BlockExecutionError> {
|
||||||
let receipts = bundle_state.receipts_by_block(header.number);
|
let receipts = bundle_state.receipts_by_block(header.number);
|
||||||
header.receipts_root = if receipts.is_empty() {
|
header.receipts_root = if receipts.is_empty() {
|
||||||
@ -344,7 +345,13 @@ impl StorageInner {
|
|||||||
.collect::<Vec<ReceiptWithBloom>>();
|
.collect::<Vec<ReceiptWithBloom>>();
|
||||||
header.logs_bloom =
|
header.logs_bloom =
|
||||||
receipts_with_bloom.iter().fold(Bloom::ZERO, |bloom, r| bloom | r.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;
|
header.gas_used = gas_used;
|
||||||
@ -382,7 +389,7 @@ impl StorageInner {
|
|||||||
.with_database_boxed(Box::new(StateProviderDatabase::new(client.latest().unwrap())))
|
.with_database_boxed(Box::new(StateProviderDatabase::new(client.latest().unwrap())))
|
||||||
.with_bundle_update()
|
.with_bundle_update()
|
||||||
.build();
|
.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)?;
|
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");
|
trace!(target: "consensus::auto", ?bundle_state, ?header, ?body, "executed block, calculating state root and completing header");
|
||||||
|
|
||||||
// fill in the rest of the fields
|
// 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");
|
trace!(target: "consensus::auto", root=?header.state_root, ?body, "calculated root");
|
||||||
|
|
||||||
|
|||||||
@ -918,7 +918,15 @@ where
|
|||||||
Receipts::from_vec(vec![receipts]),
|
Receipts::from_vec(vec![receipts]),
|
||||||
block_number,
|
block_number,
|
||||||
);
|
);
|
||||||
let receipts_root = bundle.receipts_root_slow(block_number).expect("Number is in range");
|
let receipts_root = bundle
|
||||||
|
.receipts_root_slow(
|
||||||
|
block_number,
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
chain_spec.as_ref(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
attributes.timestamp,
|
||||||
|
)
|
||||||
|
.expect("Number is in range");
|
||||||
let logs_bloom = bundle.block_logs_bloom(block_number).expect("Number is in range");
|
let logs_bloom = bundle.block_logs_bloom(block_number).expect("Number is in range");
|
||||||
|
|
||||||
// calculate the state root
|
// calculate the state root
|
||||||
|
|||||||
@ -235,7 +235,9 @@ where
|
|||||||
Receipts::from_vec(vec![receipts]),
|
Receipts::from_vec(vec![receipts]),
|
||||||
block_number,
|
block_number,
|
||||||
);
|
);
|
||||||
let receipts_root = bundle.receipts_root_slow(block_number).expect("Number is in range");
|
let receipts_root = bundle
|
||||||
|
.receipts_root_slow(block_number, chain_spec.as_ref(), attributes.timestamp)
|
||||||
|
.expect("Number is in range");
|
||||||
let logs_bloom = bundle.block_logs_bloom(block_number).expect("Number is in range");
|
let logs_bloom = bundle.block_logs_bloom(block_number).expect("Number is in range");
|
||||||
|
|
||||||
// calculate the state root
|
// calculate the state root
|
||||||
|
|||||||
@ -69,13 +69,26 @@ pub fn calculate_withdrawals_root(withdrawals: &[Withdrawal]) -> B256 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates the receipt root for a header.
|
/// Calculates the receipt root for a header.
|
||||||
|
#[cfg(not(feature = "optimism"))]
|
||||||
pub fn calculate_receipt_root(receipts: &[ReceiptWithBloom]) -> B256 {
|
pub fn calculate_receipt_root(receipts: &[ReceiptWithBloom]) -> B256 {
|
||||||
#[cfg(feature = "optimism")]
|
ordered_trie_root_with_encoder(receipts, |r, buf| r.encode_inner(buf, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Calculates the receipt root for a header.
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
pub fn calculate_receipt_root(
|
||||||
|
receipts: &[ReceiptWithBloom],
|
||||||
|
chain_spec: &crate::ChainSpec,
|
||||||
|
timestamp: u64,
|
||||||
|
) -> B256 {
|
||||||
|
// There is a minor bug in op-geth and op-erigon where in the Regolith hardfork,
|
||||||
|
// the receipt root calculation does not include the deposit nonce in the receipt
|
||||||
|
// encoding. In the Regolith Hardfork, we must strip the deposit nonce from the
|
||||||
|
// receipts before calculating the receipt root. This was corrected in the Canyon
|
||||||
|
// hardfork.
|
||||||
|
if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) &&
|
||||||
|
!chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp)
|
||||||
{
|
{
|
||||||
// There is a minor bug in op-geth and op-erigon where in the Regolith hardfork,
|
|
||||||
// the receipt root calculation does not include the deposit nonce in the receipt
|
|
||||||
// encoding. This will be fixd in the next hardfork, however for now, we must strip
|
|
||||||
// the deposit nonce from the receipts before calculating the receipt root.
|
|
||||||
let receipts = receipts
|
let receipts = receipts
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
@ -85,23 +98,41 @@ pub fn calculate_receipt_root(receipts: &[ReceiptWithBloom]) -> B256 {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
ordered_trie_root_with_encoder(receipts.as_slice(), |r, buf| r.encode_inner(buf, false))
|
return ordered_trie_root_with_encoder(receipts.as_slice(), |r, buf| {
|
||||||
|
r.encode_inner(buf, false)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "optimism"))]
|
|
||||||
ordered_trie_root_with_encoder(receipts, |r, buf| r.encode_inner(buf, false))
|
ordered_trie_root_with_encoder(receipts, |r, buf| r.encode_inner(buf, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates the receipt root for a header for the reference type of [Receipt].
|
/// Calculates the receipt root for a header for the reference type of [Receipt].
|
||||||
///
|
///
|
||||||
/// NOTE: Prefer [calculate_receipt_root] if you have log blooms memoized.
|
/// NOTE: Prefer [calculate_receipt_root] if you have log blooms memoized.
|
||||||
|
#[cfg(not(feature = "optimism"))]
|
||||||
pub fn calculate_receipt_root_ref(receipts: &[&Receipt]) -> B256 {
|
pub fn calculate_receipt_root_ref(receipts: &[&Receipt]) -> B256 {
|
||||||
#[cfg(feature = "optimism")]
|
ordered_trie_root_with_encoder(receipts, |r, buf| {
|
||||||
|
ReceiptWithBloomRef::from(*r).encode_inner(buf, false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Calculates the receipt root for a header for the reference type of [Receipt].
|
||||||
|
///
|
||||||
|
/// NOTE: Prefer [calculate_receipt_root] if you have log blooms memoized.
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
pub fn calculate_receipt_root_ref(
|
||||||
|
receipts: &[&Receipt],
|
||||||
|
chain_spec: &crate::ChainSpec,
|
||||||
|
timestamp: u64,
|
||||||
|
) -> B256 {
|
||||||
|
// There is a minor bug in op-geth and op-erigon where in the Regolith hardfork,
|
||||||
|
// the receipt root calculation does not include the deposit nonce in the receipt
|
||||||
|
// encoding. In the Regolith Hardfork, we must strip the deposit nonce from the
|
||||||
|
// receipts before calculating the receipt root. This was corrected in the Canyon
|
||||||
|
// hardfork.
|
||||||
|
if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) &&
|
||||||
|
!chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp)
|
||||||
{
|
{
|
||||||
// There is a minor bug in op-geth and op-erigon where in the Regolith hardfork,
|
|
||||||
// the receipt root calculation does not include the deposit nonce in the receipt
|
|
||||||
// encoding. This will be fixd in the next hardfork, however for now, we must strip
|
|
||||||
// the deposit nonce from the receipts before calculating the receipt root.
|
|
||||||
let receipts = receipts
|
let receipts = receipts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|r| {
|
.map(|r| {
|
||||||
@ -111,12 +142,11 @@ pub fn calculate_receipt_root_ref(receipts: &[&Receipt]) -> B256 {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
ordered_trie_root_with_encoder(&receipts, |r, buf| {
|
return ordered_trie_root_with_encoder(&receipts, |r, buf| {
|
||||||
ReceiptWithBloomRef::from(r).encode_inner(buf, false)
|
ReceiptWithBloomRef::from(r).encode_inner(buf, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "optimism"))]
|
|
||||||
ordered_trie_root_with_encoder(receipts, |r, buf| {
|
ordered_trie_root_with_encoder(receipts, |r, buf| {
|
||||||
ReceiptWithBloomRef::from(*r).encode_inner(buf, false)
|
ReceiptWithBloomRef::from(*r).encode_inner(buf, false)
|
||||||
})
|
})
|
||||||
@ -212,222 +242,248 @@ mod tests {
|
|||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_optimism_receipt_root() {
|
fn check_optimism_receipt_root() {
|
||||||
use crate::{Bloom, Bytes};
|
use crate::{Bloom, Bytes, OP_GOERLI};
|
||||||
|
|
||||||
let receipts = vec![
|
let cases = [
|
||||||
// 0xb0d6ee650637911394396d81172bd1c637d568ed1fbddab0daddfca399c58b53
|
// Deposit nonces didn't exist in Bedrock; No need to strip. For the purposes of this
|
||||||
ReceiptWithBloom {
|
// test, we do have them, so we should get the same root as Canyon.
|
||||||
receipt: Receipt {
|
(
|
||||||
tx_type: TxType::DEPOSIT,
|
"bedrock",
|
||||||
success: true,
|
1679079599,
|
||||||
cumulative_gas_used: 46913,
|
b256!("6eefbb5efb95235476654a8bfbf8cb64a4f5f0b0c80b700b0c5964550beee6d7"),
|
||||||
logs: vec![],
|
),
|
||||||
#[cfg(feature = "optimism")]
|
// Deposit nonces introduced in Regolith. They weren't included in the receipt RLP,
|
||||||
deposit_nonce: Some(4012991u64),
|
// so we need to strip them - the receipt root will differ.
|
||||||
},
|
(
|
||||||
bloom: Bloom(hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into()),
|
"regolith",
|
||||||
},
|
1679079600,
|
||||||
// 0x2f433586bae30573c393adfa02bc81d2a1888a3d6c9869f473fb57245166bd9a
|
b256!("e255fed45eae7ede0556fe4fabc77b0d294d18781a5a581cab09127bc4cd9ffb"),
|
||||||
ReceiptWithBloom {
|
),
|
||||||
receipt: Receipt {
|
// Receipt root hashing bug fixed in Canyon. Back to including the deposit nonce
|
||||||
tx_type: TxType::EIP1559,
|
// in the receipt RLP when computing the receipt root.
|
||||||
success: true,
|
(
|
||||||
cumulative_gas_used: 118083,
|
"canyon",
|
||||||
logs: vec![
|
1699981200,
|
||||||
Log {
|
b256!("6eefbb5efb95235476654a8bfbf8cb64a4f5f0b0c80b700b0c5964550beee6d7"),
|
||||||
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
),
|
||||||
topics: vec![
|
|
||||||
b256!("c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62"),
|
|
||||||
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
|
||||||
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
|
||||||
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62"),
|
|
||||||
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
|
||||||
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
||||||
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("0eb774bb9698a73583fe07b6972cf2dcc08d1d97581a22861f45feb86b395820"),
|
|
||||||
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
|
||||||
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000000000000000003")),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
#[cfg(feature = "optimism")]
|
|
||||||
deposit_nonce: None,
|
|
||||||
},
|
|
||||||
bloom: Bloom(hex!("00001000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000040000000000004000000000080000000000000000000000000000000000000000000000000000008000000000000080020000000000000000000000000002000000000000000000000000000080000010000").into()),
|
|
||||||
},
|
|
||||||
// 0x6c33676e8f6077f46a62eabab70bc6d1b1b18a624b0739086d77093a1ecf8266
|
|
||||||
ReceiptWithBloom {
|
|
||||||
receipt: Receipt {
|
|
||||||
tx_type: TxType::EIP1559,
|
|
||||||
success: true,
|
|
||||||
cumulative_gas_used: 189253,
|
|
||||||
logs: vec![
|
|
||||||
Log {
|
|
||||||
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62"),
|
|
||||||
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
|
||||||
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
|
||||||
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62"),
|
|
||||||
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
|
||||||
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
||||||
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("0eb774bb9698a73583fe07b6972cf2dcc08d1d97581a22861f45feb86b395820"),
|
|
||||||
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
|
||||||
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000000000000000003")),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
#[cfg(feature = "optimism")]
|
|
||||||
deposit_nonce: None,
|
|
||||||
},
|
|
||||||
bloom: Bloom(hex!("00000000000000000000200000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000002000000000020000000000000000000000000000000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000040000000000004000000000080000000000000000000000000000000000000000000000000000008000000000000080020000000000000000000000000002000000000000000000000000000080000000000").into()),
|
|
||||||
},
|
|
||||||
// 0x4d3ecbef04ba7ce7f5ab55be0c61978ca97c117d7da448ed9771d4ff0c720a3f
|
|
||||||
ReceiptWithBloom {
|
|
||||||
receipt: Receipt {
|
|
||||||
tx_type: TxType::EIP1559,
|
|
||||||
success: true,
|
|
||||||
cumulative_gas_used: 346969,
|
|
||||||
logs: vec![
|
|
||||||
Log {
|
|
||||||
address: hex!("4200000000000000000000000000000000000006").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
|
||||||
b256!("000000000000000000000000c3feb4ef4c2a5af77add15c95bd98f6b43640cc8"),
|
|
||||||
b256!("0000000000000000000000002992607c1614484fe6d865088e5c048f0650afd4"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000018de76816d8000")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("cf8e7e6b26f407dee615fc4db18bf829e7aa8c09").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
|
||||||
b256!("0000000000000000000000002992607c1614484fe6d865088e5c048f0650afd4"),
|
|
||||||
b256!("0000000000000000000000008dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("000000000000000000000000000000000000000000000002d24d8e9ac1aa79e2")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("2992607c1614484fe6d865088e5c048f0650afd4").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("000000000000000000000000000000000000000000000009bd50642785c15736000000000000000000000000000000000000000000011bb7ac324f724a29bbbf")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("2992607c1614484fe6d865088e5c048f0650afd4").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("d78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822"),
|
|
||||||
b256!("00000000000000000000000029843613c7211d014f5dd5718cf32bcd314914cb"),
|
|
||||||
b256!("0000000000000000000000008dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000018de76816d800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d24d8e9ac1aa79e2")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("6d0f8d488b669aa9ba2d0f0b7b75a88bf5051cd3").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
|
||||||
b256!("0000000000000000000000008dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09"),
|
|
||||||
b256!("000000000000000000000000c3feb4ef4c2a5af77add15c95bd98f6b43640cc8"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000014bc73062aea8093")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("8dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000002f122cfadc1ca82a35000000000000000000000000000000000000000000000665879dc0609945d6d1")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("8dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("d78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822"),
|
|
||||||
b256!("00000000000000000000000029843613c7211d014f5dd5718cf32bcd314914cb"),
|
|
||||||
b256!("000000000000000000000000c3feb4ef4c2a5af77add15c95bd98f6b43640cc8"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d24d8e9ac1aa79e200000000000000000000000000000000000000000000000014bc73062aea80930000000000000000000000000000000000000000000000000000000000000000")),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
#[cfg(feature = "optimism")]
|
|
||||||
deposit_nonce: None,
|
|
||||||
},
|
|
||||||
bloom: Bloom(hex!("00200000000000000000000080000000000000000000000000040000100004000000000000000000000000100000000000000000000000000000100000000000000000000000000002000008000000200000000200000000020000000000000040000000000000000400000200000000000000000000000000000010000000000400000000010400000000000000000000000000002000c80000004080002000000000000000400200000000800000000000000000000000000000000000000000000002000000000000000000000000000000000100001000000000000000000000002000000000000000000000010000000000000000000000800000800000").into()),
|
|
||||||
},
|
|
||||||
// 0xf738af5eb00ba23dbc1be2dbce41dbc0180f0085b7fb46646e90bf737af90351
|
|
||||||
ReceiptWithBloom {
|
|
||||||
receipt: Receipt {
|
|
||||||
tx_type: TxType::EIP1559,
|
|
||||||
success: true,
|
|
||||||
cumulative_gas_used: 623249,
|
|
||||||
logs: vec![
|
|
||||||
Log {
|
|
||||||
address: hex!("ac6564f3718837caadd42eed742d75c12b90a052").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
|
||||||
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
||||||
b256!("000000000000000000000000a4fa7f3fbf0677f254ebdb1646146864c305b76e"),
|
|
||||||
b256!("000000000000000000000000000000000000000000000000000000000011a1d3"),
|
|
||||||
],
|
|
||||||
data: Default::default(),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("ac6564f3718837caadd42eed742d75c12b90a052").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("9d89e36eadf856db0ad9ffb5a569e07f95634dddd9501141ecf04820484ad0dc"),
|
|
||||||
b256!("000000000000000000000000a4fa7f3fbf0677f254ebdb1646146864c305b76e"),
|
|
||||||
b256!("000000000000000000000000000000000000000000000000000000000011a1d3"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000037697066733a2f2f516d515141646b33736538396b47716577395256567a316b68643548375562476d4d4a485a62566f386a6d346f4a2f30000000000000000000")),
|
|
||||||
},
|
|
||||||
Log {
|
|
||||||
address: hex!("ac6564f3718837caadd42eed742d75c12b90a052").into(),
|
|
||||||
topics: vec![
|
|
||||||
b256!("110d160a1bedeea919a88fbc4b2a9fb61b7e664084391b6ca2740db66fef80fe"),
|
|
||||||
b256!("00000000000000000000000084d47f6eea8f8d87910448325519d1bb45c2972a"),
|
|
||||||
b256!("000000000000000000000000a4fa7f3fbf0677f254ebdb1646146864c305b76e"),
|
|
||||||
b256!("000000000000000000000000000000000000000000000000000000000011a1d3"),
|
|
||||||
],
|
|
||||||
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a4fa7f3fbf0677f254ebdb1646146864c305b76e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007717500762343034303661353035646234633961386163316433306335633332303265370000000000000000000000000000000000000000000000000000000000000037697066733a2f2f516d515141646b33736538396b47716577395256567a316b68643548375562476d4d4a485a62566f386a6d346f4a2f30000000000000000000")),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
#[cfg(feature = "optimism")]
|
|
||||||
deposit_nonce: None,
|
|
||||||
},
|
|
||||||
bloom: Bloom(hex!("00000000000000000000000000000000400000000000000000000000000000000000004000000000000001000000000000000002000000000100000000000000000000000000000000000008000000000000000000000000000000000000000004000000020000000000000000000800000000000000000000000010200100200008000002000000000000000000800000000000000000000002000000000000000000000000000000080000000000000000000000004000000000000000000000000002000000000000000000000000000000000000200000000000000020002000000000000000002000000000000000000000000000000000000000000000").into()),
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
let root = calculate_receipt_root(&receipts);
|
|
||||||
assert_eq!(root, b256!("e255fed45eae7ede0556fe4fabc77b0d294d18781a5a581cab09127bc4cd9ffb"))
|
for case in cases {
|
||||||
|
let receipts = vec![
|
||||||
|
// 0xb0d6ee650637911394396d81172bd1c637d568ed1fbddab0daddfca399c58b53
|
||||||
|
ReceiptWithBloom {
|
||||||
|
receipt: Receipt {
|
||||||
|
tx_type: TxType::DEPOSIT,
|
||||||
|
success: true,
|
||||||
|
cumulative_gas_used: 46913,
|
||||||
|
logs: vec![],
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
deposit_nonce: Some(4012991u64),
|
||||||
|
},
|
||||||
|
bloom: Bloom(hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into()),
|
||||||
|
},
|
||||||
|
// 0x2f433586bae30573c393adfa02bc81d2a1888a3d6c9869f473fb57245166bd9a
|
||||||
|
ReceiptWithBloom {
|
||||||
|
receipt: Receipt {
|
||||||
|
tx_type: TxType::EIP1559,
|
||||||
|
success: true,
|
||||||
|
cumulative_gas_used: 118083,
|
||||||
|
logs: vec![
|
||||||
|
Log {
|
||||||
|
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62"),
|
||||||
|
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
||||||
|
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
||||||
|
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62"),
|
||||||
|
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
||||||
|
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("0eb774bb9698a73583fe07b6972cf2dcc08d1d97581a22861f45feb86b395820"),
|
||||||
|
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
||||||
|
b256!("000000000000000000000000c498902843af527e674846bb7edefa8ad62b8fb9"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000000000000000003")),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
deposit_nonce: None,
|
||||||
|
},
|
||||||
|
bloom: Bloom(hex!("00001000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000040000000000004000000000080000000000000000000000000000000000000000000000000000008000000000000080020000000000000000000000000002000000000000000000000000000080000010000").into()),
|
||||||
|
},
|
||||||
|
// 0x6c33676e8f6077f46a62eabab70bc6d1b1b18a624b0739086d77093a1ecf8266
|
||||||
|
ReceiptWithBloom {
|
||||||
|
receipt: Receipt {
|
||||||
|
tx_type: TxType::EIP1559,
|
||||||
|
success: true,
|
||||||
|
cumulative_gas_used: 189253,
|
||||||
|
logs: vec![
|
||||||
|
Log {
|
||||||
|
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62"),
|
||||||
|
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
||||||
|
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
||||||
|
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62"),
|
||||||
|
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
||||||
|
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("ddb6dcce6b794415145eb5caa6cd335aeda9c272").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("0eb774bb9698a73583fe07b6972cf2dcc08d1d97581a22861f45feb86b395820"),
|
||||||
|
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
||||||
|
b256!("0000000000000000000000009d521a04bee134ff8136d2ec957e5bc8c50394ec"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000000000000000003")),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
deposit_nonce: None,
|
||||||
|
},
|
||||||
|
bloom: Bloom(hex!("00000000000000000000200000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000002000000000020000000000000000000000000000000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000040000000000004000000000080000000000000000000000000000000000000000000000000000008000000000000080020000000000000000000000000002000000000000000000000000000080000000000").into()),
|
||||||
|
},
|
||||||
|
// 0x4d3ecbef04ba7ce7f5ab55be0c61978ca97c117d7da448ed9771d4ff0c720a3f
|
||||||
|
ReceiptWithBloom {
|
||||||
|
receipt: Receipt {
|
||||||
|
tx_type: TxType::EIP1559,
|
||||||
|
success: true,
|
||||||
|
cumulative_gas_used: 346969,
|
||||||
|
logs: vec![
|
||||||
|
Log {
|
||||||
|
address: hex!("4200000000000000000000000000000000000006").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
||||||
|
b256!("000000000000000000000000c3feb4ef4c2a5af77add15c95bd98f6b43640cc8"),
|
||||||
|
b256!("0000000000000000000000002992607c1614484fe6d865088e5c048f0650afd4"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000018de76816d8000")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("cf8e7e6b26f407dee615fc4db18bf829e7aa8c09").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
||||||
|
b256!("0000000000000000000000002992607c1614484fe6d865088e5c048f0650afd4"),
|
||||||
|
b256!("0000000000000000000000008dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("000000000000000000000000000000000000000000000002d24d8e9ac1aa79e2")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("2992607c1614484fe6d865088e5c048f0650afd4").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("000000000000000000000000000000000000000000000009bd50642785c15736000000000000000000000000000000000000000000011bb7ac324f724a29bbbf")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("2992607c1614484fe6d865088e5c048f0650afd4").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("d78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822"),
|
||||||
|
b256!("00000000000000000000000029843613c7211d014f5dd5718cf32bcd314914cb"),
|
||||||
|
b256!("0000000000000000000000008dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000018de76816d800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d24d8e9ac1aa79e2")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("6d0f8d488b669aa9ba2d0f0b7b75a88bf5051cd3").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
||||||
|
b256!("0000000000000000000000008dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09"),
|
||||||
|
b256!("000000000000000000000000c3feb4ef4c2a5af77add15c95bd98f6b43640cc8"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000014bc73062aea8093")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("8dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000002f122cfadc1ca82a35000000000000000000000000000000000000000000000665879dc0609945d6d1")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("8dbffe4c8bf3caf5deae3a99b50cfcf3648cbc09").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("d78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822"),
|
||||||
|
b256!("00000000000000000000000029843613c7211d014f5dd5718cf32bcd314914cb"),
|
||||||
|
b256!("000000000000000000000000c3feb4ef4c2a5af77add15c95bd98f6b43640cc8"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d24d8e9ac1aa79e200000000000000000000000000000000000000000000000014bc73062aea80930000000000000000000000000000000000000000000000000000000000000000")),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
deposit_nonce: None,
|
||||||
|
},
|
||||||
|
bloom: Bloom(hex!("00200000000000000000000080000000000000000000000000040000100004000000000000000000000000100000000000000000000000000000100000000000000000000000000002000008000000200000000200000000020000000000000040000000000000000400000200000000000000000000000000000010000000000400000000010400000000000000000000000000002000c80000004080002000000000000000400200000000800000000000000000000000000000000000000000000002000000000000000000000000000000000100001000000000000000000000002000000000000000000000010000000000000000000000800000800000").into()),
|
||||||
|
},
|
||||||
|
// 0xf738af5eb00ba23dbc1be2dbce41dbc0180f0085b7fb46646e90bf737af90351
|
||||||
|
ReceiptWithBloom {
|
||||||
|
receipt: Receipt {
|
||||||
|
tx_type: TxType::EIP1559,
|
||||||
|
success: true,
|
||||||
|
cumulative_gas_used: 623249,
|
||||||
|
logs: vec![
|
||||||
|
Log {
|
||||||
|
address: hex!("ac6564f3718837caadd42eed742d75c12b90a052").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
||||||
|
b256!("0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
b256!("000000000000000000000000a4fa7f3fbf0677f254ebdb1646146864c305b76e"),
|
||||||
|
b256!("000000000000000000000000000000000000000000000000000000000011a1d3"),
|
||||||
|
],
|
||||||
|
data: Default::default(),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("ac6564f3718837caadd42eed742d75c12b90a052").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("9d89e36eadf856db0ad9ffb5a569e07f95634dddd9501141ecf04820484ad0dc"),
|
||||||
|
b256!("000000000000000000000000a4fa7f3fbf0677f254ebdb1646146864c305b76e"),
|
||||||
|
b256!("000000000000000000000000000000000000000000000000000000000011a1d3"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000037697066733a2f2f516d515141646b33736538396b47716577395256567a316b68643548375562476d4d4a485a62566f386a6d346f4a2f30000000000000000000")),
|
||||||
|
},
|
||||||
|
Log {
|
||||||
|
address: hex!("ac6564f3718837caadd42eed742d75c12b90a052").into(),
|
||||||
|
topics: vec![
|
||||||
|
b256!("110d160a1bedeea919a88fbc4b2a9fb61b7e664084391b6ca2740db66fef80fe"),
|
||||||
|
b256!("00000000000000000000000084d47f6eea8f8d87910448325519d1bb45c2972a"),
|
||||||
|
b256!("000000000000000000000000a4fa7f3fbf0677f254ebdb1646146864c305b76e"),
|
||||||
|
b256!("000000000000000000000000000000000000000000000000000000000011a1d3"),
|
||||||
|
],
|
||||||
|
data: Bytes::from_static(&hex!("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a4fa7f3fbf0677f254ebdb1646146864c305b76e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007717500762343034303661353035646234633961386163316433306335633332303265370000000000000000000000000000000000000000000000000000000000000037697066733a2f2f516d515141646b33736538396b47716577395256567a316b68643548375562476d4d4a485a62566f386a6d346f4a2f30000000000000000000")),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
deposit_nonce: None,
|
||||||
|
},
|
||||||
|
bloom: Bloom(hex!("00000000000000000000000000000000400000000000000000000000000000000000004000000000000001000000000000000002000000000100000000000000000000000000000000000008000000000000000000000000000000000000000004000000020000000000000000000800000000000000000000000010200100200008000002000000000000000000800000000000000000000002000000000000000000000000000000080000000000000000000000004000000000000000000000000002000000000000000000000000000000000000200000000000000020002000000000000000002000000000000000000000000000000000000000000000").into()),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
let root = calculate_receipt_root(&receipts, OP_GOERLI.as_ref(), case.1);
|
||||||
|
assert_eq!(root, case.2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -446,7 +502,13 @@ b256!("000000000000000000000000000000000000000000000000000000000011a1d3"),
|
|||||||
bloom,
|
bloom,
|
||||||
};
|
};
|
||||||
let receipt = vec![receipt];
|
let receipt = vec![receipt];
|
||||||
let root = calculate_receipt_root(&receipt);
|
let root = calculate_receipt_root(
|
||||||
|
&receipt,
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
crate::OP_GOERLI.as_ref(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
0,
|
||||||
|
);
|
||||||
assert_eq!(root, b256!("fe70ae4a136d98944951b2123859698d59ad251a381abc9960fa81cae3d0d4a0"));
|
assert_eq!(root, b256!("fe70ae4a136d98944951b2123859698d59ad251a381abc9960fa81cae3d0d4a0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -88,12 +88,28 @@ impl Receipts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the receipt root for all recorded receipts from index.
|
/// Retrieves the receipt root for all recorded receipts from index.
|
||||||
|
#[cfg(not(feature = "optimism"))]
|
||||||
pub fn root_slow(&self, index: usize) -> Option<B256> {
|
pub fn root_slow(&self, index: usize) -> Option<B256> {
|
||||||
Some(calculate_receipt_root_ref(
|
Some(calculate_receipt_root_ref(
|
||||||
&self.receipt_vec[index].iter().map(Option::as_ref).collect::<Option<Vec<_>>>()?,
|
&self.receipt_vec[index].iter().map(Option::as_ref).collect::<Option<Vec<_>>>()?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves the receipt root for all recorded receipts from index.
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
pub fn root_slow(
|
||||||
|
&self,
|
||||||
|
index: usize,
|
||||||
|
chain_spec: &crate::ChainSpec,
|
||||||
|
timestamp: u64,
|
||||||
|
) -> Option<B256> {
|
||||||
|
Some(calculate_receipt_root_ref(
|
||||||
|
&self.receipt_vec[index].iter().map(Option::as_ref).collect::<Option<Vec<_>>>()?,
|
||||||
|
chain_spec,
|
||||||
|
timestamp,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
/// Retrieves gas spent by transactions as a vector of tuples (transaction index, gas used).
|
/// Retrieves gas spent by transactions as a vector of tuples (transaction index, gas used).
|
||||||
pub fn gas_spent_by_tx(&self) -> Result<Vec<(u64, u64)>, PruneSegmentError> {
|
pub fn gas_spent_by_tx(&self) -> Result<Vec<(u64, u64)>, PruneSegmentError> {
|
||||||
self.last()
|
self.last()
|
||||||
|
|||||||
@ -36,9 +36,13 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
|
|||||||
// See more about EIP here: https://eips.ethereum.org/EIPS/eip-658
|
// See more about EIP here: https://eips.ethereum.org/EIPS/eip-658
|
||||||
if self.chain_spec.fork(Hardfork::Byzantium).active_at_block(block.header.number) {
|
if self.chain_spec.fork(Hardfork::Byzantium).active_at_block(block.header.number) {
|
||||||
let time = Instant::now();
|
let time = Instant::now();
|
||||||
if let Err(error) =
|
if let Err(error) = verify_receipt(
|
||||||
verify_receipt(block.header.receipts_root, block.header.logs_bloom, receipts.iter())
|
block.header.receipts_root,
|
||||||
{
|
block.header.logs_bloom,
|
||||||
|
receipts.iter(),
|
||||||
|
self.chain_spec.as_ref(),
|
||||||
|
block.timestamp,
|
||||||
|
) {
|
||||||
debug!(target: "evm", ?error, ?receipts, "receipts verification failed");
|
debug!(target: "evm", ?error, ?receipts, "receipts verification failed");
|
||||||
return Err(error)
|
return Err(error)
|
||||||
};
|
};
|
||||||
|
|||||||
@ -531,10 +531,18 @@ pub fn verify_receipt<'a>(
|
|||||||
expected_receipts_root: B256,
|
expected_receipts_root: B256,
|
||||||
expected_logs_bloom: Bloom,
|
expected_logs_bloom: Bloom,
|
||||||
receipts: impl Iterator<Item = &'a Receipt> + Clone,
|
receipts: impl Iterator<Item = &'a Receipt> + Clone,
|
||||||
|
#[cfg(feature = "optimism")] chain_spec: &ChainSpec,
|
||||||
|
#[cfg(feature = "optimism")] timestamp: u64,
|
||||||
) -> Result<(), BlockExecutionError> {
|
) -> Result<(), BlockExecutionError> {
|
||||||
// Check receipts root.
|
// Check receipts root.
|
||||||
let receipts_with_bloom = receipts.map(|r| r.clone().into()).collect::<Vec<ReceiptWithBloom>>();
|
let receipts_with_bloom = receipts.map(|r| r.clone().into()).collect::<Vec<ReceiptWithBloom>>();
|
||||||
let receipts_root = reth_primitives::proofs::calculate_receipt_root(&receipts_with_bloom);
|
let receipts_root = reth_primitives::proofs::calculate_receipt_root(
|
||||||
|
&receipts_with_bloom,
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
chain_spec,
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
timestamp,
|
||||||
|
);
|
||||||
if receipts_root != expected_receipts_root {
|
if receipts_root != expected_receipts_root {
|
||||||
return Err(BlockValidationError::ReceiptRootDiff(
|
return Err(BlockValidationError::ReceiptRootDiff(
|
||||||
GotExpected { got: receipts_root, expected: expected_receipts_root }.into(),
|
GotExpected { got: receipts_root, expected: expected_receipts_root }.into(),
|
||||||
|
|||||||
@ -201,7 +201,15 @@ impl PendingBlockEnv {
|
|||||||
block_number,
|
block_number,
|
||||||
);
|
);
|
||||||
|
|
||||||
let receipts_root = bundle.receipts_root_slow(block_number).expect("Block is present");
|
let receipts_root = bundle
|
||||||
|
.receipts_root_slow(
|
||||||
|
block_number,
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
chain_spec.as_ref(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
block_env.timestamp.to::<u64>(),
|
||||||
|
)
|
||||||
|
.expect("Block is present");
|
||||||
let logs_bloom = bundle.block_logs_bloom(block_number).expect("Block is present");
|
let logs_bloom = bundle.block_logs_bloom(block_number).expect("Block is present");
|
||||||
|
|
||||||
// calculate the state root
|
// calculate the state root
|
||||||
|
|||||||
@ -250,10 +250,24 @@ impl BundleStateWithReceipts {
|
|||||||
/// Returns the receipt root for all recorded receipts.
|
/// Returns the receipt root for all recorded receipts.
|
||||||
/// Note: this function calculated Bloom filters for every receipt and created merkle trees
|
/// Note: this function calculated Bloom filters for every receipt and created merkle trees
|
||||||
/// of receipt. This is a expensive operation.
|
/// of receipt. This is a expensive operation.
|
||||||
|
#[cfg(not(feature = "optimism"))]
|
||||||
pub fn receipts_root_slow(&self, block_number: BlockNumber) -> Option<B256> {
|
pub fn receipts_root_slow(&self, block_number: BlockNumber) -> Option<B256> {
|
||||||
self.receipts.root_slow(self.block_number_to_index(block_number)?)
|
self.receipts.root_slow(self.block_number_to_index(block_number)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the receipt root for all recorded receipts.
|
||||||
|
/// Note: this function calculated Bloom filters for every receipt and created merkle trees
|
||||||
|
/// of receipt. This is a expensive operation.
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
pub fn receipts_root_slow(
|
||||||
|
&self,
|
||||||
|
block_number: BlockNumber,
|
||||||
|
chain_spec: &reth_primitives::ChainSpec,
|
||||||
|
timestamp: u64,
|
||||||
|
) -> Option<B256> {
|
||||||
|
self.receipts.root_slow(self.block_number_to_index(block_number)?, chain_spec, timestamp)
|
||||||
|
}
|
||||||
|
|
||||||
/// Return reference to receipts.
|
/// Return reference to receipts.
|
||||||
pub fn receipts(&self) -> &Receipts {
|
pub fn receipts(&self) -> &Receipts {
|
||||||
&self.receipts
|
&self.receipts
|
||||||
|
|||||||
Reference in New Issue
Block a user