Documentation ¶
Index ¶
- Constants
- func IsFVMStateKey(owner string, key string) bool
- func IsSlabIndex(key string) bool
- func PrintableKey(key string) string
- type AccountStatus
- type Ledger
- type NestedTransactionId
- type State
- func (s *State) ComputationIntensities() meter.MeteredComputationIntensities
- func (s *State) Get(owner, key string, enforceLimit bool) (flow.RegisterValue, error)
- func (s *State) InteractionUsed() uint64
- func (s *State) MemoryIntensities() meter.MeteredMemoryIntensities
- func (s *State) MergeState(other *State) error
- func (s *State) Meter() *meter.Meter
- func (s *State) MeterComputation(kind common.ComputationKind, intensity uint) error
- func (s *State) MeterEmittedEvent(byteSize uint64) error
- func (s *State) MeterMemory(kind common.MemoryKind, intensity uint) error
- func (s *State) NewChild() *State
- func (s *State) NewChildWithMeterParams(params meter.MeterParameters) *State
- func (s *State) RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue)
- func (s *State) Set(owner, key string, value flow.RegisterValue, enforceLimit bool) error
- func (s *State) TotalComputationLimit() uint
- func (s *State) TotalComputationUsed() uint64
- func (s *State) TotalEmittedEventBytes() uint64
- func (s *State) TotalMemoryEstimate() uint64
- func (s *State) TotalMemoryLimit() uint
- func (s *State) UpdatedAddresses() []flow.Address
- func (s *State) View() View
- type StateOption
- type StateParameters
- func (params StateParameters) WithMaxInteractionSizeAllowed(limit uint64) StateParameters
- func (params StateParameters) WithMaxKeySizeAllowed(limit uint64) StateParameters
- func (params StateParameters) WithMaxValueSizeAllowed(limit uint64) StateParameters
- func (params StateParameters) WithMeterParameters(meterParams meter.MeterParameters) StateParameters
- type TransactionState
- func (s *TransactionState) AttachAndCommit(cachedState *State) error
- func (s *TransactionState) BeginNestedTransaction() (NestedTransactionId, error)
- func (s *TransactionState) BeginNestedTransactionWithMeterParams(params meter.MeterParameters) (NestedTransactionId, error)
- func (s *TransactionState) BeginParseRestrictedNestedTransaction(location common.AddressLocation) (NestedTransactionId, error)
- func (s *TransactionState) Commit(expectedId NestedTransactionId) (*State, error)
- func (s *TransactionState) CommitParseRestricted(location common.AddressLocation) (*State, error)
- func (s *TransactionState) ComputationIntensities() meter.MeteredComputationIntensities
- func (s *TransactionState) DisableAllLimitEnforcements()
- func (s *TransactionState) EnableAllLimitEnforcements()
- func (s *TransactionState) EnforceComputationLimits() bool
- func (s *TransactionState) EnforceLimits() bool
- func (s *TransactionState) Get(owner string, key string, enforceLimit bool) (flow.RegisterValue, error)
- func (s *TransactionState) InteractionUsed() uint64
- func (s *TransactionState) IsCurrent(id NestedTransactionId) bool
- func (s *TransactionState) IsParseRestricted() bool
- func (s *TransactionState) MainTransactionId() NestedTransactionId
- func (s *TransactionState) MemoryIntensities() meter.MeteredMemoryIntensities
- func (s *TransactionState) MeterComputation(kind common.ComputationKind, intensity uint) error
- func (s *TransactionState) MeterEmittedEvent(byteSize uint64) error
- func (s *TransactionState) MeterMemory(kind common.MemoryKind, intensity uint) error
- func (s *TransactionState) NumNestedTransactions() int
- func (s *TransactionState) Pause(expectedId NestedTransactionId) (*State, error)
- func (s *TransactionState) RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue)
- func (s *TransactionState) RestartNestedTransaction(id NestedTransactionId) error
- func (s *TransactionState) Resume(pausedState *State)
- func (s *TransactionState) RunWithAllLimitsDisabled(f func())
- func (s *TransactionState) Set(owner string, key string, value flow.RegisterValue, enforceLimit bool) error
- func (s *TransactionState) TotalComputationLimit() uint
- func (s *TransactionState) TotalComputationUsed() uint64
- func (s *TransactionState) TotalEmittedEventBytes() uint64
- func (s *TransactionState) TotalMemoryEstimate() uint64
- func (s *TransactionState) UpdatedAddresses() []flow.Address
- func (s *TransactionState) ViewForTestingOnly() View
- type View
Constants ¶
const ( DefaultMaxKeySize = 16_000 // ~16KB DefaultMaxValueSize = 256_000_000 // ~256MB // Service level keys (owner is empty): UUIDKey = "uuid" AddressStateKey = "account_address_state" // Account level keys AccountKeyPrefix = "a." AccountStatusKey = AccountKeyPrefix + "s" CodeKeyPrefix = "code." ContractNamesKey = "contract_names" PublicKeyKeyPrefix = "public_key_" )
Variables ¶
This section is empty.
Functions ¶
func IsFVMStateKey ¶ added in v0.16.2
IsFVMStateKey returns true if the key is controlled by the fvm env and return false otherwise (key controlled by the cadence env)
func IsSlabIndex ¶ added in v0.29.0
This returns true if the key is a slab index for an account's ordered fields map.
In general, each account's regular fields are stored in ordered map known only to cadence. Cadence encodes this map into bytes and split the bytes into slab chunks before storing the slabs into the ledger.
func PrintableKey ¶ added in v0.23.4
PrintableKey formats slabs properly and avoids invalid utf8s
Types ¶
type AccountStatus ¶ added in v0.27.0
type AccountStatus uint8
func AccountStatusFromBytes ¶ added in v0.27.0
func AccountStatusFromBytes(inp []byte) (AccountStatus, error)
func NewAccountStatus ¶ added in v0.27.0
func NewAccountStatus() AccountStatus
NewAccountStatus sets exist flag and return an AccountStatus
func SetAccountStatusFrozenFlag ¶ added in v0.29.0
func SetAccountStatusFrozenFlag(inp AccountStatus, frozen bool) AccountStatus
func (AccountStatus) AccountExists ¶ added in v0.29.0
func (a AccountStatus) AccountExists() bool
func (AccountStatus) IsAccountFrozen ¶ added in v0.27.0
func (a AccountStatus) IsAccountFrozen() bool
func (AccountStatus) ToBytes ¶ added in v0.27.0
func (a AccountStatus) ToBytes() []byte
type Ledger ¶
type Ledger interface { Set(owner, key string, value flow.RegisterValue) error Get(owner, key string) (flow.RegisterValue, error) Touch(owner, key string) error Delete(owner, key string) error }
Ledger is the storage interface used by the virtual machine to read and write register values.
TODO Rename this to Storage and remove reference to flow.RegisterValue and use byte[]
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() *State
type State ¶ added in v0.14.0
type State struct {
// contains filtered or unexported fields
}
State represents the execution state it holds draft of updates and captures all register touches
func NewState ¶ added in v0.14.0
func NewState(view View, params StateParameters) *State
NewState constructs a new state
func (*State) ComputationIntensities ¶ added in v0.25.2
func (s *State) ComputationIntensities() meter.MeteredComputationIntensities
ComputationIntensities returns computation intensities
func (*State) InteractionUsed ¶ added in v0.14.0
InteractionUsed returns the amount of ledger interaction (total ledger byte read + total ledger byte written)
func (*State) MemoryIntensities ¶ added in v0.25.2
func (s *State) MemoryIntensities() meter.MeteredMemoryIntensities
MemoryIntensities returns computation intensities
func (*State) MergeState ¶ added in v0.15.0
MergeState applies the changes from a the given view to this view.
func (*State) MeterComputation ¶ added in v0.25.2
func (s *State) MeterComputation(kind common.ComputationKind, intensity uint) error
MeterComputation meters computation usage
func (*State) MeterEmittedEvent ¶ added in v0.28.0
func (*State) MeterMemory ¶ added in v0.25.2
func (s *State) MeterMemory(kind common.MemoryKind, intensity uint) error
MeterMemory meters memory usage
func (*State) NewChild ¶ added in v0.15.0
NewChild generates a new child state using the parent's meter parameters.
func (*State) NewChildWithMeterParams ¶ added in v0.29.0
func (s *State) NewChildWithMeterParams( params meter.MeterParameters, ) *State
NewChildWithMeterParams generates a new child state using the provide meter parameters.
func (*State) RegisterUpdates ¶ added in v0.29.0
func (s *State) RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue)
RegisterUpdates returns the lists of register id / value that were updated.
func (*State) TotalComputationLimit ¶ added in v0.25.2
TotalComputationLimit returns total computation limit
func (*State) TotalComputationUsed ¶ added in v0.25.2
TotalComputationUsed returns total computation used
func (*State) TotalEmittedEventBytes ¶ added in v0.28.0
func (*State) TotalMemoryEstimate ¶ added in v0.27.0
TotalMemoryEstimate returns total memory used
func (*State) TotalMemoryLimit ¶ added in v0.25.2
TotalMemoryLimit returns total memory limit
func (*State) UpdatedAddresses ¶ added in v0.14.0
UpdatedAddresses returns a sorted list of addresses that were updated (at least 1 register update)
type StateOption ¶ added in v0.14.0
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) WithMaxInteractionSizeAllowed ¶ added in v0.28.0
func (params StateParameters) WithMaxInteractionSizeAllowed(limit uint64) StateParameters
TODO(patrick): rm once https://github.com/onflow/flow-emulator/pull/245 is integrated.
WithMaxInteractionSizeAllowed sets limit on total byte interaction with ledger
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 TransactionState ¶ added in v0.28.0
type TransactionState struct {
// contains filtered or unexported fields
}
TransactionState provides active transaction states and facilitates common state management operations.
func NewTransactionState ¶ added in v0.28.0
func NewTransactionState( startView View, params StateParameters, ) *TransactionState
NewTransactionState constructs a new state transaction which manages nested transactions.
func (*TransactionState) AttachAndCommit ¶ added in v0.29.0
func (s *TransactionState) AttachAndCommit(cachedState *State) error
AttachAndCommit commits the changes in the cached nested transaction state to the current (nested) transaction.
func (*TransactionState) BeginNestedTransaction ¶ added in v0.28.0
func (s *TransactionState) BeginNestedTransaction() ( NestedTransactionId, 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.
func (*TransactionState) BeginNestedTransactionWithMeterParams ¶ added in v0.29.0
func (s *TransactionState) BeginNestedTransactionWithMeterParams( params meter.MeterParameters, ) ( 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.
func (*TransactionState) BeginParseRestrictedNestedTransaction ¶ added in v0.28.0
func (s *TransactionState) BeginParseRestrictedNestedTransaction( location common.AddressLocation, ) ( NestedTransactionId, error, )
BeginParseRestrictedNestedTransaction creates a restricted nested transaction within the current (nested) transaction. The meter parameters are inherited from the current transaction.
func (*TransactionState) Commit ¶ added in v0.28.0
func (s *TransactionState) Commit( expectedId NestedTransactionId, ) ( *State, error, )
Commit 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 state otherwise.
Note: The returned committed state may be reused by another transaction via AttachAndCommit to update the transaction bookkeeping, but the caller must manually invalidate the state. USE WITH EXTREME CAUTION.
func (*TransactionState) CommitParseRestricted ¶ added in v0.28.0
func (s *TransactionState) CommitParseRestricted( location common.AddressLocation, ) ( *State, error, )
CommitParseRestricted 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 state otherwise.
Note: The returned committed state may be reused by another transaction via AttachAndCommit to update the transaction bookkeeping, but the caller must manually invalidate the state. USE WITH EXTREME CAUTION.
func (*TransactionState) ComputationIntensities ¶ added in v0.28.0
func (s *TransactionState) ComputationIntensities() meter.MeteredComputationIntensities
func (*TransactionState) DisableAllLimitEnforcements ¶ added in v0.28.0
func (s *TransactionState) DisableAllLimitEnforcements()
DisableAllLimitEnforcements disables all the limits
func (*TransactionState) EnableAllLimitEnforcements ¶ added in v0.28.0
func (s *TransactionState) EnableAllLimitEnforcements()
EnableAllLimitEnforcements enables all the limits
func (*TransactionState) EnforceComputationLimits ¶ added in v0.28.0
func (s *TransactionState) EnforceComputationLimits() bool
EnforceComputationLimits returns if the computation limits should be enforced or not.
func (*TransactionState) EnforceLimits ¶ added in v0.28.0
func (s *TransactionState) EnforceLimits() bool
EnforceInteractionLimits returns if the interaction limits should be enforced or not
func (*TransactionState) Get ¶ added in v0.28.0
func (s *TransactionState) Get( owner string, key string, enforceLimit bool, ) ( flow.RegisterValue, error, )
func (*TransactionState) InteractionUsed ¶ added in v0.28.0
func (s *TransactionState) InteractionUsed() uint64
func (*TransactionState) IsCurrent ¶ added in v0.28.0
func (s *TransactionState) IsCurrent(id NestedTransactionId) bool
IsCurrent returns true if the provide id refers to the current (nested) transaction.
func (*TransactionState) IsParseRestricted ¶ added in v0.28.0
func (s *TransactionState) IsParseRestricted() bool
IsParseRestricted returns true if the current nested transaction is in parse resticted access mode.
func (*TransactionState) MainTransactionId ¶ added in v0.28.0
func (s *TransactionState) MainTransactionId() NestedTransactionId
func (*TransactionState) MemoryIntensities ¶ added in v0.28.0
func (s *TransactionState) MemoryIntensities() meter.MeteredMemoryIntensities
func (*TransactionState) MeterComputation ¶ added in v0.28.0
func (s *TransactionState) MeterComputation( kind common.ComputationKind, intensity uint, ) error
func (*TransactionState) MeterEmittedEvent ¶ added in v0.28.0
func (s *TransactionState) MeterEmittedEvent(byteSize uint64) error
func (*TransactionState) MeterMemory ¶ added in v0.28.0
func (s *TransactionState) MeterMemory( kind common.MemoryKind, intensity uint, ) error
func (*TransactionState) NumNestedTransactions ¶ added in v0.28.0
func (s *TransactionState) NumNestedTransactions() int
NumNestedTransactions returns the number of uncommitted nested transactions. Note that the main transaction is not considered a nested transaction.
func (*TransactionState) Pause ¶ added in v0.29.0
func (s *TransactionState) Pause( expectedId NestedTransactionId, ) ( *State, error, )
Pause 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.
func (*TransactionState) RegisterUpdates ¶ added in v0.29.0
func (s *TransactionState) RegisterUpdates() ( []flow.RegisterID, []flow.RegisterValue, )
func (*TransactionState) RestartNestedTransaction ¶ added in v0.28.0
func (s *TransactionState) RestartNestedTransaction( id NestedTransactionId, ) error
RestartNestedTransaction merges all changes that belongs to the nested transaction about to be restart (for spock/meter bookkeeping), then wipes its view changes.
func (*TransactionState) Resume ¶ added in v0.29.0
func (s *TransactionState) Resume(pausedState *State)
Resume attaches the paused nested transaction (state) to the current transaction.
func (*TransactionState) RunWithAllLimitsDisabled ¶ added in v0.28.0
func (s *TransactionState) RunWithAllLimitsDisabled(f func())
RunWithAllLimitsDisabled runs f with limits disabled
func (*TransactionState) Set ¶ added in v0.28.0
func (s *TransactionState) Set( owner string, key string, value flow.RegisterValue, enforceLimit bool, ) error
func (*TransactionState) TotalComputationLimit ¶ added in v0.28.0
func (s *TransactionState) TotalComputationLimit() uint
func (*TransactionState) TotalComputationUsed ¶ added in v0.28.0
func (s *TransactionState) TotalComputationUsed() uint64
func (*TransactionState) TotalEmittedEventBytes ¶ added in v0.28.0
func (s *TransactionState) TotalEmittedEventBytes() uint64
func (*TransactionState) TotalMemoryEstimate ¶ added in v0.28.0
func (s *TransactionState) TotalMemoryEstimate() uint64
func (*TransactionState) UpdatedAddresses ¶ added in v0.28.0
func (s *TransactionState) UpdatedAddresses() []flow.Address
func (*TransactionState) ViewForTestingOnly ¶ added in v0.28.0
func (s *TransactionState) ViewForTestingOnly() View
type View ¶ added in v0.15.0
type View interface { NewChild() View MergeView(child View) error DropDelta() // drops all the delta changes RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue) AllRegisters() []flow.RegisterID Ledger }