|
11 | 11 |
|
12 | 12 | </div> |
13 | 13 |
|
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) |
15 | 38 | template for building a blockchain node. |
16 | 39 |
|
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 |
18 | 41 | such as a [Balances pallet](https://paritytech.github.io/polkadot-sdk/master/pallet_balances/index.html). |
19 | 42 |
|
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. |
21 | 44 |
|
22 | 45 | ## Template Structure |
23 | 46 |
|
24 | 47 | A Polkadot SDK based project such as this one consists of: |
25 | 48 |
|
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). |
29 | 53 |
|
30 | 54 | ## Getting Started |
31 | 55 |
|
32 | | -* 🦀 The template is using the Rust language. |
| 56 | +- 🦀 The template is using the Rust language. |
33 | 57 |
|
34 | | -* 👉 Check the |
| 58 | +- 👉 Check the |
35 | 59 | [Rust installation instructions](https://www.rust-lang.org/tools/install) for your system. |
36 | 60 |
|
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 |
38 | 62 | packages required to compile this template - please take note of the Rust compiler output. |
39 | 63 |
|
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 |
41 | 107 |
|
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. |
43 | 110 |
|
44 | 111 | ```sh |
45 | | -cargo build --release |
| 112 | +polkadot-omni-node --chain <path/to/chain_spec.json> --dev |
46 | 113 | ``` |
47 | 114 |
|
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: |
49 | 125 |
|
50 | 126 | ```sh |
51 | 127 | docker build . -t polkadot-sdk-minimal-template |
52 | 128 | ``` |
53 | 129 |
|
54 | | -### Single-Node Development Chain |
| 130 | +#### Start the `minimal-template-node` |
55 | 131 |
|
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. |
57 | 136 |
|
58 | 137 | ```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. |
60 | 149 |
|
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 |
63 | 170 | ``` |
64 | 171 |
|
65 | | -Development chains: |
| 172 | +### Zombienet with `minimal-template-node` |
66 | 173 |
|
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 | +``` |
70 | 179 |
|
71 | 180 | ### Connect with the Polkadot-JS Apps Front-End |
72 | 181 |
|
73 | | -* 🌐 You can interact with your local node using the |
| 182 | +- 🌐 You can interact with your local node using the |
74 | 183 | hosted version of the [Polkadot/Substrate |
75 | 184 | Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944). |
76 | 185 |
|
77 | | -* 🪐 A hosted version is also |
| 186 | +- 🪐 A hosted version is also |
78 | 187 | available on [IPFS](https://dotapps.io/). |
79 | 188 |
|
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 |
81 | 190 | [`polkadot-js/apps`](https://github.com/polkadot-js/apps) repository. |
82 | 191 |
|
| 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 | + |
83 | 201 | ## Contributing |
84 | 202 |
|
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). |
86 | 204 |
|
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). |
88 | 206 |
|
89 | | -* 😇 Please refer to the monorepo's |
| 207 | +- 😇 Please refer to the monorepo's |
90 | 208 | [contribution guidelines](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md) and |
91 | 209 | [Code of Conduct](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CODE_OF_CONDUCT.md). |
92 | 210 |
|
93 | 211 | ## Getting Help |
94 | 212 |
|
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. |
96 | 214 |
|
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 |
98 | 216 | the Polkadot SDK documentation resources. |
99 | 217 |
|
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 |
101 | 219 | [Substrate StackExchange](https://substrate.stackexchange.com/). |
0 commit comments