Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pallet_migrations: remove dependencies on pallet_democracy and pallet_preimage #2

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 0 additions & 37 deletions Cargo.lock

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

4 changes: 1 addition & 3 deletions pallets/migrations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ log = { workspace = true }
# Substrate
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-democracy = { workspace = true }
pallet-preimage = { workspace = true }
parity-scale-codec = { workspace = true }
scale-info = { workspace = true, features = [ "derive" ] }
sp-core = { workspace = true }
Expand All @@ -38,6 +36,6 @@ sp-io = { workspace = true, features = [ "std" ] }

[features]
default = [ "std" ]
std = [ "frame-support/std", "frame-system/std", "pallet-democracy/std", "pallet-preimage/std", "scale-info/std", "sp-core/std", "sp-io/std", "sp-runtime/std", "sp-std/std", "xcm-primitives/std" ]
std = [ "frame-support/std", "frame-system/std", "scale-info/std", "sp-core/std", "sp-io/std", "sp-runtime/std", "sp-std/std", "xcm-primitives/std" ]
runtime-benchmarks = [ "frame-benchmarking" ]
try-runtime = [ "frame-support/try-runtime" ]
76 changes: 0 additions & 76 deletions pallets/migrations/src/benchmarks.rs

This file was deleted.

24 changes: 1 addition & 23 deletions pallets/migrations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
#![allow(non_camel_case_types)]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(any(test, feature = "runtime-benchmarks"))]
mod benchmarks;
mod democracy_preimages;
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
pub mod weights;

use frame_support::{pallet, weights::Weight};

Expand Down Expand Up @@ -92,7 +88,6 @@ impl GetMigrations for Tuple {
#[pallet]
pub mod pallet {
use super::*;
use crate::weights::WeightInfo;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use xcm_primitives::PauseXcmExecution;
Expand All @@ -105,7 +100,7 @@ pub mod pallet {
/// Configuration trait of this pallet.
#[pallet::config]
pub trait Config:
frame_system::Config + pallet_democracy::Config + pallet_preimage::Config
frame_system::Config
{
/// Overarching event type
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
Expand All @@ -114,8 +109,6 @@ pub mod pallet {

/// Handler to suspend and resume XCM execution
type XcmExecutionManager: PauseXcmExecution;

type WeightInfo: WeightInfo;
}

#[pallet::event]
Expand Down Expand Up @@ -301,21 +294,6 @@ pub mod pallet {
/// of xcm messages must be paused.
type ShouldPauseXcm<T: Config> = StorageValue<_, bool, ValueQuery>;

#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(
<T as Config>::WeightInfo::migrate_democracy_preimage(*proposal_len_upper_bound)
)]
pub fn migrate_democracy_preimage(
origin: OriginFor<T>,
proposal_hash: T::Hash,
#[pallet::compact] proposal_len_upper_bound: u32,
) -> DispatchResultWithPostInfo {
Self::migrate_democracy_preimage_inner(origin, proposal_hash, proposal_len_upper_bound)
}
}

#[pallet::error]
pub enum Error<T> {
/// Missing preimage in original democracy storage
Expand Down
50 changes: 3 additions & 47 deletions pallets/migrations/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@

use super::*;
use crate as pallet_migrations;
use frame_support::traits::EqualPrivilegeOnly;
use frame_support::{
construct_runtime,
pallet_prelude::*,
parameter_types,
traits::{Everything, GenesisBuild},
traits::{EqualPrivilegeOnly, Everything, GenesisBuild},
weights::{constants::RocksDbWeight, Weight},
};
use frame_system::{EnsureRoot, EnsureSigned};
use frame_system::EnsureRoot;
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
Expand All @@ -49,10 +48,8 @@ construct_runtime!(
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Migrations: pallet_migrations::{Pallet, Storage, Config, Event<T>, Call},
Democracy: pallet_democracy::{Pallet, Storage, Config<T>, Event<T>, Call},
Migrations: pallet_migrations::{Pallet, Storage, Config, Event<T>},
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},
Preimage: pallet_preimage::{Pallet, Event<T>, Call},
}
);

Expand Down Expand Up @@ -123,37 +120,6 @@ parameter_types! {
pub const InstantAllowed: bool = false;
}

impl pallet_democracy::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type VoteLockingPeriod = VoteLockingPeriod;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
type MinimumDeposit = MinimumDeposit;
type ExternalOrigin = EnsureRoot<AccountId>;
type ExternalMajorityOrigin = EnsureRoot<AccountId>;
type ExternalDefaultOrigin = EnsureRoot<AccountId>;
type FastTrackOrigin = EnsureRoot<AccountId>;
type InstantOrigin = EnsureRoot<AccountId>;
type CancellationOrigin = EnsureRoot<AccountId>;
type CancelProposalOrigin = EnsureRoot<AccountId>;
type BlacklistOrigin = EnsureRoot<AccountId>;
type VetoOrigin = EnsureSigned<AccountId>;
type CooloffPeriod = CooloffPeriod;
type Slash = ();
type InstantAllowed = InstantAllowed;
type Scheduler = Scheduler;
type MaxVotes = MaxVotes;
type PalletsOrigin = OriginCaller;
type WeightInfo = ();
type MaxProposals = MaxProposals;
type Preimages = Preimage;
type MaxDeposits = ConstU32<1000>;
type MaxBlacklisted = ConstU32<5>;
type SubmitOrigin = EnsureSigned<AccountId>;
}
impl pallet_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
Expand All @@ -172,15 +138,6 @@ parameter_types! {
pub const ByteDeposit: u64 = 10;
}

impl pallet_preimage::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type BaseDeposit = BaseDeposit;
type ByteDeposit = ByteDeposit;
}

/// MockMigrationManager stores the test-side callbacks/closures used in the Migrations list glue.
/// It is is expected to exist as a singleton, but only remain relevant within the scope of a test.
///
Expand Down Expand Up @@ -347,7 +304,6 @@ impl Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type MigrationsList = MockMigrations;
type XcmExecutionManager = ();
type WeightInfo = ();
}

/// Externality builder for pallet migration's mock runtime
Expand Down
Loading
Loading