From 9001cc2cec2594d0761024a07441d9a6c043f23b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 Jan 2025 17:51:53 +0100 Subject: [PATCH] chore: remove reth-primitives dep from consensus (#14067) --- Cargo.lock | 1 - bin/reth/src/commands/debug_cmd/build_block.rs | 2 +- crates/consensus/consensus/Cargo.toml | 3 --- crates/consensus/consensus/src/lib.rs | 11 +++++------ crates/consensus/consensus/src/noop.rs | 3 +-- crates/consensus/consensus/src/test_utils.rs | 3 +-- crates/ethereum/consensus/src/lib.rs | 2 +- crates/ethereum/node/src/node.rs | 2 +- crates/rpc/rpc-builder/src/lib.rs | 4 ++-- 9 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 853c1739a..181d1a8c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6734,7 +6734,6 @@ dependencies = [ "alloy-primitives", "auto_impl", "derive_more", - "reth-primitives", "reth-primitives-traits", ] diff --git a/bin/reth/src/commands/debug_cmd/build_block.rs b/bin/reth/src/commands/debug_cmd/build_block.rs index 8e37161aa..935ae726b 100644 --- a/bin/reth/src/commands/debug_cmd/build_block.rs +++ b/bin/reth/src/commands/debug_cmd/build_block.rs @@ -125,7 +125,7 @@ impl> Command { ) -> eyre::Result<()> { let Environment { provider_factory, .. } = self.env.init::(AccessRights::RW)?; - let consensus: Arc> = + let consensus: Arc> = Arc::new(EthBeaconConsensus::new(provider_factory.chain_spec())); // fetch the best block from the database diff --git a/crates/consensus/consensus/Cargo.toml b/crates/consensus/consensus/Cargo.toml index 385cc5152..0bbe53c42 100644 --- a/crates/consensus/consensus/Cargo.toml +++ b/crates/consensus/consensus/Cargo.toml @@ -12,7 +12,6 @@ workspace = true [dependencies] # reth -reth-primitives.workspace = true reth-primitives-traits.workspace = true # ethereum @@ -27,7 +26,6 @@ derive_more.workspace = true [features] default = ["std"] std = [ - "reth-primitives/std", "reth-primitives-traits/std", "alloy-primitives/std", "alloy-eips/std", @@ -36,6 +34,5 @@ std = [ "derive_more/std", ] test-utils = [ - "reth-primitives/test-utils", "reth-primitives-traits/test-utils", ] diff --git a/crates/consensus/consensus/src/lib.rs b/crates/consensus/consensus/src/lib.rs index aa14806e4..0536037eb 100644 --- a/crates/consensus/consensus/src/lib.rs +++ b/crates/consensus/consensus/src/lib.rs @@ -15,11 +15,10 @@ use alloc::{fmt::Debug, sync::Arc, vec::Vec}; use alloy_consensus::Header; use alloy_eips::eip7685::Requests; use alloy_primitives::{BlockHash, BlockNumber, Bloom, B256, U256}; -use reth_primitives::{ - EthPrimitives, GotExpected, GotExpectedBoxed, InvalidTransactionError, NodePrimitives, Receipt, - RecoveredBlock, SealedBlock, SealedHeader, +use reth_primitives_traits::{ + constants::MINIMUM_GAS_LIMIT, transaction::error::InvalidTransactionError, Block, GotExpected, + GotExpectedBoxed, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader, }; -use reth_primitives_traits::{constants::MINIMUM_GAS_LIMIT, Block}; /// A consensus implementation that does nothing. pub mod noop; @@ -30,7 +29,7 @@ pub mod test_utils; /// Post execution input passed to [`FullConsensus::validate_block_post_execution`]. #[derive(Debug)] -pub struct PostExecutionInput<'a, R = Receipt> { +pub struct PostExecutionInput<'a, R> { /// Receipts of the block. pub receipts: &'a [R], /// EIP-7685 requests of the block. @@ -47,7 +46,7 @@ impl<'a, R> PostExecutionInput<'a, R> { /// [`Consensus`] implementation which knows full node primitives and is able to validation block's /// execution outcome. #[auto_impl::auto_impl(&, Arc)] -pub trait FullConsensus: AsConsensus { +pub trait FullConsensus: AsConsensus { /// Validate a block considering world state, i.e. things that can not be checked before /// execution. /// diff --git a/crates/consensus/consensus/src/noop.rs b/crates/consensus/consensus/src/noop.rs index 0b9fd81ee..40908c0e2 100644 --- a/crates/consensus/consensus/src/noop.rs +++ b/crates/consensus/consensus/src/noop.rs @@ -1,8 +1,7 @@ use crate::{Consensus, ConsensusError, FullConsensus, HeaderValidator, PostExecutionInput}; use alloc::sync::Arc; use alloy_primitives::U256; -use reth_primitives::{NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader}; -use reth_primitives_traits::Block; +use reth_primitives_traits::{Block, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader}; /// A Consensus implementation that does nothing. #[derive(Debug, Copy, Clone, Default)] diff --git a/crates/consensus/consensus/src/test_utils.rs b/crates/consensus/consensus/src/test_utils.rs index d8a94d270..044219bfd 100644 --- a/crates/consensus/consensus/src/test_utils.rs +++ b/crates/consensus/consensus/src/test_utils.rs @@ -1,8 +1,7 @@ use crate::{Consensus, ConsensusError, FullConsensus, HeaderValidator, PostExecutionInput}; use alloy_primitives::U256; use core::sync::atomic::{AtomicBool, Ordering}; -use reth_primitives::{NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader}; -use reth_primitives_traits::Block; +use reth_primitives_traits::{Block, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader}; /// Consensus engine implementation for testing #[derive(Debug)] diff --git a/crates/ethereum/consensus/src/lib.rs b/crates/ethereum/consensus/src/lib.rs index c0ca492d6..7820ba042 100644 --- a/crates/ethereum/consensus/src/lib.rs +++ b/crates/ethereum/consensus/src/lib.rs @@ -104,7 +104,7 @@ where fn validate_block_post_execution( &self, block: &RecoveredBlock, - input: PostExecutionInput<'_>, + input: PostExecutionInput<'_, N::Receipt>, ) -> Result<(), ConsensusError> { validate_block_post_execution(block, &self.chain_spec, input.receipts, input.requests) } diff --git a/crates/ethereum/node/src/node.rs b/crates/ethereum/node/src/node.rs index 6f14a5c83..e94978e21 100644 --- a/crates/ethereum/node/src/node.rs +++ b/crates/ethereum/node/src/node.rs @@ -287,7 +287,7 @@ impl ConsensusBuilder for EthereumConsensusBuilder where Node: FullNodeTypes>, { - type Consensus = Arc>; + type Consensus = Arc>; async fn build_consensus(self, ctx: &BuilderContext) -> eyre::Result { Ok(Arc::new(EthBeaconConsensus::new(ctx.chain_spec()))) diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index 3a90859c4..7b422f3ee 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -57,7 +57,7 @@ //! + 'static, //! Network: NetworkInfo + Peers + Clone + 'static, //! BlockExecutor: BlockExecutorProvider, -//! Consensus: FullConsensus + Clone + 'static, +//! Consensus: FullConsensus + Clone + 'static, //! Validator: PayloadValidator, //! { //! // configure the rpc module per transport @@ -145,7 +145,7 @@ //! EngineApi: EngineApiServer, //! EngineT: EngineTypes, //! BlockExecutor: BlockExecutorProvider, -//! Consensus: FullConsensus + Clone + 'static, +//! Consensus: FullConsensus + Clone + 'static, //! Validator: PayloadValidator, //! { //! // configure the rpc module per transport