mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Add Transaction Fee RPC to Statemint/Statemine (#559)
* add payment rpc to parachains * connect payment rpc to parachains clients * fix the rumtime_api bound/ add separate start node implementation for shell * use cumulus/parachain specific primitives * Update polkadot-parachains/src/rpc.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * rename txpool dependency * fix the package name * move parachain primitives to separate module * Refactor Shared Primitves for Payment Info (#577) * rename to parachains-common * refactor shared opaque * remove primitives * Update service.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Generated
+32
-27
@@ -6133,6 +6133,29 @@ dependencies = [
|
|||||||
"serde",
|
"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]]
|
[[package]]
|
||||||
name = "parity-db"
|
name = "parity-db"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -6696,6 +6719,8 @@ dependencies = [
|
|||||||
"jsonrpc-core",
|
"jsonrpc-core",
|
||||||
"log",
|
"log",
|
||||||
"nix",
|
"nix",
|
||||||
|
"pallet-transaction-payment-rpc",
|
||||||
|
"parachains-common",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parking_lot 0.10.2",
|
"parking_lot 0.10.2",
|
||||||
"polkadot-cli",
|
"polkadot-cli",
|
||||||
@@ -6717,6 +6742,7 @@ dependencies = [
|
|||||||
"sc-telemetry",
|
"sc-telemetry",
|
||||||
"sc-tracing",
|
"sc-tracing",
|
||||||
"sc-transaction-pool",
|
"sc-transaction-pool",
|
||||||
|
"sc-transaction-pool-api",
|
||||||
"serde",
|
"serde",
|
||||||
"shell-runtime",
|
"shell-runtime",
|
||||||
"sp-api",
|
"sp-api",
|
||||||
@@ -6734,10 +6760,10 @@ dependencies = [
|
|||||||
"sp-timestamp",
|
"sp-timestamp",
|
||||||
"sp-transaction-pool",
|
"sp-transaction-pool",
|
||||||
"statemine-runtime",
|
"statemine-runtime",
|
||||||
"statemint-common",
|
|
||||||
"statemint-runtime",
|
"statemint-runtime",
|
||||||
"structopt",
|
"structopt",
|
||||||
"substrate-build-script-utils",
|
"substrate-build-script-utils",
|
||||||
|
"substrate-frame-rpc-system",
|
||||||
"substrate-prometheus-endpoint",
|
"substrate-prometheus-endpoint",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tokio 0.2.24",
|
"tokio 0.2.24",
|
||||||
@@ -8649,6 +8675,7 @@ dependencies = [
|
|||||||
"frame-executive",
|
"frame-executive",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
"frame-system",
|
"frame-system",
|
||||||
|
"frame-system-rpc-runtime-api",
|
||||||
"hex",
|
"hex",
|
||||||
"hex-literal 0.3.3",
|
"hex-literal 0.3.3",
|
||||||
"log",
|
"log",
|
||||||
@@ -8659,6 +8686,7 @@ dependencies = [
|
|||||||
"pallet-sudo",
|
"pallet-sudo",
|
||||||
"pallet-timestamp",
|
"pallet-timestamp",
|
||||||
"pallet-transaction-payment",
|
"pallet-transaction-payment",
|
||||||
|
"pallet-transaction-payment-rpc-runtime-api",
|
||||||
"pallet-xcm",
|
"pallet-xcm",
|
||||||
"parachain-info",
|
"parachain-info",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
@@ -11136,6 +11164,7 @@ dependencies = [
|
|||||||
"pallet-utility",
|
"pallet-utility",
|
||||||
"pallet-xcm",
|
"pallet-xcm",
|
||||||
"parachain-info",
|
"parachain-info",
|
||||||
|
"parachains-common",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"polkadot-parachain",
|
"polkadot-parachain",
|
||||||
"polkadot-runtime-common",
|
"polkadot-runtime-common",
|
||||||
@@ -11153,36 +11182,12 @@ dependencies = [
|
|||||||
"sp-std",
|
"sp-std",
|
||||||
"sp-transaction-pool",
|
"sp-transaction-pool",
|
||||||
"sp-version",
|
"sp-version",
|
||||||
"statemint-common",
|
|
||||||
"substrate-wasm-builder",
|
"substrate-wasm-builder",
|
||||||
"xcm",
|
"xcm",
|
||||||
"xcm-builder",
|
"xcm-builder",
|
||||||
"xcm-executor",
|
"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]]
|
[[package]]
|
||||||
name = "statemint-runtime"
|
name = "statemint-runtime"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@@ -11224,6 +11229,7 @@ dependencies = [
|
|||||||
"pallet-utility",
|
"pallet-utility",
|
||||||
"pallet-xcm",
|
"pallet-xcm",
|
||||||
"parachain-info",
|
"parachain-info",
|
||||||
|
"parachains-common",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"polkadot-parachain",
|
"polkadot-parachain",
|
||||||
"polkadot-runtime-common",
|
"polkadot-runtime-common",
|
||||||
@@ -11241,7 +11247,6 @@ dependencies = [
|
|||||||
"sp-std",
|
"sp-std",
|
||||||
"sp-transaction-pool",
|
"sp-transaction-pool",
|
||||||
"sp-version",
|
"sp-version",
|
||||||
"statemint-common",
|
|
||||||
"substrate-wasm-builder",
|
"substrate-wasm-builder",
|
||||||
"xcm",
|
"xcm",
|
||||||
"xcm-builder",
|
"xcm-builder",
|
||||||
@@ -12931,6 +12936,7 @@ dependencies = [
|
|||||||
"pallet-utility",
|
"pallet-utility",
|
||||||
"pallet-xcm",
|
"pallet-xcm",
|
||||||
"parachain-info",
|
"parachain-info",
|
||||||
|
"parachains-common",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"polkadot-parachain",
|
"polkadot-parachain",
|
||||||
"polkadot-runtime-common",
|
"polkadot-runtime-common",
|
||||||
@@ -12948,7 +12954,6 @@ dependencies = [
|
|||||||
"sp-std",
|
"sp-std",
|
||||||
"sp-transaction-pool",
|
"sp-transaction-pool",
|
||||||
"sp-version",
|
"sp-version",
|
||||||
"statemint-common",
|
|
||||||
"substrate-wasm-builder",
|
"substrate-wasm-builder",
|
||||||
"xcm",
|
"xcm",
|
||||||
"xcm-builder",
|
"xcm-builder",
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ members = [
|
|||||||
"polkadot-parachains/pallets/ping",
|
"polkadot-parachains/pallets/ping",
|
||||||
"polkadot-parachains/rococo",
|
"polkadot-parachains/rococo",
|
||||||
"polkadot-parachains/shell",
|
"polkadot-parachains/shell",
|
||||||
"polkadot-parachains/statemint-common",
|
"polkadot-parachains/parachains-common",
|
||||||
"polkadot-parachains/statemint",
|
"polkadot-parachains/statemint",
|
||||||
"polkadot-parachains/statemine",
|
"polkadot-parachains/statemine",
|
||||||
"polkadot-parachains/westmint",
|
"polkadot-parachains/westmint",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ shell-runtime = { path = "shell" }
|
|||||||
statemint-runtime = { path = "statemint" }
|
statemint-runtime = { path = "statemint" }
|
||||||
statemine-runtime = { path = "statemine" }
|
statemine-runtime = { path = "statemine" }
|
||||||
westmint-runtime = { path = "westmint" }
|
westmint-runtime = { path = "westmint" }
|
||||||
statemint-common = { path = "statemint-common" }
|
parachains-common = { path = "parachains-common" }
|
||||||
|
|
||||||
# Substrate dependencies
|
# Substrate dependencies
|
||||||
frame-benchmarking = { git = 'https://github.com/paritytech/substrate', branch = "master" }
|
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
|
# RPC related dependencies
|
||||||
jsonrpc-core = "15.1.0"
|
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 dependencies
|
||||||
cumulus-client-cli = { path = "../client/cli" }
|
cumulus-client-cli = { path = "../client/cli" }
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "statemint-common"
|
name = "parachains-common"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
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]
|
[package.metadata.docs.rs]
|
||||||
targets = ['x86_64-unknown-linux-gnu']
|
targets = ['x86_64-unknown-linux-gnu']
|
||||||
+12
-10
@@ -13,12 +13,14 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//! Auxillary struct/enums for Statemint runtime.
|
//! Auxillary struct/enums for parachain runtimes.
|
||||||
//! Taken from polkadot/runtime/common (at a21cd64) and adapted for Statemint.
|
//! Taken from polkadot/runtime/common (at a21cd64) and adapted for parachains.
|
||||||
|
|
||||||
use frame_support::traits::{Currency, Imbalance, OnUnbalanced};
|
use frame_support::traits::{Currency, Imbalance, OnUnbalanced};
|
||||||
|
|
||||||
pub type NegativeImbalance<T> = <pallet_balances::Pallet<T> as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
|
pub type NegativeImbalance<T> = <pallet_balances::Pallet<T> as Currency<
|
||||||
|
<T as frame_system::Config>::AccountId,
|
||||||
|
>>::NegativeImbalance;
|
||||||
|
|
||||||
/// Logic for the author to get a portion of fees.
|
/// Logic for the author to get a portion of fees.
|
||||||
pub struct ToStakingPot<R>(sp_std::marker::PhantomData<R>);
|
pub struct ToStakingPot<R>(sp_std::marker::PhantomData<R>);
|
||||||
@@ -32,10 +34,7 @@ where
|
|||||||
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
|
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
|
||||||
let numeric_amount = amount.peek();
|
let numeric_amount = amount.peek();
|
||||||
let staking_pot = <pallet_collator_selection::Pallet<R>>::account_id();
|
let staking_pot = <pallet_collator_selection::Pallet<R>>::account_id();
|
||||||
<pallet_balances::Pallet<R>>::resolve_creating(
|
<pallet_balances::Pallet<R>>::resolve_creating(&staking_pot, amount);
|
||||||
&staking_pot,
|
|
||||||
amount,
|
|
||||||
);
|
|
||||||
<frame_system::Pallet<R>>::deposit_event(pallet_balances::Event::Deposit(
|
<frame_system::Pallet<R>>::deposit_event(pallet_balances::Event::Deposit(
|
||||||
staking_pot,
|
staking_pot,
|
||||||
numeric_amount,
|
numeric_amount,
|
||||||
@@ -64,9 +63,13 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use frame_support::traits::FindAuthor;
|
use frame_support::{
|
||||||
use frame_support::{parameter_types, PalletId, traits::ValidatorRegistration};
|
parameter_types,
|
||||||
|
traits::{FindAuthor, ValidatorRegistration},
|
||||||
|
PalletId,
|
||||||
|
};
|
||||||
use frame_system::{limits, EnsureRoot};
|
use frame_system::{limits, EnsureRoot};
|
||||||
|
use pallet_collator_selection::IdentityCollator;
|
||||||
use polkadot_primitives::v1::AccountId;
|
use polkadot_primitives::v1::AccountId;
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -74,7 +77,6 @@ mod tests {
|
|||||||
traits::{BlakeTwo256, IdentityLookup},
|
traits::{BlakeTwo256, IdentityLookup},
|
||||||
Perbill,
|
Perbill,
|
||||||
};
|
};
|
||||||
use pallet_collator_selection::IdentityCollator;
|
|
||||||
|
|
||||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
type Block = frame_system::mocking::MockBlock<Test>;
|
type Block = frame_system::mocking::MockBlock<Test>;
|
||||||
+24
-10
@@ -16,12 +16,12 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
pub mod impls;
|
pub mod impls;
|
||||||
pub use types::*;
|
|
||||||
pub use constants::*;
|
pub use constants::*;
|
||||||
|
pub use opaque::*;
|
||||||
/// Common types of statemint and statemine.
|
pub use types::*;
|
||||||
|
/// Common types of parachains.
|
||||||
mod types {
|
mod types {
|
||||||
use sp_runtime::traits::{Verify, IdentifyAccount, BlakeTwo256};
|
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||||
|
|
||||||
/// An index to a block.
|
/// An index to a block.
|
||||||
pub type BlockNumber = u32;
|
pub type BlockNumber = u32;
|
||||||
@@ -46,21 +46,18 @@ mod types {
|
|||||||
/// A hash of some data used by the chain.
|
/// A hash of some data used by the chain.
|
||||||
pub type Hash = sp_core::H256;
|
pub type Hash = sp_core::H256;
|
||||||
|
|
||||||
/// Block header type as expected by this runtime.
|
|
||||||
pub type Header = sp_runtime::generic::Header<BlockNumber, BlakeTwo256>;
|
|
||||||
|
|
||||||
/// Digest item type.
|
/// Digest item type.
|
||||||
pub type DigestItem = sp_runtime::generic::DigestItem<Hash>;
|
pub type DigestItem = sp_runtime::generic::DigestItem<Hash>;
|
||||||
|
|
||||||
// Aura consensus authority.
|
// Aura consensus authority.
|
||||||
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;
|
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Common constants of statemint and statemine
|
/// Common constants of parachains.
|
||||||
mod constants {
|
mod constants {
|
||||||
use super::types::BlockNumber;
|
use super::types::BlockNumber;
|
||||||
|
use frame_support::weights::{constants::WEIGHT_PER_SECOND, Weight};
|
||||||
use sp_runtime::Perbill;
|
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
|
/// 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
|
/// 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
|
/// `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.
|
/// 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;
|
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<BlockNumber, BlakeTwo256>;
|
||||||
|
/// Opaque block type.
|
||||||
|
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||||
|
/// Opaque block identifier type.
|
||||||
|
pub type BlockId = generic::BlockId<Block>;
|
||||||
|
}
|
||||||
@@ -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-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-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 = { 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-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-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" }
|
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-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-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-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 dependencies
|
||||||
cumulus-pallet-aura-ext = { path = "../../pallets/aura-ext", default-features = false }
|
cumulus-pallet-aura-ext = { path = "../../pallets/aura-ext", default-features = false }
|
||||||
|
|||||||
@@ -590,6 +590,27 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
|
||||||
|
fn account_nonce(account: AccountId) -> Index {
|
||||||
|
System::account_nonce(account)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
|
||||||
|
fn query_info(
|
||||||
|
uxt: <Block as BlockT>::Extrinsic,
|
||||||
|
len: u32,
|
||||||
|
) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
|
||||||
|
TransactionPayment::query_info(uxt, len)
|
||||||
|
}
|
||||||
|
fn query_fee_details(
|
||||||
|
uxt: <Block as BlockT>::Extrinsic,
|
||||||
|
len: u32,
|
||||||
|
) -> pallet_transaction_payment::FeeDetails<Balance> {
|
||||||
|
TransactionPayment::query_fee_details(uxt, len)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
|
impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
|
||||||
fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {
|
fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {
|
||||||
ParachainSystem::collect_collation_info()
|
ParachainSystem::collect_collation_info()
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
|
|||||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||||
|
|
||||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||||
pub type ChainSpec = sc_service::GenericChainSpec<rococo_parachain_runtime::GenesisConfig, Extensions>;
|
pub type ChainSpec =
|
||||||
|
sc_service::GenericChainSpec<rococo_parachain_runtime::GenesisConfig, Extensions>;
|
||||||
|
|
||||||
/// Specialized `ChainSpec` for the shell parachain runtime.
|
/// Specialized `ChainSpec` for the shell parachain runtime.
|
||||||
pub type ShellChainSpec = sc_service::GenericChainSpec<shell_runtime::GenesisConfig, Extensions>;
|
pub type ShellChainSpec = sc_service::GenericChainSpec<shell_runtime::GenesisConfig, Extensions>;
|
||||||
@@ -56,7 +57,8 @@ impl Extensions {
|
|||||||
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
|
||||||
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId where
|
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
||||||
|
where
|
||||||
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
||||||
{
|
{
|
||||||
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
AccountPublic::from(get_from_seed::<TPublic>(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.
|
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||||
pub type StatemintChainSpec = sc_service::GenericChainSpec<statemint_runtime::GenesisConfig, Extensions>;
|
pub type StatemintChainSpec =
|
||||||
pub type StatemineChainSpec = sc_service::GenericChainSpec<statemine_runtime::GenesisConfig, Extensions>;
|
sc_service::GenericChainSpec<statemint_runtime::GenesisConfig, Extensions>;
|
||||||
pub type WestmintChainSpec = sc_service::GenericChainSpec<westmint_runtime::GenesisConfig, Extensions>;
|
pub type StatemineChainSpec =
|
||||||
|
sc_service::GenericChainSpec<statemine_runtime::GenesisConfig, Extensions>;
|
||||||
|
pub type WestmintChainSpec =
|
||||||
|
sc_service::GenericChainSpec<westmint_runtime::GenesisConfig, Extensions>;
|
||||||
|
|
||||||
const STATEMINT_ED: StatemintBalance = statemint_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
const STATEMINT_ED: StatemintBalance = statemint_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||||
const STATEMINE_ED: StatemintBalance = statemine_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.
|
/// 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 statemint_session_keys(keys: AuraId) -> statemint_runtime::opaque::SessionKeys {
|
pub fn statemint_session_keys(keys: AuraId) -> statemint_runtime::SessionKeys {
|
||||||
statemint_runtime::opaque::SessionKeys { aura: keys }
|
statemint_runtime::SessionKeys { aura: keys }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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 statemine_session_keys(keys: AuraId) -> statemine_runtime::opaque::SessionKeys {
|
pub fn statemine_session_keys(keys: AuraId) -> statemine_runtime::SessionKeys {
|
||||||
statemine_runtime::opaque::SessionKeys { aura: keys }
|
statemine_runtime::SessionKeys { aura: keys }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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 westmint_session_keys(keys: AuraId) -> westmint_runtime::opaque::SessionKeys {
|
pub fn westmint_session_keys(keys: AuraId) -> westmint_runtime::SessionKeys {
|
||||||
westmint_runtime::opaque::SessionKeys { aura: keys }
|
westmint_runtime::SessionKeys { aura: keys }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn statemint_development_config(id: ParaId) -> StatemintChainSpec {
|
pub fn statemint_development_config(id: ParaId) -> StatemintChainSpec {
|
||||||
@@ -255,12 +260,10 @@ pub fn statemint_development_config(id: ParaId) -> StatemintChainSpec {
|
|||||||
move || {
|
move || {
|
||||||
statemint_genesis(
|
statemint_genesis(
|
||||||
// initial collators.
|
// initial collators.
|
||||||
vec![
|
vec![(
|
||||||
(
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_collator_keys_from_seed("Alice"),
|
||||||
get_collator_keys_from_seed("Alice"),
|
)],
|
||||||
)
|
|
||||||
],
|
|
||||||
vec![
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
@@ -295,14 +298,15 @@ pub fn statemint_local_config(id: ParaId) -> StatemintChainSpec {
|
|||||||
move || {
|
move || {
|
||||||
statemint_genesis(
|
statemint_genesis(
|
||||||
// initial collators.
|
// initial collators.
|
||||||
vec![(
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
(
|
||||||
get_collator_keys_from_seed("Alice")
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
),
|
get_collator_keys_from_seed("Alice"),
|
||||||
(
|
),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
(
|
||||||
get_collator_keys_from_seed("Bob")
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
),
|
get_collator_keys_from_seed("Bob"),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
@@ -358,11 +362,17 @@ fn statemint_genesis(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
session: statemint_runtime::SessionConfig {
|
session: statemint_runtime::SessionConfig {
|
||||||
keys: invulnerables.iter().cloned().map(|(acc, aura)| (
|
keys: invulnerables
|
||||||
acc.clone(), // account id
|
.iter()
|
||||||
acc.clone(), // validator id
|
.cloned()
|
||||||
statemint_session_keys(aura), // session keys
|
.map(|(acc, aura)| {
|
||||||
)).collect()
|
(
|
||||||
|
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
|
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
|
||||||
// of this.
|
// of this.
|
||||||
@@ -386,12 +396,10 @@ pub fn statemine_development_config(id: ParaId) -> StatemineChainSpec {
|
|||||||
move || {
|
move || {
|
||||||
statemine_genesis(
|
statemine_genesis(
|
||||||
// initial collators.
|
// initial collators.
|
||||||
vec![
|
vec![(
|
||||||
(
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_collator_keys_from_seed("Alice"),
|
||||||
get_collator_keys_from_seed("Alice"),
|
)],
|
||||||
)
|
|
||||||
],
|
|
||||||
vec![
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
@@ -426,14 +434,15 @@ pub fn statemine_local_config(id: ParaId) -> StatemineChainSpec {
|
|||||||
move || {
|
move || {
|
||||||
statemine_genesis(
|
statemine_genesis(
|
||||||
// initial collators.
|
// initial collators.
|
||||||
vec![(
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
(
|
||||||
get_collator_keys_from_seed("Alice")
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
),
|
get_collator_keys_from_seed("Alice"),
|
||||||
(
|
),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
(
|
||||||
get_collator_keys_from_seed("Bob")
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
),
|
get_collator_keys_from_seed("Bob"),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
@@ -477,22 +486,31 @@ pub fn statemine_config(id: ParaId) -> StatemineChainSpec {
|
|||||||
move || {
|
move || {
|
||||||
statemine_genesis(
|
statemine_genesis(
|
||||||
// initial collators.
|
// initial collators.
|
||||||
vec![(
|
vec![
|
||||||
hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730").into(),
|
(
|
||||||
hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730").unchecked_into()
|
hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730")
|
||||||
),
|
.into(),
|
||||||
(
|
hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730")
|
||||||
hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a").into(),
|
.unchecked_into(),
|
||||||
hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a").unchecked_into()
|
),
|
||||||
),
|
(
|
||||||
(
|
hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a")
|
||||||
hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a").into(),
|
.into(),
|
||||||
hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a").unchecked_into()
|
hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a")
|
||||||
),
|
.unchecked_into(),
|
||||||
(
|
),
|
||||||
hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415").into(),
|
(
|
||||||
hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415").unchecked_into()
|
hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a")
|
||||||
),
|
.into(),
|
||||||
|
hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a")
|
||||||
|
.unchecked_into(),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415")
|
||||||
|
.into(),
|
||||||
|
hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415")
|
||||||
|
.unchecked_into(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
vec![],
|
vec![],
|
||||||
id,
|
id,
|
||||||
@@ -535,11 +553,17 @@ fn statemine_genesis(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
session: statemine_runtime::SessionConfig {
|
session: statemine_runtime::SessionConfig {
|
||||||
keys: invulnerables.iter().cloned().map(|(acc, aura)| (
|
keys: invulnerables
|
||||||
acc.clone(), // account id
|
.iter()
|
||||||
acc.clone(), // validator id
|
.cloned()
|
||||||
statemine_session_keys(aura), // session keys
|
.map(|(acc, aura)| {
|
||||||
)).collect()
|
(
|
||||||
|
acc.clone(), // account id
|
||||||
|
acc.clone(), // validator id
|
||||||
|
statemine_session_keys(aura), // session keys
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
},
|
},
|
||||||
aura: Default::default(),
|
aura: Default::default(),
|
||||||
aura_ext: Default::default(),
|
aura_ext: Default::default(),
|
||||||
@@ -561,12 +585,10 @@ pub fn westmint_development_config(id: ParaId) -> WestmintChainSpec {
|
|||||||
move || {
|
move || {
|
||||||
westmint_genesis(
|
westmint_genesis(
|
||||||
// initial collators.
|
// initial collators.
|
||||||
vec![
|
vec![(
|
||||||
(
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_collator_keys_from_seed("Alice"),
|
||||||
get_collator_keys_from_seed("Alice"),
|
)],
|
||||||
)
|
|
||||||
],
|
|
||||||
vec![
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
@@ -602,14 +624,15 @@ pub fn westmint_local_config(id: ParaId) -> WestmintChainSpec {
|
|||||||
move || {
|
move || {
|
||||||
westmint_genesis(
|
westmint_genesis(
|
||||||
// initial collators.
|
// initial collators.
|
||||||
vec![(
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
(
|
||||||
get_collator_keys_from_seed("Alice")
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
),
|
get_collator_keys_from_seed("Alice"),
|
||||||
(
|
),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
(
|
||||||
get_collator_keys_from_seed("Bob")
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
),
|
get_collator_keys_from_seed("Bob"),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
@@ -654,22 +677,31 @@ pub fn westmint_config(id: ParaId) -> WestmintChainSpec {
|
|||||||
move || {
|
move || {
|
||||||
westmint_genesis(
|
westmint_genesis(
|
||||||
// initial collators.
|
// initial collators.
|
||||||
vec![(
|
vec![
|
||||||
hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325").into(),
|
(
|
||||||
hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325").unchecked_into()
|
hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325")
|
||||||
),
|
.into(),
|
||||||
(
|
hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325")
|
||||||
hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876").into(),
|
.unchecked_into(),
|
||||||
hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876").unchecked_into()
|
),
|
||||||
),
|
(
|
||||||
(
|
hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876")
|
||||||
hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f").into(),
|
.into(),
|
||||||
hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f").unchecked_into()
|
hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876")
|
||||||
),
|
.unchecked_into(),
|
||||||
(
|
),
|
||||||
hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322").into(),
|
(
|
||||||
hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322").unchecked_into()
|
hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f")
|
||||||
),
|
.into(),
|
||||||
|
hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f")
|
||||||
|
.unchecked_into(),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322")
|
||||||
|
.into(),
|
||||||
|
hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322")
|
||||||
|
.unchecked_into(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
vec![],
|
vec![],
|
||||||
// re-use the Westend sudo key
|
// re-use the Westend sudo key
|
||||||
@@ -716,11 +748,17 @@ fn westmint_genesis(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
session: westmint_runtime::SessionConfig {
|
session: westmint_runtime::SessionConfig {
|
||||||
keys: invulnerables.iter().cloned().map(|(acc, aura)| (
|
keys: invulnerables
|
||||||
acc.clone(), // account id
|
.iter()
|
||||||
acc.clone(), // validator id
|
.cloned()
|
||||||
westmint_session_keys(aura), // session keys
|
.map(|(acc, aura)| {
|
||||||
)).collect()
|
(
|
||||||
|
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
|
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
|
||||||
// of this.
|
// of this.
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ mod chain_spec;
|
|||||||
mod service;
|
mod service;
|
||||||
mod cli;
|
mod cli;
|
||||||
mod command;
|
mod command;
|
||||||
|
mod rpc;
|
||||||
|
|
||||||
fn main() -> sc_cli::Result<()> {
|
fn main() -> sc_cli::Result<()> {
|
||||||
command::run()
|
command::run()
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! 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<sc_rpc::Metadata>;
|
||||||
|
|
||||||
|
/// Full client dependencies
|
||||||
|
pub struct FullDeps<C, P> {
|
||||||
|
/// The client instance to use.
|
||||||
|
pub client: Arc<C>,
|
||||||
|
/// Transaction pool instance.
|
||||||
|
pub pool: Arc<P>,
|
||||||
|
/// Whether to deny unsafe calls
|
||||||
|
pub deny_unsafe: DenyUnsafe,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Instantiate all RPC extensions.
|
||||||
|
pub fn create_full<C, P>(deps: FullDeps<C, P>) -> RpcExtension
|
||||||
|
where
|
||||||
|
C: ProvideRuntimeApi<Block>
|
||||||
|
+ HeaderBackend<Block>
|
||||||
|
+ AuxStore
|
||||||
|
+ HeaderMetadata<Block, Error = BlockChainError>
|
||||||
|
+ Send
|
||||||
|
+ Sync
|
||||||
|
+ 'static,
|
||||||
|
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||||
|
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
||||||
|
C::Api: BlockBuilder<Block>,
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
// 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_client_consensus_aura::{
|
use cumulus_client_consensus_aura::{
|
||||||
build_aura_consensus, BuildAuraConsensusParams, SlotProportion,
|
build_aura_consensus, BuildAuraConsensusParams, SlotProportion,
|
||||||
};
|
};
|
||||||
@@ -29,6 +28,9 @@ use cumulus_primitives_core::{
|
|||||||
ParaId,
|
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 cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
|
||||||
use futures::lock::Mutex;
|
use futures::lock::Mutex;
|
||||||
use sc_client_api::ExecutorProvider;
|
use sc_client_api::ExecutorProvider;
|
||||||
@@ -37,6 +39,7 @@ use sc_consensus::{
|
|||||||
BlockImportParams,
|
BlockImportParams,
|
||||||
};
|
};
|
||||||
use sc_executor::native_executor_instance;
|
use sc_executor::native_executor_instance;
|
||||||
|
pub use sc_executor::NativeExecutor;
|
||||||
use sc_network::NetworkService;
|
use sc_network::NetworkService;
|
||||||
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
|
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
|
||||||
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
|
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
|
||||||
@@ -51,13 +54,6 @@ use sp_runtime::{
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use substrate_prometheus_endpoint::Registry;
|
use substrate_prometheus_endpoint::Registry;
|
||||||
|
|
||||||
pub use sc_executor::NativeExecutor;
|
|
||||||
|
|
||||||
type BlockNumber = u32;
|
|
||||||
type Header = sp_runtime::generic::Header<BlockNumber, sp_runtime::traits::BlakeTwo256>;
|
|
||||||
pub type Block = sp_runtime::generic::Block<Header, sp_runtime::OpaqueExtrinsic>;
|
|
||||||
type Hash = sp_core::H256;
|
|
||||||
|
|
||||||
// Native executor instance.
|
// Native executor instance.
|
||||||
native_executor_instance!(
|
native_executor_instance!(
|
||||||
pub RococoParachainRuntimeExecutor,
|
pub RococoParachainRuntimeExecutor,
|
||||||
@@ -193,11 +189,11 @@ where
|
|||||||
Ok(params)
|
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")]
|
#[sc_tracing::logging::prefix_logs_with("Parachain")]
|
||||||
async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
|
async fn start_shell_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
|
||||||
parachain_config: Configuration,
|
parachain_config: Configuration,
|
||||||
polkadot_config: Configuration,
|
polkadot_config: Configuration,
|
||||||
id: ParaId,
|
id: ParaId,
|
||||||
@@ -358,6 +354,185 @@ where
|
|||||||
Ok((task_manager, client))
|
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<RuntimeApi, Executor, RB, BIQ, BIC>(
|
||||||
|
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<TFullClient<Block, RuntimeApi, Executor>>)>
|
||||||
|
where
|
||||||
|
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>>
|
||||||
|
+ Send
|
||||||
|
+ Sync
|
||||||
|
+ 'static,
|
||||||
|
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
||||||
|
+ sp_api::Metadata<Block>
|
||||||
|
+ sp_session::SessionKeys<Block>
|
||||||
|
+ sp_api::ApiExt<
|
||||||
|
Block,
|
||||||
|
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>,
|
||||||
|
> + sp_offchain::OffchainWorkerApi<Block>
|
||||||
|
+ sp_block_builder::BlockBuilder<Block>
|
||||||
|
+ cumulus_primitives_core::CollectCollationInfo<Block>
|
||||||
|
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
|
||||||
|
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||||
|
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
|
||||||
|
Executor: sc_executor::NativeExecutionDispatch + 'static,
|
||||||
|
RB: Fn(
|
||||||
|
Arc<TFullClient<Block, RuntimeApi, Executor>>,
|
||||||
|
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
|
||||||
|
+ Send
|
||||||
|
+ 'static,
|
||||||
|
BIQ: FnOnce(
|
||||||
|
Arc<TFullClient<Block, RuntimeApi, Executor>>,
|
||||||
|
&Configuration,
|
||||||
|
Option<TelemetryHandle>,
|
||||||
|
&TaskManager,
|
||||||
|
) -> Result<
|
||||||
|
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||||
|
sc_service::Error,
|
||||||
|
> + 'static,
|
||||||
|
BIC: FnOnce(
|
||||||
|
Arc<TFullClient<Block, RuntimeApi, Executor>>,
|
||||||
|
Option<&Registry>,
|
||||||
|
Option<TelemetryHandle>,
|
||||||
|
&TaskManager,
|
||||||
|
&polkadot_service::NewFull<polkadot_service::Client>,
|
||||||
|
Arc<sc_transaction_pool::FullPool<Block, TFullClient<Block, RuntimeApi, Executor>>>,
|
||||||
|
Arc<NetworkService<Block, Hash>>,
|
||||||
|
SyncCryptoStorePtr,
|
||||||
|
bool,
|
||||||
|
) -> Result<Box<dyn ParachainConsensus<Block>>, 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::<RuntimeApi, Executor, BIQ>(¶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.
|
/// Build the import queue for the rococo parachain runtime.
|
||||||
pub fn rococo_parachain_build_import_queue(
|
pub fn rococo_parachain_build_import_queue(
|
||||||
client: Arc<
|
client: Arc<
|
||||||
@@ -532,7 +707,7 @@ pub async fn start_shell_node(
|
|||||||
TaskManager,
|
TaskManager,
|
||||||
Arc<TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>>,
|
Arc<TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>>,
|
||||||
)> {
|
)> {
|
||||||
start_node_impl::<shell_runtime::RuntimeApi, ShellRuntimeExecutor, _, _, _>(
|
start_shell_node_impl::<shell_runtime::RuntimeApi, ShellRuntimeExecutor, _, _, _>(
|
||||||
parachain_config,
|
parachain_config,
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
id,
|
id,
|
||||||
@@ -801,7 +976,9 @@ where
|
|||||||
> + sp_offchain::OffchainWorkerApi<Block>
|
> + sp_offchain::OffchainWorkerApi<Block>
|
||||||
+ sp_block_builder::BlockBuilder<Block>
|
+ sp_block_builder::BlockBuilder<Block>
|
||||||
+ cumulus_primitives_core::CollectCollationInfo<Block>
|
+ cumulus_primitives_core::CollectCollationInfo<Block>
|
||||||
+ sp_consensus_aura::AuraApi<Block, AuraId>,
|
+ sp_consensus_aura::AuraApi<Block, AuraId>
|
||||||
|
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
|
||||||
|
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||||
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
|
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
|
||||||
Executor: sc_executor::NativeExecutionDispatch + 'static,
|
Executor: sc_executor::NativeExecutionDispatch + 'static,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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-pallet-session-benchmarking = {path = "../../pallets/session-benchmarking", default-features = false, version = "3.0.0"}
|
||||||
cumulus-ping = { path = "../pallets/ping", default-features = false }
|
cumulus-ping = { path = "../pallets/ping", default-features = false }
|
||||||
pallet-collator-selection = { path = "../../pallets/collator-selection", 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 dependencies
|
||||||
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||||
@@ -149,5 +149,5 @@ std = [
|
|||||||
"xcm-executor/std",
|
"xcm-executor/std",
|
||||||
"sp-consensus-aura/std",
|
"sp-consensus-aura/std",
|
||||||
"node-primitives/std",
|
"node-primitives/std",
|
||||||
"statemint-common/std",
|
"parachains-common/std",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -54,12 +54,13 @@ use frame_system::{
|
|||||||
limits::{BlockLength, BlockWeights},
|
limits::{BlockLength, BlockWeights},
|
||||||
EnsureOneOf, EnsureRoot,
|
EnsureOneOf, EnsureRoot,
|
||||||
};
|
};
|
||||||
use sp_runtime::Perbill;
|
pub use parachains_common as common;
|
||||||
pub use statemint_common as common;
|
use parachains_common::{
|
||||||
use statemint_common::{
|
impls::DealWithFees, opaque, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index,
|
||||||
impls::DealWithFees, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature,
|
Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO,
|
||||||
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
SLOT_DURATION,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::Perbill;
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use sp_runtime::BuildStorage;
|
pub use sp_runtime::BuildStorage;
|
||||||
@@ -78,23 +79,9 @@ use xcm_builder::{
|
|||||||
};
|
};
|
||||||
use xcm_executor::{Config, XcmExecutor};
|
use xcm_executor::{Config, XcmExecutor};
|
||||||
|
|
||||||
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
|
impl_opaque_keys! {
|
||||||
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
|
pub struct SessionKeys {
|
||||||
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
|
pub aura: Aura,
|
||||||
/// 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<BlockNumber, BlakeTwo256>;
|
|
||||||
/// Opaque block type.
|
|
||||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
|
||||||
/// Opaque block identifier type.
|
|
||||||
pub type BlockId = generic::BlockId<Block>;
|
|
||||||
impl_opaque_keys! {
|
|
||||||
pub struct SessionKeys {
|
|
||||||
pub aura: Aura,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,9 +606,8 @@ impl pallet_session::Config for Runtime {
|
|||||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
type SessionManager = CollatorSelection;
|
type SessionManager = CollatorSelection;
|
||||||
// Essentially just Aura, but lets be pedantic.
|
// Essentially just Aura, but lets be pedantic.
|
||||||
type SessionHandler =
|
type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
|
||||||
<opaque::SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
|
type Keys = SessionKeys;
|
||||||
type Keys = opaque::SessionKeys;
|
|
||||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||||
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
@@ -817,13 +803,13 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
impl sp_session::SessionKeys<Block> for Runtime {
|
impl sp_session::SessionKeys<Block> for Runtime {
|
||||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||||
opaque::SessionKeys::generate(seed)
|
SessionKeys::generate(seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_session_keys(
|
fn decode_session_keys(
|
||||||
encoded: Vec<u8>,
|
encoded: Vec<u8>,
|
||||||
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
||||||
opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
|
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-pallet-session-benchmarking = { path = "../../pallets/session-benchmarking", default-features = false, version = "3.0.0" }
|
||||||
cumulus-ping = { path = "../pallets/ping", default-features = false }
|
cumulus-ping = { path = "../pallets/ping", default-features = false }
|
||||||
pallet-collator-selection = { path = "../../pallets/collator-selection", 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 dependencies
|
||||||
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||||
@@ -149,5 +149,5 @@ std = [
|
|||||||
"xcm-executor/std",
|
"xcm-executor/std",
|
||||||
"sp-consensus-aura/std",
|
"sp-consensus-aura/std",
|
||||||
"node-primitives/std",
|
"node-primitives/std",
|
||||||
"statemint-common/std",
|
"parachains-common/std",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -54,12 +54,13 @@ use frame_system::{
|
|||||||
limits::{BlockLength, BlockWeights},
|
limits::{BlockLength, BlockWeights},
|
||||||
EnsureOneOf, EnsureRoot,
|
EnsureOneOf, EnsureRoot,
|
||||||
};
|
};
|
||||||
use sp_runtime::Perbill;
|
pub use parachains_common as common;
|
||||||
pub use statemint_common as common;
|
use parachains_common::{
|
||||||
use statemint_common::{
|
impls::DealWithFees, opaque, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index,
|
||||||
impls::DealWithFees, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature,
|
Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO,
|
||||||
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
SLOT_DURATION,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::Perbill;
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use sp_runtime::BuildStorage;
|
pub use sp_runtime::BuildStorage;
|
||||||
@@ -78,23 +79,9 @@ use xcm_builder::{
|
|||||||
};
|
};
|
||||||
use xcm_executor::{Config, XcmExecutor};
|
use xcm_executor::{Config, XcmExecutor};
|
||||||
|
|
||||||
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
|
impl_opaque_keys! {
|
||||||
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
|
pub struct SessionKeys {
|
||||||
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
|
pub aura: Aura,
|
||||||
/// 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<BlockNumber, BlakeTwo256>;
|
|
||||||
/// Opaque block type.
|
|
||||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
|
||||||
/// Opaque block identifier type.
|
|
||||||
pub type BlockId = generic::BlockId<Block>;
|
|
||||||
impl_opaque_keys! {
|
|
||||||
pub struct SessionKeys {
|
|
||||||
pub aura: Aura,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,10 +314,9 @@ impl InstanceFilter<Call> for ProxyType {
|
|||||||
fn filter(&self, c: &Call) -> bool {
|
fn filter(&self, c: &Call) -> bool {
|
||||||
match self {
|
match self {
|
||||||
ProxyType::Any => true,
|
ProxyType::Any => true,
|
||||||
ProxyType::NonTransfer => !matches!(
|
ProxyType::NonTransfer => {
|
||||||
c,
|
!matches!(c, Call::Balances(..) | Call::Assets(..) | Call::Uniques(..))
|
||||||
Call::Balances(..) | Call::Assets(..) | Call::Uniques(..)
|
}
|
||||||
),
|
|
||||||
ProxyType::CancelProxy => matches!(
|
ProxyType::CancelProxy => matches!(
|
||||||
c,
|
c,
|
||||||
Call::Proxy(pallet_proxy::Call::reject_announcement(..))
|
Call::Proxy(pallet_proxy::Call::reject_announcement(..))
|
||||||
@@ -585,9 +571,8 @@ impl pallet_session::Config for Runtime {
|
|||||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
type SessionManager = CollatorSelection;
|
type SessionManager = CollatorSelection;
|
||||||
// Essentially just Aura, but lets be pedantic.
|
// Essentially just Aura, but lets be pedantic.
|
||||||
type SessionHandler =
|
type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
|
||||||
<opaque::SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
|
type Keys = SessionKeys;
|
||||||
type Keys = opaque::SessionKeys;
|
|
||||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||||
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
@@ -801,13 +786,13 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
impl sp_session::SessionKeys<Block> for Runtime {
|
impl sp_session::SessionKeys<Block> for Runtime {
|
||||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||||
opaque::SessionKeys::generate(seed)
|
SessionKeys::generate(seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_session_keys(
|
fn decode_session_keys(
|
||||||
encoded: Vec<u8>,
|
encoded: Vec<u8>,
|
||||||
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
||||||
opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
|
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-pallet-session-benchmarking = {path = "../../pallets/session-benchmarking", default-features = false, version = "3.0.0"}
|
||||||
cumulus-ping = { path = "../pallets/ping", default-features = false }
|
cumulus-ping = { path = "../pallets/ping", default-features = false }
|
||||||
pallet-collator-selection = { path = "../../pallets/collator-selection", 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 dependencies
|
||||||
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||||
@@ -149,5 +149,5 @@ std = [
|
|||||||
"xcm-executor/std",
|
"xcm-executor/std",
|
||||||
"sp-consensus-aura/std",
|
"sp-consensus-aura/std",
|
||||||
"node-primitives/std",
|
"node-primitives/std",
|
||||||
"statemint-common/std",
|
"parachains-common/std",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -54,12 +54,13 @@ use frame_system::{
|
|||||||
limits::{BlockLength, BlockWeights},
|
limits::{BlockLength, BlockWeights},
|
||||||
EnsureRoot,
|
EnsureRoot,
|
||||||
};
|
};
|
||||||
use sp_runtime::Perbill;
|
pub use parachains_common as common;
|
||||||
pub use statemint_common as common;
|
use parachains_common::{
|
||||||
use statemint_common::{
|
impls::DealWithFees, opaque, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index,
|
||||||
impls::DealWithFees, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature,
|
Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO,
|
||||||
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
SLOT_DURATION,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::Perbill;
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use sp_runtime::BuildStorage;
|
pub use sp_runtime::BuildStorage;
|
||||||
@@ -78,23 +79,9 @@ use xcm_builder::{
|
|||||||
};
|
};
|
||||||
use xcm_executor::{Config, XcmExecutor};
|
use xcm_executor::{Config, XcmExecutor};
|
||||||
|
|
||||||
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
|
impl_opaque_keys! {
|
||||||
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
|
pub struct SessionKeys {
|
||||||
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
|
pub aura: Aura,
|
||||||
/// 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<Header, UncheckedExtrinsic>;
|
|
||||||
|
|
||||||
pub type SessionHandlers = ();
|
|
||||||
|
|
||||||
impl_opaque_keys! {
|
|
||||||
pub struct SessionKeys {
|
|
||||||
pub aura: Aura,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +220,7 @@ impl pallet_sudo::Config for Runtime {
|
|||||||
type Call = Call;
|
type Call = Call;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type AssetsForceOrigin = EnsureRoot<AccountId>;
|
pub type AssetsForceOrigin = EnsureRoot<AccountId>;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const AssetDeposit: Balance = 100 * UNITS; // 100 WND deposit to create asset
|
pub const AssetDeposit: Balance = 100 * UNITS; // 100 WND deposit to create asset
|
||||||
@@ -326,10 +313,9 @@ impl InstanceFilter<Call> for ProxyType {
|
|||||||
fn filter(&self, c: &Call) -> bool {
|
fn filter(&self, c: &Call) -> bool {
|
||||||
match self {
|
match self {
|
||||||
ProxyType::Any => true,
|
ProxyType::Any => true,
|
||||||
ProxyType::NonTransfer => !matches!(
|
ProxyType::NonTransfer => {
|
||||||
c,
|
!matches!(c, Call::Balances(..) | Call::Assets(..) | Call::Uniques(..))
|
||||||
Call::Balances(..) | Call::Assets(..) | Call::Uniques(..)
|
}
|
||||||
),
|
|
||||||
ProxyType::CancelProxy => matches!(
|
ProxyType::CancelProxy => matches!(
|
||||||
c,
|
c,
|
||||||
Call::Proxy(pallet_proxy::Call::reject_announcement(..))
|
Call::Proxy(pallet_proxy::Call::reject_announcement(..))
|
||||||
@@ -583,9 +569,8 @@ impl pallet_session::Config for Runtime {
|
|||||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
type SessionManager = CollatorSelection;
|
type SessionManager = CollatorSelection;
|
||||||
// Essentially just Aura, but lets be pedantic.
|
// Essentially just Aura, but lets be pedantic.
|
||||||
type SessionHandler =
|
type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
|
||||||
<opaque::SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
|
type Keys = SessionKeys;
|
||||||
type Keys = opaque::SessionKeys;
|
|
||||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||||
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
@@ -803,13 +788,13 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
impl sp_session::SessionKeys<Block> for Runtime {
|
impl sp_session::SessionKeys<Block> for Runtime {
|
||||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||||
opaque::SessionKeys::generate(seed)
|
SessionKeys::generate(seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_session_keys(
|
fn decode_session_keys(
|
||||||
encoded: Vec<u8>,
|
encoded: Vec<u8>,
|
||||||
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
||||||
opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
|
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user