diff --git a/Cargo.lock b/Cargo.lock index 1d9f74a207d5f..c32aad625a4ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,6 +174,18 @@ dependencies = [ "serde_with", ] +[[package]] +name = "alloy-eip7702" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeffd2590ce780ddfaa9d0ae340eb2b4e08627650c4676eef537cef0b4bf535d" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "k256", + "serde", +] + [[package]] name = "alloy-eips" version = "0.4.2" @@ -181,7 +193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ffb906284a1e1f63c4607da2068c8197458a352d0b3e9796e67353d72a9be85" dependencies = [ "alloy-eip2930", - "alloy-eip7702", + "alloy-eip7702 0.1.1", "alloy-primitives", "alloy-rlp", "alloy-serde", @@ -2568,7 +2580,7 @@ dependencies = [ "reth-provider", "reth-revm", "reth-stages", - "revm", + "revm 16.0.0", "serde", "serde_json", "thiserror", @@ -6330,7 +6342,7 @@ dependencies = [ "reth-tokio-util", "reth-transaction-pool", "reth-trie", - "revm-primitives", + "revm-primitives 10.0.0", "tokio", "tokio-stream", "tracing", @@ -6354,7 +6366,7 @@ dependencies = [ "reth-revm", "reth-tasks", "reth-transaction-pool", - "revm", + "revm 16.0.0", "tokio", "tracing", ] @@ -6518,7 +6530,7 @@ dependencies = [ "reth-storage-api", "reth-testing-utils", "reth-trie", - "revm", + "revm 16.0.0", "tokio", "tokio-stream", "tracing", @@ -6717,7 +6729,7 @@ dependencies = [ "reth-consensus", "reth-primitives", "reth-storage-api", - "revm-primitives", + "revm-primitives 10.0.0", ] [[package]] @@ -7180,7 +7192,7 @@ dependencies = [ "reth-revm", "reth-rpc-types-compat", "reth-trie", - "revm-primitives", + "revm-primitives 10.0.0", "serde", "serde_json", "tokio", @@ -7341,8 +7353,8 @@ dependencies = [ "reth-revm", "reth-transaction-pool", "reth-trie", - "revm", - "revm-primitives", + "revm 16.0.0", + "revm-primitives 10.0.0", "tracing", ] @@ -7376,8 +7388,8 @@ dependencies = [ "reth-prune-types", "reth-revm", "reth-storage-errors", - "revm", - "revm-primitives", + "revm 16.0.0", + "revm-primitives 10.0.0", ] [[package]] @@ -7399,7 +7411,7 @@ dependencies = [ "reth-prune-types", "reth-revm", "reth-testing-utils", - "revm-primitives", + "revm-primitives 10.0.0", "secp256k1", "serde_json", ] @@ -7416,7 +7428,7 @@ dependencies = [ "reth-consensus", "reth-prune-types", "reth-storage-errors", - "revm-primitives", + "revm-primitives 10.0.0", ] [[package]] @@ -7431,7 +7443,7 @@ dependencies = [ "reth-execution-errors", "reth-primitives", "reth-trie", - "revm", + "revm 16.0.0", "serde", "serde_with", ] @@ -7965,7 +7977,7 @@ dependencies = [ "reth-tasks", "reth-tracing", "reth-transaction-pool", - "revm", + "revm 16.0.0", "serde_json", "tokio", ] @@ -8128,8 +8140,8 @@ dependencies = [ "reth-primitives", "reth-prune-types", "reth-revm", - "revm", - "revm-primitives", + "revm 16.0.0", + "revm-primitives 10.0.0", "tracing", ] @@ -8191,7 +8203,7 @@ dependencies = [ "reth-rpc-types-compat", "reth-tracing", "reth-transaction-pool", - "revm", + "revm 16.0.0", "serde", "serde_json", "thiserror", @@ -8226,8 +8238,8 @@ dependencies = [ "reth-rpc-types-compat", "reth-transaction-pool", "reth-trie", - "revm", - "revm-primitives", + "revm 16.0.0", + "revm-primitives 10.0.0", "sha2 0.10.8", "thiserror", "tracing", @@ -8276,7 +8288,7 @@ dependencies = [ "reth-rpc-server-types", "reth-tasks", "reth-transaction-pool", - "revm", + "revm 16.0.0", "serde_json", "thiserror", "tokio", @@ -8309,7 +8321,7 @@ dependencies = [ "reth-payload-primitives", "reth-primitives", "reth-provider", - "revm", + "revm 16.0.0", "tokio", "tokio-stream", "tracing", @@ -8382,7 +8394,7 @@ dependencies = [ "reth-static-file-types", "reth-testing-utils", "reth-trie-common", - "revm-primitives", + "revm-primitives 10.0.0", "secp256k1", "serde", "serde_json", @@ -8411,7 +8423,7 @@ dependencies = [ "rand 0.8.5", "reth-codecs", "reth-testing-utils", - "revm-primitives", + "revm-primitives 10.0.0", "roaring", "serde", "serde_json", @@ -8461,7 +8473,7 @@ dependencies = [ "reth-testing-utils", "reth-trie", "reth-trie-db", - "revm", + "revm 16.0.0", "strum", "tempfile", "tokio", @@ -8531,7 +8543,7 @@ dependencies = [ "reth-storage-api", "reth-storage-errors", "reth-trie", - "revm", + "revm 16.0.0", ] [[package]] @@ -8589,9 +8601,9 @@ dependencies = [ "reth-testing-utils", "reth-transaction-pool", "reth-trie", - "revm", + "revm 16.0.0", "revm-inspectors", - "revm-primitives", + "revm-primitives 10.0.0", "serde", "serde_json", "thiserror", @@ -8769,9 +8781,9 @@ dependencies = [ "reth-tasks", "reth-transaction-pool", "reth-trie", - "revm", + "revm 16.0.0", "revm-inspectors", - "revm-primitives", + "revm-primitives 10.0.0", "tokio", "tracing", ] @@ -8808,9 +8820,9 @@ dependencies = [ "reth-tasks", "reth-transaction-pool", "reth-trie", - "revm", + "revm 16.0.0", "revm-inspectors", - "revm-primitives", + "revm-primitives 10.0.0", "schnellru", "serde", "serde_json", @@ -9113,7 +9125,7 @@ dependencies = [ "reth-storage-api", "reth-tasks", "reth-tracing", - "revm", + "revm 16.0.0", "rustc-hash 2.0.0", "schnellru", "serde", @@ -9149,7 +9161,7 @@ dependencies = [ "reth-stages-types", "reth-storage-errors", "reth-trie-common", - "revm", + "revm 16.0.0", "serde", "serde_json", "serde_with", @@ -9178,7 +9190,7 @@ dependencies = [ "proptest-arbitrary-interop", "reth-codecs", "reth-primitives-traits", - "revm-primitives", + "revm-primitives 10.0.0", "serde", ] @@ -9208,7 +9220,7 @@ dependencies = [ "reth-storage-errors", "reth-trie", "reth-trie-common", - "revm", + "revm 16.0.0", "serde", "serde_json", "similar-asserts", @@ -9277,8 +9289,23 @@ dependencies = [ "auto_impl", "cfg-if", "dyn-clone", - "revm-interpreter", - "revm-precompile", + "revm-interpreter 10.0.3", + "revm-precompile 11.0.3", + "serde", + "serde_json", +] + +[[package]] +name = "revm" +version = "16.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34e44692d5736cc44c697a372e507890f8797f06d1541c5f4b9bec594d90fd8a" +dependencies = [ + "auto_impl", + "cfg-if", + "dyn-clone", + "revm-interpreter 12.0.0", + "revm-precompile 13.0.0", "serde", "serde_json", ] @@ -9297,7 +9324,7 @@ dependencies = [ "boa_engine", "boa_gc", "colorchoice", - "revm", + "revm 14.0.3", "serde_json", "thiserror", ] @@ -9308,7 +9335,17 @@ version = "10.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e5e14002afae20b5bf1566f22316122f42f57517000e559c55b25bf7a49cba2" dependencies = [ - "revm-primitives", + "revm-primitives 10.0.0", + "serde", +] + +[[package]] +name = "revm-interpreter" +version = "12.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f89940d17d5d077570de1977f52f69049595322e237cb6c754c3d47f668f023" +dependencies = [ + "revm-primitives 12.0.0", "serde", ] @@ -9317,6 +9354,24 @@ name = "revm-precompile" version = "11.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3198c06247e8d4ad0d1312591edf049b0de4ddffa9fecb625c318fd67db8639b" +dependencies = [ + "aurora-engine-modexp", + "c-kzg", + "cfg-if", + "k256", + "once_cell", + "revm-primitives 10.0.0", + "ripemd", + "secp256k1", + "sha2 0.10.8", + "substrate-bn", +] + +[[package]] +name = "revm-precompile" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8f816aaea3245cbdbe7fdd84955df33597f9322c7912c3e3ba7bc855e03211f" dependencies = [ "aurora-engine-modexp", "blst", @@ -9325,7 +9380,7 @@ dependencies = [ "k256", "once_cell", "p256", - "revm-primitives", + "revm-primitives 12.0.0", "ripemd", "secp256k1", "sha2 0.10.8", @@ -9339,7 +9394,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f1525851a03aff9a9d6a1d018b414d76252d6802ab54695b27093ecd7e7a101" dependencies = [ "alloy-eip2930", - "alloy-eip7702", + "alloy-eip7702 0.1.1", + "alloy-primitives", + "auto_impl", + "bitflags 2.6.0", + "bitvec", + "c-kzg", + "cfg-if", + "dyn-clone", + "enumn", + "hex", + "serde", +] + +[[package]] +name = "revm-primitives" +version = "12.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532411bbde45a46707c1d434dcdc29866cf261c1b748fb01b303ce3b4310b361" +dependencies = [ + "alloy-eip2930", + "alloy-eip7702 0.2.0", "alloy-primitives", "auto_impl", "bitflags 2.6.0", diff --git a/Cargo.toml b/Cargo.toml index e3ec1c1fb4a63..7f8678ee77e66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -410,9 +410,7 @@ reth-trie-db = { path = "crates/trie/db" } reth-trie-parallel = { path = "crates/trie/parallel" } # revm -revm = { version = "14.0.3", features = [ - "std", -], default-features = false } +revm = { version = "16.0.0", features = ["std"], default-features = false } revm-inspectors = "0.8.1" revm-primitives = { version = "10.0.0", features = [ "std", @@ -596,29 +594,29 @@ tikv-jemallocator = "0.6" tracy-client = "0.17.3" [patch.crates-io] -#alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-admin = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-debug = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-mev = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-rpc-types-txpool = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} -#alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-admin = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-debug = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-mev = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-rpc-types-txpool = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" } diff --git a/crates/chainspec/src/spec.rs b/crates/chainspec/src/spec.rs index adfee564d749c..836989d347dfc 100644 --- a/crates/chainspec/src/spec.rs +++ b/crates/chainspec/src/spec.rs @@ -4,10 +4,9 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloy_chains::{Chain, NamedChain}; use alloy_genesis::Genesis; use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256}; -use alloy_trie::EMPTY_ROOT_HASH; use derive_more::From; -use alloy_consensus::constants::{DEV_GENESIS_HASH, MAINNET_GENESIS_HASH}; +use alloy_consensus::constants::{DEV_GENESIS_HASH, KECCAK_EMPTY, MAINNET_GENESIS_HASH}; use reth_ethereum_forks::{ ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition, ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, DEV_HARDFORKS, @@ -283,8 +282,8 @@ impl ChainSpec { }; // If Prague is activated at genesis we set requests root to an empty trie root. - let requests_root = - self.is_prague_active_at_timestamp(self.genesis.timestamp).then_some(EMPTY_ROOT_HASH); + let requests_hash = + self.is_prague_active_at_timestamp(self.genesis.timestamp).then_some(KECCAK_EMPTY); Header { gas_limit: self.genesis.gas_limit, @@ -300,7 +299,7 @@ impl ChainSpec { parent_beacon_block_root, blob_gas_used: blob_gas_used.map(Into::into), excess_blob_gas: excess_blob_gas.map(Into::into), - requests_root, + requests_hash, ..Default::default() } } @@ -939,6 +938,7 @@ mod tests { use alloy_chains::Chain; use alloy_genesis::{ChainConfig, GenesisAccount}; use alloy_primitives::{b256, hex}; + use alloy_trie::EMPTY_ROOT_HASH; use reth_ethereum_forks::{ForkCondition, ForkHash, ForkId, Head}; use reth_trie_common::TrieAccount; diff --git a/crates/consensus/auto-seal/src/lib.rs b/crates/consensus/auto-seal/src/lib.rs index 261227f1074ed..cfb83df1eef6f 100644 --- a/crates/consensus/auto-seal/src/lib.rs +++ b/crates/consensus/auto-seal/src/lib.rs @@ -301,7 +301,7 @@ impl StorageInner { timestamp, base_fee_per_gas, blob_gas_used, - requests_root: requests.map(|r| proofs::calculate_requests_root(&r.0)), + requests_hash: requests.map(|r| proofs::calculate_requests_root(&r.0)), ..Default::default() }; @@ -682,7 +682,7 @@ mod tests { timestamp, base_fee_per_gas: None, blob_gas_used: Some(0), - requests_root: None, + requests_hash: None, excess_blob_gas: Some(0), ..Default::default() } diff --git a/crates/consensus/common/src/validation.rs b/crates/consensus/common/src/validation.rs index 711e7772b666e..85c9bf782c0ec 100644 --- a/crates/consensus/common/src/validation.rs +++ b/crates/consensus/common/src/validation.rs @@ -84,6 +84,7 @@ pub fn validate_cancun_gas(block: &SealedBlock) -> Result<(), ConsensusError> { /// [EIP-7685]: https://eips.ethereum.org/EIPS/eip-7685 #[inline] pub fn validate_prague_request(block: &SealedBlock) -> Result<(), ConsensusError> { + // todo: invalid let requests_root = block.body.calculate_requests_root().ok_or(ConsensusError::BodyRequestsMissing)?; let header_requests_root = block.requests_root.ok_or(ConsensusError::RequestsRootMissing)?; @@ -460,7 +461,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - requests_root: None + requests_hash: None }; // size: 0x9b5 diff --git a/crates/engine/util/src/reorg.rs b/crates/engine/util/src/reorg.rs index abfa23a57b32e..ff7d1ef68d37d 100644 --- a/crates/engine/util/src/reorg.rs +++ b/crates/engine/util/src/reorg.rs @@ -401,7 +401,7 @@ where transactions_root: proofs::calculate_transaction_root(&transactions), receipts_root: outcome.receipts_root_slow(reorg_target.header.number).unwrap(), logs_bloom: outcome.block_logs_bloom(reorg_target.header.number).unwrap(), - requests_root: None, // TODO(prague) + requests_hash: None, // TODO(prague) gas_used: cumulative_gas_used, blob_gas_used: blob_gas_used.map(Into::into), excess_blob_gas: excess_blob_gas.map(Into::into), diff --git a/crates/ethereum/consensus/src/lib.rs b/crates/ethereum/consensus/src/lib.rs index 8f2a8a7204272..0591f5f877134 100644 --- a/crates/ethereum/consensus/src/lib.rs +++ b/crates/ethereum/consensus/src/lib.rs @@ -121,10 +121,10 @@ impl Consensu } if self.chain_spec.is_prague_active_at_timestamp(header.timestamp) { - if header.requests_root.is_none() { + if header.requests_hash.is_none() { return Err(ConsensusError::RequestsRootMissing) } - } else if header.requests_root.is_some() { + } else if header.requests_hash.is_some() { return Err(ConsensusError::RequestsRootUnexpected) } diff --git a/crates/ethereum/consensus/src/validation.rs b/crates/ethereum/consensus/src/validation.rs index e510a91ab9645..4bac53b48deb6 100644 --- a/crates/ethereum/consensus/src/validation.rs +++ b/crates/ethereum/consensus/src/validation.rs @@ -38,7 +38,8 @@ pub fn validate_block_post_execution( // Validate that the header requests root matches the calculated requests root if chain_spec.is_prague_active_at_timestamp(block.timestamp) { - let Some(header_requests_root) = block.header.requests_root else { + // todo: update + let Some(header_requests_root) = block.header.requests_hash else { return Err(ConsensusError::RequestsRootMissing) }; let requests_root = reth_primitives::proofs::calculate_requests_root(requests); diff --git a/crates/ethereum/engine-primitives/src/payload.rs b/crates/ethereum/engine-primitives/src/payload.rs index ae370fdb9d7bb..511ece5489fa5 100644 --- a/crates/ethereum/engine-primitives/src/payload.rs +++ b/crates/ethereum/engine-primitives/src/payload.rs @@ -11,8 +11,7 @@ use reth_chain_state::ExecutedBlock; use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes}; use reth_primitives::{SealedBlock, Withdrawals}; use reth_rpc_types_compat::engine::payload::{ - block_to_payload_v1, block_to_payload_v3, block_to_payload_v4, - convert_block_to_payload_field_v2, + block_to_payload_v1, block_to_payload_v3, convert_block_to_payload_field_v2, }; use std::convert::Infallible; @@ -145,7 +144,7 @@ impl From for ExecutionPayloadEnvelopeV4 { let EthBuiltPayload { block, fees, sidecars, .. } = value; Self { - execution_payload: block_to_payload_v4(block), + execution_payload: block_to_payload_v3(block), block_value: fees, // From the engine API spec: // diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index 9c7748a561f0e..935a86d9e2b34 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -494,7 +494,7 @@ where #[cfg(test)] mod tests { use super::*; - use alloy_consensus::{TxLegacy, EMPTY_ROOT_HASH}; + use alloy_consensus::{constants::KECCAK_EMPTY, TxLegacy, EMPTY_ROOT_HASH}; use alloy_eips::{ eip2935::{HISTORY_STORAGE_ADDRESS, HISTORY_STORAGE_CODE}, eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_CODE, SYSTEM_ADDRESS}, @@ -1016,7 +1016,7 @@ mod tests { parent_hash: B256::random(), timestamp: 1, number: fork_activation_block, - requests_root: Some(EMPTY_ROOT_HASH), + requests_hash: Some(KECCAK_EMPTY), ..Header::default() }; let provider = executor_provider(chain_spec); @@ -1075,7 +1075,7 @@ mod tests { parent_hash: B256::random(), timestamp: 1, number: fork_activation_block, - requests_root: Some(EMPTY_ROOT_HASH), + requests_hash: Some(KECCAK_EMPTY), ..Header::default() }; @@ -1121,7 +1121,7 @@ mod tests { ); let mut header = chain_spec.genesis_header().clone(); - header.requests_root = Some(EMPTY_ROOT_HASH); + header.requests_hash = Some(KECCAK_EMPTY); let header_hash = header.hash_slow(); let provider = executor_provider(chain_spec); @@ -1159,7 +1159,7 @@ mod tests { parent_hash: header_hash, timestamp: 1, number: 1, - requests_root: Some(EMPTY_ROOT_HASH), + requests_hash: Some(KECCAK_EMPTY), ..Header::default() }; let header_hash = header.hash_slow(); @@ -1196,7 +1196,7 @@ mod tests { parent_hash: header_hash, timestamp: 1, number: 2, - requests_root: Some(EMPTY_ROOT_HASH), + requests_hash: Some(KECCAK_EMPTY), ..Header::default() }; diff --git a/crates/ethereum/evm/src/strategy.rs b/crates/ethereum/evm/src/strategy.rs index 7a297be498a38..504bc117e8030 100644 --- a/crates/ethereum/evm/src/strategy.rs +++ b/crates/ethereum/evm/src/strategy.rs @@ -266,7 +266,7 @@ where #[cfg(test)] mod tests { use super::*; - use alloy_consensus::{TxLegacy, EMPTY_ROOT_HASH}; + use alloy_consensus::{constants::KECCAK_EMPTY, TxLegacy, EMPTY_ROOT_HASH}; use alloy_eips::{ eip2935::{HISTORY_STORAGE_ADDRESS, HISTORY_STORAGE_CODE}, eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_CODE, SYSTEM_ADDRESS}, @@ -797,7 +797,7 @@ mod tests { parent_hash: B256::random(), timestamp: 1, number: fork_activation_block, - requests_root: Some(EMPTY_ROOT_HASH), + requests_hash: Some(KECCAK_EMPTY), ..Header::default() }; let provider = executor_provider(chain_spec); @@ -855,7 +855,7 @@ mod tests { parent_hash: B256::random(), timestamp: 1, number: fork_activation_block, - requests_root: Some(EMPTY_ROOT_HASH), + requests_hash: Some(KECCAK_EMPTY), ..Header::default() }; @@ -901,7 +901,7 @@ mod tests { ); let mut header = chain_spec.genesis_header().clone(); - header.requests_root = Some(EMPTY_ROOT_HASH); + header.requests_hash = Some(KECCAK_EMPTY); let header_hash = header.hash_slow(); let provider = executor_provider(chain_spec); @@ -938,7 +938,7 @@ mod tests { parent_hash: header_hash, timestamp: 1, number: 1, - requests_root: Some(EMPTY_ROOT_HASH), + requests_hash: Some(KECCAK_EMPTY), ..Header::default() }; let header_hash = header.hash_slow(); @@ -977,7 +977,7 @@ mod tests { parent_hash: header_hash, timestamp: 1, number: 2, - requests_root: Some(EMPTY_ROOT_HASH), + requests_hash: Some(KECCAK_EMPTY), ..Header::default() }; diff --git a/crates/ethereum/payload/src/lib.rs b/crates/ethereum/payload/src/lib.rs index dcf54fc02489c..c5162295955d9 100644 --- a/crates/ethereum/payload/src/lib.rs +++ b/crates/ethereum/payload/src/lib.rs @@ -308,6 +308,7 @@ where } // calculate the requests and the requests root + // todo let (requests, requests_root) = if chain_spec .is_prague_active_at_timestamp(attributes.timestamp) { @@ -414,7 +415,7 @@ where parent_beacon_block_root: attributes.parent_beacon_block_root, blob_gas_used: blob_gas_used.map(Into::into), excess_blob_gas: excess_blob_gas.map(Into::into), - requests_root, + requests_hash: None, // TODO, }; // seal the block diff --git a/crates/net/eth-wire-types/src/blocks.rs b/crates/net/eth-wire-types/src/blocks.rs index 6e5483f3a0e01..3ceee279e31be 100644 --- a/crates/net/eth-wire-types/src/blocks.rs +++ b/crates/net/eth-wire-types/src/blocks.rs @@ -277,7 +277,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - requests_root: None + requests_hash: None }, ]), }.encode(&mut data); @@ -312,7 +312,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - requests_root: None + requests_hash: None }, ]), }; @@ -412,7 +412,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - requests_root: None + requests_hash: None }, ], withdrawals: None, @@ -488,7 +488,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - requests_root: None + requests_hash: None }, ], withdrawals: None, diff --git a/crates/net/eth-wire-types/src/header.rs b/crates/net/eth-wire-types/src/header.rs index b25a7568b2225..8c11bfa82bb69 100644 --- a/crates/net/eth-wire-types/src/header.rs +++ b/crates/net/eth-wire-types/src/header.rs @@ -143,7 +143,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - requests_root: None + requests_hash: None }; assert_eq!(header.hash_slow(), expected_hash); } @@ -256,7 +256,7 @@ mod tests { blob_gas_used: Some(0x020000), excess_blob_gas: Some(0), parent_beacon_block_root: None, - requests_root: None, + requests_hash: None, }; let header = Header::decode(&mut data.as_slice()).unwrap(); @@ -296,7 +296,7 @@ mod tests { parent_beacon_block_root: None, blob_gas_used: Some(0), excess_blob_gas: Some(0x1600000), - requests_root: None, + requests_hash: None, }; let header = Header::decode(&mut data.as_slice()).unwrap(); diff --git a/crates/net/p2p/src/full_block.rs b/crates/net/p2p/src/full_block.rs index 0116f13488104..c18ae3df688e6 100644 --- a/crates/net/p2p/src/full_block.rs +++ b/crates/net/p2p/src/full_block.rs @@ -347,13 +347,14 @@ fn ensure_valid_body_response( _ => return Err(ConsensusError::WithdrawalsRootUnexpected), } - match (header.requests_root, &block.requests) { - (Some(header_requests_root), Some(requests)) => { + match (header.requests_hash, &block.requests) { + (Some(header_requests_hash), Some(requests)) => { + // TODO let requests = requests.0.as_slice(); let requests_root = reth_primitives::proofs::calculate_requests_root(requests); - if requests_root != header_requests_root { + if requests_root != header_requests_hash { return Err(ConsensusError::BodyRequestsRootDiff( - GotExpected { got: requests_root, expected: header_requests_root }.into(), + GotExpected { got: requests_root, expected: header_requests_hash }.into(), )) } } diff --git a/crates/optimism/payload/src/builder.rs b/crates/optimism/payload/src/builder.rs index e590635f524e6..0e81ac7745598 100644 --- a/crates/optimism/payload/src/builder.rs +++ b/crates/optimism/payload/src/builder.rs @@ -507,7 +507,7 @@ where parent_beacon_block_root: attributes.payload_attributes.parent_beacon_block_root, blob_gas_used, excess_blob_gas: excess_blob_gas.map(Into::into), - requests_root: None, + requests_hash: None, }; // seal the block diff --git a/crates/optimism/primitives/src/bedrock.rs b/crates/optimism/primitives/src/bedrock.rs index bd42298588fea..7153ae3155c76 100644 --- a/crates/optimism/primitives/src/bedrock.rs +++ b/crates/optimism/primitives/src/bedrock.rs @@ -85,7 +85,7 @@ pub const BEDROCK_HEADER: Header = Header { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - requests_root: None, + requests_hash: None, }; /// Bedrock total difficulty on Optimism Mainnet. diff --git a/crates/primitives-traits/src/block/body.rs b/crates/primitives-traits/src/block/body.rs index 85eeda166c432..3966717c3b410 100644 --- a/crates/primitives-traits/src/block/body.rs +++ b/crates/primitives-traits/src/block/body.rs @@ -67,6 +67,7 @@ pub trait BlockBody: /// requests, this will return `None`. // todo: can be default impl if `calculate_requests_root` made into a method on // `Requests` and `Requests` moved to alloy + // TODO fn calculate_requests_root(&self) -> Option; /// Recover signer addresses for all transactions in the block body. diff --git a/crates/primitives-traits/src/header/test_utils.rs b/crates/primitives-traits/src/header/test_utils.rs index ef5c0d0253609..c5f6e86b9db16 100644 --- a/crates/primitives-traits/src/header/test_utils.rs +++ b/crates/primitives-traits/src/header/test_utils.rs @@ -37,7 +37,7 @@ pub const fn generate_valid_header( } // Placeholder for future EIP adjustments - header.requests_root = None; + header.requests_hash = None; header } diff --git a/crates/primitives-traits/src/lib.rs b/crates/primitives-traits/src/lib.rs index 8c54bd68c9666..6d6e013c232c9 100644 --- a/crates/primitives-traits/src/lib.rs +++ b/crates/primitives-traits/src/lib.rs @@ -30,7 +30,7 @@ mod integer_list; pub use integer_list::{IntegerList, IntegerListError}; pub mod request; -pub use request::{Request, Requests}; +pub use request::Requests; pub mod block; pub use block::{body::BlockBody, Block}; diff --git a/crates/primitives-traits/src/request.rs b/crates/primitives-traits/src/request.rs index c08af3fd62252..79659de8cb995 100644 --- a/crates/primitives-traits/src/request.rs +++ b/crates/primitives-traits/src/request.rs @@ -1,15 +1,11 @@ //! EIP-7685 requests. use alloc::vec::Vec; -pub use alloy_consensus::Request; -use alloy_eips::eip7685::{Decodable7685, Encodable7685}; -use alloy_rlp::{Decodable, Encodable}; use derive_more::{Deref, DerefMut, From, IntoIterator}; -use reth_codecs::{add_arbitrary_tests, Compact}; use revm_primitives::Bytes; use serde::{Deserialize, Serialize}; -/// A list of EIP-7685 requests. +/// A list of opaque EIP-7685 requests. #[derive( Debug, Clone, @@ -23,36 +19,13 @@ use serde::{Deserialize, Serialize}; IntoIterator, Serialize, Deserialize, - Compact, )] #[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] -#[add_arbitrary_tests(compact)] -pub struct Requests(pub Vec); +pub struct Requests(Vec); -impl Encodable for Requests { - fn encode(&self, out: &mut dyn bytes::BufMut) { - let mut h = alloy_rlp::Header { list: true, payload_length: 0 }; - - let mut encoded = Vec::new(); - for req in &self.0 { - let encoded_req = req.encoded_7685(); - h.payload_length += encoded_req.len(); - encoded.push(Bytes::from(encoded_req)); - } - - h.encode(out); - for req in encoded { - req.encode(out); - } - } -} - -impl Decodable for Requests { - fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - Ok( as Decodable>::decode(buf)? - .into_iter() - .map(|bytes| Request::decode_7685(&mut bytes.as_ref())) - .collect::, alloy_eips::eip7685::Eip7685Error>>() - .map(Self)?) +impl Requests { + /// Consumes [`Requests`] and returns the inner raw opaque requests. + pub fn take(self) -> Vec { + self.0 } } diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index b7e11f7b92ea2..34a85865c929c 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -599,6 +599,7 @@ impl BlockBody { /// Calculate the requests root for the block body, if requests exist. If there are no /// requests, this will return `None`. pub fn calculate_requests_root(&self) -> Option { + // TODO self.requests.as_ref().map(|r| crate::proofs::calculate_requests_root(&r.0)) } diff --git a/crates/primitives/src/proofs.rs b/crates/primitives/src/proofs.rs index 4efbb588e10de..e5d8ac11bc916 100644 --- a/crates/primitives/src/proofs.rs +++ b/crates/primitives/src/proofs.rs @@ -33,6 +33,7 @@ pub fn calculate_receipt_root(receipts: &[ReceiptWithBloom]) -> B256 { /// /// NOTE: The requests are encoded as `id + request` pub fn calculate_requests_root(requests: &[Request]) -> B256 { + // todo: rm ordered_trie_root_with_encoder(requests, |item, buf| item.encode_7685(buf)) } diff --git a/crates/rpc/rpc-api/src/engine.rs b/crates/rpc/rpc-api/src/engine.rs index 50181d23a75c3..6fd3a2e48ea1d 100644 --- a/crates/rpc/rpc-api/src/engine.rs +++ b/crates/rpc/rpc-api/src/engine.rs @@ -11,8 +11,8 @@ use alloy_rpc_types::{ }; use alloy_rpc_types_engine::{ ClientVersionV1, ExecutionPayloadBodiesV1, ExecutionPayloadBodiesV2, ExecutionPayloadInputV2, - ExecutionPayloadV1, ExecutionPayloadV3, ExecutionPayloadV4, ForkchoiceState, ForkchoiceUpdated, - PayloadId, PayloadStatus, TransitionConfiguration, + ExecutionPayloadV1, ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadId, + PayloadStatus, TransitionConfiguration, }; use alloy_rpc_types_eth::transaction::TransactionRequest; use alloy_serde::JsonStorageKey; @@ -54,9 +54,10 @@ pub trait EngineApi { #[method(name = "newPayloadV4")] async fn new_payload_v4( &self, - payload: ExecutionPayloadV4, + payload: ExecutionPayloadV3, versioned_hashes: Vec, parent_beacon_block_root: B256, + execution_requests: Vec, ) -> RpcResult; /// See also @@ -137,7 +138,7 @@ pub trait EngineApi { /// payload build process at the time of receiving this call. Note: /// > Provider software MAY stop the corresponding build process after serving this call. #[method(name = "getPayloadV4")] - async fn get_payload_v4(&self, payload_id: PayloadId) -> RpcResult; + async fn get_payload_v4(&self, payload_id: PayloadId) -> RpcResult; /// See also #[method(name = "getPayloadBodiesByHashV1")] diff --git a/crates/rpc/rpc-engine-api/src/engine_api.rs b/crates/rpc/rpc-engine-api/src/engine_api.rs index 252808c14a77f..04a50c4d5ce9b 100644 --- a/crates/rpc/rpc-engine-api/src/engine_api.rs +++ b/crates/rpc/rpc-engine-api/src/engine_api.rs @@ -6,8 +6,7 @@ use alloy_primitives::{BlockHash, BlockNumber, B256, U64}; use alloy_rpc_types_engine::{ CancunPayloadFields, ClientVersionV1, ExecutionPayload, ExecutionPayloadBodiesV1, ExecutionPayloadBodiesV2, ExecutionPayloadInputV2, ExecutionPayloadV1, ExecutionPayloadV3, - ExecutionPayloadV4, ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus, - TransitionConfiguration, + ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus, TransitionConfiguration, }; use async_trait::async_trait; use jsonrpsee_core::RpcResult; @@ -185,9 +184,10 @@ where /// See also pub async fn new_payload_v4( &self, - payload: ExecutionPayloadV4, + payload: ExecutionPayloadV3, versioned_hashes: Vec, parent_beacon_block_root: B256, + execution_requests: Vec, ) -> EngineApiResult { let payload = ExecutionPayload::from(payload); let payload_or_attrs = diff --git a/crates/rpc/rpc-eth-api/src/helpers/pending_block.rs b/crates/rpc/rpc-eth-api/src/helpers/pending_block.rs index 832cf17055a58..4dde26f44a633 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/pending_block.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/pending_block.rs @@ -419,7 +419,8 @@ pub trait LoadPendingBlock: EthApiTypes { // note(onbjerg): the rpc spec has not been changed to include requests, so for now we just // set these to empty - let (requests, requests_root) = + let (requests, requests_hash) = + // TODO update if chain_spec.is_prague_active_at_timestamp(block_env.timestamp.to::()) { (Some(Requests::default()), Some(EMPTY_ROOT_HASH)) } else { @@ -447,7 +448,7 @@ pub trait LoadPendingBlock: EthApiTypes { excess_blob_gas: block_env.get_blob_excess_gas().map(Into::into), extra_data: Default::default(), parent_beacon_block_root, - requests_root, + requests_hash: None, // TODO requests_hash, }; // Convert Vec> to Vec diff --git a/crates/rpc/rpc-types-compat/src/block.rs b/crates/rpc/rpc-types-compat/src/block.rs index fc8ea9e1c487f..a650a69c1c1f3 100644 --- a/crates/rpc/rpc-types-compat/src/block.rs +++ b/crates/rpc/rpc-types-compat/src/block.rs @@ -124,7 +124,7 @@ pub fn from_primitive_with_hash(primitive_header: reth_primitives::SealedHeader) blob_gas_used, excess_blob_gas, parent_beacon_block_root, - requests_root, + requests_hash, } = header; Header { @@ -150,7 +150,7 @@ pub fn from_primitive_with_hash(primitive_header: reth_primitives::SealedHeader) excess_blob_gas, parent_beacon_block_root, total_difficulty: None, - requests_root, + requests_hash, } } diff --git a/crates/rpc/rpc-types-compat/src/engine/payload.rs b/crates/rpc/rpc-types-compat/src/engine/payload.rs index e6f2f97ca75c3..37ba4f8895f12 100644 --- a/crates/rpc/rpc-types-compat/src/engine/payload.rs +++ b/crates/rpc/rpc-types-compat/src/engine/payload.rs @@ -7,7 +7,7 @@ use alloy_primitives::{B256, U256}; use alloy_rpc_types_engine::{ payload::{ExecutionPayloadBodyV1, ExecutionPayloadFieldV2, ExecutionPayloadInputV2}, ExecutionPayload, ExecutionPayloadBodyV2, ExecutionPayloadV1, ExecutionPayloadV2, - ExecutionPayloadV3, ExecutionPayloadV4, PayloadError, + ExecutionPayloadV3, PayloadError, }; use reth_primitives::{ constants::MAXIMUM_EXTRA_DATA_SIZE, @@ -68,7 +68,7 @@ pub fn try_payload_v1_to_block(payload: ExecutionPayloadV1) -> Result Result Result { - let ExecutionPayloadV4 { - payload_inner, - deposit_requests, - withdrawal_requests, - consolidation_requests, - } = payload; - let mut block = try_payload_v3_to_block(payload_inner)?; - - // attach requests with asc type identifiers - let requests = deposit_requests - .into_iter() - .map(Request::DepositRequest) - .chain(withdrawal_requests.into_iter().map(Request::WithdrawalRequest)) - .chain(consolidation_requests.into_iter().map(Request::ConsolidationRequest)) - .collect::>(); - - let requests_root = proofs::calculate_requests_root(&requests); - block.header.requests_root = Some(requests_root); - block.body.requests = Some(requests.into()); - - Ok(block) -} - /// Converts [`SealedBlock`] to [`ExecutionPayload`] pub fn block_to_payload(value: SealedBlock) -> ExecutionPayload { - if value.header.requests_root.is_some() { + // TODO + if value.header.requests_hash.is_some() { // block with requests root: V3 - ExecutionPayload::V4(block_to_payload_v4(value)) + ExecutionPayload::V3(block_to_payload_v3(value)) } else if value.header.parent_beacon_block_root.is_some() { // block with parent beacon block root: V3 ExecutionPayload::V3(block_to_payload_v3(value)) @@ -218,37 +194,6 @@ pub fn block_to_payload_v3(value: SealedBlock) -> ExecutionPayloadV3 { } } -/// Converts [`SealedBlock`] to [`ExecutionPayloadV4`] -pub fn block_to_payload_v4(mut value: SealedBlock) -> ExecutionPayloadV4 { - let (deposit_requests, withdrawal_requests, consolidation_requests) = - value.body.requests.take().unwrap_or_default().into_iter().fold( - (Vec::new(), Vec::new(), Vec::new()), - |(mut deposits, mut withdrawals, mut consolidation_requests), request| { - match request { - Request::DepositRequest(r) => { - deposits.push(r); - } - Request::WithdrawalRequest(r) => { - withdrawals.push(r); - } - Request::ConsolidationRequest(r) => { - consolidation_requests.push(r); - } - _ => {} - }; - - (deposits, withdrawals, consolidation_requests) - }, - ); - - ExecutionPayloadV4 { - deposit_requests, - withdrawal_requests, - consolidation_requests, - payload_inner: block_to_payload_v3(value), - } -} - /// Converts [`SealedBlock`] to [`ExecutionPayloadFieldV2`] pub fn convert_block_to_payload_field_v2(value: SealedBlock) -> ExecutionPayloadFieldV2 { // if there are withdrawals, return V2 @@ -318,7 +263,6 @@ pub fn try_into_block( ExecutionPayload::V1(payload) => try_payload_v1_to_block(payload)?, ExecutionPayload::V2(payload) => try_payload_v2_to_block(payload)?, ExecutionPayload::V3(payload) => try_payload_v3_to_block(payload)?, - ExecutionPayload::V4(payload) => try_payload_v4_to_block(payload)?, }; base_payload.header.parent_beacon_block_root = parent_beacon_block_root; @@ -451,13 +395,12 @@ pub fn execution_payload_from_sealed_block(value: SealedBlock) -> ExecutionPaylo #[cfg(test)] mod tests { use super::{ - block_to_payload_v3, try_into_block, try_payload_v3_to_block, try_payload_v4_to_block, - validate_block_hash, + block_to_payload_v3, try_into_block, try_payload_v3_to_block, validate_block_hash, }; use alloy_primitives::{b256, hex, Bytes, U256}; use alloy_rpc_types_engine::{ CancunPayloadFields, ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, - ExecutionPayloadV3, ExecutionPayloadV4, + ExecutionPayloadV3, }; #[test] @@ -680,55 +623,4 @@ mod tests { // Ensure the actual hash is calculated if we set the fields to what they should be validate_block_hash(block_hash_with_blob_fee_fields, block).unwrap(); } - - #[test] - fn parse_payload_v4() { - let s = r#"{ - "baseFeePerGas": "0x2ada43", - "blobGasUsed": "0x0", - "blockHash": "0x86eeb2a4b656499f313b601e1dcaedfeacccab27131b6d4ea99bc69a57607f7d", - "blockNumber": "0x2c", - "depositRequests": [ - { - "amount": "0xe8d4a51000", - "index": "0x0", - "pubkey": "0xaab5f2b3aad5c2075faf0c1d8937c7de51a53b765a21b4173eb2975878cea05d9ed3428b77f16a981716aa32af74c464", - "signature": "0xa889cd238be2dae44f2a3c24c04d686c548f6f82eb44d4604e1bc455b6960efb72b117e878068a8f2cfb91ad84b7ebce05b9254207aa51a1e8a3383d75b5a5bd2439f707636ea5b17b2b594b989c93b000b33e5dff6e4bed9d53a6d2d6889b0c", - "withdrawalCredentials": "0x00ab9364f8bf7561862ea0fc3b69c424c94ace406c4dc36ddfbf8a9d72051c80" - }, - { - "amount": "0xe8d4a51000", - "index": "0x1", - "pubkey": "0xb0b1b3b51cf688ead965a954c5cc206ba4e76f3f8efac60656ae708a9aad63487a2ca1fb30ccaf2ebe1028a2b2886b1b", - "signature": "0xb9759766e9bb191b1c457ae1da6cdf71a23fb9d8bc9f845eaa49ee4af280b3b9720ac4d81e64b1b50a65db7b8b4e76f1176a12e19d293d75574600e99fbdfecc1ab48edaeeffb3226cd47691d24473821dad0c6ff3973f03e4aa89f418933a56", - "withdrawalCredentials": "0x002d2b75f4a27f78e585a4735a40ab2437eceb12ec39938a94dc785a54d62513" - } - ], - "excessBlobGas": "0x0", - "extraData": "0x726574682f76302e322e302d626574612e372f6c696e7578", - "feeRecipient": "0x8943545177806ed17b9f23f0a21ee5948ecaa776", - "gasLimit": "0x1855e85", - "gasUsed": "0x25f98", - "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", - "parentHash": "0xd753194ef19b5c566b7eca6e9ebcca03895b548e1e93a20a23d922ba0bc210d4", - "prevRandao": "0x8c52256fd491776dc32f531ad4c0dc1444684741bca15f54c9cd40c60142df90", - "receiptsRoot": "0x510e7fb94279897e5dcd6c1795f6137d8fe02e49e871bfea7999fd21a89f66aa", - "stateRoot": "0x59ae0706a2b47162666fc7af3e30ff7aa34154954b68cc6aed58c3af3d58c9c2", - "timestamp": "0x6643c5a9", - "transactions": [ - "0x02f9021e8330182480843b9aca0085174876e80083030d40944242424242424242424242424242424242424242893635c9adc5dea00000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012049f42823819771c6bbbd9cb6649850083fd3b6e5d0beb1069342c32d65a3b0990000000000000000000000000000000000000000000000000000000000000030aab5f2b3aad5c2075faf0c1d8937c7de51a53b765a21b4173eb2975878cea05d9ed3428b77f16a981716aa32af74c46400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000ab9364f8bf7561862ea0fc3b69c424c94ace406c4dc36ddfbf8a9d72051c800000000000000000000000000000000000000000000000000000000000000060a889cd238be2dae44f2a3c24c04d686c548f6f82eb44d4604e1bc455b6960efb72b117e878068a8f2cfb91ad84b7ebce05b9254207aa51a1e8a3383d75b5a5bd2439f707636ea5b17b2b594b989c93b000b33e5dff6e4bed9d53a6d2d6889b0cc080a0db786f0d89923949e533680524f003cebd66f32fbd30429a6b6bfbd3258dcf60a05241c54e05574765f7ddc1a742ae06b044edfe02bffb202bf172be97397eeca9", - "0x02f9021e8330182401843b9aca0085174876e80083030d40944242424242424242424242424242424242424242893635c9adc5dea00000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120d694d6a0b0103651aafd87db6c88297175d7317c6e6da53ccf706c3c991c91fd0000000000000000000000000000000000000000000000000000000000000030b0b1b3b51cf688ead965a954c5cc206ba4e76f3f8efac60656ae708a9aad63487a2ca1fb30ccaf2ebe1028a2b2886b1b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020002d2b75f4a27f78e585a4735a40ab2437eceb12ec39938a94dc785a54d625130000000000000000000000000000000000000000000000000000000000000060b9759766e9bb191b1c457ae1da6cdf71a23fb9d8bc9f845eaa49ee4af280b3b9720ac4d81e64b1b50a65db7b8b4e76f1176a12e19d293d75574600e99fbdfecc1ab48edaeeffb3226cd47691d24473821dad0c6ff3973f03e4aa89f418933a56c080a099dc5b94a51e9b91a6425b1fed9792863006496ab71a4178524819d7db0c5e88a0119748e62700234079d91ae80f4676f9e0f71b260e9b46ef9b4aff331d3c2318" - ], - "withdrawalRequests": [], - "withdrawals": [], - "consolidationRequests": [] - }"#; - - let payload = serde_json::from_str::(s).unwrap(); - let mut block = try_payload_v4_to_block(payload).unwrap(); - block.header.parent_beacon_block_root = - Some(b256!("d9851db05fa63593f75e2b12c4bba9f47740613ca57da3b523a381b8c27f3297")); - let hash = block.seal_slow().hash(); - assert_eq!(hash, b256!("86eeb2a4b656499f313b601e1dcaedfeacccab27131b6d4ea99bc69a57607f7d")) - } } diff --git a/crates/storage/codecs/src/alloy/header.rs b/crates/storage/codecs/src/alloy/header.rs index 623eded9ee992..90e67b1e312cd 100644 --- a/crates/storage/codecs/src/alloy/header.rs +++ b/crates/storage/codecs/src/alloy/header.rs @@ -45,7 +45,7 @@ pub(crate) struct Header { #[cfg_attr(test, derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Compact)] pub(crate) struct HeaderExt { - requests_root: Option, + requests_hash: Option, } impl HeaderExt { @@ -53,7 +53,7 @@ impl HeaderExt { /// /// Required since [`Header`] uses `Option` as a field. const fn into_option(self) -> Option { - if self.requests_root.is_some() { + if self.requests_hash.is_some() { Some(self) } else { None @@ -66,7 +66,7 @@ impl Compact for AlloyHeader { where B: bytes::BufMut + AsMut<[u8]>, { - let extra_fields = HeaderExt { requests_root: self.requests_root }; + let extra_fields = HeaderExt { requests_hash: self.requests_hash }; let header = Header { parent_hash: self.parent_hash, @@ -116,7 +116,7 @@ impl Compact for AlloyHeader { blob_gas_used: header.blob_gas_used, excess_blob_gas: header.excess_blob_gas, parent_beacon_block_root: header.parent_beacon_block_root, - requests_root: header.extra_fields.and_then(|h| h.requests_root), + requests_hash: header.extra_fields.and_then(|h| h.requests_hash), extra_data: header.extra_data, }; (alloy_header, buf) @@ -176,7 +176,7 @@ mod tests { #[test] fn test_extra_fields() { let mut header = HOLESKY_BLOCK; - header.extra_fields = Some(HeaderExt { requests_root: Some(B256::random()) }); + header.extra_fields = Some(HeaderExt { requests_hash: Some(B256::random()) }); let mut encoded_header = vec![]; let len = header.to_compact(&mut encoded_header); diff --git a/crates/storage/codecs/src/alloy/mod.rs b/crates/storage/codecs/src/alloy/mod.rs index 942258d0647ef..54c17e4c3f275 100644 --- a/crates/storage/codecs/src/alloy/mod.rs +++ b/crates/storage/codecs/src/alloy/mod.rs @@ -3,7 +3,6 @@ mod authorization_list; mod genesis_account; mod header; mod log; -mod request; mod signature; mod transaction; mod trie; diff --git a/crates/storage/codecs/src/alloy/request.rs b/crates/storage/codecs/src/alloy/request.rs deleted file mode 100644 index 2447160beb6dc..0000000000000 --- a/crates/storage/codecs/src/alloy/request.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! Native Compact codec impl for EIP-7685 requests. - -use crate::Compact; -use alloy_consensus::Request; -use alloy_eips::eip7685::{Decodable7685, Encodable7685}; -use alloy_primitives::Bytes; -use bytes::BufMut; - -impl Compact for Request { - fn to_compact(&self, buf: &mut B) -> usize - where - B: BufMut + AsMut<[u8]>, - { - let encoded: Bytes = self.encoded_7685().into(); - encoded.to_compact(buf) - } - - fn from_compact(buf: &[u8], _: usize) -> (Self, &[u8]) { - let (raw, buf) = Bytes::from_compact(buf, buf.len()); - - (Self::decode_7685(&mut raw.as_ref()).expect("invalid eip-7685 request in db"), buf) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use proptest::proptest; - use proptest_arbitrary_interop::arb; - - proptest! { - #[test] - fn roundtrip(request in arb::()) { - let mut buf = Vec::::new(); - request.to_compact(&mut buf); - let (decoded, _) = Request::from_compact(&buf, buf.len()); - assert_eq!(request, decoded); - } - } -} diff --git a/testing/ef-tests/src/models.rs b/testing/ef-tests/src/models.rs index 3f3df15363a15..30e5e5bb20c2f 100644 --- a/testing/ef-tests/src/models.rs +++ b/testing/ef-tests/src/models.rs @@ -87,7 +87,7 @@ pub struct Header { /// Parent beacon block root. pub parent_beacon_block_root: Option, /// Requests root. - pub requests_root: Option, + pub requests_hash: Option, } impl From
for SealedHeader { @@ -113,7 +113,7 @@ impl From
for SealedHeader { blob_gas_used: value.blob_gas_used.map(|v| v.to::()), excess_blob_gas: value.excess_blob_gas.map(|v| v.to::()), parent_beacon_block_root: value.parent_beacon_block_root, - requests_root: value.requests_root, + requests_hash: value.requests_hash, }; Self::new(header, value.hash) } diff --git a/testing/testing-utils/src/generators.rs b/testing/testing-utils/src/generators.rs index d07af00ce4c29..96da31720f28e 100644 --- a/testing/testing-utils/src/generators.rs +++ b/testing/testing-utils/src/generators.rs @@ -204,7 +204,8 @@ pub fn random_block(rng: &mut R, number: u64, block_params: BlockParams) let requests = block_params .requests_count .map(|count| (0..count).map(|_| random_request(rng)).collect::>()); - let requests_root = requests.as_ref().map(|requests| proofs::calculate_requests_root(requests)); + // TODO + let requests_hash = requests.as_ref().map(|requests| proofs::calculate_requests_root(requests)); let withdrawals = block_params.withdrawals_count.map(|count| { (0..count) @@ -226,7 +227,7 @@ pub fn random_block(rng: &mut R, number: u64, block_params: BlockParams) transactions_root, ommers_hash, base_fee_per_gas: Some(rng.gen()), - requests_root, + requests_hash, withdrawals_root, ..Default::default() }