Help us shape the future of Go! Take the 2026 Go Developer Survey

computation

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: AGPL-3.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ReusableCadenceRuntimePoolSize = 1000
)

Variables

This section is empty.

Functions

func DefaultFVMOptions added in v0.32.1

func DefaultFVMOptions(chainID flow.ChainID, cadenceTracing bool, extensiveTracing bool) []fvm.Option

func NewProtocolStateWrapper added in v0.37.25

func NewProtocolStateWrapper(s protocol.State) protocol.SnapshotExecutionSubsetProvider

NewProtocolStateWrapper wraps the protocol.State input so that the AtBlockID method returns a SnapshotExecutionSubset instead of the protocol.Snapshot interface. This is used in the FVM for execution.

Types

type ComputationConfig added in v0.28.0

type ComputationConfig struct {
	query.QueryConfig
	CadenceTracing       bool
	ExtensiveTracing     bool
	DerivedDataCacheSize uint
	MaxConcurrency       int

	// When NewCustomVirtualMachine is nil, the manager will create a standard
	// fvm virtual machine via fvm.NewVirtualMachine.  Otherwise, the manager
	// will create a virtual machine using this function.
	//
	// Note that this is primarily used for testing.
	NewCustomVirtualMachine func() fvm.VM
}

type ComputationManager

type ComputationManager interface {
	ExecuteScript(
		ctx context.Context,
		script []byte,
		arguments [][]byte,
		blockHeader *flow.Header,
		snapshot snapshot.StorageSnapshot,
	) (
		[]byte,
		uint64,
		error,
	)

	ComputeBlock(
		ctx context.Context,
		parentBlockExecutionResultID flow.Identifier,
		block *entity.ExecutableBlock,
		snapshot snapshot.StorageSnapshot,
	) (
		*execution.ComputationResult,
		error,
	)

	GetAccount(
		ctx context.Context,
		addr flow.Address,
		header *flow.Header,
		snapshot snapshot.StorageSnapshot,
	) (
		*flow.Account,
		error,
	)
}

type Manager

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

Manager manages computation and execution

func New

func New(
	logger zerolog.Logger,
	metrics module.ExecutionMetrics,
	tracer module.Tracer,
	me module.Local,
	protoState protocol.SnapshotExecutionSubsetProvider,
	vmCtx fvm.Context,
	committer computer.ViewCommitter,
	executionDataProvider provider.Provider,
	params ComputationConfig,
) (*Manager, error)

func (*Manager) ComputeBlock

func (e *Manager) ComputeBlock(
	ctx context.Context,
	parentBlockExecutionResultID flow.Identifier,
	block *entity.ExecutableBlock,
	snapshot snapshot.StorageSnapshot,
) (*execution.ComputationResult, error)

func (*Manager) ExecuteScript

func (e *Manager) ExecuteScript(
	ctx context.Context,
	code []byte,
	arguments [][]byte,
	blockHeader *flow.Header,
	snapshot snapshot.StorageSnapshot,
) ([]byte, uint64, error)

func (*Manager) GetAccount

func (e *Manager) GetAccount(
	ctx context.Context,
	address flow.Address,
	blockHeader *flow.Header,
	snapshot snapshot.StorageSnapshot,
) (
	*flow.Account,
	error,
)

func (*Manager) QueryExecutor added in v0.32.0

func (e *Manager) QueryExecutor() query.Executor

func (*Manager) VM added in v0.28.0

func (e *Manager) VM() fvm.VM

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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