5

I want to start a chain with Babe/Grandpa consensus. I'm able to start block production using Toolbox->RPC->author->insertKey() in UI. But I don't know how to start block finalization.

I've tried setting grandpa keys the same way I sat babe keys in Toolbox->RPC->author->insertKey():

  • keyType: gran
  • suri: //Alice
  • publicKey: 0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee (I also tried sr25519 version 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d)

And it didn't help.

Here you can see that block number increments properly while the finalized counter remains #0:

2020-01-16 15:03:19 Idle (1 peers), best: #101 (0x56ce…7c6a), finalized #0 (0x885c…85d7), ⬇ 0 ⬆ 0
2020-01-16 15:03:21 Imported #102 (0xe984…2776)
2020-01-16 15:03:24 Idle (1 peers), best: #102 (0xe984…2776), finalized #0 (0x885c…85d7), ⬇ 0.1kiB/s ⬆ 10 B/s
2020-01-16 15:03:27 Starting consensus session on top of parent 0xe98487a704c4fb20239df06ba4e8dda9e57c3fa1813b97819c16311c4ac92776
2020-01-16 15:03:29 Idle (1 peers), best: #102 (0xe984…2776), finalized #0 (0x885c…85d7), ⬇ 72 B/s ⬆ 76 B/s
2020-01-16 15:03:31 Imported #103 (0xc3ef…1438)
2020-01-16 15:03:34 Idle (1 peers), best: #103 (0xc3ef…1438), finalized #0 (0x885c…85d7), ⬇ 0.1kiB/s ⬆ 10 B/s

1 Answers1

2

There is a good tutorial to Start a network with Substrate which covers almost the exact topics you're looking for with one small exception that it uses Aura for block production rather than Babe.

If you want to use the well-known Alice, Bob, etc accounts as validators, the easiest way to get their keys into the keystore is to supply the --alice flag when starting the node. This approach is covered in step 2 of the tutorial. From substrate --help:

--alice
    Shortcut for --name Alice --validator with session keys for Alice added to keystore.

If you want to use your own self-generated keys, you will have to make the RPC calls as you're describing. This process is covered at the end of step 4 in the tutorial.

It is possible to insert the well-know Alice key via the RPC call as you attempted. Here are two reasons that you may not have finalized blocks when you attempted this approach.

  • GRANDPA requires 2/3 of validators to be casting finality votes to finalize anything (research). If you have other validators in your chain specification, nothing will get finalized until you've inserted the proper keys into at least 2/3 of the validating nodes.
  • You may need to supply the full dev phrase when inserting the keys rather than just //Alice.
JoshOrndorff
  • 1,591
  • 9
  • 19
  • 3
    I went through the tutorial with `aura` and `substrate-node-template` repo. The same problem, submitting 2 grandpa keys of 2 total via RPC call doesn't start finalization, though, specifying `--alice` and `--bob` does. Is it possible to debug this process somehow? – Nikita Chebykin Jan 16 '20 at 17:06
  • Have you made sure to insert one key into each node? When you make RPC calls from the UI you're making them to a specific node. It won't work if you insert both keys into a single node. So you'll have to connect UI to alice's node, insert alice's keys, connect ui to bob's node, insert bob's keys. – JoshOrndorff Jan 17 '20 at 06:32
  • I'm executing these 4 following commands in order to start a `local_testnet` chain template with `//Alice` and `//Bob` as 2 validators. Are they correct? https://gist.github.com/chebykin/4dbe8f5c43926b8424e87ed0a16ae6a4 – Nikita Chebykin Jan 17 '20 at 07:54
  • 4
    I've found a temporary solution. Restarting the nodes after injecting keys via RPC starts finalization. Probably a bug with Substrate. – Nikita Chebykin Jan 17 '20 at 15:12