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

Introduce OpenGov into Polkadot #6701

Merged
merged 32 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7775806
OpenGov for Polkadot
gavofyork Feb 10, 2023
e44fb68
Integrate OpenGov into XCM
gavofyork Feb 10, 2023
9d50725
Formatting
gavofyork Feb 10, 2023
a824333
Missing files
gavofyork Feb 11, 2023
5efe485
Remove Gov1 from Kusama
gavofyork Feb 12, 2023
93ccc33
Fixes
gavofyork Feb 12, 2023
1e5595e
Update runtime/polkadot/src/governance/origins.rs
gavofyork Feb 13, 2023
1dd6547
Revert scheduler origin changes
gavofyork Feb 13, 2023
8b789a3
Fixes
gavofyork Feb 13, 2023
8a97aff
Merge branch 'gav-polkadot-opengov' of github.com:paritytech/polkadot…
gavofyork Feb 13, 2023
61a9d4c
Docs
gavofyork Feb 13, 2023
5801157
Remove todo
gavofyork Feb 13, 2023
8a0cfe7
Docs
gavofyork Feb 13, 2023
b24a265
Merge remote-tracking branch 'origin/master' into gav-polkadot-opengov
gavofyork Feb 13, 2023
f95b1c2
Merge remote-tracking branch 'origin/master' into gav-polkadot-opengov
Feb 15, 2023
ae2ad9b
Move Fellowship to Collectives (#6718)
muharem Feb 15, 2023
b8e250a
define benchmarks
muharem Feb 16, 2023
d754468
correct comment for DOLLARS constant
muharem Feb 16, 2023
8266b6a
Add OpenGov Calls to Proxy Definitions (#6729)
joepetrowski Feb 16, 2023
4f0e3c5
Update runtime/polkadot/src/governance/mod.rs
gavofyork Feb 24, 2023
46390e9
Update runtime/polkadot/src/governance/tracks.rs
gavofyork Feb 24, 2023
a13c87f
Update runtime/polkadot/src/lib.rs
gavofyork Feb 24, 2023
c82efaa
Update runtime/polkadot/src/governance/origins.rs
gavofyork Feb 24, 2023
3b4bf5b
Update runtime/polkadot/src/governance/mod.rs
gavofyork Feb 24, 2023
9cbffa4
Update old.rs
gavofyork Feb 24, 2023
2a980ba
Update old.rs
gavofyork Feb 24, 2023
42e4d14
Merge remote-tracking branch 'origin/master' into gav-polkadot-opengov
gavofyork Feb 24, 2023
509f723
Merge remote-tracking branch 'origin/master' into gav-polkadot-opengov
Mar 7, 2023
97e7f75
weights with new api
muharem Mar 7, 2023
c2b8e5a
XCM tweaks for OpenGov (#6855)
muharem Mar 16, 2023
94ed887
Merge branch 'master' into gav-polkadot-opengov
gavofyork Mar 21, 2023
fda6c7c
remove unused import
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
4 changes: 4 additions & 0 deletions Cargo.lock

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

16 changes: 0 additions & 16 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,6 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
},
phragmen_election: Default::default(),
democracy: Default::default(),
council: kusama::CouncilConfig { members: vec![], phantom: Default::default() },
technical_committee: kusama::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
},
technical_membership: Default::default(),
babe: kusama::BabeConfig {
authorities: Default::default(),
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
Expand Down Expand Up @@ -1442,14 +1434,6 @@ pub fn kusama_testnet_genesis(
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
},
phragmen_election: Default::default(),
democracy: kusama::DemocracyConfig::default(),
council: kusama::CouncilConfig { members: vec![], phantom: Default::default() },
technical_committee: kusama::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
},
technical_membership: Default::default(),
babe: kusama::BabeConfig {
authorities: Default::default(),
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
Expand Down
13 changes: 1 addition & 12 deletions runtime/kusama/src/governance/fellowship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,7 @@ impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime
// - the FellowshipAdmin origin (i.e. token holder referendum);
// - a vote by the rank *above* the new rank.
type PromoteOrigin = EitherOf<
EitherOf<
frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
MapSuccess<
pallet_collective::EnsureProportionAtLeast<
Self::AccountId,
super::old::TechnicalCollective,
2,
3,
>,
Replace<ConstU16<6>>,
>,
>,
frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
EitherOf<
MapSuccess<FellowshipAdmin, Replace<ConstU16<9>>>,
TryMapSuccess<origins::EnsureFellowship, CheckedReduceBy<ConstU16<1>>>,
Expand Down
3 changes: 0 additions & 3 deletions runtime/kusama/src/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ use frame_support::{
};
use frame_system::EnsureRootWithSuccess;

// Old governance configurations.
pub mod old;

mod origins;
pub use origins::{
pallet_custom_origins, AuctionAdmin, Fellows, FellowshipAdmin, FellowshipExperts,
Expand Down
58 changes: 8 additions & 50 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem,
LockIdentifier, PrivilegeCmp, StorageMapShim, WithdrawReasons,
PrivilegeCmp, StorageMapShim, WithdrawReasons,
},
weights::ConstantMultiplier,
PalletId, RuntimeDebug,
Expand All @@ -80,7 +80,6 @@ use sp_staking::SessionIndex;
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use static_assertions::const_assert;

pub use frame_system::Call as SystemCall;
pub use pallet_balances::Call as BalancesCall;
Expand All @@ -107,8 +106,8 @@ pub mod xcm_config;
// Governance configurations.
pub mod governance;
use governance::{
old::CouncilCollective, pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin,
StakingAdmin, Treasurer, TreasurySpender,
pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin, StakingAdmin,
Treasurer, TreasurySpender,
};

#[cfg(test)]
Expand Down Expand Up @@ -207,11 +206,6 @@ impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
match (left, right) {
// Root is greater than anything.
(OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater),
// Check which one has more yes votes.
(
OriginCaller::Council(pallet_collective::RawOrigin::Members(l_yes_votes, l_count)),
OriginCaller::Council(pallet_collective::RawOrigin::Members(r_yes_votes, r_count)),
) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))),
// For every other origin we don't care, as they are not used for `ScheduleOrigin`.
_ => None,
}
Expand All @@ -224,6 +218,8 @@ impl pallet_scheduler::Config for Runtime {
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight;
// The goal of having ScheduleOrigin include AuctionAdmin is to allow the auctions track of
// OpenGov to schedule periodic auctions.
type ScheduleOrigin = EitherOf<EnsureRoot<AccountId>, AuctionAdmin>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
Expand Down Expand Up @@ -594,10 +590,7 @@ impl pallet_fast_unstake::Config for Runtime {
type Currency = Balances;
type BatchSize = frame_support::traits::ConstU32<64>;
type Deposit = frame_support::traits::ConstU128<{ CENTS * 100 }>;
type ControlOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
>;
type ControlOrigin = EnsureRoot<AccountId>;
gavofyork marked this conversation as resolved.
Show resolved Hide resolved
type Staking = Staking;
type MaxErasToCheckPerBlock = ConstU32<1>;
#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -681,17 +674,6 @@ impl pallet_child_bounties::Config for Runtime {
type WeightInfo = weights::pallet_child_bounties::WeightInfo<Runtime>;
}

impl pallet_tips::Config for Runtime {
type MaximumReasonLength = MaximumReasonLength;
type DataDepositPerByte = DataDepositPerByte;
type Tippers = PhragmenElection;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_tips::WeightInfo<Runtime>;
}

impl pallet_offences::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
Expand Down Expand Up @@ -983,15 +965,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Session(..) |
RuntimeCall::Grandpa(..) |
RuntimeCall::ImOnline(..) |
RuntimeCall::Democracy(..) |
RuntimeCall::Council(..) |
RuntimeCall::TechnicalCommittee(..) |
RuntimeCall::PhragmenElection(..) |
RuntimeCall::TechnicalMembership(..) |
RuntimeCall::Treasury(..) |
RuntimeCall::Bounties(..) |
RuntimeCall::ChildBounties(..) |
RuntimeCall::Tips(..) |
RuntimeCall::ConvictionVoting(..) |
RuntimeCall::Referenda(..) |
RuntimeCall::FellowshipCollective(..) |
Expand Down Expand Up @@ -1028,12 +1004,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
),
ProxyType::Governance => matches!(
c,
RuntimeCall::Democracy(..) |
RuntimeCall::Council(..) | RuntimeCall::TechnicalCommittee(..) |
RuntimeCall::PhragmenElection(..) |
RuntimeCall::Treasury(..) |
RuntimeCall::Treasury(..) |
RuntimeCall::Bounties(..) |
RuntimeCall::Tips(..) | RuntimeCall::Utility(..) |
RuntimeCall::Utility(..) |
RuntimeCall::ChildBounties(..) |
// OpenGov calls
RuntimeCall::ConvictionVoting(..) |
Expand Down Expand Up @@ -1361,13 +1334,7 @@ construct_runtime! {
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 12,

// Governance stuff.
Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 13,
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 14,
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 15,
PhragmenElection: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>} = 16,
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 17,
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 18,

ConvictionVoting: pallet_conviction_voting::{Pallet, Call, Storage, Event<T>} = 20,
Referenda: pallet_referenda::{Pallet, Call, Storage, Event<T>} = 21,
// pub type FellowshipCollectiveInstance = pallet_ranked_collective::Instance1;
Expand Down Expand Up @@ -1415,9 +1382,6 @@ construct_runtime! {
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>} = 35,
ChildBounties: pallet_child_bounties = 40,

// Tips module.
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 36,

// Election pallet. Only works with staking, but placed here to maintain indices.
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 37,

Expand Down Expand Up @@ -1544,19 +1508,14 @@ mod benches {
[frame_benchmarking::baseline, Baseline::<Runtime>]
[pallet_bounties, Bounties]
[pallet_child_bounties, ChildBounties]
[pallet_collective, Council]
[pallet_collective, TechnicalCommittee]
[pallet_conviction_voting, ConvictionVoting]
[pallet_democracy, Democracy]
[pallet_elections_phragmen, PhragmenElection]
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
[frame_election_provider_support, ElectionProviderBench::<Runtime>]
[pallet_fast_unstake, FastUnstake]
[pallet_nis, Nis]
[pallet_identity, Identity]
[pallet_im_online, ImOnline]
[pallet_indices, Indices]
[pallet_membership, TechnicalMembership]
[pallet_multisig, Multisig]
[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
[pallet_offences, OffencesBench::<Runtime>]
Expand All @@ -1571,7 +1530,6 @@ mod benches {
[pallet_staking, Staking]
[frame_system, SystemBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_tips, Tips]
[pallet_treasury, Treasury]
[pallet_utility, Utility]
[pallet_vesting, Vesting]
Expand Down
66 changes: 4 additions & 62 deletions runtime/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
//! XCM configurations for the Kusama runtime.

use super::{
parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, Fellows,
ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee,
XcmPallet,
parachains_origin, AccountId, AllPalletsWithSystem, Balances, Fellows, ParaId, Runtime,
RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet,
};
use frame_support::{
match_types, parameter_types,
Expand All @@ -31,8 +30,8 @@ use sp_core::ConstU32;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality,
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete,
MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
Expand Down Expand Up @@ -200,49 +199,6 @@ impl Contains<RuntimeCall> for SafeCallFilter {
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::Grandpa(..) |
RuntimeCall::ImOnline(..) |
RuntimeCall::Democracy(
pallet_democracy::Call::second { .. } |
pallet_democracy::Call::vote { .. } |
pallet_democracy::Call::emergency_cancel { .. } |
pallet_democracy::Call::fast_track { .. } |
pallet_democracy::Call::veto_external { .. } |
pallet_democracy::Call::cancel_referendum { .. } |
pallet_democracy::Call::delegate { .. } |
pallet_democracy::Call::undelegate { .. } |
pallet_democracy::Call::clear_public_proposals { .. } |
pallet_democracy::Call::unlock { .. } |
pallet_democracy::Call::remove_vote { .. } |
pallet_democracy::Call::remove_other_vote { .. } |
pallet_democracy::Call::blacklist { .. } |
pallet_democracy::Call::cancel_proposal { .. },
) |
RuntimeCall::Council(
pallet_collective::Call::vote { .. } |
pallet_collective::Call::close_old_weight { .. } |
pallet_collective::Call::disapprove_proposal { .. } |
pallet_collective::Call::close { .. },
) |
RuntimeCall::TechnicalCommittee(
pallet_collective::Call::vote { .. } |
pallet_collective::Call::close_old_weight { .. } |
pallet_collective::Call::disapprove_proposal { .. } |
pallet_collective::Call::close { .. },
) |
RuntimeCall::PhragmenElection(
pallet_elections_phragmen::Call::remove_voter { .. } |
pallet_elections_phragmen::Call::submit_candidacy { .. } |
pallet_elections_phragmen::Call::renounce_candidacy { .. } |
pallet_elections_phragmen::Call::remove_member { .. } |
pallet_elections_phragmen::Call::clean_defunct_voters { .. },
) |
RuntimeCall::TechnicalMembership(
pallet_membership::Call::add_member { .. } |
pallet_membership::Call::remove_member { .. } |
pallet_membership::Call::swap_member { .. } |
pallet_membership::Call::change_key { .. } |
pallet_membership::Call::set_prime { .. } |
pallet_membership::Call::clear_prime { .. },
) |
RuntimeCall::Treasury(..) |
RuntimeCall::ConvictionVoting(..) |
RuntimeCall::Referenda(
Expand Down Expand Up @@ -377,7 +333,6 @@ impl xcm_executor::Config for XcmConfig {
}

parameter_types! {
pub const CouncilBodyId: BodyId = BodyId::Executive;
// StakingAdmin pluralistic body.
pub const StakingAdminBodyId: BodyId = BodyId::Defense;
// Fellows pluralistic body.
Expand All @@ -389,19 +344,9 @@ parameter_types! {
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
}

/// Type to convert the council origin to a Plurality `MultiLocation` value.
pub type CouncilToPlurality = BackingToPlurality<
RuntimeOrigin,
pallet_collective::Origin<Runtime, CouncilCollective>,
CouncilBodyId,
>;

/// 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 of the
// `Unit` body.
CouncilToPlurality,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
);
Expand All @@ -416,9 +361,6 @@ pub type FellowsToPlurality = OriginToPluralityVoice<RuntimeOrigin, Fellows, Fel
/// Type to convert a pallet `Origin` type value into a `MultiLocation` value which represents an interior location
/// of this chain for a destination chain.
pub type LocalPalletOriginToLocation = (
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
// `Unit` body.
CouncilToPlurality,
// StakingAdmin origin to be used in XCM as a corresponding Plurality `MultiLocation` value.
StakingAdminToPlurality,
// Fellows origin to be used in XCM as a corresponding Plurality `MultiLocation` value.
Expand Down
Loading