Skip to content

Commit

Permalink
Remove Gov V1 collectives (#2643)
Browse files Browse the repository at this point in the history
* remove council and tech committee collective and add migration to clean up the storage
* fix remove precompile for council and tech committee
* cleanup migration parameters
* added new helper (#2663)
* Disable gov v1 based tests
* fix ts lint errors
* remove councils in moonriver
* remove councils on moonbeam
* Update runtime/moonriver/src/asset_config.rs
* remove unused pallets names
* allow OpenTechCollective to manage foreign assets

---------

Co-authored-by: Tim B <79199034+timbrinded@users.noreply.github.com>
Co-authored-by: Éloïs <c@elo.tf>
Co-authored-by: Federico Rodríguez <federico@moonsonglabs.com>
Co-authored-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
  • Loading branch information
5 people authored Feb 21, 2024
1 parent aba40f8 commit 53dddf3
Show file tree
Hide file tree
Showing 40 changed files with 379 additions and 964 deletions.
37 changes: 6 additions & 31 deletions node/service/src/chain_spec/moonbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ use cumulus_primitives_core::ParaId;
use hex_literal::hex;
use moonbase_runtime::{
currency::UNIT, AccountId, AuthorFilterConfig, AuthorMappingConfig, Balance, BalancesConfig,
CouncilCollectiveConfig, CrowdloanRewardsConfig, DemocracyConfig, EVMConfig, EligibilityValue,
EthereumChainIdConfig, EthereumConfig, GenesisAccount, InflationInfo, MaintenanceModeConfig,
CrowdloanRewardsConfig, DemocracyConfig, EVMConfig, EligibilityValue, EthereumChainIdConfig,
EthereumConfig, GenesisAccount, InflationInfo, MaintenanceModeConfig,
OpenTechCommitteeCollectiveConfig, ParachainInfoConfig, ParachainStakingConfig,
PolkadotXcmConfig, Precompiles, Range, RuntimeGenesisConfig, SudoConfig, SystemConfig,
TechCommitteeCollectiveConfig, TransactionPaymentConfig, TreasuryCouncilCollectiveConfig,
XcmTransactorConfig, HOURS, WASM_BINARY,
TransactionPaymentConfig, TreasuryCouncilCollectiveConfig, XcmTransactorConfig, HOURS,
WASM_BINARY,
};
use nimbus_primitives::NimbusId;
use pallet_transaction_payment::Multiplier;
Expand Down Expand Up @@ -69,14 +69,10 @@ pub fn development_chain_spec(mnemonic: Option<String>, num_accounts: Option<u32
testnet_genesis(
// Alith is Sudo
accounts[0],
// Council members: Baltathar, Charleth and Dorothy
vec![accounts[1], accounts[2], accounts[3]],
// Tech comitee members: Alith and Baltathar
vec![accounts[0], accounts[1]],
// Treasury Council members: Baltathar, Charleth and Dorothy
vec![accounts[1], accounts[2], accounts[3]],
// Open Tech committee members: Alith and Baltathar
vec![accounts[0], accounts[1]],
// Open Tech committee members: Alith, Baltathar and Charleth
vec![accounts[0], accounts[1], accounts[2]],
// Collator Candidate: Alice -> Alith
vec![(
accounts[0],
Expand Down Expand Up @@ -128,17 +124,6 @@ pub fn get_chain_spec(para_id: ParaId) -> ChainSpec {
testnet_genesis(
// Alith is Sudo
AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
// Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
],
// Tech comitee members: Alith and Baltathar
vec![
AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
],
// Treasury Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
Expand Down Expand Up @@ -236,8 +221,6 @@ pub fn moonbase_inflation_config() -> InflationInfo<Balance> {

pub fn testnet_genesis(
root_key: AccountId,
council_members: Vec<AccountId>,
tech_comittee_members: Vec<AccountId>,
treasury_council_members: Vec<AccountId>,
open_tech_committee_members: Vec<AccountId>,
candidates: Vec<(AccountId, NimbusId, Balance)>,
Expand Down Expand Up @@ -316,14 +299,6 @@ pub fn testnet_genesis(
blocks_per_round: BLOCKS_PER_ROUND,
num_selected_candidates: NUM_SELECTED_CANDIDATES,
},
council_collective: CouncilCollectiveConfig {
phantom: Default::default(),
members: council_members,
},
tech_committee_collective: TechCommitteeCollectiveConfig {
phantom: Default::default(),
members: tech_comittee_members,
},
treasury_council_collective: TreasuryCouncilCollectiveConfig {
phantom: Default::default(),
members: treasury_council_members,
Expand Down
36 changes: 5 additions & 31 deletions node/service/src/chain_spec/moonbeam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ use hex_literal::hex;
use moonbase_runtime::EligibilityValue;
use moonbeam_runtime::{
currency::GLMR, currency::SUPPLY_FACTOR, AccountId, AuthorFilterConfig, AuthorMappingConfig,
Balance, BalancesConfig, CouncilCollectiveConfig, CrowdloanRewardsConfig, DemocracyConfig,
EVMConfig, EthereumChainIdConfig, EthereumConfig, GenesisAccount, InflationInfo,
MaintenanceModeConfig, OpenTechCommitteeCollectiveConfig, ParachainInfoConfig,
ParachainStakingConfig, PolkadotXcmConfig, Precompiles, Range, RuntimeGenesisConfig,
SystemConfig, TechCommitteeCollectiveConfig, TransactionPaymentConfig,
TreasuryCouncilCollectiveConfig, HOURS, WASM_BINARY,
Balance, BalancesConfig, CrowdloanRewardsConfig, DemocracyConfig, EVMConfig,
EthereumChainIdConfig, EthereumConfig, GenesisAccount, InflationInfo, MaintenanceModeConfig,
OpenTechCommitteeCollectiveConfig, ParachainInfoConfig, ParachainStakingConfig,
PolkadotXcmConfig, Precompiles, Range, RuntimeGenesisConfig, SystemConfig,
TransactionPaymentConfig, TreasuryCouncilCollectiveConfig, HOURS, WASM_BINARY,
};
use nimbus_primitives::NimbusId;
use pallet_transaction_payment::Multiplier;
Expand Down Expand Up @@ -61,10 +60,6 @@ pub fn development_chain_spec(mnemonic: Option<String>, num_accounts: Option<u32
ChainType::Development,
move || {
testnet_genesis(
// Council members: Baltathar, Charleth and Dorothy
vec![accounts[1], accounts[2], accounts[3]],
// Tech comitee members: Alith and Baltathar
vec![accounts[0], accounts[1]],
// Treasury Council members: Baltathar, Charleth and Dorothy
vec![accounts[1], accounts[2], accounts[3]],
// Open Tech committee members: Alith and Baltathar
Expand Down Expand Up @@ -118,17 +113,6 @@ pub fn get_chain_spec(para_id: ParaId) -> ChainSpec {
ChainType::Local,
move || {
testnet_genesis(
// Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
],
// Tech comitee members: Alith and Baltathar
vec![
AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
],
// Treasury Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
Expand Down Expand Up @@ -225,8 +209,6 @@ pub fn moonbeam_inflation_config() -> InflationInfo<Balance> {
}

pub fn testnet_genesis(
council_members: Vec<AccountId>,
tech_comittee_members: Vec<AccountId>,
treasury_council_members: Vec<AccountId>,
open_tech_committee_members: Vec<AccountId>,
candidates: Vec<(AccountId, NimbusId, Balance)>,
Expand Down Expand Up @@ -302,14 +284,6 @@ pub fn testnet_genesis(
blocks_per_round: BLOCKS_PER_ROUND,
num_selected_candidates: NUM_SELECTED_CANDIDATES,
},
council_collective: CouncilCollectiveConfig {
phantom: Default::default(),
members: council_members,
},
tech_committee_collective: TechCommitteeCollectiveConfig {
phantom: Default::default(),
members: tech_comittee_members,
},
treasury_council_collective: TreasuryCouncilCollectiveConfig {
phantom: Default::default(),
members: treasury_council_members,
Expand Down
34 changes: 4 additions & 30 deletions node/service/src/chain_spec/moonriver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ use hex_literal::hex;
use moonbase_runtime::EligibilityValue;
use moonriver_runtime::{
currency::MOVR, AccountId, AuthorFilterConfig, AuthorMappingConfig, Balance, BalancesConfig,
CouncilCollectiveConfig, CrowdloanRewardsConfig, DemocracyConfig, EVMConfig,
EthereumChainIdConfig, EthereumConfig, GenesisAccount, InflationInfo, MaintenanceModeConfig,
OpenTechCommitteeCollectiveConfig, ParachainInfoConfig, ParachainStakingConfig,
PolkadotXcmConfig, Precompiles, Range, RuntimeGenesisConfig, SystemConfig,
TechCommitteeCollectiveConfig, TransactionPaymentConfig, TreasuryCouncilCollectiveConfig,
CrowdloanRewardsConfig, DemocracyConfig, EVMConfig, EthereumChainIdConfig, EthereumConfig,
GenesisAccount, InflationInfo, MaintenanceModeConfig, OpenTechCommitteeCollectiveConfig,
ParachainInfoConfig, ParachainStakingConfig, PolkadotXcmConfig, Precompiles, Range,
RuntimeGenesisConfig, SystemConfig, TransactionPaymentConfig, TreasuryCouncilCollectiveConfig,
HOURS, WASM_BINARY,
};
use nimbus_primitives::NimbusId;
Expand Down Expand Up @@ -61,10 +60,6 @@ pub fn development_chain_spec(mnemonic: Option<String>, num_accounts: Option<u32
ChainType::Development,
move || {
testnet_genesis(
// Council members: Baltathar, Charleth and Dorothy
vec![accounts[1], accounts[2], accounts[3]],
// Tech comitee members: Alith and Baltathar
vec![accounts[0], accounts[1]],
// Treasury Council members: Baltathar, Charleth and Dorothy
vec![accounts[1], accounts[2], accounts[3]],
// Open Tech committee members: Alith and Baltathar
Expand Down Expand Up @@ -118,17 +113,6 @@ pub fn get_chain_spec(para_id: ParaId) -> ChainSpec {
ChainType::Local,
move || {
testnet_genesis(
// Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
],
// Tech comitee members: Alith and Baltathar
vec![
AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
],
// Treasury Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
Expand Down Expand Up @@ -225,8 +209,6 @@ pub fn moonriver_inflation_config() -> InflationInfo<Balance> {
}

pub fn testnet_genesis(
council_members: Vec<AccountId>,
tech_comittee_members: Vec<AccountId>,
treasury_council_members: Vec<AccountId>,
open_tech_committee_members: Vec<AccountId>,
candidates: Vec<(AccountId, NimbusId, Balance)>,
Expand Down Expand Up @@ -302,14 +284,6 @@ pub fn testnet_genesis(
blocks_per_round: BLOCKS_PER_ROUND,
num_selected_candidates: NUM_SELECTED_CANDIDATES,
},
council_collective: CouncilCollectiveConfig {
phantom: Default::default(),
members: council_members,
},
tech_committee_collective: TechCommitteeCollectiveConfig {
phantom: Default::default(),
members: tech_comittee_members,
},
treasury_council_collective: TreasuryCouncilCollectiveConfig {
phantom: Default::default(),
members: treasury_council_members,
Expand Down
11 changes: 0 additions & 11 deletions node/service/src/chain_spec/test_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ pub fn staking_spec(para_id: ParaId) -> ChainSpec {
testnet_genesis(
// Root
AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
// Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
],
// Tech Committee members: Alith and Baltathar
vec![
AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
],
// Treasury Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
Expand Down
2 changes: 0 additions & 2 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1737,8 +1737,6 @@ mod tests {
vec![],
vec![],
vec![],
vec![],
vec![],
1000 * UNIT,
ParaId::new(0),
0,
Expand Down
2 changes: 0 additions & 2 deletions precompiles/collective/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ pub(crate) fn roll_to(n: BlockNumber) {
// We may be able to simulate this by poking its storage directly, but I don't see any value
// added from doing that.
while System::block_number() < n {
CouncilCollective::on_finalize(System::block_number());
Treasury::on_finalize(System::block_number());
// Times tamp::on_finalize(System::block_number());
Evm::on_finalize(System::block_number());
Expand All @@ -333,7 +332,6 @@ pub(crate) fn roll_to(n: BlockNumber) {
Evm::on_initialize(System::block_number());
Timestamp::on_initialize(System::block_number());
Treasury::on_initialize(System::block_number());
CouncilCollective::on_initialize(System::block_number());
}
}

Expand Down
74 changes: 61 additions & 13 deletions runtime/common/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use frame_support::ensure;
#[cfg(feature = "try-runtime")]
use frame_support::migration::get_storage_value;
use frame_support::{
pallet_prelude::GetStorageVersion,
parameter_types,
sp_runtime::traits::{Block as BlockT, Header as HeaderT},
traits::PalletInfoAccess,
traits::OnRuntimeUpgrade,
weights::Weight,
};
use frame_system::pallet_prelude::BlockNumberFor;
Expand Down Expand Up @@ -178,21 +178,67 @@ where
}
}

pub struct CommonMigrations<Runtime, Council, Tech, Treasury, OpenTech>(
PhantomData<(Runtime, Council, Tech, Treasury, OpenTech)>,
);
parameter_types! {
pub const CouncilPalletName: &'static str = "Council";
pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
}

impl<Runtime, Council, Tech, Treasury, OpenTech> GetMigrations
for CommonMigrations<Runtime, Council, Tech, Treasury, OpenTech>
pub struct PalletCollectiveDropGovV1Collectives<Runtime>(pub PhantomData<Runtime>);
impl<Runtime> Migration for PalletCollectiveDropGovV1Collectives<Runtime>
where
Runtime: frame_system::Config,
{
fn friendly_name(&self) -> &str {
"MM_RemoveGovV1Collectives"
}

fn migrate(&self, _available_weight: Weight) -> Weight {
log::info!("Removing Council and Tech from pallet_collective");

let mut weight = Weight::zero();

let w = frame_support::migrations::RemovePallet::<
CouncilPalletName,
<Runtime as frame_system::Config>::DbWeight,
>::on_runtime_upgrade();
weight = weight.saturating_add(w);

let w = frame_support::migrations::RemovePallet::<
TechnicalCommitteePalletName,
<Runtime as frame_system::Config>::DbWeight,
>::on_runtime_upgrade();
weight = weight.saturating_add(w);
weight
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
frame_support::migrations::RemovePallet::<
TechnicalCommitteePalletName,
<Runtime as frame_system::Config>::DbWeight,
>::pre_upgrade();

Ok(vec![])
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
frame_support::migrations::RemovePallet::<
TechnicalCommitteePalletName,
<Runtime as frame_system::Config>::DbWeight,
>::post_upgrade(_state);
Ok(())
}
}

pub struct CommonMigrations<Runtime>(PhantomData<Runtime>);

impl<Runtime> GetMigrations for CommonMigrations<Runtime>
where
Runtime: pallet_author_mapping::Config,
Runtime: pallet_parachain_staking::Config,
Runtime: pallet_scheduler::Config,
Runtime: AuthorSlotFilterConfig,
Council: GetStorageVersion + PalletInfoAccess + 'static,
Tech: GetStorageVersion + PalletInfoAccess + 'static,
Treasury: GetStorageVersion + PalletInfoAccess + 'static,
OpenTech: GetStorageVersion + PalletInfoAccess + 'static,
Runtime: pallet_democracy::Config,
Runtime: pallet_preimage::Config,
Runtime: pallet_asset_manager::Config,
Expand Down Expand Up @@ -269,13 +315,13 @@ where
// PalletXcmTransactorMigrateXcmV2ToV3::<Runtime>(Default::default());
//let remove_min_bond_for_old_orbiter_collators =
// RemoveMinBondForOrbiterCollators::<Runtime>(Default::default());

// RT2700
// let missing_balances_migrations = MissingBalancesMigrations::<Runtime>(Default::default());
// let fix_pallet_versions =
// FixIncorrectPalletVersions::<Runtime, Treasury, OpenTech>(Default::default());
// let pallet_referenda_migrate_v0_to_v1 =
// PalletReferendaMigrateV0ToV1::<Runtime>(Default::default());
let pallet_collective_drop_gov_v1_collectives =
PalletCollectiveDropGovV1Collectives::<Runtime>(Default::default());

vec![
// completed in runtime 800
Expand Down Expand Up @@ -330,6 +376,8 @@ where
// Box::new(missing_balances_migrations),
// Box::new(fix_pallet_versions),
// Box::new(pallet_referenda_migrate_v0_to_v1),
// completed in runtime 2800
Box::new(pallet_collective_drop_gov_v1_collectives),
]
}
}
Loading

0 comments on commit 53dddf3

Please sign in to comment.