github.com/klaytn/klaytn@v1.10.2/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  	Suicide(common.Address) bool
    62  	HasSuicided(common.Address) bool
    63  
    64  	// UpdateKey updates the account's key with the given key.
    65  	UpdateKey(addr common.Address, newKey accountkey.AccountKey, currentBlockNumber uint64) error
    66  
    67  	// Exist reports whether the given account exists in state.
    68  	// Notably this should also return true for suicided accounts.
    69  	Exist(common.Address) bool
    70  	// Empty returns whether the given account is empty. Empty
    71  	// is defined according to EIP161 (balance = nonce = code = 0).
    72  	Empty(common.Address) bool
    73  
    74  	PrepareAccessList(sender common.Address, feePayer common.Address, dest *common.Address, precompiles []common.Address)
    75  	AddressInAccessList(addr common.Address) bool
    76  	SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool)
    77  	// AddAddressToAccessList adds the given address to the access list. This operation is safe to perform
    78  	// even if the feature/fork is not active yet
    79  	AddAddressToAccessList(addr common.Address)
    80  	// AddSlotToAccessList adds the given (address,slot) to the access list. This operation is safe to perform
    81  	// even if the feature/fork is not active yet
    82  	AddSlotToAccessList(addr common.Address, slot common.Hash)
    83  
    84  	RevertToSnapshot(int)
    85  	Snapshot() int
    86  
    87  	AddLog(*types.Log)
    88  	AddPreimage(common.Hash, []byte)
    89  
    90  	// IsProgramAccount returns true if the account implements ProgramAccount.
    91  	IsProgramAccount(address common.Address) bool
    92  	IsContractAvailable(address common.Address) bool
    93  	IsValidCodeFormat(addr common.Address) bool
    94  
    95  	ForEachStorage(common.Address, func(common.Hash, common.Hash) bool)
    96  
    97  	GetTxHash() common.Hash
    98  
    99  	GetKey(address common.Address) accountkey.AccountKey
   100  }