Skip to content

Commit

Permalink
Remove locks and cleanup state
Browse files Browse the repository at this point in the history
  • Loading branch information
vgantchev committed Sep 17, 2024
1 parent 8e1dbc4 commit 131cda2
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch =
pallet-bounties = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-im-online = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
Expand All @@ -85,6 +87,7 @@ pallet-staking-reward-fn = { git = "https://github.com/paritytech/polkadot-sdk",
pallet-state-trie-migration = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-tips = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false }
Expand Down Expand Up @@ -330,6 +333,7 @@ pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
Expand All @@ -339,6 +343,7 @@ pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-tips = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
Expand Down
12 changes: 12 additions & 0 deletions runtime/basilisk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ pallet-xyk-liquidity-mining = { workspace = true , default-features = false }
pallet-xyk-liquidity-mining-benchmarking = { workspace = true, optional = true, default-features = false }

pallet-treasury = { workspace = true }
pallet-democracy = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-elections-phragmen = { workspace = true }
pallet-tips = { workspace = true }
pallet-identity = { workspace = true }
pallet-state-trie-migration = { workspace = true }

Expand Down Expand Up @@ -150,9 +153,11 @@ runtime-benchmarks = [
"xcm-builder/runtime-benchmarks",
"pallet-asset-registry/runtime-benchmarks",
"pallet-duster/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-tips/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
Expand All @@ -163,6 +168,7 @@ runtime-benchmarks = [
"pallet-ema-oracle/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"cumulus-pallet-parachain-system/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-state-trie-migration/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
Expand Down Expand Up @@ -204,6 +210,7 @@ std = [
"pallet-asset-registry/std",
"pallet-aura/std",
"pallet-balances/std",
"pallet-elections-phragmen/std",
"pallet-nft/std",
"pallet-marketplace/std",
"pallet-session/std",
Expand Down Expand Up @@ -235,9 +242,11 @@ std = [
"sp-version/std",
"pallet-treasury/std",
"pallet-collective/std",
"pallet-democracy/std",
"pallet-proxy/std",
"pallet-multisig/std",
"pallet-scheduler/std",
"pallet-tips/std",
"pallet-collator-selection/std",
"pallet-authorship/std",
"pallet-uniques/std",
Expand Down Expand Up @@ -270,16 +279,19 @@ try-runtime= [
"staging-parachain-info/try-runtime",
"pallet-aura/try-runtime",
"pallet-balances/try-runtime",
"pallet-elections-phragmen/try-runtime",
"pallet-session/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-transaction-pause/try-runtime",
"pallet-utility/try-runtime",
"pallet-treasury/try-runtime",
"pallet-collective/try-runtime",
"pallet-democracy/try-runtime",
"pallet-proxy/try-runtime",
"pallet-multisig/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-tips/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-authorship/try-runtime",
"pallet-uniques/try-runtime",
Expand Down
72 changes: 66 additions & 6 deletions runtime/basilisk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,74 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(
frame_support::migrations::RemovePallet<DmpQueuePalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<XcmRateLimiterPalletName, <Runtime as frame_system::Config>::DbWeight>,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
pallet_identity::migration::versioned::V0ToV1<Runtime, 200u64>, // We have currently 89 identities in basllisk, so limit of 200 should be enough
),
migrations::Migrations,
>;

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";
pub const DataDepositPerByte: Balance = primitives::constants::currency::CENTS;
pub const TipReportDepositBase: Balance = 10 * primitives::constants::currency::DOLLARS;
}

// 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 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;
}

pub type Migrations = (
// 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<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
);
}

parameter_types! {
pub const DmpQueuePalletName: &'static str = "DmpQueue";
pub const XcmRateLimiterPalletName: &'static str = "XcmRateLimiter";
Expand Down

0 comments on commit 131cda2

Please sign in to comment.