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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ license = "MIT OR Apache-2.0"
publish = false

[workspace]
members = [
"crates/evm",
"crates/revm",
"crates/chainspec",
"crates/primitives"
]
members = ["crates/evm", "crates/revm", "crates/chainspec", "crates/primitives"]

[workspace.lints]
[workspace.lints.clippy]
Expand All @@ -36,7 +31,10 @@ all = "warn"
morph-chainspec = { path = "crates/chainspec", default-features = false }
morph-evm = { path = "crates/evm", default-features = false }
morph-revm = { path = "crates/revm", default-features = false }
morph-primitives = { path = "crates/primitives", default-features = false }
morph-primitives = { path = "crates/primitives", default-features = false, features = [
"serde",
"reth",
] }

reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
Expand Down Expand Up @@ -159,4 +157,4 @@ criterion = "0.7.0"
test-case = "3"
secp256k1 = "0.30.0"
pyroscope = "0.5.8"
pyroscope_pprofrs = "0.2.10"
pyroscope_pprofrs = "0.2.10"
2 changes: 1 addition & 1 deletion crates/chainspec/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ hardfork!(
/// Curie hardfork.
Curie,
/// Morph203 hardfork.
#[default]
Morph203,
/// Viridian hardfork.
#[default]
Viridian,
}
);
Expand Down
7 changes: 5 additions & 2 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use reth_chainspec::{
Head,
};
use reth_network_peers::NodeRecord;
use std::sync::{Arc};
use std::sync::Arc;

pub const MORPH_BASE_FEE: u64 = 10_000_000_000;

Expand Down Expand Up @@ -289,7 +289,10 @@ mod tests {
let has_bernoulli = chainspec
.forks_iter()
.any(|(fork, _)| fork.name() == "Bernoulli");
assert!(has_bernoulli, "Bernoulli hardfork should be in inner.hardforks");
assert!(
has_bernoulli,
"Bernoulli hardfork should be in inner.hardforks"
);
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions crates/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ revm.workspace = true
[features]
default = ["rpc"]
rpc = ["dep:reth-rpc-eth-api", "morph-revm/rpc"]
engine = []
4 changes: 2 additions & 2 deletions crates/evm/src/assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use crate::{
MorphEvmConfig, MorphEvmFactory, block::MorphReceiptBuilder, context::MorphBlockExecutionCtx,
};
use alloy_evm::{block::BlockExecutionError, eth::EthBlockExecutorFactory};
use morph_chainspec::MorphChainSpec;
use morph_primitives::MorphHeader;
use reth_evm::execute::{BlockAssembler, BlockAssemblerInput};
use reth_evm_ethereum::EthBlockAssembler;
use std::sync::Arc;
use morph_chainspec::MorphChainSpec;
use morph_primitives::MorphHeader;

/// Assembler for Morph blocks.
#[derive(Debug, Clone)]
Expand Down
10 changes: 7 additions & 3 deletions crates/evm/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ use alloy_evm::{
receipt_builder::{ReceiptBuilder, ReceiptBuilderCtx},
},
};
use reth_revm::{Inspector, State, context::result::ResultAndState};
use morph_chainspec::MorphChainSpec;
use morph_primitives::{MorphReceipt, MorphTxEnvelope};
use morph_revm::{MorphHaltReason, evm::MorphContext};

use reth_revm::{Inspector, State, context::result::ResultAndState};

/// Builder for [`MorphReceipt`].
#[derive(Debug, Clone, Copy, Default)]
Expand Down Expand Up @@ -64,7 +63,12 @@ where
chain_spec: &'a MorphChainSpec,
) -> Self {
Self {
inner: EthBlockExecutor::new(evm, ctx.inner, chain_spec, MorphReceiptBuilder::default()),
inner: EthBlockExecutor::new(
evm,
ctx.inner,
chain_spec,
MorphReceiptBuilder::default(),
),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/evm/src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use crate::MorphEvmConfig;
use alloy_consensus::crypto::RecoveryError;
use alloy_primitives::Address;
use morph_payload_types::MorphExecutionData;
use morph_primitives::{Block, MorphTxEnvelope};
use morph_revm::MorphTxEnv;
use reth_evm::{
ConfigureEngineEvm, ConfigureEvm, EvmEnvFor, ExecutableTxIterator, ExecutionCtxFor,
FromRecoveredTx, RecoveredTx, ToTxEnv,
};
use reth_primitives_traits::{SealedBlock, SignedTransaction};
use std::sync::Arc;
use morph_payload_types::MorphExecutionData;
use morph_primitives::{Block, MorphTxEnvelope};
use morph_revm::MorphTxEnv;

impl ConfigureEngineEvm<MorphExecutionData> for MorphEvmConfig {
fn evm_env_for_payload(
Expand Down
15 changes: 9 additions & 6 deletions crates/evm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use alloy_evm::{
},
};
use alloy_primitives::{Address, Bytes, Log};
use reth_revm::MainContext;
use std::ops::{Deref, DerefMut};
use morph_chainspec::hardfork::MorphHardfork;
use morph_revm::{MorphHaltReason, MorphInvalidTransaction, MorphTxEnv, evm::MorphContext};
use reth_revm::MainContext;
use std::ops::{Deref, DerefMut};

use crate::MorphBlockEnv;

Expand Down Expand Up @@ -208,7 +208,7 @@ where
#[cfg(test)]
mod tests {
use reth_revm::context::BlockEnv;
use revm::database::EmptyDB;
use revm::{context::TxEnv, database::EmptyDB};

use super::*;

Expand All @@ -228,9 +228,12 @@ mod tests {
);
let result = evm
.transact(MorphTxEnv {
caller: Address::ZERO,
gas_price: 0,
gas_limit: 21000,
inner: TxEnv {
caller: Address::ZERO,
gas_price: 0,
gas_limit: 21000,
..Default::default()
},
..Default::default()
})
.unwrap();
Expand Down
17 changes: 11 additions & 6 deletions crates/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(feature = "engine")]
mod engine;
mod assemble;
use alloy_consensus::BlockHeader as _;
pub use assemble::MorphBlockAssembler;
mod block;
mod context;
pub use context::{MorphBlockExecutionCtx, MorphNextBlockEnvAttributes};
#[cfg(feature = "engine")]
mod engine;

mod error;
pub use error::MorphEvmError;
pub mod evm;
Expand All @@ -23,15 +24,15 @@ use alloy_evm::{
revm::{Inspector, database::State},
};
pub use evm::MorphEvmFactory;
use morph_primitives::{Block, MorphHeader, MorphPrimitives, MorphReceipt, MorphTxEnvelope};
use reth_chainspec::EthChainSpec;
use reth_evm::{self, ConfigureEvm, EvmEnvFor};
use reth_primitives_traits::{SealedBlock, SealedHeader};
use morph_primitives::{Block, MorphHeader, MorphPrimitives, MorphReceipt, MorphTxEnvelope};

use crate::{block::MorphBlockExecutor, evm::MorphEvm};
use reth_evm_ethereum::EthEvmConfig;
use morph_chainspec::{MorphChainSpec, hardfork::MorphHardforks};
use morph_revm::evm::MorphContext;
use reth_evm_ethereum::EthEvmConfig;

pub use morph_revm::{MorphBlockEnv, MorphHaltReason};

Expand Down Expand Up @@ -197,14 +198,18 @@ mod tests {
fn test_evm_config_can_query_morph_hardforks() {
// Create a test chainspec with Bernoulli at genesis
let chainspec = Arc::new(morph_chainspec::MorphChainSpec::from_genesis(
morph_chainspec::spec::ANDANTINO.genesis().clone(),
Default::default(),
));

let evm_config = MorphEvmConfig::new_with_default_factory(chainspec);

// Should be able to query Morph hardforks through the chainspec
assert!(evm_config.chain_spec().is_bernoulli_active_at_timestamp(0));
assert!(evm_config.chain_spec().is_bernoulli_active_at_timestamp(1000));
assert!(
evm_config
.chain_spec()
.is_bernoulli_active_at_timestamp(1000)
);

// Should be able to query activation condition
let activation = evm_config
Expand Down
33 changes: 30 additions & 3 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ workspace = true

[dependencies]
# Reth
reth-ethereum-primitives.workspace = true
reth-db-api = { workspace = true, optional = true }
reth-ethereum-primitives = { workspace = true, optional = true }
reth-primitives-traits = { workspace = true, optional = true }
reth-codecs = { workspace = true, optional = true }

# Alloy
alloy-consensus.workspace = true
Expand All @@ -21,8 +24,32 @@ alloy-primitives.workspace = true
alloy-rlp.workspace = true
alloy-serde = { workspace = true, optional = true }

# Utils
serde = { workspace = true, features = ["derive"], optional = true }
modular-bitfield = { version = "0.11.2", optional = true }


[dev-dependencies]

[features]
default = []
serde = ["dep:alloy-serde", "alloy-primitives/serde", "alloy-eips/serde"]
default = ["serde", "reth-codec"]
serde = [
"dep:serde",
"dep:alloy-serde",
"alloy-primitives/serde",
"alloy-eips/serde",
]
reth = [
"dep:reth-ethereum-primitives",
"dep:reth-primitives-traits",
]
reth-codec = [
"reth",
"serde",
"dep:reth-codecs",
"dep:reth-db-api",
"dep:modular-bitfield",
"reth-ethereum-primitives/reth-codec",
"reth-codecs/alloy",
"reth-primitives-traits/reth-codec",
]
38 changes: 31 additions & 7 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,40 @@ use alloy_primitives as _;
use alloy_rlp as _;

pub mod transaction;
use crate::transaction::envelope::MorphTxType;
use alloy_primitives::Log;

// Re-export standard Ethereum types
pub use alloy_consensus::Header;
pub use reth_ethereum_primitives::{
Block, EthPrimitives as MorphPrimitives, Receipt as MorphReceipt,
TransactionSigned as MorphTxEnvelope,
};
/// Header alias for backwards compatibility.
pub type MorphHeader = Header;

use reth_ethereum_primitives::EthereumReceipt;
use reth_primitives_traits::NodePrimitives;

/// Morph block.
pub type Block = alloy_consensus::Block<MorphTxEnvelope, MorphHeader>;

/// Morph block body.
pub type BlockBody = alloy_consensus::BlockBody<MorphTxEnvelope, MorphHeader>;

/// Morph receipt.
pub type MorphReceipt<L = Log> = EthereumReceipt<MorphTxType, L>;

// Re-export transaction types
pub use transaction::{L1Transaction, L1_TX_TYPE_ID};
pub use transaction::{
ALT_FEE_TX_TYPE_ID, L1_TX_TYPE_ID, MorphTxEnvelope, TxAltFee, TxAltFeeExt, TxL1Msg,
};

/// Header alias for backwards compatibility.
pub type MorphHeader = Header;
/// A [`NodePrimitives`] implementation for Morph.
#[derive(Debug, Clone, Default, Eq, PartialEq)]
#[non_exhaustive]
pub struct MorphPrimitives;

impl NodePrimitives for MorphPrimitives {
type Block = Block;
type BlockHeader = MorphHeader;
type BlockBody = BlockBody;
type SignedTx = MorphTxEnvelope;
type Receipt = MorphReceipt;
}
Loading