vm

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: GPL-3.0, LGPL-3.0 Imports: 57 Imported by: 0

Documentation

Overview

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

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

func FormatLocalAddress added in v0.15.3

func FormatLocalAddress(ctx *snow.Context, addr ids.ShortID) (string, error)

FormatLocalAddress takes in a raw address and produces the formatted address

func ParseAddress added in v0.15.3

func ParseAddress(ctx *snow.Context, addrStr string) (ids.ID, ids.ShortID, error)

ParseAddress takes in an address and produces the ID of the chain it's for the ID of the address

func ParseLocalAddress added in v0.15.3

func ParseLocalAddress(ctx *snow.Context, addrStr string) (ids.ShortID, error)

ParseLocalAddress takes in an address for this chain and produces the ID

func ParseServiceAddress added in v0.15.3

func ParseServiceAddress(ctx *snow.Context, addrStr string) (ids.ShortID, error)

ParseServiceAddress get address ID from address string, being it either localized (using address manager, doing also components validations), or not localized. If both attempts fail, reports error from localized address parsing

Types

type AvaxAPI added in v0.15.3

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

AvaxAPI offers Avalanche network related API methods

func (*AvaxAPI) GetAtomicTx added in v0.15.3

func (service *AvaxAPI) GetAtomicTx(r *http.Request, args *api.GetTxArgs, reply *FormattedTx) error

GetAtomicTx returns the specified transaction

func (*AvaxAPI) GetAtomicTxStatus added in v0.15.3

func (service *AvaxAPI) GetAtomicTxStatus(r *http.Request, args *api.JSONTxID, reply *client.GetAtomicTxStatusReply) error

GetAtomicTxStatus returns the status of the specified transaction

func (*AvaxAPI) GetUTXOs added in v0.15.3

func (service *AvaxAPI) GetUTXOs(r *http.Request, args *api.GetUTXOsArgs, reply *api.GetUTXOsReply) error

GetUTXOs gets all utxos for passed in addresses

func (*AvaxAPI) IssueTx added in v0.15.3

func (service *AvaxAPI) IssueTx(r *http.Request, args *api.FormattedTx, response *api.JSONTxID) error

func (*AvaxAPI) Version added in v0.15.3

func (service *AvaxAPI) Version(r *http.Request, _ *struct{}, reply *VersionReply) error

ClientVersion returns the version of the VM running

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 FormattedTx added in v0.15.3

type FormattedTx struct {
	api.FormattedTx
	BlockHeight *json.Uint64 `json:"blockHeight,omitempty"`
}

type VM

type VM struct {
	extension.InnerVM
	Ctx *snow.Context

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

	AtomicMempool *txpool.Mempool

	// [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

	AtomicTxPushGossiper *avalanchegossip.PushGossiper[*atomic.Tx]
	AtomicTxPullGossiper avalanchegossip.Gossiper
	// contains filtered or unexported fields
}

func WrapVM

func WrapVM(vm extension.InnerVM) *VM

func (*VM) BuildBlock added in v0.15.3

func (vm *VM) BuildBlock(ctx context.Context) (snowman.Block, error)

func (*VM) BuildBlockWithContext added in v0.15.3

func (vm *VM) BuildBlockWithContext(ctx context.Context, proposerVMBlockCtx *block.Context) (snowman.Block, error)

func (*VM) Clock added in v0.15.3

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

Clock implements the secp256k1fx interface

func (*VM) CodecRegistry added in v0.15.3

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

CodecRegistry implements the secp256k1fx interface

func (*VM) CreateHandlers added in v0.15.3

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

func (*VM) CurrentRules added in v0.15.3

func (vm *VM) CurrentRules() extras.Rules

CurrentRules returns the chain rules for the current block.

func (*VM) GetAtomicTx added in v0.15.3

func (vm *VM) GetAtomicTx(txID ids.ID) (*atomic.Tx, atomic.Status, uint64, error)

getAtomicTx returns the requested transaction, status, and height. If the status is Unknown, then the returned transaction will be nil.

func (*VM) Initialize

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

Initialize implements the snowman.ChainVM interface

func (*VM) Logger added in v0.15.3

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

Logger implements the secp256k1fx interface

func (*VM) NewExportTx added in v0.15.3

func (vm *VM) NewExportTx(
	assetID ids.ID,
	amount uint64,
	chainID ids.ID,
	to ids.ShortID,
	baseFee *big.Int,
	keys []*secp256k1.PrivateKey,
) (*atomic.Tx, error)

newExportTx returns a new ExportTx

func (*VM) NewImportTx added in v0.15.3

func (vm *VM) NewImportTx(
	chainID ids.ID,
	to common.Address,
	baseFee *big.Int,
	keys []*secp256k1.PrivateKey,
) (*atomic.Tx, error)

func (*VM) SetState added in v0.15.3

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

func (*VM) Shutdown added in v0.15.3

func (vm *VM) Shutdown(context.Context) error

type VerifierBackend

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

func NewVerifierBackend added in v0.15.3

func NewVerifierBackend(vm *VM, rules extras.Rules) *VerifierBackend

func (*VerifierBackend) SemanticVerify added in v0.15.3

func (b *VerifierBackend) SemanticVerify(tx *atomic.Tx, parent extension.ExtendedBlock, baseFee *big.Int) error

SemanticVerify checks the semantic validity of atomic transactions.

type VersionReply added in v0.15.3

type VersionReply struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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