runtime

package
v0.45.0-internal-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: AGPL-3.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockRandomSourceDeclaration

func BlockRandomSourceDeclaration(fvmEnv environment.Environment) stdlib.StandardLibraryValue

BlockRandomSourceDeclaration returns a declaration for the `randomSource` function. if the environment is a SwappableEnvironment the underlying environment can be swapped without causing issues.

func DefaultRuntimeParams

func DefaultRuntimeParams(chain flow.Chain) environment.RuntimeParams

func EVMInternalEVMContractValue

func EVMInternalEVMContractValue(chainID flow.ChainID, fvmEnv environment.Environment) *interpreter.SimpleCompositeValue

EVMInternalEVMContractValue creates an internal EVM contract value based on the specified ChainID and environment. if the environment is a SwappableEnvironment the underlying environment can be swapped without causing issues.

func TransactionIndexDeclaration

func TransactionIndexDeclaration(fvmEnv environment.Environment) stdlib.StandardLibraryValue

TransactionIndexDeclaration returns a declaration for the `getTransactionIndex` function. if the environment is a SwappableEnvironment the underlying environment can be swapped without causing issues.

Types

type CadenceRuntimeConstructor added in v0.30.0

type CadenceRuntimeConstructor func(config runtime.Config) runtime.Runtime

type ReusableCadenceRuntime

type ReusableCadenceRuntime struct {
	runtime.Runtime

	TxRuntimeEnv     runtime.Environment
	ScriptRuntimeEnv runtime.Environment
	// contains filtered or unexported fields
}

ReusableCadenceRuntime is a wrapper around cadence Runtime and cadence Environment with pre-injected cadence context for: EVM, getTransactionIndex, ... it can be reused by changing the fvmEnv. The reuse happens accross blocks and between scripts and transactions

This exists because creating and setting up a cadence runtime and environment is a costly operation. This assumes that the following objects are safe to reuse across blocks: - cadence runtime - cadence environment - evm emulator (and related objects)

because the cadence environment differs between scripts and transactions there are 2 wrapper structs for ReusableCadenceRuntime that change what env ReadStored and InvokeContractFunction use.

func NewReusableCadenceRuntime

func NewReusableCadenceRuntime(
	rt runtime.Runtime,
	chain flow.Chain,
	config runtime.Config,
) *ReusableCadenceRuntime

func (*ReusableCadenceRuntime) CadenceScriptEnv

func (reusable *ReusableCadenceRuntime) CadenceScriptEnv() runtime.Environment

func (*ReusableCadenceRuntime) CadenceTXEnv

func (reusable *ReusableCadenceRuntime) CadenceTXEnv() runtime.Environment

func (*ReusableCadenceRuntime) ExecuteScript

func (reusable *ReusableCadenceRuntime) ExecuteScript(
	script runtime.Script,
	location common.Location,
) (
	cadence.Value,
	error,
)

func (*ReusableCadenceRuntime) NewTransactionExecutor added in v0.29.0

func (reusable *ReusableCadenceRuntime) NewTransactionExecutor(
	script runtime.Script,
	location common.Location,
) runtime.Executor

func (*ReusableCadenceRuntime) SetFvmEnvironment

func (reusable *ReusableCadenceRuntime) SetFvmEnvironment(fvmEnv environment.Environment)

type ReusableCadenceRuntimePool

type ReusableCadenceRuntimePool struct {
	// contains filtered or unexported fields
}

func NewCustomReusableCadenceRuntimePool

func NewCustomReusableCadenceRuntimePool(
	poolSize int,
	chain flow.Chain,
	config runtime.Config,
	newCustomRuntime CadenceRuntimeConstructor,
) ReusableCadenceRuntimePool

func NewReusableCadenceRuntimePool

func NewReusableCadenceRuntimePool(
	poolSize int,
	chain flow.Chain,
	config runtime.Config,
) ReusableCadenceRuntimePool

func (ReusableCadenceRuntimePool) Borrow

func (ReusableCadenceRuntimePool) Return

type ReusableCadenceScriptRuntime

type ReusableCadenceScriptRuntime struct {
	*ReusableCadenceRuntime
}

ReusableCadenceScriptRuntime is a wrapper around ReusableCadenceRuntime that is meant to be used in scripts. see: ReusableCadenceRuntime

func (ReusableCadenceScriptRuntime) InvokeContractFunction

func (reusable ReusableCadenceScriptRuntime) InvokeContractFunction(
	contractLocation common.AddressLocation,
	functionName string,
	arguments []cadence.Value,
	argumentTypes []sema.Type,
) (
	cadence.Value,
	error,
)

func (ReusableCadenceScriptRuntime) ReadStored

func (reusable ReusableCadenceScriptRuntime) ReadStored(
	address common.Address,
	path cadence.Path,
) (
	cadence.Value,
	error,
)

type ReusableCadenceTransactionRuntime

type ReusableCadenceTransactionRuntime struct {
	*ReusableCadenceRuntime
}

ReusableCadenceTransactionRuntime is a wrapper around ReusableCadenceRuntime that is meant to be used in transactions. see: ReusableCadenceRuntime

func (ReusableCadenceTransactionRuntime) InvokeContractFunction

func (reusable ReusableCadenceTransactionRuntime) InvokeContractFunction(
	contractLocation common.AddressLocation,
	functionName string,
	arguments []cadence.Value,
	argumentTypes []sema.Type,
) (
	cadence.Value,
	error,
)

func (ReusableCadenceTransactionRuntime) ReadStored

func (reusable ReusableCadenceTransactionRuntime) ReadStored(
	address common.Address,
	path cadence.Path,
) (
	cadence.Value,
	error,
)

type SwappableEnvironment

type SwappableEnvironment struct {
	environment.Environment
}

SwappableEnvironment is a wrapper type that extends the functionality of environment.Environment. It is designed to allow dynamic replacement of the underlying environment implementation.

type WrappedCadenceExecutor

type WrappedCadenceExecutor struct {
	runtime.Executor
}

func (WrappedCadenceExecutor) Execute

func (we WrappedCadenceExecutor) Execute() error

func (WrappedCadenceExecutor) Preprocess

func (we WrappedCadenceExecutor) Preprocess() error

func (WrappedCadenceExecutor) Result

func (we WrappedCadenceExecutor) Result() (cadence.Value, error)

type WrappedCadenceRuntime

type WrappedCadenceRuntime struct {
	runtime.Runtime
}

WrappedCadenceRuntime wraps cadence runtime to handle errors. Errors from cadence runtime should be handled with `errors.HandleRuntimeError` before the FVM can understand them. Handling all possible locations, where the error could be coming from, here, makes it impossible to forget to handle the error.

func (WrappedCadenceRuntime) ExecuteScript

func (WrappedCadenceRuntime) ExecuteTransaction

func (wr WrappedCadenceRuntime) ExecuteTransaction(s runtime.Script, c runtime.Context) error

func (WrappedCadenceRuntime) InvokeContractFunction

func (wr WrappedCadenceRuntime) InvokeContractFunction(
	contractLocation common.AddressLocation,
	functionName string,
	arguments []cadence.Value,
	argumentTypes []sema.Type,
	context runtime.Context,
) (cadence.Value, error)

func (WrappedCadenceRuntime) NewContractFunctionExecutor

func (wr WrappedCadenceRuntime) NewContractFunctionExecutor(
	contractLocation common.AddressLocation,
	functionName string,
	arguments []cadence.Value,
	argumentTypes []sema.Type,
	context runtime.Context,
) runtime.Executor

func (WrappedCadenceRuntime) NewScriptExecutor

func (wr WrappedCadenceRuntime) NewScriptExecutor(s runtime.Script, c runtime.Context) runtime.Executor

func (WrappedCadenceRuntime) NewTransactionExecutor

func (wr WrappedCadenceRuntime) NewTransactionExecutor(s runtime.Script, c runtime.Context) runtime.Executor

func (WrappedCadenceRuntime) ParseAndCheckProgram

func (wr WrappedCadenceRuntime) ParseAndCheckProgram(source []byte, context runtime.Context) (*interpreter.Program, error)

func (WrappedCadenceRuntime) ReadStored

func (wr WrappedCadenceRuntime) ReadStored(address common.Address, path cadence.Path, context runtime.Context) (cadence.Value, error)

func (WrappedCadenceRuntime) Storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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