Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override keys iff they are present #275

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 48 additions & 36 deletions crates/orchestrator/src/generators/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,15 @@ fn add_authorities(
.map(|id| id.starts_with("asset-hub-polkadot"))
.unwrap_or_default();
if let Some(val) = chain_spec_json.pointer_mut(runtime_config_ptr) {
let keys: Vec<GenesisNodeKey> = nodes
.iter()
.map(|node| get_node_keys(node, session_key, asset_hub_polkadot))
.collect();
val["session"]["keys"] = json!(keys);
if let Some(session_keys) = val.pointer_mut("/session/keys") {
let keys: Vec<GenesisNodeKey> = nodes
.iter()
.map(|node| get_node_keys(node, session_key, asset_hub_polkadot))
.collect();
*session_keys = json!(keys);
} else {
warn!("⚠️ 'session/keys' key not present in runtime config.");
}
} else {
unreachable!("pointer to runtime config should be valid!")
}
Expand Down Expand Up @@ -1007,20 +1011,24 @@ fn add_aura_authorities(
_key_type: KeyType,
) {
if let Some(val) = chain_spec_json.pointer_mut(runtime_config_ptr) {
let keys: Vec<String> = nodes
.iter()
.map(|node| {
node.accounts
.accounts
.get("sr")
.expect(&format!(
"'sr' account should be set at spec computation {THIS_IS_A_BUG}"
))
.address
.clone()
})
.collect();
val["aura"]["authorities"] = json!(keys);
if let Some(aura_authorities) = val.pointer_mut("/aura/authorities") {
let keys: Vec<String> = nodes
.iter()
.map(|node| {
node.accounts
.accounts
.get("sr")
.expect(&format!(
"'sr' account should be set at spec computation {THIS_IS_A_BUG}"
))
.address
.clone()
})
.collect();
*aura_authorities = json!(keys);
} else {
warn!("⚠️ 'aura/authorities' key not present in runtime config.");
}
} else {
unreachable!("pointer to runtime config should be valid!")
}
Expand All @@ -1033,23 +1041,27 @@ fn add_grandpa_authorities(
_key_type: KeyType,
) {
if let Some(val) = chain_spec_json.pointer_mut(runtime_config_ptr) {
let keys: Vec<(String, usize)> = nodes
.iter()
.map(|node| {
(
node.accounts
.accounts
.get("ed")
.expect(&format!(
"'ed' account should be set at spec computation {THIS_IS_A_BUG}"
))
.address
.clone(),
1,
)
})
.collect();
val["grandpa"]["authorities"] = json!(keys);
if let Some(grandpa_authorities) = val.pointer_mut("/grandpa/authorities") {
let keys: Vec<(String, usize)> = nodes
.iter()
.map(|node| {
(
node.accounts
.accounts
.get("ed")
.expect(&format!(
"'ed' account should be set at spec computation {THIS_IS_A_BUG}"
))
.address
.clone(),
1,
)
})
.collect();
*grandpa_authorities = json!(keys);
} else {
warn!("⚠️ 'grandpa/authorities' key not present in runtime config.");
}
} else {
unreachable!("pointer to runtime config should be valid!")
}
Expand Down
Loading