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

move header.rs to eth-wire-types #9345

Merged
merged 4 commits into from
Jul 6, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions crates/consensus/auto-seal/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::Storage;
use reth_network_p2p::{
bodies::client::{BodiesClient, BodiesFut},
download::DownloadClient,
headers::client::{HeadersClient, HeadersFut, HeadersRequest},
headers::client::{HeadersClient, HeadersDirection, HeadersFut, HeadersRequest},
priority::Priority,
};
use reth_network_peers::{PeerId, WithPeerId};
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, HeadersDirection, B256};
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, B256};
use std::fmt::Debug;
use tracing::{trace, warn};

Expand Down
5 changes: 2 additions & 3 deletions crates/net/downloaders/src/file_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ use reth_network_p2p::{
bodies::client::{BodiesClient, BodiesFut},
download::DownloadClient,
error::RequestError,
headers::client::{HeadersClient, HeadersFut, HeadersRequest},
headers::client::{HeadersClient, HeadersDirection, HeadersFut, HeadersRequest},
priority::Priority,
};
use reth_network_peers::PeerId;
use reth_primitives::{
BlockBody, BlockHash, BlockHashOrNumber, BlockNumber, Header, HeadersDirection, SealedHeader,
B256,
BlockBody, BlockHash, BlockHashOrNumber, BlockNumber, Header, SealedHeader, B256,
};
use std::{collections::HashMap, io, path::Path};
use thiserror::Error;
Expand Down
6 changes: 2 additions & 4 deletions crates/net/downloaders/src/headers/reverse_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ use reth_consensus::Consensus;
use reth_network_p2p::{
error::{DownloadError, DownloadResult, PeerRequestResult},
headers::{
client::{HeadersClient, HeadersRequest},
client::{HeadersClient, HeadersDirection, HeadersRequest},
downloader::{validate_header_download, HeaderDownloader, SyncTarget},
error::{HeadersDownloaderError, HeadersDownloaderResult},
},
priority::Priority,
};
use reth_network_peers::PeerId;
use reth_primitives::{
BlockHashOrNumber, BlockNumber, GotExpected, Header, HeadersDirection, SealedHeader, B256,
};
use reth_primitives::{BlockHashOrNumber, BlockNumber, GotExpected, Header, SealedHeader, B256};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use std::{
cmp::{Ordering, Reverse},
Expand Down
2 changes: 1 addition & 1 deletion crates/net/eth-wire-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace = true
[dependencies]
# reth
reth-chainspec.workspace = true
reth-codecs.workspace = true
reth-codecs-derive.workspace = true
reth-primitives.workspace = true
alloy-rlp = { workspace = true, features = ["derive"] }
Expand Down Expand Up @@ -47,4 +48,3 @@ arbitrary = [
"dep:proptest-arbitrary-interop",
]
serde = ["dep:serde"]

13 changes: 9 additions & 4 deletions crates/net/eth-wire-types/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ use alloy_rlp::{RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWra
use reth_codecs_derive::{add_arbitrary_tests, derive_arbitrary};
#[cfg(any(test, feature = "arbitrary"))]
use reth_primitives::generate_valid_header;
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, HeadersDirection, B256};
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, B256};

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use crate::HeadersDirection;

/// A request for a peer to return block headers starting at the requested block.
/// The peer must return at most [`limit`](#structfield.limit) headers.
/// If the [`reverse`](#structfield.reverse) field is `true`, the headers will be returned starting
Expand Down Expand Up @@ -107,11 +109,14 @@ impl From<Vec<BlockBody>> for BlockBodies {

#[cfg(test)]
mod tests {
use crate::{message::RequestPair, BlockBodies, BlockHeaders, GetBlockBodies, GetBlockHeaders};
use crate::{
message::RequestPair, BlockBodies, BlockHeaders, GetBlockBodies, GetBlockHeaders,
HeadersDirection,
};
use alloy_rlp::{Decodable, Encodable};
use reth_primitives::{
hex, BlockHashOrNumber, Header, HeadersDirection, Signature, Transaction,
TransactionSigned, TxKind, TxLegacy, U256,
hex, BlockHashOrNumber, Header, Signature, Transaction, TransactionSigned, TxKind,
TxLegacy, U256,
};
use std::str::FromStr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use bytes::BufMut;
use reth_codecs::derive_arbitrary;
use serde::{Deserialize, Serialize};

pub use reth_primitives_traits::{Header, HeaderError, SealedHeader};

/// Represents the direction for a headers request depending on the `reverse` field of the request.
/// > The response must contain a number of block headers, of rising number when reverse is 0,
/// > falling when 1
Expand Down Expand Up @@ -88,8 +86,8 @@ impl From<HeadersDirection> for bool {
#[cfg(test)]
mod tests {
use super::*;
use crate::{address, b256, bloom, bytes, hex, Address, Bytes, B256, U256};
use alloy_rlp::{Decodable, Encodable};
use reth_primitives::{address, b256, bloom, bytes, hex, Address, Bytes, Header, B256, U256};
use std::str::FromStr;

// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
Expand Down
3 changes: 3 additions & 0 deletions crates/net/eth-wire-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub use version::EthVersion;
pub mod message;
pub use message::{EthMessage, EthMessageID, ProtocolMessage};

pub mod header;
pub use header::*;

pub mod blocks;
pub use blocks::*;

Expand Down
6 changes: 3 additions & 3 deletions crates/net/network/src/eth_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::{
use alloy_rlp::Encodable;
use futures::StreamExt;
use reth_eth_wire::{
BlockBodies, BlockHeaders, GetBlockBodies, GetBlockHeaders, GetNodeData, GetReceipts, NodeData,
Receipts,
BlockBodies, BlockHeaders, GetBlockBodies, GetBlockHeaders, GetNodeData, GetReceipts,
HeadersDirection, NodeData, Receipts,
};
use reth_network_p2p::error::RequestResult;
use reth_network_peers::PeerId;
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, HeadersDirection};
use reth_primitives::{BlockBody, BlockHashOrNumber, Header};
use reth_storage_api::{BlockReader, HeaderProvider, ReceiptProvider};
use std::{
future::Future,
Expand Down
3 changes: 1 addition & 2 deletions crates/net/network/tests/it/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy_node_bindings::Geth;
use alloy_provider::{ext::AdminApi, ProviderBuilder};
use futures::StreamExt;
use reth_discv4::Discv4Config;
use reth_eth_wire::DisconnectReason;
use reth_eth_wire::{DisconnectReason, HeadersDirection};
use reth_net_banlist::BanList;
use reth_network::{
test_utils::{enr_to_peer_id, NetworkEventStream, PeerConfig, Testnet, GETH_TIMEOUT},
Expand All @@ -16,7 +16,6 @@ use reth_network_p2p::{
sync::{NetworkSyncUpdater, SyncState},
};
use reth_network_peers::{mainnet_nodes, NodeRecord};
use reth_primitives::HeadersDirection;
use reth_provider::test_utils::NoopProvider;
use reth_transaction_pool::test_utils::testing_pool;
use secp256k1::SecretKey;
Expand Down
5 changes: 3 additions & 2 deletions crates/net/network/tests/it/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! Tests for eth related requests

use rand::Rng;
use reth_eth_wire::HeadersDirection;
use reth_network::{
test_utils::{NetworkEventStream, Testnet},
NetworkEvents,
Expand All @@ -12,8 +13,8 @@ use reth_network_p2p::{
headers::client::{HeadersClient, HeadersRequest},
};
use reth_primitives::{
Block, BlockBody, Bytes, Header, HeadersDirection, Signature, Transaction, TransactionSigned,
TxEip2930, TxKind, U256,
Block, BlockBody, Bytes, Header, Signature, Transaction, TransactionSigned, TxEip2930, TxKind,
U256,
};
use reth_provider::test_utils::MockEthProvider;
use std::sync::Arc;
Expand Down
5 changes: 2 additions & 3 deletions crates/net/p2p/src/full_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use crate::{
};
use futures::Stream;
use reth_consensus::{Consensus, ConsensusError};
use reth_eth_wire_types::HeadersDirection;
use reth_network_peers::WithPeerId;
use reth_primitives::{
BlockBody, GotExpected, Header, HeadersDirection, SealedBlock, SealedHeader, B256,
};
use reth_primitives::{BlockBody, GotExpected, Header, SealedBlock, SealedHeader, B256};
use std::{
cmp::Reverse,
collections::{HashMap, VecDeque},
Expand Down
4 changes: 2 additions & 2 deletions crates/net/p2p/src/headers/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{download::DownloadClient, error::PeerRequestResult, priority::Priority};
use futures::{Future, FutureExt};
pub use reth_eth_wire_types::BlockHeaders;
use reth_primitives::{BlockHashOrNumber, Header, HeadersDirection};
pub use reth_eth_wire_types::{BlockHeaders, HeadersDirection};
use reth_primitives::{BlockHashOrNumber, Header};
use std::{
fmt::Debug,
pin::Pin,
Expand Down
4 changes: 2 additions & 2 deletions crates/net/p2p/src/test_utils/full_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use crate::{
priority::Priority,
};
use parking_lot::Mutex;
use reth_eth_wire_types::HeadersDirection;
use reth_network_peers::{PeerId, WithPeerId};
use reth_primitives::{
BlockBody, BlockHashOrNumber, BlockNumHash, Header, HeadersDirection, SealedBlock,
SealedHeader, B256,
BlockBody, BlockHashOrNumber, BlockNumHash, Header, SealedBlock, SealedHeader, B256,
};
use std::{collections::HashMap, sync::Arc};

Expand Down
3 changes: 2 additions & 1 deletion crates/net/p2p/src/test_utils/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use crate::{
};
use futures::{Future, FutureExt, Stream, StreamExt};
use reth_consensus::{test_utils::TestConsensus, Consensus};
use reth_eth_wire_types::HeadersDirection;
use reth_network_peers::{PeerId, WithPeerId};
use reth_primitives::{Header, HeadersDirection, SealedHeader};
use reth_primitives::{Header, SealedHeader};
use std::{
fmt,
pin::Pin,
Expand Down
2 changes: 1 addition & 1 deletion crates/node/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ optimism = [
"reth-provider/optimism",
"reth-rpc-types-compat/optimism",
"reth-rpc-eth-api/optimism",
"reth-rpc-eth-types/optimism"
"reth-rpc-eth-types/optimism",
]

jemalloc = ["dep:tikv-jemalloc-ctl"]
Expand Down
4 changes: 2 additions & 2 deletions crates/node/core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use reth_chainspec::ChainSpec;
use reth_consensus_common::validation::validate_block_pre_execution;
use reth_network_p2p::{
bodies::client::BodiesClient,
headers::client::{HeadersClient, HeadersRequest},
headers::client::{HeadersClient, HeadersDirection, HeadersRequest},
priority::Priority,
};
use reth_primitives::{BlockHashOrNumber, HeadersDirection, SealedBlock, SealedHeader};
use reth_primitives::{BlockHashOrNumber, SealedBlock, SealedHeader};
use reth_rpc_types::engine::{JwtError, JwtSecret};
use std::{
env::VarError,
Expand Down
6 changes: 2 additions & 4 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ mod compression;
pub mod constants;
pub mod eip4844;
pub mod genesis;
pub mod header;
pub mod proofs;
mod receipt;
pub use reth_static_file_types as static_file;
Expand All @@ -47,13 +46,12 @@ pub use constants::{
MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
};
pub use genesis::{ChainConfig, Genesis, GenesisAccount};
pub use header::{Header, HeadersDirection, SealedHeader};
pub use receipt::{
gas_spent_by_transactions, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts,
};
pub use reth_primitives_traits::{
logs_bloom, Account, Bytecode, GotExpected, GotExpectedBoxed, Log, LogData, Request, Requests,
StorageEntry, Withdrawal, Withdrawals,
logs_bloom, Account, Bytecode, GotExpected, GotExpectedBoxed, Header, HeaderError, Log,
LogData, Request, Requests, SealedHeader, StorageEntry, Withdrawal, Withdrawals,
};
pub use static_file::StaticFileSegment;

Expand Down
Loading