github.com/RobustRoundRobin/quorum@v20.10.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  	SetBalance(addr common.Address, balance *big.Int)
    32  	GetCode(addr common.Address) []byte
    33  	GetState(a common.Address, b common.Hash) common.Hash
    34  	GetNonce(addr common.Address) uint64
    35  	SetNonce(addr common.Address, nonce uint64)
    36  	SetCode(common.Address, []byte)
    37  	// Return nil for public contract
    38  	GetStatePrivacyMetadata(addr common.Address) (*state.PrivacyMetadata, error)
    39  
    40  	// RLP-encoded of the state object in a given address
    41  	// Throw error if no state object is found
    42  	GetRLPEncodedStateObject(addr common.Address) ([]byte, error)
    43  	GetProof(common.Address) ([][]byte, error)
    44  	GetStorageProof(common.Address, common.Hash) ([][]byte, error)
    45  	StorageTrie(addr common.Address) state.Trie
    46  	Error() error
    47  	GetCodeHash(common.Address) common.Hash
    48  	SetState(common.Address, common.Hash, common.Hash)
    49  	SetStorage(addr common.Address, storage map[common.Hash]common.Hash)
    50  }
    51  
    52  // StateDB is an EVM database for full state querying.
    53  type StateDB interface {
    54  	MinimalApiState
    55  	CreateAccount(common.Address)
    56  
    57  	SubBalance(common.Address, *big.Int)
    58  	AddBalance(common.Address, *big.Int)
    59  	//GetBalance(common.Address) *big.Int
    60  
    61  	//GetNonce(common.Address) uint64
    62  	//SetNonce(common.Address, uint64)
    63  
    64  	SetStatePrivacyMetadata(common.Address, *state.PrivacyMetadata)
    65  	//GetCodeHash(common.Address) common.Hash
    66  	//GetCode(common.Address) []byte
    67  	//SetCode(common.Address, []byte)
    68  	GetCodeSize(common.Address) int
    69  
    70  	AddRefund(uint64)
    71  	SubRefund(uint64)
    72  	GetRefund() uint64
    73  
    74  	GetCommittedState(common.Address, common.Hash) common.Hash
    75  	//GetState(common.Address, common.Hash) common.Hash
    76  	//SetState(common.Address, common.Hash, common.Hash)
    77  
    78  	Suicide(common.Address) bool
    79  	HasSuicided(common.Address) bool
    80  
    81  	// Exist reports whether the given account exists in state.
    82  	// Notably this should also return true for suicided accounts.
    83  	Exist(common.Address) bool
    84  	// Empty returns whether the given account is empty. Empty
    85  	// is defined according to EIP161 (balance = nonce = code = 0).
    86  	Empty(common.Address) bool
    87  
    88  	RevertToSnapshot(int)
    89  	Snapshot() int
    90  
    91  	AddLog(*types.Log)
    92  	AddPreimage(common.Hash, []byte)
    93  
    94  	ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) error
    95  }
    96  
    97  // CallContext provides a basic interface for the EVM calling conventions. The EVM
    98  // depends on this context being implemented for doing subcalls and initialising new EVM contracts.
    99  type CallContext interface {
   100  	// Call another contract
   101  	Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
   102  	// Take another's contract code and execute within our own context
   103  	CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
   104  	// Same as CallCode except sender and value is propagated from parent to child scope
   105  	DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error)
   106  	// Create a new contract
   107  	Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
   108  }