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

net: replace reth-primitive imports with alloy-eips #11027

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/net/downloaders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ reth-db-api = { workspace = true, optional = true }
reth-testing-utils = { workspace = true, optional = true }

# ethereum
alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true

Expand Down
3 changes: 2 additions & 1 deletion crates/net/downloaders/src/file_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashMap, io, path::Path};

use alloy_eips::BlockHashOrNumber;
use alloy_primitives::{BlockHash, BlockNumber, B256};
use futures::Future;
use itertools::Either;
Expand All @@ -11,7 +12,7 @@ use reth_network_p2p::{
priority::Priority,
};
use reth_network_peers::PeerId;
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, SealedHeader};
use reth_primitives::{BlockBody, Header, SealedHeader};
use thiserror::Error;
use tokio::{fs::File, io::AsyncReadExt};
use tokio_stream::StreamExt;
Expand Down
3 changes: 2 additions & 1 deletion crates/net/downloaders/src/headers/reverse_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use super::task::TaskDownloader;
use crate::metrics::HeaderDownloaderMetrics;
use alloy_eips::BlockHashOrNumber;
use alloy_primitives::{BlockNumber, B256};
use futures::{stream::Stream, FutureExt};
use futures_util::{stream::FuturesUnordered, StreamExt};
Expand All @@ -18,7 +19,7 @@ use reth_network_p2p::{
priority::Priority,
};
use reth_network_peers::PeerId;
use reth_primitives::{BlockHashOrNumber, GotExpected, Header, SealedHeader};
use reth_primitives::{GotExpected, Header, SealedHeader};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use std::{
cmp::{Ordering, Reverse},
Expand Down
1 change: 1 addition & 0 deletions crates/net/eth-wire-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ reth-primitives.workspace = true

# ethereum
alloy-chains = { workspace = true, features = ["rlp"] }
alloy-eips.workspace = true
alloy-genesis.workspace = true
alloy-primitives.workspace = true
alloy-rlp = { workspace = true, features = ["derive"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/net/eth-wire-types/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
//! types.

use crate::HeadersDirection;
use alloy_eips::BlockHashOrNumber;
use alloy_primitives::B256;
use alloy_rlp::{RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWrapper};
use reth_codecs_derive::add_arbitrary_tests;
use reth_primitives::{BlockBody, BlockHashOrNumber, Header};
use reth_primitives::{BlockBody, Header};

/// A request for a peer to return block headers starting at the requested block.
/// The peer must return at most [`limit`](#structfield.limit) headers.
Expand Down
1 change: 1 addition & 0 deletions crates/net/eth-wire/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ reth-eth-wire-types.workspace = true
reth-network-peers.workspace = true

# ethereum
alloy-eips.workspace = true
alloy-primitives.workspace = true

# metrics
Expand Down
3 changes: 2 additions & 1 deletion crates/net/eth-wire/tests/fuzz_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ macro_rules! fuzz_type_and_name {
#[cfg(test)]
pub mod fuzz_rlp {
use crate::roundtrip_encoding;
use alloy_eips::BlockHashOrNumber;
use alloy_rlp::{RlpDecodableWrapper, RlpEncodableWrapper};
use reth_codecs::add_arbitrary_tests;
use reth_eth_wire::{
Expand All @@ -56,7 +57,7 @@ pub mod fuzz_rlp {
NewPooledTransactionHashes66, NewPooledTransactionHashes68, NodeData, P2PMessage,
PooledTransactions, Receipts, Status, Transactions,
};
use reth_primitives::{BlockHashOrNumber, TransactionSigned};
use reth_primitives::TransactionSigned;
use serde::{Deserialize, Serialize};
use test_fuzz::test_fuzz;

Expand Down
1 change: 1 addition & 0 deletions crates/net/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ reth-network-peers = { workspace = true, features = ["net"] }
reth-network-types.workspace = true

# ethereum
alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true
enr = { workspace = true, features = ["serde", "rust-secp256k1"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/net/network/src/eth_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
time::Duration,
};

use alloy_eips::BlockHashOrNumber;
use alloy_rlp::Encodable;
use futures::StreamExt;
use reth_eth_wire::{
Expand All @@ -16,7 +17,7 @@ use reth_eth_wire::{
use reth_network_api::test_utils::PeersHandle;
use reth_network_p2p::error::RequestResult;
use reth_network_peers::PeerId;
use reth_primitives::{BlockBody, BlockHashOrNumber, Header};
use reth_primitives::{BlockBody, Header};
use reth_storage_api::{BlockReader, HeaderProvider, ReceiptProvider};
use tokio::sync::{mpsc::Receiver, oneshot};
use tokio_stream::wrappers::ReceiverStream;
Expand Down
1 change: 1 addition & 0 deletions crates/net/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ reth-network-types.workspace = true
reth-storage-errors.workspace = true

# ethereum
alloy-eips.workspace = true
alloy-primitives.workspace = true

# async
Expand Down
3 changes: 2 additions & 1 deletion crates/net/p2p/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::ops::RangeInclusive;

use super::headers::client::HeadersRequest;
use alloy_eips::BlockHashOrNumber;
use alloy_primitives::{BlockNumber, B256};
use derive_more::{Display, Error};
use reth_consensus::ConsensusError;
use reth_network_peers::WithPeerId;
use reth_network_types::ReputationChangeKind;
use reth_primitives::{BlockHashOrNumber, GotExpected, GotExpectedBoxed, Header};
use reth_primitives::{GotExpected, GotExpectedBoxed, Header};
use reth_storage_errors::{db::DatabaseError, provider::ProviderError};
use tokio::sync::{mpsc, oneshot};

Expand Down
3 changes: 2 additions & 1 deletion crates/net/p2p/src/headers/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{download::DownloadClient, error::PeerRequestResult, priority::Priority};
use alloy_eips::BlockHashOrNumber;
use futures::{Future, FutureExt};
pub use reth_eth_wire_types::{BlockHeaders, HeadersDirection};
use reth_primitives::{BlockHashOrNumber, Header};
use reth_primitives::Header;
use std::{
fmt::Debug,
pin::Pin,
Expand Down
3 changes: 2 additions & 1 deletion crates/net/p2p/src/headers/downloader.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use super::error::HeadersDownloaderResult;
use crate::error::{DownloadError, DownloadResult};
use alloy_eips::BlockHashOrNumber;
use alloy_primitives::B256;
use futures::Stream;
use reth_consensus::Consensus;
use reth_primitives::{BlockHashOrNumber, SealedHeader};
use reth_primitives::SealedHeader;
/// A downloader capable of fetching and yielding block headers.
///
/// A downloader represents a distinct strategy for submitting requests to download block headers,
Expand Down
5 changes: 2 additions & 3 deletions crates/net/p2p/src/test_utils/full_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ use crate::{
headers::client::{HeadersClient, HeadersRequest},
priority::Priority,
};
use alloy_eips::{BlockHashOrNumber, BlockNumHash};
use alloy_primitives::B256;
use parking_lot::Mutex;
use reth_eth_wire_types::HeadersDirection;
use reth_network_peers::{PeerId, WithPeerId};
use reth_primitives::{
BlockBody, BlockHashOrNumber, BlockNumHash, Header, SealedBlock, SealedHeader,
};
use reth_primitives::{BlockBody, Header, SealedBlock, SealedHeader};
use std::{collections::HashMap, sync::Arc};

/// A headers+bodies client implementation that does nothing.
Expand Down
2 changes: 1 addition & 1 deletion crates/net/p2p/src/test_utils/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl TestDownload {
let request = HeadersRequest {
limit: self.limit,
direction: HeadersDirection::Rising,
start: reth_primitives::BlockHashOrNumber::Number(0), // ignored
start: alloy_eips::BlockHashOrNumber::Number(0), // ignored
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can probably use 0u64.into() here

};
let client = self.client.clone();
self.fut = Some(Box::pin(client.get_headers(request)));
Expand Down
Loading