Documentation
¶
Index ¶
- Variables
- func CommitDelta(ldg ledger.Ledger, ruh RegisterUpdatesHolder, ...) (flow.StateCommitment, *ledger.TrieUpdate, execution.ExtendableStorageSnapshot, ...)
- func IsParentExecuted(state ReadOnlyExecutionState, header *flow.Header) (bool, error)
- func NewLedgerStorageSnapshot(ldg ledger.Ledger, commitment flow.StateCommitment) snapshot.StorageSnapshot
- func RegisterEntriesToKeysValues(entries flow.RegisterEntries) ([]ledger.Key, []ledger.Value)
- type ExecutionState
- type FinalizedExecutionState
- type LedgerBackend
- type LedgerStateChecker
- type LedgerStorageSnapshot
- type ReadOnlyExecutionState
- type RegisterUpdatesHolder
- type ScriptExecutionState
Constants ¶
This section is empty.
Variables ¶
var ErrExecutionStatePruned = fmt.Errorf("execution state is pruned")
var ErrNotExecuted = fmt.Errorf("block not executed")
Functions ¶
func CommitDelta ¶
func CommitDelta( ldg ledger.Ledger, ruh RegisterUpdatesHolder, baseStorageSnapshot execution.ExtendableStorageSnapshot, ) (flow.StateCommitment, *ledger.TrieUpdate, execution.ExtendableStorageSnapshot, error)
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)
IsParentExecuted returns true if and only if the parent of the given block (header) is executed. TODO: Check whether `header` is a root block is potentially flawed, because it only works for the genesis block.
Neither spork root blocks nor dynamically boostrapped Execution Nodes (with truncated history) are supported.
func NewLedgerStorageSnapshot ¶ added in v0.30.0
func NewLedgerStorageSnapshot( ldg ledger.Ledger, commitment flow.StateCommitment, ) snapshot.StorageSnapshot
func RegisterEntriesToKeysValues ¶ added in v0.30.0
Types ¶
type ExecutionState ¶
type ExecutionState interface {
ReadOnlyExecutionState
UpdateLastExecutedBlock(context.Context, flow.Identifier) 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, error)
}
ExecutionState is an interface used to access and mutate the execution state of the blockchain.
func NewExecutionState ¶
func NewExecutionState( ledgerBackend LedgerBackend, commits storage.Commits, blocks storage.Blocks, headers storage.Headers, chunkDataPacks storage.ChunkDataPacks, results storage.ExecutionResults, myReceipts storage.MyExecutionReceipts, events storage.Events, serviceEvents storage.ServiceEvents, transactionResults storage.TransactionResults, db storage.DB, getLatestFinalized func() (uint64, error), tracer module.Tracer, registerStore execution.RegisterStore, enableRegisterStore bool, lockManager lockctx.Manager, ) ExecutionState
NewExecutionState returns a new execution state access layer backed by the given ledger.
`ledgerBackend` supplies the state-commitment checker and, unless the backend is payloadless, the register-value source for the snapshots handed out by `NewStorageSnapshot`. A payloadless backend requires `enableRegisterStore == true`; see PayloadlessLedgerBackend.
type FinalizedExecutionState ¶ added in v0.33.1
FinalizedExecutionState is an interface used to access the finalized execution state
type LedgerBackend ¶
type LedgerBackend struct {
// contains filtered or unexported fields
}
LedgerBackend bundles the ledger-side dependencies of the execution state. Its purpose is to make the valid combinations the only representable ones: a call site cannot forget to supply a register-value source, and it does not need to know that the source is absent in payloadless mode. Construct it with FullLedgerBackend or PayloadlessLedgerBackend.
func FullLedgerBackend ¶
func FullLedgerBackend(ls ledger.Ledger) LedgerBackend
FullLedgerBackend returns a LedgerBackend where the given full ledger serves both state-commitment checks and register reads. Valid with the register store either enabled or disabled: when it is enabled, register reads go to the register store and the ledger is only used for state-commitment checks.
func PayloadlessLedgerBackend ¶
func PayloadlessLedgerBackend(ls LedgerStateChecker) LedgerBackend
PayloadlessLedgerBackend returns a LedgerBackend where the given ledger only checks state commitments and cannot serve register values, as is the case for ledger.PayloadlessLedger.
CAUTION: this backend is only usable with the register store enabled, because the register store is then the sole source of register values. With the register store disabled, the snapshots handed out by `NewStorageSnapshot` have no value source and panic on the first register read. Node startup enforces this: `--payloadless` requires `--enable-storehouse` (see `ExecutionConfig.ValidateFlags`).
type LedgerStateChecker ¶
type LedgerStateChecker interface {
// HasState returns true if the given state commitment exists in the ledger.
//
// No error returns are expected during normal operation.
HasState(state ledger.State) (bool, error)
}
LedgerStateChecker is the minimum ledger-side contract the execution state always needs, regardless of register-store mode: a way to check whether a given state commitment exists in the underlying trie. Both ledger.Ledger and ledger.PayloadlessLedger satisfy this interface, which is how the execution state can be backed by either.
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)
GetLastExecutedBlockID(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.