From a8220791aee8fb9131a0ffdcace6e304b1bd5cc4 Mon Sep 17 00:00:00 2001 From: Abhishek kochar Date: Fri, 20 Sep 2024 11:50:42 +0800 Subject: [PATCH] chore(engine): replace reth_primitives with alloy_primitives (#11064) Signed-off-by: Abhishekkochar --- Cargo.lock | 6 ++++++ crates/engine/invalid-block-hooks/Cargo.toml | 1 + crates/engine/invalid-block-hooks/src/witness.rs | 5 ++--- crates/engine/local/Cargo.toml | 3 +++ crates/engine/local/src/miner.rs | 2 +- crates/engine/local/src/service.rs | 4 ++-- crates/engine/primitives/Cargo.toml | 3 +++ crates/engine/primitives/src/invalid_block_hook.rs | 3 ++- crates/engine/tree/Cargo.toml | 4 ++++ crates/engine/tree/src/backfill.rs | 3 ++- crates/engine/tree/src/download.rs | 3 ++- crates/engine/tree/src/engine.rs | 3 ++- crates/engine/tree/src/persistence.rs | 4 ++-- crates/engine/tree/src/test_utils.rs | 3 ++- crates/engine/tree/src/tree/invalid_block_hook.rs | 3 ++- crates/engine/tree/src/tree/mod.rs | 7 ++++--- crates/engine/util/Cargo.toml | 3 +++ crates/engine/util/src/reorg.rs | 3 ++- 18 files changed, 45 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b2e8aabb..645799a85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6951,6 +6951,7 @@ dependencies = [ name = "reth-engine-local" version = "1.0.7" dependencies = [ + "alloy-primitives", "eyre", "futures-util", "reth-beacon-consensus", @@ -6980,6 +6981,7 @@ dependencies = [ name = "reth-engine-primitives" version = "1.0.7" dependencies = [ + "alloy-primitives", "reth-chainspec", "reth-execution-types", "reth-payload-primitives", @@ -7020,6 +7022,8 @@ dependencies = [ name = "reth-engine-tree" version = "1.0.7" dependencies = [ + "alloy-eips", + "alloy-primitives", "alloy-rlp", "assert_matches", "futures", @@ -7065,6 +7069,7 @@ dependencies = [ name = "reth-engine-util" version = "1.0.7" dependencies = [ + "alloy-primitives", "eyre", "futures", "itertools 0.13.0", @@ -7424,6 +7429,7 @@ dependencies = [ name = "reth-invalid-block-hooks" version = "1.0.7" dependencies = [ + "alloy-primitives", "alloy-rlp", "alloy-rpc-types-debug", "eyre", diff --git a/crates/engine/invalid-block-hooks/Cargo.toml b/crates/engine/invalid-block-hooks/Cargo.toml index b0eaefce0..2e45c7bc3 100644 --- a/crates/engine/invalid-block-hooks/Cargo.toml +++ b/crates/engine/invalid-block-hooks/Cargo.toml @@ -23,6 +23,7 @@ reth-tracing.workspace = true reth-trie = { workspace = true, features = ["serde"] } # alloy +alloy-primitives.workspace = true alloy-rlp.workspace = true alloy-rpc-types-debug.workspace = true diff --git a/crates/engine/invalid-block-hooks/src/witness.rs b/crates/engine/invalid-block-hooks/src/witness.rs index 366965d6f..ebf98cf4b 100644 --- a/crates/engine/invalid-block-hooks/src/witness.rs +++ b/crates/engine/invalid-block-hooks/src/witness.rs @@ -1,5 +1,6 @@ use std::{collections::HashMap, fmt::Debug, fs::File, io::Write, path::PathBuf}; +use alloy_primitives::{keccak256, B256, U256}; use alloy_rpc_types_debug::ExecutionWitness; use eyre::OptionExt; use pretty_assertions::Comparison; @@ -9,9 +10,7 @@ use reth_evm::{ system_calls::{apply_beacon_root_contract_call, apply_blockhashes_contract_call}, ConfigureEvm, }; -use reth_primitives::{ - keccak256, Header, Receipt, SealedBlockWithSenders, SealedHeader, B256, U256, -}; +use reth_primitives::{Header, Receipt, SealedBlockWithSenders, SealedHeader}; use reth_provider::{BlockExecutionOutput, ChainSpecProvider, StateProviderFactory}; use reth_revm::{ database::StateProviderDatabase, diff --git a/crates/engine/local/Cargo.toml b/crates/engine/local/Cargo.toml index ed49b0fa3..c43a97abd 100644 --- a/crates/engine/local/Cargo.toml +++ b/crates/engine/local/Cargo.toml @@ -21,6 +21,9 @@ reth-prune.workspace = true reth-transaction-pool.workspace = true reth-stages-api.workspace = true +# alloy +alloy-primitives.workspace = true + # async tokio.workspace = true tokio-stream.workspace = true diff --git a/crates/engine/local/src/miner.rs b/crates/engine/local/src/miner.rs index 58e74224c..de3d8cb8d 100644 --- a/crates/engine/local/src/miner.rs +++ b/crates/engine/local/src/miner.rs @@ -1,7 +1,7 @@ //! Contains the implementation of the mining mode for the local engine. +use alloy_primitives::TxHash; use futures_util::{stream::Fuse, StreamExt}; -use reth_primitives::TxHash; use reth_transaction_pool::TransactionPool; use std::{ future::Future, diff --git a/crates/engine/local/src/service.rs b/crates/engine/local/src/service.rs index 3876f1c38..765737bba 100644 --- a/crates/engine/local/src/service.rs +++ b/crates/engine/local/src/service.rs @@ -7,13 +7,13 @@ //! building at a fixed interval. use crate::miner::MiningMode; +use alloy_primitives::B256; use reth_beacon_consensus::EngineNodeTypes; use reth_engine_tree::persistence::PersistenceHandle; use reth_payload_builder::PayloadBuilderHandle; use reth_payload_primitives::{ BuiltPayload, PayloadAttributesBuilder, PayloadBuilderAttributes, PayloadTypes, }; -use reth_primitives::B256; use reth_provider::ProviderFactory; use reth_prune::PrunerWithFactory; use reth_stages_api::MetricEventsSender; @@ -157,6 +157,7 @@ where #[cfg(test)] mod tests { use super::*; + use alloy_primitives::B256; use reth_chainspec::MAINNET; use reth_config::PruneConfig; use reth_db::test_utils::{create_test_rw_db, create_test_static_files_dir}; @@ -164,7 +165,6 @@ mod tests { use reth_exex_test_utils::TestNode; use reth_node_types::NodeTypesWithDBAdapter; use reth_payload_builder::test_utils::spawn_test_payload_service; - use reth_primitives::B256; use reth_provider::{providers::StaticFileProvider, BlockReader, ProviderFactory}; use reth_prune::PrunerBuilder; use reth_transaction_pool::{ diff --git a/crates/engine/primitives/Cargo.toml b/crates/engine/primitives/Cargo.toml index 437aac6a8..43bde32eb 100644 --- a/crates/engine/primitives/Cargo.toml +++ b/crates/engine/primitives/Cargo.toml @@ -18,5 +18,8 @@ reth-payload-primitives.workspace = true reth-primitives.workspace = true reth-trie.workspace = true +# alloy +alloy-primitives.workspace = true + # misc serde.workspace = true diff --git a/crates/engine/primitives/src/invalid_block_hook.rs b/crates/engine/primitives/src/invalid_block_hook.rs index 9e1737dda..13c606511 100644 --- a/crates/engine/primitives/src/invalid_block_hook.rs +++ b/crates/engine/primitives/src/invalid_block_hook.rs @@ -1,5 +1,6 @@ +use alloy_primitives::B256; use reth_execution_types::BlockExecutionOutput; -use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader, B256}; +use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader}; use reth_trie::updates::TrieUpdates; /// An invalid block hook. diff --git a/crates/engine/tree/Cargo.toml b/crates/engine/tree/Cargo.toml index e6e9193d0..4697e7fb8 100644 --- a/crates/engine/tree/Cargo.toml +++ b/crates/engine/tree/Cargo.toml @@ -35,6 +35,10 @@ reth-tasks.workspace = true reth-trie.workspace = true reth-trie-parallel.workspace = true +# alloy +alloy-primitives.workspace = true +alloy-eips.workspace = true + # common futures.workspace = true tokio = { workspace = true, features = ["macros", "sync"] } diff --git a/crates/engine/tree/src/backfill.rs b/crates/engine/tree/src/backfill.rs index 4ae244ed2..0877002a4 100644 --- a/crates/engine/tree/src/backfill.rs +++ b/crates/engine/tree/src/backfill.rs @@ -230,11 +230,12 @@ impl PipelineState { mod tests { use super::*; use crate::test_utils::{insert_headers_into_client, TestPipelineBuilder}; + use alloy_primitives::{BlockNumber, B256}; use assert_matches::assert_matches; use futures::poll; use reth_chainspec::{ChainSpecBuilder, MAINNET}; use reth_network_p2p::test_utils::TestFullBlockClient; - use reth_primitives::{BlockNumber, Header, B256}; + use reth_primitives::Header; use reth_provider::test_utils::MockNodeTypesWithDB; use reth_stages::ExecOutput; use reth_stages_api::StageCheckpoint; diff --git a/crates/engine/tree/src/download.rs b/crates/engine/tree/src/download.rs index 04c94f144..f1538c5c9 100644 --- a/crates/engine/tree/src/download.rs +++ b/crates/engine/tree/src/download.rs @@ -1,13 +1,14 @@ //! Handler that can download blocks on demand (e.g. from the network). use crate::{engine::DownloadRequest, metrics::BlockDownloaderMetrics}; +use alloy_primitives::B256; use futures::FutureExt; use reth_consensus::Consensus; use reth_network_p2p::{ full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient}, BlockClient, }; -use reth_primitives::{SealedBlock, SealedBlockWithSenders, B256}; +use reth_primitives::{SealedBlock, SealedBlockWithSenders}; use std::{ cmp::{Ordering, Reverse}, collections::{binary_heap::PeekMut, BinaryHeap, HashSet, VecDeque}, diff --git a/crates/engine/tree/src/engine.rs b/crates/engine/tree/src/engine.rs index d2542e122..8172a4469 100644 --- a/crates/engine/tree/src/engine.rs +++ b/crates/engine/tree/src/engine.rs @@ -5,11 +5,12 @@ use crate::{ chain::{ChainHandler, FromOrchestrator, HandlerEvent}, download::{BlockDownloader, DownloadAction, DownloadOutcome}, }; +use alloy_primitives::B256; use futures::{Stream, StreamExt}; use reth_beacon_consensus::{BeaconConsensusEngineEvent, BeaconEngineMessage}; use reth_chain_state::ExecutedBlock; use reth_engine_primitives::EngineTypes; -use reth_primitives::{SealedBlockWithSenders, B256}; +use reth_primitives::SealedBlockWithSenders; use std::{ collections::HashSet, fmt::Display, diff --git a/crates/engine/tree/src/persistence.rs b/crates/engine/tree/src/persistence.rs index 74d2c297c..a748ece8a 100644 --- a/crates/engine/tree/src/persistence.rs +++ b/crates/engine/tree/src/persistence.rs @@ -1,7 +1,7 @@ use crate::metrics::PersistenceMetrics; +use alloy_eips::BlockNumHash; use reth_chain_state::ExecutedBlock; use reth_errors::ProviderError; -use reth_primitives::BlockNumHash; use reth_provider::{ providers::ProviderNodeTypes, writer::UnifiedStorageWriter, BlockHashReader, DatabaseProviderFactory, ProviderFactory, StaticFileProviderFactory, @@ -264,9 +264,9 @@ impl PersistenceHandle { #[cfg(test)] mod tests { use super::*; + use alloy_primitives::B256; use reth_chain_state::test_utils::TestBlockBuilder; use reth_exex_types::FinishedExExHeight; - use reth_primitives::B256; use reth_provider::test_utils::create_test_provider_factory; use reth_prune::Pruner; use tokio::sync::mpsc::unbounded_channel; diff --git a/crates/engine/tree/src/test_utils.rs b/crates/engine/tree/src/test_utils.rs index d76fabf43..0b999cef6 100644 --- a/crates/engine/tree/src/test_utils.rs +++ b/crates/engine/tree/src/test_utils.rs @@ -1,6 +1,7 @@ +use alloy_primitives::B256; use reth_chainspec::ChainSpec; use reth_network_p2p::test_utils::TestFullBlockClient; -use reth_primitives::{BlockBody, SealedHeader, B256}; +use reth_primitives::{BlockBody, SealedHeader}; use reth_provider::{ test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB}, ExecutionOutcome, diff --git a/crates/engine/tree/src/tree/invalid_block_hook.rs b/crates/engine/tree/src/tree/invalid_block_hook.rs index 7e401b53c..98244ed13 100644 --- a/crates/engine/tree/src/tree/invalid_block_hook.rs +++ b/crates/engine/tree/src/tree/invalid_block_hook.rs @@ -1,5 +1,6 @@ +use alloy_primitives::B256; use reth_engine_primitives::InvalidBlockHook; -use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader, B256}; +use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader}; use reth_provider::BlockExecutionOutput; use reth_trie::updates::TrieUpdates; diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 77e2cbd96..05600a898 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -4,6 +4,8 @@ use crate::{ engine::{DownloadRequest, EngineApiEvent, FromEngine}, persistence::PersistenceHandle, }; +use alloy_eips::BlockNumHash; +use alloy_primitives::{BlockNumber, B256, U256}; use reth_beacon_consensus::{ BeaconConsensusEngineEvent, BeaconEngineMessage, ForkchoiceStateTracker, InvalidHeaderCache, OnForkChoiceUpdated, MIN_BLOCKS_FOR_PIPELINE_RUN, @@ -24,8 +26,7 @@ use reth_payload_builder::PayloadBuilderHandle; use reth_payload_primitives::{PayloadAttributes, PayloadBuilderAttributes}; use reth_payload_validator::ExecutionPayloadValidator; use reth_primitives::{ - Block, BlockNumHash, BlockNumber, GotExpected, Header, SealedBlock, SealedBlockWithSenders, - SealedHeader, B256, U256, + Block, GotExpected, Header, SealedBlock, SealedBlockWithSenders, SealedHeader, }; use reth_provider::{ providers::ConsistentDbView, BlockReader, DatabaseProviderFactory, ExecutionOutcome, @@ -2583,13 +2584,13 @@ impl PersistenceState { mod tests { use super::*; use crate::persistence::PersistenceAction; + use alloy_primitives::Bytes; use alloy_rlp::Decodable; use reth_beacon_consensus::{EthBeaconConsensus, ForkchoiceStatus}; use reth_chain_state::{test_utils::TestBlockBuilder, BlockState}; use reth_chainspec::{ChainSpec, HOLESKY, MAINNET}; use reth_ethereum_engine_primitives::EthEngineTypes; use reth_evm::test_utils::MockExecutorProvider; - use reth_primitives::Bytes; use reth_provider::test_utils::MockEthProvider; use reth_rpc_types_compat::engine::{block_to_payload_v1, payload::block_to_payload_v3}; use reth_trie::updates::TrieUpdates; diff --git a/crates/engine/util/Cargo.toml b/crates/engine/util/Cargo.toml index 383b7290e..3d1a1516a 100644 --- a/crates/engine/util/Cargo.toml +++ b/crates/engine/util/Cargo.toml @@ -27,6 +27,9 @@ reth-ethereum-forks.workspace = true revm-primitives.workspace = true reth-trie.workspace = true +# alloy +alloy-primitives.workspace = true + # async tokio = { workspace = true, default-features = false } tokio-util.workspace = true diff --git a/crates/engine/util/src/reorg.rs b/crates/engine/util/src/reorg.rs index bf6bb6c3a..ff699ffaa 100644 --- a/crates/engine/util/src/reorg.rs +++ b/crates/engine/util/src/reorg.rs @@ -1,5 +1,6 @@ //! Stream wrapper that simulates reorgs. +use alloy_primitives::U256; use futures::{stream::FuturesUnordered, Stream, StreamExt, TryFutureExt}; use itertools::Either; use reth_beacon_consensus::{BeaconEngineMessage, BeaconOnNewPayloadError, OnForkChoiceUpdated}; @@ -9,7 +10,7 @@ use reth_ethereum_forks::EthereumHardforks; use reth_evm::{system_calls::apply_beacon_root_contract_call, ConfigureEvm}; use reth_payload_validator::ExecutionPayloadValidator; use reth_primitives::{ - eip4844::calculate_excess_blob_gas, proofs, Block, Header, Receipt, Receipts, U256, + eip4844::calculate_excess_blob_gas, proofs, Block, Header, Receipt, Receipts, }; use reth_provider::{BlockReader, ExecutionOutcome, ProviderError, StateProviderFactory}; use reth_revm::{