state

package
v0.28.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxKeySize         = 16_000      // ~16KB
	DefaultMaxValueSize       = 256_000_000 // ~256MB
	DefaultMaxInteractionSize = 20_000_000  // ~20MB

	AccountKeyPrefix = "a."
	KeyAccountStatus = AccountKeyPrefix + "s"
	KeyCode          = "code"
	KeyContractNames = "contract_names"
)

Variables

This section is empty.

Functions

func IsFVMStateKey added in v0.16.2

func IsFVMStateKey(owner, key string) bool

IsFVMStateKey returns true if the key is controlled by the fvm env and return false otherwise (key controlled by the cadence env)

func PrintableKey added in v0.23.4

func PrintableKey(key string) string

PrintableKey formats slabs properly and avoids invalid utf8s

Types

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) Delete added in v0.14.0

func (s *State) Delete(owner, key string, enforceLimit bool) error

Delete deletes a register

func (*State) Get added in v0.14.0

func (s *State) Get(owner, key string, enforceLimit bool) (flow.RegisterValue, error)

Get returns a register value given owner and key

func (*State) InteractionUsed added in v0.14.0

func (s *State) InteractionUsed() uint64

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

func (s *State) MergeState(other *State) error

MergeState applies the changes from a the given view to this view.

func (*State) Meter added in v0.25.2

func (s *State) Meter() *meter.Meter

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 (s *State) MeterEmittedEvent(byteSize uint64) error

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

func (s *State) NewChild() *State

NewChild generates a new child state

func (*State) Set added in v0.14.0

func (s *State) Set(owner, key string, value flow.RegisterValue, enforceLimit bool) error

Set updates state delta with a register update

func (*State) TotalComputationLimit added in v0.25.2

func (s *State) TotalComputationLimit() uint

TotalComputationLimit returns total computation limit

func (*State) TotalComputationUsed added in v0.25.2

func (s *State) TotalComputationUsed() uint

TotalComputationUsed returns total computation used

func (*State) TotalEmittedEventBytes added in v0.28.0

func (s *State) TotalEmittedEventBytes() uint64

func (*State) TotalMemoryEstimate added in v0.27.0

func (s *State) TotalMemoryEstimate() uint64

TotalMemoryEstimate returns total memory used

func (*State) TotalMemoryLimit added in v0.25.2

func (s *State) TotalMemoryLimit() uint

TotalMemoryLimit returns total memory limit

func (*State) Touch added in v0.14.0

func (s *State) Touch(owner, key string) error

Touch touches a register

func (*State) UpdatedAddresses added in v0.14.0

func (s *State) UpdatedAddresses() []flow.Address

UpdatedAddresses returns a sorted list of addresses that were updated (at least 1 register update)

func (*State) View added in v0.15.0

func (s *State) View() View

type StateOption added in v0.14.0

type StateOption func(st *State) *State

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

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) AttachAndCommitParseRestricted added in v0.28.0

func (s *TransactionState) AttachAndCommitParseRestricted(
	cachedNestedTransaction *State,
) error

AttachAndCommitParseRestricted commits the changes in the cached nested transaction 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. 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.

func (*TransactionState) Commit added in v0.28.0

func (s *TransactionState) Commit(
	expectedId NestedTransactionId,
) 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.

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.

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) 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) 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() uint

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL