-
Notifications
You must be signed in to change notification settings - Fork 1.1k
service/rpc: Add a separate rpc service to handle all exposed endpoints
#693
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
Conversation
68dbb89 to
9854c8b
Compare
Codecov Report
@@ Coverage Diff @@
## main #693 +/- ##
==========================================
- Coverage 52.26% 52.05% -0.22%
==========================================
Files 103 106 +3
Lines 6224 6311 +87
==========================================
+ Hits 3253 3285 +32
- Misses 2629 2686 +57
+ Partials 342 340 -2
Continue to review full report at Codecov.
|
Wondertan
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.
👍🏻 for extracting handlers out of actual pkgs.
tzdybal
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.
Awesome!
|
There is one more thing to consider: |
adlerjohn
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.
utACK
To run the test, running celestia node is needed, version from: celestiaorg/celestia-node#693
|
|
Good point re body in a GET method I think the endpoint should look like We can also have the following endpoint: cc @tzdybal |
LGTM. |
241dbbf to
e9ff0fa
Compare
adlerjohn
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.
merge conflict
…ares/{nID}/height/{height}
… doing /namespaced_shares/{nID}
e9ff0fa to
5105a18
Compare
|
@renaynay I also added a ticket to track down updating Node API endpoint reference doc once this is merged celestiaorg/docs#65 |
liamsi
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.
utACK
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.
Thought CI seems to be failing. Doesn't even seem to compile??
Running [/home/runner/golangci-lint-1.45.2-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
Error: undeclared name: `ExtendedHeader` (typecheck)
Error: s.syncer.store undefined (type *"github.com/celestiaorg/celestia-node/header/sync".Syncer has no field or method store) (typecheck)
Error: issues found
Wondertan
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.
LGTM as before. Only left optional code structure and design-related nits.
To run the test, running celestia node is needed, version from: celestiaorg/celestia-node#693
To run the test, running celestia node is needed, version from: celestiaorg/celestia-node#693
To run the test, running celestia node is needed, version from: celestiaorg/celestia-node#693
Description
This PR refactors the current design of how endpoints are made available on celestia-node. Now, instead of having per-package endpoints, this PR introduces a
service/rpcpackage that contains a newrpc.Handlertype designed to register all available endpoints on therpc.Server. This makes it possible to make it so that shares can be retrieved just by anamespaceIDand a blockheight.Endpoints
Header endpoints
GET
/header/{height}Returns the header of the given height.
Request
Response
{"header":{"version":{"block":11},"chain_id":"devnet-2","height":300,"time":"2021-11-23T13:13:21.208225643Z","last_block_id":{"hash":"7BA28942BB87007324F0332BEB4B3FA57F63BB6FA424B3281D28DFB237AE1A01","parts":{"total":1,"hash":"5FE2802B7A4D9A0281011401640BFC64854683168BD0FBEC04EFC8065CBE8EA0"}},"last_commit_hash":"82E20D9E023C5B27A71D8AC5FAB8B8BEEAFE735E880386C899D7DE24D3735102","data_hash":"7B578B351B1B0BBD70BB350019EBC964C44A140A37EF715B552A7F8F315ACD19","validators_hash":"7F4EA93A134DEDBDA6A1FDD30D05760DD98A2B5FBA95DB3EFFFE7FCE4B361855","next_validators_hash":"7F4EA93A134DEDBDA6A1FDD30D05760DD98A2B5FBA95DB3EFFFE7FCE4B361855","consensus_hash":"048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F","app_hash":"528DBBF7330CF30BFAD76EDB1E19935D9CBD7AE522E1D4CC51A6FF0B58ABB72E","last_results_hash":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","evidence_hash":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","proposer_address":"31711F367349D1BD619BD0A39568A69614B8A048"},"commit":{"height":300,"round":0,"block_id":{"hash":"D63D40F570E90E5757AD72DA6EB839B9B47E78AB760FFBDF0275CBC6B9A74D30","parts":{"total":1,"hash":"676A9F3EA11F828E58F44C600762FD09C4DE95611FD1EF8522A3198D29B8B1C9"}},"signatures":[{"block_id_flag":2,"validator_address":"03F1044A6DF782189C7061FF89146B3D33608F17","timestamp":"2021-11-23T13:13:36.603550499Z","signature":"/14ReW+Ig0xf8Ew4SE2WtaCWnaWcB+RHsIosjo+uJUfANhceVVpQtCfO2wQtjtPk/JIBcoq/XcomkqsbOlYwBA=="},{"block_id_flag":2,"validator_address":"04881EB0A0A4C1DB414C708249CEEC2FCF348F3E","timestamp":"2021-11-23T13:13:36.60149343Z","signature":"XesoBDBgX1eJDIuVmcQIHIKqDTKZdSCMNcWjdk3xeiTgVNB5TYGlO6n7UUAZE5Gf4OZoOzqPPo847VERdWcgBQ=="},{"block_id_flag":2,"validator_address":"31711F367349D1BD619BD0A39568A69614B8A048","timestamp":"2021-11-23T13:13:36.602220136Z","signature":"rqpLcPFCFOOBRDB1Uxc9v+6i/GEoFMBIlJlYgFGWtWFSTu4Btr4ByyjRMo9tO9LIIlLW8guyHNS0+2i6ZcuRCg=="},{"block_id_flag":2,"validator_address":"5A253EC2A9AB20AFD48C7BED2AFCA53F5C80BCA6","timestamp":"2021-11-23T13:13:36.673438724Z","signature":"MofRin9HeWVw8ENHIdakr4PBN/Vsf1KeeZxFNW4KAJT6rYJKlTSCIGtfTcGgZgA5B2xyqW2aItQ+NAx/uVoPAg=="},{"block_id_flag":2,"validator_address":"79BEB39F4B396F9278DA03F1C97F9BE3B10B12D3","timestamp":"2021-11-23T13:13:36.607283878Z","signature":"/3VQESw+WIxWFgy9VnhSikzkr4qs36ZwSx9oweUnov7Gu/NgdnF94vm560YsObV6ZwN5h3xg7JQp1H+xgfOUCQ=="},{"block_id_flag":2,"validator_address":"7F1105B7B219481810C49730AECB1A83036BCA3A","timestamp":"2021-11-23T13:13:36.644589313Z","signature":"pj7uUGGZRDy2P2DsBcVUXZP50tDEpmm5bDen2B0ede8GgcNI8VjfZJKAx8ptps8TJrsThDTQdq6cx2Jj6jfuCA=="},{"block_id_flag":2,"validator_address":"87265CC17922E01497F40B701EC9F05373B83467","timestamp":"2021-11-23T13:13:36.605958421Z","signature":"dWHenir11St4TAVNp/yPY+GQSBVypMRulP3wHbWIoZILMzfcirxjfTqlM+0FLtO5B8TNcrk9y9FofBJkcsB/BA=="},{"block_id_flag":2,"validator_address":"D345D62BBD18C301B843DF7C65F10E57AB17BD98","timestamp":"2021-11-23T13:13:36.609916618Z","signature":"nOHLUTES3ZHJWGL5C0OW8qJR6Vhn2Ru8TQn2FHCaEnksOqtbehz/9+gZhoTndQHmpI6vQzCXHJc8GoxufYb0Aw=="},{"block_id_flag":2,"validator_address":"DEC2642E786A941511A401090D21621E7F08A36D","timestamp":"2021-11-23T13:13:36.602919116Z","signature":"EzKh/zkc+ghJhlkmiqldSdWDfTm4NRfZ/rT58sfAa8cNCztGm0ysCaCItTb88qJzDtB/HsdfWuvjkGezKRiACw=="}]},"validator_set":{"validators":[{"address":"03F1044A6DF782189C7061FF89146B3D33608F17","pub_key":"sMcFgSIzlD77eZYgV7H4akyxoHCPc2oIQW05qWEB6b4=","voting_power":5000,"proposer_priority":-40000},{"address":"04881EB0A0A4C1DB414C708249CEEC2FCF348F3E","pub_key":"WdqZ8hoyc1HxZCJfQrAGKm2fFJZFg7PngPNGkA1RWXc=","voting_power":5000,"proposer_priority":5000},{"address":"31711F367349D1BD619BD0A39568A69614B8A048","pub_key":"pvwSRksq3ekXIiYK7IzjQJ870BxLqEma8zRr9n9VnXI=","voting_power":5000,"proposer_priority":5000},{"address":"5A253EC2A9AB20AFD48C7BED2AFCA53F5C80BCA6","pub_key":"RnmnTlKoKxNoh2TpohBDP3cKlx4ATiPOCvQFk/6xpUU=","voting_power":5000,"proposer_priority":5000},{"address":"79BEB39F4B396F9278DA03F1C97F9BE3B10B12D3","pub_key":"oh/N+GOIennBOAa/gPNCso1mDlqaHQNn7Op/X8opbeY=","voting_power":5000,"proposer_priority":5000},{"address":"7F1105B7B219481810C49730AECB1A83036BCA3A","pub_key":"Ow/AHP/Q3guPGymUKpvhnwae+QoCOpGztpVnP179IG8=","voting_power":5000,"proposer_priority":5000},{"address":"87265CC17922E01497F40B701EC9F05373B83467","pub_key":"MNi0Z+uNF5X1Bxj988IDXVl0BKUcLs7LItoMnX6dbg4=","voting_power":5000,"proposer_priority":5000},{"address":"D345D62BBD18C301B843DF7C65F10E57AB17BD98","pub_key":"4g3hhdyU4IIgWW/4sR0nax8bsC/M/fDbt1N8s/QanF8=","voting_power":5000,"proposer_priority":5000},{"address":"DEC2642E786A941511A401090D21621E7F08A36D","pub_key":"b+Vv6Lcp0bhIjOQncr+OYBHixCvU5+k34y4RqyvpluE=","voting_power":5000,"proposer_priority":5000}],"proposer":{"address":"03F1044A6DF782189C7061FF89146B3D33608F17","pub_key":"sMcFgSIzlD77eZYgV7H4akyxoHCPc2oIQW05qWEB6b4=","voting_power":5000,"proposer_priority":-40000}},"dah":{"row_roots":["//////////7//////////uyLCVMJmAItYqbOqgHXm3OwHsq1xQiAX1kZV2Tgcobm","/////////////////////ykyWNfDJZfigziZC5BN5L00KKuoyDPduwynDywauskL"],"column_roots":["//////////7//////////uyLCVMJmAItYqbOqgHXm3OwHsq1xQiAX1kZV2Tgcobm","/////////////////////ykyWNfDJZfigziZC5BN5L00KKuoyDPduwynDywauskL"]}}Share endpoints
GET
/namespaced_shares/{nID}Returns shares of the given namespace ID
nIDfrom the latest block (chain head).Request
Response
GET
/namespaced_shares/{nID}/height/{height}Returns shares of the given namespace ID
nIDfrom the block of the given heightheight.Request
Response
State endpoints
GET
/balanceReturns the balance of the default account address of the node.
see here.
GET
/balance/{address}Returns the balance of the given address.
see here
btw @YazzyYaz , this contains a mistake. It's http method GET not method POST.
POST
/submit_txSubmits the given transaction to a running instance of celestia-app.
Request
Response
POST
/submit_pfdConstructs, signs and submits a
PayForDatamessage to a running instance of celestia-app.Request
Response
{"height":589,"txhash":"065ED98A1D75AF10EADF38FC4D2DF125920C696C525732DA094029FCC3D2FE6E","data":"0A180A162F7061796D656E742E4D7367506179466F7244617461","raw_log":"[{\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/payment.MsgPayForData\"}]},{\"type\":\"payfordata\",\"attributes\":[{\"key\":\"signer\",\"value\":\"celes1vdjkcetnxyc8gandddeh2wfcxe3ksdfn09axkdtrwdnryat3v3jkcut8wpjnjerj0y6hz6sga5fzu\"},{\"key\":\"size\",\"value\":\"256\"}]}]}]","logs":[{"events":[{"type":"message","attributes":[{"key":"action","value":"/payment.MsgPayForData"}]},{"type":"payfordata","attributes":[{"key":"signer","value":"celes1vdjkcetnxyc8gandddeh2wfcxe3ksdfn09axkdtrwdnryat3v3jkcut8wpjnjerj0y6hz6sga5fzu"},{"key":"size","value":"256"}]}]}],"gas_wanted":100000,"gas_used":38546}Overrides #673 and #672