vm

package
v0.0.0-test-arm64 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateRewards

func ValidateRewards(rewards []types.AnyReward) error

ValidateRewards syntactically validates rewards.

Types

type ApplyContext

type ApplyContext struct {
	Layer types.LayerID
}

ApplyContext has information on layer and block id.

type Config

type Config struct {
	GasLimit          uint64
	GenesisID         types.Hash20
	StorageCostFactor uint64 `mapstructure:"vm-storage-cost-factor"`
}

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 log.Log) 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.Database, 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(lctx ApplyContext, txs []types.Transaction, blockRewards []types.AnyReward) ([]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
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