Documentation ¶
Index ¶
- func IsBootstrapped(db *badger.DB) (bool, error)
- func OpenState(metrics module.ComplianceMetrics, db *badger.DB, headers storage.Headers, ...) (*State, *StateRoot, error)
- type Cluster
- type CommittedEpoch
- type Config
- type DKG
- type EpochQuery
- type FollowerState
- type InvalidEpoch
- func (u *InvalidEpoch) Cluster(uint) (protocol.Cluster, error)
- func (u *InvalidEpoch) Clustering() (flow.ClusterList, error)
- func (u *InvalidEpoch) Counter() (uint64, error)
- func (u *InvalidEpoch) DKG() (protocol.DKG, error)
- func (u *InvalidEpoch) FinalView() (uint64, error)
- func (u *InvalidEpoch) FirstView() (uint64, error)
- func (u *InvalidEpoch) InitialIdentities() (flow.IdentityList, error)
- func (u *InvalidEpoch) Seed(...uint32) ([]byte, error)
- type InvalidEpochQuery
- type InvalidSnapshot
- func (u *InvalidSnapshot) Commit() (flow.StateCommitment, error)
- func (u *InvalidSnapshot) Epochs() protocol.EpochQuery
- func (u *InvalidSnapshot) Head() (*flow.Header, error)
- func (u *InvalidSnapshot) Identities(_ flow.IdentityFilter) (flow.IdentityList, error)
- func (u *InvalidSnapshot) Identity(_ flow.Identifier) (*flow.Identity, error)
- func (u *InvalidSnapshot) Pending() ([]flow.Identifier, error)
- func (u *InvalidSnapshot) Phase() (flow.EpochPhase, error)
- func (u *InvalidSnapshot) Seed(_ ...uint32) ([]byte, error)
- type MutableState
- type Params
- type SetupEpoch
- func (es *SetupEpoch) Cluster(_ uint) (protocol.Cluster, error)
- func (es *SetupEpoch) Clustering() (flow.ClusterList, error)
- func (es *SetupEpoch) Counter() (uint64, error)
- func (es *SetupEpoch) DKG() (protocol.DKG, error)
- func (es *SetupEpoch) FinalView() (uint64, error)
- func (es *SetupEpoch) FirstView() (uint64, error)
- func (es *SetupEpoch) InitialIdentities() (flow.IdentityList, error)
- func (es *SetupEpoch) Seed(indices ...uint32) ([]byte, error)
- type Snapshot
- func (s *Snapshot) Commit() (flow.StateCommitment, error)
- func (s *Snapshot) Epochs() protocol.EpochQuery
- func (s *Snapshot) Head() (*flow.Header, error)
- func (s *Snapshot) Identities(selector flow.IdentityFilter) (flow.IdentityList, error)
- func (s *Snapshot) Identity(nodeID flow.Identifier) (*flow.Identity, error)
- func (s *Snapshot) Pending() ([]flow.Identifier, error)
- func (s *Snapshot) Phase() (flow.EpochPhase, error)
- func (s *Snapshot) Seed(indices ...uint32) ([]byte, error)
- type State
- type StateRoot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBootstrapped ¶ added in v0.14.0
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) EpochCounter ¶
func (Cluster) Members ¶
func (c Cluster) Members() flow.IdentityList
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
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func DefaultConfig ¶
func DefaultConfig() Config
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) Clustering ¶
func (u *InvalidEpoch) Clustering() (flow.ClusterList, error)
func (*InvalidEpoch) Counter ¶
func (u *InvalidEpoch) Counter() (uint64, 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)
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) Identities ¶
func (u *InvalidSnapshot) Identities(_ flow.IdentityFilter) (flow.IdentityList, error)
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)
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.
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) Clustering ¶
func (es *SetupEpoch) Clustering() (flow.ClusterList, error)
func (*SetupEpoch) Counter ¶
func (es *SetupEpoch) Counter() (uint64, 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)
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) Identities ¶
func (s *Snapshot) Identities(selector flow.IdentityFilter) (flow.IdentityList, error)
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)
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 (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