Skip to content

Commit

Permalink
fix: temporarily skip caching non-portal nodes in discovery (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
njgheorghita authored Aug 13, 2024
1 parent abf05b0 commit e3b12f3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions portalnet/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,36 @@ impl Discovery {
let _ = talk_req_tx.send(talk_req).await;
}
Event::SessionEstablished(enr, socket_addr) => {
// TODO: this is a temporary fix to prevent caching of eth2 nodes
// and will be updated to a more stable solution as soon as it
// validates the theory of what is causing the issue on mainnet.
if enr.get(ENR_PORTAL_CLIENT_KEY).is_none() {
debug!(
enr = ?enr,
"discv5 session established with node that does not have a portal client key, not caching"
);
continue;
}
if let Some(old) = node_addr_cache.write().put(
enr.node_id(),
NodeAddress {
enr: enr.clone(),
socket_addr,
},
) {
tracing::debug!(
debug!(
old = ?(old.enr, old.socket_addr),
new = ?(enr, socket_addr),
"cached node address updated"
);
} else {
tracing::debug!(addr = ?(enr, socket_addr), "node address cached");
debug!(addr = ?(enr, socket_addr), "node address cached");
}
}
_ => continue,
}
}
});

Ok(talk_req_rx)
}

Expand Down

0 comments on commit e3b12f3

Please sign in to comment.