-
Notifications
You must be signed in to change notification settings - Fork 162
feat(l1): store validated ENR from handshake in peer table #6109
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,6 +303,11 @@ impl DiscoveryServer { | |
| .secp256k1 | ||
| .and_then(|pk| PublicKey::from_slice(pk.as_bytes()).ok()); | ||
|
|
||
| // Add the peer to the peer table | ||
| self.peer_table | ||
| .new_contact_records(vec![record.clone()], self.local_node.node_id()) | ||
| .await?; | ||
|
Comment on lines
+306
to
+309
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Peer added to table before verifying node_id matches src_id (line 315). If verification fails at line 317, the invalid peer remains in the table. Move this call after the node_id verification (after line 319). Prompt To Fix With AIThis is a comment left during a code review.
Path: crates/networking/p2p/discv5/server.rs
Line: 306:309
Comment:
Peer added to table before verifying node_id matches src_id (line 315). If verification fails at line 317, the invalid peer remains in the table.
Move this call after the node_id verification (after line 319).
How can I resolve this? If you propose a fix, please make it concise.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Peer added before full handshake authentication. This call runs before the Move this call after the id-signature verification at line 346 — there's no reason to store anything until the handshake is fully authenticated. |
||
|
|
||
| // Verify that the ENR's public key matches the claimed src_id | ||
| if let Some(pk) = &pubkey { | ||
| let uncompressed = pk.serialize_uncompressed(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was already implemented more thoroughly on a previous PR
This PR will conflict once that merges. Consider rebasing on top of it and focusing only on the
handle_handshakeinsertion.