Skip to content

Commit

Permalink
GITBOOK-88: Add Preimage with length prefix part
Browse files Browse the repository at this point in the history
  • Loading branch information
Clara van Staden authored and gitbook-bot committed Jul 15, 2024
1 parent c8ea65c commit a6d24b8
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions docs/operations/test-runtime-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ $ b2sum -l 256 preimage.bin | awk '{print "0x"$1}'
$ export PREIMAGE_HASH=0x15165c85152568b7f523e374ce1a5172f2aa148721d5dae0441f86c201c1a77b4
```

6. Create a chopsticks configuration file for the Polkadot relay chain, substituting the values generated previously: 
6. Prepend compact-encoded length prefix to preimage, and convert back to hex, save as PREIMAGE\_WITH\_LENGTH\_PREFIX:

```rust
use codec::Encode;
use std::fs::File;

fn main() {
let mut file = File::open("preimage.bin")?;
let mut buf: Vec<u8> = Vec::new();
file.read_to_end(&mut buf)?;
let bytes_encoded = buf.encode();
println!("0x{}", hex::encode(bytes_encoded));
}
```

7. Create a chopsticks configuration file for the Polkadot relay chain, substituting the values generated previously:&#x20;

`polkadot.yml`

Expand Down Expand Up @@ -81,7 +96,7 @@ import-storage:
}
```

7. Use these Chopstics config files for AssetHub and BridgeHub
8. Use these Chopstics config files for AssetHub and BridgeHub

`polkadot-asset-hub.yml`

Expand Down Expand Up @@ -117,15 +132,15 @@ import-storage:
free: 1000000000000000
```

8. Run Chopsticks
9. 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:
10. Execute the upgrade on the relay chain using Polkadot-JS:

```rust
const number = (await api.rpc.chain.getHeader()).number.toNumber()
Expand Down Expand Up @@ -156,29 +171,29 @@ await api.rpc('dev_setStorage', {
await api.rpc('dev_newBlock', { count: 1 })
```

10. Advance a few blocks on the relay chain
11. 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)
12. 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:
13. 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
14. 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.
15. The parachain should now be upgraded.

## Caveats

Expand Down

0 comments on commit a6d24b8

Please sign in to comment.