mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
move header.rs to eth-wire-types (#9345)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -7155,6 +7155,7 @@ dependencies = [
|
||||
"proptest-derive 0.5.0",
|
||||
"rand 0.8.5",
|
||||
"reth-chainspec",
|
||||
"reth-codecs",
|
||||
"reth-codecs-derive",
|
||||
"reth-primitives",
|
||||
"serde",
|
||||
|
||||
@ -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};
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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},
|
||||
|
||||
@ -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"] }
|
||||
@ -47,4 +48,3 @@ arbitrary = [
|
||||
"dep:proptest-arbitrary-interop",
|
||||
]
|
||||
serde = ["dep:serde"]
|
||||
|
||||
|
||||
@ -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
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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::*;
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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},
|
||||
@ -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;
|
||||
|
||||
@ -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,
|
||||
@ -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;
|
||||
|
||||
@ -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},
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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};
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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"]
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user