Skip to content

Commit

Permalink
add alphanet and test chainspects (#191)
Browse files Browse the repository at this point in the history
* add alpha and test chainspects

* add alphanet featurs

* add comment

* add proper sora2-common tag

* add correct alphanet cs

---------

Co-authored-by: f33r0 <[email protected]>
  • Loading branch information
N1ghtStorm and f33r0 authored Nov 28, 2023
1 parent c3cb035 commit 7c7e015
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 26 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

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

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ panic = "unwind"
# multisig-verifier = { path = "../sora2-common/pallets/multisig-verifier" }
# substrate-bridge-channel = { path = "../sora2-common/pallets/substrate-channel" }
# bridge-channel-rpc = { path = "../sora2-common/pallets/substrate-channel/rpc" }
beefy-light-client = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
beefy-light-client-rpc = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
beefy-light-client-runtime-api = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
leaf-provider = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
leaf-provider-rpc = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
leaf-provider-runtime-api = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
bridge-common = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
dispatch = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
bridge-types = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
bridge-data-signer = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
multisig-verifier = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
substrate-bridge-channel = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.18" }
beefy-light-client = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
beefy-light-client-rpc = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
beefy-light-client-runtime-api = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
leaf-provider = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
leaf-provider-rpc = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
leaf-provider-runtime-api = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
bridge-common = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
dispatch = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
bridge-types = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
bridge-data-signer = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
multisig-verifier = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }
substrate-bridge-channel = { git = "https://github.com/sora-xor//sora2-common.git", tag = "1.0.19" }

[workspace]
members = [
Expand Down
3 changes: 3 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ polkadot:
rococo:
cargo build --release --features rococo

alpha:
cargo build --release --features alphanet

test-kusama:
cargo test --release --features kusama

Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@ runtime-benchmarks = [
]
try-runtime = ["sora2-parachain-runtime/try-runtime"]
rococo = ["sora2-parachain-runtime/rococo"]
alphanet = ["sora2-parachain-runtime/alphanet"]
kusama = ["sora2-parachain-runtime/kusama"]
polkadot = ["sora2-parachain-runtime/polkadot"]
94 changes: 94 additions & 0 deletions node/res/alphanet.json

Large diffs are not rendered by default.

93 changes: 92 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub enum RelayChain {
Kusama,
Rococo,
Polkadot,
Alpha,
}

pub fn dummy_beefy_id_from_account_id(a: AccountId) -> BeefyId {
Expand All @@ -66,6 +67,7 @@ impl RelayChain {
RelayChain::Kusama => "SORA Kusama",
RelayChain::Rococo => "SORA Rococo",
RelayChain::Polkadot => "SORA Polkadot",
RelayChain::Alpha => "SORA Alpha",
}
}

Expand All @@ -74,6 +76,7 @@ impl RelayChain {
RelayChain::Kusama => "sora_kusama",
RelayChain::Rococo => "sora_rococo",
RelayChain::Polkadot => "sora_polkadot",
RelayChain::Alpha => "sora_alpha",
}
}

Expand All @@ -88,6 +91,9 @@ impl RelayChain {
RelayChain::Rococo => {
hex!("54fd1e1728cd833d21da6f3e36c50884062e35edfc24aec7a70c18a60451255a")
},
RelayChain::Alpha => {
hex!("54fd1e1728cd833d21da6f3e36c50884062e35edfc24aec7a70c18a60451255a")
},
};
AccountId::from(bytes)
}
Expand Down Expand Up @@ -116,6 +122,10 @@ impl RelayChain {
(hex!("caeedb2ddad0aca6d587dd24422ab8f6281a5b2495eb5d30265294cb29238567"), None),
(hex!("3617852ccd789ce50f10d7843542964c71e8e08ef2977c1af3435eaabaca1521"), None),
],
RelayChain::Alpha => vec![
(hex!("caeedb2ddad0aca6d587dd24422ab8f6281a5b2495eb5d30265294cb29238567"), None),
(hex!("3617852ccd789ce50f10d7843542964c71e8e08ef2977c1af3435eaabaca1521"), None),
],
};
public_keys
.into_iter()
Expand Down Expand Up @@ -153,6 +163,7 @@ impl RelayChain {
RelayChain::Kusama => "kusama",
RelayChain::Polkadot => "polkadot",
RelayChain::Rococo => "rococo",
RelayChain::Alpha => "westend_moonbase_relay_testnet",
}
}

Expand All @@ -161,6 +172,7 @@ impl RelayChain {
RelayChain::Kusama => SubNetworkId::Kusama,
RelayChain::Polkadot => SubNetworkId::Polkadot,
RelayChain::Rococo => SubNetworkId::Rococo,
RelayChain::Alpha => SubNetworkId::Rococo,
}
}
}
Expand Down Expand Up @@ -212,6 +224,10 @@ pub fn rococo_chain_spec() -> Result<ChainSpec, String> {
ChainSpec::from_json_bytes(&include_bytes!("../res/rococo.json")[..])
}

pub fn alpha_chain_spec() -> Result<ChainSpec, String> {
ChainSpec::from_json_bytes(&include_bytes!("../res/alphanet.json")[..])
}

pub fn coded_config(relay_chain: RelayChain, para_id: u32) -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
Expand Down Expand Up @@ -453,7 +469,7 @@ pub fn docker_local_testnet_config() -> ChainSpec {
)
}

/// Config for bridge private testnet
/// Config for bridge private devnet
pub fn bridge_dev_config() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
Expand Down Expand Up @@ -528,6 +544,81 @@ pub fn bridge_dev_config() -> ChainSpec {
)
}

/// Config for bridge private testnet
pub fn bridge_test_config() -> ChainSpec {
// base currency unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "XOR".into());
properties.insert("tokenDecimals".into(), 18.into());
properties.insert("ss58Format".into(), sora2_parachain_runtime::SS58Prefix::get().into());

ChainSpec::from_genesis(
// Name
"Sora Testnet",
// ID
"sora_testnet",
ChainType::Local,
move || {
testnet_genesis(
hex!("f6d0e31012ebeef4b9cc4cddd0593a8579d226dc17ce725139225e81683f0143").into(),
// initial collators.
vec![
authority_keys_from_public_keys(
// scheme: sr25519, seed: <seed>//parachain-collator-1
hex!("9232d7e4f6b7e1a881346c92f63d65e0a0ce6def5170e9766ed9d1001ed27e5d"),
// scheme: sr25519, seed: <seed>//parachain-collator-1
hex!("9232d7e4f6b7e1a881346c92f63d65e0a0ce6def5170e9766ed9d1001ed27e5d"),
// scheme: ecdsa, seed: <seed>//parachain-collator-1
hex!("035cb006bff18dcad55c58409b1cdc31be223b1340596c53f3704859fa0057469d"),
),
authority_keys_from_public_keys(
// scheme: sr25519, seed: <seed>//parachain-collator-2
hex!("54036a0a47f28c64885fd8f0300c8ff436c3007e6b5ef70d4c3f1d3ee8856f5c"),
// scheme: sr25519, seed: <seed>//parachain-collator-2
hex!("54036a0a47f28c64885fd8f0300c8ff436c3007e6b5ef70d4c3f1d3ee8856f5c"),
// scheme: ecdsa, seed: <seed>//parachain-collator-2
hex!("03c9a2529b1b857aa620a6b908de3aded3503d4549dd36ecfa79f800ae46ca0c9a"),
),
],
vec![
hex!("f6d0e31012ebeef4b9cc4cddd0593a8579d226dc17ce725139225e81683f0143").into(),
hex!("9232d7e4f6b7e1a881346c92f63d65e0a0ce6def5170e9766ed9d1001ed27e5d").into(),
hex!("54036a0a47f28c64885fd8f0300c8ff436c3007e6b5ef70d4c3f1d3ee8856f5c").into(),
hex!("7a2eaa9ba604e1c6575c0cada3e50155f98cd625566ea7239577c9565236662a").into(),
hex!("ac95d7df7e9f61b82654a0a9c93a74cca9182062a89aff6f0545f09ab9c1a152").into(),
hex!("4c6018b95a633613714b65201f9f41fb8901be88dc5fb0053fc3c10c02ddad33").into(),
hex!("306c3e7cb2075ca8cd7d3a5ec71e6f51e3fa6e8e550dce003a1c39167e0f317b").into(),
hex!("328be9c672c4fff8ae9065ebdf116a47e1121933616a1d1749ff9bb3356fd542").into(),
],
2011.into(),
SubNetworkId::Rococo,
vec![
hex!("f6d0e31012ebeef4b9cc4cddd0593a8579d226dc17ce725139225e81683f0143").into(),
hex!("9232d7e4f6b7e1a881346c92f63d65e0a0ce6def5170e9766ed9d1001ed27e5d").into(),
hex!("54036a0a47f28c64885fd8f0300c8ff436c3007e6b5ef70d4c3f1d3ee8856f5c").into(),
hex!("7a2eaa9ba604e1c6575c0cada3e50155f98cd625566ea7239577c9565236662a").into(),
],
vec![],
)
},
// Bootnodes
Vec::new(),
// Telemetry
None,
// Protocol ID
Some("sora-test"),
// Fork ID
None,
// Properties
Some(properties),
// Extensions
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: 2011,
},
)
}

fn testnet_genesis(
root_key: AccountId,
invulnerables: Vec<(AccountId, (AuraId, BeefyId))>,
Expand Down
5 changes: 5 additions & 0 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const NETWORK_NAME: &str = "Kusama";
const NETWORK_NAME: &str = "Polkadot";
#[cfg(feature = "rococo")]
const NETWORK_NAME: &str = "Rococo";
#[cfg(feature = "alphanet")]
const NETWORK_NAME: &str = "Alphanet";

fn set_default_ss58_version() {
sp_core::crypto::set_default_ss58_version(sp_core::crypto::Ss58AddressFormat::custom(
Expand All @@ -36,13 +38,16 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config()),
"bridge-dev" => Box::new(chain_spec::bridge_dev_config()),
"bridge-test" => Box::new(chain_spec::bridge_test_config()),
"kusama" => Box::new(chain_spec::kusama_chain_spec()?),
"kusama-coded" => Box::new(chain_spec::coded_config(RelayChain::Kusama, 2011)),
"polkadot" => Box::new(chain_spec::polkadot_chain_spec()?),
"polkadot-coded" => Box::new(chain_spec::coded_config(RelayChain::Polkadot, 2025)),
"rococo" => Box::new(chain_spec::rococo_chain_spec()?),
"rococo-coded" => Box::new(chain_spec::coded_config(RelayChain::Rococo, 2011)),
"template-rococo" => Box::new(chain_spec::local_testnet_config()),
"alpha" => Box::new(chain_spec::alpha_chain_spec()?),
"alpha-coded" => Box::new(chain_spec::coded_config(RelayChain::Alpha, 2011)),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
"docker-local" => Box::new(chain_spec::docker_local_testnet_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
Expand Down
1 change: 1 addition & 0 deletions parachain-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polka
[features]
default = []
rococo = ["sora2-parachain-runtime/rococo"]
alphanet = ["sora2-parachain-runtime/alphanet"]
kusama = ["sora2-parachain-runtime/kusama"]
polkadot = ["sora2-parachain-runtime/polkadot"]
Binary file modified parachain-gen/src/bytes/parachain_metadata.scale
Binary file not shown.
2 changes: 2 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,5 @@ rococo = []
kusama = []

polkadot = []

alphanet = []
12 changes: 11 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ parameter_types! {
pub const SS58Prefix: u16 = 420;
}

#[cfg(feature = "alphanet")]
parameter_types! {
pub const SS58Prefix: u16 = 420;
}

#[cfg(feature = "polkadot")]
parameter_types! {
pub const SS58Prefix: u16 = 81;
Expand Down Expand Up @@ -728,6 +733,11 @@ parameter_types! {
pub const ThisNetworkId: GenericNetworkId = GenericNetworkId::Sub(SubNetworkId::Rococo);
}

#[cfg(feature = "alphanet")]
parameter_types! {
pub const ThisNetworkId: GenericNetworkId = GenericNetworkId::Sub(SubNetworkId::Alphanet);
}

#[cfg(feature = "polkadot")]
parameter_types! {
pub const ThisNetworkId: GenericNetworkId = GenericNetworkId::Sub(SubNetworkId::Polkadot);
Expand Down Expand Up @@ -1073,7 +1083,7 @@ construct_runtime!(
ElectionsPhragmen: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>} = 115,
Utility: pallet_utility::{Pallet, Call, Event} = 116,

#[cfg(feature = "rococo")]
#[cfg(any(feature = "rococo"))]
XCMAppSudoWrapper: xcm_app_sudo_wrapper::{Pallet, Call, Storage, Event<T>} = 150,
}
);
Expand Down
Loading

0 comments on commit 7c7e015

Please sign in to comment.