[][src]Struct pallet_babe::Module

pub struct Module<T: Trait>(_);

The BABE Pallet

Implementations

impl<T: Trait + 'static> Module<T>[src]

pub fn epoch_index() -> u64[src]

Current epoch index.

pub fn authorities() -> Vec<(AuthorityId, BabeAuthorityWeight)>[src]

Current epoch authorities.

pub fn genesis_slot() -> u64[src]

The slot at which the first epoch actually started. This is 0 until the first block of the chain.

pub fn current_slot() -> u64[src]

Current slot number.

pub fn randomness() -> Randomness[src]

The epoch randomness for the current epoch.

Security

This MUST NOT be used for gambling, as it can be influenced by a malicious validator in the short term. It MAY be used in many cryptographic protocols, however, so long as one remembers that this (like everything else on-chain) it is public. For example, it can be used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs.

pub fn initialized() -> Option<Option<Randomness>>[src]

Temporary value (cleared at block finalization) which is Some if per-block initialization has already been called for current block.

pub fn lateness() -> T::BlockNumber[src]

How late the current block is compared to its parent.

This entry is populated as part of block execution and is cleaned up on block finalization. Querying this storage entry outside of block execution context should always yield zero.

impl<T: Trait> Module<T>[src]

pub fn slot_duration() -> T::Moment[src]

Determine the BABE slot duration based on the Timestamp module configuration.

pub fn should_epoch_change(now: T::BlockNumber) -> bool[src]

Determine whether an epoch change should take place at this block. Assumes that initialization has already taken place.

pub fn next_expected_epoch_change(now: T::BlockNumber) -> Option<T::BlockNumber>[src]

Return the best guess block number, at which the next epoch change is predicted to happen.

Returns None if the prediction is in the past; This implies an error internally in the Babe and should not happen under normal circumstances.

In other word, this is only accurate if no slots are missed. Given missed slots, the slot number will grow while the block number will not. Hence, the result can be interpreted as an upper bound.

pub fn plan_config_change(config: NextConfigDescriptor)[src]

Plan an epoch config change. The epoch config change is recorded and will be enacted on the next call to enact_epoch_change. The config will be activated one epoch after. Multiple calls to this method will replace any existing planned config change that had not been enacted yet.

pub fn enact_epoch_change(
    authorities: Vec<(AuthorityId, BabeAuthorityWeight)>,
    next_authorities: Vec<(AuthorityId, BabeAuthorityWeight)>
)
[src]

DANGEROUS: Enact an epoch change. Should be done on every block where should_epoch_change has returned true, and the caller is the only caller of this function.

Typically, this is not handled directly by the user, but by higher-level validator-set manager logic like pallet-session.

pub fn current_epoch_start() -> SlotNumber[src]

Trait Implementations

impl<T: Trait> BoundToRuntimeAppPublic for Module<T>[src]

type Public = AuthorityId

The RuntimeAppPublic this type is bound to.

impl<T: Trait> Callable<T> for Module<T>[src]

type Call = Call<T>

impl<T: Clone + Trait> Clone for Module<T>[src]

impl<T: Copy + Trait> Copy for Module<T>[src]

impl<T: Trait> Debug for Module<T> where
    T: Debug
[src]

impl<T: Eq + Trait> Eq for Module<T>[src]

impl<T: Trait> EstimateNextSessionRotation<<T as Trait>::BlockNumber> for Module<T>[src]

impl<T: Trait> FindAuthor<u32> for Module<T>[src]

impl<T: Trait> IntegrityTest for Module<T>[src]

impl<T: Trait> IsMember<Public> for Module<T>[src]

impl<T: Trait> Lateness<<T as Trait>::BlockNumber> for Module<T>[src]

impl<T: Trait> ModuleErrorMetadata for Module<T>[src]

impl<T: Trait> OffchainWorker<<T as Trait>::BlockNumber> for Module<T>[src]

impl<T: Trait> OnFinalize<<T as Trait>::BlockNumber> for Module<T>[src]

impl<T: Trait> OnInitialize<<T as Trait>::BlockNumber> for Module<T>[src]

impl<T: Trait> OnRuntimeUpgrade for Module<T>[src]

impl<T: Trait> OnTimestampSet<<T as Trait>::Moment> for Module<T>[src]

impl<T: Trait> OneSessionHandler<<T as Trait>::AccountId> for Module<T>[src]

type Key = AuthorityId

The key type expected.

impl<T: PartialEq + Trait> PartialEq<Module<T>> for Module<T>[src]

impl<T: Trait> ProvideInherent for Module<T>[src]

type Call = Call<T>

The call type of the module.

type Error = MakeFatalError<Error>

The error returned by check_inherent.

impl<T: Trait> Randomness<<T as Trait>::Hash> for Module<T>[src]

fn random(subject: &[u8]) -> T::Hash[src]

Some BABE blocks have VRF outputs where the block producer has exactly one bit of influence, either they make the block or they do not make the block and thus someone else makes the next block. Yet, this randomness is not fresh in all BABE blocks.

If that is an insufficient security guarantee then two things can be used to improve this randomness:

  • Name, in advance, the block number whose random value will be used; ensure your module retains a buffer of previous random values for its subject and then index into these in order to obviate the ability of your user to look up the parent hash and choose when to transact based upon it.
  • Require your user to first commit to an additional value by first posting its hash. Require them to reveal the value to determine the final result, hashing it with the output of this random function. This reduces the ability of a cabal of block producers from conspiring against individuals.

impl<T: Trait> ShouldEndSession<<T as Trait>::BlockNumber> for Module<T>[src]

impl<T: Trait> StructuralEq for Module<T>[src]

impl<T: Trait> StructuralPartialEq for Module<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Module<T> where
    T: RefUnwindSafe

impl<T> Send for Module<T> where
    T: Send

impl<T> Sync for Module<T> where
    T: Sync

impl<T> Unpin for Module<T> where
    T: Unpin

impl<T> UnwindSafe for Module<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CheckedConversion for T[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IsType<T> for T[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    Outer: AsRef<T> + AsMut<T> + From<T>,
    T: From<Outer>, 

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeRefUnwindSafe for T where
    T: RefUnwindSafe

impl<T> Member for T where
    T: 'static + Clone + PartialEq<T> + Eq + Send + Sync + Debug
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 

impl<T, S> UniqueSaturatedInto<T> for S where
    S: TryInto<T>,
    T: Bounded

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,