-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change: remove `virto-xcm-emulator` * fix(node): remove unused variables * change(Cargo): update `polkadot-sdk` to `stable2409` * change(Cargo/workspace): uniform manifest structure for workspace members * change(pallet-communities): update to `stable2409` - Construct mock runtime using v2 runtime macro. - Use `AssetsFreezer` to handle assets-based vote locks. * change(pallet-communities-manager): update to `stable2409` - Upgrade `construct_runtime` to proc macro - Update configuration for `pallet-communities` * change(pallet-payments): update to `stable2409` - Update `construct_runtime` to proc macro * fix(runtime-kreivo): adjust `Contracts` parameters to meet integrity tests * change(kreivo-runtime): update to `stable2409` - Add `pallet-assets-freezer` - Update `construct_runtime` to newer proc macro - Adjust changes in pallets configurations * feat: deprecate `node` in favour of `chain-spec-generator` * change(ci): update justfile * change(Cargo): remove unused dependencies * fix(runtime-kreivo): make ci happy * change: format root Cargo.toml
- Loading branch information
Showing
47 changed files
with
3,676 additions
and
25,091 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[package] | ||
authors.workspace = true | ||
description = "Chain Spec Generator for Kreivo" | ||
edition.workspace = true | ||
homepage.workspace = true | ||
license.workspace = true | ||
name = "chain-spec-generator" | ||
repository.workspace = true | ||
version = "0.13.3" | ||
|
||
[dependencies] | ||
clap = { workspace = true, features = ["derive"] } | ||
serde_json.workspace = true | ||
serde = { workspace = true, features = ["derive"] } | ||
|
||
kreivo-runtime = { workspace = true, default-features = true } | ||
|
||
cumulus-primitives-core.workspace = true | ||
parachains-common.workspace = true | ||
sp-core.workspace = true | ||
sp-runtime.workspace = true | ||
sc-chain-spec.workspace = true | ||
sc-network.workspace = true | ||
xcm.workspace = true | ||
|
||
[features] | ||
runtime-benchmarks = [ | ||
"kreivo-runtime/runtime-benchmarks" | ||
] | ||
paseo = [ | ||
"kreivo-runtime/paseo" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use clap::Parser; | ||
use sc_chain_spec::ChainSpec; | ||
use std::collections::HashMap; | ||
|
||
mod common; | ||
mod spec; | ||
|
||
use spec::live; | ||
use spec::local; | ||
use spec::KreivoChainSpec; | ||
|
||
#[derive(Parser)] | ||
struct Cli { | ||
/// The chain spec to generate. | ||
chain: String, | ||
|
||
/// Generate the chain spec as raw? | ||
#[arg(long)] | ||
raw: bool, | ||
} | ||
|
||
fn main() -> Result<(), String> { | ||
let cli = Cli::parse(); | ||
|
||
let supported_chains = HashMap::<_, Box<dyn Fn() -> Result<Box<dyn ChainSpec>, String>>>::from([ | ||
("kreivo", Box::new(live::chain_spec) as Box<_>), | ||
("kreivo-local", Box::new(local::chain_spec) as Box<_>), | ||
]); | ||
|
||
if let Some(function) = supported_chains.get(&*cli.chain) { | ||
let chain_spec = (*function)()?.as_json(cli.raw)?; | ||
print!("{chain_spec}"); | ||
Ok(()) | ||
} else { | ||
let supported = supported_chains.keys().enumerate().fold(String::new(), |c, (n, k)| { | ||
let extra = if n + 1 < supported_chains.len() { ", " } else { "" }; | ||
format!("{c}{k}{extra}") | ||
}); | ||
if cli.chain.ends_with(".json") { | ||
let chain_spec = Box::new(KreivoChainSpec::from_json_file(cli.chain.into())?.as_json(cli.raw)?); | ||
print!("{chain_spec}"); | ||
Ok(()) | ||
} else { | ||
Err(format!("Unknown chain, only supported: {supported} or a json file")) | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use super::*; | ||
|
||
#[cfg(not(feature = "paseo"))] | ||
pub fn chain_spec() -> Result<Box<dyn ChainSpec>, String> { | ||
Ok(Box::new( | ||
KreivoChainSpec::from_json_bytes(include_bytes!("./kreivo_kusama_chainspec.json").as_slice()) | ||
.map_err(|_| "Could not find chainspec for kreivo")?, | ||
)) | ||
} | ||
|
||
#[cfg(feature = "paseo")] | ||
pub fn chain_spec() -> Result<Box<dyn ChainSpec>, String> { | ||
Ok(Box::new( | ||
KreivoChainSpec::from_json_bytes(include_bytes!("./kreivo_paseador_chainspec.json").as_slice()) | ||
.map_err(|_| "Could not find chainspec for kreivo")?, | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
use super::*; | ||
|
||
#[cfg(not(feature = "paseo"))] | ||
pub fn chain_spec() -> Result<Box<dyn ChainSpec>, String> { | ||
// Give your base currency a unit name and decimal places | ||
let mut properties = sc_chain_spec::Properties::new(); | ||
properties.insert("tokenSymbol".into(), "KSM".into()); | ||
properties.insert("tokenDecimals".into(), 12.into()); | ||
properties.insert("ss58Format".into(), 2.into()); | ||
|
||
Ok(Box::new( | ||
KreivoChainSpec::builder( | ||
kreivo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), | ||
Extensions { | ||
relay_chain: "kusama-local".into(), | ||
// You MUST set this to the correct network! | ||
para_id: KREIVO_PARA_ID, | ||
}, | ||
) | ||
.with_name("Kreivo-Kusama Local") | ||
.with_id("kreivo_kusama_local") | ||
.with_chain_type(ChainType::Local) | ||
.with_properties(properties) | ||
.with_genesis_config_patch(local_genesis( | ||
KREIVO_PARA_ID.into(), | ||
// initial collators. | ||
vec![ | ||
( | ||
get_account_id_from_seed::<sr25519::Public>("Alice"), | ||
get_collator_keys_from_seed("Alice"), | ||
), | ||
( | ||
get_account_id_from_seed::<sr25519::Public>("Bob"), | ||
get_collator_keys_from_seed("Bob"), | ||
), | ||
], | ||
vec![ | ||
get_account_id_from_seed::<sr25519::Public>("Alice"), | ||
get_account_id_from_seed::<sr25519::Public>("Bob"), | ||
get_account_id_from_seed::<sr25519::Public>("Charlie"), | ||
get_account_id_from_seed::<sr25519::Public>("Dave"), | ||
get_account_id_from_seed::<sr25519::Public>("Eve"), | ||
get_account_id_from_seed::<sr25519::Public>("Ferdie"), | ||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"), | ||
], | ||
)) | ||
.build(), | ||
)) | ||
} | ||
|
||
#[cfg(feature = "paseo")] | ||
pub fn chain_spec() -> Result<Box<dyn ChainSpec>, String> { | ||
// Give your base currency a unit name and decimal places | ||
let mut properties = sc_chain_spec::Properties::new(); | ||
properties.insert("tokenSymbol".into(), "PAS".into()); | ||
properties.insert("tokenDecimals".into(), 10.into()); | ||
properties.insert("ss58Format".into(), 1.into()); | ||
|
||
Ok(Box::new( | ||
KreivoChainSpec::builder( | ||
kreivo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), | ||
Extensions { | ||
relay_chain: "paseo-local".into(), | ||
// You MUST set this to the correct network! | ||
para_id: KREIVO_PARA_ID, | ||
}, | ||
) | ||
.with_name("Kreivo de Paseo-Local") | ||
.with_id("kreivo_paseo_local") | ||
.with_chain_type(ChainType::Local) | ||
.with_properties(properties) | ||
.with_genesis_config_patch(local_genesis( | ||
KREIVO_PARA_ID.into(), | ||
// initial collators. | ||
vec![ | ||
( | ||
get_account_id_from_seed::<sr25519::Public>("Alice"), | ||
get_collator_keys_from_seed("Alice"), | ||
), | ||
( | ||
get_account_id_from_seed::<sr25519::Public>("Bob"), | ||
get_collator_keys_from_seed("Bob"), | ||
), | ||
], | ||
vec![ | ||
get_account_id_from_seed::<sr25519::Public>("Alice"), | ||
get_account_id_from_seed::<sr25519::Public>("Bob"), | ||
get_account_id_from_seed::<sr25519::Public>("Charlie"), | ||
get_account_id_from_seed::<sr25519::Public>("Dave"), | ||
get_account_id_from_seed::<sr25519::Public>("Eve"), | ||
get_account_id_from_seed::<sr25519::Public>("Ferdie"), | ||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"), | ||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"), | ||
], | ||
get_account_id_from_seed::<sr25519::Public>("Alice"), | ||
)) | ||
.build(), | ||
)) | ||
} | ||
|
||
fn local_genesis( | ||
id: ParaId, | ||
invulnerables: Vec<(AccountId, AuraId)>, | ||
endowed_accounts: Vec<AccountId>, | ||
#[cfg(feature = "paseo")] sudo: AccountId, | ||
) -> serde_json::Value { | ||
let mut config = serde_json::json!({}).as_object().expect("map given; qed").clone(); | ||
|
||
#[cfg(feature = "paseo")] | ||
config.insert("sudo".into(), serde_json::json!({ "key": sudo })); | ||
config.insert( | ||
"balances".into(), | ||
serde_json::json!({ | ||
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>() | ||
}), | ||
); | ||
config.insert( | ||
"parachainInfo".into(), | ||
serde_json::json!({ | ||
"parachainId": id, | ||
}), | ||
); | ||
config.insert( | ||
"collatorSelection".into(), | ||
serde_json::json!({ | ||
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(), | ||
"candidacyBond": EXISTENTIAL_DEPOSIT * 16, | ||
}), | ||
); | ||
config.insert( | ||
"session".into(), | ||
serde_json::json!({ | ||
"keys": invulnerables | ||
.into_iter() | ||
.map(|(acc, aura)| { | ||
( | ||
acc.clone(), // account id | ||
acc, // validator id | ||
session_keys(aura), // session keys | ||
) | ||
}) | ||
.collect::<Vec<_>>(), | ||
}), | ||
); | ||
config.insert( | ||
"polkadotXcm".into(), | ||
serde_json::json!({ | ||
"safeXcmVersion": Some(SAFE_XCM_VERSION), | ||
}), | ||
); | ||
|
||
config.into() | ||
} |
8 changes: 3 additions & 5 deletions
8
node/src/chain_spec/kreivo/mod.rs → chain-spec-generator/src/spec/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.