Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - type EmptyStorageSnapshot
 - type ExecutionSnapshot
 - type ExecutionState
 - func (state *ExecutionState) BytesWritten() uint64
 - func (state *ExecutionState) ComputationIntensities() meter.MeteredComputationIntensities
 - func (state *ExecutionState) DropChanges() error
 - func (state *ExecutionState) Finalize() *ExecutionSnapshot
 - func (state *ExecutionState) Get(id flow.RegisterID) (flow.RegisterValue, error)
 - func (state *ExecutionState) InteractionUsed() uint64
 - func (state *ExecutionState) MemoryIntensities() meter.MeteredMemoryIntensities
 - func (state *ExecutionState) Merge(other *ExecutionSnapshot) error
 - func (state *ExecutionState) MeterComputation(kind common.ComputationKind, intensity uint) error
 - func (state *ExecutionState) MeterEmittedEvent(byteSize uint64) error
 - func (state *ExecutionState) MeterMemory(kind common.MemoryKind, intensity uint) error
 - func (state *ExecutionState) NewChild() *ExecutionState
 - func (state *ExecutionState) NewChildWithMeterParams(params meter.MeterParameters) *ExecutionState
 - func (controller ExecutionState) RunWithAllLimitsDisabled(f func())
 - func (state *ExecutionState) Set(id flow.RegisterID, value flow.RegisterValue) error
 - func (state *ExecutionState) TotalComputationLimit() uint
 - func (state *ExecutionState) TotalComputationUsed() uint64
 - func (state *ExecutionState) TotalEmittedEventBytes() uint64
 - func (state *ExecutionState) TotalMemoryEstimate() uint64
 - func (state *ExecutionState) TotalMemoryLimit() uint
 - func (state *ExecutionState) View() View
 
- type MapStorageSnapshot
 - type Meter
 - type NestedTransaction
 - type NestedTransactionId
 - type Peeker
 - type ReadFuncStorageSnapshot
 - type StateParameters
 - type Storage
 - type StorageSnapshot
 - type View
 
Constants ¶
const ( DefaultMaxKeySize = 16_000 // ~16KB DefaultMaxValueSize = 256_000_000 // ~256MB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmptyStorageSnapshot ¶ added in v0.30.0
type EmptyStorageSnapshot struct{}
    func (EmptyStorageSnapshot) Get ¶ added in v0.30.0
func (EmptyStorageSnapshot) Get( id flow.RegisterID, ) ( flow.RegisterValue, error, )
type ExecutionSnapshot ¶ added in v0.30.0
type ExecutionSnapshot struct {
	// Note that the ReadSet only include reads from the storage snapshot.
	// Reads from the WriteSet are excluded from the ReadSet.
	ReadSet map[flow.RegisterID]struct{}
	WriteSet map[flow.RegisterID]flow.RegisterValue
	// Note that the spock secret may be nil if the view does not support spock.
	SpockSecret []byte
	// Note that the meter may be nil if the view does not support metering.
	*meter.Meter
}
    func (*ExecutionSnapshot) AllRegisterIDs ¶ added in v0.30.0
func (snapshot *ExecutionSnapshot) AllRegisterIDs() []flow.RegisterID
AllRegisterIDs returns all register ids that were read / write by this view. The returned ids are unsorted.
func (*ExecutionSnapshot) ReadRegisterIDs ¶ added in v0.30.0
func (snapshot *ExecutionSnapshot) ReadRegisterIDs() []flow.RegisterID
ReadRegisterIDs returns a list of register ids that were read. The returned ids are unsorted
func (*ExecutionSnapshot) UpdatedRegisterIDs ¶ added in v0.30.0
func (snapshot *ExecutionSnapshot) UpdatedRegisterIDs() []flow.RegisterID
UpdatedRegisterIDs returns all register ids that were updated by this view. The returned ids are unsorted.
func (*ExecutionSnapshot) UpdatedRegisters ¶ added in v0.30.0
func (snapshot *ExecutionSnapshot) UpdatedRegisters() flow.RegisterEntries
UpdatedRegisters returns all registers that were updated by this view. The returned entries are sorted by ids.
type ExecutionState ¶ added in v0.30.0
type ExecutionState struct {
	// contains filtered or unexported fields
}
    TODO(patrick): make State implement the View interface.
State represents the execution state it holds draft of updates and captures all register touches
func NewExecutionState ¶ added in v0.30.0
func NewExecutionState(view View, params StateParameters) *ExecutionState
NewExecutionState constructs a new state
func (*ExecutionState) BytesWritten ¶ added in v0.30.0
func (state *ExecutionState) BytesWritten() uint64
BytesWritten returns the amount of total ledger bytes written
func (*ExecutionState) ComputationIntensities ¶ added in v0.30.0
func (state *ExecutionState) ComputationIntensities() meter.MeteredComputationIntensities
ComputationIntensities returns computation intensities
func (*ExecutionState) DropChanges ¶ added in v0.30.0
func (state *ExecutionState) DropChanges() error
func (*ExecutionState) Finalize ¶ added in v0.30.0
func (state *ExecutionState) Finalize() *ExecutionSnapshot
func (*ExecutionState) Get ¶ added in v0.30.0
func (state *ExecutionState) Get(id flow.RegisterID) (flow.RegisterValue, error)
Get returns a register value given owner and key
func (*ExecutionState) InteractionUsed ¶ added in v0.30.0
func (state *ExecutionState) InteractionUsed() uint64
InteractionUsed returns the amount of ledger interaction (total ledger byte read + total ledger byte written)
func (*ExecutionState) MemoryIntensities ¶ added in v0.30.0
func (state *ExecutionState) MemoryIntensities() meter.MeteredMemoryIntensities
MemoryIntensities returns computation intensities
func (*ExecutionState) Merge ¶ added in v0.30.0
func (state *ExecutionState) Merge(other *ExecutionSnapshot) error
MergeState the changes from a the given view to this view.
func (*ExecutionState) MeterComputation ¶ added in v0.30.0
func (state *ExecutionState) MeterComputation(kind common.ComputationKind, intensity uint) error
MeterComputation meters computation usage
func (*ExecutionState) MeterEmittedEvent ¶ added in v0.30.0
func (state *ExecutionState) MeterEmittedEvent(byteSize uint64) error
func (*ExecutionState) MeterMemory ¶ added in v0.30.0
func (state *ExecutionState) MeterMemory(kind common.MemoryKind, intensity uint) error
MeterMemory meters memory usage
func (*ExecutionState) NewChild ¶ added in v0.30.0
func (state *ExecutionState) NewChild() *ExecutionState
NewChild generates a new child state using the parent's meter parameters.
func (*ExecutionState) NewChildWithMeterParams ¶ added in v0.30.0
func (state *ExecutionState) NewChildWithMeterParams( params meter.MeterParameters, ) *ExecutionState
NewChildWithMeterParams generates a new child state using the provide meter parameters.
func (ExecutionState) RunWithAllLimitsDisabled ¶ added in v0.30.0
func (controller ExecutionState) RunWithAllLimitsDisabled(f func())
func (*ExecutionState) Set ¶ added in v0.30.0
func (state *ExecutionState) Set(id flow.RegisterID, value flow.RegisterValue) error
Set updates state delta with a register update
func (*ExecutionState) TotalComputationLimit ¶ added in v0.30.0
func (state *ExecutionState) TotalComputationLimit() uint
TotalComputationLimit returns total computation limit
func (*ExecutionState) TotalComputationUsed ¶ added in v0.30.0
func (state *ExecutionState) TotalComputationUsed() uint64
TotalComputationUsed returns total computation used
func (*ExecutionState) TotalEmittedEventBytes ¶ added in v0.30.0
func (state *ExecutionState) TotalEmittedEventBytes() uint64
func (*ExecutionState) TotalMemoryEstimate ¶ added in v0.30.0
func (state *ExecutionState) TotalMemoryEstimate() uint64
TotalMemoryEstimate returns total memory used
func (*ExecutionState) TotalMemoryLimit ¶ added in v0.30.0
func (state *ExecutionState) TotalMemoryLimit() uint
TotalMemoryLimit returns total memory limit
func (*ExecutionState) View ¶ added in v0.30.0
func (state *ExecutionState) View() View
type MapStorageSnapshot ¶ added in v0.30.0
type MapStorageSnapshot map[flow.RegisterID]flow.RegisterValue
func (MapStorageSnapshot) Get ¶ added in v0.30.0
func (storage MapStorageSnapshot) Get( id flow.RegisterID, ) ( flow.RegisterValue, error, )
type Meter ¶ added in v0.30.0
type Meter interface {
	MeterComputation(kind common.ComputationKind, intensity uint) error
	ComputationIntensities() meter.MeteredComputationIntensities
	TotalComputationLimit() uint
	TotalComputationUsed() uint64
	MeterMemory(kind common.MemoryKind, intensity uint) error
	MemoryIntensities() meter.MeteredMemoryIntensities
	TotalMemoryEstimate() uint64
	InteractionUsed() uint64
	MeterEmittedEvent(byteSize uint64) error
	TotalEmittedEventBytes() uint64
	// RunWithAllLimitsDisabled runs f with limits disabled
	RunWithAllLimitsDisabled(f func())
}
    type NestedTransaction ¶ added in v0.30.0
type NestedTransaction interface {
	Meter
	// NumNestedTransactions returns the number of uncommitted nested
	// transactions.  Note that the main transaction is not considered a
	// nested transaction.
	NumNestedTransactions() int
	// IsParseRestricted returns true if the current nested transaction is in
	// parse resticted access mode.
	IsParseRestricted() bool
	MainTransactionId() NestedTransactionId
	// IsCurrent returns true if the provide id refers to the current (nested)
	// transaction.
	IsCurrent(id NestedTransactionId) bool
	// FinalizeMainTransaction finalizes the main transaction and returns
	// its execution snapshot.  The finalized main transaction will not accept
	// any new commits after this point.  This returns an error if there are
	// outstanding nested transactions.
	FinalizeMainTransaction() (*ExecutionSnapshot, error)
	// BeginNestedTransaction creates a unrestricted nested transaction within
	// the current unrestricted (nested) transaction.  The meter parameters are
	// inherited from the current transaction.  This returns error if the
	// current nested transaction is program restricted.
	BeginNestedTransaction() (
		NestedTransactionId,
		error,
	)
	// BeginNestedTransactionWithMeterParams creates a unrestricted nested
	// transaction within the current unrestricted (nested) transaction, using
	// the provided meter parameters. This returns error if the current nested
	// transaction is program restricted.
	BeginNestedTransactionWithMeterParams(
		params meter.MeterParameters,
	) (
		NestedTransactionId,
		error,
	)
	// BeginParseRestrictedNestedTransaction creates a restricted nested
	// transaction within the current (nested) transaction.  The meter
	// parameters are inherited from the current transaction.
	BeginParseRestrictedNestedTransaction(
		location common.AddressLocation,
	) (
		NestedTransactionId,
		error,
	)
	// CommitNestedTransaction commits the changes in the current unrestricted
	// nested transaction to the parent (nested) transaction.  This returns
	// error if the expectedId does not match the current nested transaction.
	// This returns the committed execution snapshot otherwise.
	//
	// Note: The returned committed execution snapshot may be reused by another
	// transaction via AttachAndCommitNestedTransaction to update the
	// transaction bookkeeping, but the caller must manually invalidate the
	// state.
	// USE WITH EXTREME CAUTION.
	CommitNestedTransaction(
		expectedId NestedTransactionId,
	) (
		*ExecutionSnapshot,
		error,
	)
	// CommitParseRestrictedNestedTransaction commits the changes in the
	// current restricted nested transaction to the parent (nested)
	// transaction.  This returns error if the specified location does not
	// match the tracked location. This returns the committed execution
	// snapshot otherwise.
	//
	// Note: The returned committed execution snapshot may be reused by another
	// transaction via AttachAndCommitNestedTransaction to update the
	// transaction bookkeeping, but the caller must manually invalidate the
	// state.
	// USE WITH EXTREME CAUTION.
	CommitParseRestrictedNestedTransaction(
		location common.AddressLocation,
	) (
		*ExecutionSnapshot,
		error,
	)
	// PauseNestedTransaction detaches the current nested transaction from the
	// parent transaction, and returns the paused nested transaction state.
	// The paused nested transaction may be resume via Resume.
	//
	// WARNING: Pause and Resume are intended for implementing continuation
	// passing style behavior for the transaction executor, with the assumption
	// that the states accessed prior to pausing remain valid after resumption.
	// The paused nested transaction should not be reused across transactions.
	// IT IS NOT SAFE TO PAUSE A NESTED TRANSACTION IN GENERAL SINCE THAT
	// COULD LEAD TO PHANTOM READS.
	PauseNestedTransaction(
		expectedId NestedTransactionId,
	) (
		*ExecutionState,
		error,
	)
	// ResumeNestedTransaction attaches the paused nested transaction (state)
	// to the current transaction.
	ResumeNestedTransaction(pausedState *ExecutionState)
	// AttachAndCommitNestedTransaction commits the changes from the cached
	// nested transaction execution snapshot to the current (nested)
	// transaction.
	AttachAndCommitNestedTransaction(cachedSnapshot *ExecutionSnapshot) error
	// RestartNestedTransaction merges all changes that belongs to the nested
	// transaction about to be restart (for spock/meter bookkeeping), then
	// wipes its view changes.
	RestartNestedTransaction(
		id NestedTransactionId,
	) error
	Get(id flow.RegisterID) (flow.RegisterValue, error)
	Set(id flow.RegisterID, value flow.RegisterValue) error
	ViewForTestingOnly() View
}
    NestedTransaction provides active transaction states and facilitates common state management operations.
func NewTransactionState ¶ added in v0.28.0
func NewTransactionState( startView View, params StateParameters, ) NestedTransaction
NewTransactionState constructs a new state transaction which manages nested transactions.
type NestedTransactionId ¶ added in v0.28.0
type NestedTransactionId struct {
	// contains filtered or unexported fields
}
    Opaque identifier used for Restarting nested transactions
func (NestedTransactionId) StateForTestingOnly ¶ added in v0.28.0
func (id NestedTransactionId) StateForTestingOnly() *ExecutionState
type Peeker ¶ added in v0.30.0
type Peeker interface {
	Peek(id flow.RegisterID) (flow.RegisterValue, error)
}
    type ReadFuncStorageSnapshot ¶ added in v0.30.0
type ReadFuncStorageSnapshot struct {
	ReadFunc func(flow.RegisterID) (flow.RegisterValue, error)
}
    func (ReadFuncStorageSnapshot) Get ¶ added in v0.30.0
func (storage ReadFuncStorageSnapshot) Get( id flow.RegisterID, ) ( flow.RegisterValue, error, )
type StateParameters ¶ added in v0.28.0
type StateParameters struct {
	meter.MeterParameters
	// contains filtered or unexported fields
}
    func DefaultParameters ¶ added in v0.28.0
func DefaultParameters() StateParameters
func (StateParameters) WithMaxKeySizeAllowed ¶ added in v0.28.0
func (params StateParameters) WithMaxKeySizeAllowed( limit uint64, ) StateParameters
WithMaxKeySizeAllowed sets limit on max key size
func (StateParameters) WithMaxValueSizeAllowed ¶ added in v0.28.0
func (params StateParameters) WithMaxValueSizeAllowed( limit uint64, ) StateParameters
WithMaxValueSizeAllowed sets limit on max value size
func (StateParameters) WithMeterParameters ¶ added in v0.28.0
func (params StateParameters) WithMeterParameters( meterParams meter.MeterParameters, ) StateParameters
WithMeterParameters sets the state's meter parameters
type Storage ¶ added in v0.30.0
type Storage interface {
	// TODO(patrick): remove once fvm.VM.Run() is deprecated
	Peek(id flow.RegisterID) (flow.RegisterValue, error)
	Set(id flow.RegisterID, value flow.RegisterValue) error
	Get(id flow.RegisterID) (flow.RegisterValue, error)
	DropChanges() error
}
    Storage is the storage interface used by the virtual machine to read and write register values.
type StorageSnapshot ¶ added in v0.30.0
type StorageSnapshot interface {
	// Get returns the register id's value, or an empty RegisterValue if the id
	// is not found.
	Get(id flow.RegisterID) (flow.RegisterValue, error)
}
    func NewPeekerStorageSnapshot ¶ added in v0.30.0
func NewPeekerStorageSnapshot(peeker Peeker) StorageSnapshot
func NewReadFuncStorageSnapshot ¶ added in v0.30.0
func NewReadFuncStorageSnapshot( readFunc func(flow.RegisterID) (flow.RegisterValue, error), ) StorageSnapshot
type View ¶ added in v0.15.0
type View interface {
	NewChild() View
	Finalize() *ExecutionSnapshot
	Merge(child *ExecutionSnapshot) error
	Storage
}