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

Commit c175af7

Browse files
gavofyorkAnk4nmuharemjoepetrowski
authored
Introduce OpenGov into Polkadot (#6701)
* OpenGov for Polkadot * Integrate OpenGov into XCM * Formatting * Missing files * Remove Gov1 from Kusama * Fixes * Update runtime/polkadot/src/governance/origins.rs Co-authored-by: Ankan <[email protected]> * Revert scheduler origin changes * Fixes * Docs * Remove todo * Docs * Move Fellowship to Collectives (#6718) * FellowshipAdmin origin over xcm * accept Fellows origin from Collectives * remove Fellowship * remove unreachable arm * define benchmarks * correct comment for DOLLARS constant * Add OpenGov Calls to Proxy Definitions (#6729) * add opengov calls to proxy definitions * fix build * Update runtime/polkadot/src/governance/mod.rs Co-authored-by: joe petrowski <[email protected]> * Update runtime/polkadot/src/governance/tracks.rs Co-authored-by: joe petrowski <[email protected]> * Update runtime/polkadot/src/lib.rs Co-authored-by: joe petrowski <[email protected]> * Update runtime/polkadot/src/governance/origins.rs Co-authored-by: joe petrowski <[email protected]> * Update runtime/polkadot/src/governance/mod.rs Co-authored-by: joe petrowski <[email protected]> * Update old.rs * Update old.rs * weights with new api * XCM tweaks for OpenGov (#6855) * pass xcm origin, allow unpaid form Collectives and Fellows, whitelist call * unpaid execution only for Fellows * Apply suggestions from code review Co-authored-by: joe petrowski <[email protected]> * rename const namespace to system_parachains * remove prod_or_fast --------- Co-authored-by: joe petrowski <[email protected]> * remove unused import --------- Co-authored-by: Ankan <[email protected]> Co-authored-by: parity-processbot <> Co-authored-by: Muharem Ismailov <[email protected]> Co-authored-by: joe petrowski <[email protected]>
1 parent 1c2421f commit c175af7

File tree

18 files changed

+1547
-413
lines changed

18 files changed

+1547
-413
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/service/src/chain_spec.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -743,14 +743,6 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
743743
slash_reward_fraction: Perbill::from_percent(10),
744744
..Default::default()
745745
},
746-
phragmen_election: Default::default(),
747-
democracy: Default::default(),
748-
council: kusama::CouncilConfig { members: vec![], phantom: Default::default() },
749-
technical_committee: kusama::TechnicalCommitteeConfig {
750-
members: vec![],
751-
phantom: Default::default(),
752-
},
753-
technical_membership: Default::default(),
754746
babe: kusama::BabeConfig {
755747
authorities: Default::default(),
756748
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
@@ -1442,14 +1434,6 @@ pub fn kusama_testnet_genesis(
14421434
slash_reward_fraction: Perbill::from_percent(10),
14431435
..Default::default()
14441436
},
1445-
phragmen_election: Default::default(),
1446-
democracy: kusama::DemocracyConfig::default(),
1447-
council: kusama::CouncilConfig { members: vec![], phantom: Default::default() },
1448-
technical_committee: kusama::TechnicalCommitteeConfig {
1449-
members: vec![],
1450-
phantom: Default::default(),
1451-
},
1452-
technical_membership: Default::default(),
14531437
babe: kusama::BabeConfig {
14541438
authorities: Default::default(),
14551439
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),

runtime/kusama/src/governance/fellowship.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,7 @@ impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime
335335
// - the FellowshipAdmin origin (i.e. token holder referendum);
336336
// - a vote by the rank *above* the new rank.
337337
type PromoteOrigin = EitherOf<
338-
EitherOf<
339-
frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
340-
MapSuccess<
341-
pallet_collective::EnsureProportionAtLeast<
342-
Self::AccountId,
343-
super::old::TechnicalCollective,
344-
2,
345-
3,
346-
>,
347-
Replace<ConstU16<6>>,
348-
>,
349-
>,
338+
frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
350339
EitherOf<
351340
MapSuccess<FellowshipAdmin, Replace<ConstU16<9>>>,
352341
TryMapSuccess<origins::EnsureFellowship, CheckedReduceBy<ConstU16<1>>>,

runtime/kusama/src/governance/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ use frame_support::{
2323
};
2424
use frame_system::EnsureRootWithSuccess;
2525

26-
// Old governance configurations.
27-
pub mod old;
28-
2926
mod origins;
3027
pub use origins::{
3128
pallet_custom_origins, AuctionAdmin, Fellows, FellowshipAdmin, FellowshipExperts,

runtime/kusama/src/lib.rs

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use frame_support::{
5555
construct_runtime, parameter_types,
5656
traits::{
5757
ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem,
58-
LockIdentifier, PrivilegeCmp, StorageMapShim, WithdrawReasons,
58+
PrivilegeCmp, StorageMapShim, WithdrawReasons,
5959
},
6060
weights::ConstantMultiplier,
6161
PalletId, RuntimeDebug,
@@ -80,7 +80,6 @@ use sp_staking::SessionIndex;
8080
#[cfg(any(feature = "std", test))]
8181
use sp_version::NativeVersion;
8282
use sp_version::RuntimeVersion;
83-
use static_assertions::const_assert;
8483

8584
pub use frame_system::Call as SystemCall;
8685
pub use pallet_balances::Call as BalancesCall;
@@ -107,8 +106,8 @@ pub mod xcm_config;
107106
// Governance configurations.
108107
pub mod governance;
109108
use governance::{
110-
old::CouncilCollective, pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin,
111-
StakingAdmin, Treasurer, TreasurySpender,
109+
pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin, StakingAdmin,
110+
Treasurer, TreasurySpender,
112111
};
113112

114113
#[cfg(test)]
@@ -207,11 +206,6 @@ impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
207206
match (left, right) {
208207
// Root is greater than anything.
209208
(OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater),
210-
// Check which one has more yes votes.
211-
(
212-
OriginCaller::Council(pallet_collective::RawOrigin::Members(l_yes_votes, l_count)),
213-
OriginCaller::Council(pallet_collective::RawOrigin::Members(r_yes_votes, r_count)),
214-
) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))),
215209
// For every other origin we don't care, as they are not used for `ScheduleOrigin`.
216210
_ => None,
217211
}
@@ -224,6 +218,8 @@ impl pallet_scheduler::Config for Runtime {
224218
type PalletsOrigin = OriginCaller;
225219
type RuntimeCall = RuntimeCall;
226220
type MaximumWeight = MaximumSchedulerWeight;
221+
// The goal of having ScheduleOrigin include AuctionAdmin is to allow the auctions track of
222+
// OpenGov to schedule periodic auctions.
227223
type ScheduleOrigin = EitherOf<EnsureRoot<AccountId>, AuctionAdmin>;
228224
type MaxScheduledPerBlock = MaxScheduledPerBlock;
229225
type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
@@ -594,10 +590,7 @@ impl pallet_fast_unstake::Config for Runtime {
594590
type Currency = Balances;
595591
type BatchSize = frame_support::traits::ConstU32<64>;
596592
type Deposit = frame_support::traits::ConstU128<{ CENTS * 100 }>;
597-
type ControlOrigin = EitherOfDiverse<
598-
EnsureRoot<AccountId>,
599-
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
600-
>;
593+
type ControlOrigin = EnsureRoot<AccountId>;
601594
type Staking = Staking;
602595
type MaxErasToCheckPerBlock = ConstU32<1>;
603596
#[cfg(feature = "runtime-benchmarks")]
@@ -681,17 +674,6 @@ impl pallet_child_bounties::Config for Runtime {
681674
type WeightInfo = weights::pallet_child_bounties::WeightInfo<Runtime>;
682675
}
683676

684-
impl pallet_tips::Config for Runtime {
685-
type MaximumReasonLength = MaximumReasonLength;
686-
type DataDepositPerByte = DataDepositPerByte;
687-
type Tippers = PhragmenElection;
688-
type TipCountdown = TipCountdown;
689-
type TipFindersFee = TipFindersFee;
690-
type TipReportDepositBase = TipReportDepositBase;
691-
type RuntimeEvent = RuntimeEvent;
692-
type WeightInfo = weights::pallet_tips::WeightInfo<Runtime>;
693-
}
694-
695677
impl pallet_offences::Config for Runtime {
696678
type RuntimeEvent = RuntimeEvent;
697679
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
@@ -983,15 +965,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
983965
RuntimeCall::Session(..) |
984966
RuntimeCall::Grandpa(..) |
985967
RuntimeCall::ImOnline(..) |
986-
RuntimeCall::Democracy(..) |
987-
RuntimeCall::Council(..) |
988-
RuntimeCall::TechnicalCommittee(..) |
989-
RuntimeCall::PhragmenElection(..) |
990-
RuntimeCall::TechnicalMembership(..) |
991968
RuntimeCall::Treasury(..) |
992969
RuntimeCall::Bounties(..) |
993970
RuntimeCall::ChildBounties(..) |
994-
RuntimeCall::Tips(..) |
995971
RuntimeCall::ConvictionVoting(..) |
996972
RuntimeCall::Referenda(..) |
997973
RuntimeCall::FellowshipCollective(..) |
@@ -1028,12 +1004,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
10281004
),
10291005
ProxyType::Governance => matches!(
10301006
c,
1031-
RuntimeCall::Democracy(..) |
1032-
RuntimeCall::Council(..) | RuntimeCall::TechnicalCommittee(..) |
1033-
RuntimeCall::PhragmenElection(..) |
1034-
RuntimeCall::Treasury(..) |
1007+
RuntimeCall::Treasury(..) |
10351008
RuntimeCall::Bounties(..) |
1036-
RuntimeCall::Tips(..) | RuntimeCall::Utility(..) |
1009+
RuntimeCall::Utility(..) |
10371010
RuntimeCall::ChildBounties(..) |
10381011
// OpenGov calls
10391012
RuntimeCall::ConvictionVoting(..) |
@@ -1361,13 +1334,7 @@ construct_runtime! {
13611334
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 12,
13621335

13631336
// Governance stuff.
1364-
Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 13,
1365-
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 14,
1366-
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 15,
1367-
PhragmenElection: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>} = 16,
1368-
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 17,
13691337
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 18,
1370-
13711338
ConvictionVoting: pallet_conviction_voting::{Pallet, Call, Storage, Event<T>} = 20,
13721339
Referenda: pallet_referenda::{Pallet, Call, Storage, Event<T>} = 21,
13731340
// pub type FellowshipCollectiveInstance = pallet_ranked_collective::Instance1;
@@ -1415,9 +1382,6 @@ construct_runtime! {
14151382
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>} = 35,
14161383
ChildBounties: pallet_child_bounties = 40,
14171384

1418-
// Tips module.
1419-
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 36,
1420-
14211385
// Election pallet. Only works with staking, but placed here to maintain indices.
14221386
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 37,
14231387

@@ -1544,19 +1508,14 @@ mod benches {
15441508
[frame_benchmarking::baseline, Baseline::<Runtime>]
15451509
[pallet_bounties, Bounties]
15461510
[pallet_child_bounties, ChildBounties]
1547-
[pallet_collective, Council]
1548-
[pallet_collective, TechnicalCommittee]
15491511
[pallet_conviction_voting, ConvictionVoting]
1550-
[pallet_democracy, Democracy]
1551-
[pallet_elections_phragmen, PhragmenElection]
15521512
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
15531513
[frame_election_provider_support, ElectionProviderBench::<Runtime>]
15541514
[pallet_fast_unstake, FastUnstake]
15551515
[pallet_nis, Nis]
15561516
[pallet_identity, Identity]
15571517
[pallet_im_online, ImOnline]
15581518
[pallet_indices, Indices]
1559-
[pallet_membership, TechnicalMembership]
15601519
[pallet_multisig, Multisig]
15611520
[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
15621521
[pallet_offences, OffencesBench::<Runtime>]
@@ -1571,7 +1530,6 @@ mod benches {
15711530
[pallet_staking, Staking]
15721531
[frame_system, SystemBench::<Runtime>]
15731532
[pallet_timestamp, Timestamp]
1574-
[pallet_tips, Tips]
15751533
[pallet_treasury, Treasury]
15761534
[pallet_utility, Utility]
15771535
[pallet_vesting, Vesting]

runtime/kusama/src/xcm_config.rs

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
//! XCM configurations for the Kusama runtime.
1818
1919
use super::{
20-
parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, Fellows,
21-
ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee,
22-
XcmPallet,
20+
parachains_origin, AccountId, AllPalletsWithSystem, Balances, Fellows, ParaId, Runtime,
21+
RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet,
2322
};
2423
use frame_support::{
2524
match_types, parameter_types,
@@ -31,8 +30,8 @@ use sp_core::ConstU32;
3130
use xcm::latest::prelude::*;
3231
use xcm_builder::{
3332
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
34-
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality,
35-
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
33+
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
34+
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
3635
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete,
3736
MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
3837
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
@@ -200,49 +199,6 @@ impl Contains<RuntimeCall> for SafeCallFilter {
200199
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
201200
RuntimeCall::Grandpa(..) |
202201
RuntimeCall::ImOnline(..) |
203-
RuntimeCall::Democracy(
204-
pallet_democracy::Call::second { .. } |
205-
pallet_democracy::Call::vote { .. } |
206-
pallet_democracy::Call::emergency_cancel { .. } |
207-
pallet_democracy::Call::fast_track { .. } |
208-
pallet_democracy::Call::veto_external { .. } |
209-
pallet_democracy::Call::cancel_referendum { .. } |
210-
pallet_democracy::Call::delegate { .. } |
211-
pallet_democracy::Call::undelegate { .. } |
212-
pallet_democracy::Call::clear_public_proposals { .. } |
213-
pallet_democracy::Call::unlock { .. } |
214-
pallet_democracy::Call::remove_vote { .. } |
215-
pallet_democracy::Call::remove_other_vote { .. } |
216-
pallet_democracy::Call::blacklist { .. } |
217-
pallet_democracy::Call::cancel_proposal { .. },
218-
) |
219-
RuntimeCall::Council(
220-
pallet_collective::Call::vote { .. } |
221-
pallet_collective::Call::close_old_weight { .. } |
222-
pallet_collective::Call::disapprove_proposal { .. } |
223-
pallet_collective::Call::close { .. },
224-
) |
225-
RuntimeCall::TechnicalCommittee(
226-
pallet_collective::Call::vote { .. } |
227-
pallet_collective::Call::close_old_weight { .. } |
228-
pallet_collective::Call::disapprove_proposal { .. } |
229-
pallet_collective::Call::close { .. },
230-
) |
231-
RuntimeCall::PhragmenElection(
232-
pallet_elections_phragmen::Call::remove_voter { .. } |
233-
pallet_elections_phragmen::Call::submit_candidacy { .. } |
234-
pallet_elections_phragmen::Call::renounce_candidacy { .. } |
235-
pallet_elections_phragmen::Call::remove_member { .. } |
236-
pallet_elections_phragmen::Call::clean_defunct_voters { .. },
237-
) |
238-
RuntimeCall::TechnicalMembership(
239-
pallet_membership::Call::add_member { .. } |
240-
pallet_membership::Call::remove_member { .. } |
241-
pallet_membership::Call::swap_member { .. } |
242-
pallet_membership::Call::change_key { .. } |
243-
pallet_membership::Call::set_prime { .. } |
244-
pallet_membership::Call::clear_prime { .. },
245-
) |
246202
RuntimeCall::Treasury(..) |
247203
RuntimeCall::ConvictionVoting(..) |
248204
RuntimeCall::Referenda(
@@ -377,7 +333,6 @@ impl xcm_executor::Config for XcmConfig {
377333
}
378334

379335
parameter_types! {
380-
pub const CouncilBodyId: BodyId = BodyId::Executive;
381336
// StakingAdmin pluralistic body.
382337
pub const StakingAdminBodyId: BodyId = BodyId::Defense;
383338
// Fellows pluralistic body.
@@ -389,19 +344,9 @@ parameter_types! {
389344
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
390345
}
391346

392-
/// Type to convert the council origin to a Plurality `MultiLocation` value.
393-
pub type CouncilToPlurality = BackingToPlurality<
394-
RuntimeOrigin,
395-
pallet_collective::Origin<Runtime, CouncilCollective>,
396-
CouncilBodyId,
397-
>;
398-
399347
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
400348
/// of this chain.
401349
pub type LocalOriginToLocation = (
402-
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
403-
// `Unit` body.
404-
CouncilToPlurality,
405350
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
406351
SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
407352
);
@@ -416,9 +361,6 @@ pub type FellowsToPlurality = OriginToPluralityVoice<RuntimeOrigin, Fellows, Fel
416361
/// Type to convert a pallet `Origin` type value into a `MultiLocation` value which represents an interior location
417362
/// of this chain for a destination chain.
418363
pub type LocalPalletOriginToLocation = (
419-
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
420-
// `Unit` body.
421-
CouncilToPlurality,
422364
// StakingAdmin origin to be used in XCM as a corresponding Plurality `MultiLocation` value.
423365
StakingAdminToPlurality,
424366
// Fellows origin to be used in XCM as a corresponding Plurality `MultiLocation` value.

0 commit comments

Comments
 (0)