Unverified Commit 373cf924 authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Introduce/integrate a collective into Rococo Relay (#2869)



* Introduce a collective into Rococo runtime

* Intregrate Rococo Collective into XCM

* Fixes

* Update runtime/rococo/src/lib.rs

Co-authored-by: asynchronous rob's avatarRobert Habermeier <rphmeier@gmail.com>
parent f1c42ce6
Pipeline #133869 failed with stages
in 21 minutes and 38 seconds
......@@ -7335,6 +7335,7 @@ dependencies = [
"pallet-grandpa",
"pallet-im-online",
"pallet-indices",
"pallet-membership",
"pallet-mmr",
"pallet-mmr-primitives",
"pallet-offences",
......
......@@ -881,6 +881,8 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
},
pallet_grandpa: Default::default(),
pallet_im_online: Default::default(),
pallet_collective: Default::default(),
pallet_membership: Default::default(),
pallet_authority_discovery: rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
},
......@@ -1432,6 +1434,8 @@ pub fn rococo_testnet_genesis(
},
pallet_grandpa: Default::default(),
pallet_im_online: Default::default(),
pallet_collective: Default::default(),
pallet_membership: Default::default(),
pallet_authority_discovery: rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
},
......
......@@ -40,6 +40,7 @@ pallet-collective = { git = "https://github.com/paritytech/substrate", branch =
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
......@@ -87,6 +88,7 @@ std = [
"pallet-beefy/std",
"pallet-grandpa/std",
"pallet-sudo/std",
"pallet-membership/std",
"pallet-mmr/std",
"pallet-mmr-primitives/std",
"pallet-indices/std",
......@@ -159,6 +161,7 @@ try-runtime = [
"pallet-sudo/try-runtime",
"pallet-indices/try-runtime",
"pallet-im-online/try-runtime",
"pallet-membership/try-runtime",
"pallet-session/try-runtime",
"pallet-staking/try-runtime",
"pallet-offences/try-runtime",
......
......@@ -85,14 +85,10 @@ use runtime_parachains::scheduler as parachains_scheduler;
pub use pallet_balances::Call as BalancesCall;
use polkadot_parachain::primitives::Id as ParaId;
use xcm::v0::{MultiLocation, NetworkId};
use xcm::v0::{MultiLocation, NetworkId, BodyId};
use xcm_executor::XcmExecutor;
use xcm_builder::{
AccountId32Aliases, ChildParachainConvertsVia, SovereignSignedViaLocation,
CurrencyAdapter as XcmCurrencyAdapter, ChildParachainAsNative,
SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, LocationInverter,
IsConcrete, FixedWeightBounds, FixedRateOfConcreteFungible,
};
use xcm_builder::{AccountId32Aliases, ChildParachainConvertsVia, SovereignSignedViaLocation, CurrencyAdapter as XcmCurrencyAdapter, ChildParachainAsNative, SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, LocationInverter, IsConcrete, FixedWeightBounds, FixedRateOfConcreteFungible, BackingToPlurality, SignedToAccountId32};
use constants::{time::*, currency::*, fee::*};
use frame_support::traits::InstanceFilter;
......@@ -273,6 +269,10 @@ construct_runtime! {
// Validator Manager pallet.
ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>},
// A "council"
Collective: pallet_collective::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 80,
Membership: pallet_membership::{Pallet, Call, Storage, Event<T>, Config<T>} = 81,
Utility: pallet_utility::{Pallet, Call, Event} = 90,
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 91,
......@@ -645,9 +645,17 @@ impl xcm_executor::Config for XcmConfig {
type ResponseHandler = ();
}
parameter_types! {
pub const CollectiveBodyId: BodyId = BodyId::Unit;
}
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
/// of this chain.
pub type LocalOriginToLocation = (
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality
BackingToPlurality<Origin, pallet_collective::Origin<Runtime>, CollectiveBodyId>,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<Origin, AccountId, RococoNetwork>,
);
impl pallet_xcm::Config for Runtime {
......@@ -856,6 +864,34 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}
parameter_types! {
pub const MotionDuration: BlockNumber = 5;
pub const MaxProposals: u32 = 100;
pub const MaxMembers: u32 = 100;
}
impl pallet_collective::Config for Runtime {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
type MotionDuration = MotionDuration;
type MaxProposals = MaxProposals;
type MaxMembers = MaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = ();
}
impl pallet_membership::Config for Runtime {
type Event = Event;
type AddOrigin = EnsureRoot<AccountId>;
type RemoveOrigin = EnsureRoot<AccountId>;
type SwapOrigin = EnsureRoot<AccountId>;
type ResetOrigin = EnsureRoot<AccountId>;
type PrimeOrigin = EnsureRoot<AccountId>;
type MembershipInitialized = Collective;
type MembershipChanged = Collective;
}
#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
......
......@@ -31,7 +31,7 @@ mod origin_conversion;
pub use origin_conversion::{
SovereignSignedViaLocation, ParentAsSuperuser, ChildSystemParachainAsSuperuser, SiblingSystemParachainAsSuperuser,
ChildParachainAsNative, SiblingParachainAsNative, RelayChainAsNative, SignedAccountId32AsNative,
SignedAccountKey20AsNative, EnsureXcmOrigin, SignedToAccountId32
SignedAccountKey20AsNative, EnsureXcmOrigin, SignedToAccountId32, BackingToPlurality,
};
mod barriers;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment