consensus

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: 24 Imported by: 0

Documentation

Overview

Package consensus implements block execution according to the Lisk BFT protocol following LIP-0055.

Index

Constants

View Source
const (
	EventNetworkBlockNew  = "EventNetworkBlockNew"
	EventBlockNew         = "EventBlockNew"
	EventBlockDelete      = "EventBlockDelete"
	EventBlockFinalize    = "EventBlockFinalize"
	EventChainFork        = "EventChainFork"
	EventValidatorsChange = "EventValidatorsChange"
)
View Source
const (
	P2PEventPostBlock         = "postBlock"
	P2PEventPostSingleCommits = "postSingleCommits"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EventBlockDeleteMessage

type EventBlockDeleteMessage struct {
	Block *blockchain.Block `fieldNumber:"1"`
}

func (*EventBlockDeleteMessage) Decode

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

func (*EventBlockDeleteMessage) DecodeFromReader

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

func (*EventBlockDeleteMessage) DecodeStrict

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

func (*EventBlockDeleteMessage) DecodeStrictFromReader

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

func (*EventBlockDeleteMessage) Encode

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

func (*EventBlockDeleteMessage) MustDecode

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

type EventBlockFinalizeMessage

type EventBlockFinalizeMessage struct {
	Original uint32                  `fieldNumber:"1"`
	Next     uint32                  `fieldNumber:"2"`
	Trigger  *blockchain.BlockHeader `fieldNumber:"3"`
}

func (*EventBlockFinalizeMessage) Decode

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

func (*EventBlockFinalizeMessage) DecodeFromReader

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

func (*EventBlockFinalizeMessage) DecodeStrict

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

func (*EventBlockFinalizeMessage) DecodeStrictFromReader

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

func (*EventBlockFinalizeMessage) Encode

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

func (*EventBlockFinalizeMessage) MustDecode

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

type EventBlockNewMessage

type EventBlockNewMessage struct {
	Block  *blockchain.Block   `fieldNumber:"1"`
	Events []*blockchain.Event `fieldNumber:"2"`
}

func (*EventBlockNewMessage) Decode

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

func (*EventBlockNewMessage) DecodeFromReader

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

func (*EventBlockNewMessage) DecodeStrict

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

func (*EventBlockNewMessage) DecodeStrictFromReader

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

func (*EventBlockNewMessage) Encode

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

func (*EventBlockNewMessage) MustDecode

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

type EventChainForkMessage

type EventChainForkMessage struct {
	Block *blockchain.Block `fieldNumber:"1"`
}

func (*EventChainForkMessage) Decode

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

func (*EventChainForkMessage) DecodeFromReader

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

func (*EventChainForkMessage) DecodeStrict

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

func (*EventChainForkMessage) DecodeStrictFromReader

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

func (*EventChainForkMessage) Encode

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

func (*EventChainForkMessage) MustDecode

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

type EventChangeValidator

type EventChangeValidator struct {
	NextValidators       []*labi.Validator `fieldNumber:"1"`
	PrecommitThreshold   uint64            `fieldNumber:"2"`
	CertificateThreshold uint64            `fieldNumber:"3"`
}

func (*EventChangeValidator) Decode

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

func (*EventChangeValidator) DecodeFromReader

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

func (*EventChangeValidator) DecodeStrict

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

func (*EventChangeValidator) DecodeStrictFromReader

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

func (*EventChangeValidator) Encode

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

func (*EventChangeValidator) MustDecode

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

type EventNetworkBlockNewMessage

type EventNetworkBlockNewMessage struct {
	Block *blockchain.Block `fieldNumber:"1"`
}

func (*EventNetworkBlockNewMessage) Decode

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

func (*EventNetworkBlockNewMessage) DecodeFromReader

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

func (*EventNetworkBlockNewMessage) DecodeStrict

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

func (*EventNetworkBlockNewMessage) DecodeStrictFromReader

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

func (*EventNetworkBlockNewMessage) Encode

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

func (*EventNetworkBlockNewMessage) MustDecode

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

type EventPostBlock

type EventPostBlock struct {
	Block []byte `fieldNumber:"1"`
}

func (*EventPostBlock) Decode

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

func (*EventPostBlock) DecodeFromReader

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

func (*EventPostBlock) DecodeStrict

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

func (*EventPostBlock) DecodeStrictFromReader

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

func (*EventPostBlock) Encode

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

func (*EventPostBlock) MustDecode

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

type EventPostSingleCommits

type EventPostSingleCommits struct {
	SingleCommits []*certificate.SingleCommit `fieldNumber:"1"`
}

func (*EventPostSingleCommits) Decode

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

func (*EventPostSingleCommits) DecodeFromReader

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

func (*EventPostSingleCommits) DecodeStrict

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

func (*EventPostSingleCommits) DecodeStrictFromReader

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

func (*EventPostSingleCommits) Encode

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

func (*EventPostSingleCommits) MustDecode

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

type Executer

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

Executer is main process for processing a block.

func NewExecuter

func NewExecuter(config *ExecuterConfig) *Executer

NewExecuter creates new consensus component.

func (*Executer) AddInternal

func (c *Executer) AddInternal(block *blockchain.Block)

func (*Executer) BFTBeforeTransactionsExecute

func (c *Executer) BFTBeforeTransactionsExecute(blockHeader blockchain.SealedBlockHeader, diffStore *diffdb.Database) error

func (*Executer) Certify

func (c *Executer) Certify(from, to uint32, address codec.Lisk32, blsPrivateKey []byte) error

func (*Executer) GetAggregateCommit

func (c *Executer) GetAggregateCommit() (*blockchain.AggregateCommit, error)

func (*Executer) GetBFTHeights

func (c *Executer) GetBFTHeights(diffStore *diffdb.Database) (uint32, uint32, uint32, error)

func (*Executer) GetBFTParameters

func (c *Executer) GetBFTParameters(diffStore *diffdb.Database, height uint32) (*liskbft.BFTParams, error)

func (*Executer) GetGeneratorKeys

func (c *Executer) GetGeneratorKeys(diffStore *diffdb.Database, height uint32) (liskbft.Generators, error)

func (*Executer) GetSlotNumber

func (c *Executer) GetSlotNumber(unixTime uint32) int

func (*Executer) GetSlotTime

func (c *Executer) GetSlotTime(slot int) uint32

func (*Executer) HeaderHasPriority

func (c *Executer) HeaderHasPriority(context *diffdb.Database, header blockchain.SealedBlockHeader, height, maxHeightPrevoted, maxHeightGenerated uint32) (bool, error)

func (*Executer) ImpliesMaximalPrevotes

func (c *Executer) ImpliesMaximalPrevotes(context *diffdb.Database, blockHeader blockchain.ReadableBlockHeader) (bool, error)

func (*Executer) Init

func (c *Executer) Init(param *ExecuterInitParam) error

Init consensus process.

func (*Executer) Start

func (c *Executer) Start() error

Start consensus process.

func (*Executer) Stop

func (c *Executer) Stop() error

Stop consensus process.

func (*Executer) Subscribe

func (c *Executer) Subscribe(topic string) <-chan interface{}

func (*Executer) Synced

func (c *Executer) Synced(height, maxHeightPrevoted, maxHeightPreviouslyForged uint32) (bool, error)

func (*Executer) Syncing

func (c *Executer) Syncing() bool

Syncing is getter for syncing status.

type ExecuterConfig

type ExecuterConfig struct {
	CTX       context.Context
	ABI       labi.ABI
	Chain     *blockchain.Chain
	Conn      *p2p.Connection
	BlockTime uint32
	BatchSize int
}

ExecuterConfig holds config for consensus.

type ExecuterInitParam

type ExecuterInitParam struct {
	CTX          context.Context
	Logger       log.Logger
	Database     *db.DB
	GenesisBlock *blockchain.Block
}

type NextValidatorParams

type NextValidatorParams struct {
	NextValidators       []*labi.Validator `fieldNumber:"1"`
	PrecommitThreshold   uint64            `fieldNumber:"2"`
	CertificateThreshold uint64            `fieldNumber:"3"`
}

func (*NextValidatorParams) Decode

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

func (*NextValidatorParams) DecodeFromReader

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

func (*NextValidatorParams) DecodeStrict

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

func (*NextValidatorParams) DecodeStrictFromReader

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

func (*NextValidatorParams) Encode

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

func (*NextValidatorParams) MustDecode

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

type ProcessContext

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

ProcessContext holds context for processing a block.

type ValidatorWithBLSKey

type ValidatorWithBLSKey struct {
	Address   []byte
	BFTWeight uint64
	BLSKey    []byte
}

type ValidatorsHash

type ValidatorsHash struct {
	Keys                 [][]byte `fieldNumber:"1"`
	Weights              []uint64 `fieldNumber:"2"`
	CertificateThreshold uint64   `fieldNumber:"3"`
}

func (*ValidatorsHash) Decode

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

func (*ValidatorsHash) DecodeFromReader

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

func (*ValidatorsHash) DecodeStrict

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

func (*ValidatorsHash) DecodeStrictFromReader

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

func (*ValidatorsHash) Encode

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

func (*ValidatorsHash) MustDecode

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

type ValidatorsWithBLSKey

type ValidatorsWithBLSKey []*ValidatorWithBLSKey

Directories

Path Synopsis
Package certificate implements block certificate generation protocol following [LIP-0061].
Package certificate implements block certificate generation protocol following [LIP-0061].
Package contradiction package provides functions to determin contradiction between 2 block headers as defined in [LIP-0014].
Package contradiction package provides functions to determin contradiction between 2 block headers as defined in [LIP-0014].
Package forkchoice implements block comparison logic for the fork choice mechanism as defined in [LIP-0014].
Package forkchoice implements block comparison logic for the fork choice mechanism as defined in [LIP-0014].
Package liskbft implements state transition logics for BFT protocol following [LIP-0056] and [LIP-0058].
Package liskbft implements state transition logics for BFT protocol following [LIP-0056] and [LIP-0058].
Package sync provides block synchronization mechanism following the BFT protocol.
Package sync provides block synchronization mechanism following the BFT protocol.
Package validator implements utility functions regarding BFT validators.
Package validator implements utility functions regarding BFT validators.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL