Documentation ¶
Index ¶
- Constants
- Variables
- type ExecutionParameters
- type ExecutionState
- func (state *ExecutionState) BytesWritten() uint64
- func (state *ExecutionState) ComputationAvailable(kind common.ComputationKind, intensity uint) bool
- func (state *ExecutionState) ComputationIntensities() meter.MeteredComputationIntensities
- func (state *ExecutionState) DropChanges() error
- func (state *ExecutionState) ExecutionParameters() ExecutionParameters
- func (state *ExecutionState) Finalize() *snapshot.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 *snapshot.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 ExecutionParameters) *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
- type Meter
- type NestedTransactionId
- type NestedTransactionPreparer
- type StateParameters
Constants ¶
const ( DefaultMaxKeySize = 16_000 // ~16KB DefaultMaxValueSize = 256_000_000 // ~256MB )
Variables ¶
var DefaultSpockSecretHasher = func() hash.Hasher { return hash.NewSHA3_256() }
DefaultSpockSecretHasher returns a new SHA3_256 hasher
Functions ¶
This section is empty.
Types ¶
type ExecutionParameters ¶ added in v0.37.20
type ExecutionParameters struct { meter.MeterParameters ExecutionVersion semver.Version }
type ExecutionState ¶
type ExecutionState struct {
// contains filtered or unexported fields
}
State represents the execution state it holds draft of updates and captures all register touches
func NewExecutionState ¶
func NewExecutionState( snapshot snapshot.StorageSnapshot, params StateParameters, ) *ExecutionState
NewExecutionState constructs a new state
func NewExecutionStateWithSpockStateHasher ¶ added in v0.33.30
func NewExecutionStateWithSpockStateHasher( snapshot snapshot.StorageSnapshot, params StateParameters, getHasher func() hash.Hasher, ) *ExecutionState
NewExecutionStateWithSpockStateHasher constructs a new state with a custom hasher
func (*ExecutionState) BytesWritten ¶
func (state *ExecutionState) BytesWritten() uint64
BytesWritten returns the amount of total ledger bytes written
func (*ExecutionState) ComputationAvailable ¶ added in v0.33.1
func (state *ExecutionState) ComputationAvailable(kind common.ComputationKind, intensity uint) bool
ComputationAvailable checks if enough computation capacity is available without metering
func (*ExecutionState) ComputationIntensities ¶
func (state *ExecutionState) ComputationIntensities() meter.MeteredComputationIntensities
ComputationIntensities returns computation intensities
func (*ExecutionState) DropChanges ¶
func (state *ExecutionState) DropChanges() error
func (*ExecutionState) ExecutionParameters ¶ added in v0.37.20
func (state *ExecutionState) ExecutionParameters() ExecutionParameters
func (*ExecutionState) Finalize ¶
func (state *ExecutionState) Finalize() *snapshot.ExecutionSnapshot
func (*ExecutionState) Get ¶
func (state *ExecutionState) Get(id flow.RegisterID) (flow.RegisterValue, error)
Get returns a register value given owner and key
func (*ExecutionState) InteractionUsed ¶
func (state *ExecutionState) InteractionUsed() uint64
InteractionUsed returns the amount of ledger interaction (total ledger byte read + total ledger byte written)
func (*ExecutionState) MemoryIntensities ¶
func (state *ExecutionState) MemoryIntensities() meter.MeteredMemoryIntensities
MemoryIntensities returns computation intensities
func (*ExecutionState) Merge ¶
func (state *ExecutionState) Merge(other *snapshot.ExecutionSnapshot) error
MergeState the changes from a the given execution snapshot to this state.
func (*ExecutionState) MeterComputation ¶
func (state *ExecutionState) MeterComputation(kind common.ComputationKind, intensity uint) error
MeterComputation meters computation usage
func (*ExecutionState) MeterEmittedEvent ¶
func (state *ExecutionState) MeterEmittedEvent(byteSize uint64) error
func (*ExecutionState) MeterMemory ¶
func (state *ExecutionState) MeterMemory(kind common.MemoryKind, intensity uint) error
MeterMemory meters memory usage
func (*ExecutionState) NewChild ¶
func (state *ExecutionState) NewChild() *ExecutionState
NewChild generates a new child state using the parent's meter parameters.
func (*ExecutionState) NewChildWithMeterParams ¶
func (state *ExecutionState) NewChildWithMeterParams( params ExecutionParameters, ) *ExecutionState
NewChildWithMeterParams generates a new child state using the provide meter parameters.
func (ExecutionState) RunWithAllLimitsDisabled ¶
func (controller ExecutionState) RunWithAllLimitsDisabled(f func())
func (*ExecutionState) Set ¶
func (state *ExecutionState) Set(id flow.RegisterID, value flow.RegisterValue) error
Set updates state delta with a register update
func (*ExecutionState) TotalComputationLimit ¶
func (state *ExecutionState) TotalComputationLimit() uint
TotalComputationLimit returns total computation limit
func (*ExecutionState) TotalComputationUsed ¶
func (state *ExecutionState) TotalComputationUsed() uint64
TotalComputationUsed returns total computation used
func (*ExecutionState) TotalEmittedEventBytes ¶
func (state *ExecutionState) TotalEmittedEventBytes() uint64
func (*ExecutionState) TotalMemoryEstimate ¶
func (state *ExecutionState) TotalMemoryEstimate() uint64
TotalMemoryEstimate returns total memory used
func (*ExecutionState) TotalMemoryLimit ¶
func (state *ExecutionState) TotalMemoryLimit() uint
TotalMemoryLimit returns total memory limit
type Meter ¶
type Meter interface { MeterComputation(kind common.ComputationKind, intensity uint) error ComputationAvailable(kind common.ComputationKind, intensity uint) bool 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 NestedTransactionId ¶
type NestedTransactionId struct {
// contains filtered or unexported fields
}
Opaque identifier used for Restarting nested transactions
func (NestedTransactionId) StateForTestingOnly ¶
func (id NestedTransactionId) StateForTestingOnly() *ExecutionState
type NestedTransactionPreparer ¶
type NestedTransactionPreparer interface { Meter // ExecutionParameters returns the execution parameters ExecutionParameters() ExecutionParameters // 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 // InterimReadSet returns the current read set aggregated from all // outstanding nested transactions. InterimReadSet() map[flow.RegisterID]struct{} // 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() (*snapshot.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 ExecutionParameters, ) ( 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, ) ( *snapshot.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, ) ( *snapshot.ExecutionSnapshot, error, ) // AttachAndCommitNestedTransaction commits the changes from the cached // nested transaction execution snapshot to the current (nested) // transaction. AttachAndCommitNestedTransaction( cachedSnapshot *snapshot.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 }
NestedTransactionPreparer provides active transaction states and facilitates common state management operations.
func NewTransactionState ¶
func NewTransactionState( snapshot snapshot.StorageSnapshot, params StateParameters, ) NestedTransactionPreparer
NewTransactionState constructs a new state transaction which manages nested transactions.
func NewTransactionStateFromExecutionState ¶ added in v0.33.30
func NewTransactionStateFromExecutionState( startState *ExecutionState, ) NestedTransactionPreparer
NewTransactionStateFromExecutionState constructs a new state transaction directly from an execution state.
type StateParameters ¶
type StateParameters struct { meter.MeterParameters // contains filtered or unexported fields }
func DefaultParameters ¶
func DefaultParameters() StateParameters
func (StateParameters) WithMaxKeySizeAllowed ¶
func (params StateParameters) WithMaxKeySizeAllowed( limit uint64, ) StateParameters
WithMaxKeySizeAllowed sets limit on max key size
func (StateParameters) WithMaxValueSizeAllowed ¶
func (params StateParameters) WithMaxValueSizeAllowed( limit uint64, ) StateParameters
WithMaxValueSizeAllowed sets limit on max value size
func (StateParameters) WithMeterParameters ¶
func (params StateParameters) WithMeterParameters( meterParams meter.MeterParameters, ) StateParameters
WithMeterParameters sets the state's meter parameters