vm

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: GPL-3.0, LGPL-3.0 Imports: 41 Imported by: 0

Documentation

Overview

Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingUTXOs = errors.New("missing UTXOs")
	ErrEmptyBlock   = errors.New("empty block")
)
View Source
var (
	ErrAssetIDMismatch         = errors.New("asset IDs in the input don't match the utxo")
	ErrConflictingAtomicInputs = errors.New("invalid block due to conflicting atomic inputs")
)

Functions

This section is empty.

Types

type BlockFetcher

type BlockFetcher interface {
	// GetExtendedBlock returns the VMBlock for the given ID or an error if the block is not found
	GetExtendedBlock(context.Context, ids.ID) (extension.ExtendedBlock, error)
	// LastAcceptedExtendedBlock returns the last accepted VM block
	LastAcceptedExtendedBlock() extension.ExtendedBlock
}

type InnerVM

type InnerVM interface {
	extension.ExtensibleVM
	avalanchecommon.VM
	block.ChainVM
	block.BuildBlockWithContextChainVM
	block.StateSyncableVM

	// TODO: remove these
	AtomicMempool() *txpool.Mempool
}

TODO: remove this InnerVM is the interface that must be implemented by the VM that's being wrapped by the extension

type SemanticVerifier

type SemanticVerifier struct {
	Backend *VerifierBackend
	Tx      *atomic.Tx
	Parent  extension.ExtendedBlock
	BaseFee *big.Int
}

SemanticVerifier is a visitor that checks the semantic validity of atomic transactions.

func (*SemanticVerifier) ExportTx

func (s *SemanticVerifier) ExportTx(utx *atomic.UnsignedExportTx) error

ExportTx verifies this transaction is valid.

func (*SemanticVerifier) ImportTx

func (s *SemanticVerifier) ImportTx(utx *atomic.UnsignedImportTx) error

ImportTx verifies this transaction is valid.

type VM

type VM struct {
	InnerVM

	// TODO: unexport these fields
	SecpCache *secp256k1.RecoverCache
	Fx        secp256k1fx.Fx

	// [atomicTxRepository] maintains two indexes on accepted atomic txs.
	// - txID to accepted atomic tx
	// - block height to list of atomic txs accepted on block at that height
	// TODO: unexport these fields
	AtomicTxRepository *atomicstate.AtomicRepository
	// [atomicBackend] abstracts verification and processing of atomic transactions
	AtomicBackend *atomicstate.AtomicBackend
	// contains filtered or unexported fields
}

func WrapVM

func WrapVM(vm InnerVM) *VM

func (*VM) Clock

func (vm *VM) Clock() *mockable.Clock

Clock implements the secp256k1fx interface

func (*VM) CodecRegistry

func (vm *VM) CodecRegistry() codec.Registry

CodecRegistry implements the secp256k1fx interface

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtx *snow.Context,
	db avalanchedatabase.Database,
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	toEngine chan<- avalanchecommon.Message,
	fxs []*avalanchecommon.Fx,
	appSender avalanchecommon.AppSender,
) error

Initialize implements the snowman.ChainVM interface

func (*VM) Logger

func (vm *VM) Logger() logging.Logger

Logger implements the secp256k1fx interface

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state snow.State) error

func (*VM) VerifyTx

func (vm *VM) VerifyTx(tx *atomic.Tx, parentHash common.Hash, baseFee *big.Int, state *state.StateDB, rules extras.Rules) error

VerifyTx verifies that [tx] is valid to be issued into a block with parent block [parentHash] and validated at state using [rules] as the current rule set. Note: VerifyTx may modify state. If state needs to be properly maintained, the caller is responsible for reverting to the correct snapshot after calling this function. If this function is called with a throwaway state, then this is not necessary. TODO: unexport this function

type VerifierBackend

type VerifierBackend struct {
	Ctx          *snow.Context
	Fx           fx.Fx
	Rules        extras.Rules
	Bootstrapped bool
	BlockFetcher BlockFetcher
	SecpCache    *secp256k1.RecoverCache
}

Jump to

Keyboard shortcuts

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