Rename pallet-random-collective-flip to Insecure... (#13301)

* Rename pallet-random-collective-flip to Insecure...

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2023-02-06 19:12:06 +01:00
committed by GitHub
parent f11ec1ba8c
commit fc2fda8d19
11 changed files with 53 additions and 44 deletions
+18 -18
View File
@@ -3526,6 +3526,7 @@ dependencies = [
"pallet-identity", "pallet-identity",
"pallet-im-online", "pallet-im-online",
"pallet-indices", "pallet-indices",
"pallet-insecure-randomness-collective-flip",
"pallet-lottery", "pallet-lottery",
"pallet-membership", "pallet-membership",
"pallet-message-queue", "pallet-message-queue",
@@ -3540,7 +3541,6 @@ dependencies = [
"pallet-offences-benchmarking", "pallet-offences-benchmarking",
"pallet-preimage", "pallet-preimage",
"pallet-proxy", "pallet-proxy",
"pallet-randomness-collective-flip",
"pallet-ranked-collective", "pallet-ranked-collective",
"pallet-recovery", "pallet-recovery",
"pallet-referenda", "pallet-referenda",
@@ -4981,7 +4981,7 @@ dependencies = [
"pallet-aura", "pallet-aura",
"pallet-balances", "pallet-balances",
"pallet-grandpa", "pallet-grandpa",
"pallet-randomness-collective-flip", "pallet-insecure-randomness-collective-flip",
"pallet-sudo", "pallet-sudo",
"pallet-template", "pallet-template",
"pallet-timestamp", "pallet-timestamp",
@@ -5591,7 +5591,7 @@ dependencies = [
"pallet-balances", "pallet-balances",
"pallet-contracts-primitives", "pallet-contracts-primitives",
"pallet-contracts-proc-macro", "pallet-contracts-proc-macro",
"pallet-randomness-collective-flip", "pallet-insecure-randomness-collective-flip",
"pallet-timestamp", "pallet-timestamp",
"pallet-utility", "pallet-utility",
"parity-scale-codec", "parity-scale-codec",
@@ -5872,6 +5872,21 @@ dependencies = [
"sp-std", "sp-std",
] ]
[[package]]
name = "pallet-insecure-randomness-collective-flip"
version = "4.0.0-dev"
dependencies = [
"frame-support",
"frame-system",
"parity-scale-codec",
"safe-mix",
"scale-info",
"sp-core",
"sp-io",
"sp-runtime",
"sp-std",
]
[[package]] [[package]]
name = "pallet-lottery" name = "pallet-lottery"
version = "4.0.0-dev" version = "4.0.0-dev"
@@ -6197,21 +6212,6 @@ dependencies = [
"sp-std", "sp-std",
] ]
[[package]]
name = "pallet-randomness-collective-flip"
version = "4.0.0-dev"
dependencies = [
"frame-support",
"frame-system",
"parity-scale-codec",
"safe-mix",
"scale-info",
"sp-core",
"sp-io",
"sp-runtime",
"sp-std",
]
[[package]] [[package]]
name = "pallet-ranked-collective" name = "pallet-ranked-collective"
version = "4.0.0-dev" version = "4.0.0-dev"
+1 -1
View File
@@ -128,7 +128,7 @@ members = [
"frame/nomination-pools/benchmarking", "frame/nomination-pools/benchmarking",
"frame/nomination-pools/test-staking", "frame/nomination-pools/test-staking",
"frame/nomination-pools/runtime-api", "frame/nomination-pools/runtime-api",
"frame/randomness-collective-flip", "frame/insecure-randomness-collective-flip",
"frame/ranked-collective", "frame/ranked-collective",
"frame/recovery", "frame/recovery",
"frame/referenda", "frame/referenda",
@@ -20,7 +20,7 @@ pallet-aura = { version = "4.0.0-dev", default-features = false, path = "../../.
pallet-balances = { version = "4.0.0-dev", default-features = false, path = "../../../frame/balances" } pallet-balances = { version = "4.0.0-dev", default-features = false, path = "../../../frame/balances" }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/support" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/support" }
pallet-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../../frame/grandpa" } pallet-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../../frame/grandpa" }
pallet-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, path = "../../../frame/randomness-collective-flip" } pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, path = "../../../frame/insecure-randomness-collective-flip" }
pallet-sudo = { version = "4.0.0-dev", default-features = false, path = "../../../frame/sudo" } pallet-sudo = { version = "4.0.0-dev", default-features = false, path = "../../../frame/sudo" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system" }
frame-try-runtime = { version = "0.10.0-dev", default-features = false, path = "../../../frame/try-runtime", optional = true } frame-try-runtime = { version = "0.10.0-dev", default-features = false, path = "../../../frame/try-runtime", optional = true }
@@ -69,7 +69,7 @@ std = [
"pallet-aura/std", "pallet-aura/std",
"pallet-balances/std", "pallet-balances/std",
"pallet-grandpa/std", "pallet-grandpa/std",
"pallet-randomness-collective-flip/std", "pallet-insecure-randomness-collective-flip/std",
"pallet-sudo/std", "pallet-sudo/std",
"pallet-template/std", "pallet-template/std",
"pallet-timestamp/std", "pallet-timestamp/std",
@@ -107,7 +107,7 @@ try-runtime = [
"pallet-aura/try-runtime", "pallet-aura/try-runtime",
"pallet-balances/try-runtime", "pallet-balances/try-runtime",
"pallet-grandpa/try-runtime", "pallet-grandpa/try-runtime",
"pallet-randomness-collective-flip/try-runtime", "pallet-insecure-randomness-collective-flip/try-runtime",
"pallet-sudo/try-runtime", "pallet-sudo/try-runtime",
"pallet-template/try-runtime", "pallet-template/try-runtime",
"pallet-timestamp/try-runtime", "pallet-timestamp/try-runtime",
@@ -205,7 +205,7 @@ impl frame_system::Config for Runtime {
type MaxConsumers = frame_support::traits::ConstU32<16>; type MaxConsumers = frame_support::traits::ConstU32<16>;
} }
impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_insecure_randomness_collective_flip::Config for Runtime {}
impl pallet_aura::Config for Runtime { impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId; type AuthorityId = AuraId;
@@ -290,7 +290,7 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system, System: frame_system,
RandomnessCollectiveFlip: pallet_randomness_collective_flip, RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip,
Timestamp: pallet_timestamp, Timestamp: pallet_timestamp,
Aura: pallet_aura, Aura: pallet_aura,
Grandpa: pallet_grandpa, Grandpa: pallet_grandpa,
+3 -3
View File
@@ -87,7 +87,7 @@ pallet-offences = { version = "4.0.0-dev", default-features = false, path = "../
pallet-offences-benchmarking = { version = "4.0.0-dev", path = "../../../frame/offences/benchmarking", default-features = false, optional = true } pallet-offences-benchmarking = { version = "4.0.0-dev", path = "../../../frame/offences/benchmarking", default-features = false, optional = true }
pallet-preimage = { version = "4.0.0-dev", default-features = false, path = "../../../frame/preimage" } pallet-preimage = { version = "4.0.0-dev", default-features = false, path = "../../../frame/preimage" }
pallet-proxy = { version = "4.0.0-dev", default-features = false, path = "../../../frame/proxy" } pallet-proxy = { version = "4.0.0-dev", default-features = false, path = "../../../frame/proxy" }
pallet-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, path = "../../../frame/randomness-collective-flip" } pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, path = "../../../frame/insecure-randomness-collective-flip" }
pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, path = "../../../frame/ranked-collective" } pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, path = "../../../frame/ranked-collective" }
pallet-recovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/recovery" } pallet-recovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/recovery" }
pallet-referenda = { version = "4.0.0-dev", default-features = false, path = "../../../frame/referenda" } pallet-referenda = { version = "4.0.0-dev", default-features = false, path = "../../../frame/referenda" }
@@ -167,7 +167,7 @@ std = [
"pallet-preimage/std", "pallet-preimage/std",
"pallet-proxy/std", "pallet-proxy/std",
"sp-core/std", "sp-core/std",
"pallet-randomness-collective-flip/std", "pallet-insecure-randomness-collective-flip/std",
"sp-std/std", "sp-std/std",
"pallet-session/std", "pallet-session/std",
"pallet-session-benchmarking?/std", "pallet-session-benchmarking?/std",
@@ -300,7 +300,7 @@ try-runtime = [
"pallet-offences/try-runtime", "pallet-offences/try-runtime",
"pallet-preimage/try-runtime", "pallet-preimage/try-runtime",
"pallet-proxy/try-runtime", "pallet-proxy/try-runtime",
"pallet-randomness-collective-flip/try-runtime", "pallet-insecure-randomness-collective-flip/try-runtime",
"pallet-ranked-collective/try-runtime", "pallet-ranked-collective/try-runtime",
"pallet-recovery/try-runtime", "pallet-recovery/try-runtime",
"pallet-referenda/try-runtime", "pallet-referenda/try-runtime",
+2 -2
View File
@@ -233,7 +233,7 @@ impl frame_system::Config for Runtime {
type MaxConsumers = ConstU32<16>; type MaxConsumers = ConstU32<16>;
} }
impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_insecure_randomness_collective_flip::Config for Runtime {}
impl pallet_utility::Config for Runtime { impl pallet_utility::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
@@ -1732,7 +1732,7 @@ construct_runtime!(
AuthorityDiscovery: pallet_authority_discovery, AuthorityDiscovery: pallet_authority_discovery,
Offences: pallet_offences, Offences: pallet_offences,
Historical: pallet_session_historical::{Pallet}, Historical: pallet_session_historical::{Pallet},
RandomnessCollectiveFlip: pallet_randomness_collective_flip, RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip,
Identity: pallet_identity, Identity: pallet_identity,
Society: pallet_society, Society: pallet_society,
Recovery: pallet_recovery, Recovery: pallet_recovery,
+1 -1
View File
@@ -56,7 +56,7 @@ wat = "1"
# Substrate Dependencies # Substrate Dependencies
pallet-balances = { version = "4.0.0-dev", path = "../balances" } pallet-balances = { version = "4.0.0-dev", path = "../balances" }
pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" } pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" }
pallet-randomness-collective-flip = { version = "4.0.0-dev", path = "../randomness-collective-flip" } pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", path = "../insecure-randomness-collective-flip" }
pallet-utility = { version = "4.0.0-dev", path = "../utility" } pallet-utility = { version = "4.0.0-dev", path = "../utility" }
sp-keystore = { version = "0.13.0", path = "../../primitives/keystore" } sp-keystore = { version = "0.13.0", path = "../../primitives/keystore" }
+2 -2
View File
@@ -67,7 +67,7 @@ frame_support::construct_runtime!(
System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Randomness: pallet_randomness_collective_flip::{Pallet, Storage}, Randomness: pallet_insecure_randomness_collective_flip::{Pallet, Storage},
Utility: pallet_utility::{Pallet, Call, Storage, Event}, Utility: pallet_utility::{Pallet, Call, Storage, Event},
Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>}, Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},
} }
@@ -311,7 +311,7 @@ impl frame_system::Config for Test {
type OnSetCode = (); type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>; type MaxConsumers = frame_support::traits::ConstU32<16>;
} }
impl pallet_randomness_collective_flip::Config for Test {} impl pallet_insecure_randomness_collective_flip::Config for Test {}
impl pallet_balances::Config for Test { impl pallet_balances::Config for Test {
type MaxLocks = (); type MaxLocks = ();
type MaxReserves = (); type MaxReserves = ();
@@ -1,12 +1,12 @@
[package] [package]
name = "pallet-randomness-collective-flip" name = "pallet-insecure-randomness-collective-flip"
version = "4.0.0-dev" version = "4.0.0-dev"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
homepage = "https://substrate.io" homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/" repository = "https://github.com/paritytech/substrate/"
description = "FRAME randomness collective flip pallet" description = "Insecure do not use in production: FRAME randomness collective flip pallet"
readme = "README.md" readme = "README.md"
[package.metadata.docs.rs] [package.metadata.docs.rs]
@@ -1,6 +1,10 @@
# DO NOT USE IN PRODUCTION
The produced values do not fulfill the cryptographic requirements for random numbers. Should not be used for high-stake production use-cases.
# Randomness Module # Randomness Module
The Randomness Collective Flip module provides a [`random`](https://docs.rs/pallet-randomness-collective-flip/latest/pallet_randomness_collective_flip/struct.Module.html#method.random) The Randomness Collective Flip module provides a [`random`](https://docs.rs/pallet-insecure-randomness-collective-flip/latest/pallet_insecure_randomness_collective_flip/struct.Module.html#method.random)
function that generates low-influence random values based on the block hashes from the previous function that generates low-influence random values based on the block hashes from the previous
`81` blocks. Low-influence randomness can be useful when defending against relatively weak `81` blocks. Low-influence randomness can be useful when defending against relatively weak
adversaries. Using this pallet as a randomness source is advisable primarily in low-security adversaries. Using this pallet as a randomness source is advisable primarily in low-security
@@ -8,7 +12,7 @@ situations like testing.
## Public Functions ## Public Functions
See the [`Module`](https://docs.rs/pallet-randomness-collective-flip/latest/pallet_randomness_collective_flip/struct.Module.html) struct for details of publicly available functions. See the [`Module`](https://docs.rs/pallet-insecure-randomness-collective-flip/latest/pallet_insecure_randomness_collective_flip/struct.Module.html) struct for details of publicly available functions.
## Usage ## Usage
@@ -32,13 +36,13 @@ pub mod pallet {
pub struct Pallet<T>(_); pub struct Pallet<T>(_);
#[pallet::config] #[pallet::config]
pub trait Config: frame_system::Config + pallet_randomness_collective_flip::Config {} pub trait Config: frame_system::Config + pallet_insecure_randomness_collective_flip::Config {}
#[pallet::call] #[pallet::call]
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
#[pallet::weight(0)] #[pallet::weight(0)]
pub fn random_module_example(origin: OriginFor<T>) -> DispatchResult { pub fn random_module_example(origin: OriginFor<T>) -> DispatchResult {
let _random_value = <pallet_randomness_collective_flip::Pallet<T>>::random(&b"my context"[..]); let _random_value = <pallet_insecure_randomness_collective_flip::Pallet<T>>::random(&b"my context"[..]);
Ok(()) Ok(())
} }
} }
@@ -15,6 +15,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//! # DO NOT USE IN PRODUCTION
//!
//! The produced values do not fulfill the cryptographic requirements for random numbers.
//! Should not be used for high-stake production use-cases.
//!
//! # Randomness Pallet //! # Randomness Pallet
//! //!
//! The Randomness Collective Flip pallet provides a [`random`](./struct.Module.html#method.random) //! The Randomness Collective Flip pallet provides a [`random`](./struct.Module.html#method.random)
@@ -50,13 +55,13 @@
//! pub struct Pallet<T>(_); //! pub struct Pallet<T>(_);
//! //!
//! #[pallet::config] //! #[pallet::config]
//! pub trait Config: frame_system::Config + pallet_randomness_collective_flip::Config {} //! pub trait Config: frame_system::Config + pallet_insecure_randomness_collective_flip::Config {}
//! //!
//! #[pallet::call] //! #[pallet::call]
//! impl<T: Config> Pallet<T> { //! impl<T: Config> Pallet<T> {
//! #[pallet::weight(0)] //! #[pallet::weight(0)]
//! pub fn random_module_example(origin: OriginFor<T>) -> DispatchResult { //! pub fn random_module_example(origin: OriginFor<T>) -> DispatchResult {
//! let _random_value = <pallet_randomness_collective_flip::Pallet<T>>::random(&b"my context"[..]); //! let _random_value = <pallet_insecure_randomness_collective_flip::Pallet<T>>::random(&b"my context"[..]);
//! Ok(()) //! Ok(())
//! } //! }
//! } //! }
@@ -157,7 +162,7 @@ impl<T: Config> Randomness<T::Hash, T::BlockNumber> for Pallet<T> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate as pallet_randomness_collective_flip; use crate as pallet_insecure_randomness_collective_flip;
use sp_core::H256; use sp_core::H256;
use sp_runtime::{ use sp_runtime::{
@@ -181,7 +186,7 @@ mod tests {
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
CollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage}, CollectiveFlip: pallet_insecure_randomness_collective_flip::{Pallet, Storage},
} }
); );
@@ -217,7 +222,7 @@ mod tests {
type MaxConsumers = ConstU32<16>; type MaxConsumers = ConstU32<16>;
} }
impl pallet_randomness_collective_flip::Config for Test {} impl pallet_insecure_randomness_collective_flip::Config for Test {}
fn new_test_ext() -> sp_io::TestExternalities { fn new_test_ext() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap(); let t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();