-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update send_ping response type #164
Conversation
4b373a0
to
570e0b3
Compare
The starting point was ddht specs but I think our situation is slightly different. There is a current discussion in discv5 repo about exposing PING and FINDNODE rpc in the library. We had a quick chat with @pipermerriam about this and it seems that we don't have clear use cases for using those base discv5 layer endpoints, at least for now. I think we can implement without standardization any endpoint beneficial for our test network and development, and leave the specs when is more clear what are the profiles of the end-users and what they need. Does this make sense? The next step is probably to decide what we really need now. Maybe starting with the implementation of the endpoints with |
570e0b3
to
449f00d
Compare
@ogenev Yup, cool makes perfect sense. I'd agree I can't think of strong use case for base ping/find nodes. I've been working on |
Instead of duplicating those endpoints for every network, we are planning to use in the specs something like:
|
52718c9
to
8fd941e
Compare
@ogenev Ahh, gotcha. I was still under the impression we were going with |
8fd941e
to
e2aa73d
Compare
e2aa73d
to
f46423d
Compare
it was in a zoom chat, my concern was that we have to duplicate a lot of overlay endpoints in the specs and @pipermerriam proposed this schema which seems reasonable. I will update the draft specs to include those if all agree. |
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.
LGTM 👍 , left some minor comments.
trin-core/src/portalnet/types.rs
Outdated
@@ -305,6 +306,26 @@ impl fmt::Display for Pong { | |||
} | |||
} | |||
|
|||
impl Pong { | |||
pub fn from_raw_response(bytes: &[u8]) -> Result<Self, OverlayRequestError> { |
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.
@jacobkaufmann mentioned that in those cases (when we try to convert from one type to another), implementing TryFrom trait may be more Rust idiomatic.
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.
Nice, yeah that's way better
.await; | ||
|
||
match ping_result { | ||
Ok(_) => { |
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.
Do we want to check explicitly if the result is Pong
?
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'm not sure... send_ping()
returns Result<Pong, Error>
- so my assumption here is that any Ok(_)
will be a Pong
so no need to explicitly check it. However, maybe that's not a safe assumption? Maybe the return type for send_ping()
might change? Idk - do you think it's worth the explicit check?
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.
Going ahead and merging this now, but lmk if you think it's worth the explicit check and I'll circle back in a future pr
@ogenev Makes sense. It seems to me like the tradeoff here is between spec simplicity, and maybe some extra typing required. For example - via the cli - I'd rather |
Empty overlay ping responses were being recognized as valid in the testharness. So, I updated
send_ping
to parse and return an actualPong
. Seems much more useful than returning a raw vector of bytes. This raised a couple questions for me about the jsonrpc api we're targeting.@ogenev I believe you've been working on putting that spec together? Just wondering what your thoughts currently are on what endpoints we want to standardize. I know we're somewhat targeting the ddht spec - but now that I'm digging into it, I see that the design of the
discv5
library might complicate things if we want to copy that api 1 for 1.