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
1,960 changes: 1,915 additions & 45 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ members = [
"crates/consensus",
"crates/engine-api",
"crates/evm",
"crates/node",
"crates/rpc",
"crates/payload/builder",
"crates/payload/types",
"crates/primitives",
Expand Down Expand Up @@ -43,12 +45,11 @@ morph-chainspec = { path = "crates/chainspec", default-features = false }
morph-consensus = { path = "crates/consensus", default-features = false }
morph-engine-api = { path = "crates/engine-api", default-features = false }
morph-evm = { path = "crates/evm", default-features = false }
morph-node = { path = "crates/node"}
morph-payload-builder = { path = "crates/payload/builder", default-features = false }
morph-payload-types = { path = "crates/payload/types", default-features = false }
morph-primitives = { path = "crates/primitives", default-features = false, features = [
"serde",
"reth",
] }
morph-primitives = { path = "crates/primitives", default-features = false }
morph-rpc = { path = "crates/rpc" }
morph-revm = { path = "crates/revm", default-features = false }
morph-txpool = { path = "crates/txpool", default-features = false }

Expand Down Expand Up @@ -97,6 +98,7 @@ reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-rpc-server-types = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-storage-api = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-tasks = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-zstd-compressors = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "morph-chainspec"
description = "TODO:"
description = "Morph L2 chainspec implementation"

version.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workspace = true
[dependencies]
# Morph
morph-chainspec.workspace = true
morph-primitives = { workspace = true, features = ["reth-codec"] }
morph-primitives = { workspace = true, features = ["serde-bincode-compat"] }

# Reth
reth-consensus.workspace = true
Expand Down
9 changes: 4 additions & 5 deletions crates/evm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "morph-evm"
description = "TODO:"
description = "Morph EVM implementation"

version.workspace = true
edition.workspace = true
Expand All @@ -16,7 +16,7 @@ morph-chainspec.workspace = true
morph-primitives.workspace = true
morph-revm.workspace = true

reth-chainspec = { workspace = true, optional = true }
reth-chainspec.workspace = true
reth-evm.workspace = true
reth-evm-ethereum.workspace = true
reth-revm.workspace = true
Expand All @@ -38,8 +38,7 @@ alloy-genesis.workspace = true

[features]
default = []
reth-codec = [
"morph-primitives/reth-codec",
"dep:reth-chainspec",
serde-bincode-compat = [
"morph-primitives/serde-bincode-compat",
]
rpc = ["dep:reth-rpc-eth-api", "morph-revm/rpc"]
3 changes: 1 addition & 2 deletions crates/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
//!
//! # Features
//!
//! - `reth-codec`: Enable `ConfigureEvm` implementation for reth integration
//! - `serde-bincode-compat`: Enable `ConfigureEvm` implementation for reth integration
//! - `engine`: Enable engine API types

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(feature = "reth-codec")]
mod config;

mod assemble;
Expand Down
16 changes: 16 additions & 0 deletions crates/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "morph-node"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
publish.workspace = true

[lints]
workspace = true

[dependencies]
morph-rpc.workspace = true

[features]
default = []
7 changes: 7 additions & 0 deletions crates/node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Morph node implementation
//!
//! This crate provides the Morph node types and RPC implementation.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub use morph_rpc as rpc;
4 changes: 2 additions & 2 deletions crates/payload/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ workspace = true
[dependencies]
# Morph
morph-chainspec.workspace = true
morph-evm = { workspace = true, features = ["reth-codec"] }
morph-evm = { workspace = true, features = ["serde-bincode-compat"] }
morph-payload-types.workspace = true
morph-primitives.workspace = true
morph-primitives = { workspace = true, features = ["serde-bincode-compat", "reth-codec"] }

# Reth
reth-basic-payload-builder.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/payload/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ workspace = true

[dependencies]
# Morph
morph-primitives = { workspace = true, features = ["serde", "reth-codec"] }
morph-primitives = { workspace = true, features = ["serde-bincode-compat"] }

# Reth
reth-payload-builder.workspace = true
Expand All @@ -29,7 +29,7 @@ alloy-rpc-types-engine = { workspace = true, features = ["serde"] }
alloy-serde.workspace = true

# Utils
serde = { workspace = true, features = ["derive"] }
serde = { workspace = true, features = ["derive"], optional = true }
sha2.workspace = true

[dev-dependencies]
Expand All @@ -38,4 +38,4 @@ rand.workspace = true
alloy-primitives = { workspace = true, features = ["rand"] }

[features]
default = []
default = ["serde"]
11 changes: 7 additions & 4 deletions crates/payload/types/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use morph_primitives::MorphTxEnvelope;
use reth_payload_builder::EthPayloadBuilderAttributes;
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_primitives_traits::{Recovered, SignerRecoverable, WithEncoded};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};

/// Morph-specific payload attributes for Engine API.
///
/// This extends the standard Ethereum [`PayloadAttributes`] with L2-specific fields
/// for forced transaction inclusion (L1 messages).
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct MorphPayloadAttributes {
/// Standard Ethereum payload attributes.
#[serde(flatten)]
Expand All @@ -26,7 +26,10 @@ pub struct MorphPayloadAttributes {
///
/// This includes L1 messages that must be processed in order.
/// These transactions are not in the mempool and must be explicitly provided.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "serde",
serde(default, skip_serializing_if = "Option::is_none")
)]
pub transactions: Option<Vec<Bytes>>,
}

Expand Down
29 changes: 16 additions & 13 deletions crates/payload/types/src/executable_l2_data.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! ExecutableL2Data type definition.

use alloy_primitives::{Address, B256, Bytes};
use serde::{Deserialize, Serialize};

/// L2 block data used for AssembleL2Block/ValidateL2Block/NewL2Block.
///
Expand All @@ -13,8 +12,9 @@ use serde::{Deserialize, Serialize};
/// 1. **BLS message fields**: Fields that affect state calculation and need BLS signing
/// 2. **Execution results**: Fields computed after block execution
/// 3. **Metadata**: Additional L2-specific fields
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct ExecutableL2Data {
// === BLS message fields (need to be signed) ===
/// Parent block hash.
Expand All @@ -24,35 +24,38 @@ pub struct ExecutableL2Data {
pub miner: Address,

/// Block number.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub number: u64,

/// Gas limit for this block.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub gas_limit: u64,

/// Base fee per gas (EIP-1559).
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "alloy_serde::quantity::opt"
#[cfg_attr(
feature = "serde",
serde(
default,
skip_serializing_if = "Option::is_none",
with = "alloy_serde::quantity::opt"
)
)]
pub base_fee_per_gas: Option<u128>,

/// Block timestamp.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub timestamp: u64,

/// RLP-encoded transactions.
#[serde(default)]
#[cfg_attr(feature = "serde", serde(default))]
pub transactions: Vec<Bytes>,

// === Execution results ===
/// State root after execution.
pub state_root: B256,

/// Gas used by all transactions.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub gas_used: u64,

/// Receipts root.
Expand All @@ -66,7 +69,7 @@ pub struct ExecutableL2Data {

// === Metadata ===
/// Next L1 message queue index after this block.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub next_l1_message_index: u64,

/// Cached block hash.
Expand Down
4 changes: 2 additions & 2 deletions crates/payload/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use alloy_primitives::{B256, Bytes};
use morph_primitives::Block;
use reth_payload_primitives::{BuiltPayload, ExecutionPayload, PayloadTypes};
use reth_primitives_traits::{NodePrimitives, SealedBlock};
use serde::{Deserialize, Serialize};
use std::sync::Arc;

// Re-export main types
Expand All @@ -47,7 +46,8 @@ pub use safe_l2_data::SafeL2Data;
pub struct MorphPayloadTypes;

/// Execution data for Morph node. Simply wraps a sealed block.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MorphExecutionData {
/// The built block.
pub block: Arc<SealedBlock<Block>>,
Expand Down
13 changes: 7 additions & 6 deletions crates/payload/types/src/params.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//! Request/response types for L2 Engine API methods.

use alloy_primitives::Bytes;
use serde::{Deserialize, Serialize};

/// Parameters for engine_assembleL2Block.
///
/// This struct contains the input parameters for building a new L2 block.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct AssembleL2BlockParams {
/// Block number to build.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub number: u64,

/// Transactions to include in the block.
/// These are RLP-encoded transaction bytes.
#[serde(default)]
#[cfg_attr(feature = "serde", serde(default))]
pub transactions: Vec<Bytes>,
}

Expand All @@ -41,7 +41,8 @@ impl AssembleL2BlockParams {
///
/// This is used by methods like engine_validateL2Block that return
/// a simple success/failure status.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct GenericResponse {
/// Whether the operation was successful.
pub success: bool,
Expand Down
30 changes: 18 additions & 12 deletions crates/payload/types/src/safe_l2_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! This type is used for NewSafeL2Block in the derivation pipeline.

use alloy_primitives::{B256, Bytes};
use serde::{Deserialize, Serialize};

/// Safe L2 block data, used for NewSafeL2Block (derivation).
///
Expand All @@ -13,35 +12,42 @@ use serde::{Deserialize, Serialize};
/// during execution rather than provided upfront.
///
/// [`ExecutableL2Data`]: super::ExecutableL2Data
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct SafeL2Data {
/// Block number.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub number: u64,

/// Gas limit.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub gas_limit: u64,

/// Base fee per gas (EIP-1559).
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "alloy_serde::quantity::opt"
#[cfg_attr(
feature = "serde",
serde(
default,
skip_serializing_if = "Option::is_none",
with = "alloy_serde::quantity::opt"
)
)]
pub base_fee_per_gas: Option<u128>,

/// Block timestamp.
#[serde(with = "alloy_serde::quantity")]
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub timestamp: u64,

/// RLP-encoded transactions.
#[serde(default)]
#[cfg_attr(feature = "serde", serde(default))]
pub transactions: Vec<Bytes>,

/// Optional batch hash for batch association.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "serde",
serde(default, skip_serializing_if = "Option::is_none")
)]
pub batch_hash: Option<B256>,
}

Expand Down
Loading