badger

package
v0.14.0-fixing-sealing... Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: AGPL-3.0 Imports: 20 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBootstrapped added in v0.14.0

func IsBootstrapped(db *badger.DB) (bool, error)

IsBootstrapped returns whether or not the database contains a bootstrapped state

func OpenState added in v0.14.0

func OpenState(
	metrics module.ComplianceMetrics,
	db *badger.DB,
	headers storage.Headers,
	seals storage.Seals,
	blocks storage.Blocks,
	setups storage.EpochSetups,
	commits storage.EpochCommits,
	statuses storage.EpochStatuses,
) (*State, *StateRoot, error)

Types

type Cluster

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

Cluster implements interface protocol.Cluster It is a container with all information about a specific cluster.

func (Cluster) ChainID

func (c Cluster) ChainID() flow.ChainID

func (Cluster) EpochCounter

func (c Cluster) EpochCounter() uint64

func (Cluster) Index

func (c Cluster) Index() uint

func (Cluster) Members

func (c Cluster) Members() flow.IdentityList

func (Cluster) RootBlock

func (c Cluster) RootBlock() *cluster.Block

func (Cluster) RootQC

func (c Cluster) RootQC() *flow.QuorumCertificate

type CommittedEpoch

type CommittedEpoch struct {
	SetupEpoch
	// contains filtered or unexported fields
}

CommittedEpoch represents an epoch that has been committed. Both the EpochSetup and EpochCommitted events for the epoch have been emitted as of the point at which the epoch was queried.

func NewCommittedEpoch

func NewCommittedEpoch(setupEvent *flow.EpochSetup, commitEvent *flow.EpochCommit) *CommittedEpoch

func (*CommittedEpoch) Cluster

func (es *CommittedEpoch) Cluster(index uint) (protocol.Cluster, error)

func (*CommittedEpoch) DKG

func (es *CommittedEpoch) DKG() (protocol.DKG, error)

type Config

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

func DefaultConfig

func DefaultConfig() Config

type DKG

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

func (*DKG) GroupKey

func (d *DKG) GroupKey() crypto.PublicKey

func (*DKG) Index

func (d *DKG) Index(nodeID flow.Identifier) (uint, error)

func (*DKG) KeyShare

func (d *DKG) KeyShare(nodeID flow.Identifier) (crypto.PublicKey, error)

func (*DKG) Size

func (d *DKG) Size() uint

type EpochQuery

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

EpochQuery encapsulates querying epochs w.r.t. a snapshot.

func (*EpochQuery) Current

func (q *EpochQuery) Current() protocol.Epoch

Current returns the current epoch.

func (*EpochQuery) Next

func (q *EpochQuery) Next() protocol.Epoch

Next returns the next epoch, if it is available.

func (*EpochQuery) Previous added in v0.13.0

func (q *EpochQuery) Previous() protocol.Epoch

Previous returns the previous epoch. During the first epoch after the root block, this returns a sentinel error (since there is no previous epoch). For all other epochs, returns the previous epoch.

type FollowerState added in v0.14.0

type FollowerState struct {
	*State
	// contains filtered or unexported fields
}

FollowerState implements a lighter version of a mutable protocol state. When extending the state, it performs hardly any checks on the block payload. Instead, the FollowerState relies on the consensus nodes to run the full payload check. Consequently, a block B should only be considered valid, if a child block with a valid header is known. The child block's header includes quorum certificate, which proves that a supermajority of consensus nodes consider block B a valid. The FollowerState allows non-consensus nodes to execute fork-aware queries against the protocol state, while minimizing the amount of payload checks the non-consensus nodes have to perform.

func NewFollowerState added in v0.14.0

func NewFollowerState(
	state *State,
	index storage.Index,
	payloads storage.Payloads,
	tracer module.Tracer,
	consumer protocol.Consumer,
) (*FollowerState, error)

NewFollowerState initializes a light-weight version of a mutable protocol state. This implementation is suitable only for NON-Consensus nodes.

func (*FollowerState) Extend added in v0.14.0

func (m *FollowerState) Extend(candidate *flow.Block) error

Implementation of header extending for FollowerState, checks header validity with data what is available.

func (*FollowerState) Finalize added in v0.14.0

func (m *FollowerState) Finalize(blockID flow.Identifier) error

func (*FollowerState) MarkValid added in v0.14.0

func (m *FollowerState) MarkValid(blockID flow.Identifier) error

MarkValid marks the block as valid in protocol state, and triggers `BlockProcessable` event to notify that its parent block is processable. why the parent block is processable, not the block itself? because a block having a child block means it has been verified by the majority of consensus participants. Hence, if a block has passed the header validity check, its parent block must have passed both the header validity check and the body validity check. So that consensus followers can skip the block body validity checks and wait for its child to arrive, and if the child passes the header validity check, it means the consensus participants have done a complete check on its parent block, so consensus followers can trust consensus nodes did the right job, and start processing the parent block. NOTE: since a parent can have multiple children, `BlockProcessable` event could be triggered multiple times for the same block. NOTE: BlockProcessable should not be blocking, otherwise, it will block the follower

type InvalidEpoch

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

InvalidEpoch represents an epoch that does not exist. Neither the EpochSetup nor EpochCommitted events for the epoch have been emitted as of the point at which the epoch was queried.

func NewInvalidEpoch

func NewInvalidEpoch(err error) *InvalidEpoch

func (*InvalidEpoch) Cluster

func (u *InvalidEpoch) Cluster(uint) (protocol.Cluster, error)

func (*InvalidEpoch) Clustering

func (u *InvalidEpoch) Clustering() (flow.ClusterList, error)

func (*InvalidEpoch) Counter

func (u *InvalidEpoch) Counter() (uint64, error)

func (*InvalidEpoch) DKG

func (u *InvalidEpoch) DKG() (protocol.DKG, error)

func (*InvalidEpoch) FinalView

func (u *InvalidEpoch) FinalView() (uint64, error)

func (*InvalidEpoch) FirstView added in v0.13.0

func (u *InvalidEpoch) FirstView() (uint64, error)

func (*InvalidEpoch) InitialIdentities

func (u *InvalidEpoch) InitialIdentities() (flow.IdentityList, error)

func (*InvalidEpoch) Seed

func (u *InvalidEpoch) Seed(...uint32) ([]byte, error)

type InvalidEpochQuery

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

InvalidEpochQuery is an epoch query for an invalid snapshot.

func (*InvalidEpochQuery) Current

func (u *InvalidEpochQuery) Current() protocol.Epoch

func (*InvalidEpochQuery) Next

func (u *InvalidEpochQuery) Next() protocol.Epoch

func (*InvalidEpochQuery) Previous added in v0.13.0

func (u *InvalidEpochQuery) Previous() protocol.Epoch

type InvalidSnapshot

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

InvalidSnapshot represents a snapshot referencing an invalid block, or for which an error occurred while resolving the reference block.

func NewInvalidSnapshot

func NewInvalidSnapshot(err error) *InvalidSnapshot

func (*InvalidSnapshot) Commit

func (u *InvalidSnapshot) Commit() (flow.StateCommitment, error)

func (*InvalidSnapshot) Epochs

func (u *InvalidSnapshot) Epochs() protocol.EpochQuery

func (*InvalidSnapshot) Head

func (u *InvalidSnapshot) Head() (*flow.Header, error)

func (*InvalidSnapshot) Identities

func (*InvalidSnapshot) Identity

func (u *InvalidSnapshot) Identity(_ flow.Identifier) (*flow.Identity, error)

func (*InvalidSnapshot) Pending

func (u *InvalidSnapshot) Pending() ([]flow.Identifier, error)

func (*InvalidSnapshot) Phase

func (u *InvalidSnapshot) Phase() (flow.EpochPhase, error)

func (*InvalidSnapshot) Seed

func (u *InvalidSnapshot) Seed(_ ...uint32) ([]byte, error)

type MutableState added in v0.14.0

type MutableState struct {
	*FollowerState
	// contains filtered or unexported fields
}

MutableState implements a mutable protocol state. When extending the state with a new block, it checks the _entire_ block payload.

func NewFullConsensusState added in v0.14.0

func NewFullConsensusState(
	state *State,
	index storage.Index,
	payloads storage.Payloads,
	tracer module.Tracer,
	consumer protocol.Consumer,
	receiptValidator module.ReceiptValidator,
	sealValidator module.SealValidator,
) (*MutableState, error)

NewFullConsensusState initializes a new mutable protocol state backed by a badger database. When extending the state with a new block, it checks the _entire_ block payload. Consensus nodes should use the FullConsensusState, while other node roles can use the lighter FollowerState.

func (*MutableState) Extend added in v0.14.0

func (m *MutableState) Extend(candidate *flow.Block) error

Implementation of block extending for MutableState, checks validity of blocks, seal, receipts, before extending the chain.

type Params

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

func (*Params) ChainID

func (p *Params) ChainID() (flow.ChainID, error)

func (*Params) Root

func (p *Params) Root() (*flow.Header, error)

func (*Params) Seal

func (p *Params) Seal() (*flow.Seal, error)

type SetupEpoch

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

SetupEpoch represents an epoch that has been setup, but not committed. Only the EpochSetup event for the epoch has been emitted as of the point at which the epoch was queried.

func NewSetupEpoch

func NewSetupEpoch(setupEvent *flow.EpochSetup) *SetupEpoch

func (*SetupEpoch) Cluster

func (es *SetupEpoch) Cluster(_ uint) (protocol.Cluster, error)

func (*SetupEpoch) Clustering

func (es *SetupEpoch) Clustering() (flow.ClusterList, error)

func (*SetupEpoch) Counter

func (es *SetupEpoch) Counter() (uint64, error)

func (*SetupEpoch) DKG

func (es *SetupEpoch) DKG() (protocol.DKG, error)

func (*SetupEpoch) FinalView

func (es *SetupEpoch) FinalView() (uint64, error)

func (*SetupEpoch) FirstView added in v0.13.0

func (es *SetupEpoch) FirstView() (uint64, error)

func (*SetupEpoch) InitialIdentities

func (es *SetupEpoch) InitialIdentities() (flow.IdentityList, error)

func (*SetupEpoch) Seed

func (es *SetupEpoch) Seed(indices ...uint32) ([]byte, error)

type Snapshot

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

Snapshot implements the protocol.Snapshot interface. It represents a read-only immutable snapshot of the protocol state at the block it is constructed with. It allows efficient access to data associated directly with blocks at a given state (finalized, sealed), such as the related header, commit, seed or pending children. A block snapshot can lazily convert to an epoch snapshot in order to make data associated directly with epochs accessible through its API.

func NewSnapshot

func NewSnapshot(state *State, blockID flow.Identifier) *Snapshot

func (*Snapshot) Commit

func (s *Snapshot) Commit() (flow.StateCommitment, error)

Commit retrieves the latest execution state commitment at the current block snapshot. This commitment represents the execution state as currently finalized.

func (*Snapshot) Epochs

func (s *Snapshot) Epochs() protocol.EpochQuery

func (*Snapshot) Head

func (s *Snapshot) Head() (*flow.Header, error)

func (*Snapshot) Identities

func (s *Snapshot) Identities(selector flow.IdentityFilter) (flow.IdentityList, error)

func (*Snapshot) Identity

func (s *Snapshot) Identity(nodeID flow.Identifier) (*flow.Identity, error)

func (*Snapshot) Pending

func (s *Snapshot) Pending() ([]flow.Identifier, error)

func (*Snapshot) Phase

func (s *Snapshot) Phase() (flow.EpochPhase, error)

func (*Snapshot) Seed

func (s *Snapshot) Seed(indices ...uint32) ([]byte, error)

Seed returns the random seed at the given indices for the current block snapshot.

type State

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

func Bootstrap added in v0.14.0

func Bootstrap(
	metrics module.ComplianceMetrics,
	db *badger.DB,
	headers storage.Headers,
	seals storage.Seals,
	blocks storage.Blocks,
	setups storage.EpochSetups,
	commits storage.EpochCommits,
	statuses storage.EpochStatuses,
	stateRoot *StateRoot,
) (*State, error)

func (*State) AtBlockID

func (s *State) AtBlockID(blockID flow.Identifier) protocol.Snapshot

func (*State) AtHeight

func (s *State) AtHeight(height uint64) protocol.Snapshot

func (*State) Final

func (s *State) Final() protocol.Snapshot

func (*State) Params

func (s *State) Params() protocol.Params

func (*State) Sealed

func (s *State) Sealed() protocol.Snapshot

type StateRoot added in v0.14.0

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

StateRoot is the root information required to bootstrap the protocol state

func NewStateRoot added in v0.14.0

func NewStateRoot(block *flow.Block, result *flow.ExecutionResult, seal *flow.Seal, epochFirstView uint64) (*StateRoot, error)

func (StateRoot) Block added in v0.14.0

func (s StateRoot) Block() *flow.Block

func (StateRoot) EpochCommitEvent added in v0.14.0

func (s StateRoot) EpochCommitEvent() *flow.EpochCommit

func (StateRoot) EpochSetupEvent added in v0.14.0

func (s StateRoot) EpochSetupEvent() *flow.EpochSetup

func (StateRoot) Result added in v0.14.0

func (s StateRoot) Result() *flow.ExecutionResult

func (StateRoot) Seal added in v0.14.0

func (s StateRoot) Seal() *flow.Seal

Jump to

Keyboard shortcuts

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