mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 04:41:03 +00:00
Replace free for all collation in cumulus runtimes (#1251)
Partially fixes #103 This PR removes instances of "free for all" collation in the `glutton`, `shell`, and `seedling` runtimes and replaces them with Aura instances. Aura is configured without a session manager, so the initial authority set cannot be changed later on. --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
This commit is contained in:
@@ -16,10 +16,13 @@ frame-system = { path = "../../../../../substrate/frame/system", default-feature
|
||||
frame-system-rpc-runtime-api = { path = "../../../../../substrate/frame/system/rpc/runtime-api", default-features = false}
|
||||
frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true}
|
||||
frame-try-runtime = { path = "../../../../../substrate/frame/try-runtime", default-features = false, optional = true}
|
||||
pallet-aura = { path = "../../../../../substrate/frame/aura", default-features = false}
|
||||
pallet-glutton = { path = "../../../../../substrate/frame/glutton", default-features = false, optional = true}
|
||||
pallet-sudo = { path = "../../../../../substrate/frame/sudo", default-features = false, optional = true}
|
||||
pallet-timestamp = { path = "../../../../../substrate/frame/timestamp", default-features = false }
|
||||
sp-api = { path = "../../../../../substrate/primitives/api", default-features = false}
|
||||
sp-block-builder = { path = "../../../../../substrate/primitives/block-builder", default-features = false}
|
||||
sp-consensus-aura = { path = "../../../../../substrate/primitives/consensus/aura", default-features = false }
|
||||
sp-core = { path = "../../../../../substrate/primitives/core", default-features = false}
|
||||
sp-inherents = { path = "../../../../../substrate/primitives/inherents", default-features = false}
|
||||
sp-offchain = { path = "../../../../../substrate/primitives/offchain", default-features = false}
|
||||
@@ -36,9 +39,11 @@ xcm-builder = { package = "staging-xcm-builder", path = "../../../../../polkadot
|
||||
xcm-executor = { package = "staging-xcm-executor", path = "../../../../../polkadot/xcm/xcm-executor", default-features = false}
|
||||
|
||||
# Cumulus
|
||||
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
|
||||
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
|
||||
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
|
||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||
cumulus-primitives-timestamp = { path = "../../../../primitives/timestamp", default-features = false }
|
||||
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
|
||||
parachains-common = { path = "../../../common", default-features = false }
|
||||
|
||||
@@ -55,6 +60,7 @@ runtime-benchmarks = [
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-glutton/runtime-benchmarks",
|
||||
"pallet-sudo?/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"parachains-common/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
@@ -62,9 +68,11 @@ runtime-benchmarks = [
|
||||
]
|
||||
std = [
|
||||
"codec/std",
|
||||
"cumulus-pallet-aura-ext/std",
|
||||
"cumulus-pallet-parachain-system/std",
|
||||
"cumulus-pallet-xcm/std",
|
||||
"cumulus-primitives-core/std",
|
||||
"cumulus-primitives-timestamp/std",
|
||||
"frame-benchmarking?/std",
|
||||
"frame-executive/std",
|
||||
"frame-support/std",
|
||||
@@ -72,13 +80,16 @@ std = [
|
||||
"frame-system-rpc-runtime-api/std",
|
||||
"frame-system/std",
|
||||
"frame-try-runtime?/std",
|
||||
"pallet-aura/std",
|
||||
"pallet-glutton/std",
|
||||
"pallet-sudo/std",
|
||||
"pallet-timestamp/std",
|
||||
"parachain-info/std",
|
||||
"parachains-common/std",
|
||||
"scale-info/std",
|
||||
"sp-api/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-aura/std",
|
||||
"sp-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-offchain/std",
|
||||
@@ -93,14 +104,19 @@ std = [
|
||||
"xcm/std",
|
||||
]
|
||||
try-runtime = [
|
||||
"cumulus-pallet-aura-ext/try-runtime",
|
||||
"cumulus-pallet-parachain-system/try-runtime",
|
||||
"cumulus-pallet-xcm/try-runtime",
|
||||
"frame-executive/try-runtime",
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"frame-try-runtime/try-runtime",
|
||||
"pallet-aura/try-runtime",
|
||||
"pallet-glutton/try-runtime",
|
||||
"pallet-sudo/try-runtime",
|
||||
"pallet-timestamp/try-runtime",
|
||||
"parachain-info/try-runtime",
|
||||
"sp-runtime/try-runtime",
|
||||
]
|
||||
|
||||
experimental = [ "pallet-aura/experimental" ]
|
||||
|
||||
@@ -46,11 +46,12 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
pub mod weights;
|
||||
pub mod xcm_config;
|
||||
|
||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::OpaqueMetadata;
|
||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic,
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT},
|
||||
transaction_validity::{TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult,
|
||||
@@ -64,24 +65,37 @@ pub use frame_support::{
|
||||
construct_runtime,
|
||||
dispatch::DispatchClass,
|
||||
parameter_types,
|
||||
traits::{Everything, IsInVec, Randomness},
|
||||
traits::{
|
||||
ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, IsInVec, Randomness,
|
||||
},
|
||||
weights::{
|
||||
constants::{
|
||||
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND,
|
||||
},
|
||||
IdentityFee, Weight,
|
||||
},
|
||||
StorageValue,
|
||||
PalletId, StorageValue,
|
||||
};
|
||||
use frame_system::{
|
||||
limits::{BlockLength, BlockWeights},
|
||||
EnsureRoot,
|
||||
};
|
||||
use parachains_common::{AccountId, Signature};
|
||||
use parachains_common::{
|
||||
kusama::consensus::{
|
||||
BLOCK_PROCESSING_VELOCITY, RELAY_CHAIN_SLOT_DURATION_MILLIS, UNINCLUDED_SEGMENT_CAPACITY,
|
||||
},
|
||||
AccountId, Signature, SLOT_DURATION,
|
||||
};
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use sp_runtime::{Perbill, Permill};
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
pub aura: Aura,
|
||||
}
|
||||
}
|
||||
|
||||
#[sp_version::runtime_version]
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("glutton"),
|
||||
@@ -178,12 +192,35 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
type ReservedDmpWeight = ReservedDmpWeight;
|
||||
type XcmpMessageHandler = ();
|
||||
type ReservedXcmpWeight = ();
|
||||
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
|
||||
type ConsensusHook = cumulus_pallet_parachain_system::consensus_hook::ExpectParentIncluded;
|
||||
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
|
||||
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
||||
Runtime,
|
||||
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
||||
BLOCK_PROCESSING_VELOCITY,
|
||||
UNINCLUDED_SEGMENT_CAPACITY,
|
||||
>;
|
||||
}
|
||||
|
||||
impl parachain_info::Config for Runtime {}
|
||||
|
||||
impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
||||
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
type DisabledValidators = ();
|
||||
type MaxAuthorities = ConstU32<100_000>;
|
||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
||||
#[cfg(feature = "experimental")]
|
||||
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
|
||||
}
|
||||
|
||||
impl pallet_glutton::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = weights::pallet_glutton::WeightInfo<Runtime>;
|
||||
@@ -204,6 +241,7 @@ construct_runtime! {
|
||||
Pallet, Call, Config<T>, Storage, Inherent, Event<T>, ValidateUnsigned,
|
||||
} = 1,
|
||||
ParachainInfo: parachain_info::{Pallet, Storage, Config<T>} = 2,
|
||||
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3,
|
||||
|
||||
// DMP handler.
|
||||
CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin} = 10,
|
||||
@@ -211,6 +249,10 @@ construct_runtime! {
|
||||
// The main stage.
|
||||
Glutton: pallet_glutton::{Pallet, Call, Storage, Event, Config<T>} = 20,
|
||||
|
||||
// Collator support
|
||||
Aura: pallet_aura::{Pallet, Storage, Config<T>} = 30,
|
||||
AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config<T>} = 31,
|
||||
|
||||
// Sudo.
|
||||
Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>} = 255,
|
||||
}
|
||||
@@ -295,6 +337,16 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
||||
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
|
||||
}
|
||||
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
Aura::authorities().into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(
|
||||
extrinsic: <Block as BlockT>::Extrinsic,
|
||||
@@ -332,12 +384,14 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
impl sp_session::SessionKeys<Block> for Runtime {
|
||||
fn decode_session_keys(_: Vec<u8>) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
|
||||
Some(Vec::new())
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
SessionKeys::generate(seed)
|
||||
}
|
||||
|
||||
fn generate_session_keys(_: Option<Vec<u8>>) -> Vec<u8> {
|
||||
Vec::new()
|
||||
fn decode_session_keys(
|
||||
encoded: Vec<u8>,
|
||||
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
||||
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,5 +456,5 @@ impl_runtime_apis! {
|
||||
|
||||
cumulus_pallet_parachain_system::register_validate_block! {
|
||||
Runtime = Runtime,
|
||||
BlockExecutor = Executive,
|
||||
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
|
||||
}
|
||||
|
||||
@@ -15,3 +15,4 @@
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod pallet_glutton;
|
||||
pub mod pallet_timestamp;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright 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/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_timestamp`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-kusama-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=asset-hub-kusama-dev
|
||||
// --wasm-execution=compiled
|
||||
// --pallet=pallet_timestamp
|
||||
// --no-storage-info
|
||||
// --no-median-slopes
|
||||
// --no-min-squares
|
||||
// --extrinsic=*
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --json
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_timestamp`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_timestamp::WeightInfo for WeightInfo<T> {
|
||||
/// Storage: `Timestamp::Now` (r:1 w:1)
|
||||
/// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Aura::CurrentSlot` (r:1 w:0)
|
||||
/// Proof: `Aura::CurrentSlot` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
|
||||
fn set() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `86`
|
||||
// Estimated: `1493`
|
||||
// Minimum execution time: 9_313_000 picoseconds.
|
||||
Weight::from_parts(9_775_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1493))
|
||||
.saturating_add(T::DbWeight::get().reads(2))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
fn on_finalize() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `57`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 3_322_000 picoseconds.
|
||||
Weight::from_parts(3_577_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,13 @@ scale-info = { version = "2.9.0", default-features = false, features = ["derive"
|
||||
frame-executive = { path = "../../../../../substrate/frame/executive", default-features = false}
|
||||
frame-support = { path = "../../../../../substrate/frame/support", default-features = false}
|
||||
frame-system = { path = "../../../../../substrate/frame/system", default-features = false}
|
||||
pallet-aura = { path = "../../../../../substrate/frame/aura", default-features = false}
|
||||
pallet-balances = { path = "../../../../../substrate/frame/balances", default-features = false}
|
||||
pallet-sudo = { path = "../../../../../substrate/frame/sudo", default-features = false}
|
||||
pallet-timestamp = { path = "../../../../../substrate/frame/timestamp", default-features = false }
|
||||
sp-api = { path = "../../../../../substrate/primitives/api", default-features = false}
|
||||
sp-block-builder = { path = "../../../../../substrate/primitives/block-builder", default-features = false}
|
||||
sp-consensus-aura = { path = "../../../../../substrate/primitives/consensus/aura", default-features = false }
|
||||
sp-core = { path = "../../../../../substrate/primitives/core", default-features = false}
|
||||
sp-inherents = { path = "../../../../../substrate/primitives/inherents", default-features = false}
|
||||
sp-offchain = { path = "../../../../../substrate/primitives/offchain", default-features = false}
|
||||
@@ -26,11 +29,13 @@ sp-transaction-pool = { path = "../../../../../substrate/primitives/transaction-
|
||||
sp-version = { path = "../../../../../substrate/primitives/version", default-features = false}
|
||||
|
||||
# Cumulus
|
||||
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
|
||||
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
|
||||
cumulus-pallet-solo-to-para = { path = "../../../../pallets/solo-to-para", default-features = false }
|
||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||
cumulus-primitives-timestamp = { path = "../../../../primitives/timestamp", default-features = false }
|
||||
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
|
||||
parachains-common = { path = "../../../common", default-features = false }
|
||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder = { path = "../../../../../substrate/utils/wasm-builder", optional = true }
|
||||
@@ -39,19 +44,24 @@ substrate-wasm-builder = { path = "../../../../../substrate/utils/wasm-builder",
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"codec/std",
|
||||
"cumulus-pallet-aura-ext/std",
|
||||
"cumulus-pallet-parachain-system/std",
|
||||
"cumulus-pallet-solo-to-para/std",
|
||||
"cumulus-primitives-core/std",
|
||||
"cumulus-primitives-timestamp/std",
|
||||
"frame-executive/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"pallet-aura/std",
|
||||
"pallet-balances/std",
|
||||
"pallet-sudo/std",
|
||||
"pallet-timestamp/std",
|
||||
"parachain-info/std",
|
||||
"parachains-common/std",
|
||||
"scale-info/std",
|
||||
"sp-api/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-aura/std",
|
||||
"sp-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-offchain/std",
|
||||
@@ -62,3 +72,5 @@ std = [
|
||||
"sp-version/std",
|
||||
"substrate-wasm-builder",
|
||||
]
|
||||
|
||||
experimental = [ "pallet-aura/experimental" ]
|
||||
|
||||
@@ -27,11 +27,12 @@
|
||||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::OpaqueMetadata;
|
||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic,
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT},
|
||||
transaction_validity::{TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult,
|
||||
@@ -46,7 +47,7 @@ pub use frame_support::{
|
||||
construct_runtime,
|
||||
dispatch::DispatchClass,
|
||||
parameter_types,
|
||||
traits::{IsInVec, Randomness},
|
||||
traits::{ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, IsInVec, Randomness},
|
||||
weights::{
|
||||
constants::{
|
||||
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND,
|
||||
@@ -61,6 +62,12 @@ use parachains_common::{AccountId, Signature};
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use sp_runtime::{Perbill, Permill};
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
pub aura: Aura,
|
||||
}
|
||||
}
|
||||
|
||||
/// This runtime version.
|
||||
#[sp_version::runtime_version]
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
@@ -80,6 +87,15 @@ pub fn native_version() -> NativeVersion {
|
||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||
}
|
||||
|
||||
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
|
||||
/// into the relay chain.
|
||||
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
|
||||
/// How many parachain blocks are processed by the relay chain per parent. Limits the
|
||||
/// number of blocks authored per slot.
|
||||
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
|
||||
/// Relay chain slot duration, in milliseconds.
|
||||
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
|
||||
|
||||
/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers.
|
||||
/// This is used to limit the maximal weight of a single extrinsic.
|
||||
const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
||||
@@ -174,23 +190,49 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
type ReservedDmpWeight = ();
|
||||
type XcmpMessageHandler = ();
|
||||
type ReservedXcmpWeight = ();
|
||||
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
|
||||
type ConsensusHook = cumulus_pallet_parachain_system::consensus_hook::ExpectParentIncluded;
|
||||
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
|
||||
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
||||
Runtime,
|
||||
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
||||
BLOCK_PROCESSING_VELOCITY,
|
||||
UNINCLUDED_SEGMENT_CAPACITY,
|
||||
>;
|
||||
}
|
||||
|
||||
impl parachain_info::Config for Runtime {}
|
||||
|
||||
impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
type DisabledValidators = ();
|
||||
type MaxAuthorities = ConstU32<100_000>;
|
||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
||||
#[cfg(feature = "experimental")]
|
||||
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
type MinimumPeriod = ConstU64<0>;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
construct_runtime! {
|
||||
pub enum Runtime
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
|
||||
|
||||
ParachainSystem: cumulus_pallet_parachain_system::{
|
||||
Pallet, Call, Config<T>, Storage, Inherent, Event<T>, ValidateUnsigned,
|
||||
},
|
||||
ParachainInfo: parachain_info::{Pallet, Storage, Config<T>},
|
||||
SoloToPara: cumulus_pallet_solo_to_para::{Pallet, Call, Storage, Event},
|
||||
Aura: pallet_aura::{Pallet, Storage, Config<T>},
|
||||
AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config<T>},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +275,16 @@ pub type Executive = frame_executive::Executive<
|
||||
>;
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
||||
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
|
||||
}
|
||||
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
Aura::authorities().into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
@@ -298,12 +350,14 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
impl sp_session::SessionKeys<Block> for Runtime {
|
||||
fn decode_session_keys(_: Vec<u8>) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
|
||||
Some(Vec::new())
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
SessionKeys::generate(seed)
|
||||
}
|
||||
|
||||
fn generate_session_keys(_: Option<Vec<u8>>) -> Vec<u8> {
|
||||
Vec::new()
|
||||
fn decode_session_keys(
|
||||
encoded: Vec<u8>,
|
||||
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
||||
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,5 +370,5 @@ impl_runtime_apis! {
|
||||
|
||||
cumulus_pallet_parachain_system::register_validate_block! {
|
||||
Runtime = Runtime,
|
||||
BlockExecutor = Executive,
|
||||
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
|
||||
}
|
||||
|
||||
@@ -13,8 +13,11 @@ frame-executive = { path = "../../../../../substrate/frame/executive", default-f
|
||||
frame-support = { path = "../../../../../substrate/frame/support", default-features = false}
|
||||
frame-system = { path = "../../../../../substrate/frame/system", default-features = false}
|
||||
frame-try-runtime = { path = "../../../../../substrate/frame/try-runtime", default-features = false, optional = true }
|
||||
pallet-aura = { path = "../../../../../substrate/frame/aura", default-features = false}
|
||||
pallet-timestamp = { path = "../../../../../substrate/frame/timestamp", default-features = false }
|
||||
sp-api = { path = "../../../../../substrate/primitives/api", default-features = false}
|
||||
sp-block-builder = { path = "../../../../../substrate/primitives/block-builder", default-features = false}
|
||||
sp-consensus-aura = { path = "../../../../../substrate/primitives/consensus/aura", default-features = false }
|
||||
sp-core = { path = "../../../../../substrate/primitives/core", default-features = false}
|
||||
sp-inherents = { path = "../../../../../substrate/primitives/inherents", default-features = false}
|
||||
sp-offchain = { path = "../../../../../substrate/primitives/offchain", default-features = false}
|
||||
@@ -30,6 +33,7 @@ xcm-builder = { package = "staging-xcm-builder", path = "../../../../../polkadot
|
||||
xcm-executor = { package = "staging-xcm-executor", path = "../../../../../polkadot/xcm/xcm-executor", default-features = false}
|
||||
|
||||
# Cumulus
|
||||
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
|
||||
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
|
||||
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
|
||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||
@@ -43,6 +47,7 @@ substrate-wasm-builder = { path = "../../../../../substrate/utils/wasm-builder",
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"codec/std",
|
||||
"cumulus-pallet-aura-ext/std",
|
||||
"cumulus-pallet-parachain-system/std",
|
||||
"cumulus-pallet-xcm/std",
|
||||
"cumulus-primitives-core/std",
|
||||
@@ -50,11 +55,14 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"frame-try-runtime?/std",
|
||||
"pallet-aura/std",
|
||||
"pallet-timestamp/std",
|
||||
"parachain-info/std",
|
||||
"parachains-common/std",
|
||||
"scale-info/std",
|
||||
"sp-api/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-aura/std",
|
||||
"sp-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-offchain/std",
|
||||
@@ -69,12 +77,17 @@ std = [
|
||||
"xcm/std",
|
||||
]
|
||||
try-runtime = [
|
||||
"cumulus-pallet-aura-ext/try-runtime",
|
||||
"cumulus-pallet-parachain-system/try-runtime",
|
||||
"cumulus-pallet-xcm/try-runtime",
|
||||
"frame-executive/try-runtime",
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"frame-try-runtime/try-runtime",
|
||||
"pallet-aura/try-runtime",
|
||||
"pallet-timestamp/try-runtime",
|
||||
"parachain-info/try-runtime",
|
||||
"sp-runtime/try-runtime",
|
||||
]
|
||||
|
||||
experimental = [ "pallet-aura/experimental" ]
|
||||
|
||||
@@ -32,13 +32,14 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
pub mod xcm_config;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
|
||||
use frame_support::unsigned::TransactionValidityError;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::OpaqueMetadata;
|
||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic,
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, DispatchInfoOf},
|
||||
transaction_validity::{TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult,
|
||||
@@ -53,7 +54,7 @@ pub use frame_support::{
|
||||
construct_runtime,
|
||||
dispatch::DispatchClass,
|
||||
parameter_types,
|
||||
traits::{Everything, IsInVec, Randomness},
|
||||
traits::{ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, IsInVec, Randomness},
|
||||
weights::{
|
||||
constants::{
|
||||
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND,
|
||||
@@ -68,6 +69,12 @@ use parachains_common::{AccountId, Signature};
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use sp_runtime::{Perbill, Permill};
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
pub aura: Aura,
|
||||
}
|
||||
}
|
||||
|
||||
/// This runtime version.
|
||||
#[sp_version::runtime_version]
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
@@ -87,6 +94,15 @@ pub fn native_version() -> NativeVersion {
|
||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||
}
|
||||
|
||||
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
|
||||
/// into the relay chain.
|
||||
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
|
||||
/// How many parachain blocks are processed by the relay chain per parent. Limits the
|
||||
/// number of blocks authored per slot.
|
||||
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
|
||||
/// Relay chain slot duration, in milliseconds.
|
||||
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
|
||||
|
||||
/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers.
|
||||
/// This is used to limit the maximal weight of a single extrinsic.
|
||||
const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
||||
@@ -177,16 +193,41 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
type ReservedDmpWeight = ReservedDmpWeight;
|
||||
type XcmpMessageHandler = ();
|
||||
type ReservedXcmpWeight = ();
|
||||
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
|
||||
type ConsensusHook = cumulus_pallet_parachain_system::consensus_hook::ExpectParentIncluded;
|
||||
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
|
||||
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
||||
Runtime,
|
||||
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
||||
BLOCK_PROCESSING_VELOCITY,
|
||||
UNINCLUDED_SEGMENT_CAPACITY,
|
||||
>;
|
||||
}
|
||||
|
||||
impl parachain_info::Config for Runtime {}
|
||||
|
||||
impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
type DisabledValidators = ();
|
||||
type MaxAuthorities = ConstU32<100_000>;
|
||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
||||
#[cfg(feature = "experimental")]
|
||||
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
type MinimumPeriod = ConstU64<0>;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
construct_runtime! {
|
||||
pub enum Runtime
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
|
||||
|
||||
ParachainSystem: cumulus_pallet_parachain_system::{
|
||||
Pallet, Call, Config<T>, Storage, Inherent, Event<T>, ValidateUnsigned,
|
||||
},
|
||||
@@ -194,6 +235,9 @@ construct_runtime! {
|
||||
|
||||
// DMP handler.
|
||||
CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin},
|
||||
|
||||
Aura: pallet_aura::{Pallet, Storage, Config<T>},
|
||||
AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config<T>},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +307,16 @@ pub type Executive = frame_executive::Executive<
|
||||
>;
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
||||
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
|
||||
}
|
||||
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
Aura::authorities().into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
@@ -328,12 +382,14 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
impl sp_session::SessionKeys<Block> for Runtime {
|
||||
fn decode_session_keys(_: Vec<u8>) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
|
||||
Some(Vec::new())
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
SessionKeys::generate(seed)
|
||||
}
|
||||
|
||||
fn generate_session_keys(_: Option<Vec<u8>>) -> Vec<u8> {
|
||||
Vec::new()
|
||||
fn decode_session_keys(
|
||||
encoded: Vec<u8>,
|
||||
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
||||
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,5 +402,5 @@ impl_runtime_apis! {
|
||||
|
||||
cumulus_pallet_parachain_system::register_validate_block! {
|
||||
Runtime = Runtime,
|
||||
BlockExecutor = Executive,
|
||||
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user