Skip to content

Commit 753a0ba

Browse files
Merge pull request #1 from hippiestank/main
update Build a Blockchain Tutorial
2 parents 5416c44 + a127eb7 commit 753a0ba

File tree

2 files changed

+77
-62
lines changed

2 files changed

+77
-62
lines changed

content/md/en/docs/tutorials/build-a-blockchain/authorize-specific-nodes.md

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ To add the `node-authorization` pallet to the Substrate runtime:
131131

132132
```toml
133133
[dependencies]
134-
pallet-node-authorization = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
134+
pallet-node-authorization = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false }
135135
```
136136

137137
This line imports the `pallet-node-authorization` crate as a dependency and specifies the following configuration details for the crate:
@@ -222,19 +222,34 @@ To implement the `node-authorization` pallet in your runtime:
222222
}
223223
```
224224

225-
1. Add the pallet to the `construct_runtime` macro with the following line of code:
225+
1. Locate the `construct_runtime` macro:
226226

227227
```rust
228-
construct_runtime!(
229-
pub enum Runtime where
230-
Block = Block,
231-
NodeBlock = opaque::Block,
232-
UncheckedExtrinsic = UncheckedExtrinsic
233-
{
234-
/*** Add This Line ***/
235-
NodeAuthorization: pallet_node_authorization::{Pallet, Call, Storage, Event<T>, Config<T>},
236-
}
237-
);
228+
#[frame_support::runtime]
229+
mod runtime {
230+
#[runtime::runtime]
231+
#[runtime::derive(
232+
RuntimeCall,
233+
RuntimeEvent,
234+
RuntimeError,
235+
RuntimeOrigin,
236+
RuntimeFreezeReason,
237+
RuntimeHoldReason,
238+
RuntimeSlashReason,
239+
RuntimeLockId,
240+
RuntimeTask
241+
)]
242+
pub struct Runtime;
243+
244+
#[runtime::pallet_index(0)]
245+
pub type System = frame_system;
246+
```
247+
248+
1. Add the Node Authorization pallet inside the `construct_runtime!` macro with the following code:
249+
250+
```rust
251+
#[runtime::pallet_index(x)] //*** Change pallet index ***//
252+
pub type NodeAuthorization = pallet_node_authorization;
238253
```
239254

240255
1. Save your changes and close the file.
@@ -270,40 +285,37 @@ To configure genesis storage for authorized nodes:
270285

271286
```rust
272287
use sp_core::OpaquePeerId; // A struct wraps Vec<u8> to represent the node `PeerId`.
273-
use node_template_runtime::NodeAuthorizationConfig; // The genesis config that serves the pallet.
274288
```
275289

276290
1. Locate the `testnet_genesis` function that configures initial storage state for FRAME modules.
277291

278292
For example:
279293

280294
```rust
281-
/// Configure initial storage state for FRAME modules.
282-
fn testnet_genesis(
283-
wasm_binary: &[u8],
284-
initial_authorities: Vec<(AuraId, GrandpaId)>,
285-
root_key: AccountId,
286-
endowed_accounts: Vec<AccountId>,
287-
_enable_println: bool,
288-
) -> GenesisConfig {
289-
295+
/// Configure initial storage state for FRAME modules.
296+
fn testnet_genesis(
297+
initial_authorities: Vec<(AuraId, GrandpaId)>,
298+
root_key: AccountId,
299+
endowed_accounts: Vec<AccountId>,
300+
_enable_println: bool,
301+
) -> serde_json::Value {
290302
```
291303

292-
1. Within the `GenesisConfig` declaration, add the following code block:
304+
1. Within the `serde_json::Value` declaration, add the following code block:
293305

294306
```rust
295-
node_authorization: NodeAuthorizationConfig {
296-
nodes: vec![
297-
(
298-
OpaquePeerId(bs58::decode("12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2").into_vec().unwrap()),
299-
endowed_accounts[0].clone()
300-
),
301-
(
302-
OpaquePeerId(bs58::decode("12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust").into_vec().unwrap()),
303-
endowed_accounts[1].clone()
304-
),
305-
],
306-
},
307+
"nodeAuthorization": {
308+
"nodes": vec![
309+
(
310+
OpaquePeerId(bs58::decode("12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2").into_vec().unwrap()),
311+
endowed_accounts[0].clone()
312+
),
313+
(
314+
OpaquePeerId(bs58::decode("12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust").into_vec().unwrap()),
315+
endowed_accounts[1].clone()
316+
),
317+
],
318+
},
307319
```
308320

309321
In this code, `NodeAuthorizationConfig` contains a `nodes` property, which is a vector with a tuple of two elements.

content/md/en/docs/tutorials/build-a-blockchain/upgrade-a-running-network.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -144,32 +144,27 @@ To update the dependencies for the runtime to include the Utility pallet:
144144

145145
For example:
146146

147-
```text
147+
```rust
148148
[dependencies]
149-
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
150-
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
149+
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
150+
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
151151

152-
pallet-aura = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "polkadot-v1.0.0" }
152+
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false }
153153
```
154154

155155
1. Add the Utility pallet as a dependency.
156156

157157
For example, add a single line with the following fields:
158158

159-
```toml
160-
pallet-utility = {
161-
version = "4.0.0-dev",
162-
default-features = false,
163-
git = "https://github.com/paritytech/polkadot-sdk.git",
164-
branch = "polkadot-v1.0.0"
165-
}
159+
```rust
160+
pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false }
166161
```
167162

168163
1. Locate the `[features]` section and the list of the default features for the standard binary.
169164

170165
For example:
171166

172-
```text
167+
```rust
173168
[features]
174169
default = ["std"]
175170
std = [
@@ -182,7 +177,7 @@ To update the dependencies for the runtime to include the Utility pallet:
182177

183178
1. Add the Utility pallet to the list.
184179

185-
```toml
180+
```rust
186181
"pallet-utility/std",
187182
```
188183

@@ -280,24 +275,32 @@ To add the Utility types and configuration trait:
280275

281276
1. Locate the `construct_runtime!` macro.
282277

283-
```text
284-
construct_runtime!(
285-
pub struct Runtime
286-
where
287-
Block = Block,
288-
NodeBlock = opaque::Block,
289-
UncheckedExtrinsic = UncheckedExtrinsic
290-
{
291-
System: frame_system,
292-
RandomnessCollectiveFlip: pallet_randomness_collective_flip,
293-
Timestamp: pallet_timestamp,
294-
Aura: pallet_aura,
278+
```rust
279+
#[frame_support::runtime]
280+
mod runtime {
281+
#[runtime::runtime]
282+
#[runtime::derive(
283+
RuntimeCall,
284+
RuntimeEvent,
285+
RuntimeError,
286+
RuntimeOrigin,
287+
RuntimeFreezeReason,
288+
RuntimeHoldReason,
289+
RuntimeSlashReason,
290+
RuntimeLockId,
291+
RuntimeTask
292+
)]
293+
pub struct Runtime;
294+
295+
#[runtime::pallet_index(0)]
296+
pub type System = frame_system;
295297
```
296298

297299
1. Add the Utility pallet inside the `construct_runtime!` macro.
298300

299301
```rust
300-
Utility: pallet_utility,
302+
#[runtime::pallet_index(x)] //*** Change Pallet Index ***//
303+
pub type Utility = pallet_utility;
301304
```
302305

303306
1. Locate the `runtime_version` macro.
@@ -319,7 +322,7 @@ To add the Utility types and configuration trait:
319322
1. Update the value for the EXISTENTIAL_DEPOSIT for the Balances pallet.
320323

321324
```rust
322-
pub const EXISTENTIAL_DEPOSIT: u128 = 1000 // Update this value.
325+
pub const EXISTENTIAL_DEPOSIT: u128 = 1000; // Update this value.
323326
```
324327

325328
This change increases the minimum balance an account is required to have on deposit to be viewed as a valid active account.

0 commit comments

Comments
 (0)