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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>./target/release/parachain-template-node build-spec --chain plain-parachain-chainspec.json --disable-default-bootnode --raw > raw-parachain-chainspec.json</span>
<span data-ty="input"><span class="file-path"></span>polka-omni-node build-spec --chain plain-parachain-chainspec.json --disable-default-bootnode --raw > raw-parachain-chainspec.json</span>
CrackTheCode016 marked this conversation as resolved.
Show resolved Hide resolved
<br />
<span data-ty="progress">2024-09-11 09:48:15 Building chain spec</span>
<span data-ty="progress">2024-09-11 09:48:15 assembling new collators for new session 0 at #0</span>
Expand Down
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>

Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion tutorials/polkadot-sdk/parachains/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ title: Parachains
nav:
- index.md
- local-chain
- connect-to-relay-chain
- connect-to-relay-chain
- deploy-to-relay-chain
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 @@ -165,4 +165,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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: Acquire a TestNet Slot
description: This guide walks you through the journey of securing a TestNet slot on Paseo for your parachain, detailing each step to a successful registration.
title: Deploy on Paseo TestNet
description: This guide walks you through the journey of deploying your Polkadot SDK blockchain on Paseo, detailing each step to a successful TestNet deployment.
---

# Acquire a TestNet Slot
# Deploy on Paseo

## Introduction

Expand All @@ -14,18 +14,22 @@ This tutorial demonstrates deploying a parachain on a public test network like t
Before you start, you need to have the following prerequisites:

- You know how to generate and modify chain specification files as described in the [Generate Chain Specs](/develop/parachains/deployment/generate-chain-specs){target=\_blank} section
- You have installed the [`polkadot-omni-node`](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/omni_node/index.html){target=\_blank} and [`chain-spec-builder`](https://docs.rs/staging-chain-spec-builder/latest/staging_chain_spec_builder/){target=\_blank} binaries
CrackTheCode016 marked this conversation as resolved.
Show resolved Hide resolved
- You know how to generate and store keys as described in the [Spin Your Nodes](/tutorials/polkadot-sdk/parachains/local-chain/spin-your-nodes){target=\_blank} tutorial
- You have completed the [Prepare a Local Relay Chain](/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-relay-chain/){target=\_blank} and the [Prepare a Local Parachain](/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain/){target=\_blank} tutorials on your local computer
CrackTheCode016 marked this conversation as resolved.
Show resolved Hide resolved

## Get Started with an Account and Tokens

To perform any action on Paseo, you need PAS tokens, which can be requested from the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank}. Also, to store the tokens, you must have access to a Substrate-compatible digital currency wallet. Development keys and accounts should never hold assets of actual value and should not be used for production. Many options are available for holding digital currency—including hardware wallets and browser-based applications—and some are more reputable than others. You should do your own research before selecting one.
To perform any action on Paseo, you need PAS tokens, which can be requested from the [Polkadot Faucet](https://faucet.polkadot.io/){target=\_blank}. To store the tokens, you must have access to a Substrate-compatible wallet. Go to the [Wallets and Extensions](https://wiki.polkadot.network/docs/wallets-and-extensions){target=\_blank} page on the Polkadot Wiki to view different options for a wallet, or use the [Polkadot.js browser extension](https://polkadot.js.org/extension/){target=\_blank}, which is suitable for development purposes.

However, you can use the [Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank} interface to get you started for testing purposes.
!!!warning
Development keys and accounts should never hold assets of actual value and should not be used for production.

The [Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank} interface can be used to get you started for testing purposes.

To prepare an account, follow these steps:

1. Open the [Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank} interface and connect to the Paseo network
1. Open the [Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank} interface and connect to the Paseo network. Alternatively use this link to connect directly to Paseo: [Polkadot.js Apps: Paseo](https://polkadot.js.org/apps/?rpc=wss://paseo.dotters.network#/explorer){target=\_blank}

![](/images/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.webp)

Expand All @@ -47,7 +51,7 @@ To prepare an account, follow these steps:

## Reserve a Parachain Identifier

You must reserve a parachain identifier before registering a parathread on Paseo. The steps are similar to the ones you followed in [Prepare a Local Parachain](/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain){target=_\blank} to reserve an identifier on the local relay chain. However, for the public TestNet, you'll be assigned the next available identifier.
You must reserve a parachain identifier (ID) before registering your parachain on Paseo. The steps are similar to the ones you followed in [Prepare a Local Parachain](/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/prepare-parachain){target=_\blank} to reserve an identifier on the local relay chain. However, for the public TestNet, you'll be assigned the next available identifier.

To reserve a parachain identifier, follow these steps:

Expand All @@ -57,7 +61,7 @@ To reserve a parachain identifier, follow these steps:

![](/images/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-5.webp)

2. Register a parathread
2. Register a ParaId
1. Select the **Parathreads** tab
2. Click on the **+ ParaId** button

Expand All @@ -73,50 +77,46 @@ To reserve a parachain identifier, follow these steps:

![](/images/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-8.webp)

## Modify the Chain Specification File
## Generate the Chain Specification

The files required to register a parachain must specify the correct relay chain to connect to and the parachain identifier you have been assigned. To make these changes, you must build and modify the chain specification file for your parachain. In this tutorial, the relay chain is `paseo`, and the parachain identifier is `4508`.

To modify the chain specification:

1. Generate the plain text chain specification for the parachain template node by running the following command:
1. Generate the plain chain specification for the parachain template node by running the following command. You should find your runtime's Wasm file inside `target/release/wbuild`:

```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.

ditto

-r <runtime.compact.compressed.wasm>
```
!!!info
Be sure to use the `*.compact.compressed.wasm` version of your file when generating your chain specification.

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

3. Set `relay_chain` to `paseo` and `para_id` to the identifier you've been assigned. For example, if your reserved identifier is 4508, set the `para_id` field to `4508`:

```json
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.json:1:4'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.json:23:25'
```

4. Set the `parachainId` to the parachain identifier that you previously reserved:
3. Set the `parachainId` to the parachain identifier that you previously reserved:
CrackTheCode016 marked this conversation as resolved.
Show resolved Hide resolved

```json
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.json::2'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.json:5:10'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.json:22:25'
```

5. Add the public key for your account to the session keys section. Each configured session key will require a running collator:
4. Add the public key for your account to the session keys section. Each configured session key will require a running collator:

```json
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.json::2'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.json:5:7'
--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.json:11:25'
```

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:
6. Generate a raw chain specification file from the modified chain specification file:

```bash
./target/release/parachain-template-node build-spec \
polkadot-omni-node build-spec \
--chain plain-parachain-chainspec.json \
--disable-default-bootnode \
--raw > raw-parachain-chainspec.json
Expand All @@ -133,41 +133,70 @@ To prepare the parachain collator to be registered on Paseo, follow these steps:
1. Export the Wasm runtime for the parachain by running a command similar to the following:

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

2. Export the genesis state for the parachain by running a command similar to the following:

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

## Register a Parathread

Once you have the genesis state and runtime, you can now register these with your parachain ID.

1. Go to the [Parachains > Parathreads](https://polkadot.js.org/apps/#/parachains/parathreads){target=\_blank} tab, and select **+ Parathread**

2. You should see fields to place your runtime Wasm and genesis state respectively, along with the parachain ID. Select your parachain ID, and upload `para-4508-wasm` in the "code" field and `para-4508-state` in the "initial state" field:

![](/images/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-9.webp)

3. Confirm your details and **+ Submit** button, where there should be a new Parathread with your parachain ID and an active **Deregister** button:

![](/images/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/acquire-a-testnet-slot-10.webp)

Your parachain's runtime logic and genesis are now part of the relay chain. The next step is to ensure you are able to run a collator to produce blocks for your parachain.

## Start the Collator Node

Before starting a collator, generate a node key. A node key is responsible for communicating with other nodes over Libp2p:

```bash
polkadot-omni-node key generate-node-key \
--base-path /tmp/parachain/pubs-demo \
--chain raw-parachain-chainspec.json
```

After running the command, you should see the following output, indicating the base path now has a suitable node key:

--8<-- 'code/tutorials/polkadot-sdk/parachains/connect-to-relay-chain/acquire-a-testnet-slot/deploy-on-paseo-3.html'

You must have the ports for the collator publicly accessible and discoverable to enable parachain nodes to peer with Paseo validator nodes to produce blocks. You can specify the ports with the `--port` command-line option. For example, you can start the collator with a command similar to the following:

```bash
./target/release/parachain-template-node --collator \
polkadot-omni-node --collator \
--chain raw-parachain-chainspec.json \
--base-path /tmp/parachain/pubs-demo \
--port 50333 \
--rpc-port 8855 \
-- \
--execution wasm \
--chain paseo \
--port 50343 \
--rpc-port 9988
```

In this example, the first `--port` setting specifies the port for the collator node and the second `--port` specifies the embedded relay chain node port. The first `--rpc-port` setting specifies the port you can connect to the collator. The second `--rpc-port` specifies the port for connecting to the embedded relay chain.

## Obtain Coretime
## Producing Blocks

With your parachain collator operational, the next step is acquiring coretime. This is essential for ensuring your parachain's security through the relay chain. [Agile Coretime](https://wiki.polkadot.network/docs/learn-agile-coretime){target=\_blank} enhances Polkadot's resource management, offering developers greater economic adaptability. Once you have configured your parachain, you can follow two paths:

- Bulk coretime is purchased via the Broker pallet on the respective coretime system parachain. You can purchase bulk coretime on the coretime chain and assign the purchased core to the registered `ParaID`
- On-demand coretime is ordered via the `OnDemandAssignment` pallet, which is located on the respective relay chain

Once coretime is correctly assigned to your parachain, whether bulk or on-demand, blocks should be produced (provided your collator is running).

For more information on coretime, refer to the [Coretime](/polkadot-protocol/architecture/system-chains/coretime/){target=\_blank} documentation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Deploy on a Relay Chain
description: Learn how to deploy on a live relay chain including, how to acquire Coretime, manage / setup collators, and what artifacts are needed to deploy your parachain.
hide:
- feedback
CrackTheCode016 marked this conversation as resolved.
Show resolved Hide resolved
template: index-page.html
---

# Deploy to a Relay Chain

Deploying to a relay chain generally involves the following steps:

1. Reserving your Parachain's ID
2. Uploading the genesis state and runtime
3. Ensuring you have collators ready to deploy (or at least one running locally to produce blocks)
4. Obtaining Coretime - Either Bulk (long term block production) or On Demand (ordering blocks as you need)

Depending on the relay chain you are deploying on, the costs for registering the runtime and genesis state will vary. If you are registering on a TestNet like [Paseo](/develop/networks/#paseo), you will have to apply for a slot through a form or ask for enough PAS to register your runtime code:

- [Paseo Parachain Onboarding Form](https://github.com/paseo-network/support/issues/new?assignees=al3mart%2Chbulgarini%2Ceduclerici-zondax&labels=onboard-para&projects=&template=onboard-parachain.yaml&title=%5BParachain+Onboarding+%7C+Slot+Request%5D+ParaId%3A+%3Cyour_paraId%3E){target=\_blank}
- [Paseo Support Matrix Chat Room](https://matrix.to/#/#paseo-testnet-support:parity.io){target=\_blank}

## In This Section

:::INSERT_IN_THIS_SECTION:::
CrackTheCode016 marked this conversation as resolved.
Show resolved Hide resolved