state

package
v0.34.0-crescendo-prev... Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: AGPL-3.0 Imports: 17 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExecutionStatePruned = fmt.Errorf("execution state is pruned")
View Source
var ErrNotExecuted = fmt.Errorf("block not executed")

Functions

func CommitDelta

CommitDelta takes a base storage snapshot and creates a new storage snapshot with the register updates from the given RegisterUpdatesHolder a new statecommitment is returned from the ledger, along with the trie update any error returned are exceptions

func IsParentExecuted added in v0.33.1

func IsParentExecuted(state ReadOnlyExecutionState, header *flow.Header) (bool, error)

func NewLedgerStorageSnapshot added in v0.30.0

func NewLedgerStorageSnapshot(
	ldg ledger.Ledger,
	commitment flow.StateCommitment,
) snapshot.StorageSnapshot

func RegisterEntriesToKeysValues added in v0.30.0

func RegisterEntriesToKeysValues(
	entries flow.RegisterEntries,
) (
	[]ledger.Key,
	[]ledger.Value,
)

Types

type ExecutionState

type ExecutionState interface {
	ReadOnlyExecutionState

	UpdateHighestExecutedBlockIfHigher(context.Context, *flow.Header) error

	SaveExecutionResults(
		ctx context.Context,
		result *execution.ComputationResult,
	) error

	// only available with storehouse enabled
	// panic when called with storehouse disabled (which should be a bug)
	GetHighestFinalizedExecuted() uint64
}

ExecutionState is an interface used to access and mutate the execution state of the blockchain.

func NewExecutionState

func NewExecutionState(
	ls ledger.Ledger,
	commits storage.Commits,
	blocks storage.Blocks,
	headers storage.Headers,
	collections storage.Collections,
	chunkDataPacks storage.ChunkDataPacks,
	results storage.ExecutionResults,
	myReceipts storage.MyExecutionReceipts,
	events storage.Events,
	serviceEvents storage.ServiceEvents,
	transactionResults storage.TransactionResults,
	db *badger.DB,
	tracer module.Tracer,
	registerStore execution.RegisterStore,
	enableRegisterStore bool,
) ExecutionState

NewExecutionState returns a new execution state access layer for the given ledger storage.

type FinalizedExecutionState added in v0.33.1

type FinalizedExecutionState interface {
	GetHighestFinalizedExecuted() uint64
}

FinalizedExecutionState is an interface used to access the finalized execution state

type LedgerStorageSnapshot added in v0.30.0

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

func (*LedgerStorageSnapshot) Get added in v0.30.0

func (storage *LedgerStorageSnapshot) Get(
	id flow.RegisterID,
) (
	flow.RegisterValue,
	error,
)

type ReadOnlyExecutionState

type ReadOnlyExecutionState interface {
	ScriptExecutionState

	// ChunkDataPackByChunkID retrieve a chunk data pack given the chunk ID.
	ChunkDataPackByChunkID(flow.Identifier) (*flow.ChunkDataPack, error)

	GetExecutionResultID(context.Context, flow.Identifier) (flow.Identifier, error)

	GetHighestExecutedBlockID(context.Context) (uint64, flow.Identifier, error)
}

ReadOnlyExecutionState allows to read the execution state

type RegisterUpdatesHolder added in v0.16.0

type RegisterUpdatesHolder interface {
	UpdatedRegisters() flow.RegisterEntries
	UpdatedRegisterSet() map[flow.RegisterID]flow.RegisterValue
}

type ScriptExecutionState added in v0.32.0

type ScriptExecutionState interface {
	// NewStorageSnapshot creates a new ready-only view at the given block.
	NewStorageSnapshot(commit flow.StateCommitment, blockID flow.Identifier, height uint64) snapshot.StorageSnapshot

	// CreateStorageSnapshot creates a new ready-only view at the given block.
	// It returns:
	// - (nil, nil, storage.ErrNotFound) if block is unknown
	// - (nil, nil, state.ErrNotExecuted) if block is not executed
	// - (nil, nil, state.ErrExecutionStatePruned) if the execution state has been pruned
	CreateStorageSnapshot(blockID flow.Identifier) (snapshot.StorageSnapshot, *flow.Header, error)

	// StateCommitmentByBlockID returns the final state commitment for the provided block ID.
	StateCommitmentByBlockID(flow.Identifier) (flow.StateCommitment, error)

	// Any error returned is exception
	IsBlockExecuted(height uint64, blockID flow.Identifier) (bool, error)
}

ScriptExecutionState is a subset of the `state.ExecutionState` interface purposed to only access the state used for script execution and not mutate the execution state of the blockchain.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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