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

WIP - Add little command for easy access to JSON-RPC interface #169

Closed
wants to merge 3 commits into from

Conversation

lithp
Copy link
Contributor

@lithp lithp commented Oct 28, 2021

Very WIP, current interface:

brian@beat:~/ef/trin$ cargo run -p trin-cli -- rpc discv5_routingTableInfo
RoutingTableInfoResponse { buckets: [RoutingTableNodeInfo { node_id: "0xd40a..2cb0", enr: "enr:-IS4QGAwk1EybH8deeq9xrlH6HF_ZnWAu4vMODJbgZ0i78_IUnN0vdQgBpJ0p4ZXWD6FNq_k-kP1-9ZpHCqvIQphtoMBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQL0kZO-svDs-h0vbTo-QsWhJ7XeRmaQH0g8jqej35K0t4N1ZHCCEdg", status: "Connected" }], local_node_id: "0x302c..1cd1" }

Would appreciate suggestions:

  • trin-cli rpc discv5_routingTableInfo is honest but... still not a very good interface. How could it be improved?
    • what should this command be called?
    • should commands be given short names like routingTable?

There's still work to do:

  • Refactor, move a lot of this logic into trin_core::jsonrpc
  • Refactor peertest (clientside) to use these structs
    • This might require adding support for connecting over HTTP
  • Refactor the handlers (serverside) to use these nice serializable structs instead of manually generating responses
  • Come up with a clean way to map the user-supplied and dynamically typed argv into method calls
  • Add support for the rest of the JSON-RPC endpoints (I'll probably defer that work for future PRs)
  • Implement a trin-cli endpoints which lists available endpoints (maybe this is just trin-cli help and I let structopt do most of the work)

@njgheorghita
Copy link
Collaborator

should commands be given short names like routingTable?

I don't think so, at least for right now. I could definitely see a use case where I'd want to call portalState_routingTableInfo - and differentiate from discv5_routingTableInfo or portalHistory_routingTableInfo. Yeah, typing out the whole endpoint is kinda clunky, but it's pretty effective for distinguishing between the various base / overlay networks

@pipermerriam
Copy link
Member

pipermerriam commented Oct 29, 2021

suggested output formats:

  • raw response
  • pretty JSON
  • pretty human readable

@pipermerriam
Copy link
Member

for shortening: discv5_routingTableInfo fuzzy matching if no exact match might be ideal. That would allow any of the letters in any casing in proper order to match (and throw sane errors if it matches multiple endpoints). That would allow arbitrary abbreviations like --rpc v5rti

@lithp
Copy link
Contributor Author

lithp commented Nov 9, 2021

Closing in favor of #180

@lithp lithp closed this Nov 9, 2021
# 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.

3 participants