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,796 changes: 1,001 additions & 795 deletions Cargo.lock

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,83 +53,83 @@ morph-rpc = { path = "crates/rpc" }
morph-revm = { path = "crates/revm", default-features = false }
morph-txpool = { path = "crates/txpool", default-features = false }

reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-cli = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-cli-commands = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-codecs = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-codecs-derive = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-consensus-common = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-db-api = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-e2e-test-utils = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-engine-local = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-engine-tree = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-errors = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-eth-wire-types = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-ethereum-cli = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-ethereum-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-ethereum-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-ethereum-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3", default-features = false }
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-execution-types = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-metrics = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-node-metrics = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-payload-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-payload-util = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3", default-features = false }
reth-provider = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-rpc = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-rpc-builder = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
reth-rpc-convert = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3" }
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 }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-cli = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-cli-commands = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-codecs = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-codecs-derive = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-consensus = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-consensus-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-db-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-e2e-test-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-engine-local = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-engine-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-engine-tree = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-errors = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-eth-wire-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-ethereum-cli = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-ethereum-consensus = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-ethereum-engine-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-ethereum-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2", default-features = false }
reth-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-execution-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-metrics = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-node-metrics = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-payload-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-payload-util = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2", default-features = false }
reth-provider = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-rpc = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-rpc-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-rpc-convert = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-rpc-server-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-storage-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-tasks = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2" }
reth-zstd-compressors = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2", default-features = false }

reth-revm = { git = "https://github.com/paradigmxyz/reth", rev = "64909d3", features = [
reth-revm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.10.2", features = [
"std",
"optional-checks",
] }
revm = { version = "33.1.0", features = [
revm = { version = "34.0.0", features = [
"optional_fee_charge",
], default-features = false }

alloy = { version = "1.1.3", default-features = false }
alloy-consensus = { version = "1.1.3", default-features = false }
alloy-contract = { version = "1.1.3", default-features = false }
alloy-eips = { version = "1.1.3", default-features = false }
alloy-evm = "0.25.2"
alloy-genesis = "1.1.3"
alloy-hardforks = "0.4.5"
alloy-network = { version = "1.1.3", default-features = false }
alloy-primitives = { version = "1.4.1", default-features = false }
alloy-provider = { version = "1.1.3", default-features = false }
alloy-rlp = "0.3.12"
alloy-rpc-types-engine = "1.1.3"
alloy-rpc-types-eth = { version = "1.1.3" }
alloy-serde = "1.1.3"
alloy-signer = "1.1.3"
alloy-signer-local = "1.1.3"
alloy-sol-types = "1.4.1"
alloy-transport = "1.1.3"
alloy-chains = { version = "0.2.5", default-features = false }
alloy = { version = "1.6.3", default-features = false }
alloy-consensus = { version = "1.6.3", default-features = false }
alloy-contract = { version = "1.6.3", default-features = false }
alloy-eips = { version = "1.6.3", default-features = false }
alloy-evm = "0.26.4"
alloy-genesis = "1.6.3"
alloy-hardforks = "0.4.7"
alloy-network = { version = "1.6.3", default-features = false }
alloy-primitives = { version = "1.5.6", default-features = false }
alloy-provider = { version = "1.6.3", default-features = false }
alloy-rlp = "0.3.13"
alloy-rpc-types-engine = "1.6.3"
alloy-rpc-types-eth = { version = "1.6.3" }
alloy-serde = "1.6.3"
alloy-signer = "1.6.3"
alloy-signer-local = "1.6.3"
alloy-sol-types = "1.5.6"
alloy-transport = "1.6.3"
alloy-chains = { version = "0.2.30", default-features = false }
arbitrary = { version = "1.3", features = ["derive"] }
async-lock = "3.4.1"
async-trait = "0.1"
Expand Down
42 changes: 35 additions & 7 deletions crates/consensus/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use alloy_evm::block::BlockExecutionResult;
use alloy_primitives::{B256, Bloom};
use morph_chainspec::MorphChainSpec;
use morph_primitives::{Block, BlockBody, MorphHeader, MorphReceipt, MorphTxEnvelope};
use reth_consensus::{Consensus, ConsensusError, FullConsensus, HeaderValidator};
use reth_consensus::{Consensus, ConsensusError, FullConsensus, HeaderValidator, ReceiptRootBloom};
use reth_consensus_common::validation::{
validate_against_parent_hash_number, validate_body_against_header,
};
Expand Down Expand Up @@ -213,16 +213,14 @@ impl HeaderValidator<MorphHeader> for MorphConsensus {
// ============================================================================

impl Consensus<Block> for MorphConsensus {
type Error = ConsensusError;

/// Validates the block body against the header.
///
/// Checks that the body's computed transaction root matches the header's.
fn validate_body_against_header(
&self,
body: &BlockBody,
header: &SealedHeader<MorphHeader>,
) -> Result<(), Self::Error> {
) -> Result<(), ConsensusError> {
validate_body_against_header(body, header.header())
}

Expand All @@ -235,7 +233,10 @@ impl Consensus<Block> for MorphConsensus {
/// 3. **Transaction Root**: Must be valid
/// 4. **Withdrawals**: Must be empty (Morph L2 doesn't support withdrawals)
/// 5. **L1 Messages**: Must be ordered correctly (sequential queue indices, L1 before L2)
fn validate_block_pre_execution(&self, block: &SealedBlock<Block>) -> Result<(), Self::Error> {
fn validate_block_pre_execution(
&self,
block: &SealedBlock<Block>,
) -> Result<(), ConsensusError> {
// Check no uncles allowed (Morph L2 has no uncle blocks)
let ommers_len = block.body().ommers().map(|o| o.len()).unwrap_or_default();
if ommers_len > 0 {
Expand Down Expand Up @@ -290,10 +291,14 @@ impl FullConsensus<morph_primitives::MorphPrimitives> for MorphConsensus {
/// 2. **Receipts Root**: The computed receipts root must match the header's.
/// 3. **Logs Bloom**: The combined bloom filter of all receipts must match
/// the header's `logs_bloom` field.
///
/// If `receipt_root_bloom` is provided, the implementation uses the pre-computed
/// receipt root and logs bloom instead of computing them from the receipts.
fn validate_block_post_execution(
&self,
block: &RecoveredBlock<Block>,
result: &BlockExecutionResult<MorphReceipt>,
receipt_root_bloom: Option<ReceiptRootBloom>,
) -> Result<(), ConsensusError> {
// Verify the block gas used
let cumulative_gas_used = result
Expand All @@ -314,8 +319,31 @@ impl FullConsensus<morph_primitives::MorphPrimitives> for MorphConsensus {
});
}

// Verify the receipts logs bloom and root
verify_receipts(block.receipts_root(), block.logs_bloom(), &result.receipts)?;
// If pre-computed receipt root and logs bloom are provided, use them directly
if let Some((receipts_root, logs_bloom)) = receipt_root_bloom {
if receipts_root != block.receipts_root() {
return Err(ConsensusError::BodyReceiptRootDiff(
GotExpected {
got: receipts_root,
expected: block.receipts_root(),
}
.into(),
));
}

if logs_bloom != block.logs_bloom() {
return Err(ConsensusError::BodyBloomLogDiff(
GotExpected {
got: logs_bloom,
expected: block.logs_bloom(),
}
.into(),
));
}
} else {
// Verify the receipts logs bloom and root
verify_receipts(block.receipts_root(), block.logs_bloom(), &result.receipts)?;
}

Ok(())
}
Expand Down
4 changes: 4 additions & 0 deletions crates/evm/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,8 @@ where
fn evm(&self) -> &Self::Evm {
&self.evm
}

fn receipts(&self) -> &[Self::Receipt] {
&self.receipts
}
}
10 changes: 8 additions & 2 deletions crates/evm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ impl ConfigureEvm for MorphEvmConfig {
.chain_spec()
.morph_hardfork_at(header.number(), header.timestamp());

let cfg_env = cfg_env.with_spec_and_mainnet_gas_params(spec);

Ok(EvmEnv {
cfg_env: cfg_env.with_spec(spec),
cfg_env,
block_env: MorphBlockEnv { inner: block_env },
})
}
Expand Down Expand Up @@ -73,8 +75,10 @@ impl ConfigureEvm for MorphEvmConfig {
.chain_spec()
.morph_hardfork_at(parent.number() + 1, attributes.timestamp);

let cfg_env = cfg_env.with_spec_and_mainnet_gas_params(spec);

Ok(EvmEnv {
cfg_env: cfg_env.with_spec(spec),
cfg_env,
block_env: MorphBlockEnv { inner: block_env },
})
}
Expand All @@ -84,6 +88,7 @@ impl ConfigureEvm for MorphEvmConfig {
block: &'a SealedBlock<Block>,
) -> Result<EthBlockExecutionCtx<'a>, Self::Error> {
Ok(EthBlockExecutionCtx {
tx_count_hint: Some(block.body().transactions.len()),
parent_hash: block.header().parent_hash(),
parent_beacon_block_root: block.header().parent_beacon_block_root(),
ommers: &[],
Expand All @@ -98,6 +103,7 @@ impl ConfigureEvm for MorphEvmConfig {
attributes: Self::NextBlockEnvCtx,
) -> Result<EthBlockExecutionCtx<'_>, Self::Error> {
Ok(EthBlockExecutionCtx {
tx_count_hint: None,
parent_hash: parent.hash(),
parent_beacon_block_root: attributes.parent_beacon_block_root,
ommers: &[],
Expand Down
3 changes: 2 additions & 1 deletion crates/payload/builder/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use alloy_primitives::B256;
use reth_evm::execute::ProviderError;
use reth_revm::db::bal::EvmDatabaseError;

/// Errors that can occur during Morph payload building.
#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -53,5 +54,5 @@ pub enum MorphPayloadBuilderError {

/// Database error when reading contract storage.
#[error("database error: {0}")]
Database(#[from] ProviderError),
Database(#[from] EvmDatabaseError<ProviderError>),
}
5 changes: 1 addition & 4 deletions crates/payload/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@ alloy-rpc-types-engine = { workspace = true, features = ["serde"] }
alloy-serde.workspace = true

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

[dev-dependencies]
serde_json.workspace = true
rand.workspace = true
alloy-primitives = { workspace = true, features = ["rand"] }

[features]
default = ["serde"]
10 changes: 3 additions & 7 deletions crates/payload/types/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use sha2::{Digest, Sha256};
///
/// This extends the standard Ethereum [`PayloadAttributes`] with L2-specific fields
/// for forced transaction inclusion (L1 messages).
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MorphPayloadAttributes {
/// Standard Ethereum payload attributes.
#[serde(flatten)]
Expand All @@ -26,10 +25,7 @@ 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.
#[cfg_attr(
feature = "serde",
serde(default, skip_serializing_if = "Option::is_none")
)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub transactions: Option<Vec<Bytes>>,
}

Expand Down
Loading