mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Move reputation types from reth-network-api to reth-network-types (#9914)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
use crate::{fetch::DownloadRequest, flattened_response::FlattenedResponse, peers::PeersHandle};
|
||||
use futures::{future, future::Either};
|
||||
|
||||
use reth_network_api::ReputationChangeKind;
|
||||
use reth_network_p2p::{
|
||||
bodies::client::{BodiesClient, BodiesFut},
|
||||
download::DownloadClient,
|
||||
@ -12,6 +11,7 @@ use reth_network_p2p::{
|
||||
priority::Priority,
|
||||
};
|
||||
use reth_network_peers::PeerId;
|
||||
use reth_network_types::ReputationChangeKind;
|
||||
use reth_primitives::{Header, B256};
|
||||
use std::sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
use crate::{message::BlockRequest, peers::PeersHandle};
|
||||
use futures::StreamExt;
|
||||
use reth_eth_wire::{GetBlockBodies, GetBlockHeaders};
|
||||
use reth_network_api::ReputationChangeKind;
|
||||
use reth_network_p2p::{
|
||||
error::{EthResponseValidator, PeerRequestResult, RequestError, RequestResult},
|
||||
headers::client::HeadersRequest,
|
||||
priority::Priority,
|
||||
};
|
||||
use reth_network_peers::PeerId;
|
||||
use reth_network_types::ReputationChangeKind;
|
||||
use reth_primitives::{BlockBody, Header, B256};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
|
||||
@ -15,6 +15,38 @@
|
||||
//! (IP+port) of our node is published via discovery, remote peers can initiate inbound connections
|
||||
//! to the local node. Once a (tcp) connection is established, both peers start to authenticate a [RLPx session](https://github.com/ethereum/devp2p/blob/master/rlpx.md) via a handshake. If the handshake was successful, both peers announce their capabilities and are now ready to exchange sub-protocol messages via the `RLPx` session.
|
||||
|
||||
use std::{
|
||||
net::SocketAddr,
|
||||
path::Path,
|
||||
pin::Pin,
|
||||
sync::{
|
||||
atomic::{AtomicU64, AtomicUsize, Ordering},
|
||||
Arc,
|
||||
},
|
||||
task::{Context, Poll},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use futures::{Future, StreamExt};
|
||||
use parking_lot::Mutex;
|
||||
use reth_eth_wire::{
|
||||
capability::{Capabilities, CapabilityMessage},
|
||||
DisconnectReason, EthVersion, Status,
|
||||
};
|
||||
use reth_fs_util::{self as fs, FsPathError};
|
||||
use reth_metrics::common::mpsc::UnboundedMeteredSender;
|
||||
use reth_network_api::{EthProtocolInfo, NetworkStatus, PeerInfo};
|
||||
use reth_network_peers::{NodeRecord, PeerId};
|
||||
use reth_network_types::ReputationChangeKind;
|
||||
use reth_primitives::ForkId;
|
||||
use reth_storage_api::BlockNumReader;
|
||||
use reth_tasks::shutdown::GracefulShutdown;
|
||||
use reth_tokio_util::EventSender;
|
||||
use secp256k1::SecretKey;
|
||||
use tokio::sync::mpsc::{self, error::TrySendError};
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
use tracing::{debug, error, trace, warn};
|
||||
|
||||
use crate::{
|
||||
budget::{DEFAULT_BUDGET_TRY_DRAIN_NETWORK_HANDLE_CHANNEL, DEFAULT_BUDGET_TRY_DRAIN_SWARM},
|
||||
config::NetworkConfig,
|
||||
@ -35,35 +67,6 @@ use crate::{
|
||||
transactions::NetworkTransactionEvent,
|
||||
FetchClient, NetworkBuilder,
|
||||
};
|
||||
use futures::{Future, StreamExt};
|
||||
use parking_lot::Mutex;
|
||||
use reth_eth_wire::{
|
||||
capability::{Capabilities, CapabilityMessage},
|
||||
DisconnectReason, EthVersion, Status,
|
||||
};
|
||||
use reth_fs_util::{self as fs, FsPathError};
|
||||
use reth_metrics::common::mpsc::UnboundedMeteredSender;
|
||||
use reth_network_api::{EthProtocolInfo, NetworkStatus, PeerInfo, ReputationChangeKind};
|
||||
use reth_network_peers::{NodeRecord, PeerId};
|
||||
use reth_primitives::ForkId;
|
||||
use reth_storage_api::BlockNumReader;
|
||||
use reth_tasks::shutdown::GracefulShutdown;
|
||||
use reth_tokio_util::EventSender;
|
||||
use secp256k1::SecretKey;
|
||||
use std::{
|
||||
net::SocketAddr,
|
||||
path::Path,
|
||||
pin::Pin,
|
||||
sync::{
|
||||
atomic::{AtomicU64, AtomicUsize, Ordering},
|
||||
Arc,
|
||||
},
|
||||
task::{Context, Poll},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tokio::sync::mpsc::{self, error::TrySendError};
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
use tracing::{debug, error, trace, warn};
|
||||
|
||||
#[cfg_attr(doc, aquamarine::aquamarine)]
|
||||
/// Manages the _entire_ state of the network.
|
||||
|
||||
@ -14,11 +14,11 @@ use parking_lot::Mutex;
|
||||
use reth_discv4::Discv4;
|
||||
use reth_eth_wire::{DisconnectReason, NewBlock, NewPooledTransactionHashes, SharedTransactions};
|
||||
use reth_network_api::{
|
||||
NetworkError, NetworkInfo, NetworkStatus, PeerInfo, PeerKind, Peers, PeersInfo, Reputation,
|
||||
ReputationChangeKind,
|
||||
NetworkError, NetworkInfo, NetworkStatus, PeerInfo, PeerKind, Peers, PeersInfo,
|
||||
};
|
||||
use reth_network_p2p::sync::{NetworkSyncUpdater, SyncState, SyncStateProvider};
|
||||
use reth_network_peers::{NodeRecord, PeerId};
|
||||
use reth_network_types::{Reputation, ReputationChangeKind};
|
||||
use reth_primitives::{Head, TransactionSigned, B256};
|
||||
use reth_tokio_util::{EventSender, EventStream};
|
||||
use secp256k1::SecretKey;
|
||||
|
||||
@ -8,7 +8,7 @@ use crate::{
|
||||
use futures::StreamExt;
|
||||
use reth_eth_wire::{errors::EthStreamError, DisconnectReason};
|
||||
use reth_net_banlist::BanList;
|
||||
use reth_network_api::{PeerKind, ReputationChangeKind};
|
||||
use reth_network_api::PeerKind;
|
||||
use reth_network_peers::{NodeRecord, PeerId};
|
||||
use reth_network_types::{
|
||||
peers::{
|
||||
@ -17,7 +17,7 @@ use reth_network_types::{
|
||||
is_banned_reputation, DEFAULT_REPUTATION, MAX_TRUSTED_PEER_REPUTATION_CHANGE,
|
||||
},
|
||||
},
|
||||
ConnectionsConfig, PeersConfig, ReputationChangeWeights,
|
||||
ConnectionsConfig, PeersConfig, ReputationChangeKind, ReputationChangeWeights,
|
||||
};
|
||||
use reth_primitives::ForkId;
|
||||
use std::{
|
||||
@ -1326,24 +1326,6 @@ impl Display for InboundConnectionError {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::PeersManager;
|
||||
use crate::{
|
||||
peers::{
|
||||
ConnectionInfo, InboundConnectionError, PeerAction, PeerAddr, PeerBackoffDurations,
|
||||
PeerConnectionState,
|
||||
},
|
||||
session::PendingSessionHandshakeError,
|
||||
PeersConfig,
|
||||
};
|
||||
use reth_eth_wire::{
|
||||
errors::{EthHandshakeError, EthStreamError, P2PHandshakeError, P2PStreamError},
|
||||
DisconnectReason,
|
||||
};
|
||||
use reth_net_banlist::BanList;
|
||||
use reth_network_api::{Direction, ReputationChangeKind};
|
||||
use reth_network_peers::{PeerId, TrustedPeer};
|
||||
use reth_network_types::{peers::reputation::DEFAULT_REPUTATION, BackoffKind};
|
||||
use reth_primitives::B512;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
future::{poll_fn, Future},
|
||||
@ -1353,8 +1335,30 @@ mod tests {
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use reth_eth_wire::{
|
||||
errors::{EthHandshakeError, EthStreamError, P2PHandshakeError, P2PStreamError},
|
||||
DisconnectReason,
|
||||
};
|
||||
use reth_net_banlist::BanList;
|
||||
use reth_network_api::Direction;
|
||||
use reth_network_peers::{PeerId, TrustedPeer};
|
||||
use reth_network_types::{
|
||||
peers::reputation::DEFAULT_REPUTATION, BackoffKind, ReputationChangeKind,
|
||||
};
|
||||
use reth_primitives::B512;
|
||||
use url::Host;
|
||||
|
||||
use super::PeersManager;
|
||||
use crate::{
|
||||
peers::{
|
||||
ConnectionInfo, InboundConnectionError, PeerAction, PeerAddr, PeerBackoffDurations,
|
||||
PeerConnectionState,
|
||||
},
|
||||
session::PendingSessionHandshakeError,
|
||||
PeersConfig,
|
||||
};
|
||||
|
||||
struct PeerActionFuture<'a> {
|
||||
peers: &'a mut PeersManager,
|
||||
}
|
||||
|
||||
@ -1,19 +1,5 @@
|
||||
//! Transactions management for the p2p network.
|
||||
|
||||
use crate::{
|
||||
budget::{
|
||||
DEFAULT_BUDGET_TRY_DRAIN_NETWORK_TRANSACTION_EVENTS,
|
||||
DEFAULT_BUDGET_TRY_DRAIN_PENDING_POOL_IMPORTS, DEFAULT_BUDGET_TRY_DRAIN_POOL_IMPORTS,
|
||||
DEFAULT_BUDGET_TRY_DRAIN_STREAM,
|
||||
},
|
||||
cache::LruCache,
|
||||
duration_metered_exec,
|
||||
manager::NetworkEvent,
|
||||
message::{PeerRequest, PeerRequestSender},
|
||||
metered_poll_nested_stream_with_budget,
|
||||
metrics::{TransactionsManagerMetrics, NETWORK_POOL_TRANSACTIONS_SCOPE},
|
||||
NetworkEvents, NetworkHandle,
|
||||
};
|
||||
use futures::{stream::FuturesUnordered, Future, StreamExt};
|
||||
use reth_eth_wire::{
|
||||
EthVersion, GetPooledTransactions, HandleMempoolData, HandleVersionedMempoolData,
|
||||
@ -21,12 +7,13 @@ use reth_eth_wire::{
|
||||
PooledTransactions, RequestTxHashes, Transactions,
|
||||
};
|
||||
use reth_metrics::common::mpsc::UnboundedMeteredReceiver;
|
||||
use reth_network_api::{Peers, ReputationChangeKind};
|
||||
use reth_network_api::Peers;
|
||||
use reth_network_p2p::{
|
||||
error::{RequestError, RequestResult},
|
||||
sync::SyncStateProvider,
|
||||
};
|
||||
use reth_network_peers::PeerId;
|
||||
use reth_network_types::ReputationChangeKind;
|
||||
use reth_primitives::{
|
||||
FromRecoveredPooledTransaction, PooledTransactionsElement, TransactionSigned, TxHash, B256,
|
||||
};
|
||||
@ -50,6 +37,21 @@ use tokio::sync::{mpsc, oneshot, oneshot::error::RecvError};
|
||||
use tokio_stream::wrappers::{ReceiverStream, UnboundedReceiverStream};
|
||||
use tracing::{debug, trace};
|
||||
|
||||
use crate::{
|
||||
budget::{
|
||||
DEFAULT_BUDGET_TRY_DRAIN_NETWORK_TRANSACTION_EVENTS,
|
||||
DEFAULT_BUDGET_TRY_DRAIN_PENDING_POOL_IMPORTS, DEFAULT_BUDGET_TRY_DRAIN_POOL_IMPORTS,
|
||||
DEFAULT_BUDGET_TRY_DRAIN_STREAM,
|
||||
},
|
||||
cache::LruCache,
|
||||
duration_metered_exec,
|
||||
manager::NetworkEvent,
|
||||
message::{PeerRequest, PeerRequestSender},
|
||||
metered_poll_nested_stream_with_budget,
|
||||
metrics::{TransactionsManagerMetrics, NETWORK_POOL_TRANSACTIONS_SCOPE},
|
||||
NetworkEvents, NetworkHandle,
|
||||
};
|
||||
|
||||
/// Aggregation on configurable parameters for [`TransactionsManager`].
|
||||
pub mod config;
|
||||
/// Default and spec'd bounds.
|
||||
|
||||
Reference in New Issue
Block a user