mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
4a293bc5a2
Using taplo, fixes all our broken and inconsistent toml formatting and adds CI to keep them tidy. If people want we can customise the format rules as described here https://taplo.tamasfe.dev/configuration/formatter-options.html @ggwpez, I suggest zepter is used only for checking features are propagated, and leave formatting for taplo to avoid duplicate work and conflicts. TODO - [x] Use `exclude = [...]` syntax in taplo file to ignore zombienet tests instead of deleting the dir --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
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
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 situations like testing.
Public Functions
See the
Module
struct for details of publicly available functions.
Usage
Prerequisites
Import the Randomness Collective Flip module and derive your module's configuration trait from the system trait.
Example - Get random seed for the current block
use frame_support::traits::Randomness;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::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_insecure_randomness_collective_flip::Pallet<T>>::random(&b"my context"[..]);
Ok(())
}
}
}
License: Apache-2.0