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): plug discv5 crate into network #7446

Merged
merged 20 commits into from
Apr 4, 2024
Merged

Conversation

emhane
Copy link
Member

@emhane emhane commented Apr 3, 2024

  • Starts Discv5 in reth-network.
  • Streams discv5 events
  • Adds peers discovered by dns to discv5
  • Extends peer banning to discv5

Shortcoming:

Unable to update discv5 fork id out of the box. Sigp/discv5 only exposes method enr_insert, which internally rlp encodes the given value. Conversion from ForkId into BE bytes must be implemented, I started this but moved it to another branch, since this doesn't effect any other network than L1 atm. This is becauseForkId update isn't configured for other keys than 'eth', and fixing that would be out of scope.

update: sigp/discv5 has moved to alloy_rlp on master

@emhane emhane marked this pull request as draft April 3, 2024 17:13
@emhane emhane marked this pull request as ready for review April 3, 2024 18:08
@emhane emhane requested review from mattsse, Rjected and DaniPopes and removed request for mattsse April 3, 2024 18:08
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.

great!
this looks pretty clean!

crates/net/network/src/discovery.rs Show resolved Hide resolved
crates/net/network/src/discovery.rs Outdated Show resolved Hide resolved
crates/net/network/src/config.rs Outdated Show resolved Hide resolved
@emhane emhane requested a review from mattsse April 3, 2024 22:13
@DaniPopes
Copy link
Member

ENR and secp256k1 is updated here: #7000

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!
I really like how this has turned out.

Discv4::bind(discovery_addr, local_enr, sk, disc_config).await.map_err(|err| {
NetworkError::from_io_error(err, ServiceKind::Discovery(discovery_addr))
})?;
Discv4::bind(discovery_v4_addr, local_enr, sk, disc_config).await.map_err(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get your point that this setup is now even more convoluted.

this is okay for this PR.
but we could make this a bit nicer separately and run the two setups concurrently.
perhaps a match over both configs would be "more" ergonomic here

Copy link
Member Author

Choose a reason for hiding this comment

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

on the down side, when running both versions, this means a significant overhead for the reth node. it will be having double up discovery connections, once on each version, for one unique mempool peer. on the bright side, from an ethereum wide perspective, it will significantly help peer discovery, since finding specific peers becomes easier the more well connected nodes exist in the network. for example DAS will prosper form this.

not sure if it improves readability, since the two versions now have no dependency on each other, i.e. discv4 is run the same with discv5 as without discv5 and vv.

@mattsse mattsse added A-networking Related to networking in general C-enhancement New feature or request labels Apr 4, 2024
@emhane emhane enabled auto-merge April 4, 2024 12:09
@emhane emhane added this pull request to the merge queue Apr 4, 2024
@emhane emhane mentioned this pull request Apr 4, 2024
Merged via the queue into main with commit 633806e Apr 4, 2024
27 checks passed
@emhane emhane deleted the emhane/discv5-network branch April 4, 2024 12:32
@emhane emhane mentioned this pull request Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Related to networking in general C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants