Skip to content

p2p/discover: expose discv5 functions for portal JSON-RPC interface #31117

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

Merged
merged 4 commits into from
Mar 13, 2025

Conversation

GrapeBaBa
Copy link
Contributor

@GrapeBaBa GrapeBaBa commented Feb 3, 2025

This PR fix #31093 .

Function Renaming for Clarity:

  • For support portal discv5_ping json rpc endpoint, added a PingWithResp function and renamed Ping to PingWithoutResp for refactoring.
  • For support portal discv5_routingTableInfo json rpc endpoint, added RoutingTableInfo function and nodeIds function.
  • For support portal discv5_deleteEnr json rpc endpoint, added DeleteNode function and deleteNode function.
  • For support portal discv5_lookupEnr json rpc endpoint, added ResolveNodeId function.
  • For support portal discv5_addEnr json rpc endpoint, added AddKnownNode function.
  • For support portal discv5_GetEnr json rpc endpoint, renamed getNode to GetNode.
  • For support portal discv5_findNode json rpc endpoint, renamed findnode to Findnode.
  • Added WaitInit function and waitInit for support portal hive test.
  • Refactor AllNodes function.

This is the discv5 api impl code

@fjl fjl added the shisui Portal Network label Feb 18, 2025
// LocalNode returns the current local node running the
// RoutingTableInfo returns the routing table information. Used for Portal discv5 RoutingTableInfo API.
func (t *UDPv5) RoutingTableInfo() [][]string {
return t.tab.nodeIds()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should expose Table.Nodes method instead because it has more information.

return t.tab.nodeIds()
}

// AddKnownNode adds a node to the routing table. Used for Portal discv5 AddEnr API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a comment that says it's only for testing.


// WaitInit waits for the routing table to be initialized.
func (t *UDPv5) WaitInit() {
t.tab.waitInit()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to add a config option (in discover/common.go) that disables init check in table.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change will be made in another PR.

}

// PingWithResp calls PING on a node and waits for a PONG response.
func (t *UDPv5) PingWithResp(n *enode.Node) (*v5wire.Pong, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just change Ping signature to return the response object. No need to add WithoutResp method.

@fjl fjl changed the title feat:expose discv5 function for portal discv5 json rpc p2p/discover: expose discv5 functions for portal JSON-RPC interface Mar 12, 2025
@fjl fjl added this to the 1.15.6 milestone Mar 13, 2025
@fjl fjl merged commit 5117f77 into ethereum:master Mar 13, 2025
1 of 2 checks passed
sivaratrisrinivas pushed a commit to sivaratrisrinivas/go-ethereum that referenced this pull request Apr 21, 2025
…thereum#31117)

Fixes ethereum#31093

Here we add some API functions on the UDPv5 object for the purpose of implementing
the Portal Network JSON-RPC API in the shisui client.

---------

Signed-off-by: Chen Kai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shisui Portal Network
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose discv5 function for portal discv5 json rpc
2 participants