mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 22:51:03 +00:00
Add Parachain Onboarding to Rococo (#2660)
* Add Parachain Onboarding Pallets to Rococo * remove propose_parachain * add back para sudo wrapper * Revert "remove propose_parachain" This reverts commit 38b7c33c817964c9f8ad48531a72aede83670291. * turn propose_parachains into validator_manager * Update runtime/rococo/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * update origin Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -40,12 +40,12 @@ use runtime_parachains::{
|
||||
};
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{EnsureOrigin, Filter, KeyOwnerProofSystem, Randomness},
|
||||
traits::{Filter, KeyOwnerProofSystem, Randomness},
|
||||
weights::Weight,
|
||||
};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
ApplyExtrinsicResult, KeyTypeId, Perbill,
|
||||
ApplyExtrinsicResult, KeyTypeId, Perbill, ModuleId,
|
||||
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, OpaqueKeys, AccountIdLookup,
|
||||
@@ -62,8 +62,8 @@ use pallet_grandpa::{AuthorityId as GrandpaId, fg_primitives};
|
||||
use sp_core::OpaqueMetadata;
|
||||
use sp_staking::SessionIndex;
|
||||
use pallet_session::historical as session_historical;
|
||||
use frame_system::{EnsureRoot, EnsureOneOf, EnsureSigned};
|
||||
use runtime_common::{paras_sudo_wrapper, paras_registrar, xcm_sender};
|
||||
use frame_system::EnsureRoot;
|
||||
use runtime_common::{paras_sudo_wrapper, paras_registrar, xcm_sender, auctions, crowdloan, slots};
|
||||
|
||||
use runtime_parachains::origin as parachains_origin;
|
||||
use runtime_parachains::configuration as parachains_configuration;
|
||||
@@ -92,7 +92,7 @@ use constants::{time::*, currency::*, fee::*};
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
mod propose_parachain;
|
||||
mod validator_manager;
|
||||
|
||||
// Make the WASM binary available.
|
||||
#[cfg(feature = "std")]
|
||||
@@ -208,14 +208,18 @@ construct_runtime! {
|
||||
Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event},
|
||||
SessionInfo: parachains_session_info::{Pallet, Call, Storage},
|
||||
|
||||
// Parachain Onboarding Pallets
|
||||
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>},
|
||||
Auctions: auctions::{Pallet, Call, Storage, Event<T>},
|
||||
Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>},
|
||||
Slots: slots::{Pallet, Call, Storage, Event<T>},
|
||||
ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call},
|
||||
|
||||
// Sudo
|
||||
Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>},
|
||||
|
||||
// Propose parachain pallet.
|
||||
ProposeParachain: propose_parachain::{Pallet, Call, Storage, Event<T>},
|
||||
// Validator Manager pallet.
|
||||
ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,7 +422,7 @@ impl pallet_session::Config for Runtime {
|
||||
type ValidatorIdOf = ValidatorIdOf;
|
||||
type ShouldEndSession = Babe;
|
||||
type NextSessionRotation = Babe;
|
||||
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, ProposeParachain>;
|
||||
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, ValidatorManager>;
|
||||
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
|
||||
type Keys = SessionKeys;
|
||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||
@@ -600,7 +604,7 @@ impl paras_registrar::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type Currency = Balances;
|
||||
type OnSwap = ();
|
||||
type OnSwap = (Crowdloan, Slots);
|
||||
type ParaDeposit = ParaDeposit;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type MaxCodeSize = MaxCodeSize;
|
||||
@@ -608,44 +612,60 @@ impl paras_registrar::Config for Runtime {
|
||||
type WeightInfo = paras_registrar::TestWeightInfo;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const EndingPeriod: BlockNumber = 15 * MINUTES;
|
||||
}
|
||||
|
||||
impl auctions::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Leaser = Slots;
|
||||
type EndingPeriod = EndingPeriod;
|
||||
type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
|
||||
type InitiateOrigin = EnsureRoot<AccountId>;
|
||||
type WeightInfo = auctions::TestWeightInfo;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const LeasePeriod: BlockNumber = 1 * DAYS;
|
||||
}
|
||||
|
||||
impl slots::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type Registrar = Registrar;
|
||||
type LeasePeriod = LeasePeriod;
|
||||
type WeightInfo = slots::TestWeightInfo;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CrowdloanId: ModuleId = ModuleId(*b"py/cfund");
|
||||
pub const SubmissionDeposit: Balance = 100 * DOLLARS;
|
||||
pub const MinContribution: Balance = 1 * DOLLARS;
|
||||
pub const RetirementPeriod: BlockNumber = 6 * HOURS;
|
||||
pub const RemoveKeysLimit: u32 = 500;
|
||||
}
|
||||
|
||||
impl crowdloan::Config for Runtime {
|
||||
type Event = Event;
|
||||
type ModuleId = CrowdloanId;
|
||||
type SubmissionDeposit = SubmissionDeposit;
|
||||
type MinContribution = MinContribution;
|
||||
type RetirementPeriod = RetirementPeriod;
|
||||
type OrphanedFunds = ();
|
||||
type RemoveKeysLimit = RemoveKeysLimit;
|
||||
type Registrar = Registrar;
|
||||
type Auctioneer = Auctions;
|
||||
type WeightInfo = crowdloan::TestWeightInfo;
|
||||
}
|
||||
|
||||
impl pallet_sudo::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
}
|
||||
|
||||
/// Priviledged origin used by propose parachain.
|
||||
pub struct PriviledgedOrigin;
|
||||
|
||||
impl EnsureOrigin<Origin> for PriviledgedOrigin {
|
||||
type Success = ();
|
||||
|
||||
fn try_origin(o: Origin) -> Result<Self::Success, Origin> {
|
||||
let allowed = [
|
||||
hex_literal::hex!("b44c58e50328768ac06ed44b842bfa69d86ea10f60bc36156c9ffc5e00867220"),
|
||||
hex_literal::hex!("762a6a38ba72b139cba285a39a6766e02046fb023f695f5ecf7f48b037c0dd6b")
|
||||
];
|
||||
|
||||
let origin = o.clone();
|
||||
match EnsureSigned::try_origin(o) {
|
||||
Ok(who) if allowed.iter().any(|a| a == &who.as_ref()) => Ok(()),
|
||||
_ => Err(origin),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin() -> Origin { Origin::root() }
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ProposeDeposit: Balance = 1000 * DOLLARS;
|
||||
pub const MaxNameLength: u32 = 20;
|
||||
}
|
||||
|
||||
impl propose_parachain::Config for Runtime {
|
||||
impl validator_manager::Config for Runtime {
|
||||
type Event = Event;
|
||||
type MaxNameLength = MaxNameLength;
|
||||
type ProposeDeposit = ProposeDeposit;
|
||||
type PriviledgedOrigin = EnsureOneOf<AccountId, EnsureRoot<AccountId>, PriviledgedOrigin>;
|
||||
type PrivilegedOrigin = EnsureRoot<AccountId>;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "disable-runtime-api"))]
|
||||
|
||||
Reference in New Issue
Block a user