From 1a523ef22151dda7b7927f5487860c0429b26bb0 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 9 Sep 2024 16:21:58 -0300 Subject: [PATCH 01/22] fix: adding prepare substrate relay chain --- tutorials/.pages | 1 + tutorials/index.md | 2 +- tutorials/polkadot-sdk/.pages | 4 + .../polkadot-sdk/build-a-parachain/.pages | 4 + .../polkadot-sdk/build-a-parachain/index.md | 7 + .../build-a-parachain/prepare-relay-chain.md | 178 ++++++++++++++++++ tutorials/polkadot-sdk/index.md | 7 + 7 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 tutorials/polkadot-sdk/.pages create mode 100644 tutorials/polkadot-sdk/build-a-parachain/.pages create mode 100644 tutorials/polkadot-sdk/build-a-parachain/index.md create mode 100644 tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md create mode 100644 tutorials/polkadot-sdk/index.md diff --git a/tutorials/.pages b/tutorials/.pages index ec33f0aca..1cf7ae532 100644 --- a/tutorials/.pages +++ b/tutorials/.pages @@ -1,3 +1,4 @@ title: Tutorials nav: - index.md + - polkadot-sdk diff --git a/tutorials/index.md b/tutorials/index.md index c5603acf8..24957bd8b 100644 --- a/tutorials/index.md +++ b/tutorials/index.md @@ -1,5 +1,5 @@ --- -title: Step-by-Step Tutorials +title: Tutorials description: TODO hide: - feedback diff --git a/tutorials/polkadot-sdk/.pages b/tutorials/polkadot-sdk/.pages new file mode 100644 index 000000000..cf3312b39 --- /dev/null +++ b/tutorials/polkadot-sdk/.pages @@ -0,0 +1,4 @@ +title: Polkadot SDK Tutorials +nav: + - index.md + - build-a-parachain \ No newline at end of file diff --git a/tutorials/polkadot-sdk/build-a-parachain/.pages b/tutorials/polkadot-sdk/build-a-parachain/.pages new file mode 100644 index 000000000..353fb776d --- /dev/null +++ b/tutorials/polkadot-sdk/build-a-parachain/.pages @@ -0,0 +1,4 @@ +title: Build a Parachain Tutorials +nav: + - index.md + - prepare-relay-chain.md \ No newline at end of file diff --git a/tutorials/polkadot-sdk/build-a-parachain/index.md b/tutorials/polkadot-sdk/build-a-parachain/index.md new file mode 100644 index 000000000..62b295b2d --- /dev/null +++ b/tutorials/polkadot-sdk/build-a-parachain/index.md @@ -0,0 +1,7 @@ +--- +title: Build a Parachain Tutorials +description: Tutorials for building a parachain on Polkadot. These tutorials are designed to help you get started with building a parachain on Polkadot. +hide: +- feedback +template: subsection-index-page.html +--- diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md new file mode 100644 index 000000000..1af46e0f9 --- /dev/null +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -0,0 +1,178 @@ +--- +title: Prepare a Relay Chain +description: This tutorial will guide you through preparing a relay chain for a parachain, including setting up a local development environment, spinning up a new relay chain, and configuring the relay chain for parachain development. +--- + +# Prepare Relay Chain + +## Introduction + +This tutorial illustrates how to configure a local relay chain. The local relay chain is required to set up a local testing environment to which a test parachain node can connect. Setting up a local relay chain is a crucial step in parachain development. It allows developers to test their parachains in a controlled environment, simulating the interaction between a parachain and the relay chain without needing a live network. This local setup facilitates faster development cycles and easier debugging. + +The scope of this tutorial includes: + +- Installing necessary components for a local relay chain +- Configuring the relay chain settings +- Starting and running the local relay chain +- Verifying the relay chain is operational + +## Prerequisites + +Before diving into this tutorial, it's recommended that you have a basic understanding of how adding trusted nodes works in Polkadot. For further information about this process, refer to the [Add Trusted Nodes](TODO: add the absolute path to the Add Trusted Nodes tutorial) tutorial. + +To complete this tutorial, ensure that you have: +- Configured your environment for Substrate development by installing [Rust and the Rust toolchain](https://docs.substrate.io/install/){target=\_blank} +- Completed [Build a local blockchain](TODO: the add absolute path to the Build a local blockchain tutorial){target=\_blank} tutorial and know how to compile and run a Substrate node + +## Build a Local Relay Chain + +To build a local relay chain, follow these steps: + +1. Clone the most recent release branch of the Polkadot SDK repository to prepare a stable working environment. + +```bash +git clone --depth 1 --branch polkadot-stable2407-2 https://github.com/paritytech/polkadot-sdk.git +``` + +!!! note + The branch `polkadot-stable2407-2` is used in this tutorial since it is the branch that contains the latest stable release of the Polkadot SDK. You can find the latest release of the Polkadot SDK on the [Release](https://github.com/paritytech/polkadot/releases){target=\_blank} tab on the Polkadot GitHub repository. + + +!!! note + Note that the `--depth 1` flag is used to clone only the latest commit of the branch, which speeds up the cloning process. +2. Change the directory to the Polkadot SDK repository. + +```bash +cd polkadot-sdk +``` + +3. Build the relay chain node by running the following command: + +```bash +cargo build --release +``` + +!!! note + Depending on your machine’s specifications, the build process may take some time. + +4. Verify that the node is built correctly by running the following command: + +``` +./target/release/polkadot --version +``` + +If command-line help is displayed, the node is ready to configure. + +## Relay Chain Configuration + +Every Substrate-based chain requires a [chain specification](https://docs.substrate.io/build/chain-spec/){target=\_blank}. The relay chain network’s chain specification provides the same configuration settings as the chain specification does for other networks. Many of the chain specification file settings are critical for network operations. For example, the chain specification identifies peers participating in the network, keys for validators, boot node addresses, and other information. + +### Sample Chain Configuration + +The local relay chain uses a sample chain specification file with two validator relay chain nodes—Alice and Bob—as authorities for this tutorial. Because a relay chain must have at least one more validator node running than the total number of connected parachain collators, you can only use the chain specification from this tutorial for a local relay chain network with a single parachain. + +If you wanted to connect two parachains with a single collator each, you would need to run three or more relay chain validator nodes. You would need to modify the chain specification and hard-code additional validators to set up a local test network for two or more parachains. + +### Plain and Raw Chain Specification + +The chain specification file is available in two formats: a JSON file in plain text and a JSON file in SCALE-encoded raw format. + +- [Plain sample relay chain spec](https://docs.substrate.io/assets/tutorials/relay-chain-specs/plain-local-chainspec.json/){target=\_blank} +- [Raw sample relay chain spec](https://docs.substrate.io/assets/tutorials/relay-chain-specs/raw-local-chainspec.json/){target=\_blank} + +You can read and edit the plain text version of chain specification file. However, the chain specification file must be converted to the SCALE-encoded raw format before you can use it to start a node. For information about converting a chain specification to use the raw format, see [Customize a chain specification](https://docs.substrate.io/reference/how-to-guides/basics/customize-a-chain-specification/){target=\_blank}. + +The sample chain specification is only valid for a single parachain with two validator nodes. If you add other validators, add additional parachains to your relay chain, or want to use custom account keys instead of the predefined account, you'll need to create a custom chain specification file. + +Suppose you are completing this tutorial simultaneously as anyone on the same local network. In that case, you must download and modify the Plain sample relay chain spec to prevent accidentally peering with their nodes. Find the following line in the plain chain spec and add characters to make your protocolId unique: + +```json +"protocolId": "dot", +``` +## Start the Relay Chain Node + +Before starting block production for a parachain, you need to start a relay chain for them to connect. + +To start the validator nodes using the [raw sample chain specification file](https://docs.substrate.io/assets/tutorials/relay-chain-specs/raw-local-chainspec.json/){target=\_blank}, follow these steps: + +1. Download the raw chain specification file to a working directory on the local computer. + + For example, save the file as `raw-local-chainspec.json` in the `/tmp` directory. When starting the nodes, you’ll need to specify the path to the file in the commands. + +2. Start the first validator using the alice account by running the following command: + + ```bash + ./target/release/polkadot \ + --alice \ + --validator \ + --base-path /tmp/relay/alice \ + --chain /tmp/raw-local-chainspec.json \ + --port 30333 \ + --rpc-port 9944 \ + --insecure-validator-i-know-what-i-do \ + --force-authoring + ``` + + This command uses `/tmp/raw-local-chainspec.json` as the location of the sample chain specification file. Be sure the `--chain` command line specifies the path to the raw chain specification you downloaded into a local working directory. This command also uses the default values for the port (`port`) and WebSocket port (`ws-port`). The values are explicitly included here as a reminder to always check these settings. After the node starts, no other nodes on the same local machine can use these ports. + +3. Review log messages as the node starts and take note of the `Local node identity` value. This value is the node’s peer ID, which you need to connect the parachain to the relay chain. + +
+ ./target/release/polkadot \ + --alice \ + --validator \ + --base-path /tmp/relay/alice \ + --chain /tmp/raw-local-chainspec.json \ + --port 30333 \ + --rpc-port 9944 \ + --insecure-validator-i-know-what-i-do \ + --force-authoring + + 2024-09-09 13:49:58 Parity Polkadot +
+ 2024-09-09 13:49:58 ✌️ version 1.15.2-d6f482d5593 +
+ 2024-09-09 13:49:58 ❤️ by Parity Technologies , 2017-2024 +
+ 2024-09-09 13:49:58 📋 Chain specification: Rococo Local Testnet +
+ 2024-09-09 13:49:58 🏷 Node name: Alice +
+ 2024-09-09 13:49:58 👤 Role: AUTHORITY +
+ 2024-09-09 13:49:58 💾 Database: RocksDb at /tmp/relay/alice/chains/rococo_local_testnet/db/full +
+ 2024-09-09 13:49:59 🏷 Local node identity is: 12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp +
+ 2024-09-09 13:49:59 Running libp2p network backend +
+ ... +
+ +!!! note + You need to specify this identifier to enable other nodes to connect. In this case, the `Local node identity` is `12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp`. + + +4. Open a new terminal and start the second validator using the bob account. + +The command is similar to the command used to start the first node, with a few crucial differences. + +```bash +./target/release/polkadot \ +--bob \ +--validator \ +--base-path /tmp/relay/bob \ +--chain /tmp/raw-local-chainspec.json \ +--port 30334 \ +--rpc-port 9945 +``` + +Notice that this command uses a different base path (/tmp/relay/bob), validator key (`--bob`), and ports (`30334` and `9945`). + +Because both validators are running on a single local computer, it isn't necessary to specify the --bootnodes command-line option and the first node’s IP address and peer identifier. The bootnodes option is required to connect nodes outside the local network or not identified in the chain specification file. + +If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity from above): +```bash +--bootnodes \ +/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp +``` diff --git a/tutorials/polkadot-sdk/index.md b/tutorials/polkadot-sdk/index.md new file mode 100644 index 000000000..532a286e7 --- /dev/null +++ b/tutorials/polkadot-sdk/index.md @@ -0,0 +1,7 @@ +--- +title: Polkadot-SDK Tutorials +description: TODO +hide: +- feedback +template: subsection-index-page.html +--- From a59e5e3b01993ff505602c4a36761d97d72c2ab7 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 9 Sep 2024 16:22:46 -0300 Subject: [PATCH 02/22] fiox: formatting error --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 1af46e0f9..94028870a 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -21,6 +21,7 @@ The scope of this tutorial includes: Before diving into this tutorial, it's recommended that you have a basic understanding of how adding trusted nodes works in Polkadot. For further information about this process, refer to the [Add Trusted Nodes](TODO: add the absolute path to the Add Trusted Nodes tutorial) tutorial. To complete this tutorial, ensure that you have: + - Configured your environment for Substrate development by installing [Rust and the Rust toolchain](https://docs.substrate.io/install/){target=\_blank} - Completed [Build a local blockchain](TODO: the add absolute path to the Build a local blockchain tutorial){target=\_blank} tutorial and know how to compile and run a Substrate node From d5cc0842770752142d2a805b42f4cc182ecd0b9e Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 9 Sep 2024 16:25:45 -0300 Subject: [PATCH 03/22] fix: description --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 94028870a..dd447345a 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -1,6 +1,6 @@ --- title: Prepare a Relay Chain -description: This tutorial will guide you through preparing a relay chain for a parachain, including setting up a local development environment, spinning up a new relay chain, and configuring the relay chain for parachain development. +description: This tutorial will guide you through preparing a relay chain so that you can connect a test parachain node to it for local testing. --- # Prepare Relay Chain From 5e7a4dc9d5891af58bde60558edd48d6c8aaaee4 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 9 Sep 2024 16:27:38 -0300 Subject: [PATCH 04/22] fix: paraphrasing --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index dd447345a..ba205cc14 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -7,7 +7,7 @@ description: This tutorial will guide you through preparing a relay chain so tha ## Introduction -This tutorial illustrates how to configure a local relay chain. The local relay chain is required to set up a local testing environment to which a test parachain node can connect. Setting up a local relay chain is a crucial step in parachain development. It allows developers to test their parachains in a controlled environment, simulating the interaction between a parachain and the relay chain without needing a live network. This local setup facilitates faster development cycles and easier debugging. +This tutorial illustrates how to configure and spin up a local relay chain. The local relay chain is required to set up a local testing environment to which a test parachain node can connect. Setting up a local relay chain is a crucial step in parachain development. It allows developers to test their parachains in a controlled environment, simulating the interaction between a parachain and the relay chain without needing a live network. This local setup facilitates faster development cycles and easier debugging. The scope of this tutorial includes: From 2413eecab067c7c98d20fb5d44f563a73fe43109 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 9 Sep 2024 16:34:32 -0300 Subject: [PATCH 05/22] fix: vale warning --- .../polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index ba205cc14..75ca1a5af 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -172,7 +172,8 @@ Notice that this command uses a different base path (/tmp/relay/bob), validator Because both validators are running on a single local computer, it isn't necessary to specify the --bootnodes command-line option and the first node’s IP address and peer identifier. The bootnodes option is required to connect nodes outside the local network or not identified in the chain specification file. -If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity from above): +If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity from preceding): + ```bash --bootnodes \ /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp From 291a8334fd41f76c99bd8d0bff7b575df9be9c17 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 9 Sep 2024 16:43:21 -0300 Subject: [PATCH 06/22] fix: formatting --- .../build-a-parachain/prepare-relay-chain.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 75ca1a5af..254ce8a03 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -49,12 +49,12 @@ cd polkadot-sdk 3. Build the relay chain node by running the following command: -```bash -cargo build --release -``` + ```bash + cargo build --release + ``` -!!! note - Depending on your machine’s specifications, the build process may take some time. + !!! note + Depending on your machine’s specifications, the build process may take some time. 4. Verify that the node is built correctly by running the following command: @@ -150,9 +150,8 @@ To start the validator nodes using the [raw sample chain specification file](htt ... -!!! note - You need to specify this identifier to enable other nodes to connect. In this case, the `Local node identity` is `12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp`. - + !!! note + You need to specify this identifier to enable other nodes to connect. In this case, the `Local node identity` is `12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp`. 4. Open a new terminal and start the second validator using the bob account. From 3b73da196bd15b04e1b848b499cd6de1fa8b2e3b Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 9 Sep 2024 16:48:45 -0300 Subject: [PATCH 07/22] fix: adding conclusion to the tutorial --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 254ce8a03..d514291ce 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -177,3 +177,5 @@ If you don't see the relay chain producing blocks, try disabling your firewall o --bootnodes \ /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp ``` + +Once the relay chain nodes are running, you can proceed to the next tutorial to set up a test parachain node and connect it to the relay chain. \ No newline at end of file From fabc617ea2151cfce55e58346254767d2139bcdf Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Tue, 10 Sep 2024 08:23:36 -0300 Subject: [PATCH 08/22] fix: formatting --- .../build-a-parachain/prepare-relay-chain.md | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index d514291ce..007592062 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -29,38 +29,38 @@ To complete this tutorial, ensure that you have: To build a local relay chain, follow these steps: -1. Clone the most recent release branch of the Polkadot SDK repository to prepare a stable working environment. +1. Clone the most recent release branch of the Polkadot SDK repository to prepare a stable working environment -```bash -git clone --depth 1 --branch polkadot-stable2407-2 https://github.com/paritytech/polkadot-sdk.git -``` + ```bash + git clone --depth 1 --branch polkadot-stable2407-2 https://github.com/paritytech/polkadot-sdk.git + ``` -!!! note - The branch `polkadot-stable2407-2` is used in this tutorial since it is the branch that contains the latest stable release of the Polkadot SDK. You can find the latest release of the Polkadot SDK on the [Release](https://github.com/paritytech/polkadot/releases){target=\_blank} tab on the Polkadot GitHub repository. + !!! note + The branch `polkadot-stable2407-2` is used in this tutorial since it is the branch that contains the latest stable release of the Polkadot SDK. You can find the latest release of the Polkadot SDK on the [Release](https://github.com/paritytech/polkadot/releases){target=\_blank} tab on the Polkadot GitHub repository. + !!! note + Note that the `--depth 1` flag is used to clone only the latest commit of the branch, which speeds up the cloning process. -!!! note - Note that the `--depth 1` flag is used to clone only the latest commit of the branch, which speeds up the cloning process. -2. Change the directory to the Polkadot SDK repository. +2. Change the directory to the Polkadot SDK repository -```bash -cd polkadot-sdk -``` + ```bash + cd polkadot-sdk + ``` 3. Build the relay chain node by running the following command: - ```bash - cargo build --release - ``` + ```bash + cargo build --release + ``` - !!! note - Depending on your machine’s specifications, the build process may take some time. + !!! note + Depending on your machine’s specifications, the build process may take some time. 4. Verify that the node is built correctly by running the following command: -``` -./target/release/polkadot --version -``` + ``` + ./target/release/polkadot --version + ``` If command-line help is displayed, the node is ready to configure. @@ -155,27 +155,27 @@ To start the validator nodes using the [raw sample chain specification file](htt 4. Open a new terminal and start the second validator using the bob account. -The command is similar to the command used to start the first node, with a few crucial differences. + The command is similar to the command used to start the first node, with a few crucial differences. -```bash -./target/release/polkadot \ ---bob \ ---validator \ ---base-path /tmp/relay/bob \ ---chain /tmp/raw-local-chainspec.json \ ---port 30334 \ ---rpc-port 9945 -``` + ```bash + ./target/release/polkadot \ + --bob \ + --validator \ + --base-path /tmp/relay/bob \ + --chain /tmp/raw-local-chainspec.json \ + --port 30334 \ + --rpc-port 9945 + ``` -Notice that this command uses a different base path (/tmp/relay/bob), validator key (`--bob`), and ports (`30334` and `9945`). + Notice that this command uses a different base path (/tmp/relay/bob), validator key (`--bob`), and ports (`30334` and `9945`). -Because both validators are running on a single local computer, it isn't necessary to specify the --bootnodes command-line option and the first node’s IP address and peer identifier. The bootnodes option is required to connect nodes outside the local network or not identified in the chain specification file. + Because both validators are running on a single local computer, it isn't necessary to specify the --bootnodes command-line option and the first node’s IP address and peer identifier. The bootnodes option is required to connect nodes outside the local network or not identified in the chain specification file. -If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity from preceding): + If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity from preceding): -```bash ---bootnodes \ -/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp -``` + ```bash + --bootnodes \ + /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp + ``` Once the relay chain nodes are running, you can proceed to the next tutorial to set up a test parachain node and connect it to the relay chain. \ No newline at end of file From 53161229a4f0af4080179a17c2320cb75f1fd5a8 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Tue, 10 Sep 2024 08:24:27 -0300 Subject: [PATCH 09/22] fix: formatting --- .../polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 007592062..1a0027d4f 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -96,7 +96,7 @@ Before starting block production for a parachain, you need to start a relay chai To start the validator nodes using the [raw sample chain specification file](https://docs.substrate.io/assets/tutorials/relay-chain-specs/raw-local-chainspec.json/){target=\_blank}, follow these steps: -1. Download the raw chain specification file to a working directory on the local computer. +1. Download the raw chain specification file to a working directory on the local computer For example, save the file as `raw-local-chainspec.json` in the `/tmp` directory. When starting the nodes, you’ll need to specify the path to the file in the commands. @@ -116,7 +116,7 @@ To start the validator nodes using the [raw sample chain specification file](htt This command uses `/tmp/raw-local-chainspec.json` as the location of the sample chain specification file. Be sure the `--chain` command line specifies the path to the raw chain specification you downloaded into a local working directory. This command also uses the default values for the port (`port`) and WebSocket port (`ws-port`). The values are explicitly included here as a reminder to always check these settings. After the node starts, no other nodes on the same local machine can use these ports. -3. Review log messages as the node starts and take note of the `Local node identity` value. This value is the node’s peer ID, which you need to connect the parachain to the relay chain. +3. Review log messages as the node starts and take note of the `Local node identity` value. This value is the node’s peer ID, which you need to connect the parachain to the relay chain
./target/release/polkadot \ @@ -153,7 +153,7 @@ To start the validator nodes using the [raw sample chain specification file](htt !!! note You need to specify this identifier to enable other nodes to connect. In this case, the `Local node identity` is `12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp`. -4. Open a new terminal and start the second validator using the bob account. +4. Open a new terminal and start the second validator using the bob account The command is similar to the command used to start the first node, with a few crucial differences. From ff83f15010005cc65dd763b52874d6e505422728 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Tue, 10 Sep 2024 13:32:55 -0300 Subject: [PATCH 10/22] fix: updating prepare relay chain output and commands --- .../build-a-parachain/prepare-relay-chain.md | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 1a0027d4f..6379bcc43 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -106,7 +106,7 @@ To start the validator nodes using the [raw sample chain specification file](htt ./target/release/polkadot \ --alice \ --validator \ - --base-path /tmp/relay/alice \ + --base-path /tmp/alice \ --chain /tmp/raw-local-chainspec.json \ --port 30333 \ --rpc-port 9944 \ @@ -161,7 +161,7 @@ To start the validator nodes using the [raw sample chain specification file](htt ./target/release/polkadot \ --bob \ --validator \ - --base-path /tmp/relay/bob \ + --base-path /tmp/bob \ --chain /tmp/raw-local-chainspec.json \ --port 30334 \ --rpc-port 9945 @@ -178,4 +178,25 @@ To start the validator nodes using the [raw sample chain specification file](htt /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp ``` +5. Verify that the relay chain nodes are running by checking the logs for each node. The logs should show that the nodes are connected to each other and producing blocks. For example, bob's logs will be displayed as follows: + +
+ ./target/release/polkadot \ + --bob \ + --validator \ + --base-path /tmp/relay/bob \ + --chain /tmp/raw-local-chainspec.json \ + --port 30334 \ + --rpc-port 9945 + + ... +
+ 2024-09-10 13:29:38 🏆 Imported #55 (0xad6a…567c → 0xecae…ad12) +
+ 2024-09-10 13:29:38 💤 Idle (1 peers), best: #55 (0xecae…ad12), finalized #0 (0x1cac…618d), ⬇ 2.0kiB/s ⬆ 1.6kiB/s +
+ ... +
+ + Once the relay chain nodes are running, you can proceed to the next tutorial to set up a test parachain node and connect it to the relay chain. \ No newline at end of file From 213814ef60cd10f0bd4f943c2473752b82d81c98 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Wed, 11 Sep 2024 13:52:29 -0300 Subject: [PATCH 11/22] fix: typo and adding abs route to build a local blockchain tutorial --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 6379bcc43..fe26331e4 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -23,7 +23,7 @@ Before diving into this tutorial, it's recommended that you have a basic underst To complete this tutorial, ensure that you have: - Configured your environment for Substrate development by installing [Rust and the Rust toolchain](https://docs.substrate.io/install/){target=\_blank} -- Completed [Build a local blockchain](TODO: the add absolute path to the Build a local blockchain tutorial){target=\_blank} tutorial and know how to compile and run a Substrate node +- Completed [Build a Local Blockchain](/tutorials/polkadot-sdk/build-a-blockchain/build-a-local-blockchain){target=\_blank} tutorial and know how to compile and run a Substrate node ## Build a Local Relay Chain From 1286b44822d8e7bc43f5b3fb0b43976c40868b45 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Wed, 11 Sep 2024 13:53:58 -0300 Subject: [PATCH 12/22] fix: paraphrasing --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index fe26331e4..808adb945 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -23,7 +23,7 @@ Before diving into this tutorial, it's recommended that you have a basic underst To complete this tutorial, ensure that you have: - Configured your environment for Substrate development by installing [Rust and the Rust toolchain](https://docs.substrate.io/install/){target=\_blank} -- Completed [Build a Local Blockchain](/tutorials/polkadot-sdk/build-a-blockchain/build-a-local-blockchain){target=\_blank} tutorial and know how to compile and run a Substrate node +- Completed [Build a Local Blockchain](/tutorials/polkadot-sdk/build-a-blockchain/build-a-local-blockchain){target=\_blank} tutorial and know how to compile and run a Polkadot-SDK based node ## Build a Local Relay Chain From 4f2a152267b0de67ee61eaeca72dd3a04e8a5174 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Wed, 11 Sep 2024 13:54:37 -0300 Subject: [PATCH 13/22] fix: updating deprecated route --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 808adb945..bb17f2e0d 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -36,7 +36,7 @@ To build a local relay chain, follow these steps: ``` !!! note - The branch `polkadot-stable2407-2` is used in this tutorial since it is the branch that contains the latest stable release of the Polkadot SDK. You can find the latest release of the Polkadot SDK on the [Release](https://github.com/paritytech/polkadot/releases){target=\_blank} tab on the Polkadot GitHub repository. + The branch `polkadot-stable2407-2` is used in this tutorial since it is the branch that contains the latest stable release of the Polkadot SDK. You can find the latest release of the Polkadot SDK on the [Release](https://github.com/paritytech/polkadot-sdk/releases){target=\_blank} tab on the Polkadot GitHub repository. !!! note Note that the `--depth 1` flag is used to clone only the latest commit of the branch, which speeds up the cloning process. From f8b1fa8eb412d0d84e4b4ffa7d0d4a728a38293d Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Wed, 11 Sep 2024 13:55:51 -0300 Subject: [PATCH 14/22] fix: paraphrasing --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index bb17f2e0d..5ccb0b61e 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -171,7 +171,7 @@ To start the validator nodes using the [raw sample chain specification file](htt Because both validators are running on a single local computer, it isn't necessary to specify the --bootnodes command-line option and the first node’s IP address and peer identifier. The bootnodes option is required to connect nodes outside the local network or not identified in the chain specification file. - If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity from preceding): + If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity of the alice node): ```bash --bootnodes \ From 1cb5f77d252179651681fa45feb74d3a4b6948d7 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Wed, 11 Sep 2024 13:56:46 -0300 Subject: [PATCH 15/22] fix: formatting --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 5ccb0b61e..80b4e83c4 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -169,7 +169,7 @@ To start the validator nodes using the [raw sample chain specification file](htt Notice that this command uses a different base path (/tmp/relay/bob), validator key (`--bob`), and ports (`30334` and `9945`). - Because both validators are running on a single local computer, it isn't necessary to specify the --bootnodes command-line option and the first node’s IP address and peer identifier. The bootnodes option is required to connect nodes outside the local network or not identified in the chain specification file. + Because both validators are running on a single local computer, it isn't necessary to specify the `--bootnodes` command-line option and the first node’s IP address and peer identifier. The `--bootnodes` option is required to connect nodes outside the local network or not identified in the chain specification file. If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity of the alice node): From 5274116beea31e6b3aeb59c6337e1d1e92d6359d Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Wed, 11 Sep 2024 14:04:12 -0300 Subject: [PATCH 16/22] fix: chain specs decoupled from substrate website --- .../build-a-parachain/prepare-relay-chain.md | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 80b4e83c4..3425b567f 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -78,27 +78,35 @@ If you wanted to connect two parachains with a single collator each, you would n The chain specification file is available in two formats: a JSON file in plain text and a JSON file in SCALE-encoded raw format. -- [Plain sample relay chain spec](https://docs.substrate.io/assets/tutorials/relay-chain-specs/plain-local-chainspec.json/){target=\_blank} -- [Raw sample relay chain spec](https://docs.substrate.io/assets/tutorials/relay-chain-specs/raw-local-chainspec.json/){target=\_blank} - -You can read and edit the plain text version of chain specification file. However, the chain specification file must be converted to the SCALE-encoded raw format before you can use it to start a node. For information about converting a chain specification to use the raw format, see [Customize a chain specification](https://docs.substrate.io/reference/how-to-guides/basics/customize-a-chain-specification/){target=\_blank}. +You can read and edit the plain text version of chain specification file. However, the chain specification file must be converted to the SCALE-encoded raw format before you can use it to start a node. For information about converting a chain specification to use the raw format, see [Customize a Chain Specification](https://docs.substrate.io/reference/how-to-guides/basics/customize-a-chain-specification/){target=\_blank}. The sample chain specification is only valid for a single parachain with two validator nodes. If you add other validators, add additional parachains to your relay chain, or want to use custom account keys instead of the predefined account, you'll need to create a custom chain specification file. -Suppose you are completing this tutorial simultaneously as anyone on the same local network. In that case, you must download and modify the Plain sample relay chain spec to prevent accidentally peering with their nodes. Find the following line in the plain chain spec and add characters to make your protocolId unique: +Suppose you are completing this tutorial simultaneously as anyone on the same local network. In that case, you must download and modify the plain sample relay chain spec to prevent accidentally peering with their nodes. Find the following line in the plain chain spec and add characters to make the `protocolId` field unique: ```json "protocolId": "dot", ``` + ## Start the Relay Chain Node Before starting block production for a parachain, you need to start a relay chain for them to connect. -To start the validator nodes using the [raw sample chain specification file](https://docs.substrate.io/assets/tutorials/relay-chain-specs/raw-local-chainspec.json/){target=\_blank}, follow these steps: +To start the validator nodes, follow these steps: + +1. Generate the chain specification file in the plain text format and use it to create the raw chain specification file. Save the raw chain specification file in a local working directory. + + 1. The plain text chain specification file can be generated by running the following command: + + ```bash + ./target/release/polkadot build-spec --chain rococo-local-testnet > /tmp/plain-local-chainspec.json + ``` -1. Download the raw chain specification file to a working directory on the local computer + 2. Convert the plain text chain specification file to the raw format by running the following command: - For example, save the file as `raw-local-chainspec.json` in the `/tmp` directory. When starting the nodes, you’ll need to specify the path to the file in the commands. + ```bash + ./target/release/polkadot build-spec --chain plain-local-chainspec.json --raw > /tmp/raw-local-chainspec.json + ``` 2. Start the first validator using the alice account by running the following command: From 6bfe5e4c1d1156dba627f63473294ec0413b3748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Hussein?= <80422357+nhussein11@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:51:16 -0300 Subject: [PATCH 17/22] Update tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md Co-authored-by: 0xLucca <95830307+0xLucca@users.noreply.github.com> --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 3425b567f..47e4791d1 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -122,7 +122,7 @@ To start the validator nodes, follow these steps: --force-authoring ``` - This command uses `/tmp/raw-local-chainspec.json` as the location of the sample chain specification file. Be sure the `--chain` command line specifies the path to the raw chain specification you downloaded into a local working directory. This command also uses the default values for the port (`port`) and WebSocket port (`ws-port`). The values are explicitly included here as a reminder to always check these settings. After the node starts, no other nodes on the same local machine can use these ports. + This command uses `/tmp/raw-local-chainspec.json` as the location of the sample chain specification file. Be sure the `--chain` command line specifies the path to the raw chain specification you generated. This command also uses the default values for the port (`port`) and WebSocket port (`ws-port`). The values are explicitly included here as a reminder to always check these settings. After the node starts, no other nodes on the same local machine can use these ports. 3. Review log messages as the node starts and take note of the `Local node identity` value. This value is the node’s peer ID, which you need to connect the parachain to the relay chain From 6446b16e5bdc0f07385bc99844e60873d6e75c39 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 23 Sep 2024 11:57:49 -0300 Subject: [PATCH 18/22] fix: typo --- tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index 47e4791d1..ad062dd5a 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -66,7 +66,7 @@ If command-line help is displayed, the node is ready to configure. ## Relay Chain Configuration -Every Substrate-based chain requires a [chain specification](https://docs.substrate.io/build/chain-spec/){target=\_blank}. The relay chain network’s chain specification provides the same configuration settings as the chain specification does for other networks. Many of the chain specification file settings are critical for network operations. For example, the chain specification identifies peers participating in the network, keys for validators, boot node addresses, and other information. +Every Substrate-based chain requires a [chain specification](https://docs.substrate.io/build/chain-spec/){target=\_blank}. The relay chain network’s chain specification provides the same configuration settings as the chain specification does for other networks. Many of the chain specification file settings are critical for network operations. For example, the chain specification identifies peers participating in the network, keys for validators, bootnode addresses, and other information. ### Sample Chain Configuration From aa08eca553ba44d4e8798bf50a7614361c8ab825 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 23 Sep 2024 11:59:44 -0300 Subject: [PATCH 19/22] fix: removing redundant commands on terminal elements --- .../build-a-parachain/prepare-relay-chain.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index ad062dd5a..c8e81671d 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -127,16 +127,6 @@ To start the validator nodes, follow these steps: 3. Review log messages as the node starts and take note of the `Local node identity` value. This value is the node’s peer ID, which you need to connect the parachain to the relay chain
- ./target/release/polkadot \ - --alice \ - --validator \ - --base-path /tmp/relay/alice \ - --chain /tmp/raw-local-chainspec.json \ - --port 30333 \ - --rpc-port 9944 \ - --insecure-validator-i-know-what-i-do \ - --force-authoring - 2024-09-09 13:49:58 Parity Polkadot
2024-09-09 13:49:58 ✌️ version 1.15.2-d6f482d5593 @@ -189,14 +179,6 @@ To start the validator nodes, follow these steps: 5. Verify that the relay chain nodes are running by checking the logs for each node. The logs should show that the nodes are connected to each other and producing blocks. For example, bob's logs will be displayed as follows:
- ./target/release/polkadot \ - --bob \ - --validator \ - --base-path /tmp/relay/bob \ - --chain /tmp/raw-local-chainspec.json \ - --port 30334 \ - --rpc-port 9945 - ...
2024-09-10 13:29:38 🏆 Imported #55 (0xad6a…567c → 0xecae…ad12) From 8acc35744b6989b0e4a7f2642e32d55fcd8c7257 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Mon, 23 Sep 2024 12:02:51 -0300 Subject: [PATCH 20/22] fix: adding disclaimer for chain spec generation --- .../polkadot-sdk/build-a-parachain/prepare-relay-chain.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index c8e81671d..cbcaace7a 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -102,6 +102,9 @@ To start the validator nodes, follow these steps: ./target/release/polkadot build-spec --chain rococo-local-testnet > /tmp/plain-local-chainspec.json ``` + !!! 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 by running the following command: ```bash From f463234d2c91070cf5ddf66ac7efa72e2a3e053a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Hussein?= <80422357+nhussein11@users.noreply.github.com> Date: Tue, 24 Sep 2024 08:52:04 -0300 Subject: [PATCH 21/22] Apply suggestions from code review Co-authored-by: Erin Shaben --- .../build-a-parachain/prepare-relay-chain.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index cbcaace7a..a6dd718fc 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -23,7 +23,7 @@ Before diving into this tutorial, it's recommended that you have a basic underst To complete this tutorial, ensure that you have: - Configured your environment for Substrate development by installing [Rust and the Rust toolchain](https://docs.substrate.io/install/){target=\_blank} -- Completed [Build a Local Blockchain](/tutorials/polkadot-sdk/build-a-blockchain/build-a-local-blockchain){target=\_blank} tutorial and know how to compile and run a Polkadot-SDK based node +- Completed [Build a Local Blockchain](/tutorials/polkadot-sdk/build-a-blockchain/build-a-local-blockchain){target=\_blank} tutorial and know how to compile and run a Polkadot SDK-based node ## Build a Local Relay Chain @@ -58,7 +58,7 @@ To build a local relay chain, follow these steps: 4. Verify that the node is built correctly by running the following command: - ``` + ```bash ./target/release/polkadot --version ``` @@ -78,7 +78,7 @@ If you wanted to connect two parachains with a single collator each, you would n The chain specification file is available in two formats: a JSON file in plain text and a JSON file in SCALE-encoded raw format. -You can read and edit the plain text version of chain specification file. However, the chain specification file must be converted to the SCALE-encoded raw format before you can use it to start a node. For information about converting a chain specification to use the raw format, see [Customize a Chain Specification](https://docs.substrate.io/reference/how-to-guides/basics/customize-a-chain-specification/){target=\_blank}. +You can read and edit the plain text version of chain specification file. However, the chain specification file must be converted to the SCALE-encoded raw format before you can use it to start a node. For information about converting a chain specification to use the raw format, see [Customize a Chain Specification](){target=\_blank}. The sample chain specification is only valid for a single parachain with two validator nodes. If you add other validators, add additional parachains to your relay chain, or want to use custom account keys instead of the predefined account, you'll need to create a custom chain specification file. @@ -111,7 +111,7 @@ To start the validator nodes, follow these steps: ./target/release/polkadot build-spec --chain plain-local-chainspec.json --raw > /tmp/raw-local-chainspec.json ``` -2. Start the first validator using the alice account by running the following command: +2. Start the first validator using the `alice` account by running the following command: ```bash ./target/release/polkadot \ @@ -154,7 +154,7 @@ To start the validator nodes, follow these steps: !!! note You need to specify this identifier to enable other nodes to connect. In this case, the `Local node identity` is `12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp`. -4. Open a new terminal and start the second validator using the bob account +4. Open a new terminal and start the second validator using the `bob` account The command is similar to the command used to start the first node, with a few crucial differences. @@ -172,14 +172,14 @@ To start the validator nodes, follow these steps: Because both validators are running on a single local computer, it isn't necessary to specify the `--bootnodes` command-line option and the first node’s IP address and peer identifier. The `--bootnodes` option is required to connect nodes outside the local network or not identified in the chain specification file. - If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of the alice node to start the node. Adding the bootnodes option looks like this (with the node identity of the alice node): + If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of Alice's node to start the node. Adding the bootnodes option looks like this (with the node identity of Alice's node): ```bash --bootnodes \ /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp ``` -5. Verify that the relay chain nodes are running by checking the logs for each node. The logs should show that the nodes are connected to each other and producing blocks. For example, bob's logs will be displayed as follows: +5. Verify that the relay chain nodes are running by checking the logs for each node. The logs should show that the nodes are connected to each other and producing blocks. For example, Bob's logs will be displayed as follows:
... From ac7f71aeae92277d5df34c59d4184c0566512fe5 Mon Sep 17 00:00:00 2001 From: nhussein11 Date: Tue, 24 Sep 2024 09:13:33 -0300 Subject: [PATCH 22/22] fix: moving terminal outputs to code snippets --- .../relay-chain-bootstraping-logs.md | 21 ++++++ .../relay-chain-running-logs.md | 9 +++ .../build-a-parachain/prepare-relay-chain.md | 67 ++++++------------- 3 files changed, 49 insertions(+), 48 deletions(-) create mode 100644 .snippets/code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-bootstraping-logs.md create mode 100644 .snippets/code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-running-logs.md diff --git a/.snippets/code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-bootstraping-logs.md b/.snippets/code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-bootstraping-logs.md new file mode 100644 index 000000000..4266e5348 --- /dev/null +++ b/.snippets/code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-bootstraping-logs.md @@ -0,0 +1,21 @@ +
+ 2024-09-09 13:49:58 Parity Polkadot +
+ 2024-09-09 13:49:58 ✌️ version 1.15.2-d6f482d5593 +
+ 2024-09-09 13:49:58 ❤️ by Parity Technologies , 2017-2024 +
+ 2024-09-09 13:49:58 📋 Chain specification: Rococo Local Testnet +
+ 2024-09-09 13:49:58 🏷 Node name: Alice +
+ 2024-09-09 13:49:58 👤 Role: AUTHORITY +
+ 2024-09-09 13:49:58 💾 Database: RocksDb at /tmp/relay/alice/chains/rococo_local_testnet/db/full +
+ 2024-09-09 13:49:59 🏷 Local node identity is: 12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp +
+ 2024-09-09 13:49:59 Running libp2p network backend +
+ ... +
\ No newline at end of file diff --git a/.snippets/code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-running-logs.md b/.snippets/code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-running-logs.md new file mode 100644 index 000000000..8fc3c7268 --- /dev/null +++ b/.snippets/code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-running-logs.md @@ -0,0 +1,9 @@ +
+ ... +
+ 2024-09-10 13:29:38 🏆 Imported #55 (0xad6a…567c → 0xecae…ad12) +
+ 2024-09-10 13:29:38 💤 Idle (1 peers), best: #55 (0xecae…ad12), finalized #0 (0x1cac…618d), ⬇ 2.0kiB/s ⬆ 1.6kiB/s +
+ ... +
\ No newline at end of file diff --git a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md index a6dd718fc..4ea547a76 100644 --- a/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md +++ b/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain.md @@ -129,67 +129,38 @@ To start the validator nodes, follow these steps: 3. Review log messages as the node starts and take note of the `Local node identity` value. This value is the node’s peer ID, which you need to connect the parachain to the relay chain -
- 2024-09-09 13:49:58 Parity Polkadot -
- 2024-09-09 13:49:58 ✌️ version 1.15.2-d6f482d5593 -
- 2024-09-09 13:49:58 ❤️ by Parity Technologies , 2017-2024 -
- 2024-09-09 13:49:58 📋 Chain specification: Rococo Local Testnet -
- 2024-09-09 13:49:58 🏷 Node name: Alice -
- 2024-09-09 13:49:58 👤 Role: AUTHORITY -
- 2024-09-09 13:49:58 💾 Database: RocksDb at /tmp/relay/alice/chains/rococo_local_testnet/db/full -
- 2024-09-09 13:49:59 🏷 Local node identity is: 12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp -
- 2024-09-09 13:49:59 Running libp2p network backend -
- ... -
+ --8<-- "code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-bootstraping-logs.md" !!! note You need to specify this identifier to enable other nodes to connect. In this case, the `Local node identity` is `12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp`. 4. Open a new terminal and start the second validator using the `bob` account - The command is similar to the command used to start the first node, with a few crucial differences. + The command is similar to the command used to start the first node, with a few crucial differences. - ```bash - ./target/release/polkadot \ - --bob \ - --validator \ - --base-path /tmp/bob \ - --chain /tmp/raw-local-chainspec.json \ - --port 30334 \ - --rpc-port 9945 - ``` + ```bash + ./target/release/polkadot \ + --bob \ + --validator \ + --base-path /tmp/bob \ + --chain /tmp/raw-local-chainspec.json \ + --port 30334 \ + --rpc-port 9945 + ``` - Notice that this command uses a different base path (/tmp/relay/bob), validator key (`--bob`), and ports (`30334` and `9945`). + Notice that this command uses a different base path (/tmp/relay/bob), validator key (`--bob`), and ports (`30334` and `9945`). - Because both validators are running on a single local computer, it isn't necessary to specify the `--bootnodes` command-line option and the first node’s IP address and peer identifier. The `--bootnodes` option is required to connect nodes outside the local network or not identified in the chain specification file. + Because both validators are running on a single local computer, it isn't necessary to specify the `--bootnodes` command-line option and the first node’s IP address and peer identifier. The `--bootnodes` option is required to connect nodes outside the local network or not identified in the chain specification file. - If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of Alice's node to start the node. Adding the bootnodes option looks like this (with the node identity of Alice's node): + If you don't see the relay chain producing blocks, try disabling your firewall or adding the bootnodes command-line option with the address of Alice's node to start the node. Adding the bootnodes option looks like this (with the node identity of Alice's node): - ```bash - --bootnodes \ - /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp - ``` + ```bash + --bootnodes \ + /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp + ``` 5. Verify that the relay chain nodes are running by checking the logs for each node. The logs should show that the nodes are connected to each other and producing blocks. For example, Bob's logs will be displayed as follows: -
- ... -
- 2024-09-10 13:29:38 🏆 Imported #55 (0xad6a…567c → 0xecae…ad12) -
- 2024-09-10 13:29:38 💤 Idle (1 peers), best: #55 (0xecae…ad12), finalized #0 (0x1cac…618d), ⬇ 2.0kiB/s ⬆ 1.6kiB/s -
- ... -
- + --8<-- "code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-running-logs.md" Once the relay chain nodes are running, you can proceed to the next tutorial to set up a test parachain node and connect it to the relay chain. \ No newline at end of file