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

fix: temporarily skip caching non-portal nodes in discovery #1379

Merged
merged 1 commit into from
Aug 13, 2024
Merged
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
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
Loading