How to test upgrades depending on a runtime upgrade not yet executed.
Overview
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.
Steps
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.
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 by one block on bridgehub (not sure if necessary, need to experiment)
await api.rpc('dev_newBlock', { count:1 })
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
await api.rpc('dev_newBlock', { count:1 })
The parachain should now be upgraded.
Caveats
Some polkadot API endpoints aggressively timeout connections, causing Chopsticks to die: Comment