Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b7f99df
update cargo version in node-tpl to v3 and spec_version
jimmychu0807 Mar 26, 2021
30d528b
updated
jimmychu0807 Mar 26, 2021
52bd96a
Updated pallet-template to v3 and sync back files in current devhub s…
jimmychu0807 Mar 27, 2021
55c8534
Updated node-tpl release process doc
jimmychu0807 Mar 27, 2021
652b33f
updated script
jimmychu0807 Mar 27, 2021
c1fe59d
updated pallet-template version
jimmychu0807 Mar 27, 2021
f507a2d
Merge branch 'master' into jc/node-tpl-work
jimmychu0807 Mar 27, 2021
45d35e6
updated
jimmychu0807 Mar 27, 2021
1d254b5
updated
jimmychu0807 Mar 27, 2021
0b98b71
updated rsync cmd
jimmychu0807 Mar 28, 2021
236e9b5
Update bin/node-template/scripts/init.sh
Mar 29, 2021
e0c1f0d
Removed redundant info, and added explanation on spec_version
jimmychu0807 Mar 29, 2021
b91f5c9
Merge remote-tracking branch 'gh-parity/jc/node-tpl-work' into jc/nod…
jimmychu0807 Mar 29, 2021
d2cfacc
grammar fix
jimmychu0807 Mar 29, 2021
46e62fb
Rm redundant wordings
jimmychu0807 Mar 29, 2021
31d2b49
updated spelling
jimmychu0807 Mar 29, 2021
4e9b008
Comment `frame-support/try-runtime` until it is released in crate.io
jimmychu0807 Mar 29, 2021
277d124
Resumed back try-runtime line.
jimmychu0807 Mar 29, 2021
f606bd4
Added a key caveat when changing node tpl from depending on local Sub…
jimmychu0807 Mar 29, 2021
0723fb4
Update docs/node-template-release.md
Mar 29, 2021
7adef57
Update docs/node-template-release.md
Mar 29, 2021
4fa7bbd
Update docs/node-template-release.md
Mar 29, 2021
b2d4c2b
Update docs/node-template-release.md
Mar 29, 2021
bb42530
Updated readme
jimmychu0807 Mar 29, 2021
814b0ca
Merge remote-tracking branch 'gh-parity/master' into jc/node-tpl-work
jimmychu0807 Mar 29, 2021
40b5ca6
minor words update
jimmychu0807 Mar 29, 2021
e6b82bd
Merge branch 'master' into jc/node-tpl-work
jimmychu0807 Mar 29, 2021
a767adc
updated Cargo.lock
jimmychu0807 Mar 29, 2021
17bb913
Updated based on build test output
jimmychu0807 Mar 29, 2021
4995834
updated err msg comparison
jimmychu0807 Mar 29, 2021
8919acd
Merge remote-tracking branch 'gh-parity/master' into jc/node-tpl-work
jimmychu0807 Mar 29, 2021
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
2 changes: 1 addition & 1 deletion .maintain/node-template-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ "$#" -ne 1 ]; then
exit 1
fi

PATH_TO_ARCHIVE=$(pwd)/$1
PATH_TO_ARCHIVE=$1
cd $PROJECT_ROOT/.maintain/node-template-release

cargo run $PROJECT_ROOT/bin/node-template $PATH_TO_ARCHIVE
2 changes: 1 addition & 1 deletion .maintain/node-template-release/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "node-template-release"
version = "2.0.0"
version = "3.0.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"
license = "GPL-3.0"
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions bin/node-template/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style=space
indent_size=2
tab_width=2
Copy link
Member

Choose a reason for hiding this comment

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

did we want to commit this file?

end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
insert_final_newline = true

[*.{rs,toml}]
indent_style=tab
indent_size=tab
tab_width=4
max_line_length=100
128 changes: 53 additions & 75 deletions bin/node-template/README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,71 @@
# Substrate Node Template

A new FRAME-based Substrate node, ready for hacking :rocket:
A fresh FRAME-based [Substrate](https://www.substrate.io/) node, ready for hacking :rocket:

## Local Development
## Getting Started

Follow these steps to prepare a local Substrate development environment :hammer_and_wrench:
Follow these steps to get started with the Node Template :hammer_and_wrench:

### Simple Setup
### Rust Setup

Install all the required dependencies with a single command (be patient, this can take up to 30
minutes).
First, complete the [basic Rust setup instructions](./doc/rust-setup.md).

```bash
curl https://getsubstrate.io -sSf | bash -s -- --fast
```
### Run

### Manual Setup
Use Rust's native `cargo` command to build and launch the template node:

Find manual setup instructions at the
[Substrate Developer Hub](https://substrate.dev/docs/en/knowledgebase/getting-started/#manual-installation).
```sh
cargo run --release -- --dev --tmp
```

### Build

Once the development environment is set up, build the node template. This command will build the
[Wasm](https://substrate.dev/docs/en/knowledgebase/advanced/executor#wasm-execution) and
[native](https://substrate.dev/docs/en/knowledgebase/advanced/executor#native-execution) code:
The `cargo run` command will perform an initial build. Use the following command to build the node
without launching it:

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

## Run

### Single Node Development Chain
### Embedded Docs

Purge any existing dev chain state:
Once the project has been built, the following command can be used to explore all parameters and
subcommands:

```bash
./target/release/node-template purge-chain --dev
```sh
./target/release/node-template -h
```

Start a dev chain:
## Run

```bash
./target/release/node-template --dev
```
The provided `cargo run` command will launch a temporary node and its state will be discarded after
you terminate the process. After the project has been built, there are other ways to launch the
node.

### Single-Node Development Chain

Or, start a dev chain with detailed logging:
This command will start the single-node development chain with persistent state:

```bash
RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/node-template -lruntime=debug --dev
./target/release/node-template --dev
```

### Multi-Node Local Testnet

To see the multi-node consensus algorithm in action, run a local testnet with two validator nodes,
Alice and Bob, that have been [configured](./node/src/chain_spec.rs) as the initial
authorities of the `local` testnet chain and endowed with testnet units.

Note: this will require two terminal sessions (one for each node).

Start Alice's node first. The command below uses the default TCP port (30333) and specifies
`/tmp/alice` as the chain database location. Alice's node ID will be
`12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp` (legacy representation:
`QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR`); this is determined by the `node-key`.
Purge the development chain's state:

```bash
cargo run -- \
--base-path /tmp/alice \
--chain=local \
--alice \
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
--telemetry-url 'ws://telemetry.polkadot.io:1024 0' \
--validator
./target/release/node-template purge-chain --dev
```

In another terminal, use the following command to start Bob's node on a different TCP port (30334)
and with a chain database location of `/tmp/bob`. The `--bootnodes` option will connect his node to
Alice's on TCP port 30333:
Start the development chain with detailed logging:

```bash
cargo run -- \
--base-path /tmp/bob \
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp \
--chain=local \
--bob \
--port 30334 \
--ws-port 9945 \
--telemetry-url 'ws://telemetry.polkadot.io:1024 0' \
--validator
RUST_BACKTRACE=1 ./target/release/node-template -ldebug --dev
```

Execute `cargo run -- --help` to learn more about the template node's CLI options.
### Multi-Node Local Testnet

If you want to see the multi-node consensus algorithm in action, refer to
[our Start a Private Network tutorial](https://substrate.dev/docs/en/tutorials/start-a-private-network/).

## Template Structure

Expand Down Expand Up @@ -184,24 +158,28 @@ A FRAME pallet is compromised of a number of blockchain primitives:
- Config: The `Config` configuration interface is used to define the types and parameters upon
which a FRAME pallet depends.

## Generate a Custom Node Template
### Run in Docker

Generate a Substrate node template based on a particular commit by running the following commands:
First, install [Docker](https://docs.docker.com/get-docker/) and
[Docker Compose](https://docs.docker.com/compose/install/).

Then run the following command to start a single node development chain.

```bash
# Clone from the main Substrate repo
git clone https://github.com/paritytech/substrate.git
cd substrate
./scripts/docker_run.sh
```

# Switch to the branch or commit to base the template on
git checkout <branch/tag/sha1>
This command will firstly compile your code, and then start a local development network. You can
also replace the default command (`cargo build --release && ./target/release/node-template --dev --ws-external`)
by appending your own. A few useful ones are as follow.

# Run the helper script to generate a node template. This script compiles Substrate, so it will take
# a while to complete. It expects a single parameter: the location for the script's output expressed
# as a relative path.
.maintain/node-template-release.sh ../node-template.tar.gz
```
```bash
# Run Substrate node without re-compiling
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external

# Purge the local dev chain
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev

Custom node templates are not supported. Please use a recently tagged version of the
[Substrate Developer Node Template](https://github.com/substrate-developer-hub/substrate-node-template)
in order to receive support.
# Check whether the code is compilable
./scripts/docker_run.sh cargo check
```
17 changes: 17 additions & 0 deletions bin/node-template/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.2"

services:
dev:
container_name: node-template
image: paritytech/ci-linux:974ba3ac-20201006
working_dir: /var/www/node-template
ports:
- "9944:9944"
environment:
- CARGO_HOME=/var/www/node-template/.cargo
volumes:
- .:/var/www/node-template
- type: bind
source: ./.local
target: /root/.local
command: bash -c "cargo build --release && ./target/release/node-template --dev --ws-external"
81 changes: 81 additions & 0 deletions bin/node-template/docs/rust-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Installation
---

This page will guide you through the steps needed to prepare a computer for development with the
Substrate Node Template. Since Substrate is built with
[the Rust programming language](https://www.rust-lang.org/), the first thing you will need to do is
prepare the computer for Rust development - these steps will vary based on the computer's operating
system. Once Rust is configured, you will use its toolchains to interact with Rust projects; the
commands for Rust's toolchains will be the same for all supported, Unix-based operating systems.

## Unix-Based Operating Systems

Substrate development is easiest on Unix-based operating systems like macOS or Linux. The examples
in the Substrate [Tutorials](https://substrate.dev/tutorials) and [Recipes](https://substrate.dev/recipes/)
use Unix-style terminals to demonstrate how to interact with Substrate from the command line.

### macOS

Open the Terminal application and execute the following commands:

```bash
# Install Homebrew if necessary https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

# Make sure Homebrew is up-to-date, install openssl and cmake
brew update
brew install openssl cmake
```

### Ubuntu/Debian

Use a terminal shell to execute the following commands:

```bash
sudo apt update
# May prompt for location information
sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl
```

### Arch Linux

Run these commands from a terminal:

```bash
pacman -Syu --needed --noconfirm cmake gcc openssl-1.0 pkgconf git clang
export OPENSSL_LIB_DIR="/usr/lib/openssl-1.0"
export OPENSSL_INCLUDE_DIR="/usr/include/openssl-1.0"
```

### Fedora/RHEL/CentOS

Use a terminal to run the following commands:

```bash
# Update
sudo dnf update
# Install packages
sudo dnf install cmake pkgconfig rocksdb rocksdb-devel llvm git libcurl libcurl-devel curl-devel clang
```

## Rust Developer Environment

This project uses [`rustup`](https://rustup.rs/) to help manage the Rust toolchain. First install
and configure `rustup`:

```bash
# Install
curl https://sh.rustup.rs -sSf | sh
# Configure
source ~/.cargo/env
```

Finally, configure the Rust toolchain:

```bash
rustup default stable
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
```
10 changes: 5 additions & 5 deletions bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "node-template"
version = "2.0.0"
authors = ["Anonymous"]
description = "A new FRAME-based Substrate node, ready for hacking."
version = "3.0.0"
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
description = "A fresh FRAME-based Substrate node, ready for hacking."
edition = "2018"
license = "Unlicense"
build = "build.rs"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down Expand Up @@ -51,7 +51,7 @@ pallet-transaction-payment-rpc = { version = "3.0.0", path = "../../../frame/tra
frame-benchmarking = { version = "3.1.0", path = "../../../frame/benchmarking" }
frame-benchmarking-cli = { version = "3.0.0", path = "../../../utils/frame/benchmarking-cli" }

node-template-runtime = { version = "2.0.0", path = "../runtime" }
node-template-runtime = { version = "3.0.0", path = "../runtime" }

[build-dependencies]
substrate-build-script-utils = { version = "3.0.0", path = "../../../utils/build-script-utils" }
Expand Down
Loading