Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reexport bytes & bump version to 1.4 #1395

Merged
merged 2 commits into from
Feb 16, 2023
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
13 changes: 2 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/interfaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 0 additions & 1 deletion crates/net/discv4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions crates/net/discv4/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
//! This basis of this file has been taken from the discv5 codebase:
//! <https://github.com/sigp/discv5>

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},
Expand Down
6 changes: 4 additions & 2 deletions crates/net/discv4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use crate::{
error::{DecodePacketError, Discv4Error},
proto::{FindNode, Message, Neighbours, Packet, Ping, Pong},
};
use bytes::{Bytes, BytesMut};
use discv5::{
kbucket,
kbucket::{
Expand All @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions crates/net/discv4/src/proto.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion crates/net/dns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions crates/net/dns/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
4 changes: 1 addition & 3 deletions crates/net/downloaders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -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"]
6 changes: 4 additions & 2 deletions crates/net/downloaders/src/test_utils/file_codec.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
1 change: 0 additions & 1 deletion crates/net/ecies/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions crates/net/ecies/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
3 changes: 1 addition & 2 deletions crates/net/ecies/src/codec.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
9 changes: 6 additions & 3 deletions crates/net/ecies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
Expand All @@ -38,5 +41,5 @@ pub enum IngressECIESValue {
/// Receiving an ACK message
Ack,
/// Receiving a message
Message(bytes::BytesMut),
Message(BytesMut),
}
8 changes: 5 additions & 3 deletions crates/net/ecies/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -104,7 +106,7 @@ impl<Io> Stream for ECIESStream<Io>
where
Io: AsyncRead + Unpin,
{
type Item = Result<bytes::BytesMut, io::Error>;
type Item = Result<BytesMut, io::Error>;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
match ready!(self.project().stream.poll_next(cx)) {
Expand Down
3 changes: 1 addition & 2 deletions crates/net/eth-wire/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
2 changes: 1 addition & 1 deletion crates/net/eth-wire/src/capability.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
5 changes: 3 additions & 2 deletions crates/net/eth-wire/src/disconnect.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -104,7 +104,7 @@ impl TryFrom<u8> 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 {
Expand Down Expand Up @@ -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<DisconnectReason> {
Expand Down
6 changes: 4 additions & 2 deletions crates/net/eth-wire/src/ethstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions crates/net/eth-wire/src/p2pstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/net/eth-wire/src/types/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
Loading