Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 59fd2ac

Browse files
nuke-web3Sacha Lanskylisa-parity
authored
Update Template README (#12741)
* update README remove matrix links remove playground references (service reported as sunsetting) OSPL rule per Docs style guide * Apply suggestions from code review Co-authored-by: Sacha Lansky <[email protected]> * Update README.md * Apply suggestions from code review Co-authored-by: lisa-parity <[email protected]> * (fix) chmod +x script --------- Co-authored-by: Sacha Lansky <[email protected]> Co-authored-by: lisa-parity <[email protected]> Co-authored-by: parity-processbot <>
1 parent e374a33 commit 59fd2ac

File tree

2 files changed

+85
-134
lines changed

2 files changed

+85
-134
lines changed

bin/node-template/README.md

Lines changed: 85 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,72 @@
11
# Substrate Node Template
22

3-
[![Try on playground](https://img.shields.io/badge/Playground-Node_Template-brightgreen?logo=Parity%20Substrate)](https://docs.substrate.io/playground/) [![Matrix](https://img.shields.io/matrix/substrate-technical:matrix.org)](https://matrix.to/#/#substrate-technical:matrix.org)
3+
A fresh [Substrate](https://substrate.io/) node, ready for hacking :rocket:
44

5-
A fresh FRAME-based [Substrate](https://www.substrate.io/) node, ready for hacking :rocket:
5+
A standalone version of this template is available for each release of Polkadot in the [Substrate Developer Hub Parachain Template](https://github.com/substrate-developer-hub/substrate-parachain-template/) repository.
6+
The parachain template is generated directly at each Polkadot release branch form the [Node Template in Substreate](https://github.com/paritytech/substrate/tree/master/bin/node-template) upstream
67

7-
## Getting Started
8-
9-
Follow the steps below to get started with the Node Template, or get it up and running right from
10-
your browser in just a few clicks using
11-
the [Substrate Playground](https://docs.substrate.io/playground/) :hammer_and_wrench:
12-
13-
### Using Nix
14-
15-
Install [nix](https://nixos.org/) and optionally [direnv](https://github.com/direnv/direnv) and
16-
[lorri](https://github.com/nix-community/lorri) for a fully plug and play experience for setting up
17-
the development environment. To get all the correct dependencies activate direnv `direnv allow` and
18-
lorri `lorri shell`.
19-
20-
### Rust Setup
8+
It is usually best to to use the stand-alone version to start a new project.
9+
All bugs, suggestions, and feature requests should be made upstream in the [Substrate](https://github.com/paritytech/substrate/tree/master/bin/node-template) repository.
2110

22-
First, complete the [basic Rust setup instructions](./docs/rust-setup.md).
23-
24-
### Run
11+
## Getting Started
2512

26-
Use Rust's native `cargo` command to build and launch the template node:
27-
28-
```sh
29-
cargo run --release -- --dev
30-
```
13+
Depending on your operating system and Rust version, there might be additional packages required to compile this template.
14+
Check the [Install](https://docs.substrate.io/install/) instructions for your platform for the most common dependencies.
15+
Alternatively, you can use one of the [alternative installation](#alternatives-installations) options.
3116

3217
### Build
3318

34-
The `cargo run` command will perform an initial build. Use the following command to build the node
35-
without launching it:
19+
Use the following command to build the node without launching it:
3620

3721
```sh
3822
cargo build --release
3923
```
4024

4125
### Embedded Docs
4226

43-
Once the project has been built, the following command can be used to explore all parameters and
44-
subcommands:
27+
After you build the project, you can use the following command to explore its parameters and subcommands:
4528

4629
```sh
4730
./target/release/node-template -h
4831
```
4932

50-
## Run
33+
You can generate and view the [Rust Docs](https://doc.rust-lang.org/cargo/commands/cargo-doc.html) for this template with this command:
5134

52-
The provided `cargo run` command will launch a temporary node and its state will be discarded after
53-
you terminate the process. After the project has been built, there are other ways to launch the
54-
node.
35+
```sh
36+
cargo +nightly doc --open
37+
```
5538

5639
### Single-Node Development Chain
5740

58-
This command will start the single-node development chain with non-persistent state:
41+
The following command starts a single-node development chain that doesn't persist state:
5942

60-
```bash
43+
```sh
6144
./target/release/node-template --dev
6245
```
6346

64-
Purge the development chain's state:
47+
To purge the development chain's state, run the following command:
6548

66-
```bash
49+
```sh
6750
./target/release/node-template purge-chain --dev
6851
```
6952

70-
Start the development chain with detailed logging:
53+
To start the development chain with detailed logging, run the following command:
7154

72-
```bash
55+
```sh
7356
RUST_BACKTRACE=1 ./target/release/node-template -ldebug --dev
7457
```
7558

76-
> Development chain means that the state of our chain will be in a tmp folder while the nodes are
77-
> running. Also, **alice** account will be authority and sudo account as declared in the
78-
> [genesis state](https://github.com/substrate-developer-hub/substrate-node-template/blob/main/node/src/chain_spec.rs#L49).
79-
> At the same time the following accounts will be pre-funded:
80-
> - Alice
81-
> - Bob
82-
> - Alice//stash
83-
> - Bob//stash
84-
85-
In case of being interested in maintaining the chain' state between runs a base path must be added
86-
so the db can be stored in the provided folder instead of a temporal one. We could use this folder
87-
to store different chain databases, as a different folder will be created per different chain that
88-
is ran. The following commands shows how to use a newly created folder as our db base path.
89-
90-
```bash
59+
Development chains:
60+
61+
- Maintain state in a `tmp` folder while the node is running.
62+
- Use the **Alice** and **Bob** accounts as default validator authorities.
63+
- Use the **Alice** account as the default `sudo` account.
64+
- Are preconfigured with a genesis state (`/node/src/chain_spec.rs`) that includes several prefunded development accounts.
65+
66+
67+
To persist chain state between runs, specify a base path by running a command similar to the following:
68+
69+
```sh
9170
// Create a folder to use as the db base path
9271
$ mkdir my-chain-state
9372

@@ -103,23 +82,19 @@ $ ls ./my-chain-state/chains/dev
10382
db keystore network
10483
```
10584

85+
### Connect with Polkadot-JS Apps Front-End
10686

107-
### Connect with Polkadot-JS Apps Front-end
108-
109-
Once the node template is running locally, you can connect it with **Polkadot-JS Apps** front-end
110-
to interact with your chain. [Click
111-
here](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944) connecting the Apps to your
112-
local node template.
87+
After you start the node template locally, you can interact with it using the hosted version of the [Polkadot/Substrate Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944) front-end by connecting to the local node endpoint.
88+
A hosted version is also available on [IPFS (redirect) here](https://dotapps.io/) or [IPNS (direct) here](ipns://dotapps.io/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer).
89+
You can also find the source code and instructions for hosting your own instance on the [polkadot-js/apps](https://github.com/polkadot-js/apps) repository.
11390

11491
### Multi-Node Local Testnet
11592

116-
If you want to see the multi-node consensus algorithm in action, refer to our
117-
[Simulate a network tutorial](https://docs.substrate.io/tutorials/get-started/simulate-network/).
93+
If you want to see the multi-node consensus algorithm in action, see [Simulate a network](https://docs.substrate.io/tutorials/get-started/simulate-network/).
11894

11995
## Template Structure
12096

121-
A Substrate project such as this consists of a number of components that are spread across a few
122-
directories.
97+
A Substrate project such as this consists of a number of components that are spread across a few directories.
12398

12499
### Node
125100

@@ -128,98 +103,74 @@ Substrate-based blockchain nodes expose a number of capabilities:
128103

129104
- Networking: Substrate nodes use the [`libp2p`](https://libp2p.io/) networking stack to allow the
130105
nodes in the network to communicate with one another.
131-
- Consensus: Blockchains must have a way to come to
132-
[consensus](https://docs.substrate.io/main-docs/fundamentals/consensus/) on the state of the
133-
network. Substrate makes it possible to supply custom consensus engines and also ships with
134-
several consensus mechanisms that have been built on top of
135-
[Web3 Foundation research](https://research.web3.foundation/en/latest/polkadot/NPoS/index.html).
106+
- Consensus: Blockchains must have a way to come to [consensus](https://docs.substrate.io/fundamentals/consensus/) on the state of the network.
107+
Substrate makes it possible to supply custom consensus engines and also ships with several consensus mechanisms that have been built on top of [Web3 Foundation research](https://research.web3.foundation/en/latest/polkadot/NPoS/index.html).
136108
- RPC Server: A remote procedure call (RPC) server is used to interact with Substrate nodes.
137109

138-
There are several files in the `node` directory - take special note of the following:
139-
140-
- [`chain_spec.rs`](./node/src/chain_spec.rs): A
141-
[chain specification](https://docs.substrate.io/main-docs/build/chain-spec/) is a
142-
source code file that defines a Substrate chain's initial (genesis) state. Chain specifications
143-
are useful for development and testing, and critical when architecting the launch of a
144-
production chain. Take note of the `development_config` and `testnet_genesis` functions, which
145-
are used to define the genesis state for the local development chain configuration. These
146-
functions identify some
147-
[well-known accounts](https://docs.substrate.io/reference/command-line-tools/subkey/)
148-
and use them to configure the blockchain's initial state.
149-
- [`service.rs`](./node/src/service.rs): This file defines the node implementation. Take note of
150-
the libraries that this file imports and the names of the functions it invokes. In particular,
151-
there are references to consensus-related topics, such as the
152-
[block finalization and forks](https://docs.substrate.io/main-docs/fundamentals/consensus/#finalization-and-forks)
153-
and other [consensus mechanisms](https://docs.substrate.io/main-docs/fundamentals/consensus/#default-consensus-models)
154-
such as Aura for block authoring and GRANDPA for finality.
155-
156-
After the node has been [built](#build), refer to the embedded documentation to learn more about the
157-
capabilities and configuration parameters that it exposes:
158-
159-
```shell
160-
./target/release/node-template --help
161-
```
110+
There are several files in the `node` directory.
111+
Take special note of the following:
112+
113+
- [`chain_spec.rs`](./node/src/chain_spec.rs): A [chain specification](https://docs.substrate.io/build/chain-spec/) is a source code file that defines a Substrate chain's initial (genesis) state.
114+
Chain specifications are useful for development and testing, and critical when architecting the launch of a production chain.
115+
Take note of the `development_config` and `testnet_genesis` functions,.
116+
These functions are used to define the genesis state for the local development chain configuration.
117+
These functions identify some [well-known accounts](https://docs.substrate.io/reference/command-line-tools/subkey/) and use them to configure the blockchain's initial state.
118+
- [`service.rs`](./node/src/service.rs): This file defines the node implementation.
119+
Take note of the libraries that this file imports and the names of the functions it invokes.
120+
In particular, there are references to consensus-related topics, such as the [block finalization and forks](https://docs.substrate.io/fundamentals/consensus/#finalization-and-forks) and other [consensus mechanisms](https://docs.substrate.io/fundamentals/consensus/#default-consensus-models) such as Aura for block authoring and GRANDPA for finality.
121+
122+
162123

163124
### Runtime
164125

165-
In Substrate, the terms
166-
"runtime" and "state transition function"
167-
are analogous - they refer to the core logic of the blockchain that is responsible for validating
168-
blocks and executing the state changes they define. The Substrate project in this repository uses
169-
[FRAME](https://docs.substrate.io/main-docs/fundamentals/runtime-intro/#frame) to construct a
170-
blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules
171-
called "pallets". At the heart of FRAME is a helpful
172-
[macro language](https://docs.substrate.io/reference/frame-macros/) that makes it easy to
173-
create pallets and flexibly compose them to create blockchains that can address
174-
[a variety of needs](https://substrate.io/ecosystem/projects/).
175-
176-
Review the [FRAME runtime implementation](./runtime/src/lib.rs) included in this template and note
177-
the following:
178-
179-
- This file configures several pallets to include in the runtime. Each pallet configuration is
180-
defined by a code block that begins with `impl $PALLET_NAME::Config for Runtime`.
181-
- The pallets are composed into a single runtime by way of the
182-
[`construct_runtime!`](https://crates.parity.io/frame_support/macro.construct_runtime.html)
183-
macro, which is part of the core
184-
FRAME Support [system](https://docs.substrate.io/reference/frame-pallets/#system-pallets) library.
126+
In Substrate, the terms "runtime" and "state transition function" are analogous.
127+
Both terms refer to the core logic of the blockchain that is responsible for validating blocks and executing the state changes they define.
128+
The Substrate project in this repository uses [FRAME](https://docs.substrate.io/fundamentals/runtime-development/#frame) to construct a blockchain runtime.
129+
FRAME allows runtime developers to declare domain-specific logic in modules called "pallets".
130+
At the heart of FRAME is a helpful [macro language](https://docs.substrate.io/reference/frame-macros/) that makes it easy to create pallets and flexibly compose them to create blockchains that can address [a variety of needs](https://substrate.io/ecosystem/projects/).
131+
132+
Review the [FRAME runtime implementation](./runtime/src/lib.rs) included in this template and note the following:
133+
134+
- This file configures several pallets to include in the runtime.
135+
Each pallet configuration is defined by a code block that begins with `impl $PALLET_NAME::Config for Runtime`.
136+
- The pallets are composed into a single runtime by way of the [`construct_runtime!`](https://crates.parity.io/frame_support/macro.construct_runtime.html) macro, which is part of the core FRAME Support [system](https://docs.substrate.io/reference/frame-pallets/#system-pallets) library.
185137

186138
### Pallets
187139

188-
The runtime in this project is constructed using many FRAME pallets that ship with the
189-
[core Substrate repository](https://github.com/paritytech/substrate/tree/master/frame) and a
190-
template pallet that is [defined in the `pallets`](./pallets/template/src/lib.rs) directory.
140+
The runtime in this project is constructed using many FRAME pallets that ship with the [core Substrate repository](https://github.com/paritytech/substrate/tree/master/frame) and a template pallet that is [defined in the `pallets`](./pallets/template/src/lib.rs) directory.
191141

192142
A FRAME pallet is compromised of a number of blockchain primitives:
193143

194-
- Storage: FRAME defines a rich set of powerful
195-
[storage abstractions](https://docs.substrate.io/main-docs/build/runtime-storage/) that makes
196-
it easy to use Substrate's efficient key-value database to manage the evolving state of a
197-
blockchain.
198-
- Dispatchables: FRAME pallets define special types of functions that can be invoked (dispatched)
199-
from outside of the runtime in order to update its state.
200-
- Events: Substrate uses [events and errors](https://docs.substrate.io/main-docs/build/events-errors/)
201-
to notify users of important changes in the runtime.
144+
- Storage: FRAME defines a rich set of powerful [storage abstractions](https://docs.substrate.io/build/runtime-storage/) that makes it easy to use Substrate's efficient key-value database to manage the evolving state of a blockchain.
145+
- Dispatchables: FRAME pallets define special types of functions that can be invoked (dispatched) from outside of the runtime in order to update its state.
146+
- Events: Substrate uses [events and errors](https://docs.substrate.io/build/events-and-errors/) to notify users of important changes in the runtime.
202147
- Errors: When a dispatchable fails, it returns an error.
203-
- Config: The `Config` configuration interface is used to define the types and parameters upon
204-
which a FRAME pallet depends.
148+
- Config: The `Config` configuration interface is used to define the types and parameters upon which a FRAME pallet depends.
149+
150+
## Alternatives Installations
151+
152+
Instead of installing dependencies and building this source directly, consider the following alternatives.
205153

206-
### Run in Docker
154+
### Nix
207155

208-
First, install [Docker](https://docs.docker.com/get-docker/) and
209-
[Docker Compose](https://docs.docker.com/compose/install/).
156+
Install [nix](https://nixos.org/), and optionally [direnv](https://github.com/direnv/direnv) and [lorri](https://github.com/nix-community/lorri) for a fully plug-and-play experience for setting up the development environment.
157+
To get all the correct dependencies, activate direnv `direnv allow` and lorri `lorri shell`.
158+
159+
### Docker
160+
161+
First, install [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/).
210162

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

213-
```bash
165+
```sh
214166
./scripts/docker_run.sh
215167
```
216168

217-
This command will firstly compile your code, and then start a local development network. You can
218-
also replace the default command
219-
(`cargo build --release && ./target/release/node-template --dev --ws-external`)
220-
by appending your own. A few useful ones are as follow.
169+
This command compiles the code and starts a local development network.
170+
You can also replace the default command (`cargo build --release && ./target/release/node-template --dev --ws-external`) by appending your own.
171+
For example:
221172

222-
```bash
173+
```sh
223174
# Run Substrate node without re-compiling
224175
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external
225176

bin/node-template/scripts/docker_run.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)