11

I am working on a substrate based blockchain that is in production. We started the node using PoA consensus but now we want to switch to PoS consensus. I did the necessary changes i.e added necessary pallets and switched from aura to babe. And when I run the node from scratch it's working fine. But the forkless upgrade of the existing chain is causing the block production to stop. I also tried to upgrade node binary which was throwing "Unsupported or invalid BabeApi version".

This is the error I am getting when I upgrade my runtime. Error on Forkless Upgrade

Since this change also required node binary upgrade as there were changes in node. This is the error I am getting after upgrading node binary. I did both forkless runtime upgrade and node binary upgrade. enter image description here

I feel like it is because of Genesis config. Since newly added pallets(babe, Staking, etc.) genesis config will not be loaded during forkless runtime upgrade, could it be related to that?

Can someone guide me on how to do it correctly?

Edit: This question is not similar to How to change consensus engine from PoA to PoS? The difference is this question is asking about the runtime upgrade of the chain from PoA to PoS. In the latter one, it does not tell that or even if that's possible or not.

3
  • @Squirrel Not really, with the help of that, I was able to make necessary changes. But I need to upgrade my consensus from PoA to PoS. I tried forkless runtime upgrade and binary upgrade as well but it is causing the chain to break.
    – Fenn Saji
    Commented Mar 22, 2022 at 11:30
  • 2
    Could you describe the error that you are getting?
    – Gautam D
    Commented Mar 22, 2022 at 13:15
  • @GautamDhameja I have updated the question with images of error and more description. Hope that helps.
    – Fenn Saji
    Commented Mar 23, 2022 at 4:33

1 Answer 1

9

Upgrading a chain from PoA (Proof-of-Authority) to PoS (Proof-of-Stake) is orthogonal to upgrading a chain from Aura to BABE, which is what's causing the issues you are running into. At the moment, it's not possible to change consensus engines mid-flight, which means that you will have to stick with Aura or restart the chain using BABE.

However, this doesn't rule out moving to PoS - the only difference between PoA and PoS is the mechanism by which validators are selected. In a PoA system, the validators are selected by being part of a permissioned list. In a PoS system, the validators are selected by a token-staking mechanism.

pallet_aura relies on pallet_session, which in turn outsources the actual choice of which validators are active in a session to the SessionManager. To migrate a chain to PoS, simply set this SessionManager type to be pallet_staking or some other staking pallet, and configure the staking pallet to run elections. After deploying the runtime upgrade, the chain will successfully be PoS.

You can do the same thing with BABE - just remember that you have to stick with the same consensus engine you started with.

4
  • Thanks for the answer. Is there any open-source project you know that has done this? If yes, could you please share the link to their repo?
    – Fenn Saji
    Commented Mar 25, 2022 at 6:47
  • 1
    @FennSaji github.com/dpryde258/enhanced-substrate-node-template. This is the substrate node template I fork from original substrate-node-template. It is a PoS chain but using Aura instead of Babe. It follows exactly what _rob describes to move to PoS with Aura. The reason I made this template is because Babe has a risk that may brick your chain if all your validators somehow can't produce blocks in a while. For small company like us, where we don't have much resources to monitor the nodes, it's very risky for us. That's why we decide to switch back to Aura
    – Daniel Lam
    Commented Apr 20, 2022 at 5:18
  • @DanielLam Thank you very much, very much appreciated.
    – Fenn Saji
    Commented Apr 20, 2022 at 8:01
  • Hi @rob 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. Commented Nov 11, 2022 at 12:58

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