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

Revamp all CI jobs #439

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ parity-scale-codec = { version = "3.6.4", default-features = false, features = [
scale-info = { version = "2.10.0", default-features = false, features = [
"derive",
] }
serde = { version = "1.0.188", default-features = false, features = ["derive"] }
serde_json = "1.0.121"
serde = { version = "1.0.188", default-features = false }
serde_json = { version = "1.0.121", default-features = false }
smallvec = "1.11"

# Local dependencies
Expand Down
2 changes: 0 additions & 2 deletions chain-spec-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ 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 = [
Expand Down
44 changes: 0 additions & 44 deletions chain-spec-generator/src/common.rs

This file was deleted.

1 change: 0 additions & 1 deletion chain-spec-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use clap::Parser;
use sc_chain_spec::ChainSpec;
use std::collections::HashMap;

mod common;
mod spec;

use spec::live;
Expand Down
158 changes: 30 additions & 128 deletions chain-spec-generator/src/spec/local.rs
Original file line number Diff line number Diff line change
@@ -1,158 +1,60 @@
use super::*;

#[cfg(not(feature = "paseo"))]
pub fn chain_spec() -> Result<Box<dyn ChainSpec>, String> {
const RELAY_CHAIN_STRING: &str = "kusama-local";

#[cfg(not(feature = "paseo"))]
const CHAIN_ID_STRING: &str = "kreivo_kusama_local";
#[cfg(not(feature = "paseo"))]
const CHAIN_NAME_STRING: &str = "Kreivo-Kusama Local";

#[cfg(not(feature = "paseo"))]
pub fn properties() -> sc_chain_spec::Properties {
// 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(),
))
properties
}

#[cfg(feature = "paseo")]
pub fn chain_spec() -> Result<Box<dyn ChainSpec>, String> {
const RELAY_CHAIN_STRING: &str = "paseo-local";

#[cfg(feature = "paseo")]
const CHAIN_ID_STRING: &str = "kreivo_paseo_local";
#[cfg(feature = "paseo")]
const CHAIN_NAME_STRING: &str = "Kreivo de Paseo-Local";

#[cfg(feature = "paseo")]
pub fn properties() -> sc_chain_spec::Properties {
// 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());

properties
}

pub fn chain_spec() -> Result<Box<dyn ChainSpec>, String> {
Ok(Box::new(
KreivoChainSpec::builder(
kreivo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "paseo-local".into(),
relay_chain: RELAY_CHAIN_STRING.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_id(CHAIN_ID_STRING)
.with_name(CHAIN_NAME_STRING)
.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"),
],
))
.with_properties(properties())
.with_genesis_config_preset_name("local")
.build(),
))
}

fn local_genesis(
id: ParaId,
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
) -> serde_json::Value {
let mut config = serde_json::json!({}).as_object().expect("map given; qed").clone();

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()
}
27 changes: 13 additions & 14 deletions chain-spec-generator/src/spec/mod.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
use crate::common::{get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION};
use cumulus_primitives_core::ParaId;

use kreivo_runtime::{constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AuraId, SessionKeys};
use sc_chain_spec::{ChainSpec, ChainType};
use sp_core::sr25519;
use sc_chain_spec::{ChainSpec, ChainSpecExtension, ChainSpecGroup, ChainType};
use serde::{Deserialize, Serialize};

#[cfg(feature = "paseo")]
const KREIVO_PARA_ID: u32 = 2281;
#[cfg(not(feature = "paseo"))]
const KREIVO_PARA_ID: u32 = 2281;

/// The extensions for the [`ChainSpec`].
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
pub struct Extensions {
/// The relay chain of the Parachain.
#[serde(alias = "relayChain", alias = "RelayChain")]
pub relay_chain: String,
/// The id of the Parachain.
#[serde(alias = "paraId", alias = "ParaId")]
pub para_id: u32,
}

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type KreivoChainSpec = sc_chain_spec::GenericChainSpec<Extensions>;

/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we
/// have just one key).
fn session_keys(aura: AuraId) -> SessionKeys {
SessionKeys { aura }
}

pub mod live;
pub mod local;
Loading
Loading