Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Introduce Fellowship into Collectives (#2186)
Browse files Browse the repository at this point in the history
* Fellowship into Collectives

* cargo.lock

* tracks alias

* allow to send Fellows origin over XCM

* update todos, remove duplication of type

* use Collectives location for Fellows body

* alias for ranks constants

* benchmarks

* proxy for Fellowship

* docs

* correct copyright date

* Apply suggestions from code review

Co-authored-by: joe petrowski <[email protected]>

* rustfmt

* remove council, update origins

* renames

* remove tech committee from promote origin

* renames

* doc nits

* weights with new api

* sane weights for pallet_scheduler

* XCM tweaks for OpenGov (#2305)

* updated xcm configs for collectives and statemint

* remove xcm send from safe filter

* remove prod_or_fast

* remove empty line

* drop redundant aggregation

* remove match arm duplication

---------

Co-authored-by: joe petrowski <[email protected]>
  • Loading branch information
muharem and joepetrowski authored Mar 21, 2023
1 parent a2e5508 commit 7623aba
Show file tree
Hide file tree
Showing 24 changed files with 1,914 additions and 113 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use frame_support::{
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{ConstU32, ConstU64, ConstU8, Everything},
traits::{ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything},
weights::{
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
Expand All @@ -40,9 +40,10 @@ use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot,
};
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin};
use xcm_config::{RelayLocation, XcmConfig, XcmOriginToTransactDispatchOrigin};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand Down Expand Up @@ -429,11 +430,15 @@ parameter_types! {
pub const MinCandidates: u32 = 5;
pub const SessionLength: BlockNumber = 6 * HOURS;
pub const MaxInvulnerables: u32 = 100;
pub const ExecutiveBody: BodyId = BodyId::Executive;
// StakingAdmin pluralistic body.
pub const StakingAdminBodyId: BodyId = BodyId::Defense;
}

// We allow root only to execute privileged collator selection operations.
pub type CollatorSelectionUpdateOrigin = EnsureRoot<AccountId>;
/// We allow root and the StakingAdmin to execute privileged collator selection operations.
pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsVoiceOfBody<RelayLocation, StakingAdminBodyId>>,
>;

impl pallet_collator_selection::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down
25 changes: 10 additions & 15 deletions parachains/runtimes/assets/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ use parachains_common::{
Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT,
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use xcm_config::{KsmLocation, TrustBackedAssetsConvertedConcreteId, XcmConfig};
use xcm_config::{
FellowshipLocation, GovernanceLocation, KsmLocation, TrustBackedAssetsConvertedConcreteId,
XcmConfig,
};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

// Polkadot imports
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, IsVoiceOfBody};
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use xcm::latest::BodyId;
use xcm_executor::XcmExecutor;
Expand Down Expand Up @@ -228,12 +231,10 @@ parameter_types! {
// https://github.com/paritytech/substrate/blob/069917b/frame/assets/src/lib.rs#L257L271
pub const MetadataDepositBase: Balance = deposit(1, 68);
pub const MetadataDepositPerByte: Balance = deposit(0, 1);
pub const ExecutiveBody: BodyId = BodyId::Executive;
}

/// We allow root and the Relay Chain council to execute privileged asset operations.
pub type AssetsForceOrigin =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureXcm<IsMajorityOfBody<KsmLocation, ExecutiveBody>>>;
/// We allow root to execute privileged asset operations.
pub type AssetsForceOrigin = EnsureRoot<AccountId>;

// Called "Trust Backed" assets because these are generally registered by some account, and users of
// the asset assume it has some claimed backing. The pallet is called `Assets` in
Expand Down Expand Up @@ -492,10 +493,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type ControllerOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<(
IsMajorityOfBody<KsmLocation, ExecutiveBody>,
IsVoiceOfBody<KsmLocation, FellowsBodyId>,
)>,
EnsureXcm<IsVoiceOfBody<FellowshipLocation, FellowsBodyId>>,
>;
type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
Expand Down Expand Up @@ -543,13 +541,10 @@ parameter_types! {
pub const StakingAdminBodyId: BodyId = BodyId::Defense;
}

/// We allow root, the Relay Chain council and the StakingAdmin to execute privileged collator selection operations.
/// We allow root the StakingAdmin to execute privileged collator selection operations.
pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<(
IsMajorityOfBody<KsmLocation, ExecutiveBody>,
IsVoiceOfBody<KsmLocation, StakingAdminBodyId>,
)>,
EnsureXcm<IsVoiceOfBody<GovernanceLocation, StakingAdminBodyId>>,
>;

impl pallet_collator_selection::Config for Runtime {
Expand Down
2 changes: 2 additions & 0 deletions parachains/runtimes/assets/statemine/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ parameter_types! {
pub TrustBackedAssetsPalletLocation: MultiLocation =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
pub const FellowshipLocation: MultiLocation = MultiLocation::parent();
}

/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
Expand Down
28 changes: 18 additions & 10 deletions parachains/runtimes/assets/statemint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ use parachains_common::{
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use xcm_config::{
DotLocation, TrustBackedAssetsConvertedConcreteId, XcmConfig, XcmOriginToTransactDispatchOrigin,
DotLocation, FellowshipLocation, GovernanceLocation, TrustBackedAssetsConvertedConcreteId,
XcmConfig, XcmOriginToTransactDispatchOrigin,
};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

// Polkadot imports
use pallet_xcm::{EnsureXcm, IsMajorityOfBody};
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use xcm::latest::BodyId;
use xcm_executor::XcmExecutor;
Expand Down Expand Up @@ -244,12 +245,10 @@ parameter_types! {
// https://github.com/paritytech/substrate/blob/069917b/frame/assets/src/lib.rs#L257L271
pub const MetadataDepositBase: Balance = deposit(1, 68);
pub const MetadataDepositPerByte: Balance = deposit(0, 1);
pub const ExecutiveBody: BodyId = BodyId::Executive;
}

/// We allow root and the Relay Chain council to execute privileged asset operations.
pub type AssetsForceOrigin =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureXcm<IsMajorityOfBody<DotLocation, ExecutiveBody>>>;
/// We allow root to execute privileged asset operations.
pub type AssetsForceOrigin = EnsureRoot<AccountId>;

// Called "Trust Backed" assets because these are generally registered by some account, and users of
// the asset assume it has some claimed backing. The pallet is called `Assets` in
Expand Down Expand Up @@ -476,6 +475,11 @@ impl parachain_info::Config for Runtime {}

impl cumulus_pallet_aura_ext::Config for Runtime {}

parameter_types! {
// Fellows pluralistic body.
pub const FellowsBodyId: BodyId = BodyId::Technical;
}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
Expand All @@ -485,7 +489,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type ControllerOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsMajorityOfBody<DotLocation, ExecutiveBody>>,
EnsureXcm<IsVoiceOfBody<FellowshipLocation, FellowsBodyId>>,
>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type PriceForSiblingDelivery = ();
Expand Down Expand Up @@ -528,11 +532,15 @@ parameter_types! {
pub const MinCandidates: u32 = 5;
pub const SessionLength: BlockNumber = 6 * HOURS;
pub const MaxInvulnerables: u32 = 100;
// `StakingAdmin` pluralistic body.
pub const StakingAdminBodyId: BodyId = BodyId::Defense;
}

/// We allow root and the Relay Chain council to execute privileged collator selection operations.
pub type CollatorSelectionUpdateOrigin =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureXcm<IsMajorityOfBody<DotLocation, ExecutiveBody>>>;
/// We allow root and the `StakingAdmin` to execute privileged collator selection operations.
pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsVoiceOfBody<GovernanceLocation, StakingAdminBodyId>>,
>;

impl pallet_collator_selection::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down
12 changes: 9 additions & 3 deletions parachains/runtimes/assets/statemint/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ parameter_types! {
pub TrustBackedAssetsPalletLocation: MultiLocation =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub FellowshipLocation: MultiLocation = MultiLocation::new(1, Parachain(1001));
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
}

/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -142,6 +144,9 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(_) }
};
pub type FellowsPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) }
};
}

/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
Expand Down Expand Up @@ -176,7 +181,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_collator_selection::Call::set_desired_candidates { .. } |
pallet_collator_selection::Call::set_candidacy_bond { .. } |
pallet_collator_selection::Call::register_as_candidate { .. } |
pallet_collator_selection::Call::leave_intent { .. },
pallet_collator_selection::Call::leave_intent { .. } |
pallet_collator_selection::Call::set_invulnerables { .. },
) |
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::XcmpQueue(..) |
Expand Down Expand Up @@ -253,8 +259,8 @@ pub type Barrier = DenyThenTry<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its plurality (i.e. governance bodies) gets free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Parent, its plurality (i.e. governance bodies) and Fellows plurality gets free execution.
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
),
Expand Down
34 changes: 21 additions & 13 deletions parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot,
};
use pallet_xcm::{EnsureXcm, IsMajorityOfBody};
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin};
use xcm_config::{
FellowshipLocation, GovernanceLocation, XcmConfig, XcmOriginToTransactDispatchOrigin,
};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand All @@ -67,12 +69,11 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};

use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};

// XCM Imports
use crate::xcm_config::KsmRelayLocation;
use parachains_common::{
opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature,
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
// XCM Imports
use xcm::latest::prelude::BodyId;
use xcm_executor::XcmExecutor;

Expand Down Expand Up @@ -291,11 +292,15 @@ impl parachain_info::Config for Runtime {}

impl cumulus_pallet_aura_ext::Config for Runtime {}

// TODO: map gov2 origins here - after merge https://github.com/paritytech/cumulus/pull/1895
/// Privileged origin that represents Root or the majority of the Relay Chain Council.
pub type RootOrExecutiveSimpleMajority = EitherOfDiverse<
parameter_types! {
// Fellows pluralistic body.
pub const FellowsBodyId: BodyId = BodyId::Technical;
}

/// Privileged origin that represents Root or Fellows pluralistic body.
pub type RootOrFellows = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsMajorityOfBody<KsmRelayLocation, ExecutiveBody>>,
EnsureXcm<IsVoiceOfBody<FellowshipLocation, FellowsBodyId>>,
>;

impl cumulus_pallet_xcmp_queue::Config for Runtime {
Expand All @@ -304,7 +309,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ChannelInfo = ParachainSystem;
type VersionWrapper = PolkadotXcm;
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type ControllerOrigin = RootOrExecutiveSimpleMajority;
type ControllerOrigin = RootOrFellows;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
type PriceForSiblingDelivery = ();
Expand Down Expand Up @@ -342,12 +347,15 @@ impl pallet_aura::Config for Runtime {
parameter_types! {
pub const PotId: PalletId = PalletId(*b"PotStake");
pub const SessionLength: BlockNumber = 6 * HOURS;
pub const ExecutiveBody: BodyId = BodyId::Executive;
// StakingAdmin pluralistic body.
pub const StakingAdminBodyId: BodyId = BodyId::Defense;
}

// TODO: map gov2 origins here - after merge https://github.com/paritytech/cumulus/pull/1895
/// We allow root and the Relay Chain council to execute privileged collator selection operations.
pub type CollatorSelectionUpdateOrigin = RootOrExecutiveSimpleMajority;
/// We allow root, the StakingAdmin to execute privileged collator selection operations.
pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsVoiceOfBody<GovernanceLocation, StakingAdminBodyId>>,
>;

impl pallet_collator_selection::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ parameter_types! {
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
pub const FellowshipLocation: MultiLocation = MultiLocation::parent();
}

/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
Expand Down
Loading

0 comments on commit 7623aba

Please sign in to comment.