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

[Substrate.io Migration] Tutorials -> Build a Parachain -> Acquire a TestNet Slot #28

Merged
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
1a523ef
fix: adding prepare substrate relay chain
nhussein11 Sep 9, 2024
a59e5e3
fiox: formatting error
nhussein11 Sep 9, 2024
d5cc084
fix: description
nhussein11 Sep 9, 2024
5e7a4dc
fix: paraphrasing
nhussein11 Sep 9, 2024
2413eec
fix: vale warning
nhussein11 Sep 9, 2024
291a833
fix: formatting
nhussein11 Sep 9, 2024
3b73da1
fix: adding conclusion to the tutorial
nhussein11 Sep 9, 2024
fabc617
fix: formatting
nhussein11 Sep 10, 2024
5316122
fix: formatting
nhussein11 Sep 10, 2024
763f598
git: adding intro and build the parachain template section
nhussein11 Sep 10, 2024
d27184f
fix: adding wip
nhussein11 Sep 10, 2024
ff83f15
fix: updating prepare relay chain output and commands
nhussein11 Sep 10, 2024
339514f
Merge branch 'nhussein11/tutorials-substrate-prepare-relay-chain' int…
nhussein11 Sep 10, 2024
907bff6
fix: adding build a parachain complete process
nhussein11 Sep 10, 2024
75d518f
fix: vale suggestion
nhussein11 Sep 10, 2024
77509c5
fix: adding acquire a slot on testnet wip
nhussein11 Sep 11, 2024
a83ddde
fix: adding admin account example
nhussein11 Sep 11, 2024
a956e4a
fix: typos
nhussein11 Sep 11, 2024
2a7f3b3
fix: typo
nhussein11 Sep 11, 2024
010a96d
fix: typo
nhussein11 Sep 11, 2024
4d2296c
fix: formatting
nhussein11 Sep 11, 2024
5f7a28c
fix: formatting
nhussein11 Sep 11, 2024
213814e
fix: typo and adding abs route to build a local blockchain tutorial
nhussein11 Sep 11, 2024
1286b44
fix: paraphrasing
nhussein11 Sep 11, 2024
4f2a152
fix: updating deprecated route
nhussein11 Sep 11, 2024
f8b1fa8
fix: paraphrasing
nhussein11 Sep 11, 2024
1cb5f77
fix: formatting
nhussein11 Sep 11, 2024
5274116
fix: chain specs decoupled from substrate website
nhussein11 Sep 11, 2024
6bfe5e4
Update tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md
nhussein11 Sep 23, 2024
6446b16
fix: typo
nhussein11 Sep 23, 2024
aa08eca
fix: removing redundant commands on terminal elements
nhussein11 Sep 23, 2024
8acc357
fix: adding disclaimer for chain spec generation
nhussein11 Sep 23, 2024
231eafe
fix: removing redundant commands on terminal elements
nhussein11 Sep 23, 2024
1cac723
fix: removing unnecessary info
nhussein11 Sep 23, 2024
38ab69e
fix: addin small clarification about sudo txs
nhussein11 Sep 23, 2024
357bd72
fix: clarification about sudo changes
nhussein11 Sep 23, 2024
7a21a64
Update tutorials/polkadot-sdk/build-a-parachain/connect-a-parachain.md
nhussein11 Sep 23, 2024
bd8ff69
fix: adding missing terminal output
nhussein11 Sep 23, 2024
df3357c
fix: adding image to register with the local relay chain process, step 6
nhussein11 Sep 23, 2024
f463234
Apply suggestions from code review
nhussein11 Sep 24, 2024
ac7f71a
fix: moving terminal outputs to code snippets
nhussein11 Sep 24, 2024
1bd5b34
Merge branch 'master' into nhussein11/tutorials-substrate-prepare-rel…
nhussein11 Sep 24, 2024
daadd83
Merge branch 'nhussein11/tutorials-substrate-prepare-relay-chain' int…
nhussein11 Sep 24, 2024
6516f69
fix: adding clarification over resetting bc state
nhussein11 Sep 24, 2024
2f06bc0
fix: replacing Polkadot.Js by Polkadot.js
nhussein11 Sep 24, 2024
8ff9ead
fix: update acquire-a-testnet-slot to paseo and coretime docs
nhussein11 Sep 25, 2024
d4f68e4
fix: adding hook to further tutorials
nhussein11 Sep 25, 2024
5b11e48
Merge branch 'nhussein11/tutorials-substrate-connect-a-parachain' int…
nhussein11 Sep 25, 2024
bdebf22
Merge branch 'master' into nhussein11/tutorials-substrate-acquire-a-t…
nhussein11 Sep 25, 2024
1285978
clean up formatting and grammar
eshaben Sep 26, 2024
ef0fb86
fix snippet
eshaben Sep 26, 2024
e06581f
fix typo
eshaben Sep 26, 2024
8a6e3ac
update .pages file
eshaben Sep 26, 2024
038ca60
Merge remote-tracking branch 'origin/master' into nhussein11/tutorial…
eshaben Sep 26, 2024
4c67b3a
Merge remote-tracking branch 'origin/master' into nhussein11/tutorial…
eshaben Sep 26, 2024
a4ac880
Merge remote-tracking branch 'origin/master' into nhussein11/tutorial…
eshaben Sep 30, 2024
4fa1807
resolve merge conflicts
eshaben Sep 30, 2024
f450181
Update tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slo…
nhussein11 Oct 2, 2024
1098be0
Apply suggestions from code review
nhussein11 Oct 2, 2024
9b22d91
Update tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md
nhussein11 Oct 2, 2024
510ab2d
fix: decoupling from substrate documentation
nhussein11 Oct 2, 2024
316b4f1
fix: adding missed colons
nhussein11 Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tutorials/.pages
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
title: Tutorials
nav:
- index.md
- polkadot-sdk
2 changes: 1 addition & 1 deletion tutorials/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Step-by-Step Tutorials
title: Tutorials
description: TODO
hide:
- feedback
Expand Down
4 changes: 4 additions & 0 deletions tutorials/polkadot-sdk/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title: Polkadot SDK Tutorials
nav:
- index.md
- build-a-parachain
6 changes: 6 additions & 0 deletions tutorials/polkadot-sdk/build-a-parachain/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title: Build a Parachain Tutorials
nav:
- index.md
- prepare-relay-chain.md
- connect-a-parachain.md
- acquire-a-testnet-slot.md
268 changes: 268 additions & 0 deletions tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
---
title: Acquire a Testnet Slot
description: This guide walks you through the journey of securing a TestNet slot on Rococo for your parachain, detailing each step to a successful registration.
---

# Acquire a Testnet Slot
eshaben marked this conversation as resolved.
Show resolved Hide resolved

## Introduction

This tutorial demonstrates how you can deploy a parachain on a public test network, such as the Rococo test network. Public TestNets have a higher bar to entry than a private network, but represent an important step in preparing a parachain project to move into a production network.

## Prerequisites

Before you start, you need to have the following prerequisites:

- You know how to generate and modify chain specification files as described in the [Add Trusted Nodes](/tutorials/polkadot-sdk/build-a-blockchain/add-trusted-nodes/){target=\_blank} tutorial
- You know how to generate and store keys as described in the [Add Trusted Nodes](/tutorials/polkadot-sdk/build-a-blockchain/add-trusted-nodes/){target=\_blank} tutorial
- You have completed the [Prepare a Local Relay Chain](/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/){target=\_blank} and the [Connect a Local Parachain](/tutorials/polkadot-sdk/build-a-parachain/connect-a-parachain.md){target=\_blank} tutorials on your local computer
eshaben marked this conversation as resolved.
Show resolved Hide resolved

## Get Started with an Account and Tokens

To perform any action on Rococo, you need ROC tokens and to store the tokens, you must have access to a Substrate-compatible digital currency wallet. You can't use [development keys and accounts](https://docs.substrate.io/reference/command-line-tools/subkey/#predefined-accounts-and-keys){target=\_blank} for operations in any public setting. There are many options 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.
eshaben marked this conversation as resolved.
Show resolved Hide resolved

However, you can use the [Polkadot.Js Apps](https://polkadot.js.org/apps/){target=\_blank} interface to get you started for testing purposes.
eshaben marked this conversation as resolved.
Show resolved Hide resolved
nhussein11 marked this conversation as resolved.
Show resolved Hide resolved

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 Rococo network
eshaben marked this conversation as resolved.
Show resolved Hide resolved

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-1.webp)

2. Navigate to the **Accounts** section:
1. Click on the **Accounts** tab in the top menu
2. Select the **Accounts** option from the dropdown menu

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-2.webp)

3. Copy the address of the account you want to use for the parachain deployment

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-3.webp)

4. Visit the [Polkadot Faucer](https://faucet.polkadot.io){target=\_blank} and paste the copied address in the input field. Ensure that the network is set to Rococo and click on the **Get some ROCs** button

Choose a reason for hiding this comment

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

🚫 [vale] reported by reviewdog 🐶
[Vale.Spelling] Did you really mean 'Faucer'?

eshaben marked this conversation as resolved.
Show resolved Hide resolved

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-4.webp)

After a few seconds, you will receive 100 ROC tokens in your account.
eshaben marked this conversation as resolved.
Show resolved Hide resolved

!!! note
Alternatively you can join the [Rococo Element Channel](https://matrix.to/#/#rococo-faucet:matrix.org){target=\_blank} and send a message with `!drip` and the public address for your Rococo to get 100 ROC in your wallet. For example, send a message similar to the following: `!drip 5HErbKmL5JmUKDVsH1aGyXTGZb4i9iaNsFhSgkNDr8qp2Dvj`
eshaben marked this conversation as resolved.
Show resolved Hide resolved

## Reserve a Parachain Identifier

You must reserve a parachain identifier before you can register as a parathread on Rococo. The steps are similar to the ones you followed in [Connect a Local Parachain](/tutorials/polkadot-sdk/build-a-parachain/connect-a-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:

1. Navigate to the **Parachains** section
eshaben marked this conversation as resolved.
Show resolved Hide resolved
1. Click on the **Network** tab in the top menu
2. Select the **Parachains** option from the dropdown menu
eshaben marked this conversation as resolved.
Show resolved Hide resolved

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-5.webp)

2. Register a parathread
nhussein11 marked this conversation as resolved.
Show resolved Hide resolved
1. Select the **Prathreads** tab
eshaben marked this conversation as resolved.
Show resolved Hide resolved
eshaben marked this conversation as resolved.
Show resolved Hide resolved
2. Click on the **+ ParaId** button

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-6.webp)

3. Review the transaction and click on the **+ Submit** button

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-7.webp)

For this case, the next available parachain identifier is `4105`.

4. After submitting the transaction, you can navigate to the Explorer tab and check the list of recent events for successful `registrar.Reserved`

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-8.webp)

## Modify the Chain Specification File

The files required to register a parachain must specify the correct relay chain to connect to and parachain identifier that 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 `rococo` instead of `rococo-local` used in the [Connect a Local Parachain](/tutorials/polkadot-sdk/build-a-parachain/connect-a-parachain/){target=\_blank} tutorial and the para identifier is `4105`.

To modify the chain specification:

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

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

3. Set relay-chain to rococo and para_id to the identifier you've been assigned
eshaben marked this conversation as resolved.
Show resolved Hide resolved
eshaben marked this conversation as resolved.
Show resolved Hide resolved
eshaben marked this conversation as resolved.
Show resolved Hide resolved

For example, if your reserved identifier is 4105, set the `para_id` field to `4105`:

```json
...
"relay_chain": "rococo",
"para_id": 4105,
"codeSubstitutes": {},
"genesis": {
...
}
...
```

4. Set the `parachainId` to the parachain identifier that you previously reserved.

```json
...
"parachainSystem": null,
"parachainInfo": {
"parachainId": 4105
},
...
```

5. Add the public key for your account to the session keys section. Each configured session key will require a running collator
nhussein11 marked this conversation as resolved.
Show resolved Hide resolved

```json
...
"session": {
"keys": [
[
"5HErbKmL5JmUKDVsH1aGyXTGZb4i9iaNsFhSgkNDr8qp2Dvj",
"5HErbKmL5JmUKDVsH1aGyXTGZb4i9iaNsFhSgkNDr8qp2Dvj",
{
"aura": "5HErbKmL5JmUKDVsH1aGyXTGZb4i9iaNsFhSgkNDr8qp2Dvj"
}
],
]
}
...
```

6. 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:

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

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

<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>
<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>
<span data-ty="progress">2024-09-11 09:48:15 assembling new collators for new session 1 at #0</span>
</div>

## Export Required Files

To prepare the parachain collator to be registered on Rococo, follow these steps:

1. Export the WebAssembly runtime for the parachain by running a command similar to the following:

```bash
./target/release/parachain-template-node export-genesis-wasm --chain raw-parachain-chainspec.json para-4105-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 --chain raw-parachain-chainspec.json para-4105-state
```

## Start the Collator Node

You must have the ports for the collator publicly accessible and discoverable to enable parachain nodes to peer with Rococo validator nodes to produce blocks. You can specify the ports to use 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 \
--chain raw-parachain-chainspec.json \
--base-path /tmp/parachain/pubs-demo \
--port 50333 \
--rpc-port 8855 \
-- \
--execution wasm \
--chain rococo \
--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 port for the embedded relay chain node. The first `--rpc-port` setting specifies the port you can use to connect to collator. The second `--rpc-port` specifies the port for connecting to the embedded relay chain.

## Register as a Parathread
eshaben marked this conversation as resolved.
Show resolved Hide resolved

Before you can lease a slot on a public relay chain to become a parachain, you must register as a parathread on Rococo.

To register as a parathread, follow these steps:

1. Navigate to the **Parachains** section
eshaben marked this conversation as resolved.
Show resolved Hide resolved
1. Click on the **Network** tab in the top menu
2. Select the **Parachains** option from the dropdown menu
eshaben marked this conversation as resolved.
Show resolved Hide resolved

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-5.webp)

2. Register a parathread
1. Select the **Parathreads** tab
2. Click on the **+ ParaThread** button
eshaben marked this conversation as resolved.
Show resolved Hide resolved

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-9.webp)

3. Fill in the required fields:
- **parachain owner** - the account that will own the parachain
- **code** - the wasm code of the parachain
eshaben marked this conversation as resolved.
Show resolved Hide resolved
eshaben marked this conversation as resolved.
Show resolved Hide resolved
- **initial state** - the genesis state of the parachain
- Click on the **+ Submit** button

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-10.webp)

4. After submitting the transaction, you can navigate to the Explorer tab and check the list of recent events for successful `parathread.Registered`

![](/images/tutorials/polkadot-sdk/build-a-parachain/acquire-a-testnet-slot/acquire-a-testnet-slot-11.webp)

After registering as a parathread, you can lease a slot on the Rococo relay chain to become a parachain.

## Request a Parachain Slot
nhussein11 marked this conversation as resolved.
Show resolved Hide resolved

After the parachain is active as a parathread, the related project team should open a request for either a permanent or a temporary parachain slot on Rococo.

- `Permanent slots` are typically assigned to teams who have completed a successful slot lease auction and have deployed a parachain with a slot on Polkadot.
Permanent slots enable those teams to continuously test their codebase for compatibility with the latest Polkadot features in a live public environment. Only a limited number of permanent slots are available.

- `Temporary slots` are parachain slots that are dynamically allocated in a continuous, round-robbin style rotation.

At the start of every lease period, a certain number of parathreads—up to a maximum defined in the relay chain configuration—are automatically upgraded to parachains for a certain duration. The parachains that were active during the ending lease period are automatically downgraded to parathreads to free the slots for others to use in the subsequent period. Temporary slots with dynamic allocation enables teams who don't have a parachain slot on Polkadot to test their runtimes more often in a realistic network environment.

### Submitting a Slot Request

The Rococo runtime requires sudo access to assign slots. For example, the Rococo runtime specifies that the account used to assign slots must have root level permissions:

```rust
AssignSlotOrigin = EnsureRoot<Self::AccountId>;
```

Eventually, slot assignment is intended to be community-driven through Rococo governance. However, the Rococo sudo key is currently controlled by Parity Technologies. Therefore, you must submit a [Rococo Slot Request](https://github.com/paritytech/subport/issues/new?assignees=&labels=Rococo&template=rococo.yaml){target=\_blank} to receive a slot assignment. After the slot is assigned, you'll receive notification and be ready to connect.

### Assigning a Slot using an Administrative Account

If you have an account with the `AssignSlotOrigin` origin, you can use that account to assign a temporary slot on the Rococo network.

To assign a temporary slot, you can use the `assignTempParachainSlot` extrinsic from the `assignedSlots` pallet. The extrinsic will need the reserved parachain identifier and the lease period start (you can use the current block number as the lease period start, by choosing the `Current` option). If the current slot is full, you'll be assigned the next available slot.

In your account doesn't have sufficient privileges, the transaction will fail with a `BadOrigin` error.

### Lease duration

The current lease duration and slot availability settings for assigned parachain slots on Rococo are currently:

- Permanent slot lease duration: 1 year (365 days)
- Temporary slot lease duration: 3 days
- Maximum number of permanent slots: up to 25 permanent slots
- Maximum number of temporary slots: up to 20 temporary slots
- Maximum temporary slots allocated per leased period: up to 5 temporary slots per 3-day temporary lease periods
-
These setting are subject to change based on the needs of the community.



## Test your parachain

After a slot is assigned and activated for you, you can test your parachain on the Rococo test network. Note that when the temporary slot lease period ends, the parachain is automatically downgraded to a parathread. Registered and approved slots are cycled through automatically in a round-robin fashion, so you can expect to come back online as a parachain from time to time.

Loading
Loading