Documentation ¶
Index ¶
- Constants
- Variables
- func FlowFeesAddress(chain flow.Chain) flow.Address
- func FlowTokenAddress(chain flow.Chain) flow.Address
- func FungibleTokenAddress(chain flow.Chain) flow.Address
- func GetExecutionEffortWeights(env Environment, service runtime.Address) (computationWeights meter.ExecutionEffortWeights, err error)
- func GetExecutionMemoryLimit(env Environment, service runtime.Address) (memoryLimit uint64, err error)
- func GetExecutionMemoryWeights(env Environment, service runtime.Address) (memoryWeights meter.ExecutionMemoryWeights, err error)
- func InvokeAccountAvailableBalanceContract(env Environment, address common.Address) (cadence.Value, error)
- func InvokeAccountBalanceContract(env Environment, address common.Address) (cadence.Value, error)
- func InvokeAccountStorageCapacityContract(env Environment, address common.Address) (cadence.Value, error)
- func InvokeAccountsStorageCapacity(env Environment, addresses []common.Address) (cadence.Value, error)
- func InvokeDeductTransactionFeesContract(env Environment, payer flow.Address, inclusionEffort uint64, ...) (cadence.Value, error)
- func InvokeSetupNewAccountContract(env Environment, flowAddress flow.Address, payer common.Address) (cadence.Value, error)
- func InvokeUseContractAuditVoucherContract(env Environment, address common.Address, code string) (bool, error)
- func NewInterpreterRuntime(options ...runtime.Option) runtime.Runtime
- type AccountInterface
- type Blocks
- type BlocksFinder
- type BootstrapAccountKeys
- type BootstrapProcedure
- type BootstrapProcedureFeeParameters
- type BootstrapProcedureOption
- func WithAccountCreationFee(fee cadence.UFix64) BootstrapProcedureOption
- func WithBootstrapAccountKeys(keys BootstrapAccountKeys) BootstrapProcedureOption
- func WithEpochConfig(epochConfig epochs.EpochConfig) BootstrapProcedureOption
- func WithExecutionEffortWeights(weights meter.ExecutionEffortWeights) BootstrapProcedureOption
- func WithExecutionMemoryLimit(limit uint64) BootstrapProcedureOption
- func WithExecutionMemoryWeights(weights meter.ExecutionMemoryWeights) BootstrapProcedureOption
- func WithIdentities(identities flow.IdentityList) BootstrapProcedureOption
- func WithInitialTokenSupply(supply cadence.UFix64) BootstrapProcedureOption
- func WithMinimumStorageReservation(reservation cadence.UFix64) BootstrapProcedureOption
- func WithRestrictedAccountCreationEnabled(enabled cadence.Bool) BootstrapProcedureOption
- func WithRestrictedContractDeployment(restricted *bool) BootstrapProcedureOption
- func WithRootBlock(rootBlock *flow.Header) BootstrapProcedureOption
- func WithStorageMBPerFLOW(ratio cadence.UFix64) BootstrapProcedureOption
- func WithTransactionFee(fees BootstrapProcedureFeeParameters) BootstrapProcedureOption
- type Context
- type ContractFunctionInvoker
- type Environment
- type MeterInterface
- type NoopBlockFinder
- type Option
- func WithAccountFreezeEnabled(accountFreezeEnabled bool) Option
- func WithAccountStorageLimit(enabled bool) Option
- func WithAllowContextOverrideByExecutionState(load bool) Option
- func WithBlockHeader(header *flow.Header) Option
- func WithBlocks(blocks Blocks) Option
- func WithCadenceLogging(enabled bool) Option
- func WithChain(chain flow.Chain) Option
- func WithComputationLimit(limit uint64) Option
- func WithContractDeploymentRestricted(enabled bool) Option
- func WithContractRemovalRestricted(enabled bool) Option
- func WithEventCollectionSizeLimit(limit uint64) Option
- func WithExtensiveTracing() Option
- func WithGasLimit(limit uint64) Option
- func WithMaxStateInteractionSize(limit uint64) Option
- func WithMaxStateKeySize(limit uint64) Option
- func WithMaxStateValueSize(limit uint64) Option
- func WithMemoryLimit(limit uint64) Option
- func WithMetricsReporter(mr handler.MetricsReporter) Option
- func WithRestrictedDeployment(restricted bool) Option
- func WithServiceAccount(enabled bool) Option
- func WithServiceEventCollectionEnabled() Option
- func WithTracer(tr module.Tracer) Option
- func WithTransactionFeesEnabled(enabled bool) Option
- func WithTransactionProcessors(processors ...TransactionProcessor) Option
- type Procedure
- type ProgramLogger
- func (logger *ProgramLogger) Logs() []string
- func (logger *ProgramLogger) ProgramChecked(location common.Location, duration time.Duration)
- func (logger *ProgramLogger) ProgramInterpreted(location common.Location, duration time.Duration)
- func (logger *ProgramLogger) ProgramLog(message string) error
- func (logger *ProgramLogger) ProgramParsed(location common.Location, duration time.Duration)
- func (logger *ProgramLogger) RecordTrace(operation string, location common.Location, duration time.Duration, ...)
- func (logger *ProgramLogger) ValueDecoded(duration time.Duration)
- func (logger *ProgramLogger) ValueEncoded(duration time.Duration)
- type ScriptEnv
- func (env *ScriptEnv) AccountFreezeEnabled() bool
- func (e *ScriptEnv) AddAccountKey(_ runtime.Address, _ *runtime.PublicKey, _ runtime.HashAlgorithm, _ int) (*runtime.AccountKey, error)
- func (e *ScriptEnv) AddEncodedAccountKey(_ runtime.Address, _ []byte) error
- func (env *ScriptEnv) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)
- func (ScriptEnv) BLSAggregatePublicKeys(keys []*runtime.PublicKey) (*runtime.PublicKey, error)
- func (ScriptEnv) BLSAggregateSignatures(sigs [][]byte) ([]byte, error)
- func (ScriptEnv) BLSVerifyPOP(pk *runtime.PublicKey, sig []byte) (bool, error)
- func (env *ScriptEnv) Commit() ([]programs.ContractUpdateKey, error)
- func (env *ScriptEnv) ComputationUsed() uint64
- func (env *ScriptEnv) Context() *Context
- func (e *ScriptEnv) CreateAccount(_ runtime.Address) (address runtime.Address, err error)
- func (env *ScriptEnv) DecodeArgument(b []byte, _ cadence.Type) (cadence.Value, error)
- func (e *ScriptEnv) EmitEvent(_ cadence.Event) error
- func (e *ScriptEnv) Events() []flow.Event
- func (env *ScriptEnv) GenerateUUID() (uint64, error)
- func (e *ScriptEnv) GetAccountAvailableBalance(address common.Address) (value uint64, err error)
- func (e *ScriptEnv) GetAccountBalance(address common.Address) (value uint64, err error)
- func (env *ScriptEnv) GetAccountContractCode(address runtime.Address, name string) (code []byte, err error)
- func (env *ScriptEnv) GetAccountContractNames(address runtime.Address) ([]string, error)
- func (e *ScriptEnv) GetAccountKey(address runtime.Address, index int) (*runtime.AccountKey, error)
- func (env *ScriptEnv) GetBlockAtHeight(height uint64) (runtime.Block, bool, error)
- func (env *ScriptEnv) GetCode(location runtime.Location) ([]byte, error)
- func (env *ScriptEnv) GetCurrentBlockHeight() (uint64, error)
- func (env *ScriptEnv) GetProgram(location common.Location) (*interpreter.Program, error)
- func (e *ScriptEnv) GetSigningAccounts() ([]runtime.Address, error)
- func (e *ScriptEnv) GetStorageCapacity(address common.Address) (value uint64, err error)
- func (env *ScriptEnv) GetStorageUsed(address common.Address) (value uint64, err error)
- func (env *ScriptEnv) GetValue(owner, key []byte) ([]byte, error)
- func (env *ScriptEnv) Hash(data []byte, tag string, hashAlgorithm runtime.HashAlgorithm) ([]byte, error)
- func (env *ScriptEnv) ImplementationDebugLog(message string) error
- func (env *ScriptEnv) MemoryEstimate() uint64
- func (e *ScriptEnv) Meter(kind common.ComputationKind, intensity uint) error
- func (env *ScriptEnv) MeterComputation(kind common.ComputationKind, intensity uint) error
- func (env *ScriptEnv) MeterMemory(usage common.MemoryUsage) error
- func (e *ScriptEnv) RemoveAccountContractCode(_ runtime.Address, _ string) (err error)
- func (e *ScriptEnv) ResolveLocation(identifiers []runtime.Identifier, location runtime.Location) ([]runtime.ResolvedLocation, error)
- func (ScriptEnv) ResourceOwnerChanged(*interpreter.Interpreter, *interpreter.CompositeValue, common.Address, ...)
- func (e *ScriptEnv) RevokeAccountKey(_ runtime.Address, _ int) (*runtime.AccountKey, error)
- func (e *ScriptEnv) RevokeEncodedAccountKey(_ runtime.Address, _ int) (publicKey []byte, err error)
- func (env *ScriptEnv) SetProgram(location common.Location, program *interpreter.Program) error
- func (env *ScriptEnv) SetValue(owner, key, value []byte) error
- func (e *ScriptEnv) UpdateAccountContractCode(_ runtime.Address, _ string, _ []byte) (err error)
- func (env *ScriptEnv) VM() *VirtualMachine
- func (e *ScriptEnv) ValidatePublicKey(pk *runtime.PublicKey) error
- func (env *ScriptEnv) ValueExists(owner, key []byte) (exists bool, err error)
- func (e *ScriptEnv) VerifySignature(signature []byte, tag string, signedData []byte, publicKey []byte, ...) (bool, error)
- type ScriptInvoker
- type ScriptProcedure
- func (proc *ScriptProcedure) ComputationLimit(ctx Context) uint64
- func (proc *ScriptProcedure) MemoryLimit(ctx Context) uint64
- func (proc *ScriptProcedure) Run(vm *VirtualMachine, ctx Context, sth *state.StateHolder, ...) error
- func (proc *ScriptProcedure) WithArguments(args ...[]byte) *ScriptProcedure
- func (proc *ScriptProcedure) WithRequestContext(reqContext context.Context) *ScriptProcedure
- type ScriptProcessor
- type Tracer
- type TransactionEnv
- func (env *TransactionEnv) AccountFreezeEnabled() bool
- func (e *TransactionEnv) AddAccountKey(address runtime.Address, publicKey *runtime.PublicKey, ...) (*runtime.AccountKey, error)
- func (e *TransactionEnv) AddEncodedAccountKey(address runtime.Address, publicKey []byte) error
- func (env *TransactionEnv) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)
- func (TransactionEnv) BLSAggregatePublicKeys(keys []*runtime.PublicKey) (*runtime.PublicKey, error)
- func (TransactionEnv) BLSAggregateSignatures(sigs [][]byte) ([]byte, error)
- func (TransactionEnv) BLSVerifyPOP(pk *runtime.PublicKey, sig []byte) (bool, error)
- func (env *TransactionEnv) Commit() ([]programs.ContractUpdateKey, error)
- func (env *TransactionEnv) ComputationUsed() uint64
- func (env *TransactionEnv) Context() *Context
- func (e *TransactionEnv) CreateAccount(payer runtime.Address) (address runtime.Address, err error)
- func (env *TransactionEnv) DecodeArgument(b []byte, _ cadence.Type) (cadence.Value, error)
- func (e *TransactionEnv) EmitEvent(event cadence.Event) error
- func (e *TransactionEnv) Events() []flow.Event
- func (env *TransactionEnv) GenerateUUID() (uint64, error)
- func (e *TransactionEnv) GetAccountAvailableBalance(address common.Address) (value uint64, err error)
- func (e *TransactionEnv) GetAccountBalance(address common.Address) (value uint64, err error)
- func (env *TransactionEnv) GetAccountContractCode(address runtime.Address, name string) (code []byte, err error)
- func (env *TransactionEnv) GetAccountContractNames(address runtime.Address) ([]string, error)
- func (e *TransactionEnv) GetAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
- func (e *TransactionEnv) GetAccountsAuthorizedForContractRemoval() []common.Address
- func (e *TransactionEnv) GetAccountsAuthorizedForContractUpdate() []common.Address
- func (e *TransactionEnv) GetAuthorizedAccounts(path cadence.Path) []common.Address
- func (env *TransactionEnv) GetBlockAtHeight(height uint64) (runtime.Block, bool, error)
- func (env *TransactionEnv) GetCode(location runtime.Location) ([]byte, error)
- func (env *TransactionEnv) GetCurrentBlockHeight() (uint64, error)
- func (e *TransactionEnv) GetIsContractDeploymentRestricted() (restricted bool, defined bool)
- func (env *TransactionEnv) GetProgram(location common.Location) (*interpreter.Program, error)
- func (e *TransactionEnv) GetSigningAccounts() ([]runtime.Address, error)
- func (e *TransactionEnv) GetStorageCapacity(address common.Address) (value uint64, err error)
- func (env *TransactionEnv) GetStorageUsed(address common.Address) (value uint64, err error)
- func (env *TransactionEnv) GetValue(owner, key []byte) ([]byte, error)
- func (env *TransactionEnv) Hash(data []byte, tag string, hashAlgorithm runtime.HashAlgorithm) ([]byte, error)
- func (env *TransactionEnv) ImplementationDebugLog(message string) error
- func (env *TransactionEnv) MemoryEstimate() uint64
- func (e *TransactionEnv) Meter(kind common.ComputationKind, intensity uint) error
- func (env *TransactionEnv) MeterComputation(kind common.ComputationKind, intensity uint) error
- func (env *TransactionEnv) MeterMemory(usage common.MemoryUsage) error
- func (e *TransactionEnv) RemoveAccountContractCode(address runtime.Address, name string) (err error)
- func (e *TransactionEnv) ResolveLocation(identifiers []runtime.Identifier, location runtime.Location) ([]runtime.ResolvedLocation, error)
- func (TransactionEnv) ResourceOwnerChanged(*interpreter.Interpreter, *interpreter.CompositeValue, common.Address, ...)
- func (e *TransactionEnv) RevokeAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
- func (e *TransactionEnv) RevokeEncodedAccountKey(address runtime.Address, index int) (publicKey []byte, err error)
- func (e *TransactionEnv) ServiceEvents() []flow.Event
- func (e *TransactionEnv) SetAccountFrozen(address common.Address, frozen bool) error
- func (env *TransactionEnv) SetProgram(location common.Location, program *interpreter.Program) error
- func (env *TransactionEnv) SetValue(owner, key, value []byte) error
- func (e *TransactionEnv) TxID() flow.Identifier
- func (e *TransactionEnv) TxIndex() uint32
- func (e *TransactionEnv) UpdateAccountContractCode(address runtime.Address, name string, code []byte) (err error)
- func (env *TransactionEnv) VM() *VirtualMachine
- func (e *TransactionEnv) ValidatePublicKey(pk *runtime.PublicKey) error
- func (env *TransactionEnv) ValueExists(owner, key []byte) (exists bool, err error)
- func (e *TransactionEnv) VerifySignature(signature []byte, tag string, signedData []byte, publicKey []byte, ...) (bool, error)
- type TransactionInvoker
- type TransactionProcedure
- func (proc *TransactionProcedure) ComputationLimit(ctx Context) uint64
- func (proc *TransactionProcedure) MemoryLimit(ctx Context) uint64
- func (proc *TransactionProcedure) Run(vm *VirtualMachine, ctx Context, st *state.StateHolder, ...) error
- func (proc *TransactionProcedure) SetTraceSpan(traceSpan otelTrace.Span)
- type TransactionProcessor
- type TransactionSequenceNumberChecker
- type TransactionStorageLimiter
- type TransactionVerifier
- type UnsafeRandomGenerator
- type VirtualMachine
Constants ¶
const ( DefaultComputationLimit = 100_000 // 100K DefaultMemoryLimit = math.MaxUint64 // DefaultEventCollectionByteSizeLimit = 256_000 // 256KB DefaultMaxNumOfTxRetries = 3 )
const AccountKeyWeightThreshold = 1000
Variables ¶
var DefaultAccountCreationFee = func() cadence.UFix64 { value, err := cadence.NewUFix64("0.00100000") if err != nil { panic(fmt.Errorf("invalid default account creation fee: %w", err)) } return value }()
var DefaultMinimumStorageReservation = func() cadence.UFix64 { value, err := cadence.NewUFix64("0.00100000") if err != nil { panic(fmt.Errorf("invalid default minimum storage reservation: %w", err)) } return value }()
var DefaultStorageMBPerFLOW = func() cadence.UFix64 { value, err := cadence.NewUFix64("100.00000000") if err != nil { panic(fmt.Errorf("invalid default minimum storage reservation: %w", err)) } return value }()
var DefaultTransactionFees = func() BootstrapProcedureFeeParameters { surgeFactor, err := cadence.NewUFix64("1.0") if err != nil { panic(fmt.Errorf("invalid default fee surge factor: %w", err)) } inclusionEffortCost, err := cadence.NewUFix64("0.00001") if err != nil { panic(fmt.Errorf("invalid default fee effort cost: %w", err)) } executionEffortCost, err := cadence.NewUFix64("0.0") if err != nil { panic(fmt.Errorf("invalid default fee effort cost: %w", err)) } return BootstrapProcedureFeeParameters{ SurgeFactor: surgeFactor, InclusionEffortCost: inclusionEffortCost, ExecutionEffortCost: executionEffortCost, } }()
DefaultTransactionFees are the default transaction fee parameters if transaction fees are on. surge factor is 1.0, inclusion effort cost is 0.0001 (because the static inclusion effort is 1.0) and execution effort cost is 0.0 because dynamic execution fees are off If they are off (which is the default behaviour) that means the transaction fees are 0.0.
Functions ¶
func GetExecutionEffortWeights ¶ added in v0.27.0
func GetExecutionEffortWeights( env Environment, service runtime.Address, ) ( computationWeights meter.ExecutionEffortWeights, err error, )
GetExecutionEffortWeights reads stored execution effort weights from the service account
func GetExecutionMemoryLimit ¶ added in v0.27.0
func GetExecutionMemoryLimit( env Environment, service runtime.Address, ) ( memoryLimit uint64, err error, )
GetExecutionMemoryLimit reads the stored execution memory limit from the service account
func GetExecutionMemoryWeights ¶ added in v0.27.0
func GetExecutionMemoryWeights( env Environment, service runtime.Address, ) ( memoryWeights meter.ExecutionMemoryWeights, err error, )
GetExecutionMemoryWeights reads stored execution memory weights from the service account
func InvokeAccountAvailableBalanceContract ¶ added in v0.27.0
func InvokeAccountAvailableBalanceContract( env Environment, address common.Address, ) (cadence.Value, error)
InvokeAccountAvailableBalanceContract executes the get available balance contract on the storage fees contract.
func InvokeAccountBalanceContract ¶ added in v0.27.0
func InvokeAccountBalanceContract( env Environment, address common.Address, ) (cadence.Value, error)
InvokeAccountBalanceContract executes the get available balance contract on the service account.
func InvokeAccountStorageCapacityContract ¶ added in v0.27.0
func InvokeAccountStorageCapacityContract( env Environment, address common.Address, ) (cadence.Value, error)
InvokeAccountStorageCapacityContract executes the get storage capacity contract on the storage fees contract.
func InvokeAccountsStorageCapacity ¶ added in v0.27.0
func InvokeAccountsStorageCapacity( env Environment, addresses []common.Address, ) (cadence.Value, error)
InvokeAccountsStorageCapacity prepares a function that calls get storage capacity on the storage fees contract for multiple accounts at once
func InvokeDeductTransactionFeesContract ¶ added in v0.27.0
func InvokeDeductTransactionFeesContract( env Environment, payer flow.Address, inclusionEffort uint64, executionEffort uint64, ) (cadence.Value, error)
InvokeDeductTransactionFeesContract executes the fee deduction contract on the service account.
func InvokeSetupNewAccountContract ¶ added in v0.27.0
func InvokeSetupNewAccountContract( env Environment, flowAddress flow.Address, payer common.Address, ) (cadence.Value, error)
InvokeSetupNewAccountContract executes the new account setup contract on the service account.
func InvokeUseContractAuditVoucherContract ¶ added in v0.27.0
func InvokeUseContractAuditVoucherContract( env Environment, address common.Address, code string) (bool, error)
InvokeUseContractAuditVoucherContract executes the use a contract deployment audit voucher contract.
Types ¶
type AccountInterface ¶ added in v0.27.0
type AccountInterface interface { CreateAccount(address runtime.Address) (runtime.Address, error) AddAccountKey( address runtime.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) ( *runtime.AccountKey, error, ) GetAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error) RevokeAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error) AddEncodedAccountKey(address runtime.Address, publicKey []byte) error // TODO(patrick): figure out where this belongs GetSigningAccounts() ([]runtime.Address, error) }
TODO(patrick): refactor this into an object Set of account api that do not have shared implementation.
type Blocks ¶
type Blocks interface { // ByHeight returns the block at the given height in the chain ending in `header` (or finalized // if `header` is nil). This enables querying un-finalized blocks by height with respect to the // chain defined by the block we are executing. ByHeightFrom(height uint64, header *flow.Header) (*flow.Header, error) }
func NewBlockFinder ¶ added in v0.13.0
NewBlockFinder constructs a new block finder
type BlocksFinder ¶ added in v0.13.0
type BlocksFinder struct {
// contains filtered or unexported fields
}
BlocksFinder finds blocks and return block headers
func (*BlocksFinder) ByHeightFrom ¶ added in v0.13.0
ByHeightFrom returns the block header by height.
type BootstrapAccountKeys ¶ added in v0.27.0
type BootstrapAccountKeys struct { ServiceAccountPublicKeys []flow.AccountPublicKey FungibleTokenAccountPublicKeys []flow.AccountPublicKey FlowTokenAccountPublicKeys []flow.AccountPublicKey FlowFeesAccountPublicKeys []flow.AccountPublicKey NodeAccountPublicKeys []flow.AccountPublicKey }
type BootstrapProcedure ¶
type BootstrapProcedure struct {
// contains filtered or unexported fields
}
A BootstrapProcedure is an invokable that can be used to bootstrap the ledger state with the default accounts and contracts required by the Flow virtual machine.
func Bootstrap ¶
func Bootstrap( serviceAccountPublicKey flow.AccountPublicKey, opts ...BootstrapProcedureOption, ) *BootstrapProcedure
Bootstrap returns a new BootstrapProcedure instance configured with the provided genesis parameters.
func (*BootstrapProcedure) ComputationLimit ¶ added in v0.25.2
func (proc *BootstrapProcedure) ComputationLimit(_ Context) uint64
func (*BootstrapProcedure) MemoryLimit ¶ added in v0.25.2
func (proc *BootstrapProcedure) MemoryLimit(_ Context) uint64
func (*BootstrapProcedure) Run ¶
func (b *BootstrapProcedure) Run(vm *VirtualMachine, ctx Context, sth *state.StateHolder, programs *programs.Programs) error
type BootstrapProcedureFeeParameters ¶ added in v0.25.2
type BootstrapProcedureOption ¶ added in v0.14.0
type BootstrapProcedureOption func(*BootstrapProcedure) *BootstrapProcedure
func WithAccountCreationFee ¶ added in v0.14.0
func WithAccountCreationFee(fee cadence.UFix64) BootstrapProcedureOption
func WithBootstrapAccountKeys ¶ added in v0.27.0
func WithBootstrapAccountKeys(keys BootstrapAccountKeys) BootstrapProcedureOption
WithBootstrapAccountKeys sets the public keys of the accounts that will be created during bootstrapping by default all accounts are created with the ServiceAccountPublicKey specified when calling `Bootstrap`.
func WithEpochConfig ¶ added in v0.20.0
func WithEpochConfig(epochConfig epochs.EpochConfig) BootstrapProcedureOption
func WithExecutionEffortWeights ¶ added in v0.25.5
func WithExecutionEffortWeights(weights meter.ExecutionEffortWeights) BootstrapProcedureOption
func WithExecutionMemoryLimit ¶ added in v0.26.2
func WithExecutionMemoryLimit(limit uint64) BootstrapProcedureOption
func WithExecutionMemoryWeights ¶ added in v0.26.0
func WithExecutionMemoryWeights(weights meter.ExecutionMemoryWeights) BootstrapProcedureOption
func WithIdentities ¶ added in v0.20.0
func WithIdentities(identities flow.IdentityList) BootstrapProcedureOption
func WithInitialTokenSupply ¶ added in v0.14.0
func WithInitialTokenSupply(supply cadence.UFix64) BootstrapProcedureOption
func WithMinimumStorageReservation ¶ added in v0.14.0
func WithMinimumStorageReservation(reservation cadence.UFix64) BootstrapProcedureOption
func WithRestrictedAccountCreationEnabled ¶ added in v0.17.6
func WithRestrictedAccountCreationEnabled(enabled cadence.Bool) BootstrapProcedureOption
func WithRestrictedContractDeployment ¶ added in v0.26.0
func WithRestrictedContractDeployment(restricted *bool) BootstrapProcedureOption
func WithRootBlock ¶ added in v0.20.0
func WithRootBlock(rootBlock *flow.Header) BootstrapProcedureOption
func WithStorageMBPerFLOW ¶ added in v0.16.1
func WithStorageMBPerFLOW(ratio cadence.UFix64) BootstrapProcedureOption
func WithTransactionFee ¶ added in v0.14.0
func WithTransactionFee(fees BootstrapProcedureFeeParameters) BootstrapProcedureOption
type Context ¶
type Context struct { Chain flow.Chain Blocks Blocks Metrics handler.MetricsReporter Tracer module.Tracer // AllowContextOverrideByExecutionState is a flag telling the fvm to override certain parts of the context from the state AllowContextOverrideByExecutionState bool ComputationLimit uint64 MemoryLimit uint64 MaxStateKeySize uint64 MaxStateValueSize uint64 MaxStateInteractionSize uint64 EventCollectionByteSizeLimit uint64 MaxNumOfTxRetries uint8 BlockHeader *flow.Header ServiceAccountEnabled bool // Depricated: RestrictedDeploymentEnabled is deprecated use SetIsContractDeploymentRestrictedTransaction instead. // Can be removed after all networks are migrated to SetIsContractDeploymentRestrictedTransaction RestrictContractDeployment bool RestrictContractRemoval bool LimitAccountStorage bool TransactionFeesEnabled bool CadenceLoggingEnabled bool EventCollectionEnabled bool ServiceEventCollectionEnabled bool AccountFreezeEnabled bool ExtensiveTracing bool TransactionProcessors []TransactionProcessor ScriptProcessors []ScriptProcessor Logger zerolog.Logger }
A Context defines a set of execution parameters used by the virtual machine.
func NewContext ¶
NewContext initializes a new execution context with the provided options.
func NewContextFromParent ¶
NewContextFromParent spawns a child execution context with the provided options.
type ContractFunctionInvoker ¶ added in v0.25.2
type ContractFunctionInvoker struct {
// contains filtered or unexported fields
}
func NewContractFunctionInvoker ¶ added in v0.25.2
func NewContractFunctionInvoker( contractLocation common.AddressLocation, functionName string, arguments []cadence.Value, argumentTypes []sema.Type, logger zerolog.Logger) *ContractFunctionInvoker
func (*ContractFunctionInvoker) Invoke ¶ added in v0.25.2
func (i *ContractFunctionInvoker) Invoke(env Environment) (cadence.Value, error)
type Environment ¶ added in v0.22.4
type Environment interface { // TODO(patrick): stop exposing Context() Context() *Context VM() *VirtualMachine runtime.Interface // TODO(patrick): we should probably make this non-optional AccountFreezeEnabled() bool StartSpanFromRoot(name trace.SpanName) otelTrace.Span StartExtensiveTracingSpanFromRoot(name trace.SpanName) otelTrace.Span }
Environment accepts a context and a virtual machine instance and provides cadence runtime interface methods to the runtime.
type MeterInterface ¶ added in v0.27.0
type MeterInterface interface { Meter(common.ComputationKind, uint) error // contains filtered or unexported methods }
TODO(patrick): refactor this into an object. TODO(patrick): rename the method names to match meter.Meter interface.
type NoopBlockFinder ¶ added in v0.20.0
type NoopBlockFinder struct{}
NoopBlockFinder implements the Blocks interface. It is used in the bootstrapping process.
func (*NoopBlockFinder) ByHeightFrom ¶ added in v0.20.0
type Option ¶
An Option sets a configuration parameter for a virtual machine context.
func WithAccountFreezeEnabled ¶ added in v0.27.0
WithAccountFreezeEnabled enable/disable of account freeze functionality for a virtual machine context.
With this option set to true, a setAccountFreeze function will be enabled for transactions processed by the VM
func WithAccountStorageLimit ¶ added in v0.14.0
WithAccountStorageLimit enables or disables checking if account storage used is over its storage capacity
func WithAllowContextOverrideByExecutionState ¶ added in v0.26.13
WithAllowContextOverrideByExecutionState sets if certain context parameters get loaded from the state or not
func WithBlockHeader ¶
WithBlockHeader sets the block header for a virtual machine context.
The VM uses the header to provide current block information to the Cadence runtime, as well as to seed the pseudorandom number generator.
func WithBlocks ¶
WithBlocks sets the block storage provider for a virtual machine context.
The VM uses the block storage provider to provide historical block information to the Cadence runtime.
func WithCadenceLogging ¶ added in v0.13.1
WithCadenceLogging enables or disables Cadence logging for a virtual machine context.
func WithComputationLimit ¶ added in v0.25.2
WithComputationLimit sets the computation limit for a virtual machine context.
func WithContractDeploymentRestricted ¶ added in v0.27.0
WithRestrictedContractDeployment enables or disables restricted contract deployment for a virtual machine context. Warning! this would be overridden with the flag stored on chain. this is just a fallback value
func WithContractRemovalRestricted ¶ added in v0.27.0
WithRestrictContractRemoval enables or disables restricted contract removal for a virtual machine context. Warning! this would be overridden with the flag stored on chain. this is just a fallback value
func WithEventCollectionSizeLimit ¶ added in v0.13.1
WithEventCollectionSizeLimit sets the event collection byte size limit for a virtual machine context.
func WithExtensiveTracing ¶ added in v0.16.0
func WithExtensiveTracing() Option
WithExtensiveTracing sets the extensive tracing
func WithGasLimit ¶
WithGasLimit sets the computation limit for a virtual machine context. @depricated, please use WithComputationLimit instead.
func WithMaxStateInteractionSize ¶ added in v0.14.0
WithMaxStateInteractionSize sets the byte size limit for total interaction with ledger. this prevents attacks such as reading all large registers
func WithMaxStateKeySize ¶ added in v0.14.0
WithMaxStateKeySize sets the byte size limit for ledger keys
func WithMaxStateValueSize ¶ added in v0.14.0
WithMaxStateValueSize sets the byte size limit for ledger values
func WithMemoryLimit ¶ added in v0.25.2
WithMemoryLimit sets the memory limit for a virtual machine context.
func WithMetricsReporter ¶ added in v0.17.6
func WithMetricsReporter(mr handler.MetricsReporter) Option
WithMetricsReporter sets the metrics collector for a virtual machine context.
A metrics collector is used to gather metrics reported by the Cadence runtime.
func WithRestrictedDeployment ¶
@Depricated please use WithContractDeploymentRestricted instead of this this has been kept to reduce breaking change on the emulator, but would be removed at some point.
func WithServiceAccount ¶
WithServiceAccount enables or disables calls to the Flow service account.
func WithServiceEventCollectionEnabled ¶ added in v0.17.1
func WithServiceEventCollectionEnabled() Option
WithServiceEventCollectionEnabled enables service event collection
func WithTracer ¶ added in v0.14.5
WithTracer sets the tracer for a virtual machine context.
func WithTransactionFeesEnabled ¶ added in v0.17.1
WithTransactionFeesEnabled enables or disables deduction of transaction fees
func WithTransactionProcessors ¶
func WithTransactionProcessors(processors ...TransactionProcessor) Option
WithTransactionProcessors sets the transaction processors for a virtual machine context.
type Procedure ¶
type Procedure interface { Run(vm *VirtualMachine, ctx Context, sth *state.StateHolder, programs *programs.Programs) error ComputationLimit(ctx Context) uint64 MemoryLimit(ctx Context) uint64 }
An Procedure is an operation (or set of operations) that reads or writes ledger state.
type ProgramLogger ¶ added in v0.27.0
type ProgramLogger struct {
// contains filtered or unexported fields
}
func NewProgramLogger ¶ added in v0.27.0
func NewProgramLogger( tracer *Tracer, reporter handler.MetricsReporter, cadenceLoggingEnabled bool, ) *ProgramLogger
func (*ProgramLogger) Logs ¶ added in v0.27.0
func (logger *ProgramLogger) Logs() []string
func (*ProgramLogger) ProgramChecked ¶ added in v0.27.0
func (logger *ProgramLogger) ProgramChecked(location common.Location, duration time.Duration)
ProgramChecked captures time spent on checking a code at specific location
func (*ProgramLogger) ProgramInterpreted ¶ added in v0.27.0
func (logger *ProgramLogger) ProgramInterpreted(location common.Location, duration time.Duration)
ProgramInterpreted captures time spent on interpreting a code at specific location
func (*ProgramLogger) ProgramLog ¶ added in v0.27.0
func (logger *ProgramLogger) ProgramLog(message string) error
func (*ProgramLogger) ProgramParsed ¶ added in v0.27.0
func (logger *ProgramLogger) ProgramParsed(location common.Location, duration time.Duration)
ProgramParsed captures time spent on parsing a code at specific location
func (*ProgramLogger) RecordTrace ¶ added in v0.27.0
func (*ProgramLogger) ValueDecoded ¶ added in v0.27.0
func (logger *ProgramLogger) ValueDecoded(duration time.Duration)
ValueDecoded accumulates time spend on runtime value decoding
func (*ProgramLogger) ValueEncoded ¶ added in v0.27.0
func (logger *ProgramLogger) ValueEncoded(duration time.Duration)
ValueEncoded accumulates time spend on runtime value encoding
type ScriptEnv ¶ added in v0.20.0
type ScriptEnv struct {
// contains filtered or unexported fields
}
ScriptEnv is a read-only mostly used for executing scripts.
func NewScriptEnvironment ¶ added in v0.20.0
func NewScriptEnvironment( reqContext context.Context, fvmContext Context, vm *VirtualMachine, sth *state.StateHolder, programs *programs.Programs, ) (*ScriptEnv, error)
func (*ScriptEnv) AccountFreezeEnabled ¶ added in v0.27.0
func (env *ScriptEnv) AccountFreezeEnabled() bool
func (*ScriptEnv) AddAccountKey ¶ added in v0.20.0
func (*ScriptEnv) AddEncodedAccountKey ¶ added in v0.20.0
func (*ScriptEnv) AllocateStorageIndex ¶ added in v0.21.0
func (env *ScriptEnv) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)
AllocateStorageIndex allocates new storage index under the owner accounts to store a new register
func (ScriptEnv) BLSAggregatePublicKeys ¶ added in v0.25.0
func (ScriptEnv) BLSAggregateSignatures ¶ added in v0.25.0
func (ScriptEnv) BLSVerifyPOP ¶ added in v0.25.0
func (*ScriptEnv) Commit ¶ added in v0.20.0
func (env *ScriptEnv) Commit() ([]programs.ContractUpdateKey, error)
Commit commits changes and return a list of updated keys
func (*ScriptEnv) ComputationUsed ¶ added in v0.25.2
func (env *ScriptEnv) ComputationUsed() uint64
TODO(patrick): rm once Meter object has been refactored
func (*ScriptEnv) CreateAccount ¶ added in v0.20.0
func (*ScriptEnv) DecodeArgument ¶ added in v0.20.0
func (*ScriptEnv) GenerateUUID ¶ added in v0.20.0
func (*ScriptEnv) GetAccountAvailableBalance ¶ added in v0.20.0
func (*ScriptEnv) GetAccountBalance ¶ added in v0.20.0
func (*ScriptEnv) GetAccountContractCode ¶ added in v0.20.0
func (*ScriptEnv) GetAccountContractNames ¶ added in v0.21.0
func (*ScriptEnv) GetAccountKey ¶ added in v0.20.0
func (*ScriptEnv) GetBlockAtHeight ¶ added in v0.20.0
GetBlockAtHeight returns the block at the given height.
func (*ScriptEnv) GetCurrentBlockHeight ¶ added in v0.20.0
GetCurrentBlockHeight returns the current block height.
func (*ScriptEnv) GetProgram ¶ added in v0.20.0
func (env *ScriptEnv) GetProgram(location common.Location) (*interpreter.Program, error)
func (*ScriptEnv) GetSigningAccounts ¶ added in v0.20.0
func (*ScriptEnv) GetStorageCapacity ¶ added in v0.20.0
func (*ScriptEnv) GetStorageUsed ¶ added in v0.20.0
func (*ScriptEnv) ImplementationDebugLog ¶ added in v0.20.0
func (*ScriptEnv) MemoryEstimate ¶ added in v0.27.0
func (env *ScriptEnv) MemoryEstimate() uint64
TODO(patrick): rm once Meter object has been refactored
func (*ScriptEnv) Meter ¶ added in v0.27.0
func (e *ScriptEnv) Meter(kind common.ComputationKind, intensity uint) error
func (*ScriptEnv) MeterComputation ¶ added in v0.25.2
func (env *ScriptEnv) MeterComputation(kind common.ComputationKind, intensity uint) error
TODO(patrick): rm once Meter object has been refactored
func (*ScriptEnv) MeterMemory ¶ added in v0.26.0
func (env *ScriptEnv) MeterMemory(usage common.MemoryUsage) error
TODO(patrick): rm once Meter object has been refactored
func (*ScriptEnv) RemoveAccountContractCode ¶ added in v0.20.0
func (*ScriptEnv) ResolveLocation ¶ added in v0.20.0
func (e *ScriptEnv) ResolveLocation( identifiers []runtime.Identifier, location runtime.Location, ) ([]runtime.ResolvedLocation, error)
func (ScriptEnv) ResourceOwnerChanged ¶ added in v0.25.0
func (ScriptEnv) ResourceOwnerChanged( *interpreter.Interpreter, *interpreter.CompositeValue, common.Address, common.Address, )
func (*ScriptEnv) RevokeAccountKey ¶ added in v0.20.0
func (*ScriptEnv) RevokeEncodedAccountKey ¶ added in v0.20.0
func (*ScriptEnv) SetProgram ¶ added in v0.20.0
func (env *ScriptEnv) SetProgram(location common.Location, program *interpreter.Program) error
func (*ScriptEnv) SetValue ¶ added in v0.20.0
TODO disable SetValue for scripts, right now the view changes are discarded
func (*ScriptEnv) UpdateAccountContractCode ¶ added in v0.20.0
func (*ScriptEnv) VM ¶ added in v0.23.2
func (env *ScriptEnv) VM() *VirtualMachine
func (*ScriptEnv) ValidatePublicKey ¶ added in v0.20.0
func (*ScriptEnv) ValueExists ¶ added in v0.20.0
func (*ScriptEnv) VerifySignature ¶ added in v0.20.0
type ScriptInvoker ¶ added in v0.23.2
type ScriptInvoker struct{}
func NewScriptInvoker ¶ added in v0.23.2
func NewScriptInvoker() ScriptInvoker
func (ScriptInvoker) Process ¶ added in v0.23.2
func (i ScriptInvoker) Process( vm *VirtualMachine, ctx Context, proc *ScriptProcedure, sth *state.StateHolder, programs *programs.Programs, ) error
type ScriptProcedure ¶
type ScriptProcedure struct { ID flow.Identifier Script []byte Arguments [][]byte RequestContext context.Context Value cadence.Value Logs []string Events []flow.Event GasUsed uint64 MemoryEstimate uint64 Err errors.Error }
func NewScriptWithContextAndArgs ¶ added in v0.26.0
func NewScriptWithContextAndArgs(code []byte, reqContext context.Context, args ...[]byte) *ScriptProcedure
func Script ¶
func Script(code []byte) *ScriptProcedure
func (*ScriptProcedure) ComputationLimit ¶ added in v0.25.2
func (proc *ScriptProcedure) ComputationLimit(ctx Context) uint64
func (*ScriptProcedure) MemoryLimit ¶ added in v0.25.2
func (proc *ScriptProcedure) MemoryLimit(ctx Context) uint64
func (*ScriptProcedure) Run ¶
func (proc *ScriptProcedure) Run(vm *VirtualMachine, ctx Context, sth *state.StateHolder, programs *programs.Programs) error
func (*ScriptProcedure) WithArguments ¶
func (proc *ScriptProcedure) WithArguments(args ...[]byte) *ScriptProcedure
func (*ScriptProcedure) WithRequestContext ¶ added in v0.26.0
func (proc *ScriptProcedure) WithRequestContext(reqContext context.Context) *ScriptProcedure
type ScriptProcessor ¶
type ScriptProcessor interface {
Process(*VirtualMachine, Context, *ScriptProcedure, *state.StateHolder, *programs.Programs) error
}
type Tracer ¶ added in v0.27.2
func (*Tracer) RecordSpanFromRoot ¶ added in v0.27.2
func (*Tracer) StartExtensiveTracingSpanFromRoot ¶ added in v0.27.2
type TransactionEnv ¶ added in v0.20.0
type TransactionEnv struct {
// contains filtered or unexported fields
}
TransactionEnv is a read-write environment used for executing flow transactions.
func NewTransactionEnvironment ¶ added in v0.20.0
func NewTransactionEnvironment( ctx Context, vm *VirtualMachine, sth *state.StateHolder, programs *programs.Programs, tx *flow.TransactionBody, txIndex uint32, traceSpan otelTrace.Span, ) (*TransactionEnv, error)
func (*TransactionEnv) AccountFreezeEnabled ¶ added in v0.27.0
func (env *TransactionEnv) AccountFreezeEnabled() bool
func (*TransactionEnv) AddAccountKey ¶ added in v0.20.0
func (e *TransactionEnv) AddAccountKey( address runtime.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) ( *runtime.AccountKey, error, )
AddAccountKey adds a public key to an existing account.
This function returns an error if the specified account does not exist or if the key insertion fails.
func (*TransactionEnv) AddEncodedAccountKey ¶ added in v0.20.0
func (e *TransactionEnv) AddEncodedAccountKey(address runtime.Address, publicKey []byte) error
AddEncodedAccountKey adds an encoded public key to an existing account.
This function returns an error if the specified account does not exist or if the key insertion fails.
func (*TransactionEnv) AllocateStorageIndex ¶ added in v0.21.0
func (env *TransactionEnv) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)
AllocateStorageIndex allocates new storage index under the owner accounts to store a new register
func (TransactionEnv) BLSAggregatePublicKeys ¶ added in v0.25.0
func (TransactionEnv) BLSAggregateSignatures ¶ added in v0.25.0
func (TransactionEnv) BLSVerifyPOP ¶ added in v0.25.0
func (*TransactionEnv) Commit ¶ added in v0.20.0
func (env *TransactionEnv) Commit() ([]programs.ContractUpdateKey, error)
Commit commits changes and return a list of updated keys
func (*TransactionEnv) ComputationUsed ¶ added in v0.25.2
func (env *TransactionEnv) ComputationUsed() uint64
TODO(patrick): rm once Meter object has been refactored
func (*TransactionEnv) CreateAccount ¶ added in v0.20.0
func (*TransactionEnv) DecodeArgument ¶ added in v0.20.0
func (*TransactionEnv) EmitEvent ¶ added in v0.20.0
func (e *TransactionEnv) EmitEvent(event cadence.Event) error
func (*TransactionEnv) Events ¶ added in v0.20.0
func (e *TransactionEnv) Events() []flow.Event
func (*TransactionEnv) GenerateUUID ¶ added in v0.20.0
func (*TransactionEnv) GetAccountAvailableBalance ¶ added in v0.20.0
func (e *TransactionEnv) GetAccountAvailableBalance(address common.Address) (value uint64, err error)
func (*TransactionEnv) GetAccountBalance ¶ added in v0.20.0
func (e *TransactionEnv) GetAccountBalance(address common.Address) (value uint64, err error)
func (*TransactionEnv) GetAccountContractCode ¶ added in v0.20.0
func (*TransactionEnv) GetAccountContractNames ¶ added in v0.21.0
func (*TransactionEnv) GetAccountKey ¶ added in v0.20.0
func (e *TransactionEnv) GetAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
GetAccountKey retrieves a public key by index from an existing account.
This function returns a nil key with no errors, if a key doesn't exist at the given index. An error is returned if the specified account does not exist, the provided index is not valid, or if the key retrieval fails.
func (*TransactionEnv) GetAccountsAuthorizedForContractRemoval ¶ added in v0.26.0
func (e *TransactionEnv) GetAccountsAuthorizedForContractRemoval() []common.Address
GetAccountsAuthorizedForContractRemoval returns a list of addresses authorized to remove contracts
func (*TransactionEnv) GetAccountsAuthorizedForContractUpdate ¶ added in v0.26.0
func (e *TransactionEnv) GetAccountsAuthorizedForContractUpdate() []common.Address
GetAccountsAuthorizedForContractUpdate returns a list of addresses authorized to update/deploy contracts
func (*TransactionEnv) GetAuthorizedAccounts ¶ added in v0.26.0
func (e *TransactionEnv) GetAuthorizedAccounts(path cadence.Path) []common.Address
GetAuthorizedAccounts returns a list of addresses authorized by the service account. Used to determine which accounts are permitted to deploy, update, or remove contracts.
It reads a storage path from service account and parse the addresses. If any issue occurs on the process (missing registers, stored value properly not set), it gracefully handles it and falls back to default behaviour (only service account be authorized).
func (*TransactionEnv) GetBlockAtHeight ¶ added in v0.20.0
GetBlockAtHeight returns the block at the given height.
func (*TransactionEnv) GetCurrentBlockHeight ¶ added in v0.20.0
GetCurrentBlockHeight returns the current block height.
func (*TransactionEnv) GetIsContractDeploymentRestricted ¶ added in v0.26.0
func (e *TransactionEnv) GetIsContractDeploymentRestricted() (restricted bool, defined bool)
GetIsContractDeploymentRestricted returns if contract deployment restriction is defined in the state and the value of it
func (*TransactionEnv) GetProgram ¶ added in v0.20.0
func (env *TransactionEnv) GetProgram(location common.Location) (*interpreter.Program, error)
func (*TransactionEnv) GetSigningAccounts ¶ added in v0.20.0
func (e *TransactionEnv) GetSigningAccounts() ([]runtime.Address, error)
func (*TransactionEnv) GetStorageCapacity ¶ added in v0.20.0
func (e *TransactionEnv) GetStorageCapacity(address common.Address) (value uint64, err error)
func (*TransactionEnv) GetStorageUsed ¶ added in v0.20.0
func (*TransactionEnv) ImplementationDebugLog ¶ added in v0.20.0
func (*TransactionEnv) MemoryEstimate ¶ added in v0.27.0
func (env *TransactionEnv) MemoryEstimate() uint64
TODO(patrick): rm once Meter object has been refactored
func (*TransactionEnv) Meter ¶ added in v0.27.0
func (e *TransactionEnv) Meter(kind common.ComputationKind, intensity uint) error
func (*TransactionEnv) MeterComputation ¶ added in v0.25.2
func (env *TransactionEnv) MeterComputation(kind common.ComputationKind, intensity uint) error
TODO(patrick): rm once Meter object has been refactored
func (*TransactionEnv) MeterMemory ¶ added in v0.26.0
func (env *TransactionEnv) MeterMemory(usage common.MemoryUsage) error
TODO(patrick): rm once Meter object has been refactored
func (*TransactionEnv) RemoveAccountContractCode ¶ added in v0.20.0
func (e *TransactionEnv) RemoveAccountContractCode(address runtime.Address, name string) (err error)
func (*TransactionEnv) ResolveLocation ¶ added in v0.20.0
func (e *TransactionEnv) ResolveLocation( identifiers []runtime.Identifier, location runtime.Location, ) ([]runtime.ResolvedLocation, error)
func (TransactionEnv) ResourceOwnerChanged ¶ added in v0.25.0
func (TransactionEnv) ResourceOwnerChanged( *interpreter.Interpreter, *interpreter.CompositeValue, common.Address, common.Address, )
func (*TransactionEnv) RevokeAccountKey ¶ added in v0.20.0
func (e *TransactionEnv) RevokeAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
RevokeAccountKey revokes a public key by index from an existing account, and returns the revoked key.
This function returns a nil key with no errors, if a key doesn't exist at the given index. An error is returned if the specified account does not exist, the provided index is not valid, or if the key revoking fails.
func (*TransactionEnv) RevokeEncodedAccountKey ¶ added in v0.20.0
func (e *TransactionEnv) RevokeEncodedAccountKey(address runtime.Address, index int) (publicKey []byte, err error)
RevokeEncodedAccountKey revokes a public key by index from an existing account.
This function returns an error if the specified account does not exist, the provided key is invalid, or if key revoking fails.
func (*TransactionEnv) ServiceEvents ¶ added in v0.20.0
func (e *TransactionEnv) ServiceEvents() []flow.Event
func (*TransactionEnv) SetAccountFrozen ¶ added in v0.20.0
func (e *TransactionEnv) SetAccountFrozen(address common.Address, frozen bool) error
func (*TransactionEnv) SetProgram ¶ added in v0.20.0
func (env *TransactionEnv) SetProgram(location common.Location, program *interpreter.Program) error
func (*TransactionEnv) SetValue ¶ added in v0.20.0
TODO disable SetValue for scripts, right now the view changes are discarded
func (*TransactionEnv) TxID ¶ added in v0.20.0
func (e *TransactionEnv) TxID() flow.Identifier
func (*TransactionEnv) TxIndex ¶ added in v0.20.0
func (e *TransactionEnv) TxIndex() uint32
func (*TransactionEnv) UpdateAccountContractCode ¶ added in v0.20.0
func (*TransactionEnv) VM ¶ added in v0.20.0
func (env *TransactionEnv) VM() *VirtualMachine
func (*TransactionEnv) ValidatePublicKey ¶ added in v0.20.0
func (e *TransactionEnv) ValidatePublicKey(pk *runtime.PublicKey) error
func (*TransactionEnv) ValueExists ¶ added in v0.20.0
func (*TransactionEnv) VerifySignature ¶ added in v0.20.0
func (e *TransactionEnv) VerifySignature( signature []byte, tag string, signedData []byte, publicKey []byte, signatureAlgorithm runtime.SignatureAlgorithm, hashAlgorithm runtime.HashAlgorithm, ) (bool, error)
type TransactionInvoker ¶ added in v0.23.2
type TransactionInvoker struct {
// contains filtered or unexported fields
}
func NewTransactionInvoker ¶ added in v0.23.2
func NewTransactionInvoker(logger zerolog.Logger) *TransactionInvoker
func (*TransactionInvoker) Process ¶ added in v0.23.2
func (i *TransactionInvoker) Process( vm *VirtualMachine, ctx *Context, proc *TransactionProcedure, sth *state.StateHolder, programs *programs.Programs, ) (processErr error)
type TransactionProcedure ¶
type TransactionProcedure struct { ID flow.Identifier Transaction *flow.TransactionBody TxIndex uint32 Logs []string Events []flow.Event ServiceEvents []flow.Event ComputationUsed uint64 MemoryEstimate uint64 Err errors.Error TraceSpan otelTrace.Span }
func Transaction ¶
func Transaction(tx *flow.TransactionBody, txIndex uint32) *TransactionProcedure
func (*TransactionProcedure) ComputationLimit ¶ added in v0.25.2
func (proc *TransactionProcedure) ComputationLimit(ctx Context) uint64
func (*TransactionProcedure) MemoryLimit ¶ added in v0.25.2
func (proc *TransactionProcedure) MemoryLimit(ctx Context) uint64
func (*TransactionProcedure) Run ¶
func (proc *TransactionProcedure) Run(vm *VirtualMachine, ctx Context, st *state.StateHolder, programs *programs.Programs) error
func (*TransactionProcedure) SetTraceSpan ¶ added in v0.14.5
func (proc *TransactionProcedure) SetTraceSpan(traceSpan otelTrace.Span)
type TransactionProcessor ¶
type TransactionProcessor interface {
Process(*VirtualMachine, *Context, *TransactionProcedure, *state.StateHolder, *programs.Programs) error
}
type TransactionSequenceNumberChecker ¶
type TransactionSequenceNumberChecker struct{}
func NewTransactionSequenceNumberChecker ¶
func NewTransactionSequenceNumberChecker() *TransactionSequenceNumberChecker
func (*TransactionSequenceNumberChecker) Process ¶
func (c *TransactionSequenceNumberChecker) Process( _ *VirtualMachine, ctx *Context, proc *TransactionProcedure, sth *state.StateHolder, _ *programs.Programs, ) error
type TransactionStorageLimiter ¶ added in v0.14.0
type TransactionStorageLimiter struct{}
func NewTransactionStorageLimiter ¶ added in v0.14.0
func NewTransactionStorageLimiter() TransactionStorageLimiter
func (TransactionStorageLimiter) CheckLimits ¶ added in v0.20.0
func (d TransactionStorageLimiter) CheckLimits( env Environment, addresses []flow.Address, ) error
type TransactionVerifier ¶ added in v0.27.0
type TransactionVerifier struct {
KeyWeightThreshold int
}
TransactionVerifier verifies the content of the transaction by checking accounts (authorizers, payer, proposer) are not frozen checking there is no double signature all signatures are valid all accounts provides enoguh weights
if KeyWeightThreshold is set to a negative number, signature verification is skipped
func NewTransactionVerifier ¶ added in v0.27.0
func NewTransactionVerifier(keyWeightThreshold int) *TransactionVerifier
func (*TransactionVerifier) Process ¶ added in v0.27.0
func (v *TransactionVerifier) Process( _ *VirtualMachine, ctx *Context, proc *TransactionProcedure, sth *state.StateHolder, _ *programs.Programs, ) error
type UnsafeRandomGenerator ¶ added in v0.27.0
type UnsafeRandomGenerator struct {
// contains filtered or unexported fields
}
func NewUnsafeRandomGenerator ¶ added in v0.27.0
func NewUnsafeRandomGenerator( tracer *Tracer, blockHeader *flow.Header, ) *UnsafeRandomGenerator
func (*UnsafeRandomGenerator) UnsafeRandom ¶ added in v0.27.0
func (gen *UnsafeRandomGenerator) UnsafeRandom() (uint64, error)
UnsafeRandom returns a random uint64, where the process of random number derivation is not cryptographically secure.
type VirtualMachine ¶
A VirtualMachine augments the Cadence runtime with Flow host functionality.
func NewVirtualMachine ¶ added in v0.15.1
func NewVirtualMachine(rt runtime.Runtime) *VirtualMachine
NewVirtualMachine creates a new virtual machine instance with the provided runtime.
Source Files ¶
- account.go
- blocks.go
- bootstrap.go
- context.go
- contractFunctionInvocations.go
- contractFunctionInvoker.go
- env.go
- env_context.go
- executionParameters.go
- fvm.go
- program_logger.go
- script.go
- scriptEnv.go
- transaction.go
- transactionEnv.go
- transactionInvoker.go
- transactionSequenceNum.go
- transactionStorageLimiter.go
- transactionVerifier.go
- unsafe_random_generator.go
Directories ¶
Path | Synopsis |
---|---|
Package systemcontracts stores canonical address locations for all system smart contracts and service events.
|
Package systemcontracts stores canonical address locations for all system smart contracts and service events. |