vm

package
v1.21.46 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: GPL-3.0, LGPL-3.0 Imports: 58 Imported by: 0

Documentation

Overview

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

Copyright (C) 2019-2025, Lux Industries, 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

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

FormatLocalAddress takes in a raw address and produces the formatted address

func ParseAddress

func ParseAddress(ctx *consensusctx.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

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

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

func ParseServiceAddress

func ParseServiceAddress(ctx *consensusctx.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 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

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

type LuxAPI

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

LuxAPI offers Lux network related API methods

func (*LuxAPI) GetAtomicTx

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

GetAtomicTx returns the specified transaction

func (*LuxAPI) GetAtomicTxStatus

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

GetAtomicTxStatus returns the status of the specified transaction

func (*LuxAPI) GetUTXOs

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

GetUTXOs gets all utxos for passed in addresses

func (*LuxAPI) IssueTx

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

func (*LuxAPI) Version

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

ClientVersion returns the version of the VM running

type VM

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

	// TODO: unexport these fields
	SecpCache secp256k1.RecoverCacheType
	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 *luxdssip.PushGossiper[*atomic.Tx]
	AtomicTxPullGossiper luxdssip.Gossiper
	// contains filtered or unexported fields
}

func WrapVM

func WrapVM(vm extension.InnerVM) *VM

func (*VM) BuildBlock

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

func (*VM) BuildBlockWithContext

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

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) CreateHandlers

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

func (*VM) CurrentRules

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

CurrentRules returns the chain rules for the current block.

func (*VM) GetAtomicTx

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,
	chainCtxIntf interface{},
	dbIntf interface{},
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	toEngineIntf interface{},
	fxsIntf []interface{},
	appSenderIntf interface{},
) error

Initialize implements the quasarman.ChainVM interface

func (*VM) Logger

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

Logger implements the secp256k1fx interface

func (*VM) NewExportTx

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

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

func (*VM) SetState

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

func (*VM) Shutdown

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

type VerifierBackend

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

func NewVerifierBackend

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

func (*VerifierBackend) SemanticVerify

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

SemanticVerify checks the semantic validity of atomic transactions.

type VersionReply

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