paradigmxyz / reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
https://reth.rs/
Apache License 2.0
3.39k stars 858 forks source link

Implement p2p related tools #7411

Open int88 opened 2 months ago

int88 commented 2 months ago

Describe the feature

There are some p2p related tools geth, like:

https://geth.ethereum.org/docs/tools/devp2p

https://github.com/ethereum/go-ethereum/tree/master/p2p/simulations

If it's meaningful to implement related tools in reth, I'd like to do it!

@mattsse @emhane WDTY?

Additional context

No response

mattsse commented 2 months ago

sgtm!

if you want, you can add these as standalone crates first

int88 commented 2 months ago

devp2p command TODO list:

emhane commented 1 week ago

for sure! really nice idea

emhane commented 1 week ago

I'd tackle each todo as a separate new issue, adding to task list here. that way it's easier for us to review, more overseeable to give you specific hints for impl in that issue, and less merge conflicts with main for you since each topic branch would be short-lived.

a hint for discv5 already, is to use this method https://github.com/paradigmxyz/reth/blob/ef3f67743d517b2b15692949efae4671168bccbd/crates/net/discv5/src/lib.rs#L381-L387 and then read the sigp Discv5 public api thoroughly, should be possible to impl all commands with those existing methods https://github.com/sigp/discv5/blob/master/src/discv5.rs

make sure to try this tool out first https://github.com/AgeManning/discv5-cli, no need to impl same thing again in reth imo @int88

Rjected commented 1 week ago

make sure to try this tool out first https://github.com/AgeManning/discv5-cli, no need to impl same thing again in reth imo

agree, as well as enr-cli: https://github.com/agemanning/enr-cli

cargo install makes using these really easy

emhane commented 1 week ago

agree, as well as enr-cli: https://github.com/agemanning/enr-cli

true this tool exists too

I updated your list @int88 based on review https://github.com/paradigmxyz/reth/pull/8403#pullrequestreview-2102458098 and https://github.com/paradigmxyz/reth/pull/8403#pullrequestreview-2102435753

int88 commented 1 week ago

Thanks for all of your kind reviews @mattsse @Rjected @emhane .

So I would implement the commands filtered by @emhane .

One last concern, should these commands should be integrated into reth p2p or as a separate binary?

IMO, I agree with @Rjected , integrated into reth p2p maybe better :)

emhane commented 1 week ago

One last concern, should these commands should be integrated into reth p2p or as a separate binary?

yes, see the text I added to the list in bold @int88. check out how it is done for the db subcommand clear with subsubcommands mdbx and static-file

https://github.com/paradigmxyz/reth/blob/e0c22ace34e520b6276af2f54acb634363b7979f/bin/reth/src/commands/db/clear.rs#L13-L16

so for example, p2p would be the command, rlpx is a subcommand (like clear), and ping is a sub subcommand (like mdbx)