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

feat(discv5): open dns for discv5 #7328

Merged
merged 18 commits into from
Mar 27, 2024
Merged

feat(discv5): open dns for discv5 #7328

merged 18 commits into from
Mar 27, 2024

Conversation

emhane
Copy link
Member

@emhane emhane commented Mar 25, 2024

To add a node to sigp/discv5, a signed node record is needed.

while let Some(Poll::Ready(Some(update))) =
self.dns_discovery_updates.as_mut().map(|updates| updates.poll_next_unpin(cx))
{
self.add_discv4_node(update.node_record);
self.on_node_record_update(update.node_record, update.fork_id);
}

Alternative solutions: parse unsigned node record into libp2p Multiaddr type and request its ENR again. Why not use this solution? Since the dns service is already handling type Enr<SecretKey>, it's unnecessary to make the extra RTT to re-request the peer's ENR, before the peer can be used in a lookup query.

Sequel: Since dns/resolver already is generic over ENR key type, it makes sense to generalise the whole dns crate w.r.t. key type. This would save the extra work of encoding an Enr<SecretKey> and decoding it as an Enr<CombindeKey>, which is the type sigp/discv5 uses. Alt: address sigp/discv5#233.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

isn't the only thing we need a new enr field in the DnsNodeRecordUpdate?

so that we could also pipe the enrs to discv5 here:

while let Some(Poll::Ready(Some(update))) =
self.dns_discovery_updates.as_mut().map(|updates| updates.poll_next_unpin(cx))
{
self.add_discv4_node(update.node_record);

@emhane
Copy link
Member Author

emhane commented Mar 25, 2024

isn't the only thing we need a new enr field in the DnsNodeRecordUpdate?

so that we could also pipe the enrs to discv5 here:

while let Some(Poll::Ready(Some(update))) =
self.dns_discovery_updates.as_mut().map(|updates| updates.poll_next_unpin(cx))
{
self.add_discv4_node(update.node_record);

didn't want to break the public api of the crate, thoughts?

@mattsse
Copy link
Collaborator

mattsse commented Mar 25, 2024

imo this would be a very simple change and gets us exactly what we want.

no concerns re breaking changes

@emhane
Copy link
Member Author

emhane commented Mar 25, 2024

imo this would be a very simple change and gets us exactly what we want.

no concerns re breaking changes

in that case I wouldn't strip the ENR of its signature at all, i.e. don't convert from Enr type to NodeRecord type, it is only done to pass the node record up to the app anyway. will this change be welcomed?

@emhane
Copy link
Member Author

emhane commented Mar 25, 2024

re-request review @mattsse @Rjected

crates/net/dns/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm,

optional suggestion for error variant,
not super happy with the NodeRecord type in general because the only reason we have it under rpc is that we can reuse it in a few rpc functions

but we'll try to push it to alloy so we don't have to deal with it here anymore

ref alloy-rs/alloy#405

crates/rpc/rpc-types/src/net.rs Outdated Show resolved Hide resolved
crates/net/dns/src/lib.rs Outdated Show resolved Hide resolved
crates/primitives/src/net.rs Outdated Show resolved Hide resolved
crates/primitives/src/net.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-types/src/net.rs Outdated Show resolved Hide resolved
@emhane emhane requested a review from mattsse March 27, 2024 16:31
crates/primitives/src/net.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@emhane emhane added this pull request to the merge queue Mar 27, 2024
@emhane emhane removed this pull request from the merge queue due to a manual request Mar 27, 2024
@emhane emhane added this pull request to the merge queue Mar 27, 2024
Merged via the queue into main with commit 415efc8 Mar 27, 2024
28 checks passed
@emhane emhane deleted the emhane/dns-discv5 branch March 27, 2024 20:08
This was referenced Mar 30, 2024
Ruteri pushed a commit to Ruteri/reth that referenced this pull request Apr 17, 2024
Ruteri pushed a commit to Ruteri/reth that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants