-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
implement part of reth p2p rlpx ping
#9762
Conversation
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.
I like this and this command would be quite useful for testing, for example bootstrapping a private network with trusted peers and pinging the enodes would help making sure every node is reachable.
crates/cli/commands/src/p2p/rlpx.rs
Outdated
let key = rng_secret_key(); | ||
let enr = node.parse::<Enr>().unwrap(); | ||
let enr = EnrCombinedKeyWrapper(enr).into(); | ||
let node_record = NodeRecord::try_from(&enr).unwrap(); |
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.
let node_record = NodeRecord::try_from(&enr).unwrap(); | |
let node_record = NodeRecord::try_from(&enr)?; |
crates/cli/commands/src/p2p/rlpx.rs
Outdated
/// ping node | ||
Ping { | ||
/// The node to ping. | ||
#[arg(long, short)] |
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.
we can remove this so that this will be compatible with devp2p command
#[arg(long, short)] |
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.
almost there!
crates/cli/commands/src/p2p/rlpx.rs
Outdated
let enr = node.parse::<Enr>().unwrap(); | ||
let enr = EnrCombinedKeyWrapper(enr).into(); |
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.
if you import the enr::Enr
instead of discv5::Enr
, you shouldn't need this wrapper
let (_, their_hello) = | ||
UnauthedP2PStream::new(ecies_stream).handshake(hello).await?; | ||
|
||
println!("{:#?}", their_hello); |
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 should follow on to use the established session returned by the handshake (the first index in the tuple), and use that to send a ping
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 should follow on to use the established session returned by the handshake (the first index in the tuple), and use that to send a ping
@mattsse I try to implement this which need to refactor some core code of p2p, it may need some time. Or we could merge this first and I'll implement send ping
in another PR :)
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.
cool, let's get this over the line and followup separately
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.
please change the name of the pr then, since it only partially implements the ping command
@int88 just checking in, this is almost there, lmk if you don't have capacity for it |
reth p2p rlpx ping
reth p2p rlpx ping
@mattsse updated! |
crates/cli/commands/src/p2p/rlpx.rs
Outdated
match self.subcommand { | ||
Subcommands::Ping { node } => { | ||
let key = rng_secret_key(); | ||
let enr = node.parse::<Enr<secp256k1::SecretKey>>().unwrap(); |
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.
would be more helpful if this parsed an enode into an enr, rather than the serialised base 64 enr string, could open an issue for addressing this separately though
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Output of reth:
output of devp2p:
root@dev:~/re# devp2p rlpx ping enr:-KO4QMne-2ViZIH_qe4P3D7DiXtk3WtEmyWvJ5-epTBPM8U5Nsy1msLffx-v2asiF9v0F7t8MKHjynz49-IQ6yhZfI6GAY6TEHi2g2V0aMfGhPCXvBOAgmlkgnY0gmlwhFf5iVmJc2VjcDI1NmsxoQNwGDtgE0IIvlWTJKr4duH8fWIfrk4NRCWk6uG9jmMILoRzbmFwwIN0Y3CCdl-DdWRwgndp {Version:5 Name:bor/v1.2.7/linux-amd64/go1.20.14 Caps:[eth/68 snap/1] ListenPort:0 ID:[112 24 59 96 19 66 8 190 85 147 36 170 248 118 225 252 125 98 31 174 78 13 68 37 164 234 225 189 142 99 8 46 91 151 125 110 92 24 152 159 42 14 45 141 167 37 83 243 245 127 105 95 114 145 7 190 47 10 51 31 120 171 39 225] Rest:[]}