model

package
v0.26.9 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: AGPL-3.0 Imports: 7 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnverifiableBlock = errors.New("block proposal can't be verified, because its view is above the finalized view, but its QC is below the finalized view")
	ErrInvalidSignature  = errors.New("invalid signature")
)

Functions

func IsConfigurationError added in v0.23.9

func IsConfigurationError(err error) bool

IsConfigurationError returns whether err is a ConfigurationError

func IsDoubleVoteError added in v0.23.9

func IsDoubleVoteError(err error) bool

IsDoubleVoteError returns whether an error is DoubleVoteError

func IsDuplicatedSignerError added in v0.23.9

func IsDuplicatedSignerError(err error) bool

IsDuplicatedSignerError returns whether err is an DuplicatedSignerError

func IsInsufficientSignaturesError added in v0.23.9

func IsInsufficientSignaturesError(err error) bool

IsInsufficientSignaturesError returns whether err is an InsufficientSignaturesError

func IsInvalidBlockError

func IsInvalidBlockError(err error) bool

IsInvalidBlockError returns whether an error is InvalidBlockError

func IsInvalidFormatError added in v0.26.1

func IsInvalidFormatError(err error) bool

IsInvalidFormatError returns whether err is a InvalidFormatError

func IsInvalidSignatureIncludedError added in v0.23.9

func IsInvalidSignatureIncludedError(err error) bool

IsInvalidSignatureIncludedError returns whether err is an InvalidSignatureIncludedError

func IsInvalidSignerError added in v0.23.9

func IsInvalidSignerError(err error) bool

IsInvalidSignerError returns whether err is an InvalidSignerError

func IsInvalidVoteError

func IsInvalidVoteError(err error) bool

IsInvalidVoteError returns whether an error is InvalidVoteError

func IsMissingBlockError

func IsMissingBlockError(err error) bool

IsMissingBlockError returns whether an error is MissingBlockError

func IsNoVoteError

func IsNoVoteError(err error) bool

IsNoVoteError returns whether an error is NoVoteError

func NewConfigurationError added in v0.23.9

func NewConfigurationError(err error) error

func NewConfigurationErrorf added in v0.23.9

func NewConfigurationErrorf(msg string, args ...interface{}) error

func NewDoubleVoteErrorf added in v0.23.9

func NewDoubleVoteErrorf(firstVote, conflictingVote *Vote, msg string, args ...interface{}) error

func NewDuplicatedSignerError added in v0.23.9

func NewDuplicatedSignerError(err error) error

func NewDuplicatedSignerErrorf added in v0.23.9

func NewDuplicatedSignerErrorf(msg string, args ...interface{}) error

func NewInsufficientSignaturesError added in v0.23.9

func NewInsufficientSignaturesError(err error) error

func NewInsufficientSignaturesErrorf added in v0.23.9

func NewInsufficientSignaturesErrorf(msg string, args ...interface{}) error

func NewInvalidFormatError added in v0.26.1

func NewInvalidFormatError(err error) error

func NewInvalidFormatErrorf added in v0.26.1

func NewInvalidFormatErrorf(msg string, args ...interface{}) error

func NewInvalidSignatureIncludedError added in v0.23.9

func NewInvalidSignatureIncludedError(err error) error

func NewInvalidSignatureIncludedErrorf added in v0.23.9

func NewInvalidSignatureIncludedErrorf(msg string, args ...interface{}) error

func NewInvalidSignerError added in v0.23.9

func NewInvalidSignerError(err error) error

func NewInvalidSignerErrorf added in v0.23.9

func NewInvalidSignerErrorf(msg string, args ...interface{}) error

func NewInvalidVoteErrorf added in v0.23.9

func NewInvalidVoteErrorf(vote *Vote, msg string, args ...interface{}) error

func ProposalToFlow

func ProposalToFlow(proposal *Proposal) *flow.Header

ProposalToFlow turns a block proposal into a flow header.

func UnpackRandomBeaconSig added in v0.26.1

func UnpackRandomBeaconSig(sigData []byte) (crypto.Signature, error)

UnpackRandomBeaconSig takes sigData previously packed by packer, decodes it and extracts random beacon signature

Types

type Block

type Block struct {
	View        uint64
	BlockID     flow.Identifier
	ProposerID  flow.Identifier
	QC          *flow.QuorumCertificate
	PayloadHash flow.Identifier
	Timestamp   time.Time
}

Block is the HotStuff algorithm's concept of a block, which - in the bigger picture - corresponds to the block header.

func BlockFromFlow

func BlockFromFlow(header *flow.Header, parentView uint64) *Block

BlockFromFlow converts a flow header to a hotstuff block.

func GenesisBlockFromFlow

func GenesisBlockFromFlow(header *flow.Header) *Block

GenesisBlockFromFlow returns a HotStuff block model representing a genesis block based on the given header.

type ByzantineThresholdExceededError

type ByzantineThresholdExceededError struct {
	Evidence string
}

ByzantineThresholdExceededError is raised if HotStuff detects malicious conditions which prove a Byzantine threshold of consensus replicas has been exceeded. Per definition, the byzantine threshold is exceeded if there are byzantine consensus replicas with _at least_ 1/3 weight.

func (ByzantineThresholdExceededError) Error

type ConfigurationError

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

ConfigurationError indicates that a constructor or component was initialized with invalid or inconsistent parameters.

func (ConfigurationError) Error

func (e ConfigurationError) Error() string

func (ConfigurationError) Unwrap added in v0.23.9

func (e ConfigurationError) Unwrap() error

type DoubleVoteError added in v0.23.9

type DoubleVoteError struct {
	FirstVote       *Vote
	ConflictingVote *Vote
	// contains filtered or unexported fields
}

DoubleVoteError indicates that a consensus replica has voted for two different blocks, or has provided two semantically different votes for the same block.

func AsDoubleVoteError added in v0.23.9

func AsDoubleVoteError(err error) (*DoubleVoteError, bool)

AsDoubleVoteError determines whether the given error is a DoubleVoteError (potentially wrapped). It follows the same semantics as a checked type cast.

func (DoubleVoteError) Error added in v0.23.9

func (e DoubleVoteError) Error() string

func (DoubleVoteError) Unwrap added in v0.23.9

func (e DoubleVoteError) Unwrap() error

type DuplicatedSignerError added in v0.23.9

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

DuplicatedSignerError indicates that a signature from the same node ID has already been added

func (DuplicatedSignerError) Error added in v0.23.9

func (e DuplicatedSignerError) Error() string

func (DuplicatedSignerError) Unwrap added in v0.23.9

func (e DuplicatedSignerError) Unwrap() error

type InsufficientSignaturesError added in v0.23.9

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

InsufficientSignaturesError indicates that not enough signatures have been stored to complete the operation.

func (InsufficientSignaturesError) Error added in v0.23.9

func (InsufficientSignaturesError) Unwrap added in v0.23.9

type InvalidBlockError

type InvalidBlockError struct {
	BlockID flow.Identifier
	View    uint64
	Err     error
}

InvalidBlockError indicates that the block with identifier `BlockID` is invalid

func (InvalidBlockError) Error

func (e InvalidBlockError) Error() string

func (InvalidBlockError) Unwrap

func (e InvalidBlockError) Unwrap() error

type InvalidFormatError added in v0.26.1

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

InvalidFormatError indicates that some data has an incompatible format.

func (InvalidFormatError) Error added in v0.26.1

func (e InvalidFormatError) Error() string

func (InvalidFormatError) Unwrap added in v0.26.1

func (e InvalidFormatError) Unwrap() error

type InvalidSignatureIncludedError added in v0.23.9

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

InvalidSignatureIncludedError indicates that some signatures, included via TrustedAdd, are invalid

func (InvalidSignatureIncludedError) Error added in v0.23.9

func (InvalidSignatureIncludedError) Unwrap added in v0.23.9

type InvalidSignerError added in v0.23.9

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

InvalidSignerError indicates that the signer is not authorized or unknown

func (InvalidSignerError) Error added in v0.23.9

func (e InvalidSignerError) Error() string

func (InvalidSignerError) Unwrap added in v0.23.9

func (e InvalidSignerError) Unwrap() error

type InvalidVoteError

type InvalidVoteError struct {
	VoteID flow.Identifier
	View   uint64
	Err    error
}

InvalidVoteError indicates that the vote with identifier `VoteID` is invalid

func (InvalidVoteError) Error

func (e InvalidVoteError) Error() string

func (InvalidVoteError) Unwrap

func (e InvalidVoteError) Unwrap() error

type MissingBlockError

type MissingBlockError struct {
	View    uint64
	BlockID flow.Identifier
}

MissingBlockError indicates that no block with identifier `BlockID` is known

func (MissingBlockError) Error

func (e MissingBlockError) Error() string

type NewViewEvent

type NewViewEvent struct {
	View uint64
}

NewViewEvent is the new view event that contains the new view.

type NoVoteError

type NoVoteError struct {
	Msg string
}

NoVoteError contains the reason of why the voter didn't vote for a block proposal.

func (NoVoteError) Error

func (e NoVoteError) Error() string

type Proposal

type Proposal struct {
	Block   *Block
	SigData []byte
}

Proposal represent a new proposed block within HotStuff (and thus a a header in the bigger picture), signed by the proposer.

func ProposalFromFlow

func ProposalFromFlow(header *flow.Header, parentView uint64) *Proposal

ProposalFromFlow turns a flow header into a hotstuff block type.

func (*Proposal) ProposerVote

func (p *Proposal) ProposerVote() *Vote

ProposerVote extracts the proposer vote from the proposal

type SigDataPacker added in v0.26.1

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

SigDataPacker implements logic for encoding/decoding SignatureData using RLP encoding.

func (*SigDataPacker) Decode added in v0.26.1

func (p *SigDataPacker) Decode(data []byte) (*SignatureData, error)

Decode performs decoding of SignatureData

func (*SigDataPacker) Encode added in v0.26.1

func (p *SigDataPacker) Encode(sigData *SignatureData) ([]byte, error)

Encode performs encoding of SignatureData

type SignatureData added in v0.26.1

type SignatureData struct {
	// bit-vector indicating type of signature for each signer.
	// the order of each sig type matches the order of corresponding signer IDs
	SigType []byte

	AggregatedStakingSig         []byte
	AggregatedRandomBeaconSig    []byte
	ReconstructedRandomBeaconSig crypto.Signature
}

SignatureData is a compact data type for encoding the block signature data

type TimeoutMode

type TimeoutMode int

TimeoutMode enum type

const (
	// ReplicaTimeout represents the time period that the replica is waiting for the block for the current view.
	ReplicaTimeout TimeoutMode = iota
	// VoteCollectionTimeout represents the time period that the leader is waiting for votes in order to build
	// the next block.
	VoteCollectionTimeout
)

func (TimeoutMode) String

func (m TimeoutMode) String() string

type TimerInfo

type TimerInfo struct {
	Mode      TimeoutMode
	View      uint64
	StartTime time.Time
	Duration  time.Duration
}

TimerInfo represents a time period that pacemaker is waiting for a specific event. The end of the time period is the timeout that will trigger pacemaker's view change.

type Vote

type Vote struct {
	View     uint64
	BlockID  flow.Identifier
	SignerID flow.Identifier
	SigData  []byte
}

Vote is the HotStuff algorithm's concept of a vote for a block proposal.

func VoteFromFlow

func VoteFromFlow(signerID flow.Identifier, blockID flow.Identifier, view uint64, sig crypto.Signature) *Vote

VoteFromFlow turns the vote parameters into a vote struct.

func (*Vote) ID

func (uv *Vote) ID() flow.Identifier

ID returns the identifier for the vote.

Jump to

Keyboard shortcuts

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