From 79a0d23d581ca28df1ee1c01934a650ccf80d75e Mon Sep 17 00:00:00 2001 From: chengwenxi <22697326+chengwenxi@users.noreply.github.com> Date: Fri, 27 Feb 2026 09:42:32 +0800 Subject: [PATCH] refactor: rename MPTFork hardfork to Jade --- crates/chainspec/src/genesis.rs | 10 +++--- crates/chainspec/src/hardfork.rs | 54 +++++++++++++++--------------- crates/chainspec/src/spec.rs | 8 ++--- crates/engine-api/src/builder.rs | 2 +- crates/engine-api/src/lib.rs | 2 +- crates/engine-api/src/validator.rs | 38 ++++++++++----------- 6 files changed, 57 insertions(+), 57 deletions(-) diff --git a/crates/chainspec/src/genesis.rs b/crates/chainspec/src/genesis.rs index c38ac6b..9a3f714 100644 --- a/crates/chainspec/src/genesis.rs +++ b/crates/chainspec/src/genesis.rs @@ -40,7 +40,7 @@ impl TryFrom<&OtherFields> for MorphGenesisInfo { /// the Morph hardforks were activated. /// /// Note: Bernoulli and Curie use block-based activation, while Morph203, Viridian, -/// Emerald, and MPTFork use timestamp-based activation (matching go-ethereum behavior). +/// Emerald, and Jade use timestamp-based activation (matching go-ethereum behavior). #[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct MorphHardforkInfo { @@ -59,9 +59,9 @@ pub struct MorphHardforkInfo { /// Emerald hardfork timestamp. #[serde(skip_serializing_if = "Option::is_none")] pub emerald_time: Option, - /// MPTFork hardfork timestamp. + /// Jade hardfork timestamp. #[serde(skip_serializing_if = "Option::is_none")] - pub mpt_fork_time: Option, + pub jade_time: Option, } impl MorphHardforkInfo { @@ -136,7 +136,7 @@ mod tests { "morph203Time": 3000, "viridianTime": 4000, "emeraldTime": 5000, - "mptForkTime": 6000 + "jadeTime": 6000 } "#; @@ -151,7 +151,7 @@ mod tests { morph203_time: Some(3000), viridian_time: Some(4000), emerald_time: Some(5000), - mpt_fork_time: Some(6000), + jade_time: Some(6000), } ); } diff --git a/crates/chainspec/src/hardfork.rs b/crates/chainspec/src/hardfork.rs index 6eb1e34..81b38db 100644 --- a/crates/chainspec/src/hardfork.rs +++ b/crates/chainspec/src/hardfork.rs @@ -29,7 +29,7 @@ //! ## Current State //! //! Bernoulli and Curie use block-based activation, while Morph203, Viridian, -//! Emerald, and MPTFork use timestamp-based activation. +//! Emerald, and Jade use timestamp-based activation. use alloy_evm::revm::primitives::hardfork::SpecId; use alloy_hardforks::hardfork; @@ -39,7 +39,7 @@ hardfork!( /// Morph-specific hardforks for network upgrades. /// /// Note: Bernoulli and Curie use block-based activation, while Morph203, Viridian, - /// Emerald, and MPTFork use timestamp-based activation (matching go-ethereum behavior). + /// Emerald, and Jade use timestamp-based activation (matching go-ethereum behavior). #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Default)] MorphHardfork { @@ -53,9 +53,9 @@ hardfork!( Viridian, /// Emerald hardfork (timestamp-based). Emerald, - /// MPTFork hardfork (timestamp-based). + /// Jade hardfork (timestamp-based). #[default] - MPTFork, + Jade, } ); @@ -90,10 +90,10 @@ impl MorphHardfork { self >= Self::Emerald } - /// Returns `true` if this hardfork is MPTFork or later. + /// Returns `true` if this hardfork is Jade or later. #[inline] - pub fn is_mpt_fork(self) -> bool { - self >= Self::MPTFork + pub fn is_jade(self) -> bool { + self >= Self::Jade } } @@ -135,19 +135,19 @@ pub trait MorphHardforks: EthereumHardforks { .active_at_timestamp(timestamp) } - /// Convenience method to check if MPTFork hardfork is active at a given timestamp. - fn is_mpt_fork_active_at_timestamp(&self, timestamp: u64) -> bool { - self.morph_fork_activation(MorphHardfork::MPTFork) + /// Convenience method to check if Jade hardfork is active at a given timestamp. + fn is_jade_active_at_timestamp(&self, timestamp: u64) -> bool { + self.morph_fork_activation(MorphHardfork::Jade) .active_at_timestamp(timestamp) } /// Retrieves the latest Morph hardfork active at a given block and timestamp. /// /// Note: This method checks both block-based (Bernoulli, Curie) and - /// timestamp-based (Morph203, Viridian, Emerald, MPTFork) hardforks. + /// timestamp-based (Morph203, Viridian, Emerald, Jade) hardforks. fn morph_hardfork_at(&self, block_number: u64, timestamp: u64) -> MorphHardfork { - if self.is_mpt_fork_active_at_timestamp(timestamp) { - MorphHardfork::MPTFork + if self.is_jade_active_at_timestamp(timestamp) { + MorphHardfork::Jade } else if self.is_emerald_active_at_timestamp(timestamp) { MorphHardfork::Emerald } else if self.is_viridian_active_at_timestamp(timestamp) { @@ -171,7 +171,7 @@ impl From for SpecId { MorphHardfork::Morph203 => Self::OSAKA, MorphHardfork::Viridian => Self::OSAKA, MorphHardfork::Emerald => Self::OSAKA, - MorphHardfork::MPTFork => Self::OSAKA, + MorphHardfork::Jade => Self::OSAKA, } } } @@ -183,8 +183,8 @@ impl From for MorphHardfork { /// `From for SpecId`, because multiple Morph /// hardforks may share the same underlying EVM spec. fn from(spec: SpecId) -> Self { - if spec.is_enabled_in(SpecId::from(Self::MPTFork)) { - Self::MPTFork + if spec.is_enabled_in(SpecId::from(Self::Jade)) { + Self::Jade } else if spec.is_enabled_in(SpecId::from(Self::Emerald)) { Self::Emerald } else if spec.is_enabled_in(SpecId::from(Self::Viridian)) { @@ -238,7 +238,7 @@ mod tests { assert!(MorphHardfork::Morph203.is_curie()); assert!(MorphHardfork::Viridian.is_curie()); assert!(MorphHardfork::Emerald.is_curie()); - assert!(MorphHardfork::MPTFork.is_curie()); + assert!(MorphHardfork::Jade.is_curie()); } #[test] @@ -248,7 +248,7 @@ mod tests { assert!(MorphHardfork::Morph203.is_morph203()); assert!(MorphHardfork::Viridian.is_morph203()); assert!(MorphHardfork::Emerald.is_morph203()); - assert!(MorphHardfork::MPTFork.is_morph203()); + assert!(MorphHardfork::Jade.is_morph203()); } #[test] @@ -258,7 +258,7 @@ mod tests { assert!(!MorphHardfork::Morph203.is_viridian()); assert!(MorphHardfork::Viridian.is_viridian()); assert!(MorphHardfork::Emerald.is_viridian()); - assert!(MorphHardfork::MPTFork.is_viridian()); + assert!(MorphHardfork::Jade.is_viridian()); } #[test] @@ -268,16 +268,16 @@ mod tests { assert!(!MorphHardfork::Morph203.is_emerald()); assert!(!MorphHardfork::Viridian.is_emerald()); assert!(MorphHardfork::Emerald.is_emerald()); - assert!(MorphHardfork::MPTFork.is_emerald()); + assert!(MorphHardfork::Jade.is_emerald()); } #[test] - fn test_is_mpt_fork() { - assert!(!MorphHardfork::Bernoulli.is_mpt_fork()); - assert!(!MorphHardfork::Curie.is_mpt_fork()); - assert!(!MorphHardfork::Morph203.is_mpt_fork()); - assert!(!MorphHardfork::Viridian.is_mpt_fork()); - assert!(!MorphHardfork::Emerald.is_mpt_fork()); - assert!(MorphHardfork::MPTFork.is_mpt_fork()); + fn test_is_jade() { + assert!(!MorphHardfork::Bernoulli.is_jade()); + assert!(!MorphHardfork::Curie.is_jade()); + assert!(!MorphHardfork::Morph203.is_jade()); + assert!(!MorphHardfork::Viridian.is_jade()); + assert!(!MorphHardfork::Emerald.is_jade()); + assert!(MorphHardfork::Jade.is_jade()); } } diff --git a/crates/chainspec/src/spec.rs b/crates/chainspec/src/spec.rs index ad08deb..178f8cc 100644 --- a/crates/chainspec/src/spec.rs +++ b/crates/chainspec/src/spec.rs @@ -32,7 +32,7 @@ use std::sync::Arc; /// /// This allows using a ZK-trie state root (from go-ethereum) instead of /// computing an MPT state root from alloc. This is necessary because -/// Morph uses ZK-trie before MPTFork hardfork. +/// Morph uses ZK-trie before Jade hardfork. pub(crate) fn make_genesis_header(genesis: &Genesis, state_root: B256) -> MorphHeader { let base_spec = ChainSpec::from_genesis(genesis.clone()); let mut inner = base_spec.genesis_header.header().clone(); @@ -61,7 +61,7 @@ impl GenesisConfig { /// Create a configuration with custom state root and genesis hash. /// /// This is used for predefined networks (mainnet, testnet) that use ZK-trie - /// state roots before the MPTFork hardfork. + /// state roots before the Jade hardfork. pub fn with_state_root(mut self, state_root: B256, genesis_hash: B256) -> Self { self.state_root = Some(state_root); self.genesis_hash = Some(genesis_hash); @@ -99,12 +99,12 @@ fn build_hardforks(genesis: &Genesis, chain_info: &MorphGenesisInfo) -> ChainHar .into_iter() .filter_map(|(fork, block)| block.map(|b| (fork, ForkCondition::Block(b)))); - // Morph timestamp-based hardforks (Morph203, Viridian, Emerald, MPTFork) + // Morph timestamp-based hardforks (Morph203, Viridian, Emerald, Jade) let time_forks = vec![ (MorphHardfork::Morph203, hardfork_info.morph203_time), (MorphHardfork::Viridian, hardfork_info.viridian_time), (MorphHardfork::Emerald, hardfork_info.emerald_time), - (MorphHardfork::MPTFork, hardfork_info.mpt_fork_time), + (MorphHardfork::Jade, hardfork_info.jade_time), ] .into_iter() .filter_map(|(fork, time)| time.map(|t| (fork, ForkCondition::Timestamp(t)))); diff --git a/crates/engine-api/src/builder.rs b/crates/engine-api/src/builder.rs index 12fc9c5..7bd1f8b 100644 --- a/crates/engine-api/src/builder.rs +++ b/crates/engine-api/src/builder.rs @@ -209,7 +209,7 @@ where let rebuilt = rebuilt_payload.executable_data.clone(); // 4. Compare execution results - // Check state root if MPTFork is active + // Check state root if Jade is active if self .validation_ctx .should_validate_state_root(data.timestamp) diff --git a/crates/engine-api/src/lib.rs b/crates/engine-api/src/lib.rs index 59cdd7d..07bbfeb 100644 --- a/crates/engine-api/src/lib.rs +++ b/crates/engine-api/src/lib.rs @@ -4,7 +4,7 @@ //! //! - [`MorphL2EngineApi`]: The L2 Engine API trait for block building and validation //! - [`MorphL2EngineRpcServer`]: The JSON-RPC server implementation -//! - [`MorphValidationContext`]: Validation context with MPTFork hardfork support +//! - [`MorphValidationContext`]: Validation context with Jade hardfork support //! //! # L2 Engine API //! diff --git a/crates/engine-api/src/validator.rs b/crates/engine-api/src/validator.rs index df759ef..2a965aa 100644 --- a/crates/engine-api/src/validator.rs +++ b/crates/engine-api/src/validator.rs @@ -1,10 +1,10 @@ //! Morph Engine Validator utilities. //! //! This module provides utilities for state root validation according to -//! the MPTFork hardfork rules. +//! the Jade hardfork rules. //! -//! **Important**: Morph skips state root validation before the MPTFork hardfork, -//! before MPTFork, Morph uses ZK-trie, and state root verification happens in the +//! **Important**: Morph skips state root validation before the Jade hardfork, +//! before Jade, Morph uses ZK-trie, and state root verification happens in the //! ZK proof instead. use morph_chainspec::{MorphChainSpec, MorphHardforks}; @@ -12,8 +12,8 @@ use std::sync::Arc; /// Determines if state root validation should be performed for a given timestamp. /// -/// Before the MPTFork hardfork, state root validation is skipped because Morph -/// uses ZK-trie before MPTFork, and the state root verification happens in the +/// Before the Jade hardfork, state root validation is skipped because Morph +/// uses ZK-trie before Jade, and the state root verification happens in the /// ZK proof instead. /// /// # Arguments @@ -23,10 +23,10 @@ use std::sync::Arc; /// /// # Returns /// -/// Returns `true` if state root validation should be performed (MPT fork is active), -/// `false` if MPT fork is not active (validation skipped, using ZK-trie). +/// Returns `true` if state root validation should be performed (Jade is active), +/// `false` if Jade is not active (validation skipped, using ZK-trie). pub fn should_validate_state_root(chain_spec: &MorphChainSpec, timestamp: u64) -> bool { - chain_spec.is_mpt_fork_active_at_timestamp(timestamp) + chain_spec.is_jade_active_at_timestamp(timestamp) } /// Helper struct to hold chain spec for validation decisions. @@ -58,7 +58,7 @@ mod tests { use alloy_genesis::Genesis; use serde_json::json; - fn create_test_chainspec(mpt_fork_time: Option) -> Arc { + fn create_test_chainspec(jade_time: Option) -> Arc { let mut genesis_json = json!({ "config": { "chainId": 1337, @@ -69,8 +69,8 @@ mod tests { "alloc": {} }); - if let Some(time) = mpt_fork_time { - genesis_json["config"]["mptForkTime"] = json!(time); + if let Some(time) = jade_time { + genesis_json["config"]["jadeTime"] = json!(time); } let genesis: Genesis = serde_json::from_value(genesis_json).unwrap(); @@ -78,27 +78,27 @@ mod tests { } #[test] - fn test_should_validate_state_root_before_mpt_fork() { + fn test_should_validate_state_root_before_jade() { let chain_spec = create_test_chainspec(Some(1000)); - // Before MPT fork: should skip validation (return false, using ZK-trie) + // Before Jade: should skip validation (return false, using ZK-trie) assert!(!should_validate_state_root(&chain_spec, 0)); assert!(!should_validate_state_root(&chain_spec, 500)); assert!(!should_validate_state_root(&chain_spec, 999)); } #[test] - fn test_should_validate_state_root_after_mpt_fork() { + fn test_should_validate_state_root_after_jade() { let chain_spec = create_test_chainspec(Some(1000)); - // After MPT fork: should validate (return true, using MPT) + // After Jade: should validate (return true, using MPT) assert!(should_validate_state_root(&chain_spec, 1000)); assert!(should_validate_state_root(&chain_spec, 2000)); } #[test] - fn test_should_validate_state_root_no_mpt_fork() { - // If MPTFork is not set, should always return false + fn test_should_validate_state_root_no_jade() { + // If Jade is not set, should always return false let chain_spec = create_test_chainspec(None); assert!(!should_validate_state_root(&chain_spec, 0)); @@ -110,9 +110,9 @@ mod tests { let chain_spec = create_test_chainspec(Some(1000)); let ctx = MorphValidationContext::new(chain_spec); - // Before MPT fork: should skip validation (using ZK-trie) + // Before Jade: should skip validation (using ZK-trie) assert!(!ctx.should_validate_state_root(500)); - // After MPT fork: should validate (using MPT) + // After Jade: should validate (using MPT) assert!(ctx.should_validate_state_root(1000)); } }