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
+1 -1
View File
@@ -56,7 +56,7 @@ wat = "1"
# Substrate Dependencies
pallet-balances = { version = "4.0.0-dev", path = "../balances" }
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" }
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>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
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},
Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},
}
@@ -311,7 +311,7 @@ impl frame_system::Config for Test {
type OnSetCode = ();
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 {
type MaxLocks = ();
type MaxReserves = ();
@@ -1,12 +1,12 @@
[package]
name = "pallet-randomness-collective-flip"
name = "pallet-insecure-randomness-collective-flip"
version = "4.0.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "Apache-2.0"
homepage = "https://substrate.io"
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"
[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
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
`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
@@ -8,7 +12,7 @@ situations like testing.
## 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
@@ -32,17 +36,17 @@ pub mod pallet {
pub struct Pallet<T>(_);
#[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]
impl<T: Config> Pallet<T> {
#[pallet::weight(0)]
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(())
}
}
}
```
License: Apache-2.0
License: Apache-2.0
@@ -15,6 +15,11 @@
// See the License for the specific language governing permissions and
// 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
//!
//! The Randomness Collective Flip pallet provides a [`random`](./struct.Module.html#method.random)
@@ -50,13 +55,13 @@
//! pub struct Pallet<T>(_);
//!
//! #[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]
//! impl<T: Config> Pallet<T> {
//! #[pallet::weight(0)]
//! 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(())
//! }
//! }
@@ -157,7 +162,7 @@ impl<T: Config> Randomness<T::Hash, T::BlockNumber> for Pallet<T> {
#[cfg(test)]
mod tests {
use super::*;
use crate as pallet_randomness_collective_flip;
use crate as pallet_insecure_randomness_collective_flip;
use sp_core::H256;
use sp_runtime::{
@@ -181,7 +186,7 @@ mod tests {
UncheckedExtrinsic = UncheckedExtrinsic,
{
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>;
}
impl pallet_randomness_collective_flip::Config for Test {}
impl pallet_insecure_randomness_collective_flip::Config for Test {}
fn new_test_ext() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();