github.com/hyperion-hyn/go-ethereum@v2.4.0+incompatible/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 "math/big" 21 22 "github.com/ethereum/go-ethereum/common" 23 "github.com/ethereum/go-ethereum/core/state" 24 "github.com/ethereum/go-ethereum/core/types" 25 ) 26 27 // Quorum uses a cut-down StateDB, MinimalApiState. We leave the methods in StateDB commented out so they'll produce a 28 // conflict when upstream changes. 29 type MinimalApiState interface { 30 GetBalance(addr common.Address) *big.Int 31 GetCode(addr common.Address) []byte 32 GetState(a common.Address, b common.Hash) common.Hash 33 GetNonce(addr common.Address) uint64 34 GetProof(common.Address) ([][]byte, error) 35 GetStorageProof(common.Address, common.Hash) ([][]byte, error) 36 StorageTrie(addr common.Address) state.Trie 37 Error() error 38 GetCodeHash(common.Address) common.Hash 39 } 40 41 // StateDB is an EVM database for full state querying. 42 type StateDB interface { 43 MinimalApiState 44 CreateAccount(common.Address) 45 46 SubBalance(common.Address, *big.Int) 47 AddBalance(common.Address, *big.Int) 48 //GetBalance(common.Address) *big.Int 49 50 //GetNonce(common.Address) uint64 51 SetNonce(common.Address, uint64) 52 53 //GetCodeHash(common.Address) common.Hash 54 //GetCode(common.Address) []byte 55 SetCode(common.Address, []byte) 56 GetCodeSize(common.Address) int 57 58 AddRefund(uint64) 59 SubRefund(uint64) 60 GetRefund() uint64 61 62 GetCommittedState(common.Address, common.Hash) common.Hash 63 SetState(common.Address, common.Hash, common.Hash) 64 65 Suicide(common.Address) bool 66 HasSuicided(common.Address) bool 67 68 // Exist reports whether the given account exists in state. 69 // Notably this should also return true for suicided accounts. 70 Exist(common.Address) bool 71 // Empty returns whether the given account is empty. Empty 72 // is defined according to EIP161 (balance = nonce = code = 0). 73 Empty(common.Address) bool 74 75 RevertToSnapshot(int) 76 Snapshot() int 77 78 AddLog(*types.Log) 79 AddPreimage(common.Hash, []byte) 80 81 ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) 82 } 83 84 // CallContext provides a basic interface for the EVM calling conventions. The EVM 85 // depends on this context being implemented for doing subcalls and initialising new EVM contracts. 86 type CallContext interface { 87 // Call another contract 88 Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) 89 // Take another's contract code and execute within our own context 90 CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) 91 // Same as CallCode except sender and value is propagated from parent to child scope 92 DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error) 93 // Create a new contract 94 Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error) 95 }