substrate-node-template comes up with
PoA by default. I am trying to change this consensus engine to
Proof of stake, so far I have just changed
babe. What else do I need to do to change the consensus to
This is an involved topic, but as a short primer: The crucial change on the runtime side is in how the validator set is provided. Using Babe on its own with a hard-coded validator set is still PoA. You need to configure the validator set to be dynamic based on a PoS mechanism. Polkadot uses pallet-staking in combination with pallet-session for this. You might do the same or use a different staking system.
Note: Because the block production system consists of both runtime as well as node parts you cannot just change the consensus of a running chain and expect it to work. You would need to transition the node from Aura to Babe as well.
I changed the consensus engine from PoA to PoS for the substrate-node-template when it was Substrate version 3.0.0 about a year ago with the changes shown here.
To make the change using a more recent Substrate version you can refer to files like bin/node/runtime/src/lib.rs that show how you would now incorporate pallets like Babe, Staking, and Session into your runtime.
To make a PoS chain based on node template, you need to make these changes step by step,
- use BABE to produce blocks, since Aura is for test purpose or permissioned network.
- use staking, session, authorship, offences, utility, im-online pallets to enable staking, rewards and punish operations.
- use governance, treasury, democracy, membership, election pallets to make your own governance process, this is not required if you don't need onchain governance.
- initialize your chain spec to include your bootnodes, genesis validators and so on.
- use BabeCallFilter to open/close functions as you launch goes different stage.
- similarly, use governance and sudo to enable functions slowly to reduce risks.
You could use my practice by following these recent commits.
I have integrated the POS in fresh node-template on polkadot-v1.0.0
Here you can find the POS(proof-of-stake) node-template with babe: https://github.com/Aideepakchaudhary/POA-to-POS