[Discussion] Smart contract upgrade testing

As more contracts are going to upgrade to improve existing functionality or introduce new one, it’s important to maintain high quality of code.

it’s straightforward to have a security review for initial deployment, but it may become increasingly hard to have full reviewed code for every update.

One of the tools that is required to address this is ability to replay all the transactions from existing contract over the new version of the contract.

This can be part of the Sandbox environment and allow to replay transactions as part of CI.

Example will be given current contract of Sputnik v2, to specify an accounts where this contract is deployed. Then script would spin up Sandbox, fork the state of the chain as of deployment of previous version of that contract and start applying all transactions again. For overall consistency all transactions from blockchain may need to be reapplied because there might be dependencies like sending NEAR or other tokens from another account to this accounts, etc.

Finally at the end state of the contract on MainNet and in the Sandbox is compared and shown to the developer in the diff. It’s possible there are expected differences, but majority of things should be the same.

4 Likes