Struct noble_babe::Module[][src]

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

The BABE Noble

Implementations

impl<T: Config + '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() -> Slot[src]

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

pub fn current_slot() -> Slot[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 author_vrf_randomness() -> Option<Randomness>[src]

Temporary value (cleared at block finalization) that includes the VRF output generated at this block. This field should always be populated during block processing unless secondary plain slots are enabled (which don’t contain a VRF output).

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: Config> 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 noble-session.

pub fn current_epoch_start() -> Slot[src]

Finds the start slot of the current epoch. only guaranteed to give correct results after do_initialize of the first block in the chain (as its result is based off of GenesisSlot).

pub fn current_epoch() -> Epoch[src]

Produces information about the current epoch.

pub fn next_epoch() -> Epoch[src]

Produces information about the next epoch (which was already previously announced).

pub fn submit_unsigned_equivocation_report(
    equivocation_proof: EquivocationProof<T::Header>,
    key_owner_proof: T::KeyOwnerProof
) -> Option<()>
[src]

Submits an extrinsic to report an equivocation. This method will create an unsigned extrinsic with a call to report_equivocation_unsigned and will push the transaction to the pool. Only useful in an offchain context.

Trait Implementations

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

type Public = AuthorityId

The RuntimeAppPublic this type is bound to.

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

type Call = Call<T>

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

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

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

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

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

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

impl<T: Config> GetNobleVersion for Module<T>[src]

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

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

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

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

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

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

impl<T: Config> OnGenesis for Module<T>[src]

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

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

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

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

type Key = AuthorityId

The key type expected.

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

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

type Call = Call<T>

The call type of the pallet.

type Error = MakeFatalError<Error>

The error returned by check_inherent.

impl<T: Config> Randomness<<T as Config>::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: Config> ShouldEndSession<<T as Config>::BlockNumber> for Module<T>[src]

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

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

impl<T: Config> ValidateUnsigned for Module<T>[src]

A ValidateUnsigned implementation that restricts calls to report_equivocation_unsigned to local calls (i.e. extrinsics generated on this node) or that already in a block. This guarantees that only block authors can include unsigned equivocation reports.

type Call = Call<T>

The call to validate

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<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> DynClone for T where
    T: Clone
[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> Instrument for T[src]

impl<T> Instrument 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
    T: From<Outer>,
    Outer: AsRef<T> + AsMut<T> + From<T>, 

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

Get a reference to the inner from the outer.

pub 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 + Send + Sync + Debug + Eq + PartialEq<T> + Clone
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Debug + Any
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

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
    T: Bounded,
    S: TryInto<T>, 

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