vm

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAddress

func GenerateAddress() common.Address

GenerateAddress generates an Ethereum address.

func GenerateHash

func GenerateHash() common.Hash

GenerateHash generates an Ethereum hash.

func NewAddrKey

func NewAddrKey() (common.Address, *ethsecp256k1.PrivKey)

NewAddrKey generates an Ethereum address and its corresponding private key.

Types

type AccessList2

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

AccessList2 has the same functionality as the accessList in go-ethereum. But different implementation in order to perform a deep copy to match with the implementation of Snapshot and RevertToSnapshot.

func (*AccessList2) AddAddress

func (al *AccessList2) AddAddress(address common.Address) bool

AddAddress adds an address to the access list, and returns 'true' if the operation caused a change (addr was not previously in the list).

func (*AccessList2) AddSlot

func (al *AccessList2) AddSlot(address common.Address, slot common.Hash) (addrChange bool, slotChange bool)

AddSlot adds the specified (addr, slot) combo to the access list. Return values are: - address added - slot added

func (*AccessList2) CloneElements

func (al *AccessList2) CloneElements() map[common.Address]map[common.Hash]bool

func (*AccessList2) Contains

func (al *AccessList2) Contains(address common.Address, slot common.Hash) (addressPresent bool, slotPresent bool)

Contains checks if a slot within an account is present in the access list, returning separate flags for the presence of the account and the slot respectively.

func (*AccessList2) ContainsAddress

func (al *AccessList2) ContainsAddress(address common.Address) bool

ContainsAddress returns true if the address is in the access list.

func (*AccessList2) Copy

func (al *AccessList2) Copy() *AccessList2

Copy creates an independent copy of an AccessList2.

func (*AccessList2) DeleteAddress

func (al *AccessList2) DeleteAddress(address common.Address)

DeleteAddress removes an address from the access list.

func (*AccessList2) DeleteSlot

func (al *AccessList2) DeleteSlot(address common.Address, slot common.Hash)

DeleteSlot removes an (address, slot)-tuple from the access list.

type AccountTracker

type AccountTracker map[common.Address]bool

func (AccountTracker) Add

func (t AccountTracker) Add(addr common.Address)

func (AccountTracker) Copy

func (t AccountTracker) Copy() AccountTracker

func (AccountTracker) Delete

func (t AccountTracker) Delete(addr common.Address)

func (AccountTracker) Has

func (t AccountTracker) Has(addr common.Address) bool

type CStateDB

type CStateDB interface {
	corevm.StateDB

	GetTransactionLogs() []*ethtypes.Log

	CommitMultiStore(deleteEmptyObjects bool) error
	IntermediateRoot(deleteEmptyObjects bool) (common.Hash, error)
	GetCurrentContext() sdk.Context

	DestroyAccount(acc common.Address)

	Selfdestruct6780(address common.Address)
	GetTransientState(addr common.Address, key common.Hash) common.Hash
	SetTransientState(addr common.Address, key, value common.Hash)

	ForTest_AddAddressToSelfDestructedList(addr common.Address)
	ForTest_SetLogs(logs Logs)
	ForTest_CountRecordsTransientStorage() int
	ForTest_CloneTransientStorage() TransientStorage
	ForTest_CloneAccessList() *AccessList2
	ForTest_CloneTouched() AccountTracker
	ForTest_CloneSelfDestructed() AccountTracker
	ForTest_GetSnapshots() []RtStateDbSnapshot
	ForTest_ToggleStateDBPreventCommit(prevent bool)
	ForTest_GetOriginalContext() sdk.Context
	ForTest_GetEvmDenom() string
	ForTest_IsCommitted() bool
}

CStateDB is an interface that extends the vm.StateDB interface with additional methods. The implementation is Context-based, and the name CStateDB stands for Context-based-StateDB.

func NewStateDB

func NewStateDB(
	ctx sdk.Context,
	coinbase common.Address,
	ethKeeper EvmKeeper,
	accountKeeper authkeeper.AccountKeeper,
	bankKeeper bankkeeper.Keeper,
) CStateDB

type EVMConfig

type EVMConfig struct {
	Params      evmtypes.Params
	ChainConfig *ethparams.ChainConfig
	CoinBase    common.Address
	BaseFee     *big.Int
	NoBaseFee   bool
}

EVMConfig contains the needed information to initialize core VM

type EvmKeeper

type EvmKeeper interface {
	GetParams(ctx sdk.Context) (params evmtypes.Params)
	GetEip155ChainId(ctx sdk.Context) evmtypes.Eip155ChainId
	ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool)
	DeleteCodeHash(ctx sdk.Context, addr []byte)
	SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte)
	GetCodeHash(ctx sdk.Context, addr []byte) common.Hash
	GetCode(ctx sdk.Context, codeHash common.Hash) []byte
	SetCode(ctx sdk.Context, codeHash, code []byte)
	SetCodeHash(ctx sdk.Context, addr common.Address, codeHash common.Hash)
	GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash
	IsEmptyAccount(ctx sdk.Context, addr common.Address) bool
}

type Logs

type Logs []*ethtypes.Log

func (Logs) Copy

func (l Logs) Copy() Logs

type RtStateDbSnapshot

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

RtStateDbSnapshot is a snapshot of the state of the entire state database at a particular point in time.

CONTRACT: snapshot & revert must perform deep clone of the underlying state.

func (RtStateDbSnapshot) GetID

func (s RtStateDbSnapshot) GetID() int

func (RtStateDbSnapshot) WriteChanges

func (s RtStateDbSnapshot) WriteChanges()

WriteChanges commit any changes made to the snapshot cache-multi-store to the parent cache-multi-store.

type TransientStorage

type TransientStorage interface {
	Set(addr common.Address, key, value common.Hash)
	Get(addr common.Address, key common.Hash) common.Hash
	Clone() TransientStorage
	Size() int
}

TransientStorage is an interface for the transient storage. We use this interface instead of export the un-exported type transientStorage because we would like to avoid changing much of the existing code so that we can compare the code change easily.

type TxConfig

type TxConfig struct {
	BlockHash common.Hash
	TxHash    common.Hash
	TxIndex   uint
	LogIndex  uint   // the index of next log within current block
	TxType    *uint8 // transaction type, optionally provided
}

TxConfig read-only information of current tx

Jump to

Keyboard shortcuts

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