From 2af3359ca0220e82f45f72eea47551d2ce4664a2 Mon Sep 17 00:00:00 2001 From: Leonardo Razovic <4128940+lrazovic@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:56:28 +0200 Subject: [PATCH] feat: remove Randomness pallet (PLMC-602) --- Cargo.lock | 54 +++-------------------------- Cargo.toml | 1 - pallets/dispenser/src/extensions.rs | 2 +- pallets/funding/Cargo.toml | 3 -- pallets/funding/src/lib.rs | 5 +-- pallets/funding/src/mock.rs | 7 +--- runtimes/polimec/Cargo.toml | 3 -- runtimes/polimec/src/lib.rs | 22 ++++++------ 8 files changed, 18 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 01c68fa8d..21b7693f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -274,7 +274,7 @@ dependencies = [ "num-bigint", "num-traits", "paste", - "rustc_version 0.4.0", + "rustc_version", "zeroize", ] @@ -2583,7 +2583,7 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "rustc_version 0.4.0", + "rustc_version", "subtle 2.6.1", "zeroize", ] @@ -2759,7 +2759,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", + "rustc_version", "syn 2.0.71", ] @@ -4183,7 +4183,7 @@ checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" dependencies = [ "atomic-polyfill", "hash32", - "rustc_version 0.4.0", + "rustc_version", "serde", "spin 0.9.8", "stable_deref_trait", @@ -7300,7 +7300,6 @@ dependencies = [ "on-slash-vesting", "pallet-assets", "pallet-balances", - "pallet-insecure-randomness-collective-flip", "pallet-linear-release", "pallet-proxy-bonding", "pallet-timestamp", @@ -7405,21 +7404,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-insecure-randomness-collective-flip" -version = "23.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdbcd8635732846a585ee77ecd038e2701e7061ba89eb758d999d52931b02235" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "safe-mix", - "scale-info", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-linear-release" version = "0.8.0" @@ -8860,7 +8844,6 @@ dependencies = [ "pallet-elections-phragmen 0.8.0", "pallet-funding", "pallet-identity", - "pallet-insecure-randomness-collective-flip", "pallet-linear-release", "pallet-membership", "pallet-message-queue", @@ -11307,15 +11290,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.4.0" @@ -11518,15 +11492,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" -[[package]] -name = "safe-mix" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" -dependencies = [ - "rustc_version 0.2.3", -] - [[package]] name = "safe_arch" version = "0.7.2" @@ -13007,15 +12972,6 @@ dependencies = [ "semver-parser", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.23" @@ -13488,7 +13444,7 @@ dependencies = [ "curve25519-dalek 4.1.3", "rand_core 0.6.4", "ring 0.17.8", - "rustc_version 0.4.0", + "rustc_version", "sha2 0.10.8", "subtle 2.6.1", ] diff --git a/Cargo.toml b/Cargo.toml index 8035c08fc..13f7e2fce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,7 +153,6 @@ sp-weights = { version = "31.0.0", default-features = false } # FRAME pallet-aura = { version = "34.0.0", default-features = false } pallet-balances = { version = "36.0.0", default-features = false } -pallet-insecure-randomness-collective-flip = { version = "23.0.0", default-features = false } pallet-assets = { version = "36.0.0", default-features = false } pallet-authorship = { version = "35.0.0", default-features = false } pallet-session = { version = "35.0.0", default-features = false } diff --git a/pallets/dispenser/src/extensions.rs b/pallets/dispenser/src/extensions.rs index 17d700b4f..63a4689bd 100644 --- a/pallets/dispenser/src/extensions.rs +++ b/pallets/dispenser/src/extensions.rs @@ -19,7 +19,7 @@ use crate::{Call, Config}; use frame_support::{dispatch::DispatchInfo, pallet_prelude::*, traits::IsSubType}; use parity_scale_codec::{Decode, Encode}; -use scale_info::{TypeInfo}; +use scale_info::TypeInfo; use sp_runtime::traits::{DispatchInfoOf, Dispatchable, One, SignedExtension, Zero}; use sp_std::vec; /// Custom CheckNonce signed extension for Polimec Blockchain. Based on the CheckNonce signed extension from the FRAME. diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 87a8f5f80..f9489ae19 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -54,7 +54,6 @@ itertools.workspace = true sp-io.workspace = true [dev-dependencies] -pallet-insecure-randomness-collective-flip.workspace = true pallet-timestamp.workspace = true pallet-assets.workspace = true pallet-linear-release.workspace = true @@ -75,7 +74,6 @@ std = [ "on-slash-vesting/std", "pallet-assets/std", "pallet-balances/std", - "pallet-insecure-randomness-collective-flip/std", "pallet-linear-release/std", "pallet-proxy-bonding/std", "pallet-timestamp/std", @@ -124,7 +122,6 @@ try-runtime = [ "frame-system/try-runtime", "pallet-assets/try-runtime", "pallet-balances/try-runtime", - "pallet-insecure-randomness-collective-flip/try-runtime", "pallet-linear-release/try-runtime", "pallet-proxy-bonding/try-runtime", "pallet-timestamp/try-runtime", diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index afead2cd4..fb151a110 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -79,7 +79,7 @@ pub use crate::weights::WeightInfo; use frame_support::{ traits::{ tokens::{fungible, fungibles}, - AccountTouch, ContainsPair, Randomness, + AccountTouch, ContainsPair, }, BoundedVec, PalletId, }; @@ -318,9 +318,6 @@ pub mod pallet { /// Method to get the price of an asset like USDT or PLMC. Likely to come from an oracle type PriceProvider: ProvideAssetPrice; - /// Something that provides randomness in the runtime. - type Randomness: Randomness>; - /// The length (expressed in number of blocks) of the Remainder Round. #[pallet::constant] type RemainderRoundDuration: Get>; diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index e7bafb374..55364fd60 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -277,8 +277,6 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = (); } -impl pallet_insecure_randomness_collective_flip::Config for TestRuntime {} - impl pallet_timestamp::Config for TestRuntime { type MinimumPeriod = ConstU64<5>; type Moment = u64; @@ -391,8 +389,7 @@ impl ConstPriceProvider { } impl Config for TestRuntime { type AccountId32Conversion = DummyConverter; - type AllPalletsWithoutSystem = - (Balances, ContributionTokens, ForeignAssets, PolimecFunding, LinearRelease, RandomnessCollectiveFlip); + type AllPalletsWithoutSystem = (Balances, ContributionTokens, ForeignAssets, PolimecFunding, LinearRelease); type AuctionRoundDuration = AuctionRoundDuration; type BlockNumber = BlockNumber; type BlockchainOperationTreasury = BlockchainOperationTreasuryAccount; @@ -421,7 +418,6 @@ impl Config for TestRuntime { type PalletId = FundingPalletId; type Price = FixedU128; type PriceProvider = ConstPriceProvider; - type Randomness = RandomnessCollectiveFlip; type RemainderRoundDuration = RemainderRoundDuration; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; @@ -464,7 +460,6 @@ construct_runtime!( { System: frame_system, Timestamp: pallet_timestamp, - RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip, Balances: pallet_balances, LinearRelease: pallet_linear_release, ContributionTokens: pallet_assets::::{Pallet, Call, Storage, Event}, diff --git a/runtimes/polimec/Cargo.toml b/runtimes/polimec/Cargo.toml index 066821a28..a3e8f153c 100644 --- a/runtimes/polimec/Cargo.toml +++ b/runtimes/polimec/Cargo.toml @@ -56,7 +56,6 @@ pallet-collective.workspace = true pallet-democracy.workspace = true pallet-elections-phragmen.workspace = true pallet-identity.workspace = true -pallet-insecure-randomness-collective-flip.workspace = true pallet-membership.workspace = true pallet-message-queue.workspace = true pallet-multisig.workspace = true @@ -148,7 +147,6 @@ std = [ "pallet-elections-phragmen/std", "pallet-funding/std", "pallet-identity/std", - "pallet-insecure-randomness-collective-flip/std", "pallet-linear-release/std", "pallet-membership/std", "pallet-message-queue/std", @@ -264,7 +262,6 @@ try-runtime = [ "pallet-elections-phragmen/try-runtime", "pallet-funding/try-runtime", "pallet-identity/try-runtime", - "pallet-insecure-randomness-collective-flip/try-runtime", "pallet-linear-release/try-runtime", "pallet-membership/try-runtime", "pallet-message-queue/try-runtime", diff --git a/runtimes/polimec/src/lib.rs b/runtimes/polimec/src/lib.rs index 17c185872..889e38e92 100644 --- a/runtimes/polimec/src/lib.rs +++ b/runtimes/polimec/src/lib.rs @@ -164,14 +164,16 @@ pub type Migrations = migrations::Unreleased; /// The runtime migrations per release. #[allow(missing_docs)] pub mod migrations { - use crate::Runtime; + use crate::{parameter_types, Runtime}; + + parameter_types! { + pub const RandomPalletName: &'static str = "Random"; + } /// Unreleased migrations. Add new ones here: #[allow(unused_parens)] - pub type Unreleased = ( - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, - crate::custom_migrations::funding_holds::FromFundingV4Migration, - ); + pub type Unreleased = + (frame_support::migrations::RemovePallet::DbWeight>,); } /// Executive: handles dispatch to the various modules. @@ -1037,8 +1039,7 @@ impl ConvertBack for ConvertSelf { impl pallet_funding::Config for Runtime { type AccountId32Conversion = ConvertSelf; #[cfg(any(test, feature = "runtime-benchmarks", feature = "std"))] - type AllPalletsWithoutSystem = - (Balances, ContributionTokens, ForeignAssets, Oracle, Funding, LinearRelease, Random); + type AllPalletsWithoutSystem = (Balances, ContributionTokens, ForeignAssets, Oracle, Funding, LinearRelease); type AuctionRoundDuration = AuctionRoundDuration; type BlockNumber = BlockNumber; type BlockchainOperationTreasury = BlockchainOperationTreasury; @@ -1067,7 +1068,6 @@ impl pallet_funding::Config for Runtime { type PalletId = FundingPalletId; type Price = Price; type PriceProvider = OraclePriceProvider; - type Randomness = Random; type RemainderRoundDuration = RemainderRoundDuration; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; @@ -1127,8 +1127,6 @@ impl pallet_linear_release::Config for Runtime { const MAX_VESTING_SCHEDULES: u32 = 100; } -impl pallet_insecure_randomness_collective_flip::Config for Runtime {} - ord_parameter_types! { pub const DispenserAdminAccount: AccountId = AccountId::from(hex_literal::hex!("d85a4f58eb7dba17bc436b16f394b242271237021f7880e1ccaf36cd9a616c99")); } @@ -1237,7 +1235,7 @@ construct_runtime!( XcmpQueue: cumulus_pallet_xcmp_queue = 30, PolkadotXcm: pallet_xcm = 31, CumulusXcm: cumulus_pallet_xcm = 32, - // idx 31 was used for DmpQueue: cumulus_pallet_dmp_queue, now replaced by MessageQueue + // Index 31 was used for DmpQueue: cumulus_pallet_dmp_queue, now replaced by MessageQueue MessageQueue: pallet_message_queue = 34, // Governance @@ -1249,7 +1247,7 @@ construct_runtime!( Preimage: pallet_preimage::{Pallet, Call, Storage, Event, HoldReason} = 45, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 46, - Random: pallet_insecure_randomness_collective_flip = 50, + // Index 50 was used for Random: pallet_insecure_randomness_collective_flip, now not needed anymore. // Oracle Oracle: orml_oracle::{Pallet, Call, Storage, Event} = 70,