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(net): enable rust.unnameable-types = "warn" lint #9505

Merged
merged 4 commits into from
Jul 16, 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.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ rust.unreachable_pub = "warn"
rust.unused_must_use = "deny"
rust.rust_2018_idioms = { level = "deny", priority = -1 }
rustdoc.all = "warn"
# rust.unnameable-types = "warn"
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this and add it to the Cargo.toml of each of the crates in net instead under [lints]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I don't think this is possible, I got the error when make lint :
cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints

Copy link
Collaborator

Choose a reason for hiding this comment

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

we can keep this here until we can finally enable this and continue prs crate by crate imo


[workspace.lints.clippy]
# These are some of clippy's nursery (i.e., experimental) lints that we like.
Expand Down
2 changes: 1 addition & 1 deletion crates/net/dns/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{
};
pub use config::DnsDiscoveryConfig;
use enr::Enr;
use error::ParseDnsEntryError;
pub use error::ParseDnsEntryError;
use reth_ethereum_forks::{EnrForkIdEntry, ForkId};
use reth_network_peers::{pk2id, NodeRecord};
use schnellru::{ByLength, LruMap};
Expand Down
2 changes: 1 addition & 1 deletion crates/net/ecies/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub enum ECIESErrorImpl {
/// decode a message from the (partially filled) buffer.
#[error("stream closed due to not being readable")]
UnreadableStream,
// Error when data is not received from peer for a prolonged period.
/// Error when data is not received from peer for a prolonged period.
#[error("never received data from remote peer")]
StreamTimeout,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/net/ecies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod stream;
pub mod util;

mod error;
pub use error::ECIESError;
pub use error::{ECIESError, ECIESErrorImpl};

pub mod codec;

Expand Down
2 changes: 2 additions & 0 deletions crates/net/eth-wire/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ pub use crate::{
// Re-export wire types
#[doc(inline)]
pub use reth_eth_wire_types::*;

pub use disconnect::UnknownDisconnectReason;
5 changes: 5 additions & 0 deletions crates/net/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,10 @@ pub use session::{

pub use transactions::{FilterAnnouncement, MessageFilter, ValidateTx68};

pub use flattened_response::FlattenedResponse;
pub use manager::DiscoveredEvent;
pub use metrics::TxTypesCounter;
pub use reth_eth_wire::{DisconnectReason, HelloMessageWithProtocols};
pub use reth_network_types::{PeersConfig, SessionsConfig};
pub use session::EthRlpxConnection;
pub use swarm::NetworkConnectionState;
22 changes: 21 additions & 1 deletion crates/net/network/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,9 +1077,29 @@ pub enum NetworkEvent {
PeerRemoved(PeerId),
}

/// Represents events related to peer discovery in the network.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DiscoveredEvent {
EventQueued { peer_id: PeerId, addr: PeerAddr, fork_id: Option<ForkId> },
/// Indicates that a new peer has been discovered and queued for potential connection.
///
/// This event is generated when the system becomes aware of a new peer
/// but hasn't yet established a connection.
///
/// # Fields
///
/// * `peer_id` - The unique identifier of the discovered peer.
/// * `addr` - The network address of the discovered peer.
/// * `fork_id` - An optional identifier for the fork that this peer is associated with. `None`
/// if the peer is not associated with a specific fork.
EventQueued {
/// The unique identifier of the discovered peer.
peer_id: PeerId,
/// The network address of the discovered peer.
addr: PeerAddr,
/// An optional identifier for the fork that this peer is associated with.
/// `None` if the peer is not associated with a specific fork.
fork_id: Option<ForkId>,
},
}

#[derive(Debug, Default)]
Expand Down
13 changes: 13 additions & 0 deletions crates/net/network/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,25 @@ pub struct AnnouncedTxTypesMetrics {
pub(crate) eip7702: Histogram,
}

/// Counts the number of transactions by their type in a block or collection.
///
/// This struct keeps track of the count of different transaction types
/// as defined by various Ethereum Improvement Proposals (EIPs).
#[derive(Debug, Default)]
pub struct TxTypesCounter {
/// Count of legacy transactions (pre-EIP-2718).
pub(crate) legacy: usize,

/// Count of transactions conforming to EIP-2930 (Optional access lists).
pub(crate) eip2930: usize,

/// Count of transactions conforming to EIP-1559 (Fee market change).
pub(crate) eip1559: usize,

/// Count of transactions conforming to EIP-4844 (Shard Blob Transactions).
pub(crate) eip4844: usize,

/// Count of transactions conforming to EIP-7702 (Restricted Storage Windows).
pub(crate) eip7702: usize,
}

Expand Down
6 changes: 4 additions & 2 deletions crates/net/network/src/session/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ pub type EthSatelliteConnection =

/// Connection types that support the ETH protocol.
///
/// Either a [`EthPeerConnection`] or an [`EthSatelliteConnection`].
/// This can be either:
/// - A connection that only supports the ETH protocol
/// - A connection that supports the ETH protocol and at least one other `RLPx` protocol
// This type is boxed because the underlying stream is ~6KB,
// mostly coming from `P2PStream`'s `snap::Encoder` (2072), and `ECIESStream` (3600).
#[derive(Debug)]
pub enum EthRlpxConnection {
/// A That only supports the ETH protocol.
/// A connection that only supports the ETH protocol.
EthOnly(Box<EthPeerConnection>),
/// A connection that supports the ETH protocol and __at least one other__ `RLPx` protocol.
Satellite(Box<EthSatelliteConnection>),
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ mod counter;
mod handle;
pub use crate::message::PeerRequestSender;
use crate::protocol::{IntoRlpxSubProtocol, RlpxSubProtocolHandlers, RlpxSubProtocols};
pub use conn::EthRlpxConnection;
pub use handle::{
ActiveSessionHandle, ActiveSessionMessage, PendingSessionEvent, PendingSessionHandle,
SessionCommand,
};
use reth_eth_wire::multiplex::RlpxProtocolMultiplexer;
pub use reth_network_api::{Direction, PeerInfo};

/// Internal identifier for active sessions.
#[derive(Debug, Clone, Copy, PartialOrd, PartialEq, Eq, Hash)]
pub struct SessionId(usize);
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pub use init::{
enr_to_peer_id, unused_port, unused_tcp_addr, unused_tcp_and_udp_port, unused_tcp_udp,
unused_udp_addr, unused_udp_port, GETH_TIMEOUT,
};
pub use testnet::{NetworkEventStream, Peer, PeerConfig, PeerHandle, Testnet};
pub use testnet::{NetworkEventStream, Peer, PeerConfig, PeerHandle, Testnet, TestnetHandle};
Loading