Skip to content

Commit b9c4f36

Browse files
Merge pull request #1 from hayotensor/main
Testnet updates
2 parents 7a1620f + 3cbaaec commit b9c4f36

File tree

11 files changed

+1701
-1000
lines changed

11 files changed

+1701
-1000
lines changed

Cargo.lock

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

node/src/chain_spec.rs

Lines changed: 86 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId;
44
use sp_consensus_grandpa::AuthorityId as GrandpaId;
55
use sp_core::{sr25519, Pair, Public};
66
use sp_runtime::traits::{IdentifyAccount, Verify};
7+
use sp_core::crypto::Ss58Codec;
78

89
// The URL for the telemetry server.
910
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
@@ -20,6 +21,7 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu
2021

2122
type AccountPublic = <Signature as Verify>::Signer;
2223

24+
2325
/// Generate an account ID from seed.
2426
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
2527
where
@@ -33,7 +35,42 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
3335
(get_from_seed::<AuraId>(s), get_from_seed::<GrandpaId>(s))
3436
}
3537

38+
pub fn authority_keys_from_ss58(s_aura: &str, s_grandpa: &str) -> (AuraId, GrandpaId) {
39+
(
40+
aura_from_ss58_addr(s_aura),
41+
grandpa_from_ss58_addr(s_grandpa),
42+
)
43+
}
44+
45+
pub fn aura_from_ss58_addr(s: &str) -> AuraId {
46+
Ss58Codec::from_ss58check(s).unwrap()
47+
}
48+
49+
pub fn grandpa_from_ss58_addr(s: &str) -> GrandpaId {
50+
Ss58Codec::from_ss58check(s).unwrap()
51+
}
52+
53+
pub fn get_test_accounts() -> Vec<AccountId> {
54+
let test_accounts = vec![
55+
get_account_id_from_seed::<sr25519::Public>("Alice"),
56+
get_account_id_from_seed::<sr25519::Public>("Bob"),
57+
get_account_id_from_seed::<sr25519::Public>("Charlie"),
58+
get_account_id_from_seed::<sr25519::Public>("Dave"),
59+
get_account_id_from_seed::<sr25519::Public>("Eve"),
60+
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
61+
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
62+
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
63+
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
64+
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
65+
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
66+
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
67+
];
68+
test_accounts
69+
}
70+
3671
pub fn development_config() -> Result<ChainSpec, String> {
72+
let mut accounts = (0..255).map(|x| get_account_id_from_seed::<sr25519::Public>(&x.to_string())).collect::<Vec<_>>();
73+
accounts.extend(get_test_accounts());
3774
Ok(ChainSpec::builder(
3875
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
3976
None,
@@ -47,18 +84,15 @@ pub fn development_config() -> Result<ChainSpec, String> {
4784
// Sudo account
4885
get_account_id_from_seed::<sr25519::Public>("Alice"),
4986
// Pre-funded accounts
50-
vec![
51-
get_account_id_from_seed::<sr25519::Public>("Alice"),
52-
get_account_id_from_seed::<sr25519::Public>("Bob"),
53-
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
54-
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
55-
],
87+
accounts,
5688
true,
5789
))
5890
.build())
5991
}
6092

6193
pub fn local_testnet_config() -> Result<ChainSpec, String> {
94+
let mut accounts = (0..255).map(|x| get_account_id_from_seed::<sr25519::Public>(&x.to_string())).collect::<Vec<_>>();
95+
accounts.extend(get_test_accounts());
6296
Ok(ChainSpec::builder(
6397
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
6498
None,
@@ -72,20 +106,53 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
72106
// Sudo account
73107
get_account_id_from_seed::<sr25519::Public>("Alice"),
74108
// Pre-funded accounts
109+
accounts,
110+
true,
111+
))
112+
.build())
113+
}
114+
115+
pub fn gavin_config() -> Result<ChainSpec, String> {
116+
let mut accounts = (0..255).map(|x| get_account_id_from_seed::<sr25519::Public>(&x.to_string())).collect::<Vec<_>>();
117+
accounts.extend(get_test_accounts());
118+
Ok(ChainSpec::builder(
119+
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
120+
None,
121+
)
122+
.with_name("Gavin Testnet")
123+
.with_id("gavin_testnet")
124+
.with_chain_type(ChainType::Development)
125+
.with_genesis_config_patch(testnet_genesis(
126+
// Initial PoA authorities
75127
vec![
76-
get_account_id_from_seed::<sr25519::Public>("Alice"),
77-
get_account_id_from_seed::<sr25519::Public>("Bob"),
78-
get_account_id_from_seed::<sr25519::Public>("Charlie"),
79-
get_account_id_from_seed::<sr25519::Public>("Dave"),
80-
get_account_id_from_seed::<sr25519::Public>("Eve"),
81-
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
82-
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
83-
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
84-
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
85-
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
86-
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
87-
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
128+
authority_keys_from_ss58(
129+
"5F46bJk2dcCmhu7s8phKsRwZCoBpi8xwgS4xknnSviqn8wwA",
130+
"5FjbWKESKnQpJF2BjCZ8YxqCkWK2xq9kAijcpey5jYrMTb4F",
131+
),
132+
authority_keys_from_ss58(
133+
"5EX5TgeLSf55eZZrfG1GDPba6b3YXJvc4CoqzBkQoiX6KVKn",
134+
"5HLfb4bHmQJKToTAfK4SumF3AKT17752KU63ytvgxUo8a4cD",
135+
),
136+
authority_keys_from_ss58(
137+
"5CrPkhgMsYHX9NgoX3bMkSGSattgw9ukVkeF8wiv7Ewnb7vv",
138+
"5EQzoKrJJEz8ALXnDSQFi6rv8EkvNDHrW9pVTgQ5KCtTcC37",
139+
),
140+
authority_keys_from_ss58(
141+
"5DxxktpYcLXtAR6BzsosXbakUFN6cHxJEyfQPPZW1c8jiK7B",
142+
"5HdjyBj6qMEnzsutuKvybSpSFkEaXN16KgUFqJQBxaQVPMWy",
143+
),
88144
],
145+
// Sudo account
146+
// get_account_id_from_seed::<sr25519::Public>("Alice"),
147+
AccountId::from_ss58check("5F46bJk2dcCmhu7s8phKsRwZCoBpi8xwgS4xknnSviqn8wwA").unwrap(),
148+
// Pre-funded accounts
149+
// vec![
150+
// get_account_id_from_seed::<sr25519::Public>("Alice"),
151+
// get_account_id_from_seed::<sr25519::Public>("Bob"),
152+
// get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
153+
// get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
154+
// ],
155+
accounts,
89156
true,
90157
))
91158
.build())
@@ -101,7 +168,7 @@ fn testnet_genesis(
101168
serde_json::json!({
102169
"balances": {
103170
// Configure endowed accounts with initial balance of 1 << 60.
104-
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
171+
"balances": endowed_accounts.iter().cloned().map(|k| (k, 10000000000000000000000_u128)).collect::<Vec<_>>(),
105172
},
106173
"aura": {
107174
"authorities": initial_authorities.iter().map(|x| (x.0.clone())).collect::<Vec<_>>(),
@@ -113,14 +180,5 @@ fn testnet_genesis(
113180
// Assign network admin rights.
114181
"key": Some(root_key),
115182
},
116-
// "pallet_network": {
117-
// "subnet_path": "bigscience/bloom-560m".into(),
118-
// "memory_mb": 560,
119-
// "subnet_nodes": vec![],
120-
// "accounts": vec![],
121-
// "blank": {
122-
// Some(root_key.clone())
123-
// },
124-
// },
125183
})
126184
}

pallets/admin/Cargo.toml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,29 @@ repository = "https://github.com/substrate-developer-hub/substrate-node-template
1313
targets = ["x86_64-unknown-linux-gnu"]
1414

1515
[dependencies]
16-
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
16+
codec = { features = [
1717
"derive",
18-
] }
19-
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
20-
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
21-
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
22-
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
23-
log = "0.4"
24-
pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
25-
pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
18+
], workspace = true }
19+
scale-info = { features = [
20+
"derive",
21+
], workspace = true }
22+
frame-benchmarking = { optional = true, workspace = true }
23+
frame-support.workspace = true
24+
frame-system.workspace = true
25+
log.workspace = true
26+
pallet-sudo.workspace = true
27+
pallet-balances.workspace = true
2628

2729
pallet-network = { version = "4.0.0-dev", default-features = false, path = "../network" }
2830
pallet-subnet-democracy = { version = "4.0.0-dev", default-features = false, path = "../subnet-democracy" }
2931

30-
# Randomness
31-
pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
32+
pallet-insecure-randomness-collective-flip.workspace = true
33+
sp-std.workspace = true
3234

3335
[dev-dependencies]
34-
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
35-
sp-io = { version = "23.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
36-
sp-runtime = { version = "24.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
36+
sp-core = { features = ["serde"], workspace = true }
37+
sp-io = { default-features = true, workspace = true }
38+
sp-runtime = { workspace = true }
3739

3840
[features]
3941
default = ["std"]

pallets/admin/src/lib.rs

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ use frame_support::{
2828
weights::Weight,
2929
pallet_prelude::DispatchResult,
3030
ensure,
31-
dispatch::Vec
3231
};
32+
use sp_std::vec::Vec;
3333

3434
#[cfg(test)]
3535
mod mock;
@@ -115,7 +115,9 @@ pub mod pallet {
115115
#[pallet::weight(0)]
116116
pub fn set_min_subnet_nodes(origin: OriginFor<T>, value: u32) -> DispatchResult {
117117
ensure_root(origin)?;
118-
T::NetworkAdminInterface::set_min_subnet_nodes(value)
118+
// T::NetworkAdminInterface::set_min_subnet_nodes(value)
119+
// Update
120+
Ok(())
119121
}
120122

121123
#[pallet::call_index(4)]
@@ -143,112 +145,144 @@ pub mod pallet {
143145
#[pallet::weight(0)]
144146
pub fn set_max_consensus_epochs_errors(origin: OriginFor<T>, value: u32) -> DispatchResult {
145147
ensure_root(origin)?;
146-
T::NetworkAdminInterface::set_max_consensus_epochs_errors(value)
148+
// T::NetworkAdminInterface::set_max_consensus_epochs_errors(value)
149+
// Update
150+
Ok(())
147151
}
148152

149153
#[pallet::call_index(8)]
150154
#[pallet::weight(0)]
151155
pub fn set_min_required_model_consensus_submit_epochs(origin: OriginFor<T>, value: u64) -> DispatchResult {
152156
ensure_root(origin)?;
153-
T::NetworkAdminInterface::set_min_required_model_consensus_submit_epochs(value)
157+
// T::NetworkAdminInterface::set_min_required_model_consensus_submit_epochs(value)
158+
// Update
159+
Ok(())
154160
}
155161

156162
#[pallet::call_index(9)]
157163
#[pallet::weight(0)]
158164
pub fn set_min_required_peer_consensus_submit_epochs(origin: OriginFor<T>, value: u64) -> DispatchResult {
159165
ensure_root(origin)?;
160-
T::NetworkAdminInterface::set_min_required_peer_consensus_submit_epochs(value)
166+
// T::NetworkAdminInterface::set_min_required_peer_consensus_submit_epochs(value)
167+
// Update
168+
Ok(())
161169
}
162170

163171
#[pallet::call_index(10)]
164172
#[pallet::weight(0)]
165173
pub fn set_min_required_peer_consensus_inclusion_epochs(origin: OriginFor<T>, value: u64) -> DispatchResult {
166174
ensure_root(origin)?;
167-
T::NetworkAdminInterface::set_min_required_peer_consensus_inclusion_epochs(value)
175+
// T::NetworkAdminInterface::set_min_required_peer_consensus_inclusion_epochs(value)
176+
// Update
177+
Ok(())
168178
}
169179

170180
#[pallet::call_index(11)]
171181
#[pallet::weight(0)]
172182
pub fn set_min_required_peer_consensus_dishonesty_epochs(origin: OriginFor<T>, value: u64) -> DispatchResult {
173183
ensure_root(origin)?;
174-
T::NetworkAdminInterface::set_min_required_peer_consensus_dishonesty_epochs(value)
184+
// T::NetworkAdminInterface::set_min_required_peer_consensus_dishonesty_epochs(value)
185+
// Update
186+
Ok(())
175187
}
176188

177189
#[pallet::call_index(12)]
178190
#[pallet::weight(0)]
179191
pub fn set_max_outlier_delta_percent(origin: OriginFor<T>, value: u8) -> DispatchResult {
180192
ensure_root(origin)?;
181-
T::NetworkAdminInterface::set_max_outlier_delta_percent(value)
193+
// T::NetworkAdminInterface::set_max_outlier_delta_percent(value)
194+
// Update
195+
Ok(())
182196
}
183197

184198
#[pallet::call_index(13)]
185199
#[pallet::weight(0)]
186200
pub fn set_subnet_node_consensus_submit_percent_requirement(origin: OriginFor<T>, value: u128) -> DispatchResult {
187201
ensure_root(origin)?;
188-
T::NetworkAdminInterface::set_subnet_node_consensus_submit_percent_requirement(value)
202+
// T::NetworkAdminInterface::set_subnet_node_consensus_submit_percent_requirement(value)
203+
// Update
204+
Ok(())
189205
}
190206

191207
#[pallet::call_index(14)]
192208
#[pallet::weight(0)]
193209
pub fn set_consensus_blocks_interval(origin: OriginFor<T>, value: u64) -> DispatchResult {
194210
ensure_root(origin)?;
195-
T::NetworkAdminInterface::set_consensus_blocks_interval(value)
211+
// T::NetworkAdminInterface::set_consensus_blocks_interval(value)
212+
// Update
213+
Ok(())
196214
}
197215

198216
#[pallet::call_index(15)]
199217
#[pallet::weight(0)]
200218
pub fn set_peer_removal_threshold(origin: OriginFor<T>, value: u128) -> DispatchResult {
201219
ensure_root(origin)?;
202-
T::NetworkAdminInterface::set_peer_removal_threshold(value)
220+
// T::NetworkAdminInterface::set_peer_removal_threshold(value)
221+
// Update
222+
Ok(())
203223
}
204224

205225
#[pallet::call_index(16)]
206226
#[pallet::weight(0)]
207227
pub fn set_max_model_rewards_weight(origin: OriginFor<T>, value: u128) -> DispatchResult {
208228
ensure_root(origin)?;
209-
T::NetworkAdminInterface::set_max_model_rewards_weight(value)
229+
// T::NetworkAdminInterface::set_max_model_rewards_weight(value)
230+
// Update
231+
Ok(())
210232
}
211233

212234
#[pallet::call_index(17)]
213235
#[pallet::weight(0)]
214236
pub fn set_stake_reward_weight(origin: OriginFor<T>, value: u128) -> DispatchResult {
215237
ensure_root(origin)?;
216-
T::NetworkAdminInterface::set_stake_reward_weight(value)
238+
// T::NetworkAdminInterface::set_stake_reward_weight(value)
239+
// Update
240+
Ok(())
217241
}
218242

219243
#[pallet::call_index(18)]
220244
#[pallet::weight(0)]
221245
pub fn set_model_per_peer_init_cost(origin: OriginFor<T>, value: u128) -> DispatchResult {
222246
ensure_root(origin)?;
223-
T::NetworkAdminInterface::set_model_per_peer_init_cost(value)
247+
// T::NetworkAdminInterface::set_model_per_peer_init_cost(value)
248+
// Update
249+
Ok(())
224250
}
225251

226252
#[pallet::call_index(19)]
227253
#[pallet::weight(0)]
228254
pub fn set_model_consensus_unconfirmed_threshold(origin: OriginFor<T>, value: u128) -> DispatchResult {
229255
ensure_root(origin)?;
230-
T::NetworkAdminInterface::set_model_consensus_unconfirmed_threshold(value)
256+
// T::NetworkAdminInterface::set_model_consensus_unconfirmed_threshold(value)
257+
// Update
258+
Ok(())
231259
}
232260

233261
#[pallet::call_index(20)]
234262
#[pallet::weight(0)]
235263
pub fn set_remove_subnet_node_epoch_percentage(origin: OriginFor<T>, value: u128) -> DispatchResult {
236264
ensure_root(origin)?;
237-
T::NetworkAdminInterface::set_remove_subnet_node_epoch_percentage(value)
265+
// T::NetworkAdminInterface::set_remove_subnet_node_epoch_percentage(value)
266+
// Update
267+
Ok(())
238268
}
239269

240270
#[pallet::call_index(21)]
241271
#[pallet::weight(0)]
242272
pub fn set_peer_vote_premium(origin: OriginFor<T>, value: u128) -> DispatchResult {
243273
ensure_root(origin)?;
244-
T::SubnetDemocracyAdminInterface::set_peer_vote_premium(value)
274+
// T::SubnetDemocracyAdminInterface::set_peer_vote_premium(value)
275+
// Update
276+
Ok(())
245277
}
246278

247279
#[pallet::call_index(22)]
248280
#[pallet::weight(0)]
249281
pub fn set_quorum(origin: OriginFor<T>, value: u128) -> DispatchResult {
250282
ensure_root(origin)?;
251-
T::SubnetDemocracyAdminInterface::set_quorum(value)
283+
// T::SubnetDemocracyAdminInterface::set_quorum(value)
284+
// Update
285+
Ok(())
252286
}
253287
}
254288
}

0 commit comments

Comments
 (0)