Documentation ¶
Index ¶
- Constants
- Variables
- func GetStorageKeyValueSizeForTesting(storageKey flow.RegisterID, value flow.RegisterValue) uint64
- type ComputationMeter
- func (m *ComputationMeter) ComputationAvailable(kind common.ComputationKind, intensity uint) bool
- func (m *ComputationMeter) ComputationIntensities() MeteredComputationIntensities
- func (m *ComputationMeter) Merge(child ComputationMeter)
- func (m *ComputationMeter) MeterComputation(kind common.ComputationKind, intensity uint) error
- func (m *ComputationMeter) TotalComputationUsed() uint64
- type ComputationMeterParameters
- type EventMeter
- type EventMeterParameters
- type ExecutionEffortWeights
- type ExecutionMemoryWeights
- type InteractionMeter
- func (m *InteractionMeter) GetStorageRWSizeMapForTesting() (reads MeteredStorageInteractionMap, writes MeteredStorageInteractionMap)
- func (m *InteractionMeter) Merge(child InteractionMeter)
- func (m *InteractionMeter) MeterStorageRead(storageKey flow.RegisterID, value flow.RegisterValue, enforceLimit bool) error
- func (m *InteractionMeter) MeterStorageWrite(storageKey flow.RegisterID, value flow.RegisterValue, enforceLimit bool) error
- func (m *InteractionMeter) TotalBytesOfStorageInteractions() uint64
- func (m *InteractionMeter) TotalBytesReadFromStorage() uint64
- func (m *InteractionMeter) TotalBytesWrittenToStorage() uint64
- type InteractionMeterParameters
- type MemoryMeter
- type MemoryMeterParameters
- type Meter
- type MeterParameters
- func (params MeterParameters) WithComputationLimit(limit uint) MeterParameters
- func (params MeterParameters) WithComputationWeights(weights ExecutionEffortWeights) MeterParameters
- func (params MeterParameters) WithEventEmitByteLimit(byteLimit uint64) MeterParameters
- func (params MeterParameters) WithMemoryLimit(limit uint64) MeterParameters
- func (params MeterParameters) WithMemoryWeights(weights ExecutionMemoryWeights) MeterParameters
- func (params MeterParameters) WithStorageInteractionLimit(maxStorageInteractionLimit uint64) MeterParameters
- type MeteredComputationIntensities
- type MeteredMemoryIntensities
- type MeteredStorageInteractionMap
Constants ¶
const MeterExecutionInternalPrecisionBytes = 16
MeterExecutionInternalPrecisionBytes are the amount of bytes that are used internally by the WeigthedMeter to allow for metering computation smaller than one unit of computation. This allows for more fine weights. A weight of 1 unit of computation is equal to 1<<16. The minimum possible weight is 1/65536.
Variables ¶
var ( // DefaultComputationWeights is the default weights for computation intensities // these weighs make the computation metering the same as it was before dynamic execution fees // these weighs make the computation metering the same as it was before dynamic execution fees DefaultComputationWeights = ExecutionEffortWeights{ common.ComputationKindStatement: 1 << MeterExecutionInternalPrecisionBytes, common.ComputationKindLoop: 1 << MeterExecutionInternalPrecisionBytes, common.ComputationKindFunctionInvocation: 1 << MeterExecutionInternalPrecisionBytes, } )
var ( // DefaultMemoryWeights are currently hard-coded here. In the future we might like to // define this in a contract similar to the computation weights DefaultMemoryWeights = ExecutionMemoryWeights{}/* 198 elements not displayed */ )
Functions ¶
func GetStorageKeyValueSizeForTesting ¶ added in v0.28.0
func GetStorageKeyValueSizeForTesting( storageKey flow.RegisterID, value flow.RegisterValue, ) uint64
Types ¶
type ComputationMeter ¶ added in v0.30.0
type ComputationMeter struct {
// contains filtered or unexported fields
}
func NewComputationMeter ¶ added in v0.30.0
func NewComputationMeter(params ComputationMeterParameters) ComputationMeter
func (*ComputationMeter) ComputationAvailable ¶ added in v0.33.1
func (m *ComputationMeter) ComputationAvailable( kind common.ComputationKind, intensity uint, ) bool
ComputationAvailable returns true if enough computation is left in the transaction for the given intensity and type
func (*ComputationMeter) ComputationIntensities ¶ added in v0.30.0
func (m *ComputationMeter) ComputationIntensities() MeteredComputationIntensities
ComputationIntensities returns all the measured computational intensities
func (*ComputationMeter) Merge ¶ added in v0.30.0
func (m *ComputationMeter) Merge(child ComputationMeter)
func (*ComputationMeter) MeterComputation ¶ added in v0.30.0
func (m *ComputationMeter) MeterComputation( kind common.ComputationKind, intensity uint, ) error
MeterComputation captures computation usage and returns an error if it goes beyond the limit
func (*ComputationMeter) TotalComputationUsed ¶ added in v0.30.0
func (m *ComputationMeter) TotalComputationUsed() uint64
TotalComputationUsed returns the total computation used
type ComputationMeterParameters ¶ added in v0.30.0
type ComputationMeterParameters struct {
// contains filtered or unexported fields
}
func DefaultComputationMeterParameters ¶ added in v0.30.0
func DefaultComputationMeterParameters() ComputationMeterParameters
func (ComputationMeterParameters) ComputationWeights ¶ added in v0.30.0
func (params ComputationMeterParameters) ComputationWeights() ExecutionEffortWeights
func (ComputationMeterParameters) TotalComputationLimit ¶ added in v0.30.0
func (params ComputationMeterParameters) TotalComputationLimit() uint
TotalComputationLimit returns the total computation limit
type EventMeter ¶ added in v0.30.0
type EventMeter struct {
// contains filtered or unexported fields
}
func NewEventMeter ¶ added in v0.30.0
func NewEventMeter(params EventMeterParameters) EventMeter
func (*EventMeter) Merge ¶ added in v0.30.0
func (m *EventMeter) Merge(child EventMeter)
func (*EventMeter) MeterEmittedEvent ¶ added in v0.30.0
func (m *EventMeter) MeterEmittedEvent(byteSize uint64) error
func (*EventMeter) TotalEmittedEventBytes ¶ added in v0.30.0
func (m *EventMeter) TotalEmittedEventBytes() uint64
type EventMeterParameters ¶ added in v0.30.0
type EventMeterParameters struct {
// contains filtered or unexported fields
}
func DefaultEventMeterParameters ¶ added in v0.30.0
func DefaultEventMeterParameters() EventMeterParameters
type ExecutionEffortWeights ¶ added in v0.27.0
type ExecutionEffortWeights map[common.ComputationKind]uint64
func (ExecutionEffortWeights) ComputationFromIntensities ¶ added in v0.33.30
func (weights ExecutionEffortWeights) ComputationFromIntensities(intensities MeteredComputationIntensities) uint64
type ExecutionMemoryWeights ¶ added in v0.27.0
type ExecutionMemoryWeights map[common.MemoryKind]uint64
type InteractionMeter ¶ added in v0.30.0
type InteractionMeter struct {
// contains filtered or unexported fields
}
InteractionMeter is a meter that tracks storage interaction Only the first read of a given key is counted Only the last write of a given key is counted
func NewInteractionMeter ¶ added in v0.30.0
func NewInteractionMeter(params InteractionMeterParameters) InteractionMeter
func (*InteractionMeter) GetStorageRWSizeMapForTesting ¶ added in v0.30.0
func (m *InteractionMeter) GetStorageRWSizeMapForTesting() ( reads MeteredStorageInteractionMap, writes MeteredStorageInteractionMap, )
func (*InteractionMeter) Merge ¶ added in v0.30.0
func (m *InteractionMeter) Merge(child InteractionMeter)
Merge merges the child interaction meter into the parent interaction meter Prioritise parent reads because they happened first Prioritise child writes because they happened last
func (*InteractionMeter) MeterStorageRead ¶ added in v0.30.0
func (m *InteractionMeter) MeterStorageRead( storageKey flow.RegisterID, value flow.RegisterValue, enforceLimit bool, ) error
MeterStorageRead captures storage read bytes count and returns an error if it goes beyond the total interaction limit and limit is enforced
func (*InteractionMeter) MeterStorageWrite ¶ added in v0.30.0
func (m *InteractionMeter) MeterStorageWrite( storageKey flow.RegisterID, value flow.RegisterValue, enforceLimit bool, ) error
MeterStorageWrite captures storage written bytes count and returns an error if it goes beyond the total interaction limit and limit is enforced. If a key is written multiple times, only the last write is counted. If a key is written before it has been read, next time it will be read it will be from the view, not from storage, so count it as read 0.
func (*InteractionMeter) TotalBytesOfStorageInteractions ¶ added in v0.30.0
func (m *InteractionMeter) TotalBytesOfStorageInteractions() uint64
TotalBytesOfStorageInteractions returns total number of byte read and written from/to storage
func (*InteractionMeter) TotalBytesReadFromStorage ¶ added in v0.30.0
func (m *InteractionMeter) TotalBytesReadFromStorage() uint64
TotalBytesReadFromStorage returns total number of byte read from storage
func (*InteractionMeter) TotalBytesWrittenToStorage ¶ added in v0.30.0
func (m *InteractionMeter) TotalBytesWrittenToStorage() uint64
TotalBytesWrittenToStorage returns total number of byte written to storage
type InteractionMeterParameters ¶ added in v0.30.0
type InteractionMeterParameters struct {
// contains filtered or unexported fields
}
func DefaultInteractionMeterParameters ¶ added in v0.30.0
func DefaultInteractionMeterParameters() InteractionMeterParameters
type MemoryMeter ¶ added in v0.30.0
type MemoryMeter struct {
// contains filtered or unexported fields
}
func NewMemoryMeter ¶ added in v0.30.0
func NewMemoryMeter(params MemoryMeterParameters) MemoryMeter
NewMemoryMeter constructs a new Meter
func (*MemoryMeter) MemoryIntensities ¶ added in v0.30.0
func (m *MemoryMeter) MemoryIntensities() MeteredMemoryIntensities
MemoryIntensities returns all the measured memory intensities
func (*MemoryMeter) Merge ¶ added in v0.30.0
func (m *MemoryMeter) Merge(child MemoryMeter)
Merge merges the input meter into the current meter and checks for the limits
func (*MemoryMeter) MeterMemory ¶ added in v0.30.0
func (m *MemoryMeter) MeterMemory(kind common.MemoryKind, intensity uint) error
MeterMemory captures memory usage and returns an error if it goes beyond the limit
func (*MemoryMeter) TotalMemoryEstimate ¶ added in v0.30.0
func (m *MemoryMeter) TotalMemoryEstimate() uint64
TotalMemoryEstimate returns the total memory used
type MemoryMeterParameters ¶ added in v0.30.0
type MemoryMeterParameters struct {
// contains filtered or unexported fields
}
func DefaultMemoryParameters ¶ added in v0.30.0
func DefaultMemoryParameters() MemoryMeterParameters
func (MemoryMeterParameters) MemoryWeights ¶ added in v0.30.0
func (params MemoryMeterParameters) MemoryWeights() ExecutionMemoryWeights
func (MemoryMeterParameters) TotalMemoryLimit ¶ added in v0.30.0
func (params MemoryMeterParameters) TotalMemoryLimit() uint64
TotalMemoryLimit returns the total memory limit
type Meter ¶
type Meter struct { MeterParameters MemoryMeter ComputationMeter EventMeter InteractionMeter }
Meter collects memory and computation usage and enforces limits for any each memory/computation usage call it sums intensity multiplied by the weight of the intensity to the total memory/computation usage metrics and returns error if limits are not met.
func NewMeter ¶ added in v0.27.0
func NewMeter(params MeterParameters) *Meter
NewMeter constructs a new Meter
func (*Meter) MergeMeter ¶
MergeMeter merges the input meter into the current meter
type MeterParameters ¶ added in v0.28.0
type MeterParameters struct { ComputationMeterParameters MemoryMeterParameters EventMeterParameters InteractionMeterParameters }
func DefaultParameters ¶ added in v0.28.0
func DefaultParameters() MeterParameters
func (MeterParameters) WithComputationLimit ¶ added in v0.28.0
func (params MeterParameters) WithComputationLimit(limit uint) MeterParameters
func (MeterParameters) WithComputationWeights ¶ added in v0.28.0
func (params MeterParameters) WithComputationWeights( weights ExecutionEffortWeights, ) MeterParameters
func (MeterParameters) WithEventEmitByteLimit ¶ added in v0.28.0
func (params MeterParameters) WithEventEmitByteLimit( byteLimit uint64, ) MeterParameters
func (MeterParameters) WithMemoryLimit ¶ added in v0.28.0
func (params MeterParameters) WithMemoryLimit(limit uint64) MeterParameters
func (MeterParameters) WithMemoryWeights ¶ added in v0.28.0
func (params MeterParameters) WithMemoryWeights( weights ExecutionMemoryWeights, ) MeterParameters
func (MeterParameters) WithStorageInteractionLimit ¶ added in v0.28.0
func (params MeterParameters) WithStorageInteractionLimit( maxStorageInteractionLimit uint64, ) MeterParameters
type MeteredComputationIntensities ¶ added in v0.26.0
type MeteredComputationIntensities map[common.ComputationKind]uint
type MeteredMemoryIntensities ¶ added in v0.26.0
type MeteredMemoryIntensities map[common.MemoryKind]uint
type MeteredStorageInteractionMap ¶ added in v0.28.0
type MeteredStorageInteractionMap map[flow.RegisterID]uint64