runtime

package
v0.0.0-...-a20f792 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanTransfer

func CanTransfer(db vm.StateDB, addr common.Address, amount *uint256.Int) bool

CanTransfer checks whether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.

func NewEnv

func NewEnv(cfg *Config, stateDB *state.StateDB, record *vm.RecordToInitiateState) *vm.EVM

func SetDefaults

func SetDefaults(cfg *Config)

sets defaults on the config

func Transfer

func Transfer(db vm.StateDB, sender, recipient common.Address, amount *uint256.Int)

Transfer subtracts amount from sender and adds amount to recipient using the given Db

Types

type Config

type Config struct {
	ChainConfig *params.ChainConfig
	Difficulty  *big.Int
	Origin      common.Address
	Coinbase    common.Address
	BlockNumber *big.Int
	Time        uint64
	GasLimit    uint64
	GasPrice    *big.Int
	Value       *big.Int
	Debug       bool
	EVMConfig   vm.Config
	BaseFee     *big.Int
	BlobBaseFee *big.Int
	BlobHashes  []common.Hash
	BlobFeeCap  *big.Int
	Random      *common.Hash
	RPCEndpoint string
	ErrorRatio  float64

	GetHashFn func(n uint64) common.Hash
}

Config is a basic type specifying certain configuration flags for running the EVM.

type ExecutionResult

type ExecutionResult struct {
	Ret          []byte
	GasUsed      uint64
	Refund       uint64
	IntrinsicGas uint64
	Record       *RecordToInitiateState
}

func Execute

func Execute(
	address common.Address,
	originBalance *big.Int,
	code, input []byte,
	cfg *Config,
	state *state.StateDB,
	recordToInit *ourVm.RecordToInitiateState,
) (*ExecutionResult, error)

Execute executes the code using the input as call data during the execution. It returns the EVM's return value, the new state and an error if it failed.

Execute sets up an in-memory, temporary, environment for the execution of the given code. It makes sure that it's restored to its original state afterwards. In order to get an appropiate gas estimation, this should be run twice one for generating the access lists, take a look to Simulate from simulator package

type RecordToInitiateState

type RecordToInitiateState struct {
	AddressCodeSet    map[common.Address]struct{}
	AddressBalanceSet map[common.Address]struct{}
	AddressStorageSet map[string]common.Hash
	AccessList        types.AccessList
}

Jump to

Keyboard shortcuts

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