Documentation
¶
Index ¶
- Constants
- Variables
- type AllowedSlots
- type AuthorityIndex
- type Configuration
- type Epoch
- type EpochConfiguration
- type EpochStartBlocks
- type PreDigest
- func DecodePreDigest(buffer *bytes.Buffer) (PreDigest, error)
- func NewPrimaryPreDigest(authorityIndex AuthorityIndex, slot Slot, vrfSignature types.VrfSignature) PreDigest
- func NewSecondaryPlainPreDigest(authorityIndex AuthorityIndex, slot Slot) PreDigest
- func NewSecondaryVRFPreDigest(authorityIndex AuthorityIndex, slot Slot, vrfSignature types.VrfSignature) PreDigest
- type PrimaryPreDigest
- type Randomness
- type SecondaryPlainPreDigest
- type SecondaryVRFPreDigest
- type SessionIndex
- type SkippedEpoch
- type Slot
Constants ¶
const ( // Only allow primary slots. PrimarySlots sc.U8 = iota // Allow primary and secondary plain slots. PrimaryAndSecondaryPlainSlots // Allow primary and secondary VRF slots. PrimaryAndSecondaryVRFSlots )
Types of allowed slots.
const ( // A primary VRF-based slot assignment. Primary sc.U8 // A secondary deterministic slot assignment. SecondaryPlain // A secondary deterministic slot assignment with VRF outputs. SecondaryVRF )
A BABE pre-runtime digest. This contains all data required to validate a block and for the BABE runtime module. Slots can be assigned to a primary (VRF based) and to a secondary (slot number based).
const RandomnessLength = 32
VRF output length for per-slot randomness.
Variables ¶
var (
ErrInvalidAllowedSlots = errors.New("invalid 'AllowedSlots' type")
)
Functions ¶
This section is empty.
Types ¶
type AllowedSlots ¶
type AllowedSlots struct {
sc.VaryingData
}
func DecodeAllowedSlots ¶
func DecodeAllowedSlots(buffer *bytes.Buffer) (AllowedSlots, error)
func NewPrimaryAndSecondaryPlainSlots ¶
func NewPrimaryAndSecondaryPlainSlots() AllowedSlots
func NewPrimaryAndSecondaryVRFSlots ¶
func NewPrimaryAndSecondaryVRFSlots() AllowedSlots
func NewPrimarySlots ¶
func NewPrimarySlots() AllowedSlots
func (AllowedSlots) String ¶
func (a AllowedSlots) String() string
type AuthorityIndex ¶
type Configuration ¶
type Configuration struct {
// The slot duration in milliseconds for BABE. Currently, only
// the value provided by this type at genesis will be used.
//
// Dynamic slot duration may be supported in the future.
SlotDuration sc.U64
// The duration of epochs in slots.
EpochLength sc.U64
// A constant value that is used in the threshold calculation formula.
// In the threshold formula calculation, `1 - c` represents the probability
// of a slot being empty.
C primitives.Tuple2U64
// The authorities
Authorities sc.Sequence[primitives.Authority]
// The randomness
Randomness Randomness
// Type of allowed slots.
AllowedSlots AllowedSlots
}
Configuration data used by the BABE consensus engine.
func DecodeConfiguration ¶
func DecodeConfiguration(buffer *bytes.Buffer) (Configuration, error)
func (Configuration) Bytes ¶
func (c Configuration) Bytes() []byte
type Epoch ¶
type Epoch struct {
// The epoch index.
EpochIndex sc.U64
// The starting slot of the epoch.
StartSlot Slot
// The duration of this epoch.
Duration sc.U64
// The authorities and their weights.
Authorities sc.Sequence[primitives.Authority]
// Randomness for this epoch.
Randomness Randomness
// Configuration of the epoch.
Config EpochConfiguration
}
BABE epoch information
type EpochConfiguration ¶
type EpochConfiguration struct {
// A constant value that is used in the threshold calculation formula.
// In the threshold formula calculation, `1 - c` represents the probability
// of a slot being empty.
C primitives.Tuple2U64
// Whether this chain should run with secondary slots, which are assigned
// in round-robin manner.
AllowedSlots AllowedSlots
}
Configuration data used by the BABE consensus engine that may change with epochs.
func DecodeEpochConfiguration ¶
func DecodeEpochConfiguration(buffer *bytes.Buffer) (EpochConfiguration, error)
func (EpochConfiguration) Bytes ¶
func (c EpochConfiguration) Bytes() []byte
type EpochStartBlocks ¶
func DecodeEpochStartBlocks ¶
func DecodeEpochStartBlocks(buffer *bytes.Buffer) (EpochStartBlocks, error)
func (EpochStartBlocks) Bytes ¶
func (e EpochStartBlocks) Bytes() []byte
type PreDigest ¶
type PreDigest struct {
sc.VaryingData
}
func NewPrimaryPreDigest ¶
func NewPrimaryPreDigest(authorityIndex AuthorityIndex, slot Slot, vrfSignature types.VrfSignature) PreDigest
func NewSecondaryPlainPreDigest ¶
func NewSecondaryPlainPreDigest(authorityIndex AuthorityIndex, slot Slot) PreDigest
func NewSecondaryVRFPreDigest ¶
func NewSecondaryVRFPreDigest(authorityIndex AuthorityIndex, slot Slot, vrfSignature types.VrfSignature) PreDigest
func (PreDigest) AuthorityIndex ¶
func (d PreDigest) AuthorityIndex() (AuthorityIndex, error)
Returns the slot number of the pre digest.
func (PreDigest) VrfSignature ¶
Returns the VRF output and proof, if they exist.
type PrimaryPreDigest ¶
type PrimaryPreDigest struct {
AuthorityIndex AuthorityIndex
Slot Slot
VrfSignature types.VrfSignature
}
Raw BABE primary slot assignment pre-digest.
func DecodePrimaryPreDigest ¶
func DecodePrimaryPreDigest(buffer *bytes.Buffer) (PrimaryPreDigest, error)
func (PrimaryPreDigest) Bytes ¶
func (d PrimaryPreDigest) Bytes() []byte
type Randomness ¶
type Randomness = sc.FixedSequence[sc.U8]
Randomness type required by BABE operations.
func NewRandomness ¶
func NewRandomness() Randomness
type SecondaryPlainPreDigest ¶
type SecondaryPlainPreDigest struct {
// This is not strictly-speaking necessary, since the secondary slots
// are assigned based on slot number and epoch randomness. But including
// it makes things easier for higher-level users of the chain data to
// be aware of the author of a secondary-slot block.
AuthorityIndex AuthorityIndex
Slot Slot
}
BABE secondary slot assignment pre-digest.
func DecodeSecondaryPlainPreDigest ¶
func DecodeSecondaryPlainPreDigest(buffer *bytes.Buffer) (SecondaryPlainPreDigest, error)
func (SecondaryPlainPreDigest) Bytes ¶
func (d SecondaryPlainPreDigest) Bytes() []byte
type SecondaryVRFPreDigest ¶
type SecondaryVRFPreDigest struct {
AuthorityIndex AuthorityIndex
Slot Slot
VrfSignature types.VrfSignature
}
BABE secondary deterministic slot assignment with VRF outputs.
func DecodeSecondaryVRFPreDigest ¶
func DecodeSecondaryVRFPreDigest(buffer *bytes.Buffer) (SecondaryVRFPreDigest, error)
func (SecondaryVRFPreDigest) Bytes ¶
func (d SecondaryVRFPreDigest) Bytes() []byte
type SessionIndex ¶
type SkippedEpoch ¶
type SkippedEpoch struct {
sc.U64
SessionIndex
}
func (SkippedEpoch) Bytes ¶
func (se SkippedEpoch) Bytes() []byte