Skip to content

Commit 0e6d86f

Browse files
committed
wip(genesis): add Frequency Westend genesis configuration and update related modules
1 parent dc363ae commit 0e6d86f

File tree

6 files changed

+187
-13
lines changed

6 files changed

+187
-13
lines changed

deny.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ allow = [
107107
"OpenSSL",
108108
"Zlib",
109109
"Unicode-3.0",
110+
"CDLA-Permissive-2.0",
110111
]
111112
# The confidence threshold for detecting a license from license text.
112113
# The higher the value, the more closely the license text must be to the

node/service/src/chain_spec/frequency_westend.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ pub fn load_frequency_westend_spec() -> ChainSpec {
3131
.with_properties(properties)
3232
.with_chain_type(ChainType::Live)
3333
.with_genesis_config_preset_name("frequency-westend")
34+
.with_telemetry_endpoints(
35+
TelemetryEndpoints::new(vec![("wss://telemetry.frequency.xyz/submit/".into(), 0)]).ok())
3436
.build()
3537
}

runtime/frequency/src/genesis/helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type AccountPublic = <Signature as Verify>::Signer;
5555
pub fn build_genesis(
5656
invulnerables: Vec<(AccountId, AuraId)>,
5757
candidacy_bond: Balance,
58+
sudo_key: Option<AccountId>,
5859
endowed_accounts: Vec<(AccountId, Balance)>,
5960
session_keys: Vec<(AccountId, AccountId, SessionKeys)>,
6061
council_members: Vec<AccountId>,

runtime/frequency/src/genesis/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
#[cfg(any(
33
feature = "frequency-no-relay",
44
feature = "frequency-local",
5-
feature = "frequency-lint-check"
5+
feature = "frequency-lint-check",
6+
feature = "frequency-westend"
67
))]
78
pub mod helpers;
89

910
pub mod presets;
11+
12+
#[cfg(feature = "frequency-westend")]
13+
pub mod westend;

runtime/frequency/src/genesis/presets.rs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::genesis::helpers::{
1111
};
1212
extern crate alloc;
1313
use alloc::vec::Vec;
14+
use crate::genesis::westend;
1415

1516
#[cfg(any(
1617
feature = "frequency-no-relay",
@@ -21,6 +22,7 @@ fn development_genesis_config() -> serde_json::Value {
2122
super::helpers::build_genesis(
2223
default_invulnerables(),
2324
crate::EXISTENTIAL_DEPOSIT * 16,
25+
Some(get_account_id_from_seed::<sp_core::sr25519::Public>("Alice")),
2426
default_endowed_accounts(),
2527
default_session_keys(),
2628
default_council_members(),
@@ -39,6 +41,7 @@ fn frequency_local_genesis_config() -> serde_json::Value {
3941
super::helpers::build_genesis(
4042
default_invulnerables(),
4143
crate::EXISTENTIAL_DEPOSIT * 16,
44+
Some(get_account_id_from_seed::<sp_core::sr25519::Public>("Alice")),
4245
default_endowed_accounts(),
4346
default_session_keys(),
4447
default_council_members(),
@@ -61,18 +64,34 @@ fn frequency_testnet_genesis_config() -> serde_json::Value {
6164
runtime.clone()
6265
}
6366

64-
#[cfg(feature = "frequency-westend")]
65-
#[allow(clippy::unwrap_used)]
66-
fn frequency_westend_genesis_config() -> serde_json::Value {
67-
let output: serde_json::Value = serde_json::from_slice(
68-
include_bytes!("../../../../resources/frequency-westend.json").as_slice(),
69-
)
70-
.map_err(|e| format!("Invalid JSON blob {:?}", e))
71-
.unwrap();
67+
// #[cfg(feature = "frequency-westend")]
68+
// #[allow(clippy::unwrap_used)]
69+
// fn frequency_westend_genesis_config() -> serde_json::Value {
70+
// let output: serde_json::Value = serde_json::from_slice(
71+
// include_bytes!("../../../../resources/frequency-westend.json").as_slice(),
72+
// )
73+
// .map_err(|e| format!("Invalid JSON blob {:?}", e))
74+
// .unwrap();
7275

73-
let runtime = &output["genesis"]["runtime"];
74-
runtime.clone()
75-
}
76+
// let runtime = &output["genesis"]["runtime"];
77+
// runtime.clone()
78+
// }
79+
80+
// #[cfg(feature = "frequency-westend")]
81+
// #[allow(clippy::unwrap_used)]
82+
// fn frequency_westend_genesis_config() -> serde_json::Value {
83+
// super::helpers::build_genesis(
84+
// invulnerables,
85+
86+
// crate::EXISTENTIAL_DEPOSIT * 16,
87+
// Some(get_account_id_from_seed::<sp_core::sr25519::Public>("")),
88+
// default_session_keys(),
89+
// default_council_members(),
90+
// default_technical_committee_members(),
91+
// super::helpers::load_genesis_schemas(),
92+
// 2000.into(),
93+
// )
94+
// }
7695

7796
#[cfg(any(feature = "frequency", feature = "runtime-benchmarks"))]
7897
#[allow(clippy::unwrap_used)]
@@ -132,7 +151,7 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<Vec<u8>> {
132151
#[cfg(feature = "frequency-testnet")]
133152
"frequency-testnet" => frequency_testnet_genesis_config(),
134153
#[cfg(feature = "frequency-westend")]
135-
"frequency-westend" => frequency_westend_genesis_config(),
154+
"frequency-westend" => westend::frequency_westend_genesis_config(),
136155
#[cfg(any(feature = "frequency", feature = "runtime-benchmarks"))]
137156
"frequency" => frequency_genesis_config(),
138157
_ => return None,
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
extern crate alloc;
2+
use alloc::{vec, vec::Vec};
3+
use hex::FromHex;
4+
use common_primitives::node::AccountId;
5+
// use frequency_runtime::{AuraId, SessionKeys};
6+
use crate::{AuraId, Balance, SessionKeys};
7+
8+
mod public_testnet_keys {
9+
pub const COLLATOR_1_SR25519: &str =
10+
"0xaca28769c5bf9c1417002b87598b2287f487aad6b4a5fa01ea332a16ee4ba24c";
11+
pub const COLLATOR_2_SR25519: &str =
12+
"0x6463476668f638099e8a0df6e66a2e8e28c99bd5379b1c4f392b5705e2f78b7b";
13+
pub const SUDO: &str = "0xccca4a5b784105460c5466cbb8d11b34f29ffcf6c725d07b65940e697763763c";
14+
pub const TECH_COUNCIL1: &str =
15+
"0x847c1ac02474b90cf1e9d8e722318b75fd56d370e6f35e9c983fe671e788d23a";
16+
pub const TECH_COUNCIL2: &str =
17+
"0x52b580c22c5ff6f586a0966fbd2373de279d1aa1b2d05dff47616b5a338fce27";
18+
pub const TECH_COUNCIL3: &str =
19+
"0x6a13f08b279cb33b249954190bcee832747b9aa9dc14cc290f82d73d496cfc0a";
20+
pub const FRQ_COUNCIL1: &str =
21+
"0xa608f3e0030c157b6e2a540c5f0c7dbd6004793813cad2c9fbda0c84c093c301";
22+
pub const FRQ_COUNCIL2: &str =
23+
"0x52d76db441043a5d47d9bf83e6fd2d5acb86b8547062571ee7b68255b6bada10";
24+
pub const FRQ_COUNCIL3: &str =
25+
"0x809d0a4e6683ebff9d74c7f6ba9fe504a64a7227d74eb45ee85556cc01013a63";
26+
pub const FRQ_COUNCIL4: &str =
27+
"0x8e47c13fd0f028f56378e202523fa44508fd64df89fddb482fc0b128989e9f0b";
28+
pub const FRQ_COUNCIL5: &str =
29+
"0xf23d555b95ca8c752b531e48848bfb4d3aa2b4eea407484ccee947501e77d04f";
30+
pub const FRQ_COUNCIL6: &str =
31+
"0xe87a126794cb727b5a7760922f81fbf0f80fd64b7e86e6ae4fee0be4289c7512";
32+
pub const FRQ_COUNCIL7: &str =
33+
"0x14a6bff08e9637457a165779765417feca01a2119dec98ec134f8ae470111318";
34+
pub const FRQ_COUNCIL8: &str =
35+
"0x140c17ced6e4fba8b62a6935052cfb7c5a8ad8ecc43dee1f4fc7c30c1ca3cb14";
36+
pub const FRQ_COUNCIL9: &str =
37+
"0xfc61655783e14b361d2b9601c657c3c5361a2cf32aa1a448fc83b1a356808a1a";
38+
}
39+
40+
const INVULNERABLES: Vec<(AccountId, AuraId)> = vec![
41+
(
42+
// 5Fy4Ng81A32LqbZ5JNKLZwW6AA8Nme3kqSUiVSJzTd7yu4a2
43+
public_testnet_keys::COLLATOR_1_SR25519.parse::<AccountId>().unwrap().into(),
44+
AuraId::from_slice(
45+
&<[u8; 32]>::from_hex(
46+
public_testnet_keys::COLLATOR_1_SR25519.strip_prefix("0x").unwrap(),
47+
)
48+
.unwrap(),
49+
)
50+
.unwrap(),
51+
),
52+
(
53+
// 5ELL8wEC9K3QFxeK6beVhwRLQScRw7A3wquhPnuJdpeCyNxX
54+
public_testnet_keys::COLLATOR_2_SR25519.parse::<AccountId>().unwrap().into(),
55+
AuraId::from_slice(
56+
&<[u8; 32]>::from_hex(
57+
public_testnet_keys::COLLATOR_2_SR25519.strip_prefix("0x").unwrap(),
58+
)
59+
.unwrap(),
60+
)
61+
.unwrap(),
62+
),
63+
];
64+
65+
const ENDOWED_ACCOUNTS: Vec<(AccountId, Balance)> = vec![
66+
// 5GhDid9V5rpReBSAK6sSEmCzeiUXTgAmAoMJQUuK5gFzPXoq
67+
public_testnet_keys::SUDO.parse::<AccountId>().unwrap().into(),
68+
// 5E46myWYmywo8cF9Wk77NZM7TqLqVG7uMYjGuyyfrve9waa9
69+
public_testnet_keys::TECH_COUNCIL1.parse::<AccountId>().unwrap().into(),
70+
// 5Dw9hdb8Wy3cMFf1ZpQh5HuK2GvMNMcxfka4JsM2GRpjqHSA
71+
public_testnet_keys::TECH_COUNCIL2.parse::<AccountId>().unwrap().into(),
72+
// 5ETnrcfDwCTKZt5pLoKcLNbbwUcddkDAxEjtcgibAtkDhBBe
73+
public_testnet_keys::TECH_COUNCIL3.parse::<AccountId>().unwrap().into(),
74+
// 5FpQTxEFHAdF2hpkA89qKenSjGQBAHi8uCo8F6fJ5RxnR1sn
75+
public_testnet_keys::FRQ_COUNCIL1.parse::<AccountId>().unwrap().into(),
76+
// 5DwKn9yg7Kqa71qTaZVfoigwtzyPgBp23wzJKmGiUr8S3j7A
77+
public_testnet_keys::FRQ_COUNCIL2.parse::<AccountId>().unwrap().into(),
78+
// 5EyLduUEpNfUox5HuogrhbKugAdHnsLHrysKSWL6u4TQFAra
79+
public_testnet_keys::FRQ_COUNCIL3.parse::<AccountId>().unwrap().into(),
80+
// 5FHFyMYQH39mq3FA2a5ZcDe275K7RZs3zi76gsQb2TE1PF7i
81+
public_testnet_keys::FRQ_COUNCIL4.parse::<AccountId>().unwrap().into(),
82+
// 5HYKfXdGi2GUupHksmQLtHoWtwH3wPkJRSr3RpbKivTovpqX
83+
public_testnet_keys::FRQ_COUNCIL5.parse::<AccountId>().unwrap().into(),
84+
// 5HKXEFkNLeutZ2yZ9mbG2v5AbTDMXhza9VEfeDCiJGGBUyi3
85+
public_testnet_keys::FRQ_COUNCIL6.parse::<AccountId>().unwrap().into(),
86+
// 5CXnMFFgruHxAFtvCogwm8TFygWg1MWd9KhMnfEPbRdCpf74
87+
public_testnet_keys::FRQ_COUNCIL7.parse::<AccountId>().unwrap().into(),
88+
// 5CWzQaAJFqYoF1bZWsvEnzMQDGokk2csTFBwfPpo1oNfBGkn
89+
public_testnet_keys::FRQ_COUNCIL8.parse::<AccountId>().unwrap().into(),
90+
// 5HmcreGLq25iA7fiyb6An4YVWC3k1Cq8SQgYn2Qpeepq24nV
91+
public_testnet_keys::FRQ_COUNCIL9.parse::<AccountId>().unwrap().into(),
92+
// Treasury $$
93+
common_runtime::constants::TREASURY_PALLET_ID.into_account_truncating(),
94+
];
95+
96+
const FREQUENCY_COUNCIL: Vec<AccountId> = vec![
97+
public_testnet_keys::FRQ_COUNCIL1.parse::<AccountId>().unwrap().into(),
98+
public_testnet_keys::FRQ_COUNCIL2.parse::<AccountId>().unwrap().into(),
99+
public_testnet_keys::FRQ_COUNCIL3.parse::<AccountId>().unwrap().into(),
100+
public_testnet_keys::FRQ_COUNCIL4.parse::<AccountId>().unwrap().into(),
101+
public_testnet_keys::FRQ_COUNCIL5.parse::<AccountId>().unwrap().into(),
102+
public_testnet_keys::FRQ_COUNCIL6.parse::<AccountId>().unwrap().into(),
103+
public_testnet_keys::FRQ_COUNCIL7.parse::<AccountId>().unwrap().into(),
104+
public_testnet_keys::FRQ_COUNCIL8.parse::<AccountId>().unwrap().into(),
105+
public_testnet_keys::FRQ_COUNCIL9.parse::<AccountId>().unwrap().into(),
106+
];
107+
108+
const TECHNICAL_COMMITTEE: Vec<AccountId> = vec![
109+
public_testnet_keys::TECH_COUNCIL1.parse::<AccountId>().unwrap().into(),
110+
public_testnet_keys::TECH_COUNCIL2.parse::<AccountId>().unwrap().into(),
111+
public_testnet_keys::TECH_COUNCIL3.parse::<AccountId>().unwrap().into(),
112+
];
113+
114+
/// Generate the session keys from individual elements.
115+
///
116+
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
117+
pub fn template_session_keys(keys: AuraId) -> frequency_runtime::SessionKeys {
118+
frequency_runtime::SessionKeys { aura: keys }
119+
}
120+
121+
fn session_keys() -> Vec<(AccountId, AccountId, SessionKeys)> {
122+
INVULNERABLES
123+
.into_iter()
124+
.map(|(acc, aura)| {
125+
(
126+
acc.clone(), // account id
127+
acc, // validator id
128+
SessionKeys { aura }, // session keys
129+
)
130+
})
131+
.collect()
132+
}
133+
134+
#[allow(clippy::unwrap_used)]
135+
pub fn frequency_westend_genesis_config() -> serde_json::Value {
136+
super::helpers::build_genesis(
137+
INVULNERABLES,
138+
crate::EXISTENTIAL_DEPOSIT * 16,
139+
Some(public_testnet_keys::SUDO.parse::<AccountId>().unwrap().into()),
140+
ENDOWED_ACCOUNTS,
141+
session_keys(),
142+
FREQUENCY_COUNCIL,
143+
TECHNICAL_COMMITTEE,
144+
super::helpers::load_genesis_schemas(),
145+
2313.into(),
146+
)
147+
}

0 commit comments

Comments
 (0)