Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/chainspec/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -59,9 +59,9 @@ pub struct MorphHardforkInfo {
/// Emerald hardfork timestamp.
#[serde(skip_serializing_if = "Option::is_none")]
pub emerald_time: Option<u64>,
/// MPTFork hardfork timestamp.
/// Jade hardfork timestamp.
#[serde(skip_serializing_if = "Option::is_none")]
pub mpt_fork_time: Option<u64>,
pub jade_time: Option<u64>,
}

impl MorphHardforkInfo {
Expand Down Expand Up @@ -136,7 +136,7 @@ mod tests {
"morph203Time": 3000,
"viridianTime": 4000,
"emeraldTime": 5000,
"mptForkTime": 6000
"jadeTime": 6000
}
"#;

Expand All @@ -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),
}
);
}
Expand Down
54 changes: 27 additions & 27 deletions crates/chainspec/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -53,9 +53,9 @@ hardfork!(
Viridian,
/// Emerald hardfork (timestamp-based).
Emerald,
/// MPTFork hardfork (timestamp-based).
/// Jade hardfork (timestamp-based).
#[default]
MPTFork,
Jade,
}
);

Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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) {
Expand All @@ -171,7 +171,7 @@ impl From<MorphHardfork> for SpecId {
MorphHardfork::Morph203 => Self::OSAKA,
MorphHardfork::Viridian => Self::OSAKA,
MorphHardfork::Emerald => Self::OSAKA,
MorphHardfork::MPTFork => Self::OSAKA,
MorphHardfork::Jade => Self::OSAKA,
}
}
}
Expand All @@ -183,8 +183,8 @@ impl From<SpecId> for MorphHardfork {
/// `From<MorphHardfork> 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)) {
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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());
}
}
8 changes: 4 additions & 4 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))));
Expand Down
2 changes: 1 addition & 1 deletion crates/engine-api/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/engine-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//!
Expand Down
38 changes: 19 additions & 19 deletions crates/engine-api/src/validator.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//! 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};
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
Expand All @@ -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.
Expand Down Expand Up @@ -58,7 +58,7 @@ mod tests {
use alloy_genesis::Genesis;
use serde_json::json;

fn create_test_chainspec(mpt_fork_time: Option<u64>) -> Arc<MorphChainSpec> {
fn create_test_chainspec(jade_time: Option<u64>) -> Arc<MorphChainSpec> {
let mut genesis_json = json!({
"config": {
"chainId": 1337,
Expand All @@ -69,36 +69,36 @@ 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();
Arc::new(MorphChainSpec::from(genesis))
}

#[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));
Expand All @@ -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));
}
}