Skip to content

Commit

Permalink
fix: use net::discv5 for reth's discv5 tracing target namespace (reve…
Browse files Browse the repository at this point in the history
…rts #12045) (#12151)
  • Loading branch information
zilayo authored Oct 28, 2024
1 parent 4621578 commit 0297b8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions crates/net/discv5/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ pub fn discv5_sockets_wrt_rlpx_addr(
discv5_addr_ipv6.map(|ip| SocketAddrV6::new(ip, discv5_port_ipv6, 0, 0));

if let Some(discv5_addr) = discv5_addr_ipv4 {
warn!(target: "discv5",
warn!(target: "net::discv5",
%discv5_addr,
%rlpx_addr,
"Overwriting discv5 IPv4 address with RLPx IPv4 address, limited to one advertised IP address per IP version"
Expand All @@ -429,7 +429,7 @@ pub fn discv5_sockets_wrt_rlpx_addr(
discv5_addr_ipv4.map(|ip| SocketAddrV4::new(ip, discv5_port_ipv4));

if let Some(discv5_addr) = discv5_addr_ipv6 {
warn!(target: "discv5",
warn!(target: "net::discv5",
%discv5_addr,
%rlpx_addr,
"Overwriting discv5 IPv6 address with RLPx IPv6 address, limited to one advertised IP address per IP version"
Expand Down
30 changes: 15 additions & 15 deletions crates/net/discv5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ impl Discv5 {
/// CAUTION: The value **must** be rlp encoded
pub fn set_eip868_in_local_enr(&self, key: Vec<u8>, rlp: Bytes) {
let Ok(key_str) = std::str::from_utf8(&key) else {
error!(target: "discv5",
error!(target: "net::discv5",
err="key not utf-8",
"failed to update local enr"
);
return
};
if let Err(err) = self.discv5.enr_insert(key_str, &rlp) {
error!(target: "discv5",
error!(target: "net::discv5",
%err,
"failed to update local enr"
);
Expand Down Expand Up @@ -131,7 +131,7 @@ impl Discv5 {
self.discv5.ban_node(&node_id, None);
self.ban_ip(ip);
}
Err(err) => error!(target: "discv5",
Err(err) => error!(target: "net::discv5",
%err,
"failed to ban peer"
),
Expand Down Expand Up @@ -167,7 +167,7 @@ impl Discv5 {
//
let (enr, bc_enr, fork_key, rlpx_ip_mode) = build_local_enr(sk, &discv5_config);

trace!(target: "discv5",
trace!(target: "net::discv5",
?enr,
"local ENR"
);
Expand Down Expand Up @@ -271,7 +271,7 @@ impl Discv5 {
// to them over RLPx, to be compatible with EL discv5 implementations that don't
// enforce this security measure.

trace!(target: "discv5",
trace!(target: "net::discv5",
?enr,
%socket,
"discovered unverifiable enr, source socket doesn't match socket advertised in ENR"
Expand All @@ -296,7 +296,7 @@ impl Discv5 {
let node_record = match self.try_into_reachable(enr, socket) {
Ok(enr_bc) => enr_bc,
Err(err) => {
trace!(target: "discv5",
trace!(target: "net::discv5",
%err,
?enr,
"discovered peer is unreachable"
Expand All @@ -308,7 +308,7 @@ impl Discv5 {
}
};
if let FilterOutcome::Ignore { reason } = self.filter_discovered_peer(enr) {
trace!(target: "discv5",
trace!(target: "net::discv5",
?enr,
reason,
"filtered out discovered peer"
Expand All @@ -324,7 +324,7 @@ impl Discv5 {
.then(|| self.get_fork_id(enr).ok())
.flatten();

trace!(target: "discv5",
trace!(target: "net::discv5",
?fork_id,
?enr,
"discovered peer"
Expand Down Expand Up @@ -491,7 +491,7 @@ pub async fn bootstrap(
bootstrap_nodes: HashSet<BootNode>,
discv5: &Arc<discv5::Discv5>,
) -> Result<(), Error> {
trace!(target: "discv5",
trace!(target: "net::discv5",
?bootstrap_nodes,
"adding bootstrap nodes .."
);
Expand All @@ -508,7 +508,7 @@ pub async fn bootstrap(
let discv5 = discv5.clone();
enr_requests.push(async move {
if let Err(err) = discv5.request_enr(enode.to_string()).await {
debug!(target: "discv5",
debug!(target: "net::discv5",
?enode,
%err,
"failed adding boot node"
Expand Down Expand Up @@ -545,7 +545,7 @@ pub fn spawn_populate_kbuckets_bg(
for i in (0..bootstrap_lookup_countdown).rev() {
let target = discv5::enr::NodeId::random();

trace!(target: "discv5",
trace!(target: "net::discv5",
%target,
bootstrap_boost_runs_countdown=i,
lookup_interval=format!("{:#?}", pulse_lookup_interval),
Expand All @@ -563,7 +563,7 @@ pub fn spawn_populate_kbuckets_bg(
// selection (ref kademlia)
let target = get_lookup_target(kbucket_index, local_node_id);

trace!(target: "discv5",
trace!(target: "net::discv5",
%target,
lookup_interval=format!("{:#?}", lookup_interval),
"starting periodic lookup query"
Expand Down Expand Up @@ -628,11 +628,11 @@ pub async fn lookup(
);

match discv5.find_node(target).await {
Err(err) => trace!(target: "discv5",
Err(err) => trace!(target: "net::discv5",
%err,
"lookup query failed"
),
Ok(peers) => trace!(target: "discv5",
Ok(peers) => trace!(target: "net::discv5",
target=format!("{:#?}", target),
peers_count=peers.len(),
peers=format!("[{:#}]", peers.iter()
Expand All @@ -645,7 +645,7 @@ pub async fn lookup(
// `Discv5::connected_peers` can be subset of sessions, not all peers make it
// into kbuckets, e.g. incoming sessions from peers with
// unreachable enrs
debug!(target: "discv5",
debug!(target: "net::discv5",
connected_peers=discv5.connected_peers(),
"connected peers in routing table"
);
Expand Down

0 comments on commit 0297b8f

Please sign in to comment.