Skip to content

Commit 430dd05

Browse files
kianenigmagithub-actions[bot]
authored andcommitted
[create-pull-request] automated change
1 parent 3004222 commit 430dd05

File tree

18 files changed

+315
-18674
lines changed

18 files changed

+315
-18674
lines changed

Cargo.lock

Lines changed: 0 additions & 18564 deletions
This file was deleted.

Cargo.toml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@ repository = "https://github.com/paritytech/polkadot-sdk-minimal-template.git"
66
edition = "2021"
77

88
[workspace]
9-
members = ["node", "pallets/template", "runtime"]
9+
"default-members" = ["pallets/template", "runtime"]
10+
members = [
11+
"node",
12+
"pallets/template",
13+
"runtime",
14+
]
1015
resolver = "2"
1116

1217
[workspace.dependencies]
1318
minimal-template-runtime = { path = "./runtime", default-features = false }
1419
pallet-minimal-template = { path = "./pallets/template", default-features = false }
15-
clap = { version = "4.5.10" }
16-
docify = { version = "0.2.8" }
17-
futures = { version = "0.3.30" }
20+
clap = { version = "4.5.13" }
21+
docify = { version = "0.2.9" }
22+
futures = { version = "0.3.31" }
1823
futures-timer = { version = "3.0.2" }
1924
jsonrpsee = { version = "0.24.3" }
20-
polkadot-sdk = { version = "0.7.0", default-features = false }
21-
serde_json = { version = "1.0.127", default-features = false }
25+
polkadot-sdk = { version = "0.1.0", default-features = false }
26+
serde_json = { version = "1.0.132", default-features = false }
2227
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
2328
scale-info = { version = "2.11.1", default-features = false }

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ WORKDIR /polkadot
44
COPY . /polkadot
55

66
RUN cargo fetch
7-
RUN cargo build --locked --release
7+
RUN cargo build --workspace --locked --release
88

99
FROM docker.io/parity/base-bin:latest
1010

README.md

Lines changed: 149 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,91 +11,209 @@
1111
1212
</div>
1313

14-
* 🤏 This template is a minimal (in terms of complexity and the number of components)
14+
## Table of Contents
15+
16+
- [Intro](#intro)
17+
18+
- [Template Structure](#template-structure)
19+
20+
- [Getting Started](#getting-started)
21+
22+
- [Starting a Minimal Template Chain](#starting-a-minimal-template-chain)
23+
24+
- [Omni Node](#omni-node)
25+
- [Minimal Template Node](#minimal-template-node)
26+
- [Zombienet with Omni Node](#zombienet-with-omni-node)
27+
- [Zombienet with Minimal Template Node](#zombienet-with-minimal-template-node)
28+
- [Connect with the Polkadot-JS Apps Front-End](#connect-with-the-polkadot-js-apps-front-end)
29+
- [Takeaways](#takeaways)
30+
31+
- [Contributing](#contributing)
32+
33+
- [Getting Help](#getting-help)
34+
35+
## Intro
36+
37+
- 🤏 This template is a minimal (in terms of complexity and the number of components)
1538
template for building a blockchain node.
1639

17-
* 🔧 Its runtime is configured with a single custom pallet as a starting point, and a handful of ready-made pallets
40+
- 🔧 Its runtime is configured with a single custom pallet as a starting point, and a handful of ready-made pallets
1841
such as a [Balances pallet](https://paritytech.github.io/polkadot-sdk/master/pallet_balances/index.html).
1942

20-
* 👤 The template has no consensus configured - it is best for experimenting with a single node network.
43+
- 👤 The template has no consensus configured - it is best for experimenting with a single node network.
2144

2245
## Template Structure
2346

2447
A Polkadot SDK based project such as this one consists of:
2548

26-
* 💿 a [Node](./node/README.md) - the binary application.
27-
* 🧮 the [Runtime](./runtime/README.md) - the core logic of the blockchain.
28-
* 🎨 the [Pallets](./pallets/README.md) - from which the runtime is constructed.
49+
- 🧮 the [Runtime](./runtime/README.md) - the core logic of the blockchain.
50+
- 🎨 the [Pallets](./pallets/README.md) - from which the runtime is constructed.
51+
- 💿 a [Node](./node/README.md) - the binary application (which is not part of the cargo default-members list and is not
52+
compiled unless building the entire workspace).
2953

3054
## Getting Started
3155

32-
* 🦀 The template is using the Rust language.
56+
- 🦀 The template is using the Rust language.
3357

34-
* 👉 Check the
58+
- 👉 Check the
3559
[Rust installation instructions](https://www.rust-lang.org/tools/install) for your system.
3660

37-
* 🛠️ Depending on your operating system and Rust version, there might be additional
61+
- 🛠️ Depending on your operating system and Rust version, there might be additional
3862
packages required to compile this template - please take note of the Rust compiler output.
3963

40-
### Build
64+
Fetch minimal template code:
65+
66+
```sh
67+
git clone https://github.com/paritytech/polkadot-sdk-minimal-template.git minimal-template
68+
69+
cd minimal-template
70+
```
71+
72+
## Starting a Minimal Template Chain
73+
74+
### Omni Node
75+
76+
[Omni Node](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/omni_node/index.html) can
77+
be used to run the minimal template's runtime. `polkadot-omni-node` binary crate usage is described at a high-level
78+
[on crates.io](https://crates.io/crates/polkadot-omni-node).
79+
80+
#### Install `polkadot-omni-node`
81+
82+
Please see installation section on [crates.io/omni-node](https://crates.io/crates/polkadot-omni-node).
83+
84+
#### Build `minimal-template-runtime`
85+
86+
```sh
87+
cargo build -p minimal-template-runtime --release
88+
```
89+
90+
#### Install `staging-chain-spec-builder`
91+
92+
Please see the installation section at [`crates.io/staging-chain-spec-builder`](https://crates.io/crates/staging-chain-spec-builder).
93+
94+
#### Use chain-spec-builder to generate the chain_spec.json file
95+
96+
```sh
97+
chain-spec-builder create --relay-chain "dev" --para-id 1000 --runtime \
98+
target/release/wbuild/minimal-template-runtime/minimal_template_runtime.wasm named-preset development
99+
```
100+
101+
**Note**: the `relay-chain` and `para-id` flags are extra bits of information required to
102+
configure the node for the case of representing a parachain that is connected to a relay chain.
103+
They are not relevant to minimal template business logic, but they are mandatory information for
104+
Omni Node, nonetheless.
105+
106+
#### Run Omni Node
41107

42-
🔨 Use the following command to build the node without launching it:
108+
Start Omni Node in development mode (sets up block production and finalization based on manual seal,
109+
sealing a new block every 3 seconds), with a minimal template runtime chain spec.
43110

44111
```sh
45-
cargo build --release
112+
polkadot-omni-node --chain <path/to/chain_spec.json> --dev
46113
```
47114

48-
🐳 Alternatively, build the docker image:
115+
### Minimal Template Node
116+
117+
#### Build both node & runtime
118+
119+
```sh
120+
cargo build --workspace --release
121+
```
122+
123+
🐳 Alternatively, build the docker image which builds all the workspace members,
124+
and has as entry point the node binary:
49125

50126
```sh
51127
docker build . -t polkadot-sdk-minimal-template
52128
```
53129

54-
### Single-Node Development Chain
130+
#### Start the `minimal-template-node`
55131

56-
👤 The following command starts a single-node development chain:
132+
The `minimal-template-node` has dependency on the `minimal-template-runtime`. It will use
133+
the `minimal_template_runtime::WASM_BINARY` constant (which holds the WASM blob as a byte
134+
array) for chain spec building, while starting. This is in contrast to Omni Node which doesn't
135+
depend on a specific runtime, but asks for the chain spec at startup.
57136

58137
```sh
59-
./target/release/minimal-template-node --dev
138+
<target/release/path/to/minimal-template-node> --tmp --consensus manual-seal-3000
139+
# or via docker
140+
docker run --rm polkadot-sdk-minimal-template
141+
```
142+
143+
### Zombienet with Omni Node
144+
145+
#### Install `zombienet`
146+
147+
We can install `zombienet` as described [here](https://paritytech.github.io/zombienet/install.html#installation),
148+
and `zombienet-omni-node.toml` contains the network specification we want to start.
60149

61-
# docker version:
62-
docker run --rm polkadot-sdk-minimal-template --dev
150+
#### Update `zombienet-omni-node.toml` with a valid chain spec path
151+
152+
Before starting the network with zombienet we must update the network specification
153+
with a valid chain spec path. If we need to generate one, we can look up at the previous
154+
section for chain spec creation [here](#use-chain-spec-builder-to-generate-the-chain_specjson-file).
155+
156+
Then make the changes in the network specification like so:
157+
158+
```toml
159+
# ...
160+
chain = "dev"
161+
chain_spec_path = "<TO BE UPDATED WITH A VALID PATH>"
162+
default_args = ["--dev"]
163+
# ..
164+
```
165+
166+
#### Start the network
167+
168+
```sh
169+
zombienet --provider native spawn zombienet-omni-node.toml
63170
```
64171

65-
Development chains:
172+
### Zombienet with `minimal-template-node`
66173

67-
* 🧹 Do not persist the state.
68-
* 💰 Are pre-configured with a genesis state that includes several pre-funded development accounts.
69-
* 🧑‍⚖️ One development account (`ALICE`) is used as `sudo` accounts.
174+
For this one we just need to have `zombienet` installed and run:
175+
176+
```sh
177+
zombienet --provider native spawn zombienet-multi-node.toml
178+
```
70179

71180
### Connect with the Polkadot-JS Apps Front-End
72181

73-
* 🌐 You can interact with your local node using the
182+
- 🌐 You can interact with your local node using the
74183
hosted version of the [Polkadot/Substrate
75184
Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944).
76185

77-
* 🪐 A hosted version is also
186+
- 🪐 A hosted version is also
78187
available on [IPFS](https://dotapps.io/).
79188

80-
* 🧑‍🔧 You can also find the source code and instructions for hosting your own instance in the
189+
- 🧑‍🔧 You can also find the source code and instructions for hosting your own instance in the
81190
[`polkadot-js/apps`](https://github.com/polkadot-js/apps) repository.
82191

192+
### Takeaways
193+
194+
Previously minimal template's development chains:
195+
196+
- ❌ Started in a multi-node setup will produce forks because minimal lacks consensus.
197+
- 🧹 Do not persist the state.
198+
- 💰 Are pre-configured with a genesis state that includes several pre-funded development accounts.
199+
- 🧑‍⚖️ One development account (`ALICE`) is used as `sudo` accounts.
200+
83201
## Contributing
84202

85-
* 🔄 This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
203+
- 🔄 This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
86204

87-
* ➡️ Any pull requests should be directed to this [source](https://github.com/paritytech/polkadot-sdk/tree/master/templates/minimal).
205+
- ➡️ Any pull requests should be directed to this [source](https://github.com/paritytech/polkadot-sdk/tree/master/templates/minimal).
88206

89-
* 😇 Please refer to the monorepo's
207+
- 😇 Please refer to the monorepo's
90208
[contribution guidelines](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md) and
91209
[Code of Conduct](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CODE_OF_CONDUCT.md).
92210

93211
## Getting Help
94212

95-
* 🧑‍🏫 To learn about Polkadot in general, [Polkadot.network](https://polkadot.network/) website is a good starting point.
213+
- 🧑‍🏫 To learn about Polkadot in general, [Polkadot.network](https://polkadot.network/) website is a good starting point.
96214

97-
* 🧑‍🔧 For technical introduction, [here](https://github.com/paritytech/polkadot-sdk#-documentation) are
215+
- 🧑‍🔧 For technical introduction, [here](https://github.com/paritytech/polkadot-sdk#-documentation) are
98216
the Polkadot SDK documentation resources.
99217

100-
* 👥 Additionally, there are [GitHub issues](https://github.com/paritytech/polkadot-sdk/issues) and
218+
- 👥 Additionally, there are [GitHub issues](https://github.com/paritytech/polkadot-sdk/issues) and
101219
[Substrate StackExchange](https://substrate.stackexchange.com/).

node/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "minimal-template-node"
33
description = "A minimal Substrate-based Substrate node, ready for hacking."
4-
version = "0.1.0"
4+
version = "0.0.0"
55
license = "Unlicense"
66
authors.workspace = true
77
homepage.workspace = true
@@ -20,8 +20,9 @@ futures = { features = ["thread-pool"], workspace = true }
2020
futures-timer = { workspace = true }
2121
jsonrpsee = { features = ["server"], workspace = true }
2222
serde_json = { workspace = true, default-features = true }
23+
2324
polkadot-sdk = { workspace = true, features = ["experimental", "node"] }
24-
minimal-template-runtime.workspace = true
25+
minimal-template-runtime = { workspace = true }
2526

2627
[build-dependencies]
2728
polkadot-sdk = { workspace = true, features = ["substrate-build-script-utils"] }

node/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,3 @@
1616
initial (genesis) state.
1717
- [`service.rs`](./src/service.rs): This file defines the node implementation.
1818
It's a place to configure consensus-related topics. In favor of minimalism, this template has no consensus configured.
19-
20-
21-
## Release
22-
23-
Polkadot SDK stable2409

node/src/chain_spec.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
// See the License for the specific language governing permissions and
1616
// limitations under the License.
1717

18-
use minimal_template_runtime::{BalancesConfig, SudoConfig, WASM_BINARY};
18+
use minimal_template_runtime::WASM_BINARY;
1919
use polkadot_sdk::{
2020
sc_service::{ChainType, Properties},
21-
sp_keyring::AccountKeyring,
2221
*,
2322
};
24-
use serde_json::{json, Value};
2523

2624
/// This is a specialization of the general Substrate ChainSpec type.
2725
pub type ChainSpec = sc_service::GenericChainSpec;
@@ -33,26 +31,12 @@ fn props() -> Properties {
3331
properties
3432
}
3533

36-
pub fn development_config() -> Result<ChainSpec, String> {
34+
pub fn development_chain_spec() -> Result<ChainSpec, String> {
3735
Ok(ChainSpec::builder(WASM_BINARY.expect("Development wasm not available"), Default::default())
3836
.with_name("Development")
3937
.with_id("dev")
4038
.with_chain_type(ChainType::Development)
41-
.with_genesis_config_patch(testnet_genesis())
39+
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
4240
.with_properties(props())
4341
.build())
4442
}
45-
46-
/// Configure initial storage state for FRAME pallets.
47-
fn testnet_genesis() -> Value {
48-
use minimal_template_runtime::interface::{Balance, MinimumBalance};
49-
use polkadot_sdk::polkadot_sdk_frame::traits::Get;
50-
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
51-
let balances = AccountKeyring::iter()
52-
.map(|a| (a.to_account_id(), endowment))
53-
.collect::<Vec<_>>();
54-
json!({
55-
"balances": BalancesConfig { balances },
56-
"sudo": SudoConfig { key: Some(AccountKeyring::Alice.to_account_id()) },
57-
})
58-
}

node/src/cli.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use polkadot_sdk::{sc_cli::RunCmd, *};
2121
pub enum Consensus {
2222
ManualSeal(u64),
2323
InstantSeal,
24+
None,
2425
}
2526

2627
impl std::str::FromStr for Consensus {
@@ -31,6 +32,8 @@ impl std::str::FromStr for Consensus {
3132
Consensus::InstantSeal
3233
} else if let Some(block_time) = s.strip_prefix("manual-seal-") {
3334
Consensus::ManualSeal(block_time.parse().map_err(|_| "invalid block time")?)
35+
} else if s.to_lowercase() == "none" {
36+
Consensus::None
3437
} else {
3538
return Err("incorrect consensus identifier".into());
3639
})

node/src/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl SubstrateCli for Cli {
4949

5050
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
5151
Ok(match id {
52-
"dev" => Box::new(chain_spec::development_config()?),
52+
"dev" => Box::new(chain_spec::development_chain_spec()?),
5353
path =>
5454
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
5555
})

0 commit comments

Comments
 (0)