Documentation
¶
Index ¶
Constants ¶
const RandomnessLength = 32
RandomnessLength is the length of the epoch randomness (32 bytes)
Variables ¶
var ( Timstap0 = []byte("timstap0") Babeslot = []byte("babeslot") )
nolint
var ErrBadSignature = errors.New("could not verify signature")
ErrBadSignature is returned when a seal is invalid
var ErrBadSlotClaim = errors.New("could not verify slot claim")
ErrBadSlotClaim is returned when a slot claim is invalid
var ErrNilBlockState = errors.New("cannot have nil BlockState")
ErrNilBlockState is returned when the BlockState is nil
var ErrNilNextEpochDescriptor = errors.New("nil NextEpochDescriptor for epoch")
ErrNilNextEpochDescriptor is returned when attempting to get a NextEpochDescriptor that isn't set for an epoch
var ErrProducerEquivocated = errors.New("block producer equivocated")
ErrProducerEquivocated is returned when a block producer has produced conflicting blocks
Functions ¶
This section is empty.
Types ¶
type BlockState ¶
type BlockState interface {
BestBlockHash() common.Hash
BestBlockHeader() (*types.Header, error)
BestBlockNumber() (*big.Int, error)
BestBlock() (*types.Block, error)
SubChain(start, end common.Hash) ([]common.Hash, error)
AddBlock(*types.Block) error
GetAllBlocksAtDepth(hash common.Hash) []common.Hash
AddBlockWithArrivalTime(*types.Block, uint64) error
GetHeader(common.Hash) (*types.Header, error)
GetBlockByNumber(*big.Int) (*types.Block, error)
GetBlockByHash(common.Hash) (*types.Block, error)
GetArrivalTime(common.Hash) (uint64, error)
GenesisHash() common.Hash
GetSlotForBlock(common.Hash) (uint64, error)
HighestBlockHash() common.Hash
HighestBlockNumber() *big.Int
}
BlockState interface for block state methods
type InherentsData ¶
type InherentsData struct {
// contains filtered or unexported fields
}
InherentsData contains a mapping of inherent keys to values keys must be 8 bytes, values are a variable-length byte array
func NewInherentsData ¶
func NewInherentsData() *InherentsData
NewInherentsData returns InherentsData
func (*InherentsData) Encode ¶
func (d *InherentsData) Encode() ([]byte, error)
Encode will encode a given []byte using scale.Encode
func (*InherentsData) SetInt64Inherent ¶
func (d *InherentsData) SetInt64Inherent(key []byte, data uint64) error
SetInt64Inherent set the Int64 scale.Encode for a given data
type NextEpochDescriptor ¶
type NextEpochDescriptor struct {
Authorities []*types.AuthorityData
Randomness [RandomnessLength]byte // TODO: update to [32]byte when runtime is updated
}
NextEpochDescriptor contains information about the next epoch. It is broadcast as part of the consensus digest in the first block of the epoch.
func (*NextEpochDescriptor) Decode ¶
func (n *NextEpochDescriptor) Decode(in []byte) error
Decode sets the NextEpochDescriptor to the SCALE decoded input. TODO: change to io.Reader
func (*NextEpochDescriptor) Encode ¶
func (n *NextEpochDescriptor) Encode() []byte
Encode returns the SCALE encoding of the NextEpochDescriptor.
type NextEpochDescriptorRaw ¶
type NextEpochDescriptorRaw struct {
Authorities []*types.AuthorityDataRaw
Randomness [RandomnessLength]byte
}
NextEpochDescriptorRaw contains information about the next epoch.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session contains the VRF keys for the validator, as well as BABE configuation data
func NewSession ¶
func NewSession(cfg *SessionConfig) (*Session, error)
NewSession returns a new Babe session using the provided VRF keys and runtime
func (*Session) AuthorityData ¶
func (b *Session) AuthorityData() []*types.AuthorityData
AuthorityData returns the data related to the authority
func (*Session) BuildBlock ¶
BuildBlock builds a block for the slot with the given parent. TODO: separate block builder logic into separate module. The only reason this is exported is so other packages can build blocks for testing, but it would be preferred to have the builder functionality separated.
func (*Session) Descriptor ¶
func (b *Session) Descriptor() *NextEpochDescriptor
Descriptor returns the NextEpochDescriptor for the current session.
func (*Session) SetEpochData ¶
func (b *Session) SetEpochData(data *NextEpochDescriptor) error
SetEpochData will set the authorityData and randomness
type SessionConfig ¶
type SessionConfig struct {
BlockState BlockState
StorageState StorageState
TransactionQueue TransactionQueue
Keypair *sr25519.Keypair
Runtime *runtime.Runtime
NewBlocks chan<- types.Block
AuthData []*types.AuthorityData
EpochThreshold *big.Int // should only be used for testing
StartSlot uint64 // slot to begin session at
EpochDone *sync.WaitGroup
Kill <-chan struct{}
SyncLock *sync.Mutex
}
SessionConfig struct
type Slot ¶
type Slot struct {
// contains filtered or unexported fields
}
Slot represents a BABE slot
type StorageState ¶
StorageState interface for storage state methods
type TransactionQueue ¶
type TransactionQueue interface {
Push(vt *transaction.ValidTransaction) (common.Hash, error)
Pop() *transaction.ValidTransaction
Peek() *transaction.ValidTransaction
}
TransactionQueue is the interface for transaction queue methods
type VerificationManager ¶
type VerificationManager struct {
// contains filtered or unexported fields
}
VerificationManager assists the syncer in keeping track of what epoch is it currently syncing and verifying, as well as keeping track of the NextEpochDesciptor which is required to create a Verifier for an epoch.
func NewVerificationManager ¶
func NewVerificationManager(blockState BlockState, currentEpoch uint64, currentDescriptor *NextEpochDescriptor) (*VerificationManager, error)
NewVerificationManager returns a new VerificationManager
func (*VerificationManager) EpochNumber ¶
func (v *VerificationManager) EpochNumber() uint64
EpochNumber returns the current epoch number
func (*VerificationManager) IncrementEpoch ¶
func (v *VerificationManager) IncrementEpoch() (*NextEpochDescriptor, error)
IncrementEpoch sets the NextEpochDescriptor for the current epoch and returns it. It also increments the epoch number.
func (*VerificationManager) VerifyBlock ¶
func (v *VerificationManager) VerifyBlock(header *types.Header) (bool, error)
VerifyBlock verifies the given header with verifyAuthorshipRight. It also checks for a NextEpochDescriptor for the current epoch.
type VrfOutputAndProof ¶
type VrfOutputAndProof struct {
// contains filtered or unexported fields
}
VrfOutputAndProof represents the fields for VRF output and proof