-
Notifications
You must be signed in to change notification settings - Fork 168
draft(rpc): add scaffolding for ping RPC and getpeerinfo latency metrics #9880
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?
Conversation
conradoplg
left a comment
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 is looking good, feel free to move out of draft or to build on top of it, thanks!
9edf94c to
1cdd5df
Compare
|
Hi @conradoplg, thanks for the early feedback! I've just rebased the branch onto the latest |
|
I've implemented rudimentary tracking of peer latency in I'd like to hook this into the RPC layer next, and I'm looking for feedback on two points:
Currently, RTT data is stored in Happy to adjust direction based on feedback. Thanks! |
conradoplg
left a comment
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.
Some adjustments are required but hopefully it should be simple, see comments.
Regarding propagating the measured latency, I think it makes sense to use the address book. You will need to propagate the result as if Pong were returning something:
- In
process_message(), after handling thePong, changeHandler::Finished(Ok(Response::Nil))to return a new response type that you will need to create which includes the latency. - If you do that then in
send_periodic_heartbeats_run_loop(), theheartbeat_timeout()should return the new Pong response. Extract the latency from it and then pass it to theheartbest_ts_collectorinside theMetaAddr::new_respondedwhich you will need to modify to pass the latency. Then check where that is handled and store the latency in the address book.
I'm not 100% sure that will work but should you give some hints. As always, let us know if you prefer for us to work on it. Thank you for all the help!
|
Cleaned up artifacts from the earlier commits and addressed all reviewer feedback related to the first point:
Ping-pong latency tracking is now wired inside the handler, and a test was added for the round-trip. This is meant as an intermediate step. Thank you @conradoplg for stepping in and pointing me in the right direction with such detailed feedback! |
|
Addressed the second part of the review feedback:
Next steps:
|
The last commit now fully implements the suggested steps. I had to adapt several tests and decided to use some default values. Based on feedback, I can change these to more meaningful latencies. Next steps:
|
|
It's looking great, thanks |
|
Hi @conradoplg, I am sorry to bother you again, but I got stuck here. I struggle to find a way how to send the ping message to all connected peers. What I found so far:
My question:
I’d really appreciate any tips or guidance! |
I'm not sure if the method exists in zcashd alongside a heartbeat task, or if it was required because zcashd doesn't use a heartbeat task. If it's the latter, returning the @str4d Do you know if a
Not currently, as it would only send the
The peer set implements |
|
Thanks @arya2 for the explanation and for steering me away from chasing the wrong “solution”! I understand that the best next step is to fully implement support for the missing |
|
This is looking good. I agree with @arya2 that we can leave the actual force-pinging-everyone for later (for the time we could implement a dummy ping RPC that does nothing). Also feel free to do |
|
Hi @conradoplg, thank you for your feedback! I’ve extended the PR and added a proposal for the missing
Happy to adjust based on your feedback. |
Motivation
Refers to issue #9048 — Zebra currently lacks support for the
pingRPC method and its associated latency metrics (pingtimeandpingwait) in thegetpeerinforesponse.This draft PR begins implementing
pingsupport.Solution
This PR lays the foundation for
pingsupport without introducing incomplete logic or placeholder hacks.pingmethod added to theRpctrait.Ok(()), matching zcashd’s behavior.PeerInfostruct (used ingetpeerinfo) was extended with:pingtime: Option<f64>pingwait: Option<f64>From<MetaAddr>implementation updated to initialize these fields asNonefor now.Tests
pingtimeandpingwaitwithSomeandNonevalues.zebra-rpcbuild and pass.Specifications & References
pingpingRPC #9048Follow-up Work
pingmessage in thepingRPC method.pingtimeandpingwaitin thePeerInforesponse.Feedback Requested
My idea is to use the existing logic in the
zebra-networkcrate, specifically inconnection.rs, to implementpingbehavior:Message::Ping(nonce)frommessage.rsline 40.connection.rsline 1039.connection.rsline 1180.Does this look like the right place to hook into for ping tracking, or would another approach be preferred?
Acknowledgements
Thanks @oxarbitrage for outlining the relative complexity of this task in #9730 and suggesting it might be better to tackle later. That guidance was very helpful and is much appreciated.
I had already started this work over the weekend, so I wanted to clean up the scaffold and share what I learned. This draft PR can serve as a starting point for further discussion or future implementation. I plan to return to this at the end of September after my vacation.
Let me know if this direction makes sense and how best to proceed!