Test Runtime Upgrades
How to test upgrades depending on a runtime upgrade not yet executed.
Last updated
How to test upgrades depending on a runtime upgrade not yet executed.
Last updated
A scenario that frequently occurs is that we need to test a Snowbridge-related runtime upgrade that depends on a system parachain upgrade. Runtime upgrades for system parachains can take up to four weeks to execute. If we wait for the system parachain upgrade to complete first before initiating the Snowbridge upgrades, release cycles could take months.
Therefore, it is useful to be able to test system parachain upgrades that have not yet executed and then apply Snowbridge upgrades to ensure everything works.
In the following scenario, we will simulate execution of the 1.2.0 upgrade: https://github.com/polkadot-fellows/runtimes/releases/tag/v1.2.0.
Install
Build the preimage for the upgrade:
Convert the preimage from hex to binary
Determine the size of the of preimage, save as PREIMAGE_SIZE
On Linux:
On Mac:
Compute blake2-256 hash of preimage, save as PREIMAGE_HASH
Prepend compact-encoded length prefix to preimage, and convert back to hex, save as PREIMAGE_WITH_LENGTH_PREFIX:
Create a chopsticks configuration file for the Polkadot relay chain, substituting the values generated previously:
polkadot.yml
Use these Chopstics config files for AssetHub and BridgeHub
polkadot-asset-hub.yml
polkadot-bridge-hub.yml
Run Chopsticks
A verification step that can be performed to see if the preimage has been added successfully is to check the preimage
storage in the chain state. The authorized preimage should be in the list of added preimages.
Execute the upgrade on the relay chain using Polkadot-JS:
Advance a few blocks on the relay chain
Advance by one block on bridgehub (not sure if necessary, need to experiment)
Now that the upgrade has been authorized on BridgeHub, we can execute the upgrade by calling parachainSystem.enactAuthorizedUpgrade, passing the parachain WASM blob previously generated by opengov-cli:
Advance a few blocks on both bridgehub AND the relay chain
The parachain should now be upgraded.
Some polkadot API endpoints aggressively timeout connections, causing Chopsticks to die: Comment
The usual remedy is to restart chopsticks and pray the API connections don't die again.