diff --git a/Cargo.lock b/Cargo.lock index 40f976cd4a8..8c98c2e9e1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6133,6 +6133,29 @@ dependencies = [ "serde", ] +[[package]] +name = "parachains-common" +version = "1.0.0" +dependencies = [ + "frame-executive", + "frame-support", + "frame-system", + "node-primitives", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "parity-scale-codec", + "polkadot-primitives", + "polkadot-runtime-common", + "serde", + "sp-consensus-aura", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", +] + [[package]] name = "parity-db" version = "0.3.1" @@ -6696,6 +6719,8 @@ dependencies = [ "jsonrpc-core", "log", "nix", + "pallet-transaction-payment-rpc", + "parachains-common", "parity-scale-codec", "parking_lot 0.10.2", "polkadot-cli", @@ -6717,6 +6742,7 @@ dependencies = [ "sc-telemetry", "sc-tracing", "sc-transaction-pool", + "sc-transaction-pool-api", "serde", "shell-runtime", "sp-api", @@ -6734,10 +6760,10 @@ dependencies = [ "sp-timestamp", "sp-transaction-pool", "statemine-runtime", - "statemint-common", "statemint-runtime", "structopt", "substrate-build-script-utils", + "substrate-frame-rpc-system", "substrate-prometheus-endpoint", "tempfile", "tokio 0.2.24", @@ -8649,6 +8675,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", + "frame-system-rpc-runtime-api", "hex", "hex-literal 0.3.3", "log", @@ -8659,6 +8686,7 @@ dependencies = [ "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", "pallet-xcm", "parachain-info", "parity-scale-codec", @@ -11136,6 +11164,7 @@ dependencies = [ "pallet-utility", "pallet-xcm", "parachain-info", + "parachains-common", "parity-scale-codec", "polkadot-parachain", "polkadot-runtime-common", @@ -11153,36 +11182,12 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "statemint-common", "substrate-wasm-builder", "xcm", "xcm-builder", "xcm-executor", ] -[[package]] -name = "statemint-common" -version = "1.0.0" -dependencies = [ - "frame-executive", - "frame-support", - "frame-system", - "node-primitives", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "parity-scale-codec", - "polkadot-primitives", - "polkadot-runtime-common", - "serde", - "sp-consensus-aura", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", -] - [[package]] name = "statemint-runtime" version = "1.0.0" @@ -11224,6 +11229,7 @@ dependencies = [ "pallet-utility", "pallet-xcm", "parachain-info", + "parachains-common", "parity-scale-codec", "polkadot-parachain", "polkadot-runtime-common", @@ -11241,7 +11247,6 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "statemint-common", "substrate-wasm-builder", "xcm", "xcm-builder", @@ -12931,6 +12936,7 @@ dependencies = [ "pallet-utility", "pallet-xcm", "parachain-info", + "parachains-common", "parity-scale-codec", "polkadot-parachain", "polkadot-runtime-common", @@ -12948,7 +12954,6 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "statemint-common", "substrate-wasm-builder", "xcm", "xcm-builder", diff --git a/Cargo.toml b/Cargo.toml index ae84d34ea5c..7917dc11817 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ members = [ "polkadot-parachains/pallets/ping", "polkadot-parachains/rococo", "polkadot-parachains/shell", - "polkadot-parachains/statemint-common", + "polkadot-parachains/parachains-common", "polkadot-parachains/statemint", "polkadot-parachains/statemine", "polkadot-parachains/westmint", diff --git a/polkadot-parachains/Cargo.toml b/polkadot-parachains/Cargo.toml index fc142b46a89..f2f5339e9d4 100644 --- a/polkadot-parachains/Cargo.toml +++ b/polkadot-parachains/Cargo.toml @@ -28,7 +28,7 @@ shell-runtime = { path = "shell" } statemint-runtime = { path = "statemint" } statemine-runtime = { path = "statemine" } westmint-runtime = { path = "westmint" } -statemint-common = { path = "statemint-common" } +parachains-common = { path = "parachains-common" } # Substrate dependencies frame-benchmarking = { git = 'https://github.com/paritytech/substrate', branch = "master" } @@ -64,6 +64,9 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate # RPC related dependencies jsonrpc-core = "15.1.0" +sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" } +frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } # Cumulus dependencies cumulus-client-cli = { path = "../client/cli" } diff --git a/polkadot-parachains/statemint-common/Cargo.toml b/polkadot-parachains/parachains-common/Cargo.toml similarity index 96% rename from polkadot-parachains/statemint-common/Cargo.toml rename to polkadot-parachains/parachains-common/Cargo.toml index 683cb2197eb..9ab9d6c4abb 100644 --- a/polkadot-parachains/statemint-common/Cargo.toml +++ b/polkadot-parachains/parachains-common/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "statemint-common" +name = "parachains-common" version = "1.0.0" authors = ["Parity Technologies "] edition = "2018" -description = "Logic which is common to all Statemint variant runtimes" +description = "Logic which is common to all parachain runtimes" [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] diff --git a/polkadot-parachains/statemint-common/src/impls.rs b/polkadot-parachains/parachains-common/src/impls.rs similarity index 94% rename from polkadot-parachains/statemint-common/src/impls.rs rename to polkadot-parachains/parachains-common/src/impls.rs index 31c433b34fd..a03a8eb5c6b 100644 --- a/polkadot-parachains/statemint-common/src/impls.rs +++ b/polkadot-parachains/parachains-common/src/impls.rs @@ -13,12 +13,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Auxillary struct/enums for Statemint runtime. -//! Taken from polkadot/runtime/common (at a21cd64) and adapted for Statemint. +//! Auxillary struct/enums for parachain runtimes. +//! Taken from polkadot/runtime/common (at a21cd64) and adapted for parachains. use frame_support::traits::{Currency, Imbalance, OnUnbalanced}; -pub type NegativeImbalance = as Currency<::AccountId>>::NegativeImbalance; +pub type NegativeImbalance = as Currency< + ::AccountId, +>>::NegativeImbalance; /// Logic for the author to get a portion of fees. pub struct ToStakingPot(sp_std::marker::PhantomData); @@ -32,10 +34,7 @@ where fn on_nonzero_unbalanced(amount: NegativeImbalance) { let numeric_amount = amount.peek(); let staking_pot = >::account_id(); - >::resolve_creating( - &staking_pot, - amount, - ); + >::resolve_creating(&staking_pot, amount); >::deposit_event(pallet_balances::Event::Deposit( staking_pot, numeric_amount, @@ -64,9 +63,13 @@ where #[cfg(test)] mod tests { use super::*; - use frame_support::traits::FindAuthor; - use frame_support::{parameter_types, PalletId, traits::ValidatorRegistration}; + use frame_support::{ + parameter_types, + traits::{FindAuthor, ValidatorRegistration}, + PalletId, + }; use frame_system::{limits, EnsureRoot}; + use pallet_collator_selection::IdentityCollator; use polkadot_primitives::v1::AccountId; use sp_core::H256; use sp_runtime::{ @@ -74,7 +77,6 @@ mod tests { traits::{BlakeTwo256, IdentityLookup}, Perbill, }; - use pallet_collator_selection::IdentityCollator; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/polkadot-parachains/statemint-common/src/lib.rs b/polkadot-parachains/parachains-common/src/lib.rs similarity index 76% rename from polkadot-parachains/statemint-common/src/lib.rs rename to polkadot-parachains/parachains-common/src/lib.rs index 8f048cde3ba..a9462f00095 100644 --- a/polkadot-parachains/statemint-common/src/lib.rs +++ b/polkadot-parachains/parachains-common/src/lib.rs @@ -16,12 +16,12 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod impls; -pub use types::*; pub use constants::*; - -/// Common types of statemint and statemine. +pub use opaque::*; +pub use types::*; +/// Common types of parachains. mod types { - use sp_runtime::traits::{Verify, IdentifyAccount, BlakeTwo256}; + use sp_runtime::traits::{IdentifyAccount, Verify}; /// An index to a block. pub type BlockNumber = u32; @@ -46,21 +46,18 @@ mod types { /// A hash of some data used by the chain. pub type Hash = sp_core::H256; - /// Block header type as expected by this runtime. - pub type Header = sp_runtime::generic::Header; - /// Digest item type. pub type DigestItem = sp_runtime::generic::DigestItem; - + // Aura consensus authority. pub type AuraId = sp_consensus_aura::sr25519::AuthorityId; } -/// Common constants of statemint and statemine +/// Common constants of parachains. mod constants { use super::types::BlockNumber; + use frame_support::weights::{constants::WEIGHT_PER_SECOND, Weight}; use sp_runtime::Perbill; - use frame_support::weights::{Weight, constants::WEIGHT_PER_SECOND}; /// This determines the average expected block time that we are targeting. Blocks will be /// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by /// `pallet_timestamp` which is in turn picked up by `pallet_aura` to implement `fn @@ -85,3 +82,20 @@ mod constants { /// We allow for 0.5 seconds of compute with a 6 second average block time. pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2; } + +/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know +/// the specifics of the runtime. They can then be made to be agnostic over specific formats +/// of data like extrinsics, allowing for them to continue syncing the network through upgrades +/// to even the core data structures. +pub mod opaque { + use super::*; + use sp_runtime::{generic, traits::BlakeTwo256}; + + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; + /// Opaque block header type. + pub type Header = generic::Header; + /// Opaque block type. + pub type Block = generic::Block; + /// Opaque block identifier type. + pub type BlockId = generic::BlockId; +} diff --git a/polkadot-parachains/rococo/Cargo.toml b/polkadot-parachains/rococo/Cargo.toml index b118ac416fa..e7312f2f2a3 100644 --- a/polkadot-parachains/rococo/Cargo.toml +++ b/polkadot-parachains/rococo/Cargo.toml @@ -28,6 +28,7 @@ sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-f frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -35,6 +36,7 @@ pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-fe pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } # Cumulus dependencies cumulus-pallet-aura-ext = { path = "../../pallets/aura-ext", default-features = false } diff --git a/polkadot-parachains/rococo/src/lib.rs b/polkadot-parachains/rococo/src/lib.rs index 6050c8f94d3..0daab9df615 100644 --- a/polkadot-parachains/rococo/src/lib.rs +++ b/polkadot-parachains/rococo/src/lib.rs @@ -590,6 +590,27 @@ impl_runtime_apis! { } } + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Index { + System::account_nonce(account) + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { + fn query_info( + uxt: ::Extrinsic, + len: u32, + ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { + TransactionPayment::query_info(uxt, len) + } + fn query_fee_details( + uxt: ::Extrinsic, + len: u32, + ) -> pallet_transaction_payment::FeeDetails { + TransactionPayment::query_fee_details(uxt, len) + } + } + impl cumulus_primitives_core::CollectCollationInfo for Runtime { fn collect_collation_info() -> cumulus_primitives_core::CollationInfo { ParachainSystem::collect_collation_info() diff --git a/polkadot-parachains/src/chain_spec.rs b/polkadot-parachains/src/chain_spec.rs index 780d56a6426..f1cce9fedc5 100644 --- a/polkadot-parachains/src/chain_spec.rs +++ b/polkadot-parachains/src/chain_spec.rs @@ -24,7 +24,8 @@ 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; +pub type ChainSpec = + sc_service::GenericChainSpec; /// Specialized `ChainSpec` for the shell parachain runtime. pub type ShellChainSpec = sc_service::GenericChainSpec; @@ -56,7 +57,8 @@ impl Extensions { type AccountPublic = ::Signer; /// Helper function to generate an account ID from seed -pub fn get_account_id_from_seed(seed: &str) -> AccountId where +pub fn get_account_id_from_seed(seed: &str) -> AccountId +where AccountPublic: From<::Public>, { AccountPublic::from(get_from_seed::(seed)).into_account() @@ -195,12 +197,15 @@ fn shell_testnet_genesis(parachain_id: ParaId) -> shell_runtime::GenesisConfig { } } -use statemint_common::Balance as StatemintBalance; +use parachains_common::Balance as StatemintBalance; /// Specialized `ChainSpec` for the normal parachain runtime. -pub type StatemintChainSpec = sc_service::GenericChainSpec; -pub type StatemineChainSpec = sc_service::GenericChainSpec; -pub type WestmintChainSpec = sc_service::GenericChainSpec; +pub type StatemintChainSpec = + sc_service::GenericChainSpec; +pub type StatemineChainSpec = + sc_service::GenericChainSpec; +pub type WestmintChainSpec = + sc_service::GenericChainSpec; const STATEMINT_ED: StatemintBalance = statemint_runtime::constants::currency::EXISTENTIAL_DEPOSIT; const STATEMINE_ED: StatemintBalance = statemine_runtime::constants::currency::EXISTENTIAL_DEPOSIT; @@ -223,22 +228,22 @@ pub fn get_collator_keys_from_seed(seed: &str) -> AuraId { /// 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). -pub fn statemint_session_keys(keys: AuraId) -> statemint_runtime::opaque::SessionKeys { - statemint_runtime::opaque::SessionKeys { aura: keys } +pub fn statemint_session_keys(keys: AuraId) -> statemint_runtime::SessionKeys { + statemint_runtime::SessionKeys { aura: keys } } /// 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). -pub fn statemine_session_keys(keys: AuraId) -> statemine_runtime::opaque::SessionKeys { - statemine_runtime::opaque::SessionKeys { aura: keys } +pub fn statemine_session_keys(keys: AuraId) -> statemine_runtime::SessionKeys { + statemine_runtime::SessionKeys { aura: keys } } /// 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). -pub fn westmint_session_keys(keys: AuraId) -> westmint_runtime::opaque::SessionKeys { - westmint_runtime::opaque::SessionKeys { aura: keys } +pub fn westmint_session_keys(keys: AuraId) -> westmint_runtime::SessionKeys { + westmint_runtime::SessionKeys { aura: keys } } pub fn statemint_development_config(id: ParaId) -> StatemintChainSpec { @@ -255,12 +260,10 @@ pub fn statemint_development_config(id: ParaId) -> StatemintChainSpec { move || { statemint_genesis( // initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), - ) - ], + vec![( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + )], vec![ get_account_id_from_seed::("Alice"), get_account_id_from_seed::("Bob"), @@ -295,14 +298,15 @@ pub fn statemint_local_config(id: ParaId) -> StatemintChainSpec { move || { statemint_genesis( // initial collators. - vec![( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice") - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob") - ), + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed("Bob"), + ), ], vec![ get_account_id_from_seed::("Alice"), @@ -358,11 +362,17 @@ fn statemint_genesis( ..Default::default() }, session: statemint_runtime::SessionConfig { - keys: invulnerables.iter().cloned().map(|(acc, aura)| ( - acc.clone(), // account id - acc.clone(), // validator id - statemint_session_keys(aura), // session keys - )).collect() + keys: invulnerables + .iter() + .cloned() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc.clone(), // validator id + statemint_session_keys(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. @@ -386,12 +396,10 @@ pub fn statemine_development_config(id: ParaId) -> StatemineChainSpec { move || { statemine_genesis( // initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), - ) - ], + vec![( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + )], vec![ get_account_id_from_seed::("Alice"), get_account_id_from_seed::("Bob"), @@ -426,14 +434,15 @@ pub fn statemine_local_config(id: ParaId) -> StatemineChainSpec { move || { statemine_genesis( // initial collators. - vec![( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice") - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob") - ), + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed("Bob"), + ), ], vec![ get_account_id_from_seed::("Alice"), @@ -477,22 +486,31 @@ pub fn statemine_config(id: ParaId) -> StatemineChainSpec { move || { statemine_genesis( // initial collators. - vec![( - hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730").into(), - hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730").unchecked_into() - ), - ( - hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a").into(), - hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a").unchecked_into() - ), - ( - hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a").into(), - hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a").unchecked_into() - ), - ( - hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415").into(), - hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415").unchecked_into() - ), + vec![ + ( + hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730") + .into(), + hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730") + .unchecked_into(), + ), + ( + hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a") + .into(), + hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a") + .unchecked_into(), + ), + ( + hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a") + .into(), + hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a") + .unchecked_into(), + ), + ( + hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415") + .into(), + hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415") + .unchecked_into(), + ), ], vec![], id, @@ -535,11 +553,17 @@ fn statemine_genesis( ..Default::default() }, session: statemine_runtime::SessionConfig { - keys: invulnerables.iter().cloned().map(|(acc, aura)| ( - acc.clone(), // account id - acc.clone(), // validator id - statemine_session_keys(aura), // session keys - )).collect() + keys: invulnerables + .iter() + .cloned() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc.clone(), // validator id + statemine_session_keys(aura), // session keys + ) + }) + .collect(), }, aura: Default::default(), aura_ext: Default::default(), @@ -561,12 +585,10 @@ pub fn westmint_development_config(id: ParaId) -> WestmintChainSpec { move || { westmint_genesis( // initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), - ) - ], + vec![( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + )], vec![ get_account_id_from_seed::("Alice"), get_account_id_from_seed::("Bob"), @@ -602,14 +624,15 @@ pub fn westmint_local_config(id: ParaId) -> WestmintChainSpec { move || { westmint_genesis( // initial collators. - vec![( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice") - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob") - ), + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed("Bob"), + ), ], vec![ get_account_id_from_seed::("Alice"), @@ -654,22 +677,31 @@ pub fn westmint_config(id: ParaId) -> WestmintChainSpec { move || { westmint_genesis( // initial collators. - vec![( - hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325").into(), - hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325").unchecked_into() - ), - ( - hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876").into(), - hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876").unchecked_into() - ), - ( - hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f").into(), - hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f").unchecked_into() - ), - ( - hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322").into(), - hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322").unchecked_into() - ), + vec![ + ( + hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325") + .into(), + hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325") + .unchecked_into(), + ), + ( + hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876") + .into(), + hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876") + .unchecked_into(), + ), + ( + hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f") + .into(), + hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f") + .unchecked_into(), + ), + ( + hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322") + .into(), + hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322") + .unchecked_into(), + ), ], vec![], // re-use the Westend sudo key @@ -716,11 +748,17 @@ fn westmint_genesis( ..Default::default() }, session: westmint_runtime::SessionConfig { - keys: invulnerables.iter().cloned().map(|(acc, aura)| ( - acc.clone(), // account id - acc.clone(), // validator id - westmint_session_keys(aura), // session keys - )).collect() + keys: invulnerables + .iter() + .cloned() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc.clone(), // validator id + westmint_session_keys(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. diff --git a/polkadot-parachains/src/main.rs b/polkadot-parachains/src/main.rs index 7d02fd46489..d114d2f5f2c 100644 --- a/polkadot-parachains/src/main.rs +++ b/polkadot-parachains/src/main.rs @@ -24,6 +24,7 @@ mod chain_spec; mod service; mod cli; mod command; +mod rpc; fn main() -> sc_cli::Result<()> { command::run() diff --git a/polkadot-parachains/src/rpc.rs b/polkadot-parachains/src/rpc.rs new file mode 100644 index 00000000000..231b257061d --- /dev/null +++ b/polkadot-parachains/src/rpc.rs @@ -0,0 +1,80 @@ +// Copyright 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 . + +//! Parachain-specific RPCs implementation. + +#![warn(missing_docs)] + +use std::sync::Arc; + +use sc_client_api::AuxStore; +pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; +use sc_transaction_pool_api::TransactionPool; +use sp_api::ProvideRuntimeApi; +use sp_block_builder::BlockBuilder; +use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; + +use parachains_common::{AccountId, Balance, Block, Index as Nonce}; + +/// A type representing all RPC extensions. +pub type RpcExtension = jsonrpc_core::IoHandler; + +/// Full client dependencies +pub struct FullDeps { + /// The client instance to use. + pub client: Arc, + /// Transaction pool instance. + pub pool: Arc

, + /// Whether to deny unsafe calls + pub deny_unsafe: DenyUnsafe, +} + +/// Instantiate all RPC extensions. +pub fn create_full(deps: FullDeps) -> RpcExtension +where + C: ProvideRuntimeApi + + HeaderBackend + + AuxStore + + HeaderMetadata + + Send + + Sync + + 'static, + C::Api: frame_rpc_system::AccountNonceApi, + C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + C::Api: BlockBuilder, + P: TransactionPool + Sync + Send + 'static, +{ + use frame_rpc_system::{FullSystem, SystemApi}; + use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; + + let mut io = jsonrpc_core::IoHandler::default(); + let FullDeps { + client, + pool, + deny_unsafe, + } = deps; + + io.extend_with(SystemApi::to_delegate(FullSystem::new( + client.clone(), + pool, + deny_unsafe, + ))); + io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new( + client.clone(), + ))); + + io +} diff --git a/polkadot-parachains/src/service.rs b/polkadot-parachains/src/service.rs index 9268b64a7fb..8c51971002a 100644 --- a/polkadot-parachains/src/service.rs +++ b/polkadot-parachains/src/service.rs @@ -13,7 +13,6 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . - use cumulus_client_consensus_aura::{ build_aura_consensus, BuildAuraConsensusParams, SlotProportion, }; @@ -29,6 +28,9 @@ use cumulus_primitives_core::{ ParaId, }; +use crate::rpc; +pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; + use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; use futures::lock::Mutex; use sc_client_api::ExecutorProvider; @@ -37,6 +39,7 @@ use sc_consensus::{ BlockImportParams, }; use sc_executor::native_executor_instance; +pub use sc_executor::NativeExecutor; use sc_network::NetworkService; use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; @@ -51,13 +54,6 @@ use sp_runtime::{ use std::sync::Arc; use substrate_prometheus_endpoint::Registry; -pub use sc_executor::NativeExecutor; - -type BlockNumber = u32; -type Header = sp_runtime::generic::Header; -pub type Block = sp_runtime::generic::Block; -type Hash = sp_core::H256; - // Native executor instance. native_executor_instance!( pub RococoParachainRuntimeExecutor, @@ -193,11 +189,11 @@ where Ok(params) } -/// Start a node with the given parachain `Configuration` and relay chain `Configuration`. +/// Start a shell node with the given parachain `Configuration` and relay chain `Configuration`. /// -/// This is the actual implementation that is abstract over the executor and the runtime api. +/// This is the actual implementation that is abstract over the executor and the runtime api for shell nodes. #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_shell_node_impl( parachain_config: Configuration, polkadot_config: Configuration, id: ParaId, @@ -358,6 +354,185 @@ where Ok((task_manager, client)) } +/// Start a node with the given parachain `Configuration` and relay chain `Configuration`. +/// +/// This is the actual implementation that is abstract over the executor and the runtime api. +#[sc_tracing::logging::prefix_logs_with("Parachain")] +async fn start_node_impl( + parachain_config: Configuration, + polkadot_config: Configuration, + id: ParaId, + _rpc_ext_builder: RB, + build_import_queue: BIQ, + build_consensus: BIC, +) -> sc_service::error::Result<(TaskManager, Arc>)> +where + RuntimeApi: ConstructRuntimeApi> + + Send + + Sync + + 'static, + RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + + sp_api::Metadata + + sp_session::SessionKeys + + sp_api::ApiExt< + Block, + StateBackend = sc_client_api::StateBackendFor, Block>, + > + sp_offchain::OffchainWorkerApi + + sp_block_builder::BlockBuilder + + cumulus_primitives_core::CollectCollationInfo + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + frame_rpc_system::AccountNonceApi, + sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, + Executor: sc_executor::NativeExecutionDispatch + 'static, + RB: Fn( + Arc>, + ) -> Result, sc_service::Error> + + Send + + 'static, + BIQ: FnOnce( + Arc>, + &Configuration, + Option, + &TaskManager, + ) -> Result< + sc_consensus::DefaultImportQueue>, + sc_service::Error, + > + 'static, + BIC: FnOnce( + Arc>, + Option<&Registry>, + Option, + &TaskManager, + &polkadot_service::NewFull, + Arc>>, + Arc>, + SyncCryptoStorePtr, + bool, + ) -> Result>, sc_service::Error>, +{ + if matches!(parachain_config.role, Role::Light) { + return Err("Light client not supported!".into()); + } + + let parachain_config = prepare_node_config(parachain_config); + + let params = new_partial::(¶chain_config, build_import_queue)?; + let (mut telemetry, telemetry_worker_handle) = params.other; + + let relay_chain_full_node = + cumulus_client_service::build_polkadot_full_node(polkadot_config, telemetry_worker_handle) + .map_err(|e| match e { + polkadot_service::Error::Sub(x) => x, + s => format!("{}", s).into(), + })?; + + let client = params.client.clone(); + let backend = params.backend.clone(); + let block_announce_validator = build_block_announce_validator( + relay_chain_full_node.client.clone(), + id, + Box::new(relay_chain_full_node.network.clone()), + relay_chain_full_node.backend.clone(), + ); + + let force_authoring = parachain_config.force_authoring; + let validator = parachain_config.role.is_authority(); + let prometheus_registry = parachain_config.prometheus_registry().cloned(); + let transaction_pool = params.transaction_pool.clone(); + let mut task_manager = params.task_manager; + let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue); + let (network, system_rpc_tx, start_network) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: ¶chain_config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue: import_queue.clone(), + on_demand: None, + block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)), + warp_sync: None, + })?; + + let rpc_extensions_builder = { + let client = client.clone(); + let transaction_pool = transaction_pool.clone(); + + Box::new(move |deny_unsafe, _| { + let deps = rpc::FullDeps { + client: client.clone(), + pool: transaction_pool.clone(), + deny_unsafe, + }; + + Ok(rpc::create_full(deps)) + }) + }; + + sc_service::spawn_tasks(sc_service::SpawnTasksParams { + on_demand: None, + remote_blockchain: None, + rpc_extensions_builder, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + task_manager: &mut task_manager, + config: parachain_config, + keystore: params.keystore_container.sync_keystore(), + backend: backend.clone(), + network: network.clone(), + system_rpc_tx, + telemetry: telemetry.as_mut(), + })?; + + let announce_block = { + let network = network.clone(); + Arc::new(move |hash, data| network.announce_block(hash, data)) + }; + + if validator { + let parachain_consensus = build_consensus( + client.clone(), + prometheus_registry.as_ref(), + telemetry.as_ref().map(|t| t.handle()), + &task_manager, + &relay_chain_full_node, + transaction_pool, + network, + params.keystore_container.sync_keystore(), + force_authoring, + )?; + + let spawner = task_manager.spawn_handle(); + + let params = StartCollatorParams { + para_id: id, + block_status: client.clone(), + announce_block, + client: client.clone(), + task_manager: &mut task_manager, + relay_chain_full_node, + spawner, + parachain_consensus, + import_queue, + }; + + start_collator(params).await?; + } else { + let params = StartFullNodeParams { + client: client.clone(), + announce_block, + task_manager: &mut task_manager, + para_id: id, + relay_chain_full_node, + }; + + start_full_node(params)?; + } + + start_network.start_network(); + + Ok((task_manager, client)) +} + /// Build the import queue for the rococo parachain runtime. pub fn rococo_parachain_build_import_queue( client: Arc< @@ -532,7 +707,7 @@ pub async fn start_shell_node( TaskManager, Arc>, )> { - start_node_impl::( + start_shell_node_impl::( parachain_config, polkadot_config, id, @@ -801,7 +976,9 @@ where > + sp_offchain::OffchainWorkerApi + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo - + sp_consensus_aura::AuraApi, + + sp_consensus_aura::AuraApi + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + frame_rpc_system::AccountNonceApi, sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, { diff --git a/polkadot-parachains/statemine/Cargo.toml b/polkadot-parachains/statemine/Cargo.toml index ac79b250f50..36218a6c89d 100644 --- a/polkadot-parachains/statemine/Cargo.toml +++ b/polkadot-parachains/statemine/Cargo.toml @@ -62,7 +62,7 @@ cumulus-pallet-xcm = { path = "../../pallets/xcm", default-features = false } cumulus-pallet-session-benchmarking = {path = "../../pallets/session-benchmarking", default-features = false, version = "3.0.0"} cumulus-ping = { path = "../pallets/ping", default-features = false } pallet-collator-selection = { path = "../../pallets/collator-selection", default-features = false } -statemint-common = { path = "../statemint-common", default-features = false } +parachains-common = { path = "../parachains-common", default-features = false } # Polkadot dependencies polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } @@ -149,5 +149,5 @@ std = [ "xcm-executor/std", "sp-consensus-aura/std", "node-primitives/std", - "statemint-common/std", + "parachains-common/std", ] diff --git a/polkadot-parachains/statemine/src/lib.rs b/polkadot-parachains/statemine/src/lib.rs index 453266a2666..77bfa28ae94 100644 --- a/polkadot-parachains/statemine/src/lib.rs +++ b/polkadot-parachains/statemine/src/lib.rs @@ -54,12 +54,13 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureOneOf, EnsureRoot, }; -use sp_runtime::Perbill; -pub use statemint_common as common; -use statemint_common::{ - impls::DealWithFees, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature, - AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, +pub use parachains_common as common; +use parachains_common::{ + impls::DealWithFees, opaque, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, + Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, + SLOT_DURATION, }; +use sp_runtime::Perbill; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -78,23 +79,9 @@ use xcm_builder::{ }; use xcm_executor::{Config, XcmExecutor}; -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. -pub mod opaque { - use super::*; - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - /// Opaque block header type. - pub type Header = generic::Header; - /// Opaque block type. - pub type Block = generic::Block; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId; - impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - } +impl_opaque_keys! { + pub struct SessionKeys { + pub aura: Aura, } } @@ -619,9 +606,8 @@ impl pallet_session::Config for Runtime { type NextSessionRotation = pallet_session::PeriodicSessions; type SessionManager = CollatorSelection; // Essentially just Aura, but lets be pedantic. - type SessionHandler = - ::KeyTypeIdProviders; - type Keys = opaque::SessionKeys; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; type DisabledValidatorsThreshold = DisabledValidatorsThreshold; type WeightInfo = weights::pallet_session::WeightInfo; } @@ -817,13 +803,13 @@ impl_runtime_apis! { impl sp_session::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { - opaque::SessionKeys::generate(seed) + SessionKeys::generate(seed) } fn decode_session_keys( encoded: Vec, ) -> Option, KeyTypeId)>> { - opaque::SessionKeys::decode_into_raw_public_keys(&encoded) + SessionKeys::decode_into_raw_public_keys(&encoded) } } diff --git a/polkadot-parachains/statemint/Cargo.toml b/polkadot-parachains/statemint/Cargo.toml index cb7269130b1..9027ad4ec28 100644 --- a/polkadot-parachains/statemint/Cargo.toml +++ b/polkadot-parachains/statemint/Cargo.toml @@ -62,7 +62,7 @@ cumulus-pallet-xcm = { path = "../../pallets/xcm", default-features = false } cumulus-pallet-session-benchmarking = { path = "../../pallets/session-benchmarking", default-features = false, version = "3.0.0" } cumulus-ping = { path = "../pallets/ping", default-features = false } pallet-collator-selection = { path = "../../pallets/collator-selection", default-features = false } -statemint-common = { path = "../statemint-common", default-features = false } +parachains-common = { path = "../parachains-common", default-features = false } # Polkadot dependencies polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } @@ -149,5 +149,5 @@ std = [ "xcm-executor/std", "sp-consensus-aura/std", "node-primitives/std", - "statemint-common/std", + "parachains-common/std", ] diff --git a/polkadot-parachains/statemint/src/lib.rs b/polkadot-parachains/statemint/src/lib.rs index fec6014434c..95871309496 100644 --- a/polkadot-parachains/statemint/src/lib.rs +++ b/polkadot-parachains/statemint/src/lib.rs @@ -54,12 +54,13 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureOneOf, EnsureRoot, }; -use sp_runtime::Perbill; -pub use statemint_common as common; -use statemint_common::{ - impls::DealWithFees, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature, - AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, +pub use parachains_common as common; +use parachains_common::{ + impls::DealWithFees, opaque, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, + Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, + SLOT_DURATION, }; +use sp_runtime::Perbill; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -78,23 +79,9 @@ use xcm_builder::{ }; use xcm_executor::{Config, XcmExecutor}; -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. -pub mod opaque { - use super::*; - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - /// Opaque block header type. - pub type Header = generic::Header; - /// Opaque block type. - pub type Block = generic::Block; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId; - impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - } +impl_opaque_keys! { + pub struct SessionKeys { + pub aura: Aura, } } @@ -327,10 +314,9 @@ impl InstanceFilter for ProxyType { fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, - ProxyType::NonTransfer => !matches!( - c, - Call::Balances(..) | Call::Assets(..) | Call::Uniques(..) - ), + ProxyType::NonTransfer => { + !matches!(c, Call::Balances(..) | Call::Assets(..) | Call::Uniques(..)) + } ProxyType::CancelProxy => matches!( c, Call::Proxy(pallet_proxy::Call::reject_announcement(..)) @@ -585,9 +571,8 @@ impl pallet_session::Config for Runtime { type NextSessionRotation = pallet_session::PeriodicSessions; type SessionManager = CollatorSelection; // Essentially just Aura, but lets be pedantic. - type SessionHandler = - ::KeyTypeIdProviders; - type Keys = opaque::SessionKeys; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; type DisabledValidatorsThreshold = DisabledValidatorsThreshold; type WeightInfo = weights::pallet_session::WeightInfo; } @@ -801,13 +786,13 @@ impl_runtime_apis! { impl sp_session::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { - opaque::SessionKeys::generate(seed) + SessionKeys::generate(seed) } fn decode_session_keys( encoded: Vec, ) -> Option, KeyTypeId)>> { - opaque::SessionKeys::decode_into_raw_public_keys(&encoded) + SessionKeys::decode_into_raw_public_keys(&encoded) } } diff --git a/polkadot-parachains/westmint/Cargo.toml b/polkadot-parachains/westmint/Cargo.toml index fdc4c5063c0..9cf94d12def 100644 --- a/polkadot-parachains/westmint/Cargo.toml +++ b/polkadot-parachains/westmint/Cargo.toml @@ -62,7 +62,7 @@ cumulus-pallet-xcm = { path = "../../pallets/xcm", default-features = false } cumulus-pallet-session-benchmarking = {path = "../../pallets/session-benchmarking", default-features = false, version = "3.0.0"} cumulus-ping = { path = "../pallets/ping", default-features = false } pallet-collator-selection = { path = "../../pallets/collator-selection", default-features = false } -statemint-common = { path = "../statemint-common", default-features = false } +parachains-common = { path = "../parachains-common", default-features = false } # Polkadot dependencies polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } @@ -149,5 +149,5 @@ std = [ "xcm-executor/std", "sp-consensus-aura/std", "node-primitives/std", - "statemint-common/std", + "parachains-common/std", ] diff --git a/polkadot-parachains/westmint/src/lib.rs b/polkadot-parachains/westmint/src/lib.rs index 240ee46bb3e..40321925071 100644 --- a/polkadot-parachains/westmint/src/lib.rs +++ b/polkadot-parachains/westmint/src/lib.rs @@ -54,12 +54,13 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; -use sp_runtime::Perbill; -pub use statemint_common as common; -use statemint_common::{ - impls::DealWithFees, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature, - AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, +pub use parachains_common as common; +use parachains_common::{ + impls::DealWithFees, opaque, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, + Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, + SLOT_DURATION, }; +use sp_runtime::Perbill; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -78,23 +79,9 @@ use xcm_builder::{ }; use xcm_executor::{Config, XcmExecutor}; -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. -pub mod opaque { - use super::*; - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - - /// Opaque block type. - pub type Block = generic::Block; - - pub type SessionHandlers = (); - - impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - } +impl_opaque_keys! { + pub struct SessionKeys { + pub aura: Aura, } } @@ -233,7 +220,7 @@ impl pallet_sudo::Config for Runtime { type Call = Call; } -pub type AssetsForceOrigin = EnsureRoot; +pub type AssetsForceOrigin = EnsureRoot; parameter_types! { pub const AssetDeposit: Balance = 100 * UNITS; // 100 WND deposit to create asset @@ -326,10 +313,9 @@ impl InstanceFilter for ProxyType { fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, - ProxyType::NonTransfer => !matches!( - c, - Call::Balances(..) | Call::Assets(..) | Call::Uniques(..) - ), + ProxyType::NonTransfer => { + !matches!(c, Call::Balances(..) | Call::Assets(..) | Call::Uniques(..)) + } ProxyType::CancelProxy => matches!( c, Call::Proxy(pallet_proxy::Call::reject_announcement(..)) @@ -583,9 +569,8 @@ impl pallet_session::Config for Runtime { type NextSessionRotation = pallet_session::PeriodicSessions; type SessionManager = CollatorSelection; // Essentially just Aura, but lets be pedantic. - type SessionHandler = - ::KeyTypeIdProviders; - type Keys = opaque::SessionKeys; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; type DisabledValidatorsThreshold = DisabledValidatorsThreshold; type WeightInfo = weights::pallet_session::WeightInfo; } @@ -803,13 +788,13 @@ impl_runtime_apis! { impl sp_session::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { - opaque::SessionKeys::generate(seed) + SessionKeys::generate(seed) } fn decode_session_keys( encoded: Vec, ) -> Option, KeyTypeId)>> { - opaque::SessionKeys::decode_into_raw_public_keys(&encoded) + SessionKeys::decode_into_raw_public_keys(&encoded) } }