From 3826772886b37399efde023089f02419ec1f4c9d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 8 Apr 2024 20:10:10 +0200 Subject: [PATCH] chore: fix some warnings (#7515) --- Cargo.lock | 8 --- Cargo.toml | 14 ++--- bin/reth/Cargo.toml | 3 +- crates/net/dns/Cargo.toml | 1 - crates/net/dns/src/lib.rs | 3 +- crates/net/eth-wire-types/Cargo.toml | 1 - crates/net/eth-wire-types/src/status.rs | 9 +-- crates/net/eth-wire/Cargo.toml | 1 - crates/net/eth-wire/src/builder.rs | 82 ------------------------- crates/net/eth-wire/src/errors/eth.rs | 3 +- crates/net/eth-wire/src/ethstream.rs | 3 +- crates/net/eth-wire/src/test_utils.rs | 3 +- crates/net/network-api/Cargo.toml | 3 +- crates/net/network-api/src/noop.rs | 3 +- crates/primitives/src/chain/spec.rs | 5 +- crates/primitives/src/revm/config.rs | 2 +- crates/revm/src/test_utils.rs | 6 +- crates/trie/Cargo.toml | 1 - crates/trie/src/proof.rs | 3 +- examples/custom-evm/Cargo.toml | 1 - examples/custom-evm/src/main.rs | 3 +- examples/custom-node/Cargo.toml | 1 - examples/custom-node/src/main.rs | 3 +- 23 files changed, 25 insertions(+), 137 deletions(-) delete mode 100644 crates/net/eth-wire/src/builder.rs diff --git a/Cargo.lock b/Cargo.lock index 9fd5e40d2..3b090074d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2002,7 +2002,6 @@ dependencies = [ name = "custom-evm" version = "0.0.0" dependencies = [ - "alloy-chains", "eyre", "reth", "reth-node-api", @@ -2027,7 +2026,6 @@ dependencies = [ name = "custom-node" version = "0.0.0" dependencies = [ - "alloy-chains", "eyre", "reth", "reth-basic-payload-builder", @@ -6050,7 +6048,6 @@ dependencies = [ name = "reth" version = "0.2.0-beta.5" dependencies = [ - "alloy-chains", "alloy-rlp", "aquamarine", "assert_matches", @@ -6368,7 +6365,6 @@ dependencies = [ name = "reth-dns-discovery" version = "0.2.0-beta.5" dependencies = [ - "alloy-chains", "alloy-rlp", "data-encoding", "enr", @@ -6451,7 +6447,6 @@ dependencies = [ name = "reth-eth-wire" version = "0.2.0-beta.5" dependencies = [ - "alloy-chains", "alloy-rlp", "arbitrary", "async-stream", @@ -6486,7 +6481,6 @@ dependencies = [ name = "reth-eth-wire-types" version = "0.2.0-beta.5" dependencies = [ - "alloy-chains", "alloy-rlp", "arbitrary", "async-stream", @@ -6751,7 +6745,6 @@ dependencies = [ name = "reth-network-api" version = "0.2.0-beta.5" dependencies = [ - "alloy-chains", "reth-discv4", "reth-eth-wire", "reth-primitives", @@ -7451,7 +7444,6 @@ dependencies = [ name = "reth-trie" version = "0.2.0-beta.5" dependencies = [ - "alloy-chains", "alloy-rlp", "auto_impl", "criterion", diff --git a/Cargo.toml b/Cargo.toml index c85456b2d..45dcd59ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -254,22 +254,17 @@ reth-trie = { path = "crates/trie" } reth-trie-parallel = { path = "crates/trie-parallel" } # revm -revm = { version = "8.0.0", features = [ - "std", - "secp256k1", -], default-features = false } -revm-primitives = { version = "3.1.0", features = [ - "std", -], default-features = false } +revm = { version = "8.0.0", features = ["std", "secp256k1"], default-features = false } +revm-primitives = { version = "3.1.0", features = ["std"], default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "5baa6b3" } # eth -alloy-chains = { version = "0.1", feature = ["serde", "rlp", "arbitrary"] } +alloy-chains = "0.1.15" alloy-primitives = "0.7.0" alloy-dyn-abi = "0.7.0" alloy-sol-types = "0.7.0" alloy-rlp = "0.3.4" -alloy-trie = "0.3" +alloy-trie = "0.3.1" alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "6aab216" } alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "6aab216" } alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "6aab216" } @@ -282,7 +277,6 @@ alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "6aab21 alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "6aab216" } alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "6aab216" } - # misc aquamarine = "0.5" bytes = "1.5" diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index ab23e653d..2f155e2af 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -54,7 +54,6 @@ reth-node-builder.workspace = true # crypto alloy-rlp.workspace = true -alloy-chains.workspace = true # tracing tracing.workspace = true @@ -127,7 +126,7 @@ optimism = [ "reth-auto-seal-consensus/optimism", "reth-blockchain-tree/optimism", "dep:reth-node-optimism", - "reth-node-core/optimism" + "reth-node-core/optimism", ] # no-op feature flag for switching between the `optimism` and default functionality in CI matrices diff --git a/crates/net/dns/Cargo.toml b/crates/net/dns/Cargo.toml index 0a9af063c..003a6cad7 100644 --- a/crates/net/dns/Cargo.toml +++ b/crates/net/dns/Cargo.toml @@ -41,7 +41,6 @@ serde_with = { version = "3.3.0", optional = true } [dev-dependencies] tokio = { workspace = true, features = ["sync", "rt", "rt-multi-thread"] } reth-tracing.workspace = true -alloy-chains.workspace = true [features] default = ["serde"] diff --git a/crates/net/dns/src/lib.rs b/crates/net/dns/src/lib.rs index d5ca9da32..6db9c9ee2 100644 --- a/crates/net/dns/src/lib.rs +++ b/crates/net/dns/src/lib.rs @@ -412,10 +412,9 @@ fn convert_enr_node_record(enr: &Enr) -> Option mod tests { use super::*; use crate::tree::TreeRootEntry; - use alloy_chains::Chain; use alloy_rlp::Encodable; use enr::EnrKey; - use reth_primitives::{Hardfork, MAINNET}; + use reth_primitives::{Chain, Hardfork, MAINNET}; use secp256k1::rand::thread_rng; use std::{future::poll_fn, net::Ipv4Addr}; diff --git a/crates/net/eth-wire-types/Cargo.toml b/crates/net/eth-wire-types/Cargo.toml index 2d54eb187..54f3763a2 100644 --- a/crates/net/eth-wire-types/Cargo.toml +++ b/crates/net/eth-wire-types/Cargo.toml @@ -17,7 +17,6 @@ workspace = true reth-codecs.workspace = true reth-primitives.workspace = true alloy-rlp = { workspace = true, features = ["derive"] } -alloy-chains = { workspace = true, features = ["serde", "rlp", "arbitrary"] } bytes.workspace = true derive_more.workspace = true diff --git a/crates/net/eth-wire-types/src/status.rs b/crates/net/eth-wire-types/src/status.rs index 0ba17ef68..6dd3f7eb4 100644 --- a/crates/net/eth-wire-types/src/status.rs +++ b/crates/net/eth-wire-types/src/status.rs @@ -1,8 +1,9 @@ use crate::EthVersion; -use alloy_chains::{Chain, NamedChain}; use alloy_rlp::{RlpDecodable, RlpEncodable}; use reth_codecs::derive_arbitrary; -use reth_primitives::{hex, ChainSpec, ForkId, Genesis, Hardfork, Head, B256, MAINNET, U256}; +use reth_primitives::{ + hex, Chain, ChainSpec, ForkId, Genesis, Hardfork, Head, NamedChain, B256, MAINNET, U256, +}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use std::fmt::{Debug, Display}; @@ -227,11 +228,11 @@ impl StatusBuilder { #[cfg(test)] mod tests { use crate::{EthVersion, Status}; - use alloy_chains::{Chain, NamedChain}; use alloy_rlp::{Decodable, Encodable}; use rand::Rng; use reth_primitives::{ - hex, ChainSpec, ForkCondition, ForkHash, ForkId, Genesis, Hardfork, Head, B256, U256, + hex, Chain, ChainSpec, ForkCondition, ForkHash, ForkId, Genesis, Hardfork, Head, + NamedChain, B256, U256, }; use std::str::FromStr; diff --git a/crates/net/eth-wire/Cargo.toml b/crates/net/eth-wire/Cargo.toml index fc55a684c..f5b157e73 100644 --- a/crates/net/eth-wire/Cargo.toml +++ b/crates/net/eth-wire/Cargo.toml @@ -17,7 +17,6 @@ reth-codecs.workspace = true reth-primitives.workspace = true reth-ecies.workspace = true alloy-rlp = { workspace = true, features = ["derive"] } -alloy-chains = { workspace = true, features = ["serde", "rlp", "arbitrary"] } reth-discv4.workspace = true reth-eth-wire-types.workspace = true diff --git a/crates/net/eth-wire/src/builder.rs b/crates/net/eth-wire/src/builder.rs deleted file mode 100644 index dbe48a441..000000000 --- a/crates/net/eth-wire/src/builder.rs +++ /dev/null @@ -1,82 +0,0 @@ -//! Builder structs for messages. - -use crate::Status; -use alloy_chains::Chain; -use reth_primitives::{ForkId, B256, U256}; - -/// Builder for [`Status`] messages. -/// -/// # Example -/// ``` -/// use reth_eth_wire::{types::Status, EthVersion}; -/// use reth_primitives::{Chain, Hardfork, B256, MAINNET, MAINNET_GENESIS_HASH, U256}; -/// -/// // this is just an example status message! -/// let status = Status::builder() -/// .version(EthVersion::Eth66.into()) -/// .chain(Chain::mainnet()) -/// .total_difficulty(U256::from(100)) -/// .blockhash(B256::from(MAINNET_GENESIS_HASH)) -/// .genesis(B256::from(MAINNET_GENESIS_HASH)) -/// .forkid(MAINNET.hardfork_fork_id(Hardfork::Paris).unwrap()) -/// .build(); -/// -/// assert_eq!( -/// status, -/// Status { -/// version: EthVersion::Eth66.into(), -/// chain: Chain::mainnet(), -/// total_difficulty: U256::from(100), -/// blockhash: B256::from(MAINNET_GENESIS_HASH), -/// genesis: B256::from(MAINNET_GENESIS_HASH), -/// forkid: MAINNET.hardfork_fork_id(Hardfork::Paris).unwrap(), -/// } -/// ); -/// ``` -#[derive(Debug, Default)] -pub struct StatusBuilder { - status: Status, -} - -impl StatusBuilder { - /// Consumes the type and creates the actual [`Status`] message. - pub fn build(self) -> Status { - self.status - } - - /// Sets the protocol version. - pub fn version(mut self, version: u8) -> Self { - self.status.version = version; - self - } - - /// Sets the chain id. - pub fn chain(mut self, chain: Chain) -> Self { - self.status.chain = chain; - self - } - - /// Sets the total difficulty. - pub fn total_difficulty(mut self, total_difficulty: U256) -> Self { - self.status.total_difficulty = total_difficulty; - self - } - - /// Sets the block hash. - pub fn blockhash(mut self, blockhash: B256) -> Self { - self.status.blockhash = blockhash; - self - } - - /// Sets the genesis hash. - pub fn genesis(mut self, genesis: B256) -> Self { - self.status.genesis = genesis; - self - } - - /// Sets the fork id. - pub fn forkid(mut self, forkid: ForkId) -> Self { - self.status.forkid = forkid; - self - } -} diff --git a/crates/net/eth-wire/src/errors/eth.rs b/crates/net/eth-wire/src/errors/eth.rs index 3a3d46eb0..04c23a253 100644 --- a/crates/net/eth-wire/src/errors/eth.rs +++ b/crates/net/eth-wire/src/errors/eth.rs @@ -6,8 +6,7 @@ use crate::{ version::ParseVersionError, DisconnectReason, }; -use alloy_chains::Chain; -use reth_primitives::{GotExpected, GotExpectedBoxed, ValidationError, B256}; +use reth_primitives::{Chain, GotExpected, GotExpectedBoxed, ValidationError, B256}; use std::io; /// Errors when sending/receiving messages diff --git a/crates/net/eth-wire/src/ethstream.rs b/crates/net/eth-wire/src/ethstream.rs index df46b3db8..cbd1e3150 100644 --- a/crates/net/eth-wire/src/ethstream.rs +++ b/crates/net/eth-wire/src/ethstream.rs @@ -351,11 +351,10 @@ mod tests { p2pstream::{ProtocolVersion, UnauthedP2PStream}, EthMessage, EthStream, EthVersion, HelloMessageWithProtocols, PassthroughCodec, Status, }; - use alloy_chains::NamedChain; use futures::{SinkExt, StreamExt}; use reth_discv4::DEFAULT_DISCOVERY_PORT; use reth_ecies::stream::ECIESStream; - use reth_primitives::{pk2id, ForkFilter, Head, B256, U256}; + use reth_primitives::{pk2id, ForkFilter, Head, NamedChain, B256, U256}; use secp256k1::{SecretKey, SECP256K1}; use std::time::Duration; use tokio::net::{TcpListener, TcpStream}; diff --git a/crates/net/eth-wire/src/test_utils.rs b/crates/net/eth-wire/src/test_utils.rs index 27ed78784..1708e1ffa 100644 --- a/crates/net/eth-wire/src/test_utils.rs +++ b/crates/net/eth-wire/src/test_utils.rs @@ -3,9 +3,8 @@ use crate::{ EthVersion, HelloMessageWithProtocols, P2PStream, ProtocolVersion, Status, UnauthedP2PStream, }; -use alloy_chains::Chain; use reth_discv4::DEFAULT_DISCOVERY_PORT; -use reth_primitives::{pk2id, ForkFilter, Head, B256, U256}; +use reth_primitives::{pk2id, Chain, ForkFilter, Head, B256, U256}; use secp256k1::{SecretKey, SECP256K1}; use std::net::SocketAddr; use tokio::net::TcpStream; diff --git a/crates/net/network-api/Cargo.toml b/crates/net/network-api/Cargo.toml index 00a963948..002dd6c2f 100644 --- a/crates/net/network-api/Cargo.toml +++ b/crates/net/network-api/Cargo.toml @@ -17,7 +17,6 @@ reth-primitives.workspace = true reth-eth-wire.workspace = true reth-rpc-types.workspace = true reth-discv4.workspace = true -alloy-chains.workspace = true # io serde = { workspace = true, features = ["derive"], optional = true } @@ -27,4 +26,4 @@ tokio = { workspace = true, features = ["sync"] } [features] default = ["serde"] -serde = ["dep:serde"] \ No newline at end of file +serde = ["dep:serde"] diff --git a/crates/net/network-api/src/noop.rs b/crates/net/network-api/src/noop.rs index 3f731fc2b..3eb6314e7 100644 --- a/crates/net/network-api/src/noop.rs +++ b/crates/net/network-api/src/noop.rs @@ -7,10 +7,9 @@ use crate::{ NetworkError, NetworkInfo, PeerInfo, PeerKind, Peers, PeersInfo, Reputation, ReputationChangeKind, }; -use alloy_chains::Chain; use reth_discv4::DEFAULT_DISCOVERY_PORT; use reth_eth_wire::{DisconnectReason, ProtocolVersion}; -use reth_primitives::{NodeRecord, PeerId}; +use reth_primitives::{Chain, NodeRecord, PeerId}; use reth_rpc_types::{EthProtocolInfo, NetworkStatus}; use std::net::{IpAddr, SocketAddr}; diff --git a/crates/primitives/src/chain/spec.rs b/crates/primitives/src/chain/spec.rs index cb7ef8522..7319a79f4 100644 --- a/crates/primitives/src/chain/spec.rs +++ b/crates/primitives/src/chain/spec.rs @@ -7,10 +7,9 @@ use crate::{ net::{goerli_nodes, mainnet_nodes, sepolia_nodes}, proofs::state_root_ref_unhashed, revm_primitives::{address, b256}, - Address, BlockNumber, ForkFilter, ForkFilterKey, ForkHash, ForkId, Genesis, Hardfork, Head, - Header, NodeRecord, SealedHeader, B256, EMPTY_OMMER_ROOT_HASH, U256, + Address, BlockNumber, Chain, ForkFilter, ForkFilterKey, ForkHash, ForkId, Genesis, Hardfork, + Head, Header, NamedChain, NodeRecord, SealedHeader, B256, EMPTY_OMMER_ROOT_HASH, U256, }; -use alloy_chains::{Chain, NamedChain}; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use std::{ diff --git a/crates/primitives/src/revm/config.rs b/crates/primitives/src/revm/config.rs index 672910e56..31cb4ab94 100644 --- a/crates/primitives/src/revm/config.rs +++ b/crates/primitives/src/revm/config.rs @@ -142,7 +142,7 @@ mod tests { { #[inline(always)] fn op_cs(f: impl FnOnce(ChainSpecBuilder) -> ChainSpecBuilder) -> ChainSpec { - let cs = ChainSpecBuilder::mainnet().chain(alloy_chains::Chain::from_id(10)); + let cs = ChainSpecBuilder::mainnet().chain(crate::Chain::from_id(10)); f(cs).build() } diff --git a/crates/revm/src/test_utils.rs b/crates/revm/src/test_utils.rs index 6534fcb78..535d7919f 100644 --- a/crates/revm/src/test_utils.rs +++ b/crates/revm/src/test_utils.rs @@ -11,17 +11,17 @@ use reth_provider::{AccountReader, BlockHashReader, StateProvider, StateRootProv use reth_trie::updates::TrieUpdates; use revm::{ db::BundleState, - inspector_handle_register, primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv}, - GetInspector, }; use std::collections::HashMap; + #[cfg(feature = "optimism")] use { reth_primitives::revm::env::fill_op_tx_env, revm::{ + inspector_handle_register, primitives::{HandlerCfg, SpecId}, - Database, Evm, EvmBuilder, + Database, Evm, EvmBuilder, GetInspector, }, }; diff --git a/crates/trie/Cargo.toml b/crates/trie/Cargo.toml index 55f2672e9..faf874523 100644 --- a/crates/trie/Cargo.toml +++ b/crates/trie/Cargo.toml @@ -20,7 +20,6 @@ revm.workspace = true # alloy alloy-rlp.workspace = true -alloy-chains.workspace = true # tracing tracing.workspace = true diff --git a/crates/trie/src/proof.rs b/crates/trie/src/proof.rs index e6f758ce4..1af1650e5 100644 --- a/crates/trie/src/proof.rs +++ b/crates/trie/src/proof.rs @@ -165,11 +165,10 @@ where mod tests { use super::*; use crate::StateRoot; - use alloy_chains::Chain; use once_cell::sync::Lazy; use reth_db::database::Database; use reth_interfaces::RethResult; - use reth_primitives::{Account, Bytes, ChainSpec, StorageEntry, HOLESKY, MAINNET, U256}; + use reth_primitives::{Account, Bytes, Chain, ChainSpec, StorageEntry, HOLESKY, MAINNET, U256}; use reth_provider::{test_utils::create_test_provider_factory, HashingWriter, ProviderFactory}; use std::{str::FromStr, sync::Arc}; diff --git a/examples/custom-evm/Cargo.toml b/examples/custom-evm/Cargo.toml index 2748e1c88..d1b5221ed 100644 --- a/examples/custom-evm/Cargo.toml +++ b/examples/custom-evm/Cargo.toml @@ -13,6 +13,5 @@ reth-primitives.workspace = true reth-node-ethereum.workspace = true reth-tracing.workspace = true -alloy-chains.workspace = true eyre.workspace = true tokio.workspace = true diff --git a/examples/custom-evm/src/main.rs b/examples/custom-evm/src/main.rs index bd1952f87..6c80c9a74 100644 --- a/examples/custom-evm/src/main.rs +++ b/examples/custom-evm/src/main.rs @@ -2,7 +2,6 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] -use alloy_chains::Chain; use reth::{ builder::{node::NodeTypes, NodeBuilder}, primitives::{ @@ -21,7 +20,7 @@ use reth::{ use reth_node_api::{ConfigureEvm, ConfigureEvmEnv}; use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig}; use reth_node_ethereum::{EthEngineTypes, EthEvmConfig, EthereumNode}; -use reth_primitives::{ChainSpec, Genesis, Header, Transaction}; +use reth_primitives::{Chain, ChainSpec, Genesis, Header, Transaction}; use reth_tracing::{RethTracer, Tracer}; use std::sync::Arc; diff --git a/examples/custom-node/Cargo.toml b/examples/custom-node/Cargo.toml index 53efdc0a8..9d41edafd 100644 --- a/examples/custom-node/Cargo.toml +++ b/examples/custom-node/Cargo.toml @@ -17,7 +17,6 @@ reth-ethereum-payload-builder.workspace = true reth-node-ethereum.workspace = true reth-tracing.workspace = true -alloy-chains.workspace = true eyre.workspace = true tokio.workspace = true thiserror.workspace = true diff --git a/examples/custom-node/src/main.rs b/examples/custom-node/src/main.rs index a0a37ec66..a2ade9cc1 100644 --- a/examples/custom-node/src/main.rs +++ b/examples/custom-node/src/main.rs @@ -17,7 +17,6 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] -use alloy_chains::Chain; use reth::{ builder::{ components::{ComponentsBuilder, PayloadServiceBuilder}, @@ -46,7 +45,7 @@ use reth_payload_builder::{ error::PayloadBuilderError, EthBuiltPayload, EthPayloadBuilderAttributes, PayloadBuilderHandle, PayloadBuilderService, }; -use reth_primitives::{Address, ChainSpec, Genesis, Header, Withdrawals, B256}; +use reth_primitives::{Address, Chain, ChainSpec, Genesis, Header, Withdrawals, B256}; use reth_rpc_types::{ engine::{ ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3,