whalelephant
whalelephant

Reputation: 59

How to add / remove validators in a substrate network

I would like to add / remove validators from an already existing substrate private network.

Following the tutorial for starting aprivate network, I was able to create a raw customSpec and start a new chain with the validators.

However, I am not sure how to add new / remove old validators to the network. So these are the steps I tried:

  1. edit customSpecs.json to desired validators
  2. build new raw_customSpecs.json
  3. restart node with new raw_customSpecs.json
  4. use the hex code in the new raw_customSpecs to upgrade the runtime with sudo via polkadotjs, similar to the given example.

I would like to get some pointers as to how to do this properly because I am still unable to set new validators with the steps I have taken.

Thanks!

Upvotes: 1

Views: 973

Answers (1)

kianenigma
kianenigma

Reputation: 1405

You have various ways to add/remove validators. Using chain-spec is one of them, but you are on the wrong path trying to apply a runtime upgrade with the spec. A runtime upgrade will typically only update one storage item, :code, which is the code of your runtime. On the other hand, your validators are stored in other storage items in the pallet_staking and pallet_session module. So indeed applying the runtime upgrade will not get you anywhere.

Indeed, if you are fine with restarting your node, you can alter the initial validators and run your chain again, after you have updated your step 1:

edit customSpecs.json to desired validators

To do it on the fly, you need to look into how staking pallet is working. You can bond new accounts and if the ValidatorCount is more than the current number of validators, the next election round will elect the new account. Of course, a node with the private key of this newly bonded account must be present in the network for everything to work well. You can use sudo to increase ValidatorCount.

Upvotes: 4

Related Questions