Skip to content

Commit

Permalink
Merge branch 'main' into parachain-section-4
Browse files Browse the repository at this point in the history
  • Loading branch information
CrackTheCode016 committed Oct 11, 2023
2 parents f4ffbcb + 3454860 commit 21391d3
Show file tree
Hide file tree
Showing 53 changed files with 500 additions and 190 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
fetch-depth: 0

- name: Publish
env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
run: |
git config --global user.email "w3fdeply@users.noreply.github.com"
git config --global user.name "w3fdeploy"
Expand Down
2 changes: 1 addition & 1 deletion docs/AtoZ/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Polkadot network started as a Proof of Authority network, a consensus mechan
small number of validators complete control over the network. It was maintained by six validators
that Web3 Foundation controlled. With the power of Sudo (a Substrate functionality that allows for a
single account to do anything to the chain using root, though a bit technical, you can learn more
about it [here](https://paritytech.github.io/substrate/master/pallet_sudo/index.html) and
about it [here](https://paritytech.github.io/polkadot-sdk/master/pallet_sudo/index.html) and
[here](https://www.shawntabrizi.com/substrate/the-sudo-story-in-substrate/)), the Foundation closely
nourished the early stages of the network. Users were allowed to claim their DOT tokens and stake
them. However, during this phase, users' staking only meant **signaling their intention** to be a
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Parachain/beginner/assets/developer_sudo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Parachain/beginner/assets/successful_pvf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Parachain/beginner/assets/sudo_schedule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 41 additions & 30 deletions docs/Parachain/beginner/section2/install-binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_label: Install Local Binaries
description: Install the necessary Polkadot binaries onto your local machine.
---

This page will focus on installing the dependencies you need to run a local relay chain. You will:
This page will focus on installing the dependencies you need to run a local relay chain. You will:

- Install `polkadot`
- Configure a valid chain specification for your relay chain
Expand All @@ -19,62 +19,63 @@ Before starting, you should have the following already on your system:

For more information, view the **General Prerequisites** page.

For the best experience in following this guide, consider also cloning this repository: [`parachain-guide-resources`](https://github.com/CrackTheCode016/parachain-guide-resources)
For the best experience in following this guide, consider also cloning this repository:
[`parachain-guide-resources`](https://github.com/CrackTheCode016/parachain-guide-resources)

## Installing `polkadot`

For this guide, we will ensure a consistent environment by installing Polkadot. This is how we will provision and start our relay chain instance:

For this guide, we will ensure a consistent environment by installing Polkadot. This is how we will
provision and start our relay chain instance:

### Option 1: Manual Compilation (Recommended)

If you are on macOS, below is the current best way to install `polkadot`:

1. Clone the latest, stable branch of Polkadot (1.0.0 at the time of this writing):

```bash
git clone --branch release-v1.0.0 https://github.com/paritytech/polkadot.git
```

```bash
git clone --branch release-v1.0.0 https://github.com/paritytech/polkadot.git
```

2. Use `cargo` to build the binary

```bash
cargo build --release
```
```bash
cargo build --release
```

:::caution ⌛ This will take some time
:::caution ⌛ This will take some time

Depending on your machine, this may take 45-60 minutes.
Depending on your machine, this may take 45-60 minutes.

:::
:::

3. Once compiled, ensure it runs:

```bash
./target/release/polkadot --help
```
```bash
./target/release/polkadot --help
```

:::tip Create a symlink to easily run your Polkadot binary.

For ease of use, consider adding the target executable to your local path or creating a symlink. There are three binaries that need to be linked if you choose to do this:
For ease of use, consider adding the target executable to your local path or creating a symlink.
There are three binaries that need to be linked if you choose to do this:

- `polkadot`
- `polkadot-execute-worker`
- `polkadot-prepare-worker`

```bash
# Replace <path> with the path to your cloned polkadot repo
# The last line may need to be replaced!
# The last line may need to be replaced!
# Polkadot
ln -s <path-to-polkadot>/target/release/polkadot /usr/local/bin/polkadot
ln -s <path-to-polkadot>/target/release/polkadot /usr/local/bin/polkadot
# Polkadot Prepare Worker
ln -s <path-to-polkadot>/target/release/polkadot-prepare-worker /usr/local/bin/polkadot-prepare-worker
ln -s <path-to-polkadot>/target/release/polkadot-prepare-worker /usr/local/bin/polkadot-prepare-worker
# Polkadot Execute Worker
ln -s <path-to-polkadot>/target/release/polkadot-execute-worker /usr/local/bin/polkadot-execute-worker
ln -s <path-to-polkadot>/target/release/polkadot-execute-worker /usr/local/bin/polkadot-execute-worker
# Use directly in path!
Expand Down Expand Up @@ -103,26 +104,36 @@ apt install polkadot

## Chain Specification

Once Polkadot is compiled, we must ensure we have a valid `chain_spec` file to launch our local relay chain.
Once Polkadot is compiled, we must ensure we have a valid `chain_spec` file to launch our local
relay chain.

For the purposes of this guide, you can use the one located here with your cloned repository at `relaychain/relaychain_chain_spec.json` and `relaychain/relaychain_chain_spec_raw.json` and. Keep this at hand, as this will be used to run your relay chain.
For the purposes of this guide, you can use the one located here with your cloned repository at
`relaychain/relaychain_chain_spec.json` and `relaychain/relaychain_chain_spec_raw.json` and. Keep
this at hand, as this will be used to run your relay chain.

### Optional: Generating a Custom Chain Specification

It is possible to also generate your own, custom chain specification. This is usually done after changing the `polkadot` source code, as the `code` field within the chain spec would need to be updated. Once you modify the chain spec, you can run the following command to generate it:
It is possible to also generate your own, custom chain specification. This is usually done after
changing the `polkadot` source code, as the `code` field within the chain spec would need to be
updated. Once you modify the chain spec, you can run the following command to generate it:

```bash
# Run from locally compiled repository
./polkadot/target/release/polkadot build-spec > /tmp/chain-spec-plain.json
./polkadot/target/release/polkadot build-spec > ./relaychain/relaychain_spec.json
# or, with symlink
polkadot build-spec > /tmp/chain-spec-plain.json
polkadot build-spec > ./relaychain/relaychain_spec.json
```

Once this is built, also build the **raw**, SCALE-encoded file:

```bash
# Run from locally compiled repository
./polkadot/target/release/polkadot build-spec > /tmp/chain-spec-plain.json
./polkadot/target/release/polkadot build-spec \
--chain ./relaychain/relaychain_spec.json \
--raw > ./relaychain/relaychain_spec_raw.json
# or, with symlink
polkadot build-spec > /tmp/chain-spec-plain.json
polkadot build-spec \
--chain ./relaychain/relaychain_spec.json \
--raw > ./relaychain/relaychain_spec_raw.json
```
131 changes: 78 additions & 53 deletions docs/Parachain/beginner/section2/install-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,117 +5,142 @@ sidebar_label: Install the Cumulus Parachain Template
description: Install the Cumulus Parachain Template
---

With our relay chain ready to be launched, we now need to ensure we have a parachain that meets the aforementioned requirements.
With our relay chain ready to be launched, we now need to ensure we have a parachain that meets the
aforementioned requirements.

In this page, you will:

- Install and compile the `substrate-parachain-template`
- Configure the ParaID & Chain Spec
- Generate your parachain's runtime and genesis state (Wasm)
- If you don't wish to customize or go through this process, refer to the `parachain-guide-resources` repository


- If you don't wish to customize or go through this process, refer to the
`parachain-guide-resources` repository

## Install the `substrate-parachain-template`

The `substrate-parachain-template` is a Cumulus ready node template. If you have taken the previous Intro to Substrate course, you may have used a similar template. That template was a standalone chain - this template contains the requirements that a parachain needs to fulfill.
The `substrate-parachain-template` is a Cumulus ready node template. If you have taken the previous
[Intro to Substrate course](../../../introsubstrate.md), you may have used a similar template. That
template was a standalone chain - this template contains the requirements that a parachain needs to
fulfill in order to connect to the relay chain and follow the
[Parachains Protocol](https://wiki.polkadot.network/docs/learn-parachains-protocol).

1. Start by cloning the repository with the **same version as the relay chain**:

```bash
git clone --depth 1 --branch polkadot-v1.0.0 https://github.com/substrate-developer-hub/substrate-parachain-template.git
```
```bash
git clone --depth 1 --branch polkadot-v1.0.0 https://github.com/substrate-developer-hub/substrate-parachain-template.git
```

2. Ensure we're on our own branch, and now build
:::caution ⌛ This will take some time
:::caution ⌛ This will take some time
Depending on your machine, this may take 45-60 minutes.
Depending on your machine, this may take 45-60 minutes.
:::
:::
```bash
cd substrate-parachain-template
git switch -c my-branch-v1.0.0
# Build
cargo build --release
```
```bash
cd substrate-parachain-template
git switch -c my-branch-v1.0.0
# Build
cargo build --release
```
Once your parachain is compiled, the process of altering it (if required) and recompiling will be trivial.
Once your parachain is compiled, the process of altering it (if required) and recompiling will be
trivial.
:::tip Create a symlink to easily run your parachain binary.
For ease of use, consider adding the target executable to your local path or creating a symlink:
```bash
# Replace <path> with the path to your cloned substrate-parachain-template repo
# The last line may need to be replaced!
ln -s <path>/target/release/substrate-parachain-template /usr/local/bin/substrate-parachain-template
# The last line may need to be replaced!
ln -s <path>/target/release/parachain-template-node /usr/local/bin/parachain-template-node
# Use directly in path!
substrate-parachain-template --help
parachain-template-node --help
```
:::
:::tip If you don't wish to customize or go through this process, refer to the [`parachain-guide-resources`](https://github.com/CrackTheCode016/parachain-guide-resources) repository
:::tip If you don't wish to customize or go through this process, refer to the
[`parachain-guide-resources`](https://github.com/CrackTheCode016/parachain-guide-resources)
repository

The repository has everything required to proceed to running your chains.

:::

## Parachain Chain Specification

Just as the relay chain had a chain spec, the parachain must have one as well. It is generated in the same way:

Just as the relay chain had a chain spec, the parachain must have one as well. It is generated in
the same way:

1. Firstly, generate the JSON file:

```bash
# Run from locally compiled repository
./target/release/substrate-parachain-template build-spec > /tmp/parachain_chain_spec.json
# or, with symlink:
substrate-parachain-template build-spec > /tmp/parachain_chain_spec.json
```
```bash
# Run from locally compiled repository
./substrate-parachain-template/target/target/release/parachain-template-node build-spec > ./parachain/parachain_chain_spec.json
```

2. Once this is built, also build the **raw**, SCALE-encoded file:

```bash
# Run from locally compiled repository
./target/release/substrate-parachain-template build-spec > /tmp/parachain_chain_spec.json
# or, with symlink:
substrate-parachain-template build-spec > /tmp/parachain_chain_spec.json
```
```bash
# Run from locally compiled repository
./substrate-parachain-template/target/release/parachain-template-node build-spec \
--chain ./parachain/parachain_chain_spec.json \
--disable-default-bootnode --raw > raw-parachain-chainspec.json
```

If this succeeded, you will see the following output:

```bash
2023-09-13 13:25:01 Building chain spec
2023-09-13 13:25:01 assembling new collators for new session 0 at #0
2023-09-13 13:25:01 assembling new collators for new session 1 at #0
```

## Parachain Genesis & Runtime State

If you recall, the runtime of every Substrate-based chain is compiled down to Web Assembly (Wasm). This enables the runtime to be portable and stored on the relay chain, which is used for the purpose of validating state transitions from the parachain's collator.
If you recall, the runtime of every Substrate-based chain is compiled down to Web Assembly (Wasm).
This enables the runtime to be portable and stored on the relay chain, which is used for the purpose
of validating state transitions from the parachain's collator.
The genesis configuration must also be configured, as the relay chain will require it when registering it in the next section. These both depend on the `parachain_chain_spec.json` which we previously generated.
The genesis configuration must also be configured, as the relay chain will require it when
registering it in the next section. These both depend on the `parachain_chain_spec.json` which we
previously generated.
As always, these are already available within
As always, these are already available within the `parachain-guide-resources` repository.
### Optional: Generating The Runtime Wasm Bundle
```bash
./substrate-parachain-template/target/target/release/parachain-template-node export-genesis-wasm --chain ./parachain/parachain_chain_spec_raw.json parachain-wasm
# or, with symlink:
parachain-template-node export-genesis-wasm --chain ./parachain/parachain_chain_spec_raw.json parachain-wasm
```
```bash
./substrate-parachain-template/target/target/release/parachain-template-node export-genesis-wasm \
--chain ./parachain/parachain_chain_spec_raw.json ./parachain/parachain-wasm
### Optional: Generating the Genesis Wasm Bundle
# or, with symlink:
parachain-template-node export-genesis-wasm \
--chain ./parachain/parachain_chain_spec_raw.json parachain-wasm
```
### Optional: Generating the Genesis State Bundle
```bash
./substrate-parachain-template/target/target/release/parachain-template-node export-genesis-state --chain ./parachain/parachain_chain_spec_raw.json ./parachain/parachain-genesis-state
# or, with symlink:
parachain-template-node export-genesis-state --chain ./parachain/parachain_chain_spec_raw.json ./parachain/parachain-genesis-state
```
```bash
./substrate-parachain-template/target/target/release/parachain-template-node export-genesis-state \
--chain ./parachain/parachain_chain_spec_raw.json ./parachain/parachain-genesis-state
# or, with symlink:
parachain-template-node export-genesis-state \
--chain ./parachain/parachain_chain_spec_raw.json ./parachain/parachain-genesis-state
```
By now, you should have three total files generated and/or available:
By now, you should have three total files generated and/or available under the `parachains/`
directory:
- **Parachain Runtime**: `parachain-wasm`
- **Genesis State**: `parachain-genesis-state`
- **JSON Chain Spec**: `parachain_chain_spec.json`
- **Raw Chain Spec**: `parachain_chain_spec_raw.json`
With these, we are now able to run our relay chain validators, run our parachain collator, and finally register our parachain.
With these, we are now able to run our relay chain validators, run our parachain collator, and
finally register our parachain.
Loading

0 comments on commit 21391d3

Please sign in to comment.