Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorials: Update parachain tutorial #234

Merged
merged 12 commits into from
Dec 13, 2024

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>polkadot-omni-node key generate-node-key --base-path /tmp/parachain/pubs-demo --chain raw-parachain-chainspec.json</span>
<br />
<span data-ty="progress">2024-09-11 09:48:15 Building chain spec</span>
<span data-ty="progress">Generating key in "/tmp/parachain/pubs-demo/chains/live/network/secret_ed25519"</span>
<span data-ty="progress">12D3KooWJH816dWizsft7MXVrv1nH3dHnGsHxD1qdyQm9mMAbo7Z</span>
</div>

Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>./target/release/parachain-template-node build-spec \</span>
<span data-ty>--chain plain-parachain-chainspec.json \</span>
<span data-ty>--disable-default-bootnode \</span>
<span data-ty>--raw > raw-parachain-chainspec.json</span>
<span data-ty></span>
<span data-ty>2024-09-10 14:34:58 Building chain spec</span>
<span data-ty>2024-09-10 14:34:59 assembling new collators for new session 0 at #0</span>
<span data-ty>2024-09-10 14:34:59 assembling new collators for new session 1 at #0</span>
<span data-ty="input"><span class="file-path"></span>polkadot-omni-node export-genesis-state --chain raw-parachain-chainspec.json para-2000-genesis-state</span>
<span data-ty>2024-09-10 14:41:13 🔨 Initializing Genesis block/state (state: 0xb089…1830, header-hash: 0x6b0b…bd69)</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>./target/release/parachain-template-node export-genesis-state \ --chain raw-parachain-chainspec.json para-2000-genesis-state</span>
<span data-ty>2024-09-10 14:41:13 🔨 Initializing Genesis block/state (state: 0xb089…1830, header-hash: 0x6b0b…bd69)</span>
<span data-ty="input"><span class="file-path"></span>polkadot-omni-node \</span>
<span data-ty>--charlie \</span>
<span data-ty>--collator \</span>
<span data-ty>--force-authoring \</span>
<span data-ty>--chain raw-parachain-chainspec.json \</span>
<span data-ty>--base-path /tmp/charlie-parachain/ \</span>
<span data-ty>--unsafe-force-node-key-generation \</span>
<span data-ty>--port 40333 \</span>
<span data-ty>--rpc-port 8844 \</span>
<span data-ty>-- \</span>
<span data-ty>--chain INSERT_RELAY_CHAIN_PATH/local-raw-spec.json \</span>
<span data-ty>--port 30333 \</span>
<span data-ty>--rpc-port 9946</span>
<span data-ty></span>
<span data-ty>2024-09-10 16:26:30 [Parachain] PoV size { header: 0.21875kb, extrinsics: 3.6103515625kb, storage_proof: 3.150390625kb }</span>
<span data-ty>2024-09-10 16:26:30 [Parachain] Compressed PoV size: 6.150390625kb</span>
<span data-ty>2024-09-10 16:26:33 [Relaychain] 💤 Idle (2 peers), best: #1729 (0x3aa4…cb6b), finalized #1726 (0xff7a…4352), ⬇ 9.1kiB/s ⬆ 3.8kiB/s</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>

This file was deleted.

Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tutorials/polkadot-sdk/parachains/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ nav:
- index.md
- local-chain
- connect-to-relay-chain
- deploy-to-relay-chain
- build-custom-pallet
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
title: Connect to a Relay Chain
title: Connect to a Local Relay Chain
nav:
- index.md
- 'Prepare Relay Chain': prepare-relay-chain.md
- 'Prepare Parachain': prepare-parachain.md
- 'Acquire a TestNet Slot': acquire-a-testnet-slot.md
- 'Prepare A Local Relay Chain': prepare-relay-chain.md
- 'Prepare Local Parachain': prepare-parachain.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To build the parachain template, follow these steps:
2. Change the directory to the cloned repository

```bash
cd polkadot-sdk-solochain-template
cd polkadot-sdk-parachain-template
```

3. Build the parachain template collator
Expand Down Expand Up @@ -108,50 +108,37 @@ To modify the default chain specification, follow these steps:
1. Generate the plain text chain specification for the parachain template node by running the following command

```bash
./target/release/parachain-template-node build-spec \
--disable-default-bootnode > plain-parachain-chainspec.json
chain-spec-builder create --relay-chain paseo \
--para-id 4508 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a placeholder instead of 4508 here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only reason it's that specific ID is because earlier the para id reserved is 4508

-r <runtime.compact.compressed.wasm> \
default
```

2. Open the plain text chain specification for the parachain template node in a text editor

3. Set the `para_id` to the parachain identifier that you previously reserved. For example, if your reserved identifier is `2000`, set the `para_id` field to `2000`:
CrackTheCode016 marked this conversation as resolved.
Show resolved Hide resolved

```json
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-2.json:1:4'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-2.json:6:6'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-2.json:13:15'
```

4. Set the `parachainId` to the parachain identifier that you previously reserved. For example, if your reserved identifier is `2000`, set the `parachainId` field to `2000`
3. Set the `parachainId` to the parachain identifier that you previously reserved. For example, if your reserved identifier is `2000`, set the `parachainId` field to `2000`

```json
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-2.json:1:2'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-2.json:6:15'
```

5. If you complete this tutorial simultaneously as anyone on the same local network, an additional step is needed to prevent accidentally peering with their nodes. Find the following line and add characters to make your `protocolId` unique
4. If you complete this tutorial simultaneously as anyone on the same local network, an additional step is needed to prevent accidentally peering with their nodes. Find the following line and add characters to make your `protocolId` unique

```json
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-2.json:1:2'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-2.json:5:6'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-2.json:13:15'
```

6. Save your changes and close the plain text chain specification file
5. Save your changes and close the plain text chain specification file

7. Generate a raw chain specification file from the modified chain specification file by running the following command
6. Generate a raw chain specification file from the modified chain specification file by running the following command

```bash
./target/release/parachain-template-node build-spec \
--chain plain-parachain-chainspec.json \
--disable-default-bootnode \
--raw > raw-parachain-chainspec.json
chain-spec-builder convert-to-raw plain-parachain-chainspec.json
```

After running the command, you will see the following output:

--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-3.html'

## Prepare the Parachain Collator

With the local relay chain running and the raw chain specification for the parachain template updated, you can start the parachain collator node and export information about its runtime and genesis state.
Expand All @@ -163,30 +150,30 @@ To prepare the parachain collator to be registered:
The relay chain needs the parachain-specific runtime validation logic to validate parachain blocks. You can export the Wasm runtime for a parachain collator node by running a command similar to the following:

```bash
./target/release/parachain-template-node export-genesis-wasm \
--chain raw-parachain-chainspec.json para-2000-wasm
polkadot-omni-node export-genesis-wasm \
--chain raw-parachain-chainspec.json para-2000-wasm
```

2. Generate a parachain genesis state

To register a parachain, the relay chain needs to know the genesis state of the parachain. You can export the entire genesis state—hex-encoded—to a file by running a command similar to the following:

```bash
./target/release/parachain-template-node export-genesis-state \
--chain raw-parachain-chainspec.json para-2000-genesis-state
polkadot-omni-node export-genesis-state \
--chain raw-parachain-chainspec.json para-2000-state
```

After running the command, you will see the following output:

--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-4.html'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-3.html'

!!!note
You should note that the runtime and state you export must be for the genesis block. You can't connect a parachain with any previous state to a relay chain. All parachains must start from block 0 on the relay chain. See [Convert a Solo Chain](https://docs.substrate.io/reference/how-to-guides/parachains/convert-a-solo-chain/){target=\_blank} for details on how the parachain template was created and how to convert the chain logic—not its history or state migrations—to a parachain.

3. Start a collator node with a command similar to the following

```bash
./target/release/parachain-template-node \
polkadot-omni-node \
--charlie \
--collator \
--force-authoring \
Expand All @@ -206,7 +193,7 @@ To prepare the parachain collator to be registered:

After running the command, you will see the following output:

--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-5.html'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/prepare-parachain-4.html'

## Register With the Local Relay Chain

Expand Down Expand Up @@ -273,7 +260,7 @@ To reset the blockchain state, follow these steps:
2. Purge the parachain collator state by running the following command

```bash
./target/release/parachain-template-node purge-chain \
polkadot-omni-node purge-chain \
--chain raw-parachain-chainspec.json
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,17 @@ To start the validator nodes, follow these steps:
1. Generate the plain text chain specification file:

```bash
./target/release/polkadot build-spec \
--chain rococo-local-testnet > /tmp/plain-local-chainspec.json
chain-spec-builder create -r <path-to-runtime.compact.compressed.wasm> default
```

!!! note
Note that the network values are set to the default when generating the chain specification file with the `build-spec`. You can customize the network values by editing the chain specification file for production networks.

2. Convert the plain text chain specification file to the raw format:

```bash
./target/release/polkadot build-spec \
--chain plain-local-chainspec.json \
--raw > /tmp/raw-local-chainspec.json
```
```bash
chain-spec-builder convert-to-raw plain-parachain-chainspec.json
````

2. Start the first validator using the `alice` account by running the following command:

Expand Down Expand Up @@ -165,4 +162,4 @@ To start the validator nodes, follow these steps:

--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-relay-chain/prepare-relay-chain-2.html'

Once the relay chain nodes are running, you can proceed to the next tutorial to [set up a test parachain node and connect it](/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain) to the relay chain.
Once the relay chain nodes are running, you can proceed to the next tutorial to [set up a test parachain node and connect it](/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain) to the relay chain.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title: Deploy to a Relay Chain
nav:
- index.md
- 'Deploy on Paseo TestNet': deploy-on-paseo.md
Loading