4
votes

Problem

I am running a private chain with 2 local nodes using custom accounts and keys.

Peer discovery works, but blocks are not being finalized.

Idle (1 peers), best: #0 (0xb166…8ad2), finalized #0 (0xb166…8ad2),
Idle (1 peers), best: #0 (0xb166…8ad2), finalized #0 (0xb166…8ad2),
...

Description

In chain_spec.rs:

  • Create a new set of accounts from Armstrong, Armstrong//stash, Aldrin, Aldrin//stash seeds the way it is done in the bin/node :

    AccountPublic::from(sp_core::Public::Pair::from_string(seed)).into_account()

  • Set the initial authorities to the controller accounts Armstrong and Aldrin.

  • Create the SessionKeys for the initial authorities.

  • BalancesConfig: endow some balances for each account.

  • SessionConfig: use the SessionKeys I just created.

  • StakingConfig: set the stakers as a 4-tuple containing (stash, controlller, amount, StakerStatus::Validator)

This results in a build-spec like:

palletSession

{
    "keys": [
        [
        "<STASH_ID>",
        {
            "grandpa": "...",
            "babe": "<CONTROLLER_ID>",
            "im_online": "<CONTROLLER_ID>",
            "authority_discovery": "<CONTROLLER_ID>"
        }
        ],
        [
        "<STASH_ID>",
        {
            "grandpa": "...",
            "babe": "<CONTROLLER_ID>",
            "im_online": "<CONTROLLER_ID>",
            "authority_discovery": "<CONTROLLER_ID>"
        }
        ]
    ]
}

palletStaking

"stakers": [
    [
        "<STASH_ID>",
        "<CONTROLLER_ID>",
        <STASH_AMOUNT>,
        "Validator"
    ],
    [
        "<STASH_ID>",
        "<CONTROLLER_ID>",
        <STASH_AMOUNT>,
        "Validator"
    ]
]

Polkadot.js UI

  • Peer is shown in the Explorer -> Node info:

enter image description here

  • I can add the created accounts to the Address Book, but they are not showing in Accounts:

enter image description here enter image description here

  • Stash accounts show up in the Stacking screen as validators, but Account actions shows a No funds staked yet. Bond funds to validate or nominate a validator message:

enter image description here enter image description here

1
This might be a basic question but we've seen it some many times before: Are you running a release build? running debug is most often too slow to produce and finalize anything. - kianenigma
@kianenigma Thank you for your answer, I am indeed running a release build. It is worth mentioning that I am able to produce / finalize blocks once I do a author_insertKey rpc and restart both nodes (using the public keys for babe and grandpa provided by the subkey command). However, isn't setting the SessionKeys for pallet_session on genesis enough? That is how it is done for Alice and Bob and works out of the box. - TMichel
Hey @TMichel, can you please support our Substrate StackExchange proposal: area51.stackexchange.com/proposals/126136 - Shawn Tabrizi

1 Answers

1
votes
  1. check, that you've added grandpa private keys to the node's storage (author_insertKey, or rotate). When you start alice/bob chain private keys are already in storage
  2. there is an issue that node is checking that private keys are in storage at start (spawning grandpa thread), so if you insert grandpa private keys you need to restart the node.