github.com/klaytn/klaytn@v1.12.1/blockchain/vm/interface.go (about) 1 // Modifications Copyright 2018 The klaytn Authors 2 // Copyright 2015 The go-ethereum Authors 3 // This file is part of the go-ethereum library. 4 // 5 // The go-ethereum library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Lesser General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // The go-ethereum library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 17 // 18 // This file is derived from core/vm/interface.go (2018/06/04). 19 // Modified and improved for the klaytn development. 20 21 package vm 22 23 import ( 24 "math/big" 25 26 "github.com/klaytn/klaytn/blockchain/types" 27 "github.com/klaytn/klaytn/blockchain/types/accountkey" 28 "github.com/klaytn/klaytn/common" 29 "github.com/klaytn/klaytn/params" 30 ) 31 32 // StateDB is an EVM database for full state querying. 33 type StateDB interface { 34 CreateAccount(common.Address) 35 CreateSmartContractAccount(addr common.Address, format params.CodeFormat, r params.Rules) 36 CreateSmartContractAccountWithKey(addr common.Address, humanReadable bool, key accountkey.AccountKey, format params.CodeFormat, r params.Rules) 37 CreateEOA(addr common.Address, humanReadable bool, key accountkey.AccountKey) 38 39 SubBalance(common.Address, *big.Int) 40 AddBalance(common.Address, *big.Int) 41 GetBalance(common.Address) *big.Int 42 43 GetNonce(common.Address) uint64 44 IncNonce(common.Address) 45 SetNonce(common.Address, uint64) 46 47 GetCodeHash(common.Address) common.Hash 48 GetCode(common.Address) []byte 49 SetCode(common.Address, []byte) error 50 GetCodeSize(common.Address) int 51 GetVmVersion(common.Address) (params.VmVersion, bool) 52 53 AddRefund(uint64) 54 SubRefund(uint64) 55 GetRefund() uint64 56 57 GetCommittedState(common.Address, common.Hash) common.Hash 58 GetState(common.Address, common.Hash) common.Hash 59 SetState(common.Address, common.Hash, common.Hash) 60 61 GetTransientState(addr common.Address, key common.Hash) common.Hash 62 SetTransientState(addr common.Address, key, value common.Hash) 63 64 SelfDestruct(common.Address) 65 HasSelfDestructed(common.Address) bool 66 67 SelfDestruct6780(common.Address) 68 69 // UpdateKey updates the account's key with the given key. 70 UpdateKey(addr common.Address, newKey accountkey.AccountKey, currentBlockNumber uint64) error 71 72 // Exist reports whether the given account exists in state. 73 // Notably this should also return true for self-destructed accounts. 74 Exist(common.Address) bool 75 // Empty returns whether the given account is empty. Empty 76 // is defined according to EIP161 (balance = nonce = code = 0). 77 Empty(common.Address) bool 78 79 AddressInAccessList(addr common.Address) bool 80 SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool) 81 // AddAddressToAccessList adds the given address to the access list. This operation is safe to perform 82 // even if the feature/fork is not active yet 83 AddAddressToAccessList(addr common.Address) 84 // AddSlotToAccessList adds the given (address,slot) to the access list. This operation is safe to perform 85 // even if the feature/fork is not active yet 86 AddSlotToAccessList(addr common.Address, slot common.Hash) 87 Prepare(rules params.Rules, sender, feePayer, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) 88 89 RevertToSnapshot(int) 90 Snapshot() int 91 92 AddLog(*types.Log) 93 AddPreimage(common.Hash, []byte) 94 95 // IsProgramAccount returns true if the account implements ProgramAccount. 96 IsProgramAccount(address common.Address) bool 97 IsContractAvailable(address common.Address) bool 98 IsValidCodeFormat(addr common.Address) bool 99 100 ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) 101 102 GetTxHash() common.Hash 103 104 GetKey(address common.Address) accountkey.AccountKey 105 }