vm

package
v1.7.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	GasLimit  uint64
	GenesisID types.Hash20
}

Config defines the configuration options for vm.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default RewardConfig.

type Opt

type Opt func(*VM)

Opt is for changing VM during initialization.

func WithConfig

func WithConfig(cfg Config) Opt

WithConfig updates config on the vm.

func WithLogger

func WithLogger(logger *zap.Logger) Opt

WithLogger sets logger for VM.

type Request

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

Request used to implement 2-step validation flow. After Parse is executed - conservative cache may do validation and skip Verify if transaction can't be executed.

func (*Request) Parse

func (r *Request) Parse() (*core.Header, error)

Parse header from the raw transaction.

func (*Request) Verify

func (r *Request) Verify() bool

Verify transaction. Will panic if called without Parse completing successfully.

type VM

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

VM handles modifications to the account state.

func New

func New(db sql.StateDatabase, opts ...Opt) *VM

New returns VM instance.

func (*VM) AccountExists

func (v *VM) AccountExists(address core.Address) (bool, error)

AccountExists returns true if the address exists, spawned or not.

func (*VM) Apply

func (v *VM) Apply(
	layer types.LayerID,
	txs []types.Transaction,
	blockRewards []types.CoinbaseReward,
) ([]types.Transaction, []types.TransactionWithResult, error)

Apply transactions.

func (*VM) ApplyGenesis

func (v *VM) ApplyGenesis(genesis []types.Account) error

ApplyGenesis saves list of accounts for genesis.

func (*VM) GetAllAccounts

func (v *VM) GetAllAccounts() ([]*types.Account, error)

GetAllAccounts returns a dump of all accounts in global state.

func (*VM) GetBalance

func (v *VM) GetBalance(address types.Address) (uint64, error)

GetBalance returns balance for an address.

func (*VM) GetLayerApplied

func (v *VM) GetLayerApplied(tid types.TransactionID) (types.LayerID, error)

GetLayerApplied returns layer of the applied transaction.

func (*VM) GetLayerStateRoot

func (v *VM) GetLayerStateRoot(lid types.LayerID) (types.Hash32, error)

GetLayerStateRoot returns the state root at a given layer.

func (*VM) GetNonce

func (v *VM) GetNonce(address core.Address) (core.Nonce, error)

GetNonce returns expected next nonce for the address.

func (*VM) GetStateRoot

func (v *VM) GetStateRoot() (types.Hash32, error)

GetStateRoot gets the current state root hash.

func (*VM) Revert

func (v *VM) Revert(lid types.LayerID) error

Revert all changes that we made after the layer.

func (*VM) Validation

func (v *VM) Validation(raw types.RawTx) system.ValidationRequest

Validation initializes validation request.

Directories

Path Synopsis
cmd
gen
nolint
nolint
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
sdk
templates
multisig
nolint
nolint
vault
nolint
nolint
vesting
nolint
nolint
wallet
nolint
nolint

Jump to

Keyboard shortcuts

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