How to keep the chain data consistent after upgrading with new features?

When we change some codes on BaseApp or some parameters in our app.go, we have to restart a new chain to see the changes to take effect. This is not practical in production as even if we start a new chain with the old app state, the transactions were all gone. This happens with the several gaia testnets as well. When the chain halts, new patches can’t be applied and all validators have to start a new chain with upgraded software to avoid those issues.

How can we assure that we can keep the old chain data and continue with a live chain when we upgrade our dapp software or compile with a new version of the SDK? Any guidelines on how starting a new chain can be prevented? And are there any ways to apply hotfixes when the chain is halted?

2 Likes

Any suggestions for this so far?

Since the consensus will be made on KVStore, the most simple solution is just update the code and restart all validators without reset, as long as there is no transaction write different value to KVStore. For example, If you simply run the counter example and you wanna change counter increment from +1 to +2, you can just modify the code and restart all validators. Just make sure there is no new transaction coming during restart window, which causes the updated validators set counter +2 and those not updated validators set counter +1. This solution is simple but the problem is that the new validator can’t join this chain except they run different code during different time window.

So it would be naturally come up with second solution: when you need to update the counter from +1 to +2, you just wrap your new code with kind of if condition block says that after a certain block height the counter +2 and store in KVStore. By doing this you can restart validators at any time before the assign block height and new validator can run the same code to join the chain at any time.

1 Like

Thanks! I will study more on this.