liskbft

package
v0.0.0-...-77dcbbd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package liskbft implements state transition logics for BFT protocol following LIP-0056 and LIP-0058.

Index

Constants

View Source
const (
	ModuleID uint32 = 11
)

Variables

View Source
var (
	ErrBFTParamsNotFound     = errors.New("bFT parameters does not exist")
	ErrGeneratorKeysNotFound = errors.New("generator keys does not exist")
)

Functions

func GetBFTValidatorAndGenerators

func GetBFTValidatorAndGenerators(validators labi.Validators) (BFTValidators, Generators)

func GetLabiValidators

func GetLabiValidators(validators BFTValidators, generators Generators) labi.Validators

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func (*API) AreHeadersContradicting

func (a *API) AreHeadersContradicting(header1, header2 blockchain.SealedBlockHeader) (bool, error)

func (*API) ExistBFTParameters

func (a *API) ExistBFTParameters(diffStore *diffdb.Database, height uint32) (bool, error)

func (*API) GetBFTHeights

func (a *API) GetBFTHeights(diffStore *diffdb.Database) (uint32, uint32, uint32, error)

func (*API) GetBFTParameters

func (a *API) GetBFTParameters(diffStore *diffdb.Database, height uint32) (*BFTParams, error)

func (*API) GetCurrentValidators

func (a *API) GetCurrentValidators(context *diffdb.Database) (BFTValidators, error)

func (*API) GetGeneratorKeys

func (a *API) GetGeneratorKeys(diffStore *diffdb.Database, height uint32) (Generators, error)

func (*API) GetValidator

func (a *API) GetValidator(context *diffdb.Database, address codec.Lisk32, height uint32) (*BFTValidator, error)

func (*API) HeaderHasPriority

func (a *API) HeaderHasPriority(diffStore *diffdb.Database, header blockchain.SealedBlockHeader, height, maxHeightPrevoted, maxHeightPreviouslyForged uint32) (bool, error)

func (*API) ImpliesMaximalPrevotes

func (a *API) ImpliesMaximalPrevotes(context *diffdb.Database, blockHeader blockchain.ReadableBlockHeader) (bool, error)

func (*API) IsHeaderContradictingChain

func (a *API) IsHeaderContradictingChain(context *diffdb.Database, header blockchain.SealedBlockHeader) (bool, error)

func (*API) NextHeightBFTParameters

func (a *API) NextHeightBFTParameters(context *diffdb.Database, height uint32) (uint32, error)

func (*API) SetBFTParameters

func (a *API) SetBFTParameters(
	diffStore *diffdb.Database,
	precommitThreshold, certificateThreshold uint64,
	validators BFTValidators,
) error

func (*API) SetGeneratorKeys

func (a *API) SetGeneratorKeys(diffStore *diffdb.Database, generators Generators) error

type ActiveValidator

type ActiveValidator struct {
	// contains filtered or unexported fields
}

ActiveValidator holds information for a particular concenter.

func (*ActiveValidator) Decode

func (e *ActiveValidator) Decode(data []byte) error

func (*ActiveValidator) DecodeFromReader

func (e *ActiveValidator) DecodeFromReader(reader *codec.Reader) error

func (*ActiveValidator) DecodeStrict

func (e *ActiveValidator) DecodeStrict(data []byte) error

func (*ActiveValidator) DecodeStrictFromReader

func (e *ActiveValidator) DecodeStrictFromReader(reader *codec.Reader) error

func (*ActiveValidator) Encode

func (e *ActiveValidator) Encode() []byte

func (*ActiveValidator) MustDecode

func (e *ActiveValidator) MustDecode(data []byte)

type ActiveValidators

type ActiveValidators []*ActiveValidator

type BFTBlockHeader

type BFTBlockHeader struct {
	// contains filtered or unexported fields
}

func (*BFTBlockHeader) Decode

func (e *BFTBlockHeader) Decode(data []byte) error

func (*BFTBlockHeader) DecodeFromReader

func (e *BFTBlockHeader) DecodeFromReader(reader *codec.Reader) error

func (*BFTBlockHeader) DecodeStrict

func (e *BFTBlockHeader) DecodeStrict(data []byte) error

func (*BFTBlockHeader) DecodeStrictFromReader

func (e *BFTBlockHeader) DecodeStrictFromReader(reader *codec.Reader) error

func (*BFTBlockHeader) Encode

func (e *BFTBlockHeader) Encode() []byte

func (*BFTBlockHeader) GeneratorAddress

func (h *BFTBlockHeader) GeneratorAddress() []byte

func (*BFTBlockHeader) Height

func (h *BFTBlockHeader) Height() uint32

func (*BFTBlockHeader) MaxHeightGenerated

func (h *BFTBlockHeader) MaxHeightGenerated() uint32

func (*BFTBlockHeader) MaxHeightPrevoted

func (h *BFTBlockHeader) MaxHeightPrevoted() uint32

func (*BFTBlockHeader) MustDecode

func (e *BFTBlockHeader) MustDecode(data []byte)

type BFTBlockHeaders

type BFTBlockHeaders []*BFTBlockHeader

type BFTParams

type BFTParams struct {
	// contains filtered or unexported fields
}

func (*BFTParams) CertificateThreshold

func (c *BFTParams) CertificateThreshold() uint64

func (*BFTParams) Decode

func (e *BFTParams) Decode(data []byte) error

func (*BFTParams) DecodeFromReader

func (e *BFTParams) DecodeFromReader(reader *codec.Reader) error

func (*BFTParams) DecodeStrict

func (e *BFTParams) DecodeStrict(data []byte) error

func (*BFTParams) DecodeStrictFromReader

func (e *BFTParams) DecodeStrictFromReader(reader *codec.Reader) error

func (*BFTParams) Encode

func (e *BFTParams) Encode() []byte

func (*BFTParams) MustDecode

func (e *BFTParams) MustDecode(data []byte)

func (*BFTParams) PrecommitThreshold

func (c *BFTParams) PrecommitThreshold() uint64

func (*BFTParams) PrevoteThreshold

func (c *BFTParams) PrevoteThreshold() uint64

func (BFTParams) String

func (c BFTParams) String() string

func (*BFTParams) Validators

func (c *BFTParams) Validators() []*BFTValidator

func (*BFTParams) ValidatorsHash

func (c *BFTParams) ValidatorsHash() codec.Hex

type BFTValidator

type BFTValidator struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator(address codec.Lisk32, bftWeight uint64, blsKey codec.Hex) *BFTValidator

func (*BFTValidator) Address

func (v *BFTValidator) Address() codec.Lisk32

func (*BFTValidator) BFTWeight

func (v *BFTValidator) BFTWeight() uint64

func (*BFTValidator) BLSKey

func (v *BFTValidator) BLSKey() codec.Hex

func (*BFTValidator) Decode

func (e *BFTValidator) Decode(data []byte) error

func (*BFTValidator) DecodeFromReader

func (e *BFTValidator) DecodeFromReader(reader *codec.Reader) error

func (*BFTValidator) DecodeStrict

func (e *BFTValidator) DecodeStrict(data []byte) error

func (*BFTValidator) DecodeStrictFromReader

func (e *BFTValidator) DecodeStrictFromReader(reader *codec.Reader) error

func (*BFTValidator) Encode

func (e *BFTValidator) Encode() []byte

func (*BFTValidator) MustDecode

func (e *BFTValidator) MustDecode(data []byte)

type BFTValidators

type BFTValidators []*BFTValidator

func (BFTValidators) Equal

func (vs BFTValidators) Equal(validators BFTValidators) bool

func (BFTValidators) Find

func (vs BFTValidators) Find(address []byte) (*BFTValidator, bool)

func (BFTValidators) Get

func (vs BFTValidators) Get(address []byte) (*BFTValidator, bool)

func (*BFTValidators) Sort

func (vs *BFTValidators) Sort()

type BFTVotes

type BFTVotes struct {
	// contains filtered or unexported fields
}

func (*BFTVotes) Decode

func (e *BFTVotes) Decode(data []byte) error

func (*BFTVotes) DecodeFromReader

func (e *BFTVotes) DecodeFromReader(reader *codec.Reader) error

func (*BFTVotes) DecodeStrict

func (e *BFTVotes) DecodeStrict(data []byte) error

func (*BFTVotes) DecodeStrictFromReader

func (e *BFTVotes) DecodeStrictFromReader(reader *codec.Reader) error

func (*BFTVotes) Encode

func (e *BFTVotes) Encode() []byte

func (*BFTVotes) MustDecode

func (e *BFTVotes) MustDecode(data []byte)

func (BFTVotes) String

func (v BFTVotes) String() string

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

func (*Endpoint) Get

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(address codec.Lisk32, generatorKey codec.Hex) *Generator

func (*Generator) Address

func (g *Generator) Address() codec.Lisk32

func (*Generator) Decode

func (e *Generator) Decode(data []byte) error

func (*Generator) DecodeFromReader

func (e *Generator) DecodeFromReader(reader *codec.Reader) error

func (*Generator) DecodeStrict

func (e *Generator) DecodeStrict(data []byte) error

func (*Generator) DecodeStrictFromReader

func (e *Generator) DecodeStrictFromReader(reader *codec.Reader) error

func (*Generator) Encode

func (e *Generator) Encode() []byte

func (*Generator) GeneratorKey

func (g *Generator) GeneratorKey() codec.Hex

func (*Generator) MustDecode

func (e *Generator) MustDecode(data []byte)

type GeneratorKeys

type GeneratorKeys struct {
	Generators []*Generator `fieldNumber:"1"`
}

func (*GeneratorKeys) Decode

func (e *GeneratorKeys) Decode(data []byte) error

func (*GeneratorKeys) DecodeFromReader

func (e *GeneratorKeys) DecodeFromReader(reader *codec.Reader) error

func (*GeneratorKeys) DecodeStrict

func (e *GeneratorKeys) DecodeStrict(data []byte) error

func (*GeneratorKeys) DecodeStrictFromReader

func (e *GeneratorKeys) DecodeStrictFromReader(reader *codec.Reader) error

func (*GeneratorKeys) Encode

func (e *GeneratorKeys) Encode() []byte

func (*GeneratorKeys) MustDecode

func (e *GeneratorKeys) MustDecode(data []byte)

type Generators

type Generators []*Generator

func (Generators) AtTimestamp

func (vs Generators) AtTimestamp(slot SlotNumberGetter, timestamp uint32) (*Generator, error)

type GetValidatorInfoResponse

type GetValidatorInfoResponse struct {
	MaxHeightPrevoted uint32 `json:"maxHeightPrevoted" fieldNumber:"1"`
}

func (*GetValidatorInfoResponse) Decode

func (e *GetValidatorInfoResponse) Decode(data []byte) error

func (*GetValidatorInfoResponse) DecodeFromReader

func (e *GetValidatorInfoResponse) DecodeFromReader(reader *codec.Reader) error

func (*GetValidatorInfoResponse) DecodeStrict

func (e *GetValidatorInfoResponse) DecodeStrict(data []byte) error

func (*GetValidatorInfoResponse) DecodeStrictFromReader

func (e *GetValidatorInfoResponse) DecodeStrictFromReader(reader *codec.Reader) error

func (*GetValidatorInfoResponse) Encode

func (e *GetValidatorInfoResponse) Encode() []byte

func (*GetValidatorInfoResponse) MustDecode

func (e *GetValidatorInfoResponse) MustDecode(data []byte)

type HashValidator

type HashValidator struct {
	BLSKey    []byte `fieldNumber:"1"`
	BFTWeight uint64 `fieldNumber:"2"`
}

func (*HashValidator) Decode

func (e *HashValidator) Decode(data []byte) error

func (*HashValidator) DecodeFromReader

func (e *HashValidator) DecodeFromReader(reader *codec.Reader) error

func (*HashValidator) DecodeStrict

func (e *HashValidator) DecodeStrict(data []byte) error

func (*HashValidator) DecodeStrictFromReader

func (e *HashValidator) DecodeStrictFromReader(reader *codec.Reader) error

func (*HashValidator) Encode

func (e *HashValidator) Encode() []byte

func (*HashValidator) MustDecode

func (e *HashValidator) MustDecode(data []byte)

type HashValidators

type HashValidators []*HashValidator

type HashingValidators

type HashingValidators struct {
	ActiveValidators     []*HashValidator `fieldNumber:"1"`
	CertificateThreshold uint64           `fieldNumber:"2"`
}

func (*HashingValidators) Decode

func (e *HashingValidators) Decode(data []byte) error

func (*HashingValidators) DecodeFromReader

func (e *HashingValidators) DecodeFromReader(reader *codec.Reader) error

func (*HashingValidators) DecodeStrict

func (e *HashingValidators) DecodeStrict(data []byte) error

func (*HashingValidators) DecodeStrictFromReader

func (e *HashingValidators) DecodeStrictFromReader(reader *codec.Reader) error

func (*HashingValidators) Encode

func (e *HashingValidators) Encode() []byte

func (*HashingValidators) MustDecode

func (e *HashingValidators) MustDecode(data []byte)

type IsBFTComplientRequest

type IsBFTComplientRequest struct {
	GeneratorPublicKey codec.Hex `json:"generatorPublicKey" fieldNumber:"1"`
	Height             uint32    `json:"height" fieldNumber:"2"`
	MaxHeightGenerated uint32    `json:"maxHeightPreviouslyForged" fieldNumber:"3"`
	MaxHeightPrevoted  uint32    `json:"maxHeightPrevoted" fieldNumber:"4"`
}

func (*IsBFTComplientRequest) Decode

func (e *IsBFTComplientRequest) Decode(data []byte) error

func (*IsBFTComplientRequest) DecodeFromReader

func (e *IsBFTComplientRequest) DecodeFromReader(reader *codec.Reader) error

func (*IsBFTComplientRequest) DecodeStrict

func (e *IsBFTComplientRequest) DecodeStrict(data []byte) error

func (*IsBFTComplientRequest) DecodeStrictFromReader

func (e *IsBFTComplientRequest) DecodeStrictFromReader(reader *codec.Reader) error

func (*IsBFTComplientRequest) Encode

func (e *IsBFTComplientRequest) Encode() []byte

func (*IsBFTComplientRequest) MustDecode

func (e *IsBFTComplientRequest) MustDecode(data []byte)

type IsBFTComplientResponse

type IsBFTComplientResponse struct {
	Valid bool `json:"valid" fieldNumber:"1"`
}

func (*IsBFTComplientResponse) Decode

func (e *IsBFTComplientResponse) Decode(data []byte) error

func (*IsBFTComplientResponse) DecodeFromReader

func (e *IsBFTComplientResponse) DecodeFromReader(reader *codec.Reader) error

func (*IsBFTComplientResponse) DecodeStrict

func (e *IsBFTComplientResponse) DecodeStrict(data []byte) error

func (*IsBFTComplientResponse) DecodeStrictFromReader

func (e *IsBFTComplientResponse) DecodeStrictFromReader(reader *codec.Reader) error

func (*IsBFTComplientResponse) Encode

func (e *IsBFTComplientResponse) Encode() []byte

func (*IsBFTComplientResponse) MustDecode

func (e *IsBFTComplientResponse) MustDecode(data []byte)

type KV

type KV struct {
	// contains filtered or unexported fields
}

func (*KV) Key

func (k *KV) Key() []byte

func (*KV) Value

func (k *KV) Value() []byte

type Module

type Module struct {
	// contains filtered or unexported fields
}

func NewModule

func NewModule() *Module

func (*Module) API

func (m *Module) API() *API

func (*Module) BeforeTransactionsExecute

func (m *Module) BeforeTransactionsExecute(blockHeader blockchain.ReadableBlockHeader, diffStore *diffdb.Database) error

AfterBlockApply applies BFT properties.

func (*Module) Endpoint

func (m *Module) Endpoint() statemachine.Endpoint

func (*Module) ID

func (m *Module) ID() uint32

Properties to satisfy state machine module.

func (*Module) Init

func (m *Module) Init(batchSize int) error

func (*Module) InitGenesisState

func (m *Module) InitGenesisState(blockHeader blockchain.SealedBlockHeader, diffStore *diffdb.Database) error

func (*Module) Name

func (m *Module) Name() string

type ModuleConfig

type ModuleConfig struct {
	BatchSize int `json:"batchSize"`
}

type SlotNumberGetter

type SlotNumberGetter interface {
	GetSlotNumber(unixTime uint32) int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳