-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'vincent/beefy-relay-improvements' into ron/skip-mandato…
…ry-commitment
- Loading branch information
Showing
44 changed files
with
2,077 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,4 @@ go.work* | |
control/target/ | ||
web/packages/operations/.env.polkadot | ||
web/packages/operations/.env.rococo | ||
lodestar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
--- | ||
description: How to test upgrades depending on a runtime upgrade not yet executed. | ||
--- | ||
|
||
# Test Runtime Upgrades | ||
|
||
## 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. | ||
|
||
1. Install [opengov-cli](https://github.com/joepetrowski/opengov-cli) | ||
2. Build the preimage for the upgrade: | ||
|
||
<pre class="language-sh"><code class="lang-sh"><strong>opengov-cli build-upgrade --network polkadot --relay-version 1.2.0 --filename preimage.hex | ||
</strong></code></pre> | ||
|
||
3. Convert the preimage from hex to binary | ||
|
||
```sh | ||
cd upgrade-polkadot-1.2.0 | ||
xxd -r -p preimage.hex > preimage.bin | ||
``` | ||
|
||
4. Determine the size of the of preimage, save as `PREIMAGE_SIZE` | ||
|
||
On Linux: | ||
|
||
```sh | ||
$ stat -c%s preimage.bin | ||
1567371 | ||
$ export PREIMAGE_SIZE=1567371 | ||
``` | ||
|
||
On Mac: | ||
|
||
```sh | ||
$ stat -f%z preimage.bin | ||
1567371 | ||
$ export PREIMAGE_SIZE=1567371 | ||
``` | ||
|
||
5. Compute blake2-256 hash of preimage, save as PREIMAGE\_HASH | ||
|
||
```sh | ||
$ b2sum -l 256 preimage.bin | awk '{print "0x"$1}' | ||
0x15165c85152568b7f523e374ce1a5172f2aa148721d5dae0441f86c201c1a77b4 | ||
$ export PREIMAGE_HASH=0x15165c85152568b7f523e374ce1a5172f2aa148721d5dae0441f86c201c1a77b4 | ||
``` | ||
|
||
6. Create a chopsticks configuration file for the Polkadot relay chain, substituting the values generated previously:  | ||
|
||
`polkadot.yml` | ||
|
||
```yaml | ||
endpoint: wss://polkadot-rpc.dwellir.com | ||
mock-signature-host: true | ||
block: ${env.POLKADOT_BLOCK_NUMBER} | ||
db: ./polkadot.sqlite | ||
|
||
import-storage: | ||
System: | ||
Account: | ||
- - - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY | ||
- providers: 1 | ||
data: | ||
free: '10000000000000000000' | ||
ParasDisputes: | ||
$removePrefix: ['disputes'] # those can makes block building super slow | ||
Preimage: | ||
{ | ||
PreimageFor: | ||
[[[[PREIMAGE_HASH, PREIMAGE_SIZE]], PREIMAGE_WITH_LENGTH_PREFIX]], | ||
StatusFor: | ||
[[[PREIMAGE_HASH], { Requested: { count: 1, len: PREIMAGE_SIZE } }]], | ||
} | ||
``` | ||
|
||
7. Use these Chopstics config files for AssetHub and BridgeHub | ||
|
||
`polkadot-asset-hub.yml` | ||
|
||
```yaml | ||
endpoint: wss://statemint-rpc.dwellir.com | ||
mock-signature-host: true | ||
block: ${env.POLKADOT_ASSET_HUB_BLOCK_NUMBER} | ||
db: ./assethub.sqlite | ||
|
||
import-storage: | ||
System: | ||
Account: | ||
- - - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY | ||
- providers: 1 | ||
data: | ||
free: 1000000000000000 | ||
``` | ||
`polkadot-bridge-hub.yml` | ||
|
||
```yaml | ||
endpoint: wss://polkadot-bridge-hub-rpc.dwellir.com | ||
mock-signature-host: true | ||
block: ${env.POLKADOT_BRIDGEHUB_BLOCK_NUMBER} | ||
db: ./bridgehub.sqlite | ||
import-storage: | ||
System: | ||
Account: | ||
- - - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY | ||
- providers: 1 | ||
data: | ||
free: 1000000000000000 | ||
``` | ||
|
||
8. Run Chopsticks | ||
|
||
```sh | ||
yarn start xcm -r polkadot.yml -p polkadot-asset-hub.yml -p polkadot-bridge-hub.yml | ||
``` | ||
|
||
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. | ||
|
||
9. Execute the upgrade on the relay chain using Polkadot-JS: | ||
|
||
```rust | ||
const number = (await api.rpc.chain.getHeader()).number.toNumber() | ||
await api.rpc('dev_setStorage', { | ||
Scheduler: { | ||
Agenda: [ | ||
[ | ||
[number + 1], | ||
[ | ||
{ | ||
call: { | ||
Lookup: { | ||
hash: PREIMAGE_HASH, | ||
len: PREIMAGE_SIZE, | ||
}, | ||
}, | ||
origin: { | ||
system: 'Root', | ||
}, | ||
}, | ||
], | ||
], | ||
], | ||
}, | ||
}) | ||
await api.rpc('dev_newBlock', { count: 1 }) | ||
``` | ||
|
||
10. Advance a few blocks on the relay chain | ||
|
||
```rust | ||
await api.rpc('dev_newBlock', { count: 2 }) | ||
``` | ||
|
||
11. Advance by one block on bridgehub (not sure if necessary, need to experiment) | ||
|
||
```rust | ||
await api.rpc('dev_newBlock', { count: 1 }) | ||
``` | ||
|
||
12. 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: | ||
|
||
<figure><img src="../.gitbook/assets/image.png" alt=""><figcaption></figcaption></figure> | ||
|
||
12. Advance a few blocks on both bridgehub AND the relay chain | ||
|
||
```rust | ||
await api.rpc('dev_newBlock', { count: 1 }) | ||
``` | ||
|
||
14. The parachain should now be upgraded. | ||
|
||
## Caveats | ||
|
||
Some polkadot API endpoints aggressively timeout connections, causing Chopsticks to die: Comment | ||
|
||
```sh | ||
API-WS: disconnected from wss://polkadot-rpc.dwellir.com: 1006:: Abnormal Closure | ||
``` | ||
|
||
The usual remedy is to restart chopsticks and pray the API connections don't die again. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule lodestar
deleted from
5d93a6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.