diff --git a/crates/evm/execution-types/src/chain.rs b/crates/evm/execution-types/src/chain.rs index 200a37423cfa..2d1f815aacad 100644 --- a/crates/evm/execution-types/src/chain.rs +++ b/crates/evm/execution-types/src/chain.rs @@ -817,6 +817,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![], success: true, + #[cfg(feature = "scroll")] + l1_fee: alloy_primitives::U256::ZERO, }; // Create another random receipt object, receipt2 @@ -825,6 +827,8 @@ mod tests { cumulative_gas_used: 1325345, logs: vec![], success: true, + #[cfg(feature = "scroll")] + l1_fee: alloy_primitives::U256::ZERO, }; // Create a Receipts object with a vector of receipt vectors diff --git a/crates/evm/execution-types/src/execution_outcome.rs b/crates/evm/execution-types/src/execution_outcome.rs index d6a9ddfd8250..2b67b95fcb3a 100644 --- a/crates/evm/execution-types/src/execution_outcome.rs +++ b/crates/evm/execution-types/src/execution_outcome.rs @@ -398,6 +398,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, })]], }; @@ -460,6 +462,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, })]], }; @@ -495,6 +499,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![Log::::default()], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, })]], }; @@ -527,6 +533,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![Log::::default()], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, })]], }; @@ -553,6 +561,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![Log::::default()], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, })] ); } @@ -567,6 +577,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![Log::::default()], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, })]], }; @@ -615,6 +627,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, }; // Create a Receipts object with a vector of receipt vectors @@ -664,6 +678,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, }; // Create a Receipts object containing the receipt. @@ -708,6 +724,8 @@ mod tests { cumulative_gas_used: 46913, logs: vec![], success: true, + #[cfg(feature = "scroll")] + l1_fee: U256::ZERO, }; // Create a Receipts object with a vector of receipt vectors diff --git a/crates/primitives/src/proofs.rs b/crates/primitives/src/proofs.rs index 1712112281f4..5cfda9ab1dad 100644 --- a/crates/primitives/src/proofs.rs +++ b/crates/primitives/src/proofs.rs @@ -94,6 +94,8 @@ mod tests { success: true, cumulative_gas_used: 102068, logs, + #[cfg(feature = "scroll")] + l1_fee: U256::from(0xffffff), }, bloom, }; diff --git a/crates/primitives/src/receipt.rs b/crates/primitives/src/receipt.rs index 53adb85eda05..34bfa3c890cf 100644 --- a/crates/primitives/src/receipt.rs +++ b/crates/primitives/src/receipt.rs @@ -7,6 +7,8 @@ use alloy_consensus::{ Eip658Value, TxReceipt, }; use alloy_eips::eip2718::Encodable2718; +#[cfg(all(feature = "scroll", not(feature = "optimism")))] +use alloy_primitives::U256; use alloy_primitives::{Bloom, Log, B256}; use alloy_rlp::{length_of_length, Decodable, Encodable, RlpDecodable, RlpEncodable}; use bytes::{Buf, BufMut}; @@ -50,6 +52,12 @@ pub struct Receipt { /// ensures this is only set for post-Canyon deposit transactions. #[cfg(all(feature = "optimism", not(feature = "scroll")))] pub deposit_receipt_version: Option, + /// Additional fee to cover l1 data availability costs. + /// L1 fee is not part of the consensus encoding of a receipt. + /// + #[cfg(all(feature = "scroll", not(feature = "optimism")))] + #[rlp(skip)] + pub l1_fee: U256, } impl Receipt { @@ -247,6 +255,8 @@ impl<'a> arbitrary::Arbitrary<'a> for Receipt { deposit_nonce, #[cfg(all(feature = "optimism", not(feature = "scroll")))] deposit_receipt_version, + #[cfg(all(feature = "scroll", not(feature = "optimism")))] + l1_fee: U256::arbitrary(u)?, }) } } @@ -334,6 +344,8 @@ impl ReceiptWithBloom { deposit_nonce: None, #[cfg(all(feature = "optimism", not(feature = "scroll")))] deposit_receipt_version: None, + #[cfg(all(feature = "scroll", not(feature = "optimism")))] + l1_fee: U256::ZERO, }, }; @@ -571,10 +583,14 @@ mod tests { #[test] fn test_decode_receipt() { - #[cfg(not(feature = "optimism"))] + #[cfg(all(not(feature = "optimism"), not(feature = "scroll")))] reth_codecs::test_utils::test_decode::(&hex!( "c428b52ffd23fc42696156b10200f034792b6a94c3850215c2fef7aea361a0c31b79d9a32652eefc0d4e2e730036061cff7344b6fc6132b50cda0ed810a991ae58ef013150c12b2522533cb3b3a8b19b7786a8b5ff1d3cdc84225e22b02def168c8858df" )); + #[cfg(feature = "scroll")] + reth_codecs::test_utils::test_decode::(&hex!( + "c42128b52ffd23fc42696159c90200f034792b6a94c3850215c2fef7aea361a0c31b79d9a32652eefc0d4e2e730036061cff7344b6fc6132b50cda0ed810a991ae58ef013150c12b2522533cb3b3a8b19b7786a8b5ff1d3cdc84225e22b02def168c8858dfffffff" + )); #[cfg(feature = "optimism")] reth_codecs::test_utils::test_decode::(&hex!( "c30328b52ffd23fc426961a00105007eb0042307705a97e503562eacf2b95060cce9de6de68386b6c155b73a9650021a49e2f8baad17f30faff5899d785c4c0873e45bc268bcf07560106424570d11f9a59e8f3db1efa4ceec680123712275f10d92c3411e1caaa11c7c5d591bc11487168e09934a9986848136da1b583babf3a7188e3aed007a1520f1cf4c1ca7d3482c6c28d37c298613c70a76940008816c4c95644579fd08471dc34732fd0f24" @@ -604,6 +620,8 @@ mod tests { deposit_nonce: None, #[cfg(all(feature = "optimism", not(feature = "scroll")))] deposit_receipt_version: None, + #[cfg(all(feature = "scroll", not(feature = "optimism")))] + l1_fee: U256::ZERO, }, bloom: [0; 256].into(), }; @@ -638,6 +656,8 @@ mod tests { deposit_nonce: None, #[cfg(all(feature = "optimism", not(feature = "scroll")))] deposit_receipt_version: None, + #[cfg(all(feature = "scroll", not(feature = "optimism")))] + l1_fee: U256::ZERO, }, bloom: [0; 256].into(), }; @@ -720,6 +740,8 @@ mod tests { deposit_nonce: None, #[cfg(all(feature = "optimism", not(feature = "scroll")))] deposit_receipt_version: None, + #[cfg(all(feature = "scroll", not(feature = "optimism")))] + l1_fee: U256::from(0xffffff), }; let mut data = vec![]; @@ -740,6 +762,8 @@ mod tests { deposit_nonce: None, #[cfg(all(feature = "optimism", not(feature = "scroll")))] deposit_receipt_version: None, + #[cfg(all(feature = "scroll", not(feature = "optimism")))] + l1_fee: U256::from(0xffffff), }, bloom: Bloom::default(), }; @@ -762,6 +786,8 @@ mod tests { deposit_nonce: None, #[cfg(all(feature = "optimism", not(feature = "scroll")))] deposit_receipt_version: None, + #[cfg(all(feature = "scroll", not(feature = "optimism")))] + l1_fee: U256::from(0xffffff), }, bloom: Bloom::default(), }; diff --git a/crates/storage/db-api/Cargo.toml b/crates/storage/db-api/Cargo.toml index 3aa908a60093..1071e0a4432a 100644 --- a/crates/storage/db-api/Cargo.toml +++ b/crates/storage/db-api/Cargo.toml @@ -82,3 +82,4 @@ arbitrary = [ "alloy-consensus/arbitrary", ] optimism = ["reth-primitives/optimism", "reth-codecs/optimism"] +scroll = ["reth-primitives/scroll"] diff --git a/crates/storage/db-api/src/models/mod.rs b/crates/storage/db-api/src/models/mod.rs index 5d18711922ed..83d2913c5bc5 100644 --- a/crates/storage/db-api/src/models/mod.rs +++ b/crates/storage/db-api/src/models/mod.rs @@ -335,7 +335,10 @@ mod tests { assert_eq!(PruneCheckpoint::bitflag_encoded_bytes(), 1); assert_eq!(PruneMode::bitflag_encoded_bytes(), 1); assert_eq!(PruneSegment::bitflag_encoded_bytes(), 1); + #[cfg(not(feature = "scroll"))] assert_eq!(Receipt::bitflag_encoded_bytes(), 1); + #[cfg(feature = "scroll")] + assert_eq!(Receipt::bitflag_encoded_bytes(), 2); assert_eq!(StageCheckpoint::bitflag_encoded_bytes(), 1); assert_eq!(StageUnitCheckpoint::bitflag_encoded_bytes(), 1); assert_eq!(StoredBlockBodyIndices::bitflag_encoded_bytes(), 1); @@ -356,7 +359,10 @@ mod tests { validate_bitflag_backwards_compat!(PruneCheckpoint, UnusedBits::NotZero); validate_bitflag_backwards_compat!(PruneMode, UnusedBits::Zero); validate_bitflag_backwards_compat!(PruneSegment, UnusedBits::Zero); + #[cfg(not(feature = "scroll"))] validate_bitflag_backwards_compat!(Receipt, UnusedBits::Zero); + #[cfg(feature = "scroll")] + validate_bitflag_backwards_compat!(Receipt, UnusedBits::NotZero); validate_bitflag_backwards_compat!(StageCheckpoint, UnusedBits::NotZero); validate_bitflag_backwards_compat!(StageUnitCheckpoint, UnusedBits::Zero); validate_bitflag_backwards_compat!(StoredBlockBodyIndices, UnusedBits::Zero);