core

package
v0.0.0-...-bc2f5d5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(val interface{}) ([]byte, error)

func GetAggregatedEpochValidatorSetSeal

func GetAggregatedEpochValidatorSetSeal(seals MessageSet) (types.IstanbulEpochValidatorSetSeal, error)

GetAggregatedEpochValidatorSetSeal aggregates all the given seals for the SNARK-friendly epoch encoding to a bls aggregated signature

func GetAggregatedSeal

func GetAggregatedSeal(seals MessageSet, round *big.Int) (types.IstanbulAggregatedSeal, error)

GetAggregatedSeal aggregates all the given seals for a given message set to a bls aggregated signature and bitmap

func PrepareCommittedSeal

func PrepareCommittedSeal(hash common.Hash, round *big.Int) []byte

PrepareCommittedSeal returns a committed seal for the given hash and round number.

func UnionOfSeals

func UnionOfSeals(aggregatedSignature types.IstanbulAggregatedSeal, seals MessageSet) (types.IstanbulAggregatedSeal, error)

UnionOfSeals combines a BLS aggregated signature with an array of signatures. Accounts for double aggregating the same signature by only adding aggregating if the validator was not found in the previous bitmap. This function assumes that the provided seals' validator set is the same one which produced the provided bitmap

Types

type Engine

type Engine interface {
	Start() error
	Stop() error
	// CurrentView returns the current view or nil if none
	CurrentView() *istanbul.View
	// CurrentRoundState returns the current roundState or nil if none
	CurrentRoundState() RoundState
	SetAddress(common.Address)
	// Validator -> CommittedSeal from Parent Block
	ParentCommits() MessageSet
	// ForceRoundChange will force round change to the current desiredRound + 1
	ForceRoundChange()
}

func New

func New(backend istanbul.Backend, config *istanbul.Config) Engine

New creates an Istanbul consensus core

type MessageSet

type MessageSet interface {
	fmt.Stringer
	Add(msg *istanbul.Message) error
	GetAddressIndex(addr common.Address) (uint64, error)
	Remove(address common.Address)
	Values() (result []*istanbul.Message)
	Size() int
	Get(addr common.Address) *istanbul.Message
	Addresses() []common.Address
	Serialize() ([]byte, error)
}

type MsgBacklog

type MsgBacklog interface {
	// contains filtered or unexported methods
}

MsgBacklog represent a backlog of future messages It works by:

  • allowing storing messages with "store()"
  • call eventListener when a backlog message becomes "present"
  • updates its notion of time/state with updateState()

type RoundState

type RoundState interface {
	// mutation functions
	StartNewRound(nextRound *big.Int, validatorSet istanbul.ValidatorSet, nextProposer istanbul.Validator) error
	StartNewSequence(nextSequence *big.Int, validatorSet istanbul.ValidatorSet, nextProposer istanbul.Validator, parentCommits MessageSet) error
	TransitionToPreprepared(preprepare *istanbul.Preprepare) error
	TransitionToWaitingForNewRound(r *big.Int, nextProposer istanbul.Validator) error
	TransitionToCommitted() error
	TransitionToPrepared(quorumSize int) error
	AddCommit(msg *istanbul.Message) error
	AddPrepare(msg *istanbul.Message) error
	AddParentCommit(msg *istanbul.Message) error
	SetPendingRequest(pendingRequest *istanbul.Request) error
	SetProposalVerificationStatus(proposalHash common.Hash, verificationStatus error)

	// view functions
	DesiredRound() *big.Int
	State() State
	GetPrepareOrCommitSize() int
	GetValidatorByAddress(address common.Address) istanbul.Validator
	ValidatorSet() istanbul.ValidatorSet
	Proposer() istanbul.Validator
	IsProposer(address common.Address) bool
	Subject() *istanbul.Subject
	Preprepare() *istanbul.Preprepare
	Proposal() istanbul.Proposal
	Round() *big.Int
	Commits() MessageSet
	Prepares() MessageSet
	ParentCommits() MessageSet
	PendingRequest() *istanbul.Request
	Sequence() *big.Int
	View() *istanbul.View
	PreparedCertificate() istanbul.PreparedCertificate
	GetProposalVerificationStatus(proposalHash common.Hash) (verificationStatus error, isCached bool)
	Summary() *RoundStateSummary
}

type RoundStateDB

type RoundStateDB interface {
	GetLastView() (*istanbul.View, error)
	// GetOldestValidView returns the oldest valid view that can be stored on the db
	// it might or might not be present on the db
	GetOldestValidView() (*istanbul.View, error)
	GetRoundStateFor(view *istanbul.View) (RoundState, error)
	UpdateLastRoundState(rs RoundState) error
	Close() error
}

type RoundStateDBOptions

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

RoundStateDBOptions are the options for a RoundStateDB instance

type RoundStateSummary

type RoundStateSummary struct {
	State              string       `json:"state"`
	Sequence           *big.Int     `json:"sequence"`
	Round              *big.Int     `json:"round"`
	DesiredRound       *big.Int     `json:"desiredRound"`
	PendingRequestHash *common.Hash `json:"pendingRequestHash"`

	ValidatorSet []common.Address `json:"validatorSet"`
	Proposer     common.Address   `json:"proposer"`

	Prepares      []common.Address `json:"prepares"`
	Commits       []common.Address `json:"commits"`
	ParentCommits []common.Address `json:"parentCommits"`

	Preprepare          *istanbul.PreprepareSummary          `json:"preprepare"`
	PreparedCertificate *istanbul.PreparedCertificateSummary `json:"preparedCertificate"`
}

type State

type State uint64

State represents the IBFT state

const (
	StateAcceptRequest State = iota
	StatePreprepared
	StatePrepared
	StateCommitted
	StateWaitingForNewRound
)

Different IBFT Core States

func (State) Cmp

func (s State) Cmp(y State) int

Cmp compares s and y and returns:

-1 if s is the previous state of y
 0 if s and y are the same state
+1 if s is the next state of y

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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