github.com/ethereum/go-ethereum@v1.16.1/core/vm/interface.go (about) 1 // Copyright 2016 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package vm 18 19 import ( 20 "github.com/ethereum/go-ethereum/common" 21 "github.com/ethereum/go-ethereum/core/state" 22 "github.com/ethereum/go-ethereum/core/stateless" 23 "github.com/ethereum/go-ethereum/core/tracing" 24 "github.com/ethereum/go-ethereum/core/types" 25 "github.com/ethereum/go-ethereum/params" 26 "github.com/ethereum/go-ethereum/trie/utils" 27 "github.com/holiman/uint256" 28 ) 29 30 // StateDB is an EVM database for full state querying. 31 type StateDB interface { 32 CreateAccount(common.Address) 33 CreateContract(common.Address) 34 35 SubBalance(common.Address, *uint256.Int, tracing.BalanceChangeReason) uint256.Int 36 AddBalance(common.Address, *uint256.Int, tracing.BalanceChangeReason) uint256.Int 37 GetBalance(common.Address) *uint256.Int 38 39 GetNonce(common.Address) uint64 40 SetNonce(common.Address, uint64, tracing.NonceChangeReason) 41 42 GetCodeHash(common.Address) common.Hash 43 GetCode(common.Address) []byte 44 45 // SetCode sets the new code for the address, and returns the previous code, if any. 46 SetCode(common.Address, []byte) []byte 47 GetCodeSize(common.Address) int 48 49 AddRefund(uint64) 50 SubRefund(uint64) 51 GetRefund() uint64 52 53 GetCommittedState(common.Address, common.Hash) common.Hash 54 GetState(common.Address, common.Hash) common.Hash 55 SetState(common.Address, common.Hash, common.Hash) common.Hash 56 GetStorageRoot(addr common.Address) common.Hash 57 58 GetTransientState(addr common.Address, key common.Hash) common.Hash 59 SetTransientState(addr common.Address, key, value common.Hash) 60 61 SelfDestruct(common.Address) uint256.Int 62 HasSelfDestructed(common.Address) bool 63 64 // SelfDestruct6780 is post-EIP6780 selfdestruct, which means that it's a 65 // send-all-to-beneficiary, unless the contract was created in this same 66 // transaction, in which case it will be destructed. 67 // This method returns the prior balance, along with a boolean which is 68 // true iff the object was indeed destructed. 69 SelfDestruct6780(common.Address) (uint256.Int, bool) 70 71 // Exist reports whether the given account exists in state. 72 // Notably this also returns true for self-destructed accounts within the current transaction. 73 Exist(common.Address) bool 74 // Empty returns whether the given account is empty. Empty 75 // is defined according to EIP161 (balance = nonce = code = 0). 76 Empty(common.Address) bool 77 78 AddressInAccessList(addr common.Address) bool 79 SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool) 80 // AddAddressToAccessList adds the given address to the access list. This operation is safe to perform 81 // even if the feature/fork is not active yet 82 AddAddressToAccessList(addr common.Address) 83 // AddSlotToAccessList adds the given (address,slot) to the access list. This operation is safe to perform 84 // even if the feature/fork is not active yet 85 AddSlotToAccessList(addr common.Address, slot common.Hash) 86 87 // PointCache returns the point cache used in computations 88 PointCache() *utils.PointCache 89 90 Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) 91 92 RevertToSnapshot(int) 93 Snapshot() int 94 95 AddLog(*types.Log) 96 AddPreimage(common.Hash, []byte) 97 98 Witness() *stateless.Witness 99 100 AccessEvents() *state.AccessEvents 101 102 // Finalise must be invoked at the end of a transaction 103 Finalise(bool) 104 }