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

Commit 705775d

Browse files
committed
Merge remote-tracking branch 'origin/master' into bounty
2 parents c1f9900 + 60e3a69 commit 705775d

File tree

95 files changed

+1984
-1948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1984
-1948
lines changed

Cargo.lock

Lines changed: 13 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node-template/README.md

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,76 @@
1+
[![Substrate Playground](https://img.shields.io/badge/Playground-node_template-brightgreen?logo=Parity%20Substrate)](https://playground-staging.substrate.dev/?deploy=node-template)
2+
13
# Substrate Node Template
24

3-
A new FRAME-based Substrate node, ready for hacking.
5+
A new FRAME-based Substrate node, ready for hacking :rocket:
46

5-
## Build
7+
## Local Development
68

7-
Install Rust:
9+
Follow these steps to prepare a local Substrate development environment :hammer_and_wrench:
810

9-
```bash
10-
curl https://sh.rustup.rs -sSf | sh
11-
```
11+
### Simple Setup
1212

13-
Initialize your Wasm Build environment:
13+
Install all the required dependencies with a single command (be patient, this can take up
14+
to 30 minutes).
1415

1516
```bash
16-
./scripts/init.sh
17+
curl https://getsubstrate.io -sSf | bash -s -- --fast
1718
```
1819

19-
Build Wasm and native code:
20+
### Manual Setup
21+
22+
Find manual setup instructions at the [Substrate Developer Hub](https://substrate.dev/docs/en/knowledgebase/getting-started/#manual-installation).
23+
24+
### Build
25+
26+
Once the development environment is set up, build the node template. This command will build the
27+
[Wasm](https://substrate.dev/docs/en/knowledgebase/advanced/executor#wasm-execution) and
28+
[native](https://substrate.dev/docs/en/knowledgebase/advanced/executor#native-execution) code:
2029

2130
```bash
2231
cargo build --release
2332
```
2433

34+
## Playground [![Substrate Playground](https://img.shields.io/badge/Playground-node_template-brightgreen?logo=Parity%20Substrate)](https://playground-staging.substrate.dev/?deploy=node-template)
35+
36+
[The Substrate Playground](https://playground-staging.substrate.dev/?deploy=node-template) is an
37+
online development environment that supplies a pre-configured container with pre-compiled build
38+
artifacts :cartwheeling:
39+
2540
## Run
2641

27-
### Single node development chain
42+
### Single Node Development Chain
2843

29-
Purge any existing developer chain state:
44+
Purge any existing dev chain state:
3045

3146
```bash
3247
./target/release/node-template purge-chain --dev
3348
```
3449

35-
Start a development chain with:
50+
Start a dev chain:
3651

3752
```bash
3853
./target/release/node-template --dev
3954
```
4055

41-
Detailed logs may be shown by running the node with the following environment variables set: `RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev`.
56+
Or, start a dev chain with detailed logging:
4257

43-
### Multi-node local testnet
58+
```bash
59+
RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/node-template -lruntime=debug --dev
60+
```
4461

45-
If you want to see the multi-node consensus algorithm in action locally, then you can create a local testnet with two validator nodes for Alice and Bob, who are the initial authorities of the genesis chain that have been endowed with testnet units.
62+
### Multi-Node Local Testnet
4663

47-
Optionally, give each node a name and expose them so they are listed on the Polkadot [telemetry site](https://telemetry.polkadot.io/#/Local%20Testnet).
64+
To see the multi-node consensus algorithm in action, run a local testnet with two validator nodes,
65+
Alice and Bob, that have been [configured](/bin/node-template/node/src/chain_spec.rs) as the
66+
initial authorities of the `local` testnet chain and endowed with testnet units.
4867

49-
You'll need two terminal windows open.
68+
Note: this will require two terminal sessions (one for each node).
5069

51-
We'll start Alice's substrate node first on default TCP port 30333 with her chain database stored locally at `/tmp/alice`. The bootnode ID of her node is `QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR`, which is generated from the `--node-key` value that we specify below:
70+
Start Alice's node first. The command below uses the default TCP port (30333) and specifies
71+
`/tmp/alice` as the chain database location. Alice's node ID will be
72+
`12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp` (legacy representation:
73+
`QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR`); this is determined by the `node-key`.
5274

5375
```bash
5476
cargo run -- \
@@ -60,17 +82,42 @@ cargo run -- \
6082
--validator
6183
```
6284

63-
In the second terminal, we'll start Bob's substrate node on a different TCP port of 30334, and with his chain database stored locally at `/tmp/bob`. We'll specify a value for the `--bootnodes` option that will connect his node to Alice's bootnode ID on TCP port 30333:
85+
In another terminal, use the following command to start Bob's node on a different TCP port (30334)
86+
and with a chain database location of `/tmp/bob`. The `--bootnodes` option will connect his node to
87+
Alice's on TCP port 30333:
6488

6589
```bash
6690
cargo run -- \
6791
--base-path /tmp/bob \
68-
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR \
92+
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp \
6993
--chain=local \
7094
--bob \
7195
--port 30334 \
96+
--ws-port 9945 \
7297
--telemetry-url 'ws://telemetry.polkadot.io:1024 0' \
7398
--validator
7499
```
75100

76-
Additional CLI usage options are available and may be shown by running `cargo run -- --help`.
101+
Execute `cargo run -- --help` to learn more about the template node's CLI options.
102+
103+
## Generate a Custom Node Template
104+
105+
Generate a Substrate node template based on a particular commit by running the following commands:
106+
107+
```bash
108+
# Clone from the main Substrate repo
109+
git clone https://github.com/paritytech/substrate.git
110+
cd substrate
111+
112+
# Switch to the branch or commit to base the template on
113+
git checkout <branch/tag/sha1>
114+
115+
# Run the helper script to generate a node template. This script compiles Substrate, so it will take
116+
# a while to complete. It expects a single parameter: the location for the script's output expressed
117+
# as a relative path.
118+
.maintain/node-template-release.sh ../node-template.tar.gz
119+
```
120+
121+
Custom node templates are not supported. Please use a recently tagged version of the
122+
[Substrate Developer Node Template](https://github.com/substrate-developer-hub/substrate-node-template)
123+
in order to receive support.

bin/node-template/node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "node-template"
33
version = "2.0.0-rc4"
44
authors = ["Anonymous"]
5-
description = "Substrate Node template"
5+
description = "A new FRAME-based Substrate node, ready for hacking."
66
edition = "2018"
77
license = "Unlicense"
88
build = "build.rs"

bin/node-template/node/src/service.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ macro_rules! new_full_start {
4949
builder.client().clone(),
5050
None,
5151
);
52-
Ok(sc_transaction_pool::BasicPool::new(
52+
Ok(sc_transaction_pool::BasicPool::new_full(
5353
builder.config().transaction_pool.clone(),
5454
std::sync::Arc::new(pool_api),
5555
builder.prometheus_registry(),
56+
builder.spawn_handle(),
57+
builder.client().clone(),
5658
))
5759
})?
5860
.with_import_queue(|
@@ -221,12 +223,12 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
221223
builder.client().clone(),
222224
fetcher.clone(),
223225
);
224-
let pool = sc_transaction_pool::BasicPool::with_revalidation_type(
226+
let pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
225227
builder.config().transaction_pool.clone(),
226228
Arc::new(pool_api),
227229
builder.prometheus_registry(),
228-
sc_transaction_pool::RevalidationType::Light,
229-
);
230+
builder.spawn_handle(),
231+
));
230232
Ok(pool)
231233
})?
232234
.with_import_queue_and_fprb(|

0 commit comments

Comments
 (0)