Skip to content

dot/rpc: implement RPC methods chain_getHeader and chain_getBlock#745

Merged
edwardmack merged 22 commits intodevelopmentfrom
ed/309_implement-rpc-chain-methods
Apr 6, 2020
Merged

dot/rpc: implement RPC methods chain_getHeader and chain_getBlock#745
edwardmack merged 22 commits intodevelopmentfrom
ed/309_implement-rpc-chain-methods

Conversation

@edwardmack
Copy link
Copy Markdown
Contributor

Changes

  • Implement RPC methods and tests for chain_getHeader
  • Implement RPC methods and test for chain_getBlock

Tests:

Unit tests:

go test ./dot/rpc/... -v

Interactive testing, start node:

make gossamer
./bin/gossamer --key alice --roles 4 --rpc --rpcmods chain,system

Interact with node via RPC, call chain_getHeader for latest header

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getHeader", "params": []}' http://localhost:8545/

Interact with node via RPC, call chain_getHeader for hash

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getHeader", "params": ["0x64be6cb9aaa36571309cb9f9c3dcf08197c8d1f80baff58e80bd1bb188d909fe"]}' http://localhost:8545/

Similar for calls to chain_getBlock

Issues:

This code introduces bug described in issue #744

Comment thread dot/rpc/modules/chain.go Outdated
Comment thread dot/rpc/modules/chain_test.go Outdated
Comment thread dot/rpc/modules/chain_test.go Outdated
Copy link
Copy Markdown
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

cleanup GetBlockHash, otherwise looks good!

also, could you update node/gssmr/defaults.go to include "chain" in DefaultRPCModules?

@edwardmack
Copy link
Copy Markdown
Contributor Author

I think this is ready now...

Copy link
Copy Markdown
Contributor

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Nice work! Looks good to me. You can base the pull request off your other branch until it is merged if you want to separate the code in the pull request but not necessary, just something I like to do.

@edwardmack edwardmack merged commit 935a6c0 into development Apr 6, 2020
@edwardmack edwardmack deleted the ed/309_implement-rpc-chain-methods branch April 6, 2020 14:32
ryanchristo pushed a commit that referenced this pull request Jun 24, 2020
* refactor to use gorilla/rpc lib

* introduce gorilla rpc package

* address lint issues

* implement GetHeader chain rpc func

* added getBlock rpc call

* add test for chain getBlock and getHeader

* added TODO issue #744 to comments

* fix spelling, remove extra logging, add chain to default

* go fmt-ed

* refactor to use gorilla/rpc lib

* address lint issues

* implement GetHeader chain rpc func

* added getBlock rpc call

* add test for chain getBlock and getHeader

* added TODO issue #744 to comments

* fix spelling, remove extra logging, add chain to default

* go fmt-ed

* fix merge issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants