Skip to content

Commit

Permalink
feat: remove Randomness pallet (PLMC-602)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrazovic authored and JuaniRios committed Oct 10, 2024
1 parent fe4f161 commit 2af3359
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 79 deletions.
54 changes: 5 additions & 49 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion pallets/dispenser/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions pallets/funding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions pallets/funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub use crate::weights::WeightInfo;
use frame_support::{
traits::{
tokens::{fungible, fungibles},
AccountTouch, ContainsPair, Randomness,
AccountTouch, ContainsPair,
},
BoundedVec, PalletId,
};
Expand Down Expand Up @@ -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<AssetId = u32, Price = Self::Price>;

/// Something that provides randomness in the runtime.
type Randomness: Randomness<Self::Hash, BlockNumberFor<Self>>;

/// The length (expressed in number of blocks) of the Remainder Round.
#[pallet::constant]
type RemainderRoundDuration: Get<BlockNumberFor<Self>>;
Expand Down
7 changes: 1 addition & 6 deletions pallets/funding/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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::<Instance1>::{Pallet, Call, Storage, Event<T>},
Expand Down
3 changes: 0 additions & 3 deletions runtimes/polimec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
22 changes: 10 additions & 12 deletions runtimes/polimec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Runtime>,
crate::custom_migrations::funding_holds::FromFundingV4Migration,
);
pub type Unreleased =
(frame_support::migrations::RemovePallet<RandomPalletName, <Runtime as frame_system::Config>::DbWeight>,);
}

/// Executive: handles dispatch to the various modules.
Expand Down Expand Up @@ -1037,8 +1039,7 @@ impl ConvertBack<AccountId, [u8; 32]> 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;
Expand Down Expand Up @@ -1067,7 +1068,6 @@ impl pallet_funding::Config for Runtime {
type PalletId = FundingPalletId;
type Price = Price;
type PriceProvider = OraclePriceProvider<AssetId, Price, Oracle>;
type Randomness = Random;
type RemainderRoundDuration = RemainderRoundDuration;
type RequiredMaxCapacity = RequiredMaxCapacity;
type RequiredMaxMessageSize = RequiredMaxMessageSize;
Expand Down Expand Up @@ -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"));
}
Expand Down Expand Up @@ -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
Expand All @@ -1249,7 +1247,7 @@ construct_runtime!(
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>, HoldReason} = 45,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 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<T>} = 70,
Expand Down

0 comments on commit 2af3359

Please sign in to comment.