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

Introduce Fellowship into Collectives #2186

Merged
merged 26 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
29a3125
Fellowship into Collectives
muharem Feb 15, 2023
11bad7b
Merge remote-tracking branch 'origin/master' into muharem-collectives…
muharem Feb 15, 2023
2d6f124
cargo.lock
muharem Feb 15, 2023
2ccb3d7
tracks alias
muharem Feb 15, 2023
a1332a9
allow to send Fellows origin over XCM
muharem Feb 15, 2023
63d799c
update todos, remove duplication of type
muharem Feb 15, 2023
916997a
use Collectives location for Fellows body
muharem Feb 15, 2023
7b772d2
alias for ranks constants
muharem Feb 16, 2023
97f6629
benchmarks
muharem Feb 16, 2023
1f9cfdd
proxy for Fellowship
muharem Feb 16, 2023
34a7bd3
docs
muharem Feb 16, 2023
6ece4f3
correct copyright date
muharem Feb 20, 2023
7213d57
Apply suggestions from code review
muharem Feb 25, 2023
ea0abd1
Merge remote-tracking branch 'origin/master' into muharem-collectives…
muharem Feb 25, 2023
0b82eaf
rustfmt
muharem Feb 25, 2023
03f5c87
remove council, update origins
muharem Feb 25, 2023
73a2f36
renames
muharem Feb 25, 2023
58c986e
remove tech committee from promote origin
muharem Feb 25, 2023
c0fe803
renames
muharem Feb 26, 2023
8127b8f
doc nits
joepetrowski Mar 6, 2023
9499e4f
Merge remote-tracking branch 'origin/master' into muharem-collectives…
muharem Mar 6, 2023
45a5976
weights with new api
muharem Mar 6, 2023
ed4b336
sane weights for pallet_scheduler
muharem Mar 10, 2023
63796bd
XCM tweaks for OpenGov (#2305)
muharem Mar 12, 2023
b860a02
Merge remote-tracking branch 'origin/master' into muharem-collectives…
muharem Mar 21, 2023
930bca8
remove match arm duplication
muharem Mar 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -425,11 +426,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
20 changes: 6 additions & 14 deletions parachains/runtimes/assets/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use xcm_config::{KsmLocation, XcmConfig};
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 @@ -223,12 +223,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 @@ -468,10 +466,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<KsmLocation, FellowsBodyId>>,
>;
type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
Expand Down Expand Up @@ -519,13 +514,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<KsmLocation, StakingAdminBodyId>>,
>;

impl pallet_collator_selection::Config for Runtime {
Expand Down
27 changes: 17 additions & 10 deletions parachains/runtimes/assets/statemint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ use parachains_common::{
Signature, StatemintAuraId as AuraId, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT,
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use xcm_config::{DotLocation, XcmConfig, XcmOriginToTransactDispatchOrigin};
use xcm_config::{CollectivesLocation, DotLocation, 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 @@ -238,12 +238,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 @@ -470,6 +468,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 @@ -479,7 +482,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type ControllerOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsMajorityOfBody<DotLocation, ExecutiveBody>>,
EnsureXcm<IsVoiceOfBody<CollectivesLocation, FellowsBodyId>>,
>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type PriceForSiblingDelivery = ();
Expand Down Expand Up @@ -522,11 +525,15 @@ parameter_types! {
pub const MinCandidates: u32 = 5;
pub const SessionLength: BlockNumber = 6 * HOURS;
pub const MaxInvulnerables: u32 = 100;
// StakingAdmin pluralistic body.
joepetrowski marked this conversation as resolved.
Show resolved Hide resolved
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.
joepetrowski marked this conversation as resolved.
Show resolved Hide resolved
pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsVoiceOfBody<DotLocation, StakingAdminBodyId>>,
>;

impl pallet_collator_selection::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down
1 change: 1 addition & 0 deletions parachains/runtimes/assets/statemint/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ parameter_types! {
pub TrustBackedAssetsPalletLocation: MultiLocation =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub CollectivesLocation: MultiLocation = MultiLocation::new(1, Parachain(1001));
}

/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
Expand Down
27 changes: 17 additions & 10 deletions parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ 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};
Expand Down Expand Up @@ -287,11 +287,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<KsmRelayLocation, FellowsBodyId>>,
>;

impl cumulus_pallet_xcmp_queue::Config for Runtime {
Expand All @@ -300,7 +304,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 @@ -338,12 +342,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<KsmRelayLocation, StakingAdminBodyId>>,
>;

impl pallet_collator_selection::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down
27 changes: 18 additions & 9 deletions parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ 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::{CollectivesLocation, XcmConfig, XcmOriginToTransactDispatchOrigin};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand Down Expand Up @@ -287,10 +287,15 @@ impl parachain_info::Config for Runtime {}

impl cumulus_pallet_aura_ext::Config for Runtime {}

/// 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.
pub type RootOrFellows = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsMajorityOfBody<DotRelayLocation, ExecutiveBody>>,
EnsureXcm<IsVoiceOfBody<CollectivesLocation, FellowsBodyId>>,
>;

impl cumulus_pallet_xcmp_queue::Config for Runtime {
Expand All @@ -299,7 +304,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 @@ -337,11 +342,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;
}

/// 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<DotRelayLocation, StakingAdminBodyId>>,
muharem marked this conversation as resolved.
Show resolved Hide resolved
>;

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,7 @@ parameter_types! {
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub CollectivesLocation: MultiLocation = MultiLocation::new(1, Parachain(1001));
}

/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
Expand Down
2 changes: 0 additions & 2 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ use parachains_common::{
opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature,
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use xcm::latest::prelude::BodyId;
use xcm_executor::XcmExecutor;

/// The address format for describing accounts.
Expand Down Expand Up @@ -368,7 +367,6 @@ 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;
}

pub type CollatorSelectionUpdateOrigin = EnsureRoot<AccountId>;
Expand Down
17 changes: 17 additions & 0 deletions parachains/runtimes/collectives/collectives-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ pallet-authorship = { git = "https://github.com/paritytech/substrate", default-f
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-referenda = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-ranked-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down Expand Up @@ -95,6 +100,10 @@ runtime-benchmarks = [
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-ranked-collective/runtime-benchmarks",
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand All @@ -119,6 +128,10 @@ try-runtime = [
"pallet-utility/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-preimage/try-runtime",
"pallet-referenda/try-runtime",
"pallet-ranked-collective/try-runtime",
]
std = [
"codec/std",
Expand Down Expand Up @@ -170,4 +183,8 @@ std = [
"pallet-collator-selection/std",
"parachain-info/std",
"parachains-common/std",
"pallet-scheduler/std",
"pallet-preimage/std",
"pallet-referenda/std",
"pallet-ranked-collective/std",
]
Loading