Skip to content

Commit 2ce5b37

Browse files
author
Joshua Mir
committed
move to kitchen-node-based chain
1 parent 2ab15b3 commit 2ce5b37

File tree

17 files changed

+1029
-3101
lines changed

17 files changed

+1029
-3101
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[workspace]
22
members = [
3+
"datdot-node/pallets/datdot",
4+
"datdot-node/runtime",
35
"datdot-node/node",
4-
"datdot-node/runtime"
56
]
67

78
[profile.release]

datdot-node/node/Cargo.toml

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,73 @@
11
[package]
22
name = "datdot-node"
3-
version = "0.0.1"
4-
authors = ["Datdot Authors"]
5-
description = "Datdot Demo Node"
3+
version = "2.0.0-rc3"
64
edition = "2018"
7-
license = "Unlicense"
8-
build = "build.rs"
9-
homepage = "https://playproject.io"
10-
repository = "https://github.com/playproject-io/datdot-substrate"
5+
authors = ['Joshy Orndorff', '4meta5', 'Jimmy Chu']
6+
repository = 'https://github.com/substrate-developer-hub/recipes'
7+
description = 'An instant-sealing Substrate node for datdot. Based on the substrate kitchen-node.'
8+
license = "GPL-3.0-or-later"
119

12-
[package.metadata.docs.rs]
13-
targets = ["x86_64-unknown-linux-gnu"]
10+
[package.metadata.substrate]
11+
categories = [
12+
"Node",
13+
"Instant Seal",
14+
"tutorial",
15+
"recipe",
16+
]
17+
compatibility_version = "2.0.0-rc3"
1418

1519
[[bin]]
16-
name = "datdot-node"
20+
name = "kitchen-node"
21+
path = "src/main.rs"
1722

1823
[dependencies]
19-
futures = "0.3.4"
20-
log = "0.4.8"
24+
derive_more = "0.15.0"
25+
futures = "0.3.1"
2126
structopt = "0.3.8"
27+
futures01 = { package = "futures", version = "0.1.29" }
28+
ctrlc = { version = "3.1.3", features = ["termination"] }
29+
log = "0.4.8"
30+
tokio = "0.1.22"
31+
exit-future = "0.2.0"
32+
parking_lot = "0.9.0"
33+
trie-root = "0.15.2"
34+
sc-basic-authorship = '0.8.0-rc3'
35+
sc-cli = '0.8.0-rc3'
36+
sc-client-api = '2.0.0-rc3'
37+
sc-consensus = '0.8.0-rc3'
38+
sc-consensus-manual-seal = '0.8.0-rc3'
39+
sc-executor = '0.8.0-rc3'
40+
sc-network = '0.8.0-rc3'
41+
sc-service = '0.8.0-rc3'
42+
sc-transaction-pool = '2.0.0-rc3'
43+
sp-consensus = '0.8.0-rc3'
44+
sp-core = '2.0.0-rc3'
45+
sp-inherents = '2.0.0-rc3'
46+
sp-io = '2.0.0-rc3'
47+
sp-runtime = '2.0.0-rc3'
48+
sp-timestamp = '2.0.0-rc3'
49+
sp-transaction-pool = '2.0.0-rc3'
50+
51+
# This node is compatible with any of the runtimes below
52+
# ---
53+
# Common runtime configured with most Recipes pallets.
54+
runtime = { package = "datdot-runtime", path = "../runtime" }
2255

23-
sc-cli = { version = "0.8.0-rc2" }
24-
sc-rpc = { version = "2.0.0-rc2" }
25-
sp-core = { version = "2.0.0-rc2" }
26-
sc-executor = { version = "0.8.0-rc2" }
27-
sc-service = { version = "0.8.0-rc2" }
28-
sp-inherents = { version = "2.0.0-rc2" }
29-
sc-transaction-pool = { version = "2.0.0-rc2" }
30-
sp-transaction-pool = { version = "2.0.0-rc2" }
31-
sc-network = { version = "0.8.0-rc2" }
32-
sc-consensus-babe = { version = "0.8.0-rc2" }
33-
sp-consensus-babe = { version = "0.8.0-rc2" }
34-
sp-authority-discovery = { version = "2.0.0-rc2" }
35-
sp-consensus = { version = "0.8.0-rc2" }
36-
sc-consensus = { version = "0.8.0-rc2" }
37-
sc-finality-grandpa = { version = "0.8.0-rc2" }
38-
sp-finality-grandpa = { version = "2.0.0-rc2" }
39-
sc-client-api = { version = "2.0.0-rc2" }
40-
sp-runtime = { version = "2.0.0-rc2" }
41-
sc-basic-authorship = { version = "0.8.0-rc2" }
42-
sc-authority-discovery = { version = "0.8.0-rc2" }
43-
pallet-im-online = { version = "2.0.0-rc2" }
44-
45-
datdot-runtime = { version = "2.0.0-rc2", path = "../runtime" }
56+
# Runtime with custom weight and fee calculation.
57+
# runtime = { package = "weight-fee-runtime", path = "../../runtimes/weight-fee-runtime"}
58+
59+
# Runtime with off-chain worker enabled.
60+
# To use this runtime, compile the node with `ocw` feature enabled,
61+
# `cargo build --release --features ocw`.
62+
# runtime = { package = "ocw-runtime", path = "../../runtimes/ocw-runtime" }
63+
64+
# Runtime with custom runtime-api (custom API only used in rpc-node)
65+
# runtime = { package = "api-runtime", path = "../../runtimes/api-runtime" }
66+
# ---
4667

4768
[build-dependencies]
48-
substrate-build-script-utils = { version = "2.0.0-rc2" }
69+
vergen = "3.0.4"
70+
substrate-build-script-utils = '2.0.0-rc3'
71+
72+
[features]
73+
ocw = []

datdot-node/node/src/chain_spec.rs

Lines changed: 29 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,22 @@
1-
use sp_core::{Pair, Public, sr25519};
2-
use datdot_runtime::{
3-
primitives::AccountId, primitives::Signature, primitives::Balance,
4-
BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig, ElectionsConfig,
5-
SudoConfig, SystemConfig, WASM_BINARY, IndicesConfig, ImOnlineConfig,
6-
AuthorityDiscoveryConfig, CouncilConfig, TechnicalCommitteeConfig,
7-
DemocracyConfig, SessionConfig, SessionKeys,
8-
constants::currency::*
1+
use runtime::{
2+
genesis::{account_id_from_seed, dev_genesis, testnet_genesis},
3+
GenesisConfig,
94
};
10-
use sp_consensus_babe::AuthorityId as BabeId;
11-
use sp_finality_grandpa::AuthorityId as GrandpaId;
12-
use pallet_im_online::sr25519::{AuthorityId as ImOnlineId};
13-
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
14-
use sp_runtime::traits::{Verify, IdentifyAccount};
15-
use sc_service::ChainType;
5+
use sp_core::sr25519;
166

177
// Note this is the URL for the telemetry server
188
//const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
199

2010
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
2111
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
2212

23-
/// Helper function to generate a crypto pair from seed
24-
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
25-
TPublic::Pair::from_string(&format!("//{}", seed), None)
26-
.expect("static values are valid; qed")
27-
.public()
28-
}
29-
30-
type AccountPublic = <Signature as Verify>::Signer;
31-
32-
/// Helper function to generate an account ID from seed
33-
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId where
34-
AccountPublic: From<<TPublic::Pair as Pair>::Public>
35-
{
36-
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
37-
}
38-
39-
/// Helper function to generate stash, controller and session key from seed
40-
pub fn authority_keys_from_seed(seed: &str) -> (
41-
AccountId,
42-
AccountId,
43-
GrandpaId,
44-
BabeId,
45-
ImOnlineId,
46-
AuthorityDiscoveryId,
47-
) {
48-
(
49-
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
50-
get_account_id_from_seed::<sr25519::Public>(seed),
51-
get_from_seed::<GrandpaId>(seed),
52-
get_from_seed::<BabeId>(seed),
53-
get_from_seed::<ImOnlineId>(seed),
54-
get_from_seed::<AuthorityDiscoveryId>(seed),
55-
)
56-
}
57-
58-
pub fn development_config() -> ChainSpec {
13+
/// Build a Development ChainSpec
14+
pub fn dev_config() -> ChainSpec {
5915
ChainSpec::from_genesis(
6016
"Development",
6117
"dev",
62-
ChainType::Development,
63-
|| testnet_genesis(
64-
vec![
65-
authority_keys_from_seed("Alice"),
66-
],
67-
get_account_id_from_seed::<sr25519::Public>("Alice"),
68-
Some(vec![
69-
get_account_id_from_seed::<sr25519::Public>("Alice"),
70-
get_account_id_from_seed::<sr25519::Public>("Bob"),
71-
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
72-
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
73-
]),
74-
true,
75-
),
18+
sc_service::ChainType::Development,
19+
dev_genesis,
7620
vec![],
7721
None,
7822
None,
@@ -81,139 +25,35 @@ pub fn development_config() -> ChainSpec {
8125
)
8226
}
8327

28+
/// Build a Local Chainspec
8429
pub fn local_testnet_config() -> ChainSpec {
8530
ChainSpec::from_genesis(
8631
"Local Testnet",
8732
"local_testnet",
88-
ChainType::Local,
89-
|| testnet_genesis(
90-
vec![
91-
authority_keys_from_seed("Alice"),
92-
authority_keys_from_seed("Bob"),
93-
],
94-
get_account_id_from_seed::<sr25519::Public>("Alice"),
95-
Some(vec![
96-
get_account_id_from_seed::<sr25519::Public>("Alice"),
97-
get_account_id_from_seed::<sr25519::Public>("Bob"),
98-
get_account_id_from_seed::<sr25519::Public>("Charlie"),
99-
get_account_id_from_seed::<sr25519::Public>("Dave"),
100-
get_account_id_from_seed::<sr25519::Public>("Eve"),
101-
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
102-
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
103-
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
104-
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
105-
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
106-
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
107-
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
108-
]),
109-
true,
110-
),
33+
sc_service::ChainType::Local,
34+
|| {
35+
testnet_genesis(
36+
account_id_from_seed::<sr25519::Pair>("Alice"),
37+
vec![
38+
account_id_from_seed::<sr25519::Pair>("Alice"),
39+
account_id_from_seed::<sr25519::Pair>("Bob"),
40+
account_id_from_seed::<sr25519::Pair>("Charlie"),
41+
account_id_from_seed::<sr25519::Pair>("Dave"),
42+
account_id_from_seed::<sr25519::Pair>("Eve"),
43+
account_id_from_seed::<sr25519::Pair>("Ferdie"),
44+
account_id_from_seed::<sr25519::Pair>("Alice//stash"),
45+
account_id_from_seed::<sr25519::Pair>("Bob//stash"),
46+
account_id_from_seed::<sr25519::Pair>("Charlie//stash"),
47+
account_id_from_seed::<sr25519::Pair>("Dave//stash"),
48+
account_id_from_seed::<sr25519::Pair>("Eve//stash"),
49+
account_id_from_seed::<sr25519::Pair>("Ferdie//stash"),
50+
],
51+
)
52+
},
11153
vec![],
11254
None,
11355
None,
11456
None,
11557
None,
11658
)
11759
}
118-
119-
fn session_keys(
120-
grandpa: GrandpaId,
121-
babe: BabeId,
122-
im_online: ImOnlineId,
123-
authority_discovery: AuthorityDiscoveryId,
124-
) -> SessionKeys {
125-
SessionKeys { grandpa, babe, im_online, authority_discovery }
126-
}
127-
128-
fn testnet_genesis(
129-
initial_authorities: Vec<(
130-
AccountId,
131-
AccountId,
132-
GrandpaId,
133-
BabeId,
134-
ImOnlineId,
135-
AuthorityDiscoveryId,
136-
)>,
137-
root_key: AccountId,
138-
endowed_accounts: Option<Vec<AccountId>>,
139-
_enable_println: bool,
140-
) -> GenesisConfig {
141-
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
142-
vec![
143-
get_account_id_from_seed::<sr25519::Public>("Alice"),
144-
get_account_id_from_seed::<sr25519::Public>("Bob"),
145-
get_account_id_from_seed::<sr25519::Public>("Charlie"),
146-
get_account_id_from_seed::<sr25519::Public>("Dave"),
147-
get_account_id_from_seed::<sr25519::Public>("Eve"),
148-
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
149-
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
150-
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
151-
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
152-
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
153-
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
154-
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
155-
]
156-
});
157-
let num_endowed_accounts = endowed_accounts.len();
158-
159-
const ENDOWMENT: Balance = 10_000_000 * DOLLARS;
160-
const STASH: Balance = 100 * DOLLARS;
161-
162-
GenesisConfig {
163-
frame_system: Some(SystemConfig {
164-
code: WASM_BINARY.to_vec(),
165-
changes_trie_config: Default::default(),
166-
}),
167-
pallet_balances: Some(BalancesConfig {
168-
balances: endowed_accounts.iter().cloned()
169-
.map(|k| (k, ENDOWMENT))
170-
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
171-
.collect(),
172-
}),
173-
pallet_indices: Some(IndicesConfig {
174-
indices: vec![],
175-
}),
176-
pallet_session: Some(SessionConfig {
177-
keys: initial_authorities.iter().map(|x| {
178-
(x.0.clone(), x.0.clone(), session_keys(
179-
x.2.clone(),
180-
x.3.clone(),
181-
x.4.clone(),
182-
x.5.clone(),
183-
))
184-
}).collect::<Vec<_>>(),
185-
}),
186-
pallet_democracy: Some(DemocracyConfig::default()),
187-
pallet_elections_phragmen: Some(ElectionsConfig {
188-
members: endowed_accounts.iter()
189-
.take((num_endowed_accounts + 1) / 2)
190-
.cloned()
191-
.map(|member| (member, STASH))
192-
.collect(),
193-
}),
194-
pallet_collective_Instance1: Some(CouncilConfig::default()),
195-
pallet_collective_Instance2: Some(TechnicalCommitteeConfig {
196-
members: endowed_accounts.iter()
197-
.take((num_endowed_accounts + 1) / 2)
198-
.cloned()
199-
.collect(),
200-
phantom: Default::default(),
201-
}),
202-
pallet_sudo: Some(SudoConfig {
203-
key: root_key,
204-
}),
205-
pallet_babe: Some(BabeConfig {
206-
authorities: vec![],
207-
}),
208-
pallet_im_online: Some(ImOnlineConfig {
209-
keys: vec![],
210-
}),
211-
pallet_authority_discovery: Some(AuthorityDiscoveryConfig {
212-
keys: vec![],
213-
}),
214-
pallet_grandpa: Some(GrandpaConfig {
215-
authorities: vec![],
216-
}),
217-
pallet_membership_Instance1: Some(Default::default()),
218-
}
219-
}

0 commit comments

Comments
 (0)