As there is no way to change consensus algorithm from Aura to Babe through a forkless upgrade, we will fork the chain with
a process re-genesis, i.e. we will start a new chain with new
genesis, but the state (and not the blocks) of the old chain (PoA) will be included in the new chain's genesis so that account balances,
contracts, DIDs, etc are not lost. This new genesis will also include the PoA chain's last block hash. The new chain-will have
new spec_name
so that a client can simultaneously connect to both chains (we will be hosting a PoA chain for a while). Below
are the steps needed for re-genesis
- Short-circuit epoch of PoA chain so that pending rewards are given to validators and treasury.
- Disable emission rewards in PoA module so that emission stops
- Disable access to all important modules that can meaningfully change the state as seen here.
- Dump the state of the chain to a JSON file with this script. This is done only to compare state with the new chain.
- Brick the chain, i.e. the chain will not produce any block and can't be used anymore. This is done by setting the wasm code to empty bytes (using
setCodeWithoutChecks
). - Take the chain's last block hash and put in the
chain_spec.rs
to make the new genesis have the PoA chain's last block. - Use the fork-off script to generate the new (PoS) genesis file and download old chain's state. Make sure the necessary files like metadata, binary, runtime wasm, types, etc are present and env variables are set before running the script
- Start nodes with the new genesis file.
- Download the state of the new chain with script from step 4 and compare the JSON is same (there will be minor difference; in sudo account's nonce and in genesis accounts' locks)
- Update code and docker images with new genesis and code.