operation

package
v0.41.1-unsafe-follower.5 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: AGPL-3.0 Imports: 16 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockExists added in v0.31.0

func BlockExists(blockID flow.Identifier, blockExists *bool) func(*badger.Txn) error

BlockExists checks whether the block exists in the database. No errors are expected during normal operation.

func EnsurePublicDB added in v0.22.4

func EnsurePublicDB(db *badger.DB) error

func EnsureSecretDB added in v0.22.4

func EnsureSecretDB(db *badger.DB) error

func Fail

func Fail(err error) func(*badger.Txn) error

Fail returns a DB operation function that always fails with the given error.

func FindHeaders

func FindHeaders(filter func(header *flow.Header) bool, found *[]flow.Header) func(*badger.Txn) error

FindHeaders iterates through all headers, calling `filter` on each, and adding them to the `found` slice if `filter` returned true

func IndexBlockHeight

func IndexBlockHeight(height uint64, blockID flow.Identifier) func(*badger.Txn) error

IndexBlockHeight indexes the height of a block. It should only be called on finalized blocks.

func IndexClusterBlockByReferenceHeight added in v0.25.15

func IndexClusterBlockByReferenceHeight(refHeight uint64, clusterBlockID flow.Identifier) func(*badger.Txn) error

IndexClusterBlockByReferenceHeight indexes a cluster block ID by its reference block height. The cluster block ID is included in the key for more efficient traversal. Only finalized cluster blocks should be included in this index. The key looks like: <prefix 0:1><ref_height 1:9><cluster_block_id 9:41>

func IndexClusterBlockHeight

func IndexClusterBlockHeight(clusterID flow.ChainID, number uint64, blockID flow.Identifier) func(*badger.Txn) error

IndexClusterBlockHeight inserts a block number to block ID mapping for the given cluster.

func IndexCollectionBlock

func IndexCollectionBlock(collID flow.Identifier, blockID flow.Identifier) func(*badger.Txn) error

IndexCollectionBlock indexes a block by a collection within that block.

func IndexCollectionByTransaction

func IndexCollectionByTransaction(txID flow.Identifier, collectionID flow.Identifier) func(*badger.Txn) error

IndexCollectionByTransaction inserts a collection id keyed by a transaction id

func IndexCollectionPayload

func IndexCollectionPayload(blockID flow.Identifier, txIDs []flow.Identifier) func(*badger.Txn) error

IndexCollectionPayload indexes the transactions within the collection payload of a cluster block.

func IndexReferenceBlockByClusterBlock added in v0.25.15

func IndexReferenceBlockByClusterBlock(clusterBlockID, refID flow.Identifier) func(*badger.Txn) error

IndexReferenceBlockByClusterBlock inserts the reference block ID for the given cluster block ID. While each cluster block specifies a reference block in its payload, we maintain this additional lookup for performance reasons.

func IndexResultApproval added in v0.14.0

func IndexResultApproval(resultID flow.Identifier, chunkIndex uint64, approvalID flow.Identifier) func(*badger.Txn) error

IndexResultApproval inserts a ResultApproval ID keyed by ExecutionResult ID and chunk index. If a value for this key exists, a storage.ErrAlreadyExists error is returned. This operation is only used by the ResultApprovals store, which is only used within a Verification node, where it is assumed that there is only one approval per chunk.

func InitJobLatestIndex added in v0.15.0

func InitJobLatestIndex(queue string, index uint64) func(*badger.Txn) error

func InitMax

func InitMax(tx *badger.Txn) error

InitMax retrieves the maximum key length to have it internally in the package after restarting. No errors are expected during normal operation.

func InsertBlockChildren

func InsertBlockChildren(blockID flow.Identifier, childrenIDs flow.IdentifierList) func(*badger.Txn) error

InsertBlockChildren insert an index to lookup the direct child of a block by its ID

func InsertChunkLocator added in v0.15.0

func InsertChunkLocator(locator *chunks.Locator) func(*badger.Txn) error

func InsertClusterFinalizedHeight

func InsertClusterFinalizedHeight(clusterID flow.ChainID, number uint64) func(*badger.Txn) error

InsertClusterFinalizedHeight inserts the finalized boundary for the given cluster.

func InsertCollection

func InsertCollection(collection *flow.LightCollection) func(*badger.Txn) error

func InsertEpochFirstHeight added in v0.30.0

func InsertEpochFirstHeight(epoch, height uint64) func(*badger.Txn) error

InsertEpochFirstHeight inserts the height of the first block in the given epoch. The first block of an epoch E is the finalized block with view >= E.FirstView. Although we don't store the final height of an epoch, it can be inferred from this index. Returns storage.ErrAlreadyExists if the height has already been indexed.

func InsertExecutedBlock

func InsertExecutedBlock(blockID flow.Identifier) func(*badger.Txn) error

func InsertExecutionForkEvidence added in v0.13.0

func InsertExecutionForkEvidence(conflictingSeals []*flow.IncorporatedResultSeal) func(*badger.Txn) error

func InsertFinalizedHeight

func InsertFinalizedHeight(height uint64) func(*badger.Txn) error

func InsertHeader

func InsertHeader(headerID flow.Identifier, header *flow.Header) func(*badger.Txn) error

func InsertJobAtIndex added in v0.15.0

func InsertJobAtIndex(queue string, index uint64, entity flow.Identifier) func(*badger.Txn) error

InsertJobAtIndex insert an entity ID at the given index

func InsertLivenessData added in v0.29.0

func InsertLivenessData(chainID flow.ChainID, livenessData *hotstuff.LivenessData) func(*badger.Txn) error

InsertLivenessData inserts liveness data into the database.

func InsertMyBeaconPrivateKey added in v0.23.2

func InsertMyBeaconPrivateKey(epochCounter uint64, info *encodable.RandomBeaconPrivKey) func(*badger.Txn) error

InsertMyBeaconPrivateKey stores the random beacon private key for the given epoch.

CAUTION: This method stores confidential information and should only be used in the context of the secrets database. This is enforced in the above layer (see storage.DKGState). Error returns: storage.ErrAlreadyExists.

func InsertPublicDBMarker added in v0.22.4

func InsertPublicDBMarker(txn *badger.Txn) error

func InsertResultApproval added in v0.14.0

func InsertResultApproval(approval *flow.ResultApproval) func(*badger.Txn) error

InsertResultApproval inserts a ResultApproval by ID.

func InsertRootHeight

func InsertRootHeight(height uint64) func(*badger.Txn) error

func InsertSafetyData added in v0.29.0

func InsertSafetyData(chainID flow.ChainID, safetyData *hotstuff.SafetyData) func(*badger.Txn) error

InsertSafetyData inserts safety data into the database.

func InsertSecretDBMarker added in v0.22.4

func InsertSecretDBMarker(txn *badger.Txn) error

func InsertTransaction

func InsertTransaction(txID flow.Identifier, tx *flow.TransactionBody) func(*badger.Txn) error

InsertTransaction inserts a transaction keyed by transaction fingerprint.

func LookupBlockHeight

func LookupBlockHeight(height uint64, blockID *flow.Identifier) func(*badger.Txn) error

LookupBlockHeight retrieves finalized blocks by height.

func LookupClusterBlockHeight

func LookupClusterBlockHeight(clusterID flow.ChainID, number uint64, blockID *flow.Identifier) func(*badger.Txn) error

LookupClusterBlockHeight retrieves a block ID by number for the given cluster

func LookupClusterBlocksByReferenceHeightRange added in v0.25.15

func LookupClusterBlocksByReferenceHeightRange(start, end uint64, clusterBlockIDs *[]flow.Identifier) func(*badger.Txn) error

LookupClusterBlocksByReferenceHeightRange traverses the ref_height->cluster_block index and returns any finalized cluster blocks which have a reference block with height in the given range. This is used to avoid including duplicate transaction when building or validating a new collection.

func LookupCollectionBlock

func LookupCollectionBlock(collID flow.Identifier, blockID *flow.Identifier) func(*badger.Txn) error

LookupCollectionBlock looks up a block by a collection within that block.

func LookupCollectionPayload

func LookupCollectionPayload(blockID flow.Identifier, txIDs *[]flow.Identifier) func(*badger.Txn) error

LookupCollection looks up the collection for a given cluster payload.

func LookupReferenceBlockByClusterBlock added in v0.25.15

func LookupReferenceBlockByClusterBlock(clusterBlockID flow.Identifier, refID *flow.Identifier) func(*badger.Txn) error

LookupReferenceBlockByClusterBlock looks up the reference block ID for the given cluster block ID. While each cluster block specifies a reference block in its payload, we maintain this additional lookup for performance reasons.

func LookupResultApproval added in v0.14.0

func LookupResultApproval(resultID flow.Identifier, chunkIndex uint64, approvalID *flow.Identifier) func(*badger.Txn) error

LookupResultApproval finds a ResultApproval by result ID and chunk index.

func MigrateDKGEndStateFromV1 added in v0.39.0

func MigrateDKGEndStateFromV1(log zerolog.Logger) func(txn *badger.Txn) error

MigrateDKGEndStateFromV1 migrates the database that was used in protocol version v1 to the v2. It reads already stored data by deprecated prefix and writes it to the new prefix with values converted to the new representation. TODO(EFM, #6794): This function is introduced to implement a backward-compatible upgrade from v1 to v2. Remove this once we complete the network upgrade.

func PersistBlocklist added in v0.28.0

func PersistBlocklist(blocklist map[flow.Identifier]struct{}) func(*badger.Txn) error

PersistBlocklist writes the set of blocked nodes IDs into the data base. If an entry already exists, it is overwritten; otherwise a new entry is created. No errors are expected during normal operations.

TODO: TEMPORARY manual override for adding node IDs to list of ejected nodes, applies to networking layer only

func PurgeBlocklist added in v0.28.0

func PurgeBlocklist() func(*badger.Txn) error

PurgeBlocklist removes the set of blocked nodes IDs from the data base. If no corresponding entry exists, this function is a no-op. No errors are expected during normal operations. TODO: TEMPORARY manual override for adding node IDs to list of ejected nodes, applies to networking layer only

func RemoveCollection

func RemoveCollection(collID flow.Identifier) func(*badger.Txn) error

func RemoveExecutionForkEvidence added in v0.13.0

func RemoveExecutionForkEvidence() func(*badger.Txn) error

func RetrieveBlockChildren

func RetrieveBlockChildren(blockID flow.Identifier, childrenIDs *flow.IdentifierList) func(*badger.Txn) error

RetrieveBlockChildren the child block ID by parent block ID

func RetrieveBlocklist added in v0.28.0

func RetrieveBlocklist(blocklist *map[flow.Identifier]struct{}) func(*badger.Txn) error

RetrieveBlocklist reads the set of blocked node IDs from the data base. Returns `storage.ErrNotFound` error in case no respective data base entry is present.

TODO: TEMPORARY manual override for adding node IDs to list of ejected nodes, applies to networking layer only

func RetrieveChunkLocator added in v0.15.0

func RetrieveChunkLocator(locatorID flow.Identifier, locator *chunks.Locator) func(*badger.Txn) error

func RetrieveClusterFinalizedHeight

func RetrieveClusterFinalizedHeight(clusterID flow.ChainID, number *uint64) func(*badger.Txn) error

RetrieveClusterFinalizedHeight retrieves the finalized boundary for the given cluster.

func RetrieveCollection

func RetrieveCollection(collID flow.Identifier, collection *flow.LightCollection) func(*badger.Txn) error

func RetrieveCollectionID

func RetrieveCollectionID(txID flow.Identifier, collectionID *flow.Identifier) func(*badger.Txn) error

LookupCollectionID retrieves a collection id by transaction id

func RetrieveDKGStartedForEpoch added in v0.23.9

func RetrieveDKGStartedForEpoch(epochCounter uint64, started *bool) func(*badger.Txn) error

RetrieveDKGStartedForEpoch retrieves whether DKG has started for the given epoch. If no flag is set, started is set to false and no error is returned. No errors expected during normal operation.

func RetrieveDKGStateForEpoch added in v0.39.0

func RetrieveDKGStateForEpoch(epochCounter uint64, currentState *flow.DKGState) func(*badger.Txn) error

RetrieveDKGStateForEpoch retrieves the current DKG state for the epoch. Error returns: storage.ErrNotFound

func RetrieveEpochFirstHeight added in v0.30.0

func RetrieveEpochFirstHeight(epoch uint64, height *uint64) func(*badger.Txn) error

RetrieveEpochFirstHeight retrieves the height of the first block in the given epoch. Returns storage.ErrNotFound if the first block of the epoch has not yet been finalized.

func RetrieveEpochLastHeight added in v0.31.0

func RetrieveEpochLastHeight(epoch uint64, height *uint64) func(*badger.Txn) error

RetrieveEpochLastHeight retrieves the height of the last block in the given epoch. It's a more readable, but equivalent query to RetrieveEpochFirstHeight when interested in the last height of an epoch. Returns storage.ErrNotFound if the first block of the epoch has not yet been finalized.

func RetrieveExecutedBlock

func RetrieveExecutedBlock(blockID *flow.Identifier) func(*badger.Txn) error

func RetrieveExecutionForkEvidence added in v0.13.0

func RetrieveExecutionForkEvidence(conflictingSeals *[]*flow.IncorporatedResultSeal) func(*badger.Txn) error

func RetrieveFinalizedHeight

func RetrieveFinalizedHeight(height *uint64) func(*badger.Txn) error

func RetrieveHeader

func RetrieveHeader(blockID flow.Identifier, header *flow.Header) func(*badger.Txn) error

func RetrieveJobAtIndex added in v0.15.0

func RetrieveJobAtIndex(queue string, index uint64, entity *flow.Identifier) func(*badger.Txn) error

RetrieveJobAtIndex returns the entity at the given index

func RetrieveJobLatestIndex added in v0.15.0

func RetrieveJobLatestIndex(queue string, index *uint64) func(*badger.Txn) error

func RetrieveLivenessData added in v0.29.0

func RetrieveLivenessData(chainID flow.ChainID, livenessData *hotstuff.LivenessData) func(*badger.Txn) error

RetrieveLivenessData retrieves liveness data from the database.

func RetrieveMyBeaconPrivateKey added in v0.23.2

func RetrieveMyBeaconPrivateKey(epochCounter uint64, info *encodable.RandomBeaconPrivKey) func(*badger.Txn) error

RetrieveMyBeaconPrivateKey retrieves the random beacon private key for the given epoch.

CAUTION: This method stores confidential information and should only be used in the context of the secrets database. This is enforced in the above layer (see storage.DKGState). Error returns: storage.ErrNotFound

func RetrieveResultApproval added in v0.14.0

func RetrieveResultApproval(approvalID flow.Identifier, approval *flow.ResultApproval) func(*badger.Txn) error

RetrieveResultApproval retrieves an approval by ID.

func RetrieveRootHeight

func RetrieveRootHeight(height *uint64) func(*badger.Txn) error

func RetrieveSafetyData added in v0.29.0

func RetrieveSafetyData(chainID flow.ChainID, safetyData *hotstuff.SafetyData) func(*badger.Txn) error

RetrieveSafetyData retrieves safety data from the database.

func RetrieveTransaction

func RetrieveTransaction(txID flow.Identifier, tx *flow.TransactionBody) func(*badger.Txn) error

RetrieveTransaction retrieves a transaction by fingerprint.

func RetryOnConflict

func RetryOnConflict(action func(func(*badger.Txn) error) error, op func(tx *badger.Txn) error) error

func RetryOnConflictTx added in v0.17.0

func RetryOnConflictTx(db *badger.DB, action func(*badger.DB, func(*transaction.Tx) error) error, op func(*transaction.Tx) error) error

func SetJobLatestIndex added in v0.15.0

func SetJobLatestIndex(queue string, index uint64) func(*badger.Txn) error

func SetMax

func SetMax(tx storage.Transaction) error

SetMax sets the value for the maximum key length used for efficient iteration. No errors are expected during normal operation.

func SkipDuplicates

func SkipDuplicates(op func(*badger.Txn) error) func(tx *badger.Txn) error

func SkipDuplicatesTx added in v0.33.30

func SkipDuplicatesTx(op func(*transaction.Tx) error) func(tx *transaction.Tx) error

func SkipNonExist added in v0.24.5

func SkipNonExist(op func(*badger.Txn) error) func(tx *badger.Txn) error

func UpdateBlockChildren

func UpdateBlockChildren(blockID flow.Identifier, childrenIDs flow.IdentifierList) func(*badger.Txn) error

UpdateBlockChildren updates the children for a block.

func UpdateClusterFinalizedHeight

func UpdateClusterFinalizedHeight(clusterID flow.ChainID, number uint64) func(*badger.Txn) error

UpdateClusterFinalizedHeight updates the finalized boundary for the given cluster.

func UpdateExecutedBlock

func UpdateExecutedBlock(blockID flow.Identifier) func(*badger.Txn) error

func UpdateFinalizedHeight

func UpdateFinalizedHeight(height uint64) func(*badger.Txn) error

func UpdateLivenessData added in v0.29.0

func UpdateLivenessData(chainID flow.ChainID, livenessData *hotstuff.LivenessData) func(*badger.Txn) error

UpdateLivenessData updates liveness data in the database.

func UpdateSafetyData added in v0.29.0

func UpdateSafetyData(chainID flow.ChainID, safetyData *hotstuff.SafetyData) func(*badger.Txn) error

UpdateSafetyData updates safety data in the database.

func UpsertDKGStateForEpoch added in v0.39.0

func UpsertDKGStateForEpoch(epochCounter uint64, newState flow.DKGState) func(*badger.Txn) error

UpsertDKGStateForEpoch stores the current state of Random Beacon Recoverable State Machine for the epoch, irrespective of whether an entry for the given epoch counter already exists in the database or not.

func UpsertMyBeaconPrivateKey added in v0.39.0

func UpsertMyBeaconPrivateKey(epochCounter uint64, info *encodable.RandomBeaconPrivKey) func(*badger.Txn) error

UpsertMyBeaconPrivateKey stores the random beacon private key, irrespective of whether an entry for the given epoch counter already exists in the database or not.

CAUTION: This method stores confidential information and should only be used in the context of the secrets database. This is enforced in the above layer (see storage.EpochRecoveryMyBeaconKey). This method has to be used only in very specific cases, like epoch recovery, for normal usage use InsertMyBeaconPrivateKey.

Types

This section is empty.

Jump to

Keyboard shortcuts

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