From 5d911a8c24fdcc1ac1f1033650f14b2fc719d93a Mon Sep 17 00:00:00 2001 From: Gregory Edison Date: Fri, 27 Dec 2024 19:43:00 +0100 Subject: [PATCH] feat: add mpt feature flag for correct genesis header computation in mpt mode Signed-off-by: Gregory Edison --- Cargo.lock | 1 + crates/scroll/bin/scroll-reth-mpt/Cargo.toml | 4 ++-- crates/scroll/chainspec/Cargo.toml | 4 +++- crates/scroll/chainspec/src/lib.rs | 3 +++ crates/scroll/cli/Cargo.toml | 3 ++- crates/scroll/node/Cargo.toml | 1 + 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a266d744fad7..7df9ba7a5861 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9392,6 +9392,7 @@ dependencies = [ "reth-primitives-traits", "reth-scroll-forks", "reth-scroll-state-commitment", + "reth-trie-common", "serde", "serde_json", ] diff --git a/crates/scroll/bin/scroll-reth-mpt/Cargo.toml b/crates/scroll/bin/scroll-reth-mpt/Cargo.toml index d52394afee6d..e48d3c330611 100644 --- a/crates/scroll/bin/scroll-reth-mpt/Cargo.toml +++ b/crates/scroll/bin/scroll-reth-mpt/Cargo.toml @@ -18,8 +18,8 @@ reth-node-builder.workspace = true reth-provider.workspace = true # scroll -reth-scroll-cli.workspace = true -reth-scroll-node.workspace = true +reth-scroll-cli = { workspace = true, features = ["mpt"]} +reth-scroll-node = { workspace = true, features = ["mpt"] } # misc clap = { workspace = true, features = ["derive", "env"] } diff --git a/crates/scroll/chainspec/Cargo.toml b/crates/scroll/chainspec/Cargo.toml index 4b28834a3c38..1c2a67ad5c1c 100644 --- a/crates/scroll/chainspec/Cargo.toml +++ b/crates/scroll/chainspec/Cargo.toml @@ -15,8 +15,9 @@ workspace = true # reth reth-chainspec.workspace = true reth-ethereum-forks.workspace = true -reth-primitives-traits.workspace = true reth-network-peers.workspace = true +reth-primitives-traits.workspace = true +reth-trie-common = { workspace = true, optional = true } # scroll reth-scroll-forks.workspace = true @@ -60,3 +61,4 @@ std = [ "derive_more/std", "reth-network-peers/std" ] +mpt = ["reth-trie-common"] diff --git a/crates/scroll/chainspec/src/lib.rs b/crates/scroll/chainspec/src/lib.rs index a4b523431ba8..ff2f2de93576 100644 --- a/crates/scroll/chainspec/src/lib.rs +++ b/crates/scroll/chainspec/src/lib.rs @@ -233,7 +233,10 @@ impl ScrollChainSpec { difficulty: self.genesis.difficulty, nonce: self.genesis.nonce.into(), extra_data: self.genesis.extra_data.clone(), + #[cfg(not(feature = "mpt"))] state_root: reth_scroll_state_commitment::state_root_ref_unhashed(&self.genesis.alloc), + #[cfg(feature = "mpt")] + state_root: reth_trie_common::root::state_root_ref_unhashed(&self.genesis.alloc), timestamp: self.genesis.timestamp, mix_hash: self.genesis.mix_hash, beneficiary: self.genesis.coinbase, diff --git a/crates/scroll/cli/Cargo.toml b/crates/scroll/cli/Cargo.toml index 4270e15af03a..13cdb87ad9bd 100644 --- a/crates/scroll/cli/Cargo.toml +++ b/crates/scroll/cli/Cargo.toml @@ -46,4 +46,5 @@ scroll = [ "reth-node-core/scroll", "reth-scroll-evm/scroll", "reth-scroll-node/scroll" -] \ No newline at end of file +] +mpt = ["reth-scroll-chainspec/mpt"] \ No newline at end of file diff --git a/crates/scroll/node/Cargo.toml b/crates/scroll/node/Cargo.toml index 7df01c10185b..739bf8ce4d72 100644 --- a/crates/scroll/node/Cargo.toml +++ b/crates/scroll/node/Cargo.toml @@ -64,4 +64,5 @@ scroll = [ "reth-scroll-evm/scroll", "reth-scroll-engine/scroll" ] +mpt = ["reth-scroll-chainspec/mpt"] skip-state-root-validation = [] \ No newline at end of file