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

dot/rpc: implement RPC call state_control #896

Merged
merged 15 commits into from
Jun 26, 2020

Conversation

edwardmack
Copy link
Member

@edwardmack edwardmack commented May 27, 2020

Changes

Introduce RPC method to control services

  • There is currently in issue when calling stop on babe, it cause the node to crash with a panic because sendVoteMessages tries to send on a closed channel:
panic: send on closed channel

goroutine 76 [running]:
github.com/ChainSafe/gossamer/dot/core.(*Service).sendVoteMessages(0xc0002aa1e0)
        /home/emack/projects/chainsafe/gossamer/dot/core/finality.go:49 +0x207
created by github.com/ChainSafe/gossamer/dot/core.(*Service).Start
        /home/emack/projects/chainsafe/gossamer/dot/core/service.go:234 +0x219

Process finished with exit code 2

  • Call RPC method state_control and params array of strings where first element is service (currently babe or network), second element command (start or stop).
  • it returns an error if the service returns an error.

Tests:

Start gossamer with rpc

./bin/gossamer --key alice --rpc

Make RPC call (example to stop babe service):

curl --location --request POST 'http://127.0.0.1:8545' --header 'Content-Type: application/json' --data-raw '{
    "jsonrpc": "2.0",
    "method": "state_control",
    "params": ["babe", "stop"],
    "id": 1
}'

Checklist:

  • I have read CONTRIBUTING and CODE_OF_CONDUCT
  • I have provided as much information as possible and necessary
  • I have reviewed my own pull request before requesting a review
  • I have linked any relevant issues in my pull request comments
  • All integration tests and required coverage checks are passing

Issues:

@noot
Copy link
Contributor

noot commented Jun 25, 2020

@edwardmack I updated this to have a RPC dev module that directly uses the BlockProducer interface. it looks like it works now:

./bin/gossamer --key alice --rpc --rpcmods="dev" 

then:

$ curl --location --request POST 'http://127.0.0.1:8545' --header 'Content-Type: application/json' --data-raw '{
    "jsonrpc": "2.0",
    "method": "dev_control",
    "params": ["babe", "start"],
    "id": 1
}'

I'm wondering whether we should have separate calls for BABE and network (and start and stop), what do you think? it works as is so not a huge deal.

@edwardmack
Copy link
Member Author

@noot, this looks great, it makes sense to use the BlockProducer interface. Regarding call format, I'm open. I could create a call to start and one to stop, and pass in babe or network (and possible future things). OR I could do a call for babe and on for network, and pass in start or stop. I'm open, let me know.

@noot
Copy link
Contributor

noot commented Jun 26, 2020

@edwardmack let's leave it for now, in the future if we add more services to control it might make more sense to break it out. but I think it's fine as is

@noot noot marked this pull request as ready for review June 26, 2020 16:02
@noot noot self-requested a review June 26, 2020 16:02
@noot noot merged commit 625610d into development Jun 26, 2020
@noot noot deleted the ed/856-rpc-block_production branch June 26, 2020 16:16
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.

Developer RPC Endpoint: Start & stop block production Developer RPC Endpoint: Start & stop libp2p network
2 participants