Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit d2e033b

Browse files
committed
add chain specs, and more
1 parent f31e7cc commit d2e033b

File tree

12 files changed

+25
-59
lines changed

12 files changed

+25
-59
lines changed

ensure_node_compatible.sh

100644100755
+3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ do
2929

3030
if cargo test -p tutorial-node >/dev/null 2>&1; then
3131
echo "✅ cargo test for ${dir} completed successfully"
32+
cargo run -p tutorial-node -- build-spec --dev > tutorial/${dir}/dev.json 2>/dev/null
33+
echo "✅ written chain spec to tutorial/${dir}/dev.json"
3234
else
35+
echo "❌ cargo test for ${dir} completed with errors"
3336
cargo test -p tutorial-node >/dev/null
3437
fi
3538

staging/node/src/chain_spec.rs

-17
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,6 @@ pub fn development_config() -> Result<ChainSpec, String> {
2828
))
2929
}
3030

31-
pub fn local_testnet_config() -> Result<ChainSpec, String> {
32-
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
33-
34-
Ok(ChainSpec::from_genesis(
35-
"Local Testnet",
36-
"local_testnet",
37-
ChainType::Local,
38-
move || testnet_genesis(wasm_binary),
39-
vec![],
40-
None,
41-
None,
42-
None,
43-
Some(props()),
44-
None,
45-
))
46-
}
47-
4831
/// Configure initial storage state for FRAME modules.
4932
fn testnet_genesis(wasm_binary: &[u8]) -> RuntimeGenesisConfig {
5033
use frame::traits::Get;

staging/node/src/command.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ impl SubstrateCli for Cli {
3737
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
3838
Ok(match id {
3939
"dev" => Box::new(chain_spec::development_config()?),
40-
"" | "local" => Box::new(chain_spec::local_testnet_config()?),
4140
path =>
4241
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
4342
})

staging/runtime/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
1919
spec_name: create_runtime_str!("minimal-runtime"),
2020
impl_name: create_runtime_str!("minimal-runtime"),
2121
authoring_version: 1,
22-
spec_version: 100,
22+
spec_version: 0,
2323
impl_version: 1,
2424
apis: RUNTIME_API_VERSIONS,
2525
transaction_version: 1,
@@ -86,6 +86,7 @@ impl pallet_balances::Config for Runtime {
8686
type RuntimeHoldReason = RuntimeHoldReason;
8787
type DustRemoval = ();
8888
type AccountStore = System;
89+
type ExistentialDeposit = ();
8990
}
9091

9192
#[derive_impl(pallet_sudo::config_preludes::SolochainDefaultConfig as pallet_sudo::DefaultConfig)]

tutorial/node/src/chain_spec.rs

+4-24
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;
66
fn props() -> Properties {
77
let mut properties = Properties::new();
88
properties.insert("tokenDecimals".to_string(), 0.into());
9-
properties.insert("tokenSymbol".to_string(), "TEST".into());
9+
properties.insert("tokenSymbol".to_string(), "UNIT".into());
1010
properties
1111
}
1212

1313
pub fn development_config() -> Result<ChainSpec, String> {
1414
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
1515
Ok(ChainSpec::from_genesis(
16-
"Development",
17-
"dev",
16+
"Polkadot-SDK-Tutorial-Development",
17+
"pst-dev",
1818
ChainType::Development,
1919
move || testnet_genesis(wasm_binary),
2020
vec![],
@@ -26,30 +26,10 @@ pub fn development_config() -> Result<ChainSpec, String> {
2626
))
2727
}
2828

29-
pub fn local_testnet_config() -> Result<ChainSpec, String> {
30-
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
31-
32-
Ok(ChainSpec::from_genesis(
33-
"Local Testnet",
34-
"local_testnet",
35-
ChainType::Local,
36-
move || testnet_genesis(wasm_binary),
37-
vec![],
38-
None,
39-
None,
40-
None,
41-
Some(props()),
42-
None,
43-
))
44-
}
45-
4629
/// Configure initial storage state for FRAME modules.
4730
fn testnet_genesis(wasm_binary: &[u8]) -> RuntimeGenesisConfig {
4831
RuntimeGenesisConfig {
49-
system: SystemConfig {
50-
// Add Wasm runtime to storage.
51-
code: wasm_binary.to_vec(),
52-
},
32+
system: SystemConfig { code: wasm_binary.to_vec() },
5333
..Default::default()
5434
}
5535
}

tutorial/node/src/command.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ impl SubstrateCli for Cli {
3636

3737
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
3838
Ok(match id {
39-
"dev" => Box::new(chain_spec::development_config()?),
40-
"" | "local" => Box::new(chain_spec::local_testnet_config()?),
39+
"dev" | "" => Box::new(chain_spec::development_config()?),
4140
path =>
4241
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
4342
})

tutorial/step-3/runtime/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use pallets::currency::pallet as pallet_currency;
66

77
#[runtime_version]
88
pub const VERSION: RuntimeVersion = RuntimeVersion {
9-
spec_name: create_runtime_str!("node-template"),
10-
impl_name: create_runtime_str!("node-template"),
9+
spec_name: create_runtime_str!("tutorial-node"),
10+
impl_name: create_runtime_str!(""),
1111
authoring_version: 1,
12-
spec_version: 100,
12+
spec_version: 3,
1313
impl_version: 1,
1414
apis: RUNTIME_API_VERSIONS,
1515
transaction_version: 1,

tutorial/step-4/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Step 4
22

3-
In this step, we will only tweak the existing runtime such that it will compile to WASM as well.
3+
In this step, we will only tweak the existing runtime such that it will compile to WASM as well. We
4+
also combine it with a substrate node template.
45

56
- [Step 4](#step-4)
67
- [information Points](#information-points)

tutorial/step-4/runtime/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use pallets::currency::pallet as pallet_currency;
1212

1313
#[runtime_version]
1414
pub const VERSION: RuntimeVersion = RuntimeVersion {
15-
spec_name: create_runtime_str!("node-template"),
16-
impl_name: create_runtime_str!("node-template"),
15+
spec_name: create_runtime_str!("tutorial-node"),
16+
impl_name: create_runtime_str!(""),
1717
authoring_version: 1,
18-
spec_version: 100,
18+
spec_version: 4,
1919
impl_version: 1,
2020
apis: RUNTIME_API_VERSIONS,
2121
transaction_version: 1,

tutorial/step-5/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ In this step, we will start using `#[pallet::genesis]` features.
1313
## In the code
1414

1515
- Let's look at our `test_state()`. Not so pretty. Also, when we launched a node, it had no initial
16-
balance. Can we do better? yes.
16+
balance when we ran a node. Can we do better? yes.
1717
- start by adding `#[pallet::genesis_config]`. The fields of this struct are the pieces of
1818
information that your pallet expects to receive from someone (eg. a genesis chain specification).
1919
For our case, we expect to get a list of accounts and balances.

tutorial/step-5/runtime/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ use pallets::currency::pallet as pallet_currency;
1616

1717
#[runtime_version]
1818
pub const VERSION: RuntimeVersion = RuntimeVersion {
19-
spec_name: create_runtime_str!("node-template"),
20-
impl_name: create_runtime_str!("node-template"),
19+
spec_name: create_runtime_str!("tutorial-node"),
20+
impl_name: create_runtime_str!(""),
2121
authoring_version: 1,
22-
spec_version: 100,
22+
spec_version: 5,
2323
impl_version: 1,
2424
apis: RUNTIME_API_VERSIONS,
2525
transaction_version: 1,

tutorial/step-6/runtime/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ use pallets::{currency::pallet as pallet_currency, staking::pallet as pallet_sta
1616

1717
#[runtime_version]
1818
pub const VERSION: RuntimeVersion = RuntimeVersion {
19-
spec_name: create_runtime_str!("node-template"),
20-
impl_name: create_runtime_str!("node-template"),
19+
spec_name: create_runtime_str!("tutorial-node"),
20+
impl_name: create_runtime_str!(""),
2121
authoring_version: 1,
22-
spec_version: 100,
22+
spec_version: 6,
2323
impl_version: 1,
2424
apis: RUNTIME_API_VERSIONS,
2525
transaction_version: 1,

0 commit comments

Comments
 (0)