Skip to content
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

Merged
merged 2 commits into from
Oct 29, 2021
Merged

Conversation

njgheorghita
Copy link
Collaborator

@njgheorghita njgheorghita commented Oct 27, 2021

Empty overlay ping responses were being recognized as valid in the testharness. So, I updated send_ping to parse and return an actual Pong. 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.

@ogenev
Copy link
Member

ogenev commented Oct 28, 2021

@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.

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 high priority from #95 and leaving the rest (low/medium priority) when we are actually using them for something?

@njgheorghita njgheorghita marked this pull request as ready for review October 28, 2021 15:06
@njgheorghita
Copy link
Collaborator Author

@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 portalState_ping (which would be a round trip) (and also de facto portalHistory_ping). Imo those endpoints and the other overlay round trip endpoints (portal*_findNodes & portal*_findContent) are the other two high priority endpoints to support.

@njgheorghita njgheorghita requested review from ogenev and lithp October 28, 2021 23:57
@ogenev
Copy link
Member

ogenev commented Oct 29, 2021

I've been working on portalState_ping (which would be a round trip) (and also de facto portalHistory_ping). Imo those endpoints and the other overlay round trip endpoints (portal*_findNodes & portal*_findContent) are the other two high priority endpoints to support.

Instead of duplicating those endpoints for every network, we are planning to use in the specs something like:

overlay_methodName(network_name, *params)

@njgheorghita njgheorghita force-pushed the send-ping branch 2 times, most recently from 52718c9 to 8fd941e Compare October 29, 2021 14:16
@njgheorghita
Copy link
Collaborator Author

@ogenev Ahh, gotcha. I was still under the impression we were going with portalState_* / portalHistory_* from this convo. Do you have a link to these updated specs / conversation? I don't see the overlay endpoints here.

@ogenev
Copy link
Member

ogenev commented Oct 29, 2021

@ogenev Ahh, gotcha. I was still under the impression we were going with portalState_* / portalHistory_* from this convo. Do you have a link to these updated specs / conversation? I don't see the overlay endpoints here.

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.

Copy link
Member

@ogenev ogenev left a 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.

@@ -305,6 +306,26 @@ impl fmt::Display for Pong {
}
}

impl Pong {
pub fn from_raw_response(bytes: &[u8]) -> Result<Self, OverlayRequestError> {
Copy link
Member

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.

Copy link
Collaborator Author

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(_) => {
Copy link
Member

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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

@njgheorghita
Copy link
Collaborator Author

I will update the draft specs to include those if all agree.

@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 portalHistory_ping(..) than overlay_ping("history", ..). But, I would agree that keeping the spec simple probably takes priority in this case. Anyways, we can/probably will introduce whatever shortcut schemes in the cli that we decide upon eventually

@njgheorghita njgheorghita self-assigned this Oct 29, 2021
@njgheorghita njgheorghita merged commit f12d4f8 into ethereum:master Oct 29, 2021
@njgheorghita njgheorghita deleted the send-ping branch October 29, 2021 19:34
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants