Skip to content

Commit

Permalink
Remove governance v1 from Crab (#1376)
Browse files Browse the repository at this point in the history
* Remove governance v1

* Format

* Clean

* Add migration

* Fix
  • Loading branch information
aurexav authored Jan 9, 2024
1 parent 978dda2 commit d954a70
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 1,941 deletions.
4 changes: 0 additions & 4 deletions node/src/chain_spec/crab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ pub fn genesis_config() -> ChainSpec {
aura_ext: Default::default(),

// Governance stuff.
democracy: Default::default(),
council: Default::default(),
technical_committee: Default::default(),
treasury: Default::default(),

Expand Down Expand Up @@ -327,8 +325,6 @@ fn testnet_genesis(
aura_ext: Default::default(),

// Governance stuff.
democracy: Default::default(),
council: Default::default(),
technical_committee: Default::default(),
treasury: Default::default(),

Expand Down
10 changes: 0 additions & 10 deletions node/src/chain_spec/pangolin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,8 @@ pub fn genesis_config() -> ChainSpec {
ecdsa_authority: Default::default(),

// Governance stuff.
council: Default::default(),
technical_committee: Default::default(),
treasury: Default::default(),
democracy: Default::default(),

// Utility stuff.
sudo: SudoConfig { key: Some(array_bytes::hex_n_into_unchecked::<_, _, 20>(SUDO)) },
Expand Down Expand Up @@ -322,13 +320,6 @@ fn testnet_genesis(
ecdsa_authority: Default::default(),

// Governance stuff.
council: CouncilConfig {
members: vec![
array_bytes::hex_n_into_unchecked::<_, _, 20>(ALITH),
array_bytes::hex_n_into_unchecked::<_, _, 20>(BALTATHAR),
],
..Default::default()
},
technical_committee: TechnicalCommitteeConfig {
members: vec![
array_bytes::hex_n_into_unchecked::<_, _, 20>(ALITH),
Expand All @@ -337,7 +328,6 @@ fn testnet_genesis(
..Default::default()
},
treasury: Default::default(),
democracy: Default::default(),

// Utility stuff.
sudo: SudoConfig { key: Some(array_bytes::hex_n_into_unchecked::<_, _, 20>(ALITH)) },
Expand Down
6 changes: 2 additions & 4 deletions runtime/crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ frame_support::construct_runtime! {
// Governance stuff.
// PhragmenElection: pallet_elections_phragmen = 21,
// TechnicalMembership: pallet_membership::<Instance1> = 22,
Council: pallet_collective::<Instance1> = 19,
// Council: pallet_collective::<Instance1> = 19,
TechnicalCommittee: pallet_collective::<Instance2> = 20,
Treasury: pallet_treasury = 23,
// Tips: pallet_tips = 24,
Democracy: pallet_democracy = 18,
// Democracy: pallet_democracy = 18,
ConvictionVoting: pallet_conviction_voting = 44,
Referenda: pallet_referenda = 45,
Origins: custom_origins = 46,
Expand Down Expand Up @@ -190,10 +190,8 @@ frame_benchmarking::define_benchmarks! {
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Assets]
[pallet_balances, Balances]
[pallet_collective, Council]
[pallet_collective, TechnicalCommittee]
[pallet_conviction_voting, ConvictionVoting]
[pallet_democracy, Democracy]
[pallet_identity, Identity]
[pallet_preimage, Preimage]
[pallet_proxy, Proxy]
Expand Down
45 changes: 19 additions & 26 deletions runtime/crab/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,25 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
}

fn migrate() -> frame_support::weights::Weight {
// polkadot-sdk
use frame_support::traits::{LockableCurrency, ReservableCurrency};

[
("0xb2960e11b253c107f973cd778bbe1520e35e8602", 100009600000000000000_u128),
("0x3e25247cff03f99a7d83b28f207112234fee73a6", 100022400000000000000),
("0x0a1287977578f888bdc1c7627781af1cc000e6ab", 100009600000000000000),
("0xd891ce6a97b4f01a8b9b36d0298aa3631fe2eef5", 100019200000000000000),
("0xe59261f6d4088bcd69985a3d369ff14cc54ef1e5", 100009600000000000000),
("0xabcf7060a68f62624f7569ada9d78b5a5db0782a", 100012800000000000000),
("0x9f33a4809aa708d7a399fedba514e0a0d15efa85", 100012800000000000000),
("0xacfa39b864e42d1bd3792783a571d2958af0bf1f", 100009600000000000000),
("0x88a39b052d477cfde47600a7c9950a441ce61cb4", 100009600000000000000),
("0x5b7544b3f6abd9e03fba494796b1ee6f9543e2e4", 100012800000000000000),
("0x44cda595218ddb3810fb66c2e982f50ea00255ee", 100009600000000000000),
]
.iter()
.for_each(|(acc, deposit)| {
if let Ok(a) = array_bytes::hex_n_into::<_, AccountId, 20>(acc) {
let r = Balances::unreserve(&a, *deposit);

Balances::remove_lock(*b"phrelect", &a);

log::info!("{acc}: {r:?}");
}
});
let _ = migration::clear_storage_prefix(b"Council", b"Proposals", &[], None, None);
let _ = migration::clear_storage_prefix(b"Council", b"ProposalOf", &[], None, None);
let _ = migration::clear_storage_prefix(b"Council", b"Voting", &[], None, None);
let _ = migration::clear_storage_prefix(b"Council", b"ProposalCount", &[], None, None);
let _ = migration::clear_storage_prefix(b"Council", b"Members", &[], None, None);
let _ = migration::clear_storage_prefix(b"Council", b"Prime", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"PublicPropCount", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"PublicProps", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"DepositOf", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"ReferendumCount", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"LowestUnbaked", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"ReferendumInfoOf", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"VotingOf", &[], None, None);
let _ =
migration::clear_storage_prefix(b"Democracy", b"LastTabledWasExternal", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"NextExternal", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"Blacklist", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"Cancellations", &[], None, None);
let _ = migration::clear_storage_prefix(b"Democracy", b"MetadataOf", &[], None, None);

// frame_support::weights::Weight::zero()
RuntimeBlockWeights::get().max_block
Expand Down
20 changes: 3 additions & 17 deletions runtime/crab/src/pallets/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ pub use origin::{custom_origins, GeneralAdmin};
mod track;
use track::*;

mod v1;

pub use pallet_collective::{Instance1 as CouncilCollective, Instance2 as TechnicalCollective};
pub use pallet_collective::Instance2 as TechnicalCollective;

pub(super) use crate::*;

Expand All @@ -40,18 +38,6 @@ frame_support::parameter_types! {
pub MaxProposalWeight: frame_support::weights::Weight = sp_runtime::Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
}

impl pallet_collective::Config<CouncilCollective> for Runtime {
type DefaultVote = pallet_collective::PrimeDefaultVote;
type MaxMembers = ConstU32<COLLECTIVE_MAX_MEMBERS>;
type MaxProposalWeight = MaxProposalWeight;
type MaxProposals = ConstU32<100>;
type MotionDuration = ConstU32<{ 3 * DAYS }>;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type SetMembersOrigin = RootOr<GeneralAdmin>;
type WeightInfo = weights::pallet_collective_council::WeightInfo<Self>;
}
impl pallet_collective::Config<TechnicalCollective> for Runtime {
type DefaultVote = pallet_collective::PrimeDefaultVote;
type MaxMembers = ConstU32<COLLECTIVE_MAX_MEMBERS>;
Expand Down Expand Up @@ -125,10 +111,10 @@ impl pallet_treasury::Config for Runtime {
type ProposalBond = ProposalBond;
type ProposalBondMaximum = ();
type ProposalBondMinimum = ConstU128<DARWINIA_PROPOSAL_REQUIREMENT>;
type RejectOrigin = RootOrAll<CouncilCollective>;
type RejectOrigin = RootOr<GeneralAdmin>;
type RuntimeEvent = RuntimeEvent;
type SpendFunds = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
type SpendPeriod = ConstU32<{ 7 * DAYS }>;
type SpendPeriod = ConstU32<{ 14 * DAYS }>;
type WeightInfo = weights::pallet_treasury::WeightInfo<Self>;
}
55 changes: 0 additions & 55 deletions runtime/crab/src/pallets/governance/v1.rs

This file was deleted.

4 changes: 2 additions & 2 deletions runtime/crab/src/pallets/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ impl pallet_identity::Config for Runtime {
type Currency = Balances;
// 66 bytes on-chain.
type FieldDeposit = ConstU128<{ darwinia_deposit(0, 66) }>;
type ForceOrigin = RootOrMoreThanHalf<CouncilCollective>;
type ForceOrigin = RootOr<GeneralAdmin>;
type MaxAdditionalFields = ConstU32<100>;
type MaxRegistrars = ConstU32<20>;
type MaxSubAccounts = ConstU32<100>;
type RegistrarOrigin = RootOrMoreThanHalf<CouncilCollective>;
type RegistrarOrigin = RootOr<GeneralAdmin>;
type RuntimeEvent = RuntimeEvent;
type Slashed = Treasury;
// 53 bytes on-chain.
Expand Down
10 changes: 3 additions & 7 deletions runtime/crab/src/pallets/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,9 @@ impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType {
| RuntimeCall::PolkadotXcm(..)
| RuntimeCall::Ethereum(..) // }
),
ProxyType::Governance => matches!(
c,
RuntimeCall::Democracy(..)
| RuntimeCall::Council(..)
| RuntimeCall::TechnicalCommittee(..)
| RuntimeCall::Treasury(..)
),
ProxyType::Governance =>
matches!(c, |RuntimeCall::Referenda(..)| RuntimeCall::TechnicalCommittee(..)
| RuntimeCall::Treasury(..)),
ProxyType::Staking => {
matches!(
c,
Expand Down
10 changes: 8 additions & 2 deletions runtime/crab/src/pallets/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ impl frame_support::traits::PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
Some(core::cmp::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)),
OriginCaller::TechnicalCommittee(pallet_collective::RawOrigin::Members(
l_yes_votes,
l_count,
)),
OriginCaller::TechnicalCommittee(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 Down
2 changes: 0 additions & 2 deletions runtime/crab/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ pub mod frame_system;
pub mod pallet_assets;
pub mod pallet_balances;
pub mod pallet_bridge_grandpa;
pub mod pallet_collective_council;
pub mod pallet_collective_technical_committee;
pub mod pallet_conviction_voting;
pub mod pallet_democracy;
pub mod pallet_fee_market;
pub mod pallet_identity;
pub mod pallet_preimage;
Expand Down
Loading

0 comments on commit d954a70

Please sign in to comment.