emulator

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0, BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(store kv.KVStore, chainID uint16, gasLimit, timestamp uint64, alloc core.GenesisAlloc)

Init initializes the EVM state with the provided genesis allocation parameters

Types

type BlockchainDB

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

func NewBlockchainDB

func NewBlockchainDB(store kv.KVStore) *BlockchainDB

func (*BlockchainDB) AddBlock

func (bc *BlockchainDB) AddBlock(header *types.Header)

func (*BlockchainDB) AddTransaction

func (bc *BlockchainDB) AddTransaction(tx *types.Transaction, receipt *types.Receipt, timestamp uint64)

func (*BlockchainDB) GetBlockByHash

func (bc *BlockchainDB) GetBlockByHash(hash common.Hash) *types.Block

func (*BlockchainDB) GetBlockByNumber

func (bc *BlockchainDB) GetBlockByNumber(blockNumber *big.Int) *types.Block

func (*BlockchainDB) GetBlockHashByBlockNumber

func (bc *BlockchainDB) GetBlockHashByBlockNumber(blockNumber *big.Int) common.Hash

func (*BlockchainDB) GetBlockNumberByBlockHash

func (bc *BlockchainDB) GetBlockNumberByBlockHash(hash common.Hash) *big.Int

func (*BlockchainDB) GetBlockNumberByTxHash

func (bc *BlockchainDB) GetBlockNumberByTxHash(txHash common.Hash) *big.Int

func (*BlockchainDB) GetChainID

func (bc *BlockchainDB) GetChainID() uint16

func (*BlockchainDB) GetCurrentBlock

func (bc *BlockchainDB) GetCurrentBlock() *types.Block

func (*BlockchainDB) GetGasLimit

func (bc *BlockchainDB) GetGasLimit() uint64

func (*BlockchainDB) GetHeaderByBlockNumber

func (bc *BlockchainDB) GetHeaderByBlockNumber(blockNumber *big.Int) *types.Header

func (*BlockchainDB) GetHeaderByHash

func (bc *BlockchainDB) GetHeaderByHash(hash common.Hash) *types.Header

func (*BlockchainDB) GetNumber

func (bc *BlockchainDB) GetNumber() *big.Int

func (*BlockchainDB) GetReceiptByBlockNumber

func (bc *BlockchainDB) GetReceiptByBlockNumber(blockNumber *big.Int) *types.Receipt

func (*BlockchainDB) GetReceiptByTxHash

func (bc *BlockchainDB) GetReceiptByTxHash(txHash common.Hash) *types.Receipt

func (*BlockchainDB) GetTimestampByBlockNumber

func (bc *BlockchainDB) GetTimestampByBlockNumber(blockNumber *big.Int) uint64

func (*BlockchainDB) GetTransactionByBlockNumber

func (bc *BlockchainDB) GetTransactionByBlockNumber(blockNumber *big.Int) *types.Transaction

func (*BlockchainDB) GetTransactionByHash

func (bc *BlockchainDB) GetTransactionByHash(txHash common.Hash) *types.Transaction

func (*BlockchainDB) Init

func (bc *BlockchainDB) Init(chainID uint16, gasLimit, timestamp uint64)

func (*BlockchainDB) Initialized

func (bc *BlockchainDB) Initialized() bool

func (*BlockchainDB) SetChainID

func (bc *BlockchainDB) SetChainID(chainID uint16)

func (*BlockchainDB) SetGasLimit

func (bc *BlockchainDB) SetGasLimit(gas uint64)

func (*BlockchainDB) SetNumber

func (bc *BlockchainDB) SetNumber(n *big.Int)

type BufferedStateDB

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

BufferedStateDB is a wrapper for StateDB that writes all mutations into an in-memory buffer, leaving the original state unmodified until the mutations are applied manually with Commit().

func NewBufferedStateDB

func NewBufferedStateDB(base *StateDB) *BufferedStateDB

func (*BufferedStateDB) Commit

func (b *BufferedStateDB) Commit()

func (*BufferedStateDB) StateDB

func (b *BufferedStateDB) StateDB() *StateDB

type EVMEmulator

type EVMEmulator struct {
	IEVMBackend vm.ISCPBackend
	// contains filtered or unexported fields
}

func NewEVMEmulator

func NewEVMEmulator(store kv.KVStore, timestamp uint64, backend vm.ISCPBackend) *EVMEmulator

func (*EVMEmulator) BlockchainDB

func (e *EVMEmulator) BlockchainDB() *BlockchainDB

func (*EVMEmulator) CallContract

func (e *EVMEmulator) CallContract(call ethereum.CallMsg) ([]byte, error)

CallContract executes a contract call, without committing changes to the state

func (*EVMEmulator) ChainContext

func (e *EVMEmulator) ChainContext() core.ChainContext

func (*EVMEmulator) EstimateGas

func (e *EVMEmulator) EstimateGas(call ethereum.CallMsg) (uint64, error)

EstimateGas executes the requested code against the current state and returns the used amount of gas, discarding state changes

func (*EVMEmulator) FilterLogs

func (e *EVMEmulator) FilterLogs(query *ethereum.FilterQuery) []*types.Log

FilterLogs executes a log filter operation, blocking during execution and returning all the results in one batch.

func (*EVMEmulator) GasLimit

func (e *EVMEmulator) GasLimit() uint64

func (*EVMEmulator) GetIEVMBackend

func (e *EVMEmulator) GetIEVMBackend() vm.ISCPBackend

func (*EVMEmulator) PendingHeader

func (e *EVMEmulator) PendingHeader() *types.Header

func (*EVMEmulator) SendTransaction

func (e *EVMEmulator) SendTransaction(tx *types.Transaction) (*types.Receipt, error)

SendTransaction updates the pending block to include the given transaction. It returns an error if the transaction is invalid.

func (*EVMEmulator) Signer

func (e *EVMEmulator) Signer() types.Signer

func (*EVMEmulator) StateDB

func (e *EVMEmulator) StateDB() *StateDB

type StateDB

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

StateDB implements vm.StateDB with a kv.KVStore as backend

func NewStateDB

func NewStateDB(store kv.KVStore) *StateDB

func (*StateDB) AddAddressToAccessList

func (s *StateDB) AddAddressToAccessList(addr common.Address)

AddAddressToAccessList adds the given address to the access list. This operation is safe to perform even if the feature/fork is not active yet

func (*StateDB) AddBalance

func (s *StateDB) AddBalance(addr common.Address, amount *big.Int)

func (*StateDB) AddLog

func (s *StateDB) AddLog(log *types.Log)

func (*StateDB) AddPreimage

func (s *StateDB) AddPreimage(common.Hash, []byte)

func (*StateDB) AddRefund

func (s *StateDB) AddRefund(n uint64)

func (*StateDB) AddSlotToAccessList

func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash)

AddSlotToAccessList adds the given (address,slot) to the access list. This operation is safe to perform even if the feature/fork is not active yet

func (*StateDB) AddressInAccessList

func (s *StateDB) AddressInAccessList(addr common.Address) bool

func (*StateDB) Buffered

func (s *StateDB) Buffered() *BufferedStateDB

func (*StateDB) CreateAccount

func (s *StateDB) CreateAccount(addr common.Address)

func (*StateDB) Empty

func (s *StateDB) Empty(addr common.Address) bool

Empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).

func (*StateDB) Exist

func (s *StateDB) Exist(addr common.Address) bool

Exist reports whether the given account exists in state. Notably this should also return true for suicided accounts.

func (*StateDB) ForEachStorage

func (s *StateDB) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) error

func (*StateDB) GetBalance

func (s *StateDB) GetBalance(addr common.Address) *big.Int

func (*StateDB) GetCode

func (s *StateDB) GetCode(addr common.Address) []byte

func (*StateDB) GetCodeHash

func (s *StateDB) GetCodeHash(addr common.Address) common.Hash

func (*StateDB) GetCodeSize

func (s *StateDB) GetCodeSize(addr common.Address) int

func (*StateDB) GetCommittedState

func (s *StateDB) GetCommittedState(addr common.Address, key common.Hash) common.Hash

func (*StateDB) GetLogs

func (s *StateDB) GetLogs(hash common.Hash) []*types.Log

func (*StateDB) GetNonce

func (s *StateDB) GetNonce(addr common.Address) uint64

func (*StateDB) GetRefund

func (s *StateDB) GetRefund() uint64

func (*StateDB) GetState

func (s *StateDB) GetState(addr common.Address, key common.Hash) common.Hash

func (*StateDB) HasSuicided

func (s *StateDB) HasSuicided(common.Address) bool

func (*StateDB) PrepareAccessList

func (s *StateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList)

func (*StateDB) RevertToSnapshot

func (s *StateDB) RevertToSnapshot(int)

func (*StateDB) SetCode

func (s *StateDB) SetCode(addr common.Address, code []byte)

func (*StateDB) SetNonce

func (s *StateDB) SetNonce(addr common.Address, n uint64)

func (*StateDB) SetState

func (s *StateDB) SetState(addr common.Address, key, value common.Hash)

func (*StateDB) SlotInAccessList

func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressOk, slotOk bool)

func (*StateDB) Snapshot

func (s *StateDB) Snapshot() int

func (*StateDB) SubBalance

func (s *StateDB) SubBalance(addr common.Address, amount *big.Int)

func (*StateDB) SubRefund

func (s *StateDB) SubRefund(n uint64)

func (*StateDB) Suicide

func (s *StateDB) Suicide(addr common.Address) bool

Jump to

Keyboard shortcuts

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