8

The 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 aura to babe. What else do I need to do to change the consensus to PoS?

2
  • I have referenced your template version 3.0 but I tried the current substrate-node-template for it, so many modules conflict. Could you show me latest version files, please?
    – W.B Expert
    Jun 16, 2022 at 23:57
  • If you want PoA for testing purpose then you should use substrate full node. Jun 9, 2023 at 10:33

5 Answers 5

8

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.

4
  • Hi. I've managed to switch my node from aura to babe, and am now considering what's the bare minimum of pallets required to get PoS running. I've managed to narrow down the list to staking, sessions, imonline, authorship, authority discovery, election_provider_multi_phase, treasury, and council. Is this enough to have a nPOS system? Feb 23, 2022 at 8:44
  • Hi @apopiak how can we upgrade a live poa chain to npos? is it possible? if so what would be right steps for it? Even polkadot was initially POA and then they switched to NPOS right? so it should be possible but right now we are not sure how. kindly put some light on it. Thank you Nov 11, 2022 at 12:57
  • @Purple_Turtle That sounds roughly right, but I don't know the required list off the top of my head.
    – apopiak
    Jan 3, 2023 at 16:05
  • @ImmanuelJohn It is possible in principle but can be difficult in practice. If you started out with Aura, one way would be to change how the Aura validator set is determined (i.e. change that to PoS). This will not change block production, though.
    – apopiak
    Jan 3, 2023 at 16:06
6

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.

1
  • 1
    The template is functioning smoothly under POS consensus. However, I think it incorporates several extra pallets. Could you identify the redundant pallets integrated into the template that can be removed without disrupting its functionality?
    – Ajit
    Oct 1, 2023 at 16:18
4

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.

1

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

Thanks!

0

My big question is how all of the authors above initially understood what to do in order to enable PoS or make any more complex adjustment for that matter? In my opinion, the official documentation and tutorials provided by Substrate do not bring you near the capability to make complex adjustments of the node template. Did all of the above authors attend Polkadot Academy, or are there any advanced tutorials/trainings that I missed?

Not the answer you're looking for? Browse other questions tagged or ask your own question.