mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 04:41:03 +00:00
Removed dependance on rococo_parachain_runtime for unrelated stuff (#1500)
* Clean misleading imports `rococo_parachain_runtime::{AccountId, AuraId}`
* Remove dependance on `rococo_parachain_runtime` for unrelated stuff
* fmt + rebase fix
* Addressing review comments
* Addressing review comments
* Fix for `purge_chain_works` works now with `rococo-local` and purge command needs to allow `rococo-native`
This commit is contained in:
Generated
+6
@@ -6815,6 +6815,7 @@ dependencies = [
|
|||||||
"pallet-transaction-payment-rpc-runtime-api",
|
"pallet-transaction-payment-rpc-runtime-api",
|
||||||
"pallet-xcm",
|
"pallet-xcm",
|
||||||
"parachain-info",
|
"parachain-info",
|
||||||
|
"parachains-common",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"polkadot-parachain 0.9.27",
|
"polkadot-parachain 0.9.27",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
@@ -7093,6 +7094,7 @@ dependencies = [
|
|||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"polkadot-runtime",
|
"polkadot-runtime",
|
||||||
"polkadot-runtime-common",
|
"polkadot-runtime-common",
|
||||||
|
"rococo-runtime",
|
||||||
"sc-client-api",
|
"sc-client-api",
|
||||||
"sc-consensus",
|
"sc-consensus",
|
||||||
"sc-executor",
|
"sc-executor",
|
||||||
@@ -7770,6 +7772,7 @@ dependencies = [
|
|||||||
"sp-keystore",
|
"sp-keystore",
|
||||||
"sp-offchain",
|
"sp-offchain",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
|
"sp-serializer",
|
||||||
"sp-session",
|
"sp-session",
|
||||||
"sp-timestamp",
|
"sp-timestamp",
|
||||||
"sp-transaction-pool",
|
"sp-transaction-pool",
|
||||||
@@ -8118,6 +8121,7 @@ dependencies = [
|
|||||||
"polkadot-runtime-parachains",
|
"polkadot-runtime-parachains",
|
||||||
"polkadot-statement-distribution",
|
"polkadot-statement-distribution",
|
||||||
"rococo-runtime",
|
"rococo-runtime",
|
||||||
|
"rococo-runtime-constants",
|
||||||
"sc-authority-discovery",
|
"sc-authority-discovery",
|
||||||
"sc-basic-authorship",
|
"sc-basic-authorship",
|
||||||
"sc-block-builder",
|
"sc-block-builder",
|
||||||
@@ -10402,6 +10406,7 @@ dependencies = [
|
|||||||
"pallet-balances",
|
"pallet-balances",
|
||||||
"pallet-sudo",
|
"pallet-sudo",
|
||||||
"parachain-info",
|
"parachain-info",
|
||||||
|
"parachains-common",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -10609,6 +10614,7 @@ dependencies = [
|
|||||||
"frame-try-runtime",
|
"frame-try-runtime",
|
||||||
"log",
|
"log",
|
||||||
"parachain-info",
|
"parachain-info",
|
||||||
|
"parachains-common",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub type ChainSpec =
|
|||||||
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
|
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
|
||||||
|
|
||||||
/// Helper function to generate a crypto pair from seed
|
/// Helper function to generate a crypto pair from seed
|
||||||
pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
||||||
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
||||||
.expect("static values are valid; qed")
|
.expect("static values are valid; qed")
|
||||||
.public()
|
.public()
|
||||||
@@ -43,7 +43,7 @@ type AccountPublic = <Signature as Verify>::Signer;
|
|||||||
///
|
///
|
||||||
/// This function's return type must always match the session keys of the chain in tuple format.
|
/// This function's return type must always match the session keys of the chain in tuple format.
|
||||||
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
|
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
|
||||||
get_public_from_seed::<AuraId>(seed)
|
get_from_seed::<AuraId>(seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to generate an account ID from seed
|
/// Helper function to generate an account ID from seed
|
||||||
@@ -51,7 +51,7 @@ pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
|||||||
where
|
where
|
||||||
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
||||||
{
|
{
|
||||||
AccountPublic::from(get_public_from_seed::<TPublic>(seed)).into_account()
|
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate the session keys from individual elements.
|
/// Generate the session keys from individual elements.
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ sp-version = { git = "https://github.com/paritytech/substrate", default-features
|
|||||||
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
|
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
|
||||||
cumulus-pallet-solo-to-para = { path = "../../../../pallets/solo-to-para", default-features = false }
|
cumulus-pallet-solo-to-para = { path = "../../../../pallets/solo-to-para", default-features = false }
|
||||||
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
|
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
|
||||||
|
parachains-common = { path = "../../../common", default-features = false }
|
||||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ pub use frame_support::{
|
|||||||
StorageValue,
|
StorageValue,
|
||||||
};
|
};
|
||||||
use frame_system::limits::{BlockLength, BlockWeights};
|
use frame_system::limits::{BlockLength, BlockWeights};
|
||||||
|
use parachains_common::{AccountId, Signature};
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use sp_runtime::BuildStorage;
|
pub use sp_runtime::BuildStorage;
|
||||||
pub use sp_runtime::{Perbill, Permill};
|
pub use sp_runtime::{Perbill, Permill};
|
||||||
@@ -189,11 +190,6 @@ construct_runtime! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
|
|
||||||
pub type Signature = sp_runtime::MultiSignature;
|
|
||||||
/// Some way of identifying an account on the chain. We intentionally make it equivalent
|
|
||||||
/// to the public key of our transaction signing scheme.
|
|
||||||
pub type AccountId = <<Signature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId;
|
|
||||||
/// Index of a transaction in the chain.
|
/// Index of a transaction in the chain.
|
||||||
pub type Index = u32;
|
pub type Index = u32;
|
||||||
/// A hash of some data used by the chain.
|
/// A hash of some data used by the chain.
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = fals
|
|||||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||||
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
|
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
|
||||||
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
|
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
|
||||||
|
parachains-common = { path = "../../../common", default-features = false }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ pub use frame_support::{
|
|||||||
StorageValue,
|
StorageValue,
|
||||||
};
|
};
|
||||||
use frame_system::limits::{BlockLength, BlockWeights};
|
use frame_system::limits::{BlockLength, BlockWeights};
|
||||||
|
use parachains_common::{AccountId, Signature};
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use sp_runtime::BuildStorage;
|
pub use sp_runtime::BuildStorage;
|
||||||
pub use sp_runtime::{Perbill, Permill};
|
pub use sp_runtime::{Perbill, Permill};
|
||||||
@@ -228,11 +229,6 @@ impl sp_runtime::traits::SignedExtension for DisallowSigned {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
|
|
||||||
pub type Signature = sp_runtime::MultiSignature;
|
|
||||||
/// Some way of identifying an account on the chain. We intentionally make it equivalent
|
|
||||||
/// to the public key of our transaction signing scheme.
|
|
||||||
pub type AccountId = <<Signature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId;
|
|
||||||
/// Index of a transaction in the chain.
|
/// Index of a transaction in the chain.
|
||||||
pub type Index = u32;
|
pub type Index = u32;
|
||||||
/// A hash of some data used by the chain.
|
/// A hash of some data used by the chain.
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ cumulus-primitives-timestamp = { path = "../../../../primitives/timestamp", defa
|
|||||||
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
|
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
|
||||||
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
|
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
|
||||||
parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false }
|
parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false }
|
||||||
|
parachains-common = { path = "../../../common", default-features = false }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [
|
default = [
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
|||||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
create_runtime_str, generic, impl_opaque_keys,
|
create_runtime_str, generic, impl_opaque_keys,
|
||||||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify},
|
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT},
|
||||||
transaction_validity::{TransactionSource, TransactionValidity},
|
transaction_validity::{TransactionSource, TransactionValidity},
|
||||||
ApplyExtrinsicResult, MultiSignature,
|
ApplyExtrinsicResult,
|
||||||
};
|
};
|
||||||
pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Permill};
|
pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Permill};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -70,16 +70,10 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
|||||||
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
||||||
|
|
||||||
// XCM Imports
|
// XCM Imports
|
||||||
|
use parachains_common::{AccountId, Signature};
|
||||||
use xcm::latest::prelude::BodyId;
|
use xcm::latest::prelude::BodyId;
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
|
|
||||||
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
|
|
||||||
pub type Signature = MultiSignature;
|
|
||||||
|
|
||||||
/// Some way of identifying an account on the chain. We intentionally make it equivalent
|
|
||||||
/// to the public key of our transaction signing scheme.
|
|
||||||
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
|
|
||||||
|
|
||||||
/// Balance of an account.
|
/// Balance of an account.
|
||||||
pub type Balance = u128;
|
pub type Balance = u128;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ pub use sp_runtime::{Perbill, Permill};
|
|||||||
|
|
||||||
use parachains_common::{
|
use parachains_common::{
|
||||||
impls::{AssetsFrom, NonZeroIssuance},
|
impls::{AssetsFrom, NonZeroIssuance},
|
||||||
AssetId,
|
AccountId, AssetId, Signature,
|
||||||
};
|
};
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex,
|
||||||
@@ -543,11 +543,6 @@ construct_runtime! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
|
|
||||||
pub type Signature = sp_runtime::MultiSignature;
|
|
||||||
/// Some way of identifying an account on the chain. We intentionally make it equivalent
|
|
||||||
/// to the public key of our transaction signing scheme.
|
|
||||||
pub type AccountId = <<Signature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId;
|
|
||||||
/// Balance of an account.
|
/// Balance of an account.
|
||||||
pub type Balance = u128;
|
pub type Balance = u128;
|
||||||
/// Index of a transaction in the chain.
|
/// Index of a transaction in the chain.
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "maste
|
|||||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
@@ -95,6 +96,8 @@ nix = "0.24"
|
|||||||
tempfile = "3.3.0"
|
tempfile = "3.3.0"
|
||||||
tokio = { version = "1.19.2", features = ["macros", "time", "parking_lot"] }
|
tokio = { version = "1.19.2", features = ["macros", "time", "parking_lot"] }
|
||||||
wait-timeout = "0.2"
|
wait-timeout = "0.2"
|
||||||
|
# purge_chain_works works with rococo-local and needs to allow this
|
||||||
|
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master", features = ["rococo-native"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ use crate::chain_spec::{
|
|||||||
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
|
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 parachains_common::Balance as CollectivesBalance;
|
use parachains_common::{AccountId, AuraId, Balance as CollectivesBalance};
|
||||||
use rococo_parachain_runtime::{AccountId, AuraId};
|
|
||||||
use sc_service::ChainType;
|
use sc_service::ChainType;
|
||||||
use sp_core::sr25519;
|
use sp_core::sr25519;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use crate::chain_spec::{
|
|||||||
};
|
};
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use rococo_parachain_runtime::{AccountId, AuraId};
|
use parachains_common::{AccountId, AuraId};
|
||||||
use sc_service::ChainType;
|
use sc_service::ChainType;
|
||||||
use sp_core::{crypto::UncheckedInto, sr25519};
|
use sp_core::{crypto::UncheckedInto, sr25519};
|
||||||
|
|
||||||
|
|||||||
@@ -14,37 +14,24 @@
|
|||||||
// 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 cumulus_primitives_core::ParaId;
|
use parachains_common::{AccountId, Signature};
|
||||||
use hex_literal::hex;
|
|
||||||
use rococo_parachain_runtime::{AccountId, AuraId, Signature};
|
|
||||||
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
|
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
|
||||||
use sc_service::ChainType;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
|
use sp_core::{Pair, Public};
|
||||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||||
|
|
||||||
pub mod collectives;
|
pub mod collectives;
|
||||||
pub mod contracts;
|
pub mod contracts;
|
||||||
pub mod penpal;
|
pub mod penpal;
|
||||||
|
pub mod rococo_parachain;
|
||||||
pub mod seedling;
|
pub mod seedling;
|
||||||
pub mod shell;
|
pub mod shell;
|
||||||
pub mod statemint;
|
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.
|
/// The default XCM version to set in genesis config.
|
||||||
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
|
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
|
||||||
|
|
||||||
/// Helper function to generate a crypto pair from seed
|
/// Generic extensions for Parachain ChainSpecs.
|
||||||
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)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Extensions {
|
pub struct Extensions {
|
||||||
@@ -61,6 +48,13 @@ impl Extensions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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()
|
||||||
|
}
|
||||||
|
|
||||||
type AccountPublic = <Signature as Verify>::Signer;
|
type AccountPublic = <Signature as Verify>::Signer;
|
||||||
|
|
||||||
/// Helper function to generate an account ID from seed
|
/// Helper function to generate an account ID from seed
|
||||||
@@ -71,108 +65,9 @@ where
|
|||||||
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
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.
|
/// Generate collator keys from seed.
|
||||||
///
|
///
|
||||||
/// This function's return type must always match the session keys of the chain in tuple format.
|
/// 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 {
|
pub fn get_collator_keys_from_seed<AuraId: Public>(seed: &str) -> <AuraId::Pair as Pair>::Public {
|
||||||
get_public_from_seed::<AuraId>(seed)
|
get_from_seed::<AuraId>(seed)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,11 @@
|
|||||||
// 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, Extensions};
|
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 rococo_parachain_runtime::{AuraId};
|
use parachains_common::{AccountId, AuraId};
|
||||||
use crate::chain_spec::{get_collator_keys_from_seed, SAFE_XCM_VERSION};
|
|
||||||
use sc_service::ChainType;
|
use sc_service::ChainType;
|
||||||
use sp_core::sr25519;
|
use sp_core::sr25519;
|
||||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||||
@@ -42,11 +43,11 @@ pub fn get_penpal_chain_spec(id: ParaId, relay_chain: &str) -> PenpalChainSpec {
|
|||||||
vec![
|
vec![
|
||||||
(
|
(
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
get_collator_keys_from_seed::<penpal_runtime::AuraId>("Alice"),
|
get_collator_keys_from_seed::<AuraId>("Alice"),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
get_collator_keys_from_seed::<penpal_runtime::AuraId>("Bob"),
|
get_collator_keys_from_seed::<AuraId>("Bob"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
@@ -79,8 +80,8 @@ pub fn get_penpal_chain_spec(id: ParaId, relay_chain: &str) -> PenpalChainSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn penpal_testnet_genesis(
|
fn penpal_testnet_genesis(
|
||||||
invulnerables: Vec<(penpal_runtime::AccountId, penpal_runtime::AuraId)>,
|
invulnerables: Vec<(AccountId, AuraId)>,
|
||||||
endowed_accounts: Vec<penpal_runtime::AccountId>,
|
endowed_accounts: Vec<AccountId>,
|
||||||
id: ParaId,
|
id: ParaId,
|
||||||
) -> penpal_runtime::GenesisConfig {
|
) -> penpal_runtime::GenesisConfig {
|
||||||
penpal_runtime::GenesisConfig {
|
penpal_runtime::GenesisConfig {
|
||||||
@@ -131,6 +132,6 @@ fn penpal_testnet_genesis(
|
|||||||
/// 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).
|
||||||
pub fn penpal_session_keys(keys: penpal_runtime::AuraId) -> penpal_runtime::SessionKeys {
|
pub fn penpal_session_keys(keys: AuraId) -> penpal_runtime::SessionKeys {
|
||||||
penpal_runtime::SessionKeys { aura: keys }
|
penpal_runtime::SessionKeys { aura: keys }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
// Copyright 2022 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/>.
|
||||||
|
|
||||||
|
//! ChainSpecs dedicated to Rococo parachain setups (for testing and example purposes)
|
||||||
|
|
||||||
|
use crate::chain_spec::{get_from_seed, Extensions, SAFE_XCM_VERSION};
|
||||||
|
use cumulus_primitives_core::ParaId;
|
||||||
|
use hex_literal::hex;
|
||||||
|
use parachains_common::AccountId;
|
||||||
|
use polkadot_service::chain_spec::get_account_id_from_seed;
|
||||||
|
use rococo_parachain_runtime::AuraId;
|
||||||
|
use sc_chain_spec::ChainType;
|
||||||
|
use sp_core::{crypto::UncheckedInto, sr25519};
|
||||||
|
|
||||||
|
pub type RococoParachainChainSpec =
|
||||||
|
sc_service::GenericChainSpec<rococo_parachain_runtime::GenesisConfig, Extensions>;
|
||||||
|
|
||||||
|
pub fn rococo_parachain_local_config() -> RococoParachainChainSpec {
|
||||||
|
RococoParachainChainSpec::from_genesis(
|
||||||
|
"Rococo Parachain Local",
|
||||||
|
"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: "rococo-local".into(), para_id: 1000 },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn staging_rococo_parachain_local_config() -> RococoParachainChainSpec {
|
||||||
|
RococoParachainChainSpec::from_genesis(
|
||||||
|
"Staging Rococo Parachain Local",
|
||||||
|
"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: "rococo-local".into(), para_id: 1000 },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) 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),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
use crate::chain_spec::{get_account_id_from_seed, Extensions};
|
use crate::chain_spec::{get_account_id_from_seed, Extensions};
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use rococo_parachain_runtime::AccountId;
|
use parachains_common::AccountId;
|
||||||
use sc_service::ChainType;
|
use sc_service::ChainType;
|
||||||
use sp_core::sr25519;
|
use sp_core::sr25519;
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ use crate::chain_spec::{
|
|||||||
};
|
};
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use parachains_common::{Balance as StatemintBalance, StatemintAuraId};
|
use parachains_common::{AccountId, AuraId, Balance as StatemintBalance, StatemintAuraId};
|
||||||
use rococo_parachain_runtime::{AccountId, AuraId};
|
|
||||||
use sc_service::ChainType;
|
use sc_service::ChainType;
|
||||||
use sp_core::{crypto::UncheckedInto, sr25519};
|
use sp_core::{crypto::UncheckedInto, sr25519};
|
||||||
|
|
||||||
|
|||||||
@@ -38,12 +38,15 @@ use sc_service::{
|
|||||||
};
|
};
|
||||||
use sp_core::hexdisplay::HexDisplay;
|
use sp_core::hexdisplay::HexDisplay;
|
||||||
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
|
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
|
||||||
use std::net::SocketAddr;
|
use std::{net::SocketAddr, path::PathBuf};
|
||||||
|
|
||||||
#[derive(Debug)]
|
/// Helper enum that is used for better distinction of different parachain/runtime configuration
|
||||||
|
/// (it is based/calculated on ChainSpec's ID attribute)
|
||||||
|
#[derive(Debug, PartialEq, Default)]
|
||||||
enum Runtime {
|
enum Runtime {
|
||||||
/// This is the default runtime (based on rococo)
|
/// This is the default runtime (actually based on rococo)
|
||||||
Generic,
|
#[default]
|
||||||
|
Default,
|
||||||
Shell,
|
Shell,
|
||||||
Seedling,
|
Seedling,
|
||||||
Statemint,
|
Statemint,
|
||||||
@@ -55,22 +58,30 @@ enum Runtime {
|
|||||||
CollectivesWestend,
|
CollectivesWestend,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ChainType {
|
trait RuntimeResolver {
|
||||||
fn runtime(&self) -> Runtime;
|
fn runtime(&self) -> Runtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChainType for dyn ChainSpec {
|
impl RuntimeResolver for dyn ChainSpec {
|
||||||
fn runtime(&self) -> Runtime {
|
fn runtime(&self) -> Runtime {
|
||||||
runtime(self.id())
|
runtime(self.id())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use sc_chain_spec::GenericChainSpec;
|
/// Implementation, that can resolve [`Runtime`] from any json configuration file
|
||||||
impl ChainType
|
impl RuntimeResolver for PathBuf {
|
||||||
for GenericChainSpec<rococo_parachain_runtime::GenesisConfig, chain_spec::Extensions>
|
|
||||||
{
|
|
||||||
fn runtime(&self) -> Runtime {
|
fn runtime(&self) -> Runtime {
|
||||||
runtime(self.id())
|
#[derive(Debug, serde::Deserialize)]
|
||||||
|
struct EmptyChainSpecWithId {
|
||||||
|
id: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
let file = std::fs::File::open(self).expect("Failed to open file");
|
||||||
|
let reader = std::io::BufReader::new(file);
|
||||||
|
let chain_spec: EmptyChainSpecWithId = sp_serializer::from_reader(reader)
|
||||||
|
.expect("Failed to read 'json' file with ChainSpec configuration");
|
||||||
|
|
||||||
|
runtime(&chain_spec.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,32 +108,41 @@ fn runtime(id: &str) -> Runtime {
|
|||||||
} else if id.starts_with("collectives-westend") {
|
} else if id.starts_with("collectives-westend") {
|
||||||
Runtime::CollectivesWestend
|
Runtime::CollectivesWestend
|
||||||
} else {
|
} else {
|
||||||
Runtime::Generic
|
log::warn!("No specific runtime was recognized for ChainSpec's id: '{}', so Runtime::default() will be used", id);
|
||||||
|
Runtime::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||||
let (id, _, para_id) = extract_parachain_id(id);
|
let (id, _, para_id) = extract_parachain_id(id);
|
||||||
Ok(match id {
|
Ok(match id {
|
||||||
"staging" => Box::new(chain_spec::staging_test_net()),
|
// - Defaul-like
|
||||||
"tick" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"staging" =>
|
||||||
|
Box::new(chain_spec::rococo_parachain::staging_rococo_parachain_local_config()),
|
||||||
|
"tick" =>
|
||||||
|
Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/tick.json")[..],
|
&include_bytes!("../../parachains/chain-specs/tick.json")[..],
|
||||||
)?),
|
)?),
|
||||||
"trick" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"trick" =>
|
||||||
|
Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/trick.json")[..],
|
&include_bytes!("../../parachains/chain-specs/trick.json")[..],
|
||||||
)?),
|
)?),
|
||||||
"track" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"track" =>
|
||||||
|
Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/track.json")[..],
|
&include_bytes!("../../parachains/chain-specs/track.json")[..],
|
||||||
)?),
|
)?),
|
||||||
|
|
||||||
|
// -- Starters
|
||||||
"shell" => Box::new(chain_spec::shell::get_shell_chain_spec()),
|
"shell" => Box::new(chain_spec::shell::get_shell_chain_spec()),
|
||||||
// -- Statemint
|
|
||||||
"seedling" => Box::new(chain_spec::seedling::get_seedling_chain_spec()),
|
"seedling" => Box::new(chain_spec::seedling::get_seedling_chain_spec()),
|
||||||
|
|
||||||
|
// -- Statemint
|
||||||
"statemint-dev" => Box::new(chain_spec::statemint::statemint_development_config()),
|
"statemint-dev" => Box::new(chain_spec::statemint::statemint_development_config()),
|
||||||
"statemint-local" => Box::new(chain_spec::statemint::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::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::statemint::StatemintChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/statemint.json")[..],
|
&include_bytes!("../../parachains/chain-specs/statemint.json")[..],
|
||||||
)?),
|
)?),
|
||||||
|
|
||||||
@@ -132,7 +152,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
|||||||
// 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::statemint::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::statemint::StatemineChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/statemine.json")[..],
|
&include_bytes!("../../parachains/chain-specs/statemine.json")[..],
|
||||||
)?),
|
)?),
|
||||||
|
|
||||||
@@ -142,7 +162,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
|||||||
// 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::statemint::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::statemint::WestmintChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/westmint.json")[..],
|
&include_bytes!("../../parachains/chain-specs/westmint.json")[..],
|
||||||
)?),
|
)?),
|
||||||
|
|
||||||
@@ -151,10 +171,12 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
|||||||
Box::new(chain_spec::collectives::collectives_polkadot_development_config()),
|
Box::new(chain_spec::collectives::collectives_polkadot_development_config()),
|
||||||
"collectives-polkadot-local" =>
|
"collectives-polkadot-local" =>
|
||||||
Box::new(chain_spec::collectives::collectives_polkadot_local_config()),
|
Box::new(chain_spec::collectives::collectives_polkadot_local_config()),
|
||||||
"collectives-polkadot" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"collectives-polkadot" =>
|
||||||
|
Box::new(chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/collectives-polkadot.json")[..],
|
&include_bytes!("../../parachains/chain-specs/collectives-polkadot.json")[..],
|
||||||
)?),
|
)?),
|
||||||
"collectives-westend" => Box::new(chain_spec::ChainSpec::from_json_bytes(
|
"collectives-westend" =>
|
||||||
|
Box::new(chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/collectives-westend.json")[..],
|
&include_bytes!("../../parachains/chain-specs/collectives-westend.json")[..],
|
||||||
)?),
|
)?),
|
||||||
|
|
||||||
@@ -164,9 +186,12 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
|||||||
"contracts-rococo-local" =>
|
"contracts-rococo-local" =>
|
||||||
Box::new(chain_spec::contracts::contracts_rococo_local_config()),
|
Box::new(chain_spec::contracts::contracts_rococo_local_config()),
|
||||||
"contracts-rococo-genesis" => Box::new(chain_spec::contracts::contracts_rococo_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::contracts::ContractsRococoChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../../parachains/chain-specs/contracts-rococo.json")[..],
|
&include_bytes!("../../parachains/chain-specs/contracts-rococo.json")[..],
|
||||||
)?),
|
)?),
|
||||||
|
|
||||||
|
// -- Penpall
|
||||||
"penpal-kusama" => Box::new(chain_spec::penpal::get_penpal_chain_spec(
|
"penpal-kusama" => Box::new(chain_spec::penpal::get_penpal_chain_spec(
|
||||||
para_id.expect("Must specify parachain id"),
|
para_id.expect("Must specify parachain id"),
|
||||||
"kusama-local",
|
"kusama-local",
|
||||||
@@ -177,34 +202,35 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
|||||||
)),
|
)),
|
||||||
|
|
||||||
// -- Fallback (generic chainspec)
|
// -- Fallback (generic chainspec)
|
||||||
"" => Box::new(chain_spec::get_chain_spec()),
|
"" => {
|
||||||
|
log::warn!("No ChainSpec.id specified, so using default one, based on rococo-parachain runtime");
|
||||||
|
Box::new(chain_spec::rococo_parachain::rococo_parachain_local_config())
|
||||||
|
},
|
||||||
|
|
||||||
// -- 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 path: PathBuf = path.into();
|
||||||
match chain_spec.runtime() {
|
match path.runtime() {
|
||||||
Runtime::Statemint => Box::new(
|
Runtime::Statemint =>
|
||||||
chain_spec::statemint::StatemintChainSpec::from_json_file(path.into())?,
|
Box::new(chain_spec::statemint::StatemintChainSpec::from_json_file(path)?),
|
||||||
),
|
Runtime::Statemine =>
|
||||||
Runtime::Statemine => Box::new(
|
Box::new(chain_spec::statemint::StatemineChainSpec::from_json_file(path)?),
|
||||||
chain_spec::statemint::StatemineChainSpec::from_json_file(path.into())?,
|
|
||||||
),
|
|
||||||
Runtime::Westmint =>
|
Runtime::Westmint =>
|
||||||
Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path.into())?),
|
Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path)?),
|
||||||
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend =>
|
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => Box::new(
|
||||||
Box::new(chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_file(
|
chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_file(path)?,
|
||||||
path.into(),
|
|
||||||
)?),
|
|
||||||
Runtime::Shell =>
|
|
||||||
Box::new(chain_spec::shell::ShellChainSpec::from_json_file(path.into())?),
|
|
||||||
Runtime::Seedling =>
|
|
||||||
Box::new(chain_spec::seedling::SeedlingChainSpec::from_json_file(path.into())?),
|
|
||||||
Runtime::ContractsRococo => Box::new(
|
|
||||||
chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path.into())?,
|
|
||||||
),
|
),
|
||||||
|
Runtime::Shell =>
|
||||||
|
Box::new(chain_spec::shell::ShellChainSpec::from_json_file(path)?),
|
||||||
|
Runtime::Seedling =>
|
||||||
|
Box::new(chain_spec::seedling::SeedlingChainSpec::from_json_file(path)?),
|
||||||
|
Runtime::ContractsRococo =>
|
||||||
|
Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?),
|
||||||
Runtime::Penpal(_para_id) =>
|
Runtime::Penpal(_para_id) =>
|
||||||
Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path.into())?),
|
Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?),
|
||||||
Runtime::Generic => Box::new(chain_spec),
|
Runtime::Default => Box::new(
|
||||||
|
chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_file(path)?,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -263,7 +289,7 @@ impl SubstrateCli for Cli {
|
|||||||
2017
|
2017
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||||
load_spec(id)
|
load_spec(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +304,7 @@ impl SubstrateCli for Cli {
|
|||||||
Runtime::Seedling => &seedling_runtime::VERSION,
|
Runtime::Seedling => &seedling_runtime::VERSION,
|
||||||
Runtime::ContractsRococo => &contracts_rococo_runtime::VERSION,
|
Runtime::ContractsRococo => &contracts_rococo_runtime::VERSION,
|
||||||
Runtime::Penpal(_) => &penpal_runtime::VERSION,
|
Runtime::Penpal(_) => &penpal_runtime::VERSION,
|
||||||
Runtime::Generic => &rococo_parachain_runtime::VERSION,
|
Runtime::Default => &rococo_parachain_runtime::VERSION,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,7 +340,7 @@ impl SubstrateCli for RelayChainCli {
|
|||||||
2017
|
2017
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||||
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
|
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,7 +460,7 @@ macro_rules! construct_async_run {
|
|||||||
{ $( $code )* }.map(|v| (v, task_manager))
|
{ $( $code )* }.map(|v| (v, task_manager))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Runtime::Penpal(_) | Runtime::Generic => {
|
Runtime::Penpal(_) | Runtime::Default => {
|
||||||
runner.async_run(|$config| {
|
runner.async_run(|$config| {
|
||||||
let $components = new_partial::<
|
let $components = new_partial::<
|
||||||
rococo_parachain_runtime::RuntimeApi,
|
rococo_parachain_runtime::RuntimeApi,
|
||||||
@@ -700,7 +726,7 @@ pub fn run() -> Result<()> {
|
|||||||
.await
|
.await
|
||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
Runtime::Penpal(_) | Runtime::Generic =>
|
Runtime::Penpal(_) | Runtime::Default =>
|
||||||
crate::service::start_rococo_parachain_node(
|
crate::service::start_rococo_parachain_node(
|
||||||
config,
|
config,
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
@@ -853,3 +879,118 @@ impl CliConfiguration<Self> for RelayChainCli {
|
|||||||
self.base.base.node_name()
|
self.base.base.node_name()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{
|
||||||
|
chain_spec::{get_account_id_from_seed, get_from_seed},
|
||||||
|
command::{Runtime, RuntimeResolver},
|
||||||
|
};
|
||||||
|
use sc_chain_spec::{ChainSpec, ChainSpecExtension, ChainSpecGroup, ChainType, Extension};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sp_core::sr25519;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use tempfile::TempDir;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension, Default,
|
||||||
|
)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct Extensions1 {
|
||||||
|
pub attribute1: String,
|
||||||
|
pub attribute2: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension, Default,
|
||||||
|
)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct Extensions2 {
|
||||||
|
pub attribute_x: String,
|
||||||
|
pub attribute_y: String,
|
||||||
|
pub attribute_z: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn store_configuration(dir: &TempDir, spec: Box<dyn ChainSpec>) -> PathBuf {
|
||||||
|
let raw_output = true;
|
||||||
|
let json = sc_service::chain_ops::build_spec(&*spec, raw_output)
|
||||||
|
.expect("Failed to build json string");
|
||||||
|
let mut cfg_file_path = dir.path().to_path_buf();
|
||||||
|
cfg_file_path.push(spec.id());
|
||||||
|
cfg_file_path.set_extension("json");
|
||||||
|
std::fs::write(&cfg_file_path, json).expect("Failed to write to json file");
|
||||||
|
cfg_file_path
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type DummyChainSpec<E> =
|
||||||
|
sc_service::GenericChainSpec<rococo_parachain_runtime::GenesisConfig, E>;
|
||||||
|
|
||||||
|
pub fn create_default_with_extensions<E: Extension>(
|
||||||
|
id: &str,
|
||||||
|
extension: E,
|
||||||
|
) -> DummyChainSpec<E> {
|
||||||
|
DummyChainSpec::from_genesis(
|
||||||
|
"Dummy local testnet",
|
||||||
|
id,
|
||||||
|
ChainType::Local,
|
||||||
|
move || {
|
||||||
|
crate::chain_spec::rococo_parachain::testnet_genesis(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
vec![
|
||||||
|
get_from_seed::<rococo_parachain_runtime::AuraId>("Alice"),
|
||||||
|
get_from_seed::<rococo_parachain_runtime::AuraId>("Bob"),
|
||||||
|
],
|
||||||
|
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
|
||||||
|
1000.into(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
Vec::new(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
extension,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_resolve_runtime_for_different_configuration_files() {
|
||||||
|
let temp_dir = tempfile::tempdir().expect("Failed to access tempdir");
|
||||||
|
|
||||||
|
let path = store_configuration(
|
||||||
|
&temp_dir,
|
||||||
|
Box::new(create_default_with_extensions("shell-1", Extensions1::default())),
|
||||||
|
);
|
||||||
|
assert_eq!(Runtime::Shell, path.runtime());
|
||||||
|
|
||||||
|
let path = store_configuration(
|
||||||
|
&temp_dir,
|
||||||
|
Box::new(create_default_with_extensions("shell-2", Extensions2::default())),
|
||||||
|
);
|
||||||
|
assert_eq!(Runtime::Shell, path.runtime());
|
||||||
|
|
||||||
|
let path = store_configuration(
|
||||||
|
&temp_dir,
|
||||||
|
Box::new(create_default_with_extensions("seedling", Extensions2::default())),
|
||||||
|
);
|
||||||
|
assert_eq!(Runtime::Seedling, path.runtime());
|
||||||
|
|
||||||
|
let path = store_configuration(
|
||||||
|
&temp_dir,
|
||||||
|
Box::new(crate::chain_spec::rococo_parachain::rococo_parachain_local_config()),
|
||||||
|
);
|
||||||
|
assert_eq!(Runtime::Default, path.runtime());
|
||||||
|
|
||||||
|
let path = store_configuration(
|
||||||
|
&temp_dir,
|
||||||
|
Box::new(crate::chain_spec::statemint::statemine_local_config()),
|
||||||
|
);
|
||||||
|
assert_eq!(Runtime::Statemine, path.runtime());
|
||||||
|
|
||||||
|
let path = store_configuration(
|
||||||
|
&temp_dir,
|
||||||
|
Box::new(crate::chain_spec::contracts::contracts_rococo_local_config()),
|
||||||
|
);
|
||||||
|
assert_eq!(Runtime::ContractsRococo, path.runtime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -69,21 +69,6 @@ type HostFunctions = sp_io::SubstrateHostFunctions;
|
|||||||
type HostFunctions =
|
type HostFunctions =
|
||||||
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);
|
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);
|
||||||
|
|
||||||
/// Native executor instance.
|
|
||||||
pub struct RococoParachainRuntimeExecutor;
|
|
||||||
|
|
||||||
impl sc_executor::NativeExecutionDispatch for RococoParachainRuntimeExecutor {
|
|
||||||
type ExtendHostFunctions = ();
|
|
||||||
|
|
||||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
|
||||||
rococo_parachain_runtime::api::dispatch(method, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn native_version() -> sc_executor::NativeVersion {
|
|
||||||
rococo_parachain_runtime::native_version()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Native executor instance.
|
/// Native executor instance.
|
||||||
pub struct ShellRuntimeExecutor;
|
pub struct ShellRuntimeExecutor;
|
||||||
|
|
||||||
@@ -99,21 +84,6 @@ impl sc_executor::NativeExecutionDispatch for ShellRuntimeExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Native executor instance.
|
|
||||||
pub struct SeedlingRuntimeExecutor;
|
|
||||||
|
|
||||||
impl sc_executor::NativeExecutionDispatch for SeedlingRuntimeExecutor {
|
|
||||||
type ExtendHostFunctions = ();
|
|
||||||
|
|
||||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
|
||||||
seedling_runtime::api::dispatch(method, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn native_version() -> sc_executor::NativeVersion {
|
|
||||||
seedling_runtime::native_version()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Native Statemint executor instance.
|
// Native Statemint executor instance.
|
||||||
pub struct StatemintRuntimeExecutor;
|
pub struct StatemintRuntimeExecutor;
|
||||||
|
|
||||||
@@ -174,21 +144,6 @@ impl sc_executor::NativeExecutionDispatch for CollectivesPolkadotRuntimeExecutor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Native Contracts on Rococo executor instance.
|
|
||||||
pub struct ContractsRococoRuntimeExecutor;
|
|
||||||
|
|
||||||
impl sc_executor::NativeExecutionDispatch for ContractsRococoRuntimeExecutor {
|
|
||||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
|
||||||
|
|
||||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
|
||||||
contracts_rococo_runtime::api::dispatch(method, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn native_version() -> sc_executor::NativeVersion {
|
|
||||||
contracts_rococo_runtime::native_version()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Starts a `ServiceBuilder` for a full service.
|
/// Starts a `ServiceBuilder` for a full service.
|
||||||
///
|
///
|
||||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||||
|
|||||||
Reference in New Issue
Block a user