Kagome
Polkadot Runtime Engine in C++17
kagome::consensus::BabeLottery Struct Referenceabstract

#include <babe_lottery.hpp>

Inheritance diagram for kagome::consensus::BabeLottery:
Collaboration diagram for kagome::consensus::BabeLottery:

Public Member Functions

virtual ~BabeLottery ()=default
 
virtual void changeEpoch (const EpochDescriptor &epoch, const Randomness &randomness, const Threshold &threshold, const crypto::Sr25519Keypair &keypair)=0
 
virtual EpochDescriptor getEpoch () const =0
 
virtual std::optional< crypto::VRFOutputgetSlotLeadership (primitives::BabeSlotNumber slot) const =0
 
virtual crypto::VRFOutput slotVrfSignature (primitives::BabeSlotNumber slot) const =0
 
virtual std::optional< primitives::AuthorityIndexsecondarySlotAuthor (primitives::BabeSlotNumber slot, primitives::AuthorityListSize authorities_count, const Randomness &randomness) const =0
 

Detailed Description

Interface for acquiring leadership information for the current Babe epoch. It is expected to be used as follows:

  • first epoch is started, r (randomness) = 0
  • blocks are being accepted
  • when a block is finalized, submitVRFValue function is called for each block in the finalized chain up to the last finalized one (in the chronological order). The chain can be retrieved via calling BlockTree::longestPath() firstly and only then BlockTree::finalize(..)
  • at the end of the epoch, computeRandomness(..) is called, providing a randomness value for the new epoch
  • that value is then is used in slotsLeadership(..)

Definition at line 30 of file babe_lottery.hpp.

Constructor & Destructor Documentation

virtual kagome::consensus::BabeLottery::~BabeLottery ( )
virtualdefault

Member Function Documentation

virtual void kagome::consensus::BabeLottery::changeEpoch ( const EpochDescriptor epoch,
const Randomness randomness,
const Threshold threshold,
const crypto::Sr25519Keypair keypair 
)
pure virtual

Set new epoch and corresponding randomness, threshold and keypair values

Parameters
epochis an information about epoch where we calculate leadership
randomnessis an epoch random byte sequence
thresholdis a maximum value that is considered valid by vrf
keypairis a current babe sign pair

Implemented in kagome::consensus::BabeLotteryImpl.

virtual EpochDescriptor kagome::consensus::BabeLottery::getEpoch ( ) const
pure virtual

Return lottery current epoch

Implemented in kagome::consensus::BabeLotteryImpl.

virtual std::optional<crypto::VRFOutput> kagome::consensus::BabeLottery::getSlotLeadership ( primitives::BabeSlotNumber  slot) const
pure virtual

Compute leadership for the slot

Parameters
slotis a slot number
Returns
none means the peer was not chosen as a leader for that slot, value contains VRF value and proof

Implemented in kagome::consensus::BabeLotteryImpl.

virtual std::optional<primitives::AuthorityIndex> kagome::consensus::BabeLottery::secondarySlotAuthor ( primitives::BabeSlotNumber  slot,
primitives::AuthorityListSize  authorities_count,
const Randomness randomness 
) const
pure virtual

Compute the expected author for secondary slot

Parameters
slot- slot to have secondary block produced
authorities_count- quantity of authorities in current epoch
randomness- current randomness
Returns
- should always return some authority unless authorities list is empty

Implemented in kagome::consensus::BabeLotteryImpl.

virtual crypto::VRFOutput kagome::consensus::BabeLottery::slotVrfSignature ( primitives::BabeSlotNumber  slot) const
pure virtual

Computes VRF proof for the slot regardless threshold. Used when secondary VRF slots are enabled

Parameters
slotis a slot number
Returns
VRF output and proof

Implemented in kagome::consensus::BabeLotteryImpl.


The documentation for this struct was generated from the following file: