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

migration: unlock/unreserve Gov v1 balances, remove Gov V1 pallets from polkadot runtime, and remove Gov V1 pallet key/values from storage #7314

Merged
merged 39 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d1cf215
restore old gov configs
liamaharon May 31, 2023
639ab0a
migrate old gov v1 storage
liamaharon May 31, 2023
3066df0
exclude the Call enum for gov v1 pallets
liamaharon May 31, 2023
d099689
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jun 2, 2023
964ac34
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jun 5, 2023
fc9e0a2
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jun 13, 2023
670f199
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jun 13, 2023
abf4d90
update substrate
liamaharon Jun 13, 2023
357328c
update tips pallet
liamaharon Jun 13, 2023
e2a8ff2
update chain_spec
liamaharon Jun 13, 2023
a85c346
fix migrations tuple
liamaharon Jun 14, 2023
49174b9
oliver comments
liamaharon Jun 14, 2023
b090f34
format comment
liamaharon Jun 14, 2023
187bda0
".git/.scripts/commands/fmt/fmt.sh"
Jun 14, 2023
c94588a
comments
liamaharon Jun 14, 2023
b3cbdde
Merge branch 'liam-kusama-gov-v1-storage-migration' of github.com:par…
liamaharon Jun 14, 2023
b64b92b
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jul 2, 2023
271666a
polkadot migrations
liamaharon Jul 2, 2023
4ec49ff
fix cargo.lock
liamaharon Jul 2, 2023
ca208cf
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jul 24, 2023
5dd4daa
fix compilation
liamaharon Jul 24, 2023
bff4590
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jul 28, 2023
4005aee
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Aug 4, 2023
45ba24f
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Aug 16, 2023
5e440c1
use democracy standalone migration
liamaharon Aug 16, 2023
1f3f785
re-remove gov v1 pallets from kusama
liamaharon Aug 16, 2023
6cd663b
remove unnecessary feature
liamaharon Aug 16, 2023
8fef227
fix unlock configs
liamaharon Aug 17, 2023
82d4de9
use substrate master
liamaharon Aug 17, 2023
1991ecb
Merge remote-tracking branch 'origin' into liam-kusama-gov-v1-storage…
liamaharon Aug 17, 2023
e6048d9
reset cargo.lock
liamaharon Aug 17, 2023
7473d8e
cargo update -p sp-io
liamaharon Aug 17, 2023
3a47d7a
remove from chainspec
liamaharon Aug 17, 2023
3eb21c0
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Aug 17, 2023
2779a6e
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Aug 18, 2023
25e81d4
remove polkadot gov v1 pallets
liamaharon Aug 18, 2023
8ef96a0
clean up chain spec
liamaharon Aug 18, 2023
6bf0aec
cargo fmt
liamaharon Aug 18, 2023
6baa262
remove old gov import
liamaharon Aug 18, 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
24 changes: 24 additions & 0 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,18 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::RuntimeG
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
nis_counterpart_balances: Default::default(),

// Old gov v1 pallets that should be removed once the migration unlocking funds is confirmed
// successful, probably in release 1.1.
// See https://github.com/paritytech/polkadot/issues/6749
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(),
}
}

Expand Down Expand Up @@ -1400,6 +1412,18 @@ pub fn kusama_testnet_genesis(
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
nis_counterpart_balances: Default::default(),

// Old gov v1 pallets that should be removed once the migration unlocking funds is confirmed
// successful, probably in release 1.1.
// See https://github.com/paritytech/polkadot/issues/6749
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(),
}
}

Expand Down
60 changes: 60 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,52 @@ pub type Migrations = (migrations::Unreleased,);
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;
use frame_support::traits::LockIdentifier;
use frame_system::pallet_prelude::BlockNumberFor;

parameter_types! {
pub const DemocracyPalletName: &'static str = "Democracy";
pub const CouncilPalletName: &'static str = "Council";
pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
pub const TipsPalletName: &'static str = "Tips";
pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
}

// Special Config for Gov V1 pallets, allowing us to run migrations for them without
// implementing their configs on [`Runtime`].
pub struct UnlockConfig;
impl pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockConfig for UnlockConfig {
type Currency = Balances;
type MaxVotes = ConstU32<100>;
type MaxDeposits = ConstU32<100>;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = DemocracyPalletName;
}
impl pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockConfig
for UnlockConfig
{
type Currency = Balances;
type MaxVotesPerVoter = ConstU32<16>;
type PalletId = PhragmenElectionPalletId;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = PhragmenElectionPalletName;
}
impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfig {
type Currency = Balances;
type Hash = Hash;
type DataDepositPerByte = DataDepositPerByte;
type TipReportDepositBase = TipReportDepositBase;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = TipsPalletName;
}

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
Expand All @@ -1538,6 +1584,20 @@ pub mod migrations {
>,
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,

liamaharon marked this conversation as resolved.
Show resolved Hide resolved
// Unlock/unreserve balances from Gov v1 pallets that hold them
// https://github.com/paritytech/polkadot/issues/6749
pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfig, ()>,

// Delete storage key/values from all Gov v1 pallets
frame_support::migrations::RemovePallet<DemocracyPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<CouncilPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<TechnicalCommitteePalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<TechnicalMembershipPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
);
}

Expand Down
64 changes: 63 additions & 1 deletion runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,9 +1376,9 @@ construct_runtime! {
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 16,
PhragmenElection: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>} = 17,
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 18,
Treasury: pallet_treasury::{Pallet, Call, Storage, Config<T>, Event<T>} = 19,

// OpenGov stuff.
Treasury: pallet_treasury::{Pallet, Call, Storage, Config<T>, Event<T>} = 19,
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
ConvictionVoting: pallet_conviction_voting::{Pallet, Call, Storage, Event<T>} = 20,
Referenda: pallet_referenda::{Pallet, Call, Storage, Event<T>} = 21,
Origins: pallet_custom_origins::{Origin} = 22,
Expand Down Expand Up @@ -1489,11 +1489,73 @@ pub type Migrations = migrations::Unreleased;
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;
use frame_support::traits::LockIdentifier;
use frame_system::pallet_prelude::BlockNumberFor;

parameter_types! {
pub const DemocracyPalletName: &'static str = "Democracy";
pub const CouncilPalletName: &'static str = "Council";
pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
pub const TipsPalletName: &'static str = "Tips";
pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
}

// Special Config for Gov V1 pallets, allowing us to run migrations for them without
// implementing their configs on [`Runtime`].
pub struct UnlockConfig;
impl pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockConfig for UnlockConfig {
type Currency = Balances;
type MaxVotes = ConstU32<100>;
type MaxDeposits = ConstU32<100>;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = DemocracyPalletName;
}
impl pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockConfig
for UnlockConfig
{
type Currency = Balances;
type MaxVotesPerVoter = ConstU32<16>;
type PalletId = PhragmenElectionPalletId;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = PhragmenElectionPalletName;
}
impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfig {
type Currency = Balances;
type Hash = Hash;
type DataDepositPerByte = DataDepositPerByte;
type TipReportDepositBase = TipReportDepositBase;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = TipsPalletName;
}

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,

// Gov v1 storage migrations
// https://github.com/paritytech/polkadot/issues/6749
pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfig, ()>,

// Delete all Gov v1 pallet storage key/values Leaving this commented out for now, until we
// figure out how to remove `runtime/polkadot/src/xcm_config.rs` dependency on Gov V1
// pallets and remove them from the runtime.
// frame_support::migrations::RemovePallet<DemocracyPalletName, <Runtime as frame_system::Config>::DbWeight>,
// frame_support::migrations::RemovePallet<CouncilPalletName, <Runtime as frame_system::Config>::DbWeight>,
// frame_support::migrations::RemovePallet<TechnicalCommitteePalletName, <Runtime as frame_system::Config>::DbWeight>,
// frame_support::migrations::RemovePallet<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
// frame_support::migrations::RemovePallet<TechnicalMembershipPalletName, <Runtime as frame_system::Config>::DbWeight>,
// frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
);
}

Expand Down