mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11: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:
@@ -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>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user