vm

package
v1.23.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: BSD-3-Clause Imports: 34 Imported by: 0

Documentation

Overview

Package vm provides utilities for creating and managing virtual machines.

Index

Constants

View Source
const (
	LowGasLimit    = uint64(12_000_000)
	MediumGasLimit = uint64(15_000_000)
	HighGasLimit   = uint64(20_000_000)

	LowTargetGas    = uint64(1_500_000)
	MediumTargetGas = uint64(2_000_000)
	HighTargetGas   = uint64(5_000_000)

	NoDynamicFeesGasLimitToTargetGasFactor = uint64(10)
)

Gas limits

View Source
const (
	// ParsDefaultChainID is the default chain ID for Pars networks
	ParsDefaultChainID = 7070
	// ParsOrg is the GitHub organization for Pars
	ParsOrg = "parsdao"
	// ParsRepoName is the repository name for parsd
	ParsRepoName = "node"
)
View Source
const (
	EvmDebugConfig    = `{"log-level": "debug"}`
	EvmNonDebugConfig = `{"log-level": "info"}`
)

EVM configuration constants

View Source
const (
	NativeMint        = "Native Minting"
	ContractAllowList = "Contract Deployment Allow List"
	TxAllowList       = "Transaction Allow List"
	FeeManager        = "Manage Fee Settings"
	RewardManager     = "RewardManagerConfig"
)

Variables

View Source
var (
	Difficulty = big.NewInt(0)

	// This is the current c-chain gas config
	StarterFeeConfig = fees.DefaultFeeConfig
)
View Source
var ErrNoLuxVersion = errors.New("unable to find a compatible node version")
View Source
var OneLux = big.NewInt(1_000_000_000) // 1 LUX = 1e9 nLUX

Units

Functions

func ConfigureInitialRewardConfig

func ConfigureInitialRewardConfig(app *application.Lux) (*rewardmanager.InitialRewardConfig, error)

func CopyCustomVM

func CopyCustomVM(app *application.Lux, chainName string, vmPath string) error

func CreateCustomChainConfig added in v1.22.9

func CreateCustomChainConfig(app *application.Lux, chainName string, genesisPath, vmPath string) ([]byte, *models.Sidecar, error)

func CreateCustomSidecar

func CreateCustomSidecar(
	sc *models.Sidecar,
	app *application.Lux,
	blockchainName string,
	vmVersion string,
) (*models.Sidecar, error)

CreateCustomSidecar creates a sidecar for custom VMs

func CreateEVMGenesis

func CreateEVMGenesis(chainID *big.Int, allocations types.GenesisAlloc, timestamps map[string]uint64) map[string]interface{}

CreateEVMGenesis creates a new EVM genesis configuration

func CreateEVMGenesisWithParams

func CreateEVMGenesisWithParams(
	app *application.Lux,
	params EVMGenesisParams,
	warpInfo *warp.WarpInfo,
	addWarpRegistryToGenesis bool,
	proxyContractOwner string,
	rewardBasisPoints uint64,
	useACP99 bool,
) ([]byte, error)

CreateEVMGenesisWithParams creates EVM genesis with extended parameters

func CreateEvmConfig

func CreateEvmConfig(app *application.Lux, chainName string, genesisPath string, evmVersion string) ([]byte, *models.Sidecar, error)

func CreateEvmSidecar

func CreateEvmSidecar(
	sc *models.Sidecar,
	app *application.Lux,
	blockchainName string,
	vmVersion string,
	tokenSymbol string,
	deployInterop bool,
	sovereign bool,
	useACP99 bool,
) (*models.Sidecar, error)

CreateEvmSidecar creates a sidecar for EVM-based blockchains

func CreateParsChainConfig added in v1.23.1

func CreateParsChainConfig(
	app *application.Lux,
	chainName string,
	vmVersion string,
) ([]byte, *models.Sidecar, error)

CreateParsChainConfig creates a new Pars chain configuration

func GetLatestLuxByProtocolVersion

func GetLatestLuxByProtocolVersion(app *application.Lux, rpcVersion int, url string) (string, error)

func GetParsDescriptors added in v1.23.1

func GetParsDescriptors(app *application.Lux, vmVersion string) (
	*big.Int,
	string,
	string,
	statemachine.StateDirection,
	error,
)

GetParsDescriptors prompts for Pars chain configuration

func GetRPCProtocolVersion

func GetRPCProtocolVersion(app *application.Lux, vmType models.VMType, vmVersion string) (int, error)

func GetVMBinaryProtocolVersion

func GetVMBinaryProtocolVersion(vmBinaryPath string) (int, error)

GetVMBinaryProtocolVersion returns the protocol version for the VM binary

func PrecompileToUpgradeString

func PrecompileToUpgradeString(p Precompile) string

func PromptEVMVersion added in v1.21.40

func PromptEVMVersion(app *application.Lux, vmType models.VMType, version string) (string, error)

PromptEVMVersion prompts for Chain EVM version

func PromptInterop

func PromptInterop(app *application.Lux, vmType models.VMType, version string, chainID uint64, interop bool) (bool, error)

PromptInterop prompts for interoperability configuration

func PromptTokenSymbol

func PromptTokenSymbol(app *application.Lux, state statemachine.StateType, token string) (string, error)

PromptTokenSymbol prompts for token symbol

func PromptVMType

func PromptVMType(app *application.Lux, useEVM bool, useCustom bool, usePars bool, useSession bool) (models.VMType, error)

PromptVMType prompts the user to select a VM type

Types

type AllocationEntry added in v1.9.7

type AllocationEntry struct {
	Address string
	Balance string
}

AllocationEntry represents an allocation entry in genesis

type AllowList

type AllowList struct {
	AdminAddresses   []common.Address
	ManagerAddresses []common.Address
	EnabledAddresses []common.Address
}

AllowList represents an allow list configuration

func GenerateAllowList

func GenerateAllowList(
	app *application.Lux,
	config AllowList,
	action string,
	vmVersion string,
) (AllowList, bool, error)

GenerateAllowList prompts the user to configure an allow list

type DefaultsKind

type DefaultsKind int

DefaultsKind represents the type of defaults to use for VM configuration

const (
	// NoDefaults means no default configuration will be applied
	NoDefaults DefaultsKind = iota
	// TestDefaults means test-friendly defaults will be applied
	TestDefaults
	// ProductionDefaults means production-ready defaults will be applied
	ProductionDefaults
)

func PromptDefaults

func PromptDefaults(app *application.Lux, defaultsKind DefaultsKind, vmType models.VMType) (DefaultsKind, error)

PromptDefaults prompts the user for default configuration

type EVMGenesisParams added in v1.21.40

type EVMGenesisParams struct {
	UseDefaults         bool
	Interop             bool
	UseWarp             bool
	UseExternalGasToken bool
	ChainID             uint64
	TokenSymbol         string
	Allocations         []AllocationEntry
}

EVMGenesisParams contains parameters for Chain EVM genesis

func PromptEVMGenesisParams added in v1.21.40

func PromptEVMGenesisParams(
	app *application.Lux,
	params EVMGenesisParams,
	vmType models.VMType,
	version string,
	chainID uint64,
	symbol string,
	interop bool,
) (*EVMGenesisParams, error)

PromptEVMGenesisParams prompts for Chain EVM genesis parameters

type ParsGenesisConfig added in v1.23.1

type ParsGenesisConfig struct {
	ChainID uint64 `json:"chainId"`
	Network struct {
		RPCAddr   string `json:"rpcAddr"`
		P2PAddr   string `json:"p2pAddr"`
		ChainID   uint64 `json:"chainId"`
		NetworkID uint64 `json:"networkId"`
	} `json:"network"`
	EVM struct {
		Enabled     bool `json:"enabled"`
		Precompiles struct {
			MLDSA    string `json:"mldsa"`
			MLKEM    string `json:"mlkem"`
			BLS      string `json:"bls"`
			Ringtail string `json:"ringtail"`
			FHE      string `json:"fhe"`
		} `json:"precompiles"`
	} `json:"evm"`
	Pars struct {
		Enabled bool `json:"enabled"`
		Storage struct {
			MaxSize       int64 `json:"maxSize"`
			RetentionDays int   `json:"retentionDays"`
		} `json:"storage"`
		Onion struct {
			HopCount int `json:"hopCount"`
		} `json:"onion"`
		Session struct {
			IDPrefix string `json:"idPrefix"`
		} `json:"session"`
	} `json:"pars"`
	Warp struct {
		Enabled     bool   `json:"enabled"`
		LuxEndpoint string `json:"luxEndpoint"`
	} `json:"warp"`
	Crypto struct {
		GPUEnabled      bool   `json:"gpuEnabled"`
		SignatureScheme string `json:"signatureScheme"`
		KEMScheme       string `json:"kemScheme"`
		ThresholdScheme string `json:"thresholdScheme"`
	} `json:"crypto"`
	Consensus struct {
		Engine      string `json:"engine"`
		BlockTimeMs int    `json:"blockTimeMs"`
	} `json:"consensus"`
}

ParsGenesisConfig represents the genesis configuration for a Pars chain

func DefaultParsGenesis added in v1.23.1

func DefaultParsGenesis(chainID uint64) *ParsGenesisConfig

DefaultParsGenesis returns the default genesis configuration for Pars

type Precompile

type Precompile string

Jump to

Keyboard shortcuts

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