storehouse

package
v0.37.20-verify-execut... Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExecuted = fmt.Errorf("block is not executed")

Functions

func NewPrunedError

func NewPrunedError(height uint64, prunedHeight uint64, prunedID flow.Identifier) error

Types

type BlockEndStateSnapshot

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

BlockEndStateSnapshot represents the storage at the end of a block.

func NewBlockEndStateSnapshot

func NewBlockEndStateSnapshot(
	storage execution.RegisterStore,
	blockID flow.Identifier,
	height uint64,
) *BlockEndStateSnapshot

the caller must ensure the block height is for the given block

func (*BlockEndStateSnapshot) Get

Get returns the value of the register with the given register ID. It returns: - (value, nil) if the register exists - (nil, nil) if the register does not exist - (nil, storage.ErrHeightNotIndexed) if the height is below the first height that is indexed. - (nil, storehouse.ErrNotExecuted) if the block is not executed yet - (nil, storehouse.ErrNotExecuted) if the block is conflicting with finalized block - (nil, err) for any other exceptions

type ExecutingBlockSnapshot

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

ExecutingBlockSnapshot is a snapshot of the storage at an executed collection. It starts with a storage snapshot at the end of previous block, The register updates at the executed collection at baseHeight + 1 are cached in a map, such that retrieving register values at the snapshot will first check the cache, and then the storage.

func NewExecutingBlockSnapshot

func NewExecutingBlockSnapshot(
	previous snapshot.StorageSnapshot,

	commitment flow.StateCommitment,
) *ExecutingBlockSnapshot

create a new storage snapshot for an executed collection at the base block at height h - 1

func (*ExecutingBlockSnapshot) Commitment

func (*ExecutingBlockSnapshot) Extend

Extend returns a new storage snapshot at the same block but but for a different state commitment, which contains the given registerUpdates Usually it's used to create a new storage snapshot at the next executed collection. The registerUpdates contains the register updates at the executed collection.

func (*ExecutingBlockSnapshot) Get

Get returns the register value at the snapshot.

type InMemoryRegisterStore

type InMemoryRegisterStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewInMemoryRegisterStore

func NewInMemoryRegisterStore(lastHeight uint64, lastID flow.Identifier) *InMemoryRegisterStore

func (*InMemoryRegisterStore) GetRegister

func (s *InMemoryRegisterStore) GetRegister(height uint64, blockID flow.Identifier, register flow.RegisterID) (flow.RegisterValue, error)

GetRegister will return the latest updated value of the given register since the pruned height. It returns PrunedError if the register is unknown or not updated since the pruned height Can't return ErrNotFound, since we can't distinguish between not found or not updated since the pruned height

func (*InMemoryRegisterStore) GetUpdatedRegisters

func (s *InMemoryRegisterStore) GetUpdatedRegisters(height uint64, blockID flow.Identifier) (flow.RegisterEntries, error)

GetUpdatedRegisters returns the updated registers of a block

func (*InMemoryRegisterStore) IsBlockExecuted

func (s *InMemoryRegisterStore) IsBlockExecuted(height uint64, blockID flow.Identifier) (bool, error)

func (*InMemoryRegisterStore) Prune

func (s *InMemoryRegisterStore) Prune(height uint64, blockID flow.Identifier) error

Prune prunes the register store to the given height The pruned height must be an executed block, the caller should ensure that by calling SaveRegisters before.

Pruning is done by walking up the finalized fork from `s.prunedHeight` to `height`. At each height, prune all other forks that begin at that height. This ensures that data for all conflicting forks are freed

TODO: It does not block the caller, the pruning work is done async

func (*InMemoryRegisterStore) PrunedHeight

func (s *InMemoryRegisterStore) PrunedHeight() uint64

func (*InMemoryRegisterStore) SaveRegisters

func (s *InMemoryRegisterStore) SaveRegisters(
	height uint64,
	blockID flow.Identifier,
	parentID flow.Identifier,
	registers flow.RegisterEntries,
) error

SaveRegisters saves the registers of a block to InMemoryRegisterStore It needs to ensure the block is above the pruned height and is connected to the pruned block

type NoopNotifier

type NoopNotifier struct{}

func NewNoopNotifier

func NewNoopNotifier() *NoopNotifier

func (*NoopNotifier) OnFinalizedAndExecutedHeightUpdated

func (n *NoopNotifier) OnFinalizedAndExecutedHeightUpdated(height uint64)

type PrunedError

type PrunedError struct {
	PrunedHeight uint64
	PrunedID     flow.Identifier
	Height       uint64
}

func IsPrunedError

func IsPrunedError(err error) (PrunedError, bool)

func (PrunedError) Error

func (e PrunedError) Error() string

type RegisterEngine

type RegisterEngine struct {
	*component.ComponentManager
	// contains filtered or unexported fields
}

RegisterEngine is a wrapper for RegisterStore in order to make Block Finalization process non-blocking.

func NewRegisterEngine

func NewRegisterEngine(store *RegisterStore) *RegisterEngine

func (*RegisterEngine) OnBlockFinalized

func (e *RegisterEngine) OnBlockFinalized(*model.Block)

OnBlockFinalized will create a single goroutine to notify register store when a block is finalized. This call is non-blocking in order to avoid blocking the consensus

type RegisterStore

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

func (*RegisterStore) GetRegister

func (r *RegisterStore) GetRegister(height uint64, blockID flow.Identifier, register flow.RegisterID) (flow.RegisterValue, error)

GetRegister first try to get the register from InMemoryRegisterStore, then OnDiskRegisterStore 1. below pruned height, and is conflicting 2. below pruned height, and is finalized 3. above pruned height, and is not executed 4. above pruned height, and is executed, and register is updated 5. above pruned height, and is executed, but register is not updated since pruned height It returns:

  • (value, nil) if the register value is found at the given block
  • (nil, nil) if the register is not found
  • (nil, storage.ErrHeightNotIndexed) if the height is below the first height that is indexed.
  • (nil, storehouse.ErrNotExecuted) if the block is not executed yet
  • (nil, storehouse.ErrNotExecuted) if the block is conflicting iwth finalized block
  • (nil, err) for any other exceptions

func (*RegisterStore) IsBlockExecuted

func (r *RegisterStore) IsBlockExecuted(height uint64, blockID flow.Identifier) (bool, error)

IsBlockExecuted returns true if the block is executed, false if not executed Note: it returns (true, nil) even if the block has been pruned from on disk register store,

func (*RegisterStore) LastFinalizedAndExecutedHeight

func (r *RegisterStore) LastFinalizedAndExecutedHeight() uint64

LastFinalizedAndExecutedHeight returns the height of the last finalized and executed block, which has been saved in OnDiskRegisterStore

func (*RegisterStore) OnBlockFinalized

func (r *RegisterStore) OnBlockFinalized() error

Depend on FinalizedReader's FinalizedBlockIDAtHeight Depend on ExecutedFinalizedWAL.Append Depend on OnDiskRegisterStore.SaveRegisters OnBlockFinalized trigger the check of whether a block at the next height becomes finalized and executed. the next height is the existing finalized and executed block's height + 1. If a block at next height becomes finalized and executed, then: 1. write the registers to write ahead logs 2. save the registers of the block to OnDiskRegisterStore 3. prune the height in InMemoryRegisterStore

func (*RegisterStore) SaveRegisters

func (r *RegisterStore) SaveRegisters(header *flow.Header, registers flow.RegisterEntries) error

SaveRegisters saves to InMemoryRegisterStore first, then trigger the same check as OnBlockFinalized Depend on InMemoryRegisterStore.SaveRegisters It returns: - nil if the registers are saved successfully - exception is the block is above the pruned height but does not connect to the pruned height (conflicting block). - exception if the block is below the pruned height - exception if the save block is saved again - exception for any other exception

type RegisterStoreMetrics

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

func NewRegisterStoreMetrics

func NewRegisterStoreMetrics(collector module.ExecutionMetrics) *RegisterStoreMetrics

func (*RegisterStoreMetrics) OnFinalizedAndExecutedHeightUpdated

func (m *RegisterStoreMetrics) OnFinalizedAndExecutedHeightUpdated(height uint64)

Jump to

Keyboard shortcuts

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