diff --git a/Cargo.lock b/Cargo.lock index a6b4b8985f98..e3d1c0bfc4c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -503,9 +503,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" dependencies = [ "serde", ] @@ -4166,7 +4166,6 @@ dependencies = [ name = "reth-discv4" version = "0.1.0" dependencies = [ - "bytes", "discv5", "enr 0.7.0", "generic-array 0.14.6", @@ -4191,7 +4190,6 @@ name = "reth-dns-discovery" version = "0.1.0" dependencies = [ "async-trait", - "bytes", "data-encoding", "enr 0.7.0", "linked_hash_set", @@ -4216,7 +4214,6 @@ name = "reth-downloaders" version = "0.1.0" dependencies = [ "assert_matches", - "bytes", "futures", "futures-util", "itertools 0.10.5", @@ -4245,7 +4242,6 @@ dependencies = [ "aes 0.8.2", "block-padding 0.3.2", "byteorder", - "bytes", "cipher 0.4.3", "ctr 0.9.2", "digest 0.10.6", @@ -4278,7 +4274,6 @@ dependencies = [ "bytes", "ethers-core", "futures", - "hex", "hex-literal", "metrics", "pin-project", @@ -4332,7 +4327,6 @@ dependencies = [ "arbitrary", "async-trait", "auto_impl 1.0.1", - "bytes", "futures", "hex-literal", "modular-bitfield", @@ -4451,7 +4445,6 @@ dependencies = [ "aquamarine", "async-trait", "auto_impl 1.0.1", - "bytes", "enr 0.7.0", "ethers-core", "ethers-middleware", @@ -4672,7 +4665,6 @@ name = "reth-rpc-engine-api" version = "0.1.0" dependencies = [ "assert_matches", - "bytes", "futures", "reth-executor", "reth-interfaces", @@ -4690,7 +4682,6 @@ dependencies = [ name = "reth-rpc-types" version = "0.1.0" dependencies = [ - "bytes", "jsonrpsee-types", "lru 0.9.0", "reth-network-api", diff --git a/crates/interfaces/Cargo.toml b/crates/interfaces/Cargo.toml index 6ca15c44e093..aeb1b909c5fd 100644 --- a/crates/interfaces/Cargo.toml +++ b/crates/interfaces/Cargo.toml @@ -16,7 +16,6 @@ async-trait = "0.1.57" thiserror = "1.0.37" auto_impl = "1.0" tokio = { version = "1.21.2", features = ["sync"] } -bytes = "1.2" # TODO(onbjerg): We only need this for [BlockBody] reth-eth-wire = { path = "../net/eth-wire" } diff --git a/crates/net/discv4/Cargo.toml b/crates/net/discv4/Cargo.toml index 4daa3bc181db..a2b9f30c8a41 100644 --- a/crates/net/discv4/Cargo.toml +++ b/crates/net/discv4/Cargo.toml @@ -33,7 +33,6 @@ tokio = { version = "1", features = ["io-util", "net", "time"] } tokio-stream = "0.1" # misc -bytes = "1.2" tracing = "0.1" thiserror = "1.0" hex = "0.4" diff --git a/crates/net/discv4/src/config.rs b/crates/net/discv4/src/config.rs index 06dc379f9943..0a8c14cbc542 100644 --- a/crates/net/discv4/src/config.rs +++ b/crates/net/discv4/src/config.rs @@ -3,10 +3,12 @@ //! This basis of this file has been taken from the discv5 codebase: //! -use bytes::{Bytes, BytesMut}; use reth_net_common::ban_list::BanList; use reth_net_nat::{NatResolver, ResolveNatInterval}; -use reth_primitives::NodeRecord; +use reth_primitives::{ + bytes::{Bytes, BytesMut}, + NodeRecord, +}; use reth_rlp::Encodable; use std::{ collections::{HashMap, HashSet}, diff --git a/crates/net/discv4/src/lib.rs b/crates/net/discv4/src/lib.rs index 2a0dc7eb6f99..9e6e7187bf9c 100644 --- a/crates/net/discv4/src/lib.rs +++ b/crates/net/discv4/src/lib.rs @@ -21,7 +21,6 @@ use crate::{ error::{DecodePacketError, Discv4Error}, proto::{FindNode, Message, Neighbours, Packet, Ping, Pong}, }; -use bytes::{Bytes, BytesMut}; use discv5::{ kbucket, kbucket::{ @@ -32,7 +31,10 @@ use discv5::{ }; use enr::{Enr, EnrBuilder}; use proto::{EnrRequest, EnrResponse}; -use reth_primitives::{ForkId, PeerId, H256}; +use reth_primitives::{ + bytes::{Bytes, BytesMut}, + ForkId, PeerId, H256, +}; use secp256k1::SecretKey; use std::{ cell::RefCell, diff --git a/crates/net/discv4/src/proto.rs b/crates/net/discv4/src/proto.rs index 935174341622..e4e8f28594a9 100644 --- a/crates/net/discv4/src/proto.rs +++ b/crates/net/discv4/src/proto.rs @@ -1,9 +1,11 @@ #![allow(missing_docs)] use crate::{error::DecodePacketError, PeerId, MAX_PACKET_SIZE, MIN_PACKET_SIZE}; -use bytes::{Buf, BufMut, Bytes, BytesMut}; use enr::Enr; -use reth_primitives::{keccak256, ForkId, NodeRecord, H256}; +use reth_primitives::{ + bytes::{Buf, BufMut, Bytes, BytesMut}, + keccak256, ForkId, NodeRecord, H256, +}; use reth_rlp::{Decodable, DecodeError, Encodable, Header}; use reth_rlp_derive::{RlpDecodable, RlpEncodable}; use secp256k1::{ @@ -420,7 +422,6 @@ mod tests { test_utils::{rng_endpoint, rng_ipv4_record, rng_ipv6_record, rng_message}, SAFE_MAX_DATAGRAM_NEIGHBOUR_RECORDS, }; - use bytes::BytesMut; use rand::{thread_rng, Rng, RngCore}; #[test] diff --git a/crates/net/dns/Cargo.toml b/crates/net/dns/Cargo.toml index 2c125d7b0056..80bea744cb59 100644 --- a/crates/net/dns/Cargo.toml +++ b/crates/net/dns/Cargo.toml @@ -31,7 +31,6 @@ trust-dns-resolver = "0.22" # misc data-encoding = "2" async-trait = "0.1" -bytes = "1.2" linked_hash_set = "0.1" lru = "0.9" thiserror = "1.0" diff --git a/crates/net/dns/src/tree.rs b/crates/net/dns/src/tree.rs index dae92468856e..6f42af14679b 100644 --- a/crates/net/dns/src/tree.rs +++ b/crates/net/dns/src/tree.rs @@ -23,10 +23,9 @@ use crate::error::{ ParseDnsEntryError::{FieldNotFound, UnknownEntry}, ParseEntryResult, }; -use bytes::Bytes; use data_encoding::{BASE32_NOPAD, BASE64URL_NOPAD}; use enr::{Enr, EnrError, EnrKey, EnrKeyUnambiguous, EnrPublicKey}; -use reth_primitives::hex; +use reth_primitives::{bytes::Bytes, hex}; use secp256k1::SecretKey; use std::{fmt, str::FromStr}; diff --git a/crates/net/downloaders/Cargo.toml b/crates/net/downloaders/Cargo.toml index be25c45c54cc..cb7d8fc2bce5 100644 --- a/crates/net/downloaders/Cargo.toml +++ b/crates/net/downloaders/Cargo.toml @@ -31,7 +31,6 @@ metrics = "0.20.1" thiserror = { version = "1", optional = true } reth-rlp = { path = "../../rlp", optional = true } tokio-util = { version = "0.7", features = ["codec"], optional = true } -bytes = { version = "1", optional = true } tempfile = { version = "3.3", optional = true } itertools = { version = "0.10", optional = true } @@ -45,10 +44,9 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tokio-util = { version = "0.7", features = ["codec"] } reth-rlp = { path = "../../rlp" } itertools = "0.10" -bytes = "1" thiserror = "1" tempfile = "3.3" [features] -test-utils = ["dep:reth-rlp", "dep:thiserror", "dep:tokio-util", "dep:tempfile", "dep:bytes", "dep:itertools"] +test-utils = ["dep:reth-rlp", "dep:thiserror", "dep:tokio-util", "dep:tempfile", "dep:itertools"] diff --git a/crates/net/downloaders/src/test_utils/file_codec.rs b/crates/net/downloaders/src/test_utils/file_codec.rs index aecaa2662e24..98388be4ad76 100644 --- a/crates/net/downloaders/src/test_utils/file_codec.rs +++ b/crates/net/downloaders/src/test_utils/file_codec.rs @@ -1,7 +1,9 @@ //! Codec for reading raw block bodies from a file. use super::FileClientError; -use bytes::{Buf, BytesMut}; -use reth_primitives::Block; +use reth_primitives::{ + bytes::{Buf, BytesMut}, + Block, +}; use reth_rlp::{Decodable, Encodable}; use tokio_util::codec::{Decoder, Encoder}; diff --git a/crates/net/ecies/Cargo.toml b/crates/net/ecies/Cargo.toml index 3f558084a6f6..9c61f8eef36d 100644 --- a/crates/net/ecies/Cargo.toml +++ b/crates/net/ecies/Cargo.toml @@ -25,7 +25,6 @@ tracing = "0.1.37" generic-array = "0.14.6" typenum = "1.15.0" byteorder = "1.4.3" -bytes = "1.2.1" # crypto rand = "0.8.5" diff --git a/crates/net/ecies/src/algorithm.rs b/crates/net/ecies/src/algorithm.rs index 9502aec82c48..26f530ab820c 100644 --- a/crates/net/ecies/src/algorithm.rs +++ b/crates/net/ecies/src/algorithm.rs @@ -7,12 +7,14 @@ use crate::{ }; use aes::{cipher::StreamCipher, Aes128, Aes256}; use byteorder::{BigEndian, ByteOrder, ReadBytesExt}; -use bytes::{BufMut, Bytes, BytesMut}; use ctr::Ctr64BE; use digest::{crypto_common::KeyIvInit, Digest}; use educe::Educe; use rand::{thread_rng, Rng}; -use reth_primitives::{H128, H256, H512 as PeerId}; +use reth_primitives::{ + bytes::{BufMut, Bytes, BytesMut}, + H128, H256, H512 as PeerId, +}; use reth_rlp::{Encodable, Rlp, RlpEncodable, RlpMaxEncodedLen}; use secp256k1::{ ecdsa::{RecoverableSignature, RecoveryId}, diff --git a/crates/net/ecies/src/codec.rs b/crates/net/ecies/src/codec.rs index e8b56ff7c3f1..33f42b7d0217 100644 --- a/crates/net/ecies/src/codec.rs +++ b/crates/net/ecies/src/codec.rs @@ -1,6 +1,5 @@ use crate::{algorithm::ECIES, ECIESError, EgressECIESValue, IngressECIESValue}; -use bytes::BytesMut; -use reth_primitives::H512 as PeerId; +use reth_primitives::{bytes::BytesMut, H512 as PeerId}; use secp256k1::SecretKey; use std::{fmt::Debug, io}; use tokio_util::codec::{Decoder, Encoder}; diff --git a/crates/net/ecies/src/lib.rs b/crates/net/ecies/src/lib.rs index 6f47f1ebe92a..87c9773fff0c 100644 --- a/crates/net/ecies/src/lib.rs +++ b/crates/net/ecies/src/lib.rs @@ -17,7 +17,10 @@ pub use error::ECIESError; mod codec; -use reth_primitives::H512 as PeerId; +use reth_primitives::{ + bytes::{Bytes, BytesMut}, + H512 as PeerId, +}; /// Raw egress values for an ECIES protocol #[derive(Clone, Debug, PartialEq, Eq)] @@ -27,7 +30,7 @@ pub enum EgressECIESValue { /// The ACK message being sent out Ack, /// The message being sent out (wrapped bytes) - Message(bytes::Bytes), + Message(Bytes), } /// Raw ingress values for an ECIES protocol @@ -38,5 +41,5 @@ pub enum IngressECIESValue { /// Receiving an ACK message Ack, /// Receiving a message - Message(bytes::BytesMut), + Message(BytesMut), } diff --git a/crates/net/ecies/src/stream.rs b/crates/net/ecies/src/stream.rs index dd9274b18a70..69b3fe9e906d 100644 --- a/crates/net/ecies/src/stream.rs +++ b/crates/net/ecies/src/stream.rs @@ -2,10 +2,12 @@ use crate::{ codec::ECIESCodec, error::ECIESErrorImpl, ECIESError, EgressECIESValue, IngressECIESValue, }; -use bytes::Bytes; use futures::{ready, Sink, SinkExt}; use reth_net_common::stream::HasRemoteAddr; -use reth_primitives::H512 as PeerId; +use reth_primitives::{ + bytes::{Bytes, BytesMut}, + H512 as PeerId, +}; use secp256k1::SecretKey; use std::{ fmt::Debug, @@ -104,7 +106,7 @@ impl Stream for ECIESStream where Io: AsyncRead + Unpin, { - type Item = Result; + type Item = Result; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match ready!(self.project().stream.poll_next(cx)) { diff --git a/crates/net/eth-wire/Cargo.toml b/crates/net/eth-wire/Cargo.toml index 5bd03e5f45df..264c3a449ce1 100644 --- a/crates/net/eth-wire/Cargo.toml +++ b/crates/net/eth-wire/Cargo.toml @@ -8,8 +8,7 @@ repository = "https://github.com/paradigmxyz/reth" readme = "README.md" [dependencies] -bytes = { version = "1.1" } -hex = "0.4" +bytes = "1.4" thiserror = "1" serde = { version = "1", optional = true } diff --git a/crates/net/eth-wire/src/capability.rs b/crates/net/eth-wire/src/capability.rs index b6733c83498b..cd2394aea1a4 100644 --- a/crates/net/eth-wire/src/capability.rs +++ b/crates/net/eth-wire/src/capability.rs @@ -1,8 +1,8 @@ //! All capability related types use crate::{version::ParseVersionError, EthMessage, EthVersion}; -use bytes::{BufMut, Bytes}; use reth_codecs::add_arbitrary_tests; +use reth_primitives::bytes::{BufMut, Bytes}; use reth_rlp::{Decodable, DecodeError, Encodable, RlpDecodable, RlpEncodable}; use smol_str::SmolStr; diff --git a/crates/net/eth-wire/src/disconnect.rs b/crates/net/eth-wire/src/disconnect.rs index 5dd39697f065..6ddf4367f974 100644 --- a/crates/net/eth-wire/src/disconnect.rs +++ b/crates/net/eth-wire/src/disconnect.rs @@ -1,7 +1,7 @@ //! Disconnect -use bytes::Buf; use reth_codecs::derive_arbitrary; +use reth_primitives::bytes::{Buf, BufMut}; use reth_rlp::{Decodable, DecodeError, Encodable, Header}; use std::fmt::Display; use thiserror::Error; @@ -104,7 +104,7 @@ impl TryFrom for DisconnectReason { /// The [`Encodable`](reth_rlp::Encodable) implementation for [`DisconnectReason`] encodes the /// disconnect reason in a single-element RLP list. impl Encodable for DisconnectReason { - fn encode(&self, out: &mut dyn bytes::BufMut) { + fn encode(&self, out: &mut dyn BufMut) { vec![*self as u8].encode(out); } fn length(&self) -> usize { @@ -146,6 +146,7 @@ impl Decodable for DisconnectReason { #[cfg(test)] mod tests { use crate::{p2pstream::P2PMessage, DisconnectReason}; + use reth_primitives::hex; use reth_rlp::{Decodable, Encodable}; fn all_reasons() -> Vec { diff --git a/crates/net/eth-wire/src/ethstream.rs b/crates/net/eth-wire/src/ethstream.rs index 46c9ed693f43..c0f96ecc82b6 100644 --- a/crates/net/eth-wire/src/ethstream.rs +++ b/crates/net/eth-wire/src/ethstream.rs @@ -3,10 +3,12 @@ use crate::{ message::{EthBroadcastMessage, ProtocolBroadcastMessage}, types::{EthMessage, ProtocolMessage, Status}, }; -use bytes::{Bytes, BytesMut}; use futures::{ready, Sink, SinkExt, StreamExt}; use pin_project::pin_project; -use reth_primitives::ForkFilter; +use reth_primitives::{ + bytes::{Bytes, BytesMut}, + ForkFilter, +}; use reth_rlp::{Decodable, Encodable}; use std::{ pin::Pin, diff --git a/crates/net/eth-wire/src/p2pstream.rs b/crates/net/eth-wire/src/p2pstream.rs index 1e73d464b8c7..6b5adc695e71 100644 --- a/crates/net/eth-wire/src/p2pstream.rs +++ b/crates/net/eth-wire/src/p2pstream.rs @@ -5,11 +5,14 @@ use crate::{ pinger::{Pinger, PingerEvent}, DisconnectReason, HelloMessage, }; -use bytes::{Buf, Bytes, BytesMut}; use futures::{Sink, SinkExt, StreamExt}; use metrics::counter; use pin_project::pin_project; use reth_codecs::derive_arbitrary; +use reth_primitives::{ + bytes::{Buf, BufMut, Bytes, BytesMut}, + hex, +}; use reth_rlp::{Decodable, DecodeError, Encodable, EMPTY_LIST_CODE}; use std::{ collections::{BTreeSet, HashMap, HashSet, VecDeque}, @@ -651,7 +654,7 @@ impl P2PMessage { /// for all variants except the [`P2PMessage::Hello`] variant, because the hello message is never /// compressed in the `p2p` subprotocol. impl Encodable for P2PMessage { - fn encode(&self, out: &mut dyn bytes::BufMut) { + fn encode(&self, out: &mut dyn BufMut) { (self.message_id() as u8).encode(out); match self { P2PMessage::Hello(msg) => msg.encode(out), @@ -761,7 +764,7 @@ pub enum ProtocolVersion { } impl Encodable for ProtocolVersion { - fn encode(&self, out: &mut dyn bytes::BufMut) { + fn encode(&self, out: &mut dyn BufMut) { (*self as u8).encode(out) } fn length(&self) -> usize { diff --git a/crates/net/eth-wire/src/types/message.rs b/crates/net/eth-wire/src/types/message.rs index e768f0a6ab9d..e52392d7b10e 100644 --- a/crates/net/eth-wire/src/types/message.rs +++ b/crates/net/eth-wire/src/types/message.rs @@ -5,7 +5,7 @@ use super::{ NodeData, PooledTransactions, Receipts, Status, Transactions, }; use crate::SharedTransactions; -use bytes::{Buf, BufMut}; +use reth_primitives::bytes::{Buf, BufMut}; use reth_rlp::{length_of_length, Decodable, Encodable, Header}; use std::{fmt::Debug, sync::Arc}; diff --git a/crates/net/eth-wire/src/types/status.rs b/crates/net/eth-wire/src/types/status.rs index 7350f931d26f..4b67d486eb93 100644 --- a/crates/net/eth-wire/src/types/status.rs +++ b/crates/net/eth-wire/src/types/status.rs @@ -2,7 +2,7 @@ use crate::{EthVersion, StatusBuilder}; use ethers_core::utils::Genesis; use reth_codecs::derive_arbitrary; -use reth_primitives::{Chain, ChainSpec, ForkId, Hardfork, Head, H256, MAINNET, U256}; +use reth_primitives::{hex, Chain, ChainSpec, ForkId, Hardfork, Head, H256, MAINNET, U256}; use reth_rlp::{RlpDecodable, RlpEncodable}; use std::fmt::{Debug, Display}; diff --git a/crates/net/eth-wire/src/types/transactions.rs b/crates/net/eth-wire/src/types/transactions.rs index 476c6cdce831..7f38c0f69235 100644 --- a/crates/net/eth-wire/src/types/transactions.rs +++ b/crates/net/eth-wire/src/types/transactions.rs @@ -56,7 +56,7 @@ mod test { use crate::{message::RequestPair, GetPooledTransactions, PooledTransactions}; use hex_literal::hex; use reth_primitives::{ - Signature, Transaction, TransactionKind, TransactionSigned, TxEip1559, TxLegacy, U256, + hex, Signature, Transaction, TransactionKind, TransactionSigned, TxEip1559, TxLegacy, U256, }; use reth_rlp::{Decodable, Encodable}; use std::str::FromStr; diff --git a/crates/net/eth-wire/tests/new_block.rs b/crates/net/eth-wire/tests/new_block.rs index dcf896387d4b..9e011bd8d45b 100644 --- a/crates/net/eth-wire/tests/new_block.rs +++ b/crates/net/eth-wire/tests/new_block.rs @@ -1,5 +1,6 @@ //! Decoding tests for [`NewBlock`] use reth_eth_wire::NewBlock; +use reth_primitives::hex; use reth_rlp::Decodable; use std::{fs, path::PathBuf}; diff --git a/crates/net/eth-wire/tests/new_pooled_transactions.rs b/crates/net/eth-wire/tests/new_pooled_transactions.rs index c80f2cf103ab..8272c5c73082 100644 --- a/crates/net/eth-wire/tests/new_pooled_transactions.rs +++ b/crates/net/eth-wire/tests/new_pooled_transactions.rs @@ -1,5 +1,6 @@ //! Decoding tests for [`NewPooledTransactions`] use reth_eth_wire::NewPooledTransactionHashes; +use reth_primitives::hex; use reth_rlp::Decodable; use std::{fs, path::PathBuf}; diff --git a/crates/net/network/Cargo.toml b/crates/net/network/Cargo.toml index 37b3d7ff3cf2..9c27701b12b5 100644 --- a/crates/net/network/Cargo.toml +++ b/crates/net/network/Cargo.toml @@ -56,7 +56,6 @@ fnv = "1.0" thiserror = "1.0" parking_lot = "0.12" async-trait = "0.1" -bytes = "1.2" linked_hash_set = "0.1" linked-hash-map = "0.5.6" rand = "0.8" diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index df03c8ec2be9..23ca188ecd92 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -40,7 +40,7 @@ secp256k1 = { version = "0.24.2", default-features = false, features = [ crc = "3" # misc -bytes = "1.2" +bytes = "1.4" serde = "1.0" serde_json = "1.0" serde_with = "2.1.0" diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 1129790f3d8a..340aec66d944 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -92,6 +92,7 @@ pub use revm_primitives::{ruint::aliases::U128, B160 as H160, B256 as H256, U256 #[doc(hidden)] mod __reexport { + pub use bytes; pub use hex; pub use hex_literal; pub use tiny_keccak; diff --git a/crates/rpc/ipc/Cargo.toml b/crates/rpc/ipc/Cargo.toml index ad340108952d..e42aed3aedf0 100644 --- a/crates/rpc/ipc/Cargo.toml +++ b/crates/rpc/ipc/Cargo.toml @@ -24,7 +24,7 @@ tower = "0.4" jsonrpsee = { version = "0.16", features = ["server", "client"] } serde_json = "1.0" tracing = "0.1.37" -bytes = "1.2.1" +bytes = "1.4" thiserror = "1.0.37" [dev-dependencies] diff --git a/crates/rpc/rpc-engine-api/Cargo.toml b/crates/rpc/rpc-engine-api/Cargo.toml index 0c3c5e1a5915..25cc579ccb7c 100644 --- a/crates/rpc/rpc-engine-api/Cargo.toml +++ b/crates/rpc/rpc-engine-api/Cargo.toml @@ -30,4 +30,3 @@ thiserror = "1.0.37" reth-interfaces = { path = "../../interfaces", features = ["test-utils"] } reth-provider = { path = "../../storage/provider", features = ["test-utils"] } assert_matches = "1.5.0" -bytes = "1.2" diff --git a/crates/rpc/rpc-engine-api/src/engine_api.rs b/crates/rpc/rpc-engine-api/src/engine_api.rs index f9673fac5207..4367c20da67a 100644 --- a/crates/rpc/rpc-engine-api/src/engine_api.rs +++ b/crates/rpc/rpc-engine-api/src/engine_api.rs @@ -326,9 +326,11 @@ mod tests { mod new_payload { use super::*; - use bytes::{Bytes, BytesMut}; use reth_interfaces::test_utils::generators::random_header; - use reth_primitives::Block; + use reth_primitives::{ + bytes::{Bytes, BytesMut}, + Block, + }; use reth_rlp::DecodeError; fn transform_block Block>(src: SealedBlock, f: F) -> SealedBlock { diff --git a/crates/rpc/rpc-types/Cargo.toml b/crates/rpc/rpc-types/Cargo.toml index e0a3aba29647..13996c5266df 100644 --- a/crates/rpc/rpc-types/Cargo.toml +++ b/crates/rpc/rpc-types/Cargo.toml @@ -23,6 +23,5 @@ tokio = { version = "1", features = ["sync"] } # misc serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -bytes = "1.2" jsonrpsee-types = { version = "0.16" } lru = "0.9" diff --git a/crates/rpc/rpc-types/src/eth/engine.rs b/crates/rpc/rpc-types/src/eth/engine.rs index 32c2b87e4add..a536d86125b8 100644 --- a/crates/rpc/rpc-types/src/eth/engine.rs +++ b/crates/rpc/rpc-types/src/eth/engine.rs @@ -2,8 +2,9 @@ #![allow(missing_docs)] -use bytes::BytesMut; -use reth_primitives::{Address, Bloom, Bytes, SealedBlock, Withdrawal, H256, H64, U256, U64}; +use reth_primitives::{ + bytes::BytesMut, Address, Bloom, Bytes, SealedBlock, Withdrawal, H256, H64, U256, U64, +}; use reth_rlp::Encodable; use serde::{Deserialize, Serialize}; diff --git a/crates/staged-sync/Cargo.toml b/crates/staged-sync/Cargo.toml index b11ce31f7a4f..dc440eaa634d 100644 --- a/crates/staged-sync/Cargo.toml +++ b/crates/staged-sync/Cargo.toml @@ -24,7 +24,7 @@ reth-primitives = { path = "../../crates/primitives" } reth-provider = { path = "../../crates/storage/provider", features = ["test-utils"] } reth-net-nat = { path = "../../crates/net/nat" } reth-interfaces = { path = "../interfaces", optional = true } -reth-tasks= { path = "../../crates/tasks" } +reth-tasks = { path = "../../crates/tasks" } # io serde = "1.0" diff --git a/crates/storage/codecs/Cargo.toml b/crates/storage/codecs/Cargo.toml index fc742c5b762b..f39c6143c4bf 100644 --- a/crates/storage/codecs/Cargo.toml +++ b/crates/storage/codecs/Cargo.toml @@ -21,7 +21,7 @@ arbitrary = [ [dependencies] -bytes = "1.2.1" +bytes = "1.4" codecs-derive = { version = "0.1.0", path = "./derive", default-features = false } revm-primitives = { version = "1.0.0", features = ["serde"] } diff --git a/crates/storage/db/Cargo.toml b/crates/storage/db/Cargo.toml index f32e3c5dcf06..a0ab525625b8 100644 --- a/crates/storage/db/Cargo.toml +++ b/crates/storage/db/Cargo.toml @@ -33,7 +33,7 @@ modular-bitfield = "0.11.2" metrics = "0.20.1" # misc -bytes = "1.2.1" +bytes = "1.4" page_size = "0.4.2" thiserror = "1.0.37" tempfile = { version = "3.3.0", optional = true } diff --git a/crates/storage/db/src/abstraction/table.rs b/crates/storage/db/src/abstraction/table.rs index cd3fffbd8929..202ee6b58a7c 100644 --- a/crates/storage/db/src/abstraction/table.rs +++ b/crates/storage/db/src/abstraction/table.rs @@ -3,7 +3,7 @@ use crate::{ transaction::{DbTx, DbTxMut}, Error, }; -use bytes::Bytes; +use reth_primitives::bytes::Bytes; use serde::Serialize; use std::{ fmt::Debug, diff --git a/crates/storage/db/src/tables/models/accounts.rs b/crates/storage/db/src/tables/models/accounts.rs index 4ca5a735100d..3783cf3acbc3 100644 --- a/crates/storage/db/src/tables/models/accounts.rs +++ b/crates/storage/db/src/tables/models/accounts.rs @@ -5,9 +5,11 @@ use crate::{ table::{Decode, Encode}, Error, }; -use bytes::Bytes; use reth_codecs::Compact; -use reth_primitives::{Account, Address, TransitionId}; +use reth_primitives::{ + bytes::{BufMut, Bytes}, + Account, Address, TransitionId, +}; use serde::{Deserialize, Serialize}; /// Account as it is saved inside [`AccountChangeSet`][crate::tables::AccountChangeSet]. @@ -25,7 +27,7 @@ pub struct AccountBeforeTx { // and compress second part of the value. If we have compression // over whole value (Even SubKey) that would mess up fetching of values with seek_by_key_subkey impl Compact for AccountBeforeTx { - fn to_compact(self, buf: &mut impl bytes::BufMut) -> usize { + fn to_compact(self, buf: &mut impl BufMut) -> usize { // for now put full bytes and later compress it. buf.put_slice(&self.address.to_fixed_bytes()[..]); self.info.to_compact(buf) + 32 @@ -88,7 +90,7 @@ impl Encode for TransitionIdAddress { impl Decode for TransitionIdAddress { fn decode>(value: B) -> Result { - let value: bytes::Bytes = value.into(); + let value: Bytes = value.into(); let num = u64::from_be_bytes(value.as_ref()[..8].try_into().map_err(|_| Error::DecodeError)?); diff --git a/crates/storage/db/src/tables/models/blocks.rs b/crates/storage/db/src/tables/models/blocks.rs index 48213662c755..87226a2bd64e 100644 --- a/crates/storage/db/src/tables/models/blocks.rs +++ b/crates/storage/db/src/tables/models/blocks.rs @@ -7,9 +7,8 @@ use crate::{ table::{Decode, Encode}, Error, }; -use bytes::Bytes; use reth_codecs::{main_codec, Compact}; -use reth_primitives::{BlockHash, BlockNumber, Header, TxNumber, Withdrawal, H256}; +use reth_primitives::{bytes::Bytes, BlockHash, BlockNumber, Header, TxNumber, Withdrawal, H256}; use serde::{Deserialize, Serialize}; /// Total number of transactions. @@ -128,7 +127,7 @@ impl Encode for BlockNumHash { impl Decode for BlockNumHash { fn decode>(value: B) -> Result { - let value: bytes::Bytes = value.into(); + let value: Bytes = value.into(); let num = u64::from_be_bytes(value.as_ref()[..8].try_into().map_err(|_| Error::DecodeError)?); diff --git a/crates/storage/db/src/tables/models/integer_list.rs b/crates/storage/db/src/tables/models/integer_list.rs index f43345685094..6293b84c81d7 100644 --- a/crates/storage/db/src/tables/models/integer_list.rs +++ b/crates/storage/db/src/tables/models/integer_list.rs @@ -4,8 +4,7 @@ use crate::{ table::{Compress, Decompress}, Error, }; -use bytes::Bytes; -use reth_primitives::IntegerList; +use reth_primitives::{bytes::Bytes, IntegerList}; impl Compress for IntegerList { type Compressed = Vec; diff --git a/crates/storage/db/src/tables/models/mod.rs b/crates/storage/db/src/tables/models/mod.rs index 040a88430693..545eca6366f9 100644 --- a/crates/storage/db/src/tables/models/mod.rs +++ b/crates/storage/db/src/tables/models/mod.rs @@ -8,13 +8,13 @@ pub mod storage_sharded_key; pub use accounts::*; pub use blocks::*; -use reth_primitives::{Address, H256}; pub use sharded_key::ShardedKey; use crate::{ table::{Decode, Encode}, Error, }; +use reth_primitives::{bytes::Bytes, Address, H256}; /// Macro that implements [`Encode`] and [`Decode`] for uint types. macro_rules! impl_uints { @@ -31,8 +31,8 @@ macro_rules! impl_uints { impl Decode for $name { - fn decode>(value: B) -> Result { - let value: bytes::Bytes = value.into(); + fn decode>(value: B) -> Result { + let value: Bytes = value.into(); Ok( $name::from_be_bytes( value.as_ref().try_into().map_err(|_| Error::DecodeError)? @@ -54,7 +54,7 @@ impl Encode for Vec { } impl Decode for Vec { - fn decode>(value: B) -> Result { + fn decode>(value: B) -> Result { Ok(value.into().to_vec()) } } @@ -67,7 +67,7 @@ impl Encode for Address { } impl Decode for Address { - fn decode>(value: B) -> Result { + fn decode>(value: B) -> Result { Ok(Address::from_slice(&value.into()[..])) } } @@ -79,7 +79,7 @@ impl Encode for H256 { } impl Decode for H256 { - fn decode>(value: B) -> Result { + fn decode>(value: B) -> Result { Ok(H256::from_slice(&value.into()[..])) } } diff --git a/crates/storage/db/src/tables/models/sharded_key.rs b/crates/storage/db/src/tables/models/sharded_key.rs index 81978829a3b2..a56b29e0ff7c 100644 --- a/crates/storage/db/src/tables/models/sharded_key.rs +++ b/crates/storage/db/src/tables/models/sharded_key.rs @@ -4,7 +4,7 @@ use crate::{ table::{Decode, Encode}, Error, }; -use reth_primitives::TransitionId; +use reth_primitives::{bytes::Bytes, TransitionId}; /// Number of indices in one shard. pub const NUM_OF_INDICES_IN_SHARD: usize = 100; @@ -48,8 +48,8 @@ impl Decode for ShardedKey where T: Decode, { - fn decode>(value: B) -> Result { - let value: bytes::Bytes = value.into(); + fn decode>(value: B) -> Result { + let value: Bytes = value.into(); let tx_num_index = value.len() - 8; let highest_tx_number = u64::from_be_bytes( diff --git a/crates/storage/db/src/tables/models/storage_sharded_key.rs b/crates/storage/db/src/tables/models/storage_sharded_key.rs index 2a14e62c2dfd..16a8c0c76535 100644 --- a/crates/storage/db/src/tables/models/storage_sharded_key.rs +++ b/crates/storage/db/src/tables/models/storage_sharded_key.rs @@ -4,7 +4,7 @@ use crate::{ table::{Decode, Encode}, Error, }; -use reth_primitives::{TransitionId, H160, H256}; +use reth_primitives::{bytes::Bytes, TransitionId, H160, H256}; use super::ShardedKey; @@ -44,8 +44,8 @@ impl Encode for StorageShardedKey { } impl Decode for StorageShardedKey { - fn decode>(value: B) -> Result { - let value: bytes::Bytes = value.into(); + fn decode>(value: B) -> Result { + let value: Bytes = value.into(); let tx_num_index = value.len() - 8; let highest_tx_number = u64::from_be_bytes( diff --git a/crates/storage/db/src/tables/utils.rs b/crates/storage/db/src/tables/utils.rs index 1e20a809de3e..899a9b0be6a9 100644 --- a/crates/storage/db/src/tables/utils.rs +++ b/crates/storage/db/src/tables/utils.rs @@ -3,7 +3,7 @@ use crate::{ table::{Decode, Decompress, Table}, Error, }; -use bytes::Bytes; +use reth_primitives::bytes::Bytes; use std::borrow::Cow; #[macro_export] diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index 77924b295d20..b71b70ce6bef 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -24,7 +24,7 @@ async-trait = "0.1.57" thiserror = "1.0.37" auto_impl = "1.0" tokio = { version = "1.21.2", features = ["sync"] } -bytes = "1.2" +bytes = "1.4" futures = "0.3.25" tokio-stream = "0.1.11" rand = "0.8.5"