github.com/FusionFoundation/efsn/v4@v4.2.0/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/FusionFoundation/efsn/v4/common"
    23  	"github.com/FusionFoundation/efsn/v4/core/types"
    24  )
    25  
    26  // StateDB is an EVM database for full state querying.
    27  type StateDB interface {
    28  	CreateAccount(common.Address)
    29  
    30  	SubBalance(common.Address, common.Hash, *big.Int)
    31  	AddBalance(common.Address, common.Hash, *big.Int)
    32  	GetBalance(common.Hash, common.Address) *big.Int
    33  	SubTimeLockBalance(common.Address, common.Hash, *common.TimeLock, *big.Int, uint64)
    34  	AddTimeLockBalance(common.Address, common.Hash, *common.TimeLock, *big.Int, uint64)
    35  	SetTimeLockBalance(common.Address, common.Hash, *common.TimeLock)
    36  	GetTimeLockBalance(common.Hash, common.Address) *common.TimeLock
    37  	TransferNotation(notation uint64, from common.Address, to common.Address) error
    38  
    39  	GetNonce(common.Address) uint64
    40  	SetNonce(common.Address, uint64)
    41  
    42  	GetCodeHash(common.Address) common.Hash
    43  	GetCode(common.Address) []byte
    44  	SetCode(common.Address, []byte)
    45  	GetCodeSize(common.Address) int
    46  
    47  	AddRefund(uint64)
    48  	SubRefund(uint64)
    49  	GetRefund() uint64
    50  
    51  	GetCommittedState(common.Address, common.Hash) common.Hash
    52  	GetState(common.Address, common.Hash) common.Hash
    53  	SetState(common.Address, common.Hash, common.Hash)
    54  
    55  	Suicide(common.Address) bool
    56  	HasSuicided(common.Address) bool
    57  
    58  	// Exist reports whether the given account exists in state.
    59  	// Notably this should also return true for suicided accounts.
    60  	Exist(common.Address) bool
    61  	// Empty returns whether the given account is empty. Empty
    62  	// is defined according to EIP161 (balance = nonce = code = 0).
    63  	Empty(common.Address) bool
    64  
    65  	PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList)
    66  	AddressInAccessList(addr common.Address) bool
    67  	SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool)
    68  	// AddAddressToAccessList adds the given address to the access list. This operation is safe to perform
    69  	// even if the feature/fork is not active yet
    70  	AddAddressToAccessList(addr common.Address)
    71  	// AddSlotToAccessList adds the given (address,slot) to the access list. This operation is safe to perform
    72  	// even if the feature/fork is not active yet
    73  	AddSlotToAccessList(addr common.Address, slot common.Hash)
    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  	GenNotation(common.Address) error
    84  	GetNotation(common.Address) uint64
    85  
    86  	GenAsset(common.Asset) error
    87  	UpdateAsset(common.Asset) error
    88  
    89  	AllTickets() (common.TicketsDataSlice, error)
    90  	AddTicket(common.Ticket) error
    91  	RemoveTicket(id common.Hash) error
    92  	GetTicket(id common.Hash) (*common.Ticket, error)
    93  	IsTicketExist(id common.Hash) bool
    94  
    95  	AddSwap(swap common.Swap) error
    96  	UpdateSwap(swap common.Swap) error
    97  	RemoveSwap(id common.Hash) error
    98  	GetSwap(swapID common.Hash) (common.Swap, error)
    99  	GetAsset(assetID common.Hash) (common.Asset, error)
   100  	AddMultiSwap(swap common.MultiSwap) error
   101  	UpdateMultiSwap(swap common.MultiSwap) error
   102  	RemoveMultiSwap(id common.Hash) error
   103  	GetMultiSwap(swapID common.Hash) (common.MultiSwap, error)
   104  
   105  	IsReportExist(report []byte) bool
   106  	AddReport(report []byte) error
   107  }
   108  
   109  // CallContext provides a basic interface for the EVM calling conventions. The EVM EVM
   110  // depends on this context being implemented for doing subcalls and initialising new EVM contracts.
   111  type CallContext interface {
   112  	// Call another contract
   113  	Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
   114  	// Take another's contract code and execute within our own context
   115  	CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
   116  	// Same as CallCode except sender and value is propagated from parent to child scope
   117  	DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error)
   118  	// Create a new contract
   119  	Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
   120  }