mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
Split chain_spec to individual chain families (#1347)
* Split chain_spec to individual chain families. * cargo fmt * Replace ifs with match * Runtime::Generic variant avoiding Option
This commit is contained in:
@@ -0,0 +1,279 @@
|
|||||||
|
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Cumulus.
|
||||||
|
|
||||||
|
// Cumulus is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Cumulus is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use crate::chain_spec::{
|
||||||
|
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
|
||||||
|
};
|
||||||
|
use cumulus_primitives_core::ParaId;
|
||||||
|
use hex_literal::hex;
|
||||||
|
use rococo_parachain_runtime::{AccountId, AuraId};
|
||||||
|
use sc_service::ChainType;
|
||||||
|
use sp_core::{crypto::UncheckedInto, sr25519};
|
||||||
|
|
||||||
|
pub type ContractsRococoChainSpec =
|
||||||
|
sc_service::GenericChainSpec<contracts_rococo_runtime::GenesisConfig, Extensions>;
|
||||||
|
|
||||||
|
/// No relay chain suffix because the id is the same over all relay chains.
|
||||||
|
const CONTRACTS_PARACHAIN_ID: u32 = 1002;
|
||||||
|
|
||||||
|
/// The existential deposit is determined by the runtime "contracts-rococo".
|
||||||
|
const CONTRACTS_ROCOCO_ED: contracts_rococo_runtime::Balance =
|
||||||
|
contracts_rococo_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||||
|
|
||||||
|
pub fn contracts_rococo_development_config() -> ContractsRococoChainSpec {
|
||||||
|
let mut properties = sc_chain_spec::Properties::new();
|
||||||
|
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||||
|
properties.insert("tokenDecimals".into(), 12.into());
|
||||||
|
|
||||||
|
ContractsRococoChainSpec::from_genesis(
|
||||||
|
// Name
|
||||||
|
"Contracts on Rococo Development",
|
||||||
|
// ID
|
||||||
|
"contracts-rococo-dev",
|
||||||
|
ChainType::Development,
|
||||||
|
move || {
|
||||||
|
contracts_rococo_genesis(
|
||||||
|
// initial collators.
|
||||||
|
vec![
|
||||||
|
(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
get_collator_keys_from_seed::<contracts_rococo_runtime::AuraId>("Alice"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
|
get_collator_keys_from_seed::<contracts_rococo_runtime::AuraId>("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"),
|
||||||
|
],
|
||||||
|
CONTRACTS_PARACHAIN_ID.into(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
Vec::new(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Extensions {
|
||||||
|
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
||||||
|
para_id: CONTRACTS_PARACHAIN_ID,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn contracts_rococo_local_config() -> ContractsRococoChainSpec {
|
||||||
|
let mut properties = sc_chain_spec::Properties::new();
|
||||||
|
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||||
|
properties.insert("tokenDecimals".into(), 12.into());
|
||||||
|
|
||||||
|
ContractsRococoChainSpec::from_genesis(
|
||||||
|
// Name
|
||||||
|
"Contracts on Rococo",
|
||||||
|
// ID
|
||||||
|
"contracts-rococo-local",
|
||||||
|
ChainType::Local,
|
||||||
|
move || {
|
||||||
|
contracts_rococo_genesis(
|
||||||
|
// initial collators.
|
||||||
|
vec![
|
||||||
|
(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
get_collator_keys_from_seed::<contracts_rococo_runtime::AuraId>("Alice"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
|
get_collator_keys_from_seed::<contracts_rococo_runtime::AuraId>("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"),
|
||||||
|
],
|
||||||
|
CONTRACTS_PARACHAIN_ID.into(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
// Bootnodes
|
||||||
|
Vec::new(),
|
||||||
|
// Telemetry
|
||||||
|
None,
|
||||||
|
// Protocol ID
|
||||||
|
None,
|
||||||
|
// Fork ID
|
||||||
|
None,
|
||||||
|
// Properties
|
||||||
|
Some(properties),
|
||||||
|
// Extensions
|
||||||
|
Extensions {
|
||||||
|
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
||||||
|
para_id: CONTRACTS_PARACHAIN_ID,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn contracts_rococo_config() -> ContractsRococoChainSpec {
|
||||||
|
// Give your base currency a unit name and decimal places
|
||||||
|
let mut properties = sc_chain_spec::Properties::new();
|
||||||
|
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||||
|
properties.insert("tokenDecimals".into(), 12.into());
|
||||||
|
|
||||||
|
ContractsRococoChainSpec::from_genesis(
|
||||||
|
// Name
|
||||||
|
"Contracts on Rococo",
|
||||||
|
// ID
|
||||||
|
"contracts-rococo",
|
||||||
|
ChainType::Live,
|
||||||
|
move || {
|
||||||
|
contracts_rococo_genesis(
|
||||||
|
vec![
|
||||||
|
// 5GKFbTTgrVS4Vz1UWWHPqMZQNFWZtqo7H2KpCDyYhEL3aS26
|
||||||
|
(
|
||||||
|
hex!["bc09354c12c054c8f6b3da208485eacec4ac648bad348895273b37bab5a0937c"]
|
||||||
|
.into(),
|
||||||
|
hex!["bc09354c12c054c8f6b3da208485eacec4ac648bad348895273b37bab5a0937c"]
|
||||||
|
.unchecked_into(),
|
||||||
|
),
|
||||||
|
// 5EPRJHm2GpABVWcwnAujcrhnrjFZyDGd5TwKFzkBoGgdRyv2
|
||||||
|
(
|
||||||
|
hex!["66be63b7bcbfb91040e5248e2d1ceb822cf219c57848c5924ffa3a1f8e67ba72"]
|
||||||
|
.into(),
|
||||||
|
hex!["66be63b7bcbfb91040e5248e2d1ceb822cf219c57848c5924ffa3a1f8e67ba72"]
|
||||||
|
.unchecked_into(),
|
||||||
|
),
|
||||||
|
// 5GH62vrJrVZxLREcHzm2PR5uTLAT5RQMJitoztCGyaP4o3uM
|
||||||
|
(
|
||||||
|
hex!["ba62886472a0a9f66b5e39f1469ce1c5b3d8cad6be39078daf16f111e89d1e44"]
|
||||||
|
.into(),
|
||||||
|
hex!["ba62886472a0a9f66b5e39f1469ce1c5b3d8cad6be39078daf16f111e89d1e44"]
|
||||||
|
.unchecked_into(),
|
||||||
|
),
|
||||||
|
// 5FHfoJDLdjRYX5KXLRqMDYBbWrwHLMtti21uK4QByUoUAbJF
|
||||||
|
(
|
||||||
|
hex!["8e97f65cda001976311df9bed39e8d0c956089093e94a75ef76fe9347a0eda7b"]
|
||||||
|
.into(),
|
||||||
|
hex!["8e97f65cda001976311df9bed39e8d0c956089093e94a75ef76fe9347a0eda7b"]
|
||||||
|
.unchecked_into(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
// Warning: The configuration for a production chain should not contain
|
||||||
|
// any endowed accounts here, otherwise it'll be minting extra native tokens
|
||||||
|
// from the relay chain on the parachain.
|
||||||
|
vec![
|
||||||
|
// NOTE: Remove endowed accounts if deployed on other relay chains.
|
||||||
|
// Endowed accounts
|
||||||
|
hex!["baa78c7154c7f82d6d377177e20bcab65d327eca0086513f9964f5a0f6bdad56"].into(),
|
||||||
|
// AccountId of an account which `ink-waterfall` uses for automated testing
|
||||||
|
hex!["0e47e2344d523c3cc5c34394b0d58b9a4200e813a038e6c5a6163cc07d70b069"].into(),
|
||||||
|
],
|
||||||
|
CONTRACTS_PARACHAIN_ID.into(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
// Bootnodes
|
||||||
|
vec![
|
||||||
|
"/dns/contracts-collator-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWKg3Rpxcr9oJ8n6khoxpGKWztCZydtUZk2cojHqnfLrpj"
|
||||||
|
.parse()
|
||||||
|
.expect("MultiaddrWithPeerId"),
|
||||||
|
"/dns/contracts-collator-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWPEXYrz8tHU3nDtPoPw4V7ou5dzMEWSTuUj7vaWiYVAVh"
|
||||||
|
.parse()
|
||||||
|
.expect("MultiaddrWithPeerId"),
|
||||||
|
"/dns/contracts-collator-2.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWEVU8AFNary4nP4qEnEcwJaRuy59Wefekzdu9pKbnVEhk"
|
||||||
|
.parse()
|
||||||
|
.expect("MultiaddrWithPeerId"),
|
||||||
|
"/dns/contracts-collator-3.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWP6pV3ZmcXzGDjv8ZMgA6nZxfAKDxSz4VNiLx6vVCQgJX"
|
||||||
|
.parse()
|
||||||
|
.expect("MultiaddrWithPeerId"),
|
||||||
|
],
|
||||||
|
// Telemetry
|
||||||
|
None,
|
||||||
|
// Protocol ID
|
||||||
|
None,
|
||||||
|
// Fork ID
|
||||||
|
None,
|
||||||
|
// Properties
|
||||||
|
Some(properties),
|
||||||
|
// Extensions
|
||||||
|
Extensions { relay_chain: "rococo".into(), para_id: CONTRACTS_PARACHAIN_ID },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn contracts_rococo_genesis(
|
||||||
|
invulnerables: Vec<(AccountId, AuraId)>,
|
||||||
|
endowed_accounts: Vec<AccountId>,
|
||||||
|
id: ParaId,
|
||||||
|
) -> contracts_rococo_runtime::GenesisConfig {
|
||||||
|
contracts_rococo_runtime::GenesisConfig {
|
||||||
|
system: contracts_rococo_runtime::SystemConfig {
|
||||||
|
code: contracts_rococo_runtime::WASM_BINARY
|
||||||
|
.expect("WASM binary was not build, please build it!")
|
||||||
|
.to_vec(),
|
||||||
|
},
|
||||||
|
balances: contracts_rococo_runtime::BalancesConfig {
|
||||||
|
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||||
|
},
|
||||||
|
parachain_info: contracts_rococo_runtime::ParachainInfoConfig { parachain_id: id },
|
||||||
|
collator_selection: contracts_rococo_runtime::CollatorSelectionConfig {
|
||||||
|
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
|
||||||
|
candidacy_bond: CONTRACTS_ROCOCO_ED * 16,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
session: contracts_rococo_runtime::SessionConfig {
|
||||||
|
keys: invulnerables
|
||||||
|
.into_iter()
|
||||||
|
.map(|(acc, aura)| {
|
||||||
|
(
|
||||||
|
acc.clone(), // account id
|
||||||
|
acc, // validator id
|
||||||
|
contracts_rococo_runtime::SessionKeys { aura }, // session keys
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
},
|
||||||
|
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
|
||||||
|
// of this.
|
||||||
|
aura: Default::default(),
|
||||||
|
aura_ext: Default::default(),
|
||||||
|
parachain_system: Default::default(),
|
||||||
|
polkadot_xcm: contracts_rococo_runtime::PolkadotXcmConfig {
|
||||||
|
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||||
|
},
|
||||||
|
sudo: contracts_rococo_runtime::SudoConfig {
|
||||||
|
key: Some(
|
||||||
|
hex!["2681a28014e7d3a5bfb32a003b3571f53c408acbc28d351d6bf58f5028c4ef14"].into(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Cumulus.
|
||||||
|
|
||||||
|
// Cumulus is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Cumulus is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use cumulus_primitives_core::ParaId;
|
||||||
|
use hex_literal::hex;
|
||||||
|
use rococo_parachain_runtime::{AccountId, AuraId, Signature};
|
||||||
|
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
|
||||||
|
use sc_service::ChainType;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
|
||||||
|
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||||
|
|
||||||
|
pub mod contracts;
|
||||||
|
pub mod seedling;
|
||||||
|
pub mod shell;
|
||||||
|
pub mod statemint;
|
||||||
|
|
||||||
|
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||||
|
pub type ChainSpec =
|
||||||
|
sc_service::GenericChainSpec<rococo_parachain_runtime::GenesisConfig, Extensions>;
|
||||||
|
|
||||||
|
/// The default XCM version to set in genesis config.
|
||||||
|
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
|
||||||
|
|
||||||
|
/// Helper function to generate a crypto pair from seed
|
||||||
|
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
||||||
|
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
||||||
|
.expect("static values are valid; qed")
|
||||||
|
.public()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The extensions for the [`ChainSpec`].
|
||||||
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct Extensions {
|
||||||
|
/// The relay chain of the Parachain.
|
||||||
|
pub relay_chain: String,
|
||||||
|
/// The id of the Parachain.
|
||||||
|
pub para_id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Extensions {
|
||||||
|
/// Try to get the extension from the given `ChainSpec`.
|
||||||
|
pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
|
||||||
|
sc_chain_spec::get_extension(chain_spec.extensions())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type AccountPublic = <Signature as Verify>::Signer;
|
||||||
|
|
||||||
|
/// Helper function to generate an account ID from seed
|
||||||
|
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
||||||
|
where
|
||||||
|
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
||||||
|
{
|
||||||
|
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_chain_spec() -> ChainSpec {
|
||||||
|
ChainSpec::from_genesis(
|
||||||
|
"Local Testnet",
|
||||||
|
"local_testnet",
|
||||||
|
ChainType::Local,
|
||||||
|
move || {
|
||||||
|
testnet_genesis(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
vec![get_from_seed::<AuraId>("Alice"), get_from_seed::<AuraId>("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"),
|
||||||
|
],
|
||||||
|
1000.into(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
Vec::new(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Extensions { relay_chain: "westend".into(), para_id: 1000 },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn staging_test_net() -> ChainSpec {
|
||||||
|
ChainSpec::from_genesis(
|
||||||
|
"Staging Testnet",
|
||||||
|
"staging_testnet",
|
||||||
|
ChainType::Live,
|
||||||
|
move || {
|
||||||
|
testnet_genesis(
|
||||||
|
hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into(),
|
||||||
|
vec![
|
||||||
|
// $secret//one
|
||||||
|
hex!["aad9fa2249f87a210a0f93400b7f90e47b810c6d65caa0ca3f5af982904c2a33"]
|
||||||
|
.unchecked_into(),
|
||||||
|
// $secret//two
|
||||||
|
hex!["d47753f0cca9dd8da00c70e82ec4fc5501a69c49a5952a643d18802837c88212"]
|
||||||
|
.unchecked_into(),
|
||||||
|
],
|
||||||
|
vec![
|
||||||
|
hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into()
|
||||||
|
],
|
||||||
|
1000.into(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
Vec::new(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Extensions { relay_chain: "westend".into(), para_id: 1000 },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn testnet_genesis(
|
||||||
|
root_key: AccountId,
|
||||||
|
initial_authorities: Vec<AuraId>,
|
||||||
|
endowed_accounts: Vec<AccountId>,
|
||||||
|
id: ParaId,
|
||||||
|
) -> rococo_parachain_runtime::GenesisConfig {
|
||||||
|
rococo_parachain_runtime::GenesisConfig {
|
||||||
|
system: rococo_parachain_runtime::SystemConfig {
|
||||||
|
code: rococo_parachain_runtime::WASM_BINARY
|
||||||
|
.expect("WASM binary was not build, please build it!")
|
||||||
|
.to_vec(),
|
||||||
|
},
|
||||||
|
balances: rococo_parachain_runtime::BalancesConfig {
|
||||||
|
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||||
|
},
|
||||||
|
sudo: rococo_parachain_runtime::SudoConfig { key: Some(root_key) },
|
||||||
|
parachain_info: rococo_parachain_runtime::ParachainInfoConfig { parachain_id: id },
|
||||||
|
aura: rococo_parachain_runtime::AuraConfig { authorities: initial_authorities },
|
||||||
|
aura_ext: Default::default(),
|
||||||
|
parachain_system: Default::default(),
|
||||||
|
polkadot_xcm: rococo_parachain_runtime::PolkadotXcmConfig {
|
||||||
|
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Helper function to generate a crypto pair from seed
|
||||||
|
pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
||||||
|
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
||||||
|
.expect("static values are valid; qed")
|
||||||
|
.public()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Generate collator keys from seed.
|
||||||
|
///
|
||||||
|
/// This function's return type must always match the session keys of the chain in tuple format.
|
||||||
|
pub fn get_collator_keys_from_seed<AuraId: Public>(seed: &str) -> <AuraId::Pair as Pair>::Public {
|
||||||
|
get_public_from_seed::<AuraId>(seed)
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Cumulus.
|
||||||
|
|
||||||
|
// Cumulus is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Cumulus is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use crate::chain_spec::{get_account_id_from_seed, Extensions};
|
||||||
|
use cumulus_primitives_core::ParaId;
|
||||||
|
use rococo_parachain_runtime::AccountId;
|
||||||
|
use sc_service::ChainType;
|
||||||
|
use sp_core::sr25519;
|
||||||
|
|
||||||
|
/// Specialized `ChainSpec` for the seedling parachain runtime.
|
||||||
|
pub type SeedlingChainSpec =
|
||||||
|
sc_service::GenericChainSpec<seedling_runtime::GenesisConfig, Extensions>;
|
||||||
|
|
||||||
|
pub fn get_seedling_chain_spec() -> SeedlingChainSpec {
|
||||||
|
SeedlingChainSpec::from_genesis(
|
||||||
|
"Seedling Local Testnet",
|
||||||
|
"seedling_local_testnet",
|
||||||
|
ChainType::Local,
|
||||||
|
move || {
|
||||||
|
seedling_testnet_genesis(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
2000.into(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
Vec::new(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Extensions { relay_chain: "westend".into(), para_id: 2000 },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn seedling_testnet_genesis(
|
||||||
|
root_key: AccountId,
|
||||||
|
parachain_id: ParaId,
|
||||||
|
) -> seedling_runtime::GenesisConfig {
|
||||||
|
seedling_runtime::GenesisConfig {
|
||||||
|
system: seedling_runtime::SystemConfig {
|
||||||
|
code: seedling_runtime::WASM_BINARY
|
||||||
|
.expect("WASM binary was not build, please build it!")
|
||||||
|
.to_vec(),
|
||||||
|
},
|
||||||
|
sudo: seedling_runtime::SudoConfig { key: Some(root_key) },
|
||||||
|
parachain_info: seedling_runtime::ParachainInfoConfig { parachain_id },
|
||||||
|
parachain_system: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Cumulus.
|
||||||
|
|
||||||
|
// Cumulus is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Cumulus is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use crate::chain_spec::Extensions;
|
||||||
|
use cumulus_primitives_core::ParaId;
|
||||||
|
use sc_service::ChainType;
|
||||||
|
|
||||||
|
/// Specialized `ChainSpec` for the shell parachain runtime.
|
||||||
|
pub type ShellChainSpec = sc_service::GenericChainSpec<shell_runtime::GenesisConfig, Extensions>;
|
||||||
|
|
||||||
|
pub fn get_shell_chain_spec() -> ShellChainSpec {
|
||||||
|
ShellChainSpec::from_genesis(
|
||||||
|
"Shell Local Testnet",
|
||||||
|
"shell_local_testnet",
|
||||||
|
ChainType::Local,
|
||||||
|
move || shell_testnet_genesis(1000.into()),
|
||||||
|
Vec::new(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Extensions { relay_chain: "westend".into(), para_id: 1000 },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn shell_testnet_genesis(parachain_id: ParaId) -> shell_runtime::GenesisConfig {
|
||||||
|
shell_runtime::GenesisConfig {
|
||||||
|
system: shell_runtime::SystemConfig {
|
||||||
|
code: shell_runtime::WASM_BINARY
|
||||||
|
.expect("WASM binary was not build, please build it!")
|
||||||
|
.to_vec(),
|
||||||
|
},
|
||||||
|
parachain_info: shell_runtime::ParachainInfoConfig { parachain_id },
|
||||||
|
parachain_system: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-479
@@ -14,219 +14,15 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use crate::chain_spec::{
|
||||||
|
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
|
||||||
|
};
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use rococo_parachain_runtime::{AccountId, AuraId, Signature};
|
|
||||||
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
|
|
||||||
use sc_service::ChainType;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
|
|
||||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
|
||||||
|
|
||||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
|
||||||
pub type ChainSpec =
|
|
||||||
sc_service::GenericChainSpec<rococo_parachain_runtime::GenesisConfig, Extensions>;
|
|
||||||
|
|
||||||
/// Specialized `ChainSpec` for the shell parachain runtime.
|
|
||||||
pub type ShellChainSpec = sc_service::GenericChainSpec<shell_runtime::GenesisConfig, Extensions>;
|
|
||||||
|
|
||||||
/// Specialized `ChainSpec` for the seedling parachain runtime.
|
|
||||||
pub type SeedlingChainSpec =
|
|
||||||
sc_service::GenericChainSpec<seedling_runtime::GenesisConfig, Extensions>;
|
|
||||||
|
|
||||||
/// The default XCM version to set in genesis config.
|
|
||||||
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
|
|
||||||
|
|
||||||
/// Helper function to generate a crypto pair from seed
|
|
||||||
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
|
||||||
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
|
||||||
.expect("static values are valid; qed")
|
|
||||||
.public()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The extensions for the [`ChainSpec`].
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
|
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub struct Extensions {
|
|
||||||
/// The relay chain of the Parachain.
|
|
||||||
pub relay_chain: String,
|
|
||||||
/// The id of the Parachain.
|
|
||||||
pub para_id: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Extensions {
|
|
||||||
/// Try to get the extension from the given `ChainSpec`.
|
|
||||||
pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
|
|
||||||
sc_chain_spec::get_extension(chain_spec.extensions())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type AccountPublic = <Signature as Verify>::Signer;
|
|
||||||
|
|
||||||
/// Helper function to generate an account ID from seed
|
|
||||||
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
|
||||||
where
|
|
||||||
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
|
||||||
{
|
|
||||||
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_chain_spec() -> ChainSpec {
|
|
||||||
ChainSpec::from_genesis(
|
|
||||||
"Local Testnet",
|
|
||||||
"local_testnet",
|
|
||||||
ChainType::Local,
|
|
||||||
move || {
|
|
||||||
testnet_genesis(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
vec![get_from_seed::<AuraId>("Alice"), get_from_seed::<AuraId>("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"),
|
|
||||||
],
|
|
||||||
1000.into(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
Vec::new(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Extensions { relay_chain: "westend".into(), para_id: 1000 },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_shell_chain_spec() -> ShellChainSpec {
|
|
||||||
ShellChainSpec::from_genesis(
|
|
||||||
"Shell Local Testnet",
|
|
||||||
"shell_local_testnet",
|
|
||||||
ChainType::Local,
|
|
||||||
move || shell_testnet_genesis(1000.into()),
|
|
||||||
Vec::new(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Extensions { relay_chain: "westend".into(), para_id: 1000 },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_seedling_chain_spec() -> SeedlingChainSpec {
|
|
||||||
SeedlingChainSpec::from_genesis(
|
|
||||||
"Seedling Local Testnet",
|
|
||||||
"seedling_local_testnet",
|
|
||||||
ChainType::Local,
|
|
||||||
move || {
|
|
||||||
seedling_testnet_genesis(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
2000.into(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
Vec::new(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Extensions { relay_chain: "westend".into(), para_id: 2000 },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn staging_test_net() -> ChainSpec {
|
|
||||||
ChainSpec::from_genesis(
|
|
||||||
"Staging Testnet",
|
|
||||||
"staging_testnet",
|
|
||||||
ChainType::Live,
|
|
||||||
move || {
|
|
||||||
testnet_genesis(
|
|
||||||
hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into(),
|
|
||||||
vec![
|
|
||||||
// $secret//one
|
|
||||||
hex!["aad9fa2249f87a210a0f93400b7f90e47b810c6d65caa0ca3f5af982904c2a33"]
|
|
||||||
.unchecked_into(),
|
|
||||||
// $secret//two
|
|
||||||
hex!["d47753f0cca9dd8da00c70e82ec4fc5501a69c49a5952a643d18802837c88212"]
|
|
||||||
.unchecked_into(),
|
|
||||||
],
|
|
||||||
vec![
|
|
||||||
hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into()
|
|
||||||
],
|
|
||||||
1000.into(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
Vec::new(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Extensions { relay_chain: "westend".into(), para_id: 1000 },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn testnet_genesis(
|
|
||||||
root_key: AccountId,
|
|
||||||
initial_authorities: Vec<AuraId>,
|
|
||||||
endowed_accounts: Vec<AccountId>,
|
|
||||||
id: ParaId,
|
|
||||||
) -> rococo_parachain_runtime::GenesisConfig {
|
|
||||||
rococo_parachain_runtime::GenesisConfig {
|
|
||||||
system: rococo_parachain_runtime::SystemConfig {
|
|
||||||
code: rococo_parachain_runtime::WASM_BINARY
|
|
||||||
.expect("WASM binary was not build, please build it!")
|
|
||||||
.to_vec(),
|
|
||||||
},
|
|
||||||
balances: rococo_parachain_runtime::BalancesConfig {
|
|
||||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
|
||||||
},
|
|
||||||
sudo: rococo_parachain_runtime::SudoConfig { key: Some(root_key) },
|
|
||||||
parachain_info: rococo_parachain_runtime::ParachainInfoConfig { parachain_id: id },
|
|
||||||
aura: rococo_parachain_runtime::AuraConfig { authorities: initial_authorities },
|
|
||||||
aura_ext: Default::default(),
|
|
||||||
parachain_system: Default::default(),
|
|
||||||
polkadot_xcm: rococo_parachain_runtime::PolkadotXcmConfig {
|
|
||||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn shell_testnet_genesis(parachain_id: ParaId) -> shell_runtime::GenesisConfig {
|
|
||||||
shell_runtime::GenesisConfig {
|
|
||||||
system: shell_runtime::SystemConfig {
|
|
||||||
code: shell_runtime::WASM_BINARY
|
|
||||||
.expect("WASM binary was not build, please build it!")
|
|
||||||
.to_vec(),
|
|
||||||
},
|
|
||||||
parachain_info: shell_runtime::ParachainInfoConfig { parachain_id },
|
|
||||||
parachain_system: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn seedling_testnet_genesis(
|
|
||||||
root_key: AccountId,
|
|
||||||
parachain_id: ParaId,
|
|
||||||
) -> seedling_runtime::GenesisConfig {
|
|
||||||
seedling_runtime::GenesisConfig {
|
|
||||||
system: seedling_runtime::SystemConfig {
|
|
||||||
code: seedling_runtime::WASM_BINARY
|
|
||||||
.expect("WASM binary was not build, please build it!")
|
|
||||||
.to_vec(),
|
|
||||||
},
|
|
||||||
sudo: seedling_runtime::SudoConfig { key: Some(root_key) },
|
|
||||||
parachain_info: seedling_runtime::ParachainInfoConfig { parachain_id },
|
|
||||||
parachain_system: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use parachains_common::{Balance as StatemintBalance, StatemintAuraId};
|
use parachains_common::{Balance as StatemintBalance, StatemintAuraId};
|
||||||
|
use rococo_parachain_runtime::{AccountId, AuraId};
|
||||||
|
use sc_service::ChainType;
|
||||||
|
use sp_core::{crypto::UncheckedInto, sr25519};
|
||||||
|
|
||||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||||
pub type StatemintChainSpec =
|
pub type StatemintChainSpec =
|
||||||
@@ -240,20 +36,6 @@ const STATEMINT_ED: StatemintBalance = statemint_runtime::constants::currency::E
|
|||||||
const STATEMINE_ED: StatemintBalance = statemine_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
const STATEMINE_ED: StatemintBalance = statemine_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||||
const WESTMINT_ED: StatemintBalance = westmint_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
const WESTMINT_ED: StatemintBalance = westmint_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||||
|
|
||||||
/// Helper function to generate a crypto pair from seed
|
|
||||||
pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
|
||||||
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
|
||||||
.expect("static values are valid; qed")
|
|
||||||
.public()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generate collator keys from seed.
|
|
||||||
///
|
|
||||||
/// This function's return type must always match the session keys of the chain in tuple format.
|
|
||||||
pub fn get_collator_keys_from_seed<AuraId: Public>(seed: &str) -> <AuraId::Pair as Pair>::Public {
|
|
||||||
get_public_from_seed::<AuraId>(seed)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generate the session keys from individual elements.
|
/// 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).
|
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
|
||||||
@@ -834,258 +616,3 @@ fn westmint_genesis(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ContractsRococoChainSpec =
|
|
||||||
sc_service::GenericChainSpec<contracts_rococo_runtime::GenesisConfig, Extensions>;
|
|
||||||
|
|
||||||
/// No relay chain suffix because the id is the same over all relay chains.
|
|
||||||
const CONTRACTS_PARACHAIN_ID: u32 = 1002;
|
|
||||||
|
|
||||||
/// The existential deposit is determined by the runtime "contracts-rococo".
|
|
||||||
const CONTRACTS_ROCOCO_ED: contracts_rococo_runtime::Balance =
|
|
||||||
contracts_rococo_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
|
||||||
|
|
||||||
pub fn contracts_rococo_development_config() -> ContractsRococoChainSpec {
|
|
||||||
let mut properties = sc_chain_spec::Properties::new();
|
|
||||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
|
||||||
properties.insert("tokenDecimals".into(), 12.into());
|
|
||||||
|
|
||||||
ContractsRococoChainSpec::from_genesis(
|
|
||||||
// Name
|
|
||||||
"Contracts on Rococo Development",
|
|
||||||
// ID
|
|
||||||
"contracts-rococo-dev",
|
|
||||||
ChainType::Development,
|
|
||||||
move || {
|
|
||||||
contracts_rococo_genesis(
|
|
||||||
// initial collators.
|
|
||||||
vec![
|
|
||||||
(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
get_collator_keys_from_seed::<contracts_rococo_runtime::AuraId>("Alice"),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
get_collator_keys_from_seed::<contracts_rococo_runtime::AuraId>("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"),
|
|
||||||
],
|
|
||||||
CONTRACTS_PARACHAIN_ID.into(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
Vec::new(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Extensions {
|
|
||||||
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
|
||||||
para_id: CONTRACTS_PARACHAIN_ID,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn contracts_rococo_local_config() -> ContractsRococoChainSpec {
|
|
||||||
let mut properties = sc_chain_spec::Properties::new();
|
|
||||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
|
||||||
properties.insert("tokenDecimals".into(), 12.into());
|
|
||||||
|
|
||||||
ContractsRococoChainSpec::from_genesis(
|
|
||||||
// Name
|
|
||||||
"Contracts on Rococo",
|
|
||||||
// ID
|
|
||||||
"contracts-rococo-local",
|
|
||||||
ChainType::Local,
|
|
||||||
move || {
|
|
||||||
contracts_rococo_genesis(
|
|
||||||
// initial collators.
|
|
||||||
vec![
|
|
||||||
(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
get_collator_keys_from_seed::<contracts_rococo_runtime::AuraId>("Alice"),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
get_collator_keys_from_seed::<contracts_rococo_runtime::AuraId>("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"),
|
|
||||||
],
|
|
||||||
CONTRACTS_PARACHAIN_ID.into(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
// Bootnodes
|
|
||||||
Vec::new(),
|
|
||||||
// Telemetry
|
|
||||||
None,
|
|
||||||
// Protocol ID
|
|
||||||
None,
|
|
||||||
// Fork ID
|
|
||||||
None,
|
|
||||||
// Properties
|
|
||||||
Some(properties),
|
|
||||||
// Extensions
|
|
||||||
Extensions {
|
|
||||||
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
|
||||||
para_id: CONTRACTS_PARACHAIN_ID,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn contracts_rococo_config() -> ContractsRococoChainSpec {
|
|
||||||
// Give your base currency a unit name and decimal places
|
|
||||||
let mut properties = sc_chain_spec::Properties::new();
|
|
||||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
|
||||||
properties.insert("tokenDecimals".into(), 12.into());
|
|
||||||
|
|
||||||
ContractsRococoChainSpec::from_genesis(
|
|
||||||
// Name
|
|
||||||
"Contracts on Rococo",
|
|
||||||
// ID
|
|
||||||
"contracts-rococo",
|
|
||||||
ChainType::Live,
|
|
||||||
move || {
|
|
||||||
contracts_rococo_genesis(
|
|
||||||
vec![
|
|
||||||
// 5GKFbTTgrVS4Vz1UWWHPqMZQNFWZtqo7H2KpCDyYhEL3aS26
|
|
||||||
(
|
|
||||||
hex!["bc09354c12c054c8f6b3da208485eacec4ac648bad348895273b37bab5a0937c"]
|
|
||||||
.into(),
|
|
||||||
hex!["bc09354c12c054c8f6b3da208485eacec4ac648bad348895273b37bab5a0937c"]
|
|
||||||
.unchecked_into(),
|
|
||||||
),
|
|
||||||
// 5EPRJHm2GpABVWcwnAujcrhnrjFZyDGd5TwKFzkBoGgdRyv2
|
|
||||||
(
|
|
||||||
hex!["66be63b7bcbfb91040e5248e2d1ceb822cf219c57848c5924ffa3a1f8e67ba72"]
|
|
||||||
.into(),
|
|
||||||
hex!["66be63b7bcbfb91040e5248e2d1ceb822cf219c57848c5924ffa3a1f8e67ba72"]
|
|
||||||
.unchecked_into(),
|
|
||||||
),
|
|
||||||
// 5GH62vrJrVZxLREcHzm2PR5uTLAT5RQMJitoztCGyaP4o3uM
|
|
||||||
(
|
|
||||||
hex!["ba62886472a0a9f66b5e39f1469ce1c5b3d8cad6be39078daf16f111e89d1e44"]
|
|
||||||
.into(),
|
|
||||||
hex!["ba62886472a0a9f66b5e39f1469ce1c5b3d8cad6be39078daf16f111e89d1e44"]
|
|
||||||
.unchecked_into(),
|
|
||||||
),
|
|
||||||
// 5FHfoJDLdjRYX5KXLRqMDYBbWrwHLMtti21uK4QByUoUAbJF
|
|
||||||
(
|
|
||||||
hex!["8e97f65cda001976311df9bed39e8d0c956089093e94a75ef76fe9347a0eda7b"]
|
|
||||||
.into(),
|
|
||||||
hex!["8e97f65cda001976311df9bed39e8d0c956089093e94a75ef76fe9347a0eda7b"]
|
|
||||||
.unchecked_into(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
// Warning: The configuration for a production chain should not contain
|
|
||||||
// any endowed accounts here, otherwise it'll be minting extra native tokens
|
|
||||||
// from the relay chain on the parachain.
|
|
||||||
vec![
|
|
||||||
// NOTE: Remove endowed accounts if deployed on other relay chains.
|
|
||||||
// Endowed accounts
|
|
||||||
hex!["baa78c7154c7f82d6d377177e20bcab65d327eca0086513f9964f5a0f6bdad56"].into(),
|
|
||||||
// AccountId of an account which `ink-waterfall` uses for automated testing
|
|
||||||
hex!["0e47e2344d523c3cc5c34394b0d58b9a4200e813a038e6c5a6163cc07d70b069"].into(),
|
|
||||||
],
|
|
||||||
CONTRACTS_PARACHAIN_ID.into(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
// Bootnodes
|
|
||||||
vec![
|
|
||||||
"/dns/contracts-collator-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWKg3Rpxcr9oJ8n6khoxpGKWztCZydtUZk2cojHqnfLrpj"
|
|
||||||
.parse()
|
|
||||||
.expect("MultiaddrWithPeerId"),
|
|
||||||
"/dns/contracts-collator-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWPEXYrz8tHU3nDtPoPw4V7ou5dzMEWSTuUj7vaWiYVAVh"
|
|
||||||
.parse()
|
|
||||||
.expect("MultiaddrWithPeerId"),
|
|
||||||
"/dns/contracts-collator-2.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWEVU8AFNary4nP4qEnEcwJaRuy59Wefekzdu9pKbnVEhk"
|
|
||||||
.parse()
|
|
||||||
.expect("MultiaddrWithPeerId"),
|
|
||||||
"/dns/contracts-collator-3.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWP6pV3ZmcXzGDjv8ZMgA6nZxfAKDxSz4VNiLx6vVCQgJX"
|
|
||||||
.parse()
|
|
||||||
.expect("MultiaddrWithPeerId"),
|
|
||||||
],
|
|
||||||
// Telemetry
|
|
||||||
None,
|
|
||||||
// Protocol ID
|
|
||||||
None,
|
|
||||||
// Fork ID
|
|
||||||
None,
|
|
||||||
// Properties
|
|
||||||
Some(properties),
|
|
||||||
// Extensions
|
|
||||||
Extensions { relay_chain: "rococo".into(), para_id: CONTRACTS_PARACHAIN_ID },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn contracts_rococo_genesis(
|
|
||||||
invulnerables: Vec<(AccountId, AuraId)>,
|
|
||||||
endowed_accounts: Vec<AccountId>,
|
|
||||||
id: ParaId,
|
|
||||||
) -> contracts_rococo_runtime::GenesisConfig {
|
|
||||||
contracts_rococo_runtime::GenesisConfig {
|
|
||||||
system: contracts_rococo_runtime::SystemConfig {
|
|
||||||
code: contracts_rococo_runtime::WASM_BINARY
|
|
||||||
.expect("WASM binary was not build, please build it!")
|
|
||||||
.to_vec(),
|
|
||||||
},
|
|
||||||
balances: contracts_rococo_runtime::BalancesConfig {
|
|
||||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
|
||||||
},
|
|
||||||
parachain_info: contracts_rococo_runtime::ParachainInfoConfig { parachain_id: id },
|
|
||||||
collator_selection: contracts_rococo_runtime::CollatorSelectionConfig {
|
|
||||||
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
|
|
||||||
candidacy_bond: CONTRACTS_ROCOCO_ED * 16,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
session: contracts_rococo_runtime::SessionConfig {
|
|
||||||
keys: invulnerables
|
|
||||||
.into_iter()
|
|
||||||
.map(|(acc, aura)| {
|
|
||||||
(
|
|
||||||
acc.clone(), // account id
|
|
||||||
acc, // validator id
|
|
||||||
contracts_rococo_runtime::SessionKeys { aura }, // session keys
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
},
|
|
||||||
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
|
|
||||||
// of this.
|
|
||||||
aura: Default::default(),
|
|
||||||
aura_ext: Default::default(),
|
|
||||||
parachain_system: Default::default(),
|
|
||||||
polkadot_xcm: contracts_rococo_runtime::PolkadotXcmConfig {
|
|
||||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
|
||||||
},
|
|
||||||
sudo: contracts_rococo_runtime::SudoConfig {
|
|
||||||
key: Some(
|
|
||||||
hex!["2681a28014e7d3a5bfb32a003b3571f53c408acbc28d351d6bf58f5028c4ef14"].into(),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+232
-247
@@ -40,54 +40,51 @@ use sp_core::hexdisplay::HexDisplay;
|
|||||||
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
|
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
|
||||||
use std::{io::Write, net::SocketAddr};
|
use std::{io::Write, net::SocketAddr};
|
||||||
|
|
||||||
trait IdentifyChain {
|
enum Runtime {
|
||||||
fn is_shell(&self) -> bool;
|
/// This is the default runtime (based on rococo)
|
||||||
fn is_seedling(&self) -> bool;
|
Generic,
|
||||||
fn is_statemint(&self) -> bool;
|
Shell,
|
||||||
fn is_statemine(&self) -> bool;
|
Seedling,
|
||||||
fn is_westmint(&self) -> bool;
|
Statemint,
|
||||||
fn is_contracts_rococo(&self) -> bool;
|
Statemine,
|
||||||
|
Westmint,
|
||||||
|
ContractsRococo,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IdentifyChain for dyn sc_service::ChainSpec {
|
trait ChainType {
|
||||||
fn is_shell(&self) -> bool {
|
fn runtime(&self) -> Runtime;
|
||||||
self.id().starts_with("shell")
|
}
|
||||||
}
|
|
||||||
fn is_seedling(&self) -> bool {
|
impl ChainType for dyn ChainSpec {
|
||||||
self.id().starts_with("seedling")
|
fn runtime(&self) -> Runtime {
|
||||||
}
|
runtime(self.id())
|
||||||
fn is_statemint(&self) -> bool {
|
|
||||||
self.id().starts_with("statemint")
|
|
||||||
}
|
|
||||||
fn is_statemine(&self) -> bool {
|
|
||||||
self.id().starts_with("statemine")
|
|
||||||
}
|
|
||||||
fn is_westmint(&self) -> bool {
|
|
||||||
self.id().starts_with("westmint")
|
|
||||||
}
|
|
||||||
fn is_contracts_rococo(&self) -> bool {
|
|
||||||
self.id().starts_with("contracts-rococo")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: sc_service::ChainSpec + 'static> IdentifyChain for T {
|
use sc_chain_spec::GenericChainSpec;
|
||||||
fn is_shell(&self) -> bool {
|
impl ChainType
|
||||||
<dyn sc_service::ChainSpec>::is_shell(self)
|
for GenericChainSpec<rococo_parachain_runtime::GenesisConfig, chain_spec::Extensions>
|
||||||
|
{
|
||||||
|
fn runtime(&self) -> Runtime {
|
||||||
|
runtime(self.id())
|
||||||
}
|
}
|
||||||
fn is_seedling(&self) -> bool {
|
}
|
||||||
<dyn sc_service::ChainSpec>::is_seedling(self)
|
|
||||||
}
|
fn runtime(id: &str) -> Runtime {
|
||||||
fn is_statemint(&self) -> bool {
|
if id.starts_with("shell") {
|
||||||
<dyn sc_service::ChainSpec>::is_statemint(self)
|
Runtime::Shell
|
||||||
}
|
} else if id.starts_with("seedling") {
|
||||||
fn is_statemine(&self) -> bool {
|
Runtime::Seedling
|
||||||
<dyn sc_service::ChainSpec>::is_statemine(self)
|
} else if id.starts_with("statemint") {
|
||||||
}
|
Runtime::Statemint
|
||||||
fn is_westmint(&self) -> bool {
|
} else if id.starts_with("statemine") {
|
||||||
<dyn sc_service::ChainSpec>::is_westmint(self)
|
Runtime::Statemine
|
||||||
}
|
} else if id.starts_with("westmint") {
|
||||||
fn is_contracts_rococo(&self) -> bool {
|
Runtime::Westmint
|
||||||
<dyn sc_service::ChainSpec>::is_contracts_rococo(self)
|
} else if id.starts_with("contracts-rococo") {
|
||||||
|
Runtime::ContractsRococo
|
||||||
|
} else {
|
||||||
|
Runtime::Generic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,39 +100,41 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
|
|||||||
"track" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"track" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/track.json")[..],
|
&include_bytes!("../../parachains/chain-specs/track.json")[..],
|
||||||
)?),
|
)?),
|
||||||
"shell" => Box::new(chain_spec::get_shell_chain_spec()),
|
"shell" => Box::new(chain_spec::shell::get_shell_chain_spec()),
|
||||||
// -- Statemint
|
// -- Statemint
|
||||||
"seedling" => Box::new(chain_spec::get_seedling_chain_spec()),
|
"seedling" => Box::new(chain_spec::seedling::get_seedling_chain_spec()),
|
||||||
"statemint-dev" => Box::new(chain_spec::statemint_development_config()),
|
"statemint-dev" => Box::new(chain_spec::statemint::statemint_development_config()),
|
||||||
"statemint-local" => Box::new(chain_spec::statemint_local_config()),
|
"statemint-local" => Box::new(chain_spec::statemint::statemint_local_config()),
|
||||||
// the chain spec as used for generating the upgrade genesis values
|
// the chain spec as used for generating the upgrade genesis values
|
||||||
"statemint-genesis" => Box::new(chain_spec::statemint_config()),
|
"statemint-genesis" => Box::new(chain_spec::statemint::statemint_config()),
|
||||||
// the shell-based chain spec as used for syncing
|
// the shell-based chain spec as used for syncing
|
||||||
"statemint" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"statemint" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/statemint.json")[..],
|
&include_bytes!("../../parachains/chain-specs/statemint.json")[..],
|
||||||
)?),
|
)?),
|
||||||
// -- Statemine
|
// -- Statemine
|
||||||
"statemine-dev" => Box::new(chain_spec::statemine_development_config()),
|
"statemine-dev" => Box::new(chain_spec::statemint::statemine_development_config()),
|
||||||
"statemine-local" => Box::new(chain_spec::statemine_local_config()),
|
"statemine-local" => Box::new(chain_spec::statemint::statemine_local_config()),
|
||||||
// the chain spec as used for generating the upgrade genesis values
|
// the chain spec as used for generating the upgrade genesis values
|
||||||
"statemine-genesis" => Box::new(chain_spec::statemine_config()),
|
"statemine-genesis" => Box::new(chain_spec::statemint::statemine_config()),
|
||||||
// the shell-based chain spec as used for syncing
|
// the shell-based chain spec as used for syncing
|
||||||
"statemine" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"statemine" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/statemine.json")[..],
|
&include_bytes!("../../parachains/chain-specs/statemine.json")[..],
|
||||||
)?),
|
)?),
|
||||||
// -- Westmint
|
// -- Westmint
|
||||||
"westmint-dev" => Box::new(chain_spec::westmint_development_config()),
|
"westmint-dev" => Box::new(chain_spec::statemint::westmint_development_config()),
|
||||||
"westmint-local" => Box::new(chain_spec::westmint_local_config()),
|
"westmint-local" => Box::new(chain_spec::statemint::westmint_local_config()),
|
||||||
// the chain spec as used for generating the upgrade genesis values
|
// the chain spec as used for generating the upgrade genesis values
|
||||||
"westmint-genesis" => Box::new(chain_spec::westmint_config()),
|
"westmint-genesis" => Box::new(chain_spec::statemint::westmint_config()),
|
||||||
// the shell-based chain spec as used for syncing
|
// the shell-based chain spec as used for syncing
|
||||||
"westmint" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"westmint" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/westmint.json")[..],
|
&include_bytes!("../../parachains/chain-specs/westmint.json")[..],
|
||||||
)?),
|
)?),
|
||||||
// -- Contracts on Rococo
|
// -- Contracts on Rococo
|
||||||
"contracts-rococo-dev" => Box::new(chain_spec::contracts_rococo_development_config()),
|
"contracts-rococo-dev" =>
|
||||||
"contracts-rococo-local" => Box::new(chain_spec::contracts_rococo_local_config()),
|
Box::new(chain_spec::contracts::contracts_rococo_development_config()),
|
||||||
"contracts-rococo-genesis" => Box::new(chain_spec::contracts_rococo_config()),
|
"contracts-rococo-local" =>
|
||||||
|
Box::new(chain_spec::contracts::contracts_rococo_local_config()),
|
||||||
|
"contracts-rococo-genesis" => Box::new(chain_spec::contracts::contracts_rococo_config()),
|
||||||
"contracts-rococo" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"contracts-rococo" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/contracts-rococo.json")[..],
|
&include_bytes!("../../parachains/chain-specs/contracts-rococo.json")[..],
|
||||||
)?),
|
)?),
|
||||||
@@ -144,20 +143,23 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
|
|||||||
// -- Loading a specific spec from disk
|
// -- Loading a specific spec from disk
|
||||||
path => {
|
path => {
|
||||||
let chain_spec = chain_spec::ChainSpec::from_json_file(path.into())?;
|
let chain_spec = chain_spec::ChainSpec::from_json_file(path.into())?;
|
||||||
if chain_spec.is_statemint() {
|
match chain_spec.runtime() {
|
||||||
Box::new(chain_spec::StatemintChainSpec::from_json_file(path.into())?)
|
Runtime::Statemint => Box::new(
|
||||||
} else if chain_spec.is_statemine() {
|
chain_spec::statemint::StatemintChainSpec::from_json_file(path.into())?,
|
||||||
Box::new(chain_spec::StatemineChainSpec::from_json_file(path.into())?)
|
),
|
||||||
} else if chain_spec.is_westmint() {
|
Runtime::Statemine => Box::new(
|
||||||
Box::new(chain_spec::WestmintChainSpec::from_json_file(path.into())?)
|
chain_spec::statemint::StatemineChainSpec::from_json_file(path.into())?,
|
||||||
} else if chain_spec.is_shell() {
|
),
|
||||||
Box::new(chain_spec::ShellChainSpec::from_json_file(path.into())?)
|
Runtime::Westmint =>
|
||||||
} else if chain_spec.is_seedling() {
|
Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path.into())?),
|
||||||
Box::new(chain_spec::SeedlingChainSpec::from_json_file(path.into())?)
|
Runtime::Shell =>
|
||||||
} else if chain_spec.is_contracts_rococo() {
|
Box::new(chain_spec::shell::ShellChainSpec::from_json_file(path.into())?),
|
||||||
Box::new(chain_spec::ContractsRococoChainSpec::from_json_file(path.into())?)
|
Runtime::Seedling =>
|
||||||
} else {
|
Box::new(chain_spec::seedling::SeedlingChainSpec::from_json_file(path.into())?),
|
||||||
Box::new(chain_spec)
|
Runtime::ContractsRococo => Box::new(
|
||||||
|
chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path.into())?,
|
||||||
|
),
|
||||||
|
Runtime::Generic => Box::new(chain_spec),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -199,20 +201,14 @@ impl SubstrateCli for Cli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||||
if chain_spec.is_statemint() {
|
match chain_spec.runtime() {
|
||||||
&statemint_runtime::VERSION
|
Runtime::Statemint => &statemint_runtime::VERSION,
|
||||||
} else if chain_spec.is_statemine() {
|
Runtime::Statemine => &statemine_runtime::VERSION,
|
||||||
&statemine_runtime::VERSION
|
Runtime::Westmint => &westmint_runtime::VERSION,
|
||||||
} else if chain_spec.is_westmint() {
|
Runtime::Shell => &shell_runtime::VERSION,
|
||||||
&westmint_runtime::VERSION
|
Runtime::Seedling => &seedling_runtime::VERSION,
|
||||||
} else if chain_spec.is_shell() {
|
Runtime::ContractsRococo => &contracts_rococo_runtime::VERSION,
|
||||||
&shell_runtime::VERSION
|
Runtime::Generic => &rococo_parachain_runtime::VERSION,
|
||||||
} else if chain_spec.is_seedling() {
|
|
||||||
&seedling_runtime::VERSION
|
|
||||||
} else if chain_spec.is_contracts_rococo() {
|
|
||||||
&contracts_rococo_runtime::VERSION
|
|
||||||
} else {
|
|
||||||
&rococo_parachain_runtime::VERSION
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,26 +266,29 @@ fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<V
|
|||||||
/// Creates partial components for the runtimes that are supported by the benchmarks.
|
/// Creates partial components for the runtimes that are supported by the benchmarks.
|
||||||
macro_rules! construct_benchmark_partials {
|
macro_rules! construct_benchmark_partials {
|
||||||
($config:expr, |$partials:ident| $code:expr) => {
|
($config:expr, |$partials:ident| $code:expr) => {
|
||||||
if $config.chain_spec.is_statemine() {
|
match $config.chain_spec.runtime() {
|
||||||
let $partials = new_partial::<statemine_runtime::RuntimeApi, _>(
|
Runtime::Statemine => {
|
||||||
&$config,
|
let $partials = new_partial::<statemine_runtime::RuntimeApi, _>(
|
||||||
crate::service::statemint_build_import_queue::<_, AuraId>,
|
&$config,
|
||||||
)?;
|
crate::service::statemint_build_import_queue::<_, AuraId>,
|
||||||
$code
|
)?;
|
||||||
} else if $config.chain_spec.is_westmint() {
|
$code
|
||||||
let $partials = new_partial::<westmint_runtime::RuntimeApi, _>(
|
},
|
||||||
&$config,
|
Runtime::Westmint => {
|
||||||
crate::service::statemint_build_import_queue::<_, AuraId>,
|
let $partials = new_partial::<westmint_runtime::RuntimeApi, _>(
|
||||||
)?;
|
&$config,
|
||||||
$code
|
crate::service::statemint_build_import_queue::<_, AuraId>,
|
||||||
} else if $config.chain_spec.is_statemint() {
|
)?;
|
||||||
let $partials = new_partial::<statemint_runtime::RuntimeApi, _>(
|
$code
|
||||||
&$config,
|
},
|
||||||
crate::service::statemint_build_import_queue::<_, StatemintAuraId>,
|
Runtime::Statemint => {
|
||||||
)?;
|
let $partials = new_partial::<statemint_runtime::RuntimeApi, _>(
|
||||||
$code
|
&$config,
|
||||||
} else {
|
crate::service::statemint_build_import_queue::<_, StatemintAuraId>,
|
||||||
Err("The chain is not supported".into())
|
)?;
|
||||||
|
$code
|
||||||
|
},
|
||||||
|
_ => Err("The chain is not supported".into()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -297,72 +296,80 @@ macro_rules! construct_benchmark_partials {
|
|||||||
macro_rules! construct_async_run {
|
macro_rules! construct_async_run {
|
||||||
(|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
|
(|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
|
||||||
let runner = $cli.create_runner($cmd)?;
|
let runner = $cli.create_runner($cmd)?;
|
||||||
if runner.config().chain_spec.is_westmint() {
|
match runner.config().chain_spec.runtime() {
|
||||||
runner.async_run(|$config| {
|
Runtime::Westmint => {
|
||||||
let $components = new_partial::<westmint_runtime::RuntimeApi, _>(
|
runner.async_run(|$config| {
|
||||||
&$config,
|
let $components = new_partial::<westmint_runtime::RuntimeApi, _>(
|
||||||
crate::service::statemint_build_import_queue::<_, AuraId>,
|
&$config,
|
||||||
)?;
|
crate::service::statemint_build_import_queue::<_, AuraId>,
|
||||||
let task_manager = $components.task_manager;
|
)?;
|
||||||
{ $( $code )* }.map(|v| (v, task_manager))
|
let task_manager = $components.task_manager;
|
||||||
})
|
{ $( $code )* }.map(|v| (v, task_manager))
|
||||||
} else if runner.config().chain_spec.is_statemine() {
|
})
|
||||||
runner.async_run(|$config| {
|
},
|
||||||
let $components = new_partial::<statemine_runtime::RuntimeApi, _>(
|
Runtime::Statemine => {
|
||||||
&$config,
|
runner.async_run(|$config| {
|
||||||
crate::service::statemint_build_import_queue::<_, AuraId>,
|
let $components = new_partial::<statemine_runtime::RuntimeApi, _>(
|
||||||
)?;
|
&$config,
|
||||||
let task_manager = $components.task_manager;
|
crate::service::statemint_build_import_queue::<_, AuraId>,
|
||||||
{ $( $code )* }.map(|v| (v, task_manager))
|
)?;
|
||||||
})
|
let task_manager = $components.task_manager;
|
||||||
} else if runner.config().chain_spec.is_statemint() {
|
{ $( $code )* }.map(|v| (v, task_manager))
|
||||||
runner.async_run(|$config| {
|
})
|
||||||
let $components = new_partial::<statemint_runtime::RuntimeApi, _>(
|
},
|
||||||
&$config,
|
Runtime::Statemint => {
|
||||||
crate::service::statemint_build_import_queue::<_, StatemintAuraId>,
|
runner.async_run(|$config| {
|
||||||
)?;
|
let $components = new_partial::<statemint_runtime::RuntimeApi, _>(
|
||||||
let task_manager = $components.task_manager;
|
&$config,
|
||||||
{ $( $code )* }.map(|v| (v, task_manager))
|
crate::service::statemint_build_import_queue::<_, StatemintAuraId>,
|
||||||
})
|
)?;
|
||||||
} else if runner.config().chain_spec.is_shell() {
|
let task_manager = $components.task_manager;
|
||||||
runner.async_run(|$config| {
|
{ $( $code )* }.map(|v| (v, task_manager))
|
||||||
let $components = new_partial::<shell_runtime::RuntimeApi, _>(
|
})
|
||||||
&$config,
|
},
|
||||||
crate::service::shell_build_import_queue,
|
Runtime::Shell => {
|
||||||
)?;
|
runner.async_run(|$config| {
|
||||||
let task_manager = $components.task_manager;
|
let $components = new_partial::<shell_runtime::RuntimeApi, _>(
|
||||||
{ $( $code )* }.map(|v| (v, task_manager))
|
&$config,
|
||||||
})
|
crate::service::shell_build_import_queue,
|
||||||
} else if runner.config().chain_spec.is_seedling() {
|
)?;
|
||||||
runner.async_run(|$config| {
|
let task_manager = $components.task_manager;
|
||||||
let $components = new_partial::<seedling_runtime::RuntimeApi, _>(
|
{ $( $code )* }.map(|v| (v, task_manager))
|
||||||
&$config,
|
})
|
||||||
crate::service::shell_build_import_queue,
|
},
|
||||||
)?;
|
Runtime::Seedling => {
|
||||||
let task_manager = $components.task_manager;
|
runner.async_run(|$config| {
|
||||||
{ $( $code )* }.map(|v| (v, task_manager))
|
let $components = new_partial::<seedling_runtime::RuntimeApi, _>(
|
||||||
})
|
&$config,
|
||||||
} else if runner.config().chain_spec.is_contracts_rococo() {
|
crate::service::shell_build_import_queue,
|
||||||
runner.async_run(|$config| {
|
)?;
|
||||||
let $components = new_partial::<contracts_rococo_runtime::RuntimeApi, _>(
|
let task_manager = $components.task_manager;
|
||||||
&$config,
|
{ $( $code )* }.map(|v| (v, task_manager))
|
||||||
crate::service::contracts_rococo_build_import_queue,
|
})
|
||||||
)?;
|
},
|
||||||
let task_manager = $components.task_manager;
|
Runtime::ContractsRococo => {
|
||||||
{ $( $code )* }.map(|v| (v, task_manager))
|
runner.async_run(|$config| {
|
||||||
})
|
let $components = new_partial::<contracts_rococo_runtime::RuntimeApi, _>(
|
||||||
} else {
|
&$config,
|
||||||
runner.async_run(|$config| {
|
crate::service::contracts_rococo_build_import_queue,
|
||||||
let $components = new_partial::<
|
)?;
|
||||||
rococo_parachain_runtime::RuntimeApi,
|
let task_manager = $components.task_manager;
|
||||||
_
|
{ $( $code )* }.map(|v| (v, task_manager))
|
||||||
>(
|
})
|
||||||
&$config,
|
},
|
||||||
crate::service::rococo_parachain_build_import_queue,
|
Runtime::Generic => {
|
||||||
)?;
|
runner.async_run(|$config| {
|
||||||
let task_manager = $components.task_manager;
|
let $components = new_partial::<
|
||||||
{ $( $code )* }.map(|v| (v, task_manager))
|
rococo_parachain_runtime::RuntimeApi,
|
||||||
})
|
_
|
||||||
|
>(
|
||||||
|
&$config,
|
||||||
|
crate::service::rococo_parachain_build_import_queue,
|
||||||
|
)?;
|
||||||
|
let task_manager = $components.task_manager;
|
||||||
|
{ $( $code )* }.map(|v| (v, task_manager))
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@@ -472,16 +479,13 @@ pub fn run() -> Result<()> {
|
|||||||
match cmd {
|
match cmd {
|
||||||
BenchmarkCmd::Pallet(cmd) =>
|
BenchmarkCmd::Pallet(cmd) =>
|
||||||
if cfg!(feature = "runtime-benchmarks") {
|
if cfg!(feature = "runtime-benchmarks") {
|
||||||
runner.sync_run(|config| {
|
runner.sync_run(|config| match config.chain_spec.runtime() {
|
||||||
if config.chain_spec.is_statemine() {
|
Runtime::Statemine =>
|
||||||
cmd.run::<Block, StatemineRuntimeExecutor>(config)
|
cmd.run::<Block, StatemineRuntimeExecutor>(config),
|
||||||
} else if config.chain_spec.is_westmint() {
|
Runtime::Westmint => cmd.run::<Block, WestmintRuntimeExecutor>(config),
|
||||||
cmd.run::<Block, WestmintRuntimeExecutor>(config)
|
Runtime::Statemint =>
|
||||||
} else if config.chain_spec.is_statemint() {
|
cmd.run::<Block, StatemintRuntimeExecutor>(config),
|
||||||
cmd.run::<Block, StatemintRuntimeExecutor>(config)
|
_ => Err("Chain doesn't support benchmarking".into()),
|
||||||
} else {
|
|
||||||
Err("Chain doesn't support benchmarking".into())
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err("Benchmarking wasn't enabled when building the node. \
|
Err("Benchmarking wasn't enabled when building the node. \
|
||||||
@@ -513,24 +517,20 @@ pub fn run() -> Result<()> {
|
|||||||
TaskManager::new(runner.config().tokio_handle.clone(), *registry)
|
TaskManager::new(runner.config().tokio_handle.clone(), *registry)
|
||||||
.map_err(|e| format!("Error: {:?}", e))?;
|
.map_err(|e| format!("Error: {:?}", e))?;
|
||||||
|
|
||||||
if runner.config().chain_spec.is_statemine() {
|
match runner.config().chain_spec.runtime() {
|
||||||
runner.async_run(|config| {
|
Runtime::Statemine => runner.async_run(|config| {
|
||||||
Ok((cmd.run::<Block, StatemineRuntimeExecutor>(config), task_manager))
|
Ok((cmd.run::<Block, StatemineRuntimeExecutor>(config), task_manager))
|
||||||
})
|
}),
|
||||||
} else if runner.config().chain_spec.is_westmint() {
|
Runtime::Westmint => runner.async_run(|config| {
|
||||||
runner.async_run(|config| {
|
|
||||||
Ok((cmd.run::<Block, WestmintRuntimeExecutor>(config), task_manager))
|
Ok((cmd.run::<Block, WestmintRuntimeExecutor>(config), task_manager))
|
||||||
})
|
}),
|
||||||
} else if runner.config().chain_spec.is_statemint() {
|
Runtime::Statemint => runner.async_run(|config| {
|
||||||
runner.async_run(|config| {
|
|
||||||
Ok((cmd.run::<Block, StatemintRuntimeExecutor>(config), task_manager))
|
Ok((cmd.run::<Block, StatemintRuntimeExecutor>(config), task_manager))
|
||||||
})
|
}),
|
||||||
} else if runner.config().chain_spec.is_shell() {
|
Runtime::Shell => runner.async_run(|config| {
|
||||||
runner.async_run(|config| {
|
|
||||||
Ok((cmd.run::<Block, ShellRuntimeExecutor>(config), task_manager))
|
Ok((cmd.run::<Block, ShellRuntimeExecutor>(config), task_manager))
|
||||||
})
|
}),
|
||||||
} else {
|
_ => Err("Chain doesn't support try-runtime".into()),
|
||||||
Err("Chain doesn't support try-runtime".into())
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err("Try-runtime must be enabled by `--features try-runtime`.".into())
|
Err("Try-runtime must be enabled by `--features try-runtime`.".into())
|
||||||
@@ -584,16 +584,46 @@ pub fn run() -> Result<()> {
|
|||||||
info!("Parachain genesis state: {}", genesis_state);
|
info!("Parachain genesis state: {}", genesis_state);
|
||||||
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
|
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
|
||||||
|
|
||||||
if config.chain_spec.is_statemint() {
|
match config.chain_spec.runtime() {
|
||||||
crate::service::start_statemint_node::<
|
Runtime::Statemint => crate::service::start_statemint_node::<
|
||||||
statemint_runtime::RuntimeApi,
|
statemint_runtime::RuntimeApi,
|
||||||
StatemintAuraId,
|
StatemintAuraId,
|
||||||
>(config, polkadot_config, collator_options, id, hwbench)
|
>(config, polkadot_config, collator_options, id, hwbench)
|
||||||
.await
|
.await
|
||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into),
|
||||||
} else if config.chain_spec.is_statemine() {
|
Runtime::Statemine => crate::service::start_statemint_node::<
|
||||||
crate::service::start_statemint_node::<statemine_runtime::RuntimeApi, AuraId>(
|
statemine_runtime::RuntimeApi,
|
||||||
|
AuraId,
|
||||||
|
>(config, polkadot_config, collator_options, id, hwbench)
|
||||||
|
.await
|
||||||
|
.map(|r| r.0)
|
||||||
|
.map_err(Into::into),
|
||||||
|
Runtime::Westmint => crate::service::start_statemint_node::<
|
||||||
|
westmint_runtime::RuntimeApi,
|
||||||
|
AuraId,
|
||||||
|
>(config, polkadot_config, collator_options, id, hwbench)
|
||||||
|
.await
|
||||||
|
.map(|r| r.0)
|
||||||
|
.map_err(Into::into),
|
||||||
|
Runtime::Shell =>
|
||||||
|
crate::service::start_shell_node::<shell_runtime::RuntimeApi>(
|
||||||
|
config,
|
||||||
|
polkadot_config,
|
||||||
|
collator_options,
|
||||||
|
id,
|
||||||
|
hwbench,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map(|r| r.0)
|
||||||
|
.map_err(Into::into),
|
||||||
|
Runtime::Seedling => crate::service::start_shell_node::<
|
||||||
|
seedling_runtime::RuntimeApi,
|
||||||
|
>(config, polkadot_config, collator_options, id, hwbench)
|
||||||
|
.await
|
||||||
|
.map(|r| r.0)
|
||||||
|
.map_err(Into::into),
|
||||||
|
Runtime::ContractsRococo => crate::service::start_contracts_rococo_node(
|
||||||
config,
|
config,
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
collator_options,
|
collator_options,
|
||||||
@@ -602,9 +632,8 @@ pub fn run() -> Result<()> {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into),
|
||||||
} else if config.chain_spec.is_westmint() {
|
Runtime::Generic => crate::service::start_rococo_parachain_node(
|
||||||
crate::service::start_statemint_node::<westmint_runtime::RuntimeApi, AuraId>(
|
|
||||||
config,
|
config,
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
collator_options,
|
collator_options,
|
||||||
@@ -613,51 +642,7 @@ pub fn run() -> Result<()> {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into),
|
||||||
} else if config.chain_spec.is_shell() {
|
|
||||||
crate::service::start_shell_node::<shell_runtime::RuntimeApi>(
|
|
||||||
config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0)
|
|
||||||
.map_err(Into::into)
|
|
||||||
} else if config.chain_spec.is_seedling() {
|
|
||||||
crate::service::start_shell_node::<seedling_runtime::RuntimeApi>(
|
|
||||||
config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0)
|
|
||||||
.map_err(Into::into)
|
|
||||||
} else if config.chain_spec.is_contracts_rococo() {
|
|
||||||
crate::service::start_contracts_rococo_node(
|
|
||||||
config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0)
|
|
||||||
.map_err(Into::into)
|
|
||||||
} else {
|
|
||||||
crate::service::start_rococo_parachain_node(
|
|
||||||
config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0)
|
|
||||||
.map_err(Into::into)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user