Documentation
¶
Overview ¶
Package vm implements the Ethereum Virtual Machine.
The vm package implements two EVMs, a byte code VM and a JIT VM. The BC (Byte Code) VM loops over a set of bytes and executes them according to the set of rules defined in the Ethereum yellow paper. When the BC VM is invoked it invokes the JIT VM in a separate goroutine and compiles the byte code in JIT instructions.
The JIT VM, when invoked, loops around a set of pre-defined instructions until it either runs of gas, causes an internal error, returns or stops.
The JIT optimiser attempts to pre-compile instructions in to chunks or segments such as multiple PUSH operations and static JUMPs. It does this by analysing the opcodes and attempts to match certain regions to known sets. Whenever the optimiser finds said segments it creates a new instruction and replaces the first occurrence in the sequence.
* * @hub.go define data structure for recording infos * @Note: most parts of this file has been useless other than last function 'isRelOracle()'.
* *@ hacker_operation.go * 1 store some vital operations which recorded in file @instruction.go * 2 key unit:operation_stack
* *@hacker_oracle.go * define * 1 vulunerable oracle(such as Reentrancy,ExceptionDisorder,GaslessSend,CallEtherFailed.etc) formally. * 2 other Operation (such as sendOp,CallOp.etc) Oracle. * 3 simple count(such as RepeatedCall) Oracle. * And give strict check condition for each oracle upper.
*@hacker_state.go * 1 Record snapshot of contract state after reach any keypoint * (such as operation Call,DelegateCall to be initiated);
* * @HackerUtils * provide simple util function to compare,check eq,or hash for call info.
Index ¶
- Constants
- Variables
- func CallsPointerToString(calls []*HackerContractCall) string
- func CallsToString(calls []*HackerContractCall) string
- func Hacker_record(op OpCode, fun opFunc, pc *uint64, evm *EVM, contract *Contract, ...) ([]byte, error)
- func IsAccountAddress(addr common.Address) bool
- func NewFrontierInstructionSet() [256]operation
- func NewHomesteadInstructionSet() [256]operation
- func NoopCanTransfer(db StateDB, from common.Address, balance *big.Int) bool
- func NoopTransfer(db StateDB, from, to common.Address, amount *big.Int)
- func RunPrecompiledContract(p PrecompiledContract, input []byte, contract *Contract) (ret []byte, err error)
- func StorageToString(storage map[common.Hash]common.Hash) string
- func WriteLogs(writer io.Writer, logs []*types.Log)
- func WriteTrace(writer io.Writer, logs []StructLog)
- type AccountRef
- type CallContext
- type CanTransferFunc
- type Config
- type Context
- type Contract
- func (c *Contract) Address() common.Address
- func (c *Contract) AsDelegate() *Contract
- func (c *Contract) Caller() common.Address
- func (c *Contract) GetByte(n uint64) byte
- func (c *Contract) GetOp(n uint64) OpCode
- func (self *Contract) SetCallCode(addr *common.Address, hash common.Hash, code []byte)
- func (self *Contract) SetCode(hash common.Hash, code []byte)
- func (c *Contract) UseGas(gas uint64) (ok bool)
- func (c *Contract) Value() *big.Int
- type ContractRef
- type EVM
- func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas uint64, ...) (ret []byte, leftOverGas uint64, err error)
- func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, gas uint64, ...) (ret []byte, leftOverGas uint64, err error)
- func (evm *EVM) Cancel()
- func (evm *EVM) ChainConfig() *params.ChainConfig
- func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error)
- func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error)
- func (evm *EVM) Interpreter() *Interpreter
- type GetHashFunc
- type HackerBalanceGtZero
- type HackerBlockHashOp
- type HackerCallEtherTransferFailed
- func (oracle *HackerCallEtherTransferFailed) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
- func (oracle *HackerCallEtherTransferFailed) String() string
- func (oracle *HackerCallEtherTransferFailed) TestOracle() bool
- func (oracle *HackerCallEtherTransferFailed) TriggerFallbackCall(call *HackerContractCall) bool
- func (oracle *HackerCallEtherTransferFailed) Write(writer io.Writer)
- type HackerCallExecption
- type HackerCallInfoReportor
- type HackerCallOpInfo
- type HackerContractCall
- func (call *HackerContractCall) Hash() []byte
- func (call *HackerContractCall) OnAddress()
- func (call *HackerContractCall) OnBalance()
- func (call *HackerContractCall) OnBlockHash()
- func (call *HackerContractCall) OnCall(_caller ContractRef, _callee common.Address, _value, _gas big.Int, ...) *HackerContractCall
- func (call *HackerContractCall) OnCallCode(_caller ContractRef, _callee common.Address, _value, _gas big.Int, ...) *HackerContractCall
- func (call *HackerContractCall) OnCallValue()
- func (call *HackerContractCall) OnCalldataLoad()
- func (call *HackerContractCall) OnCaller()
- func (call *HackerContractCall) OnCloseCall(finalgas big.Int)
- func (call *HackerContractCall) OnCreate()
- func (call *HackerContractCall) OnDelegateCall(_caller ContractRef, _callee common.Address, _gas big.Int, _input []byte) *HackerContractCall
- func (call *HackerContractCall) OnDiv()
- func (call *HackerContractCall) OnGas()
- func (call *HackerContractCall) OnJump()
- func (call *HackerContractCall) OnJumpi()
- func (call *HackerContractCall) OnMload()
- func (call *HackerContractCall) OnMstore()
- func (call *HackerContractCall) OnNumber()
- func (call *HackerContractCall) OnOrigin()
- func (call *HackerContractCall) OnRelationOp(relation OpCode)
- func (call *HackerContractCall) OnReturn()
- func (call *HackerContractCall) OnSha3()
- func (call *HackerContractCall) OnSload()
- func (call *HackerContractCall) OnSstore()
- func (call *HackerContractCall) OnSuicide()
- func (call *HackerContractCall) OnTimestamp()
- func (call *HackerContractCall) Sig() string
- func (call *HackerContractCall) ToString() string
- func (call *HackerContractCall) Write(writer io.Writer)
- type HackerContractCallStack
- type HackerDelegateCallInfo
- func (oracle *HackerDelegateCallInfo) GetFeatures(rootcall, call *HackerContractCall)
- func (oracle *HackerDelegateCallInfo) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
- func (oracle *HackerDelegateCallInfo) String() string
- func (oracle *HackerDelegateCallInfo) TestOracle() bool
- func (oracle *HackerDelegateCallInfo) TriggerDelegateCall(call *HackerContractCall) bool
- func (oracle *HackerDelegateCallInfo) Write(writer io.Writer)
- type HackerEtherTransfer
- type HackerEtherTransferFailed
- func (oracle *HackerEtherTransferFailed) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
- func (oracle *HackerEtherTransferFailed) String() string
- func (oracle *HackerEtherTransferFailed) TestOracle() bool
- func (oracle *HackerEtherTransferFailed) Write(writer io.Writer)
- type HackerExceptionDisorder
- func (oracle *HackerExceptionDisorder) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
- func (oracle *HackerExceptionDisorder) String() string
- func (oracle *HackerExceptionDisorder) TestOracle() bool
- func (oracle *HackerExceptionDisorder) TriggerExceptionCall(root, call *HackerContractCall) bool
- func (oracle *HackerExceptionDisorder) Write(writer io.Writer)
- type HackerGaslessSend
- func (oracle *HackerGaslessSend) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
- func (oracle *HackerGaslessSend) String() string
- func (oracle *HackerGaslessSend) TestOracle() bool
- func (oracle *HackerGaslessSend) TriggerExceptionCall(call *HackerContractCall) bool
- func (oracle *HackerGaslessSend) Write(writer io.Writer)
- type HackerNumberOp
- type HackerOperationStack
- type HackerReentrancy
- type HackerRepeatedCall
- type HackerRootCallFailed
- type HackerSendOpInfo
- type HackerState
- type HackerStateDiff
- type HackerStateStack
- type HackerStorageChanged
- func (oracle *HackerStorageChanged) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
- func (oracle *HackerStorageChanged) String() string
- func (oracle *HackerStorageChanged) TestOracle() bool
- func (oracle *HackerStorageChanged) TriggerOracle(rootCall *HackerContractCall) bool
- func (oracle *HackerStorageChanged) Write(writer io.Writer)
- type HackerTimestampOp
- type HackerUnknownCall
- func (oracle *HackerUnknownCall) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
- func (oracle *HackerUnknownCall) String() string
- func (oracle *HackerUnknownCall) TestOracle() bool
- func (oracle *HackerUnknownCall) TriggerOracle(rootCall, call *HackerContractCall) bool
- func (oracle *HackerUnknownCall) Write(writer io.Writer)
- type HackerUtils
- type Hacker_ContractState
- type Interpreter
- type LogConfig
- type Memory
- type NoopEVMCallContext
- func (NoopEVMCallContext) Call(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
- func (NoopEVMCallContext) CallCode(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
- func (NoopEVMCallContext) Create(caller ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
- func (NoopEVMCallContext) DelegateCall(me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error)
- type NoopStateDB
- func (NoopStateDB) AddBalance(common.Address, *big.Int)
- func (NoopStateDB) AddLog(*types.Log)
- func (NoopStateDB) AddPreimage(common.Hash, []byte)
- func (NoopStateDB) AddRefund(*big.Int)
- func (NoopStateDB) CreateAccount(common.Address)
- func (NoopStateDB) Empty(common.Address) bool
- func (NoopStateDB) Exist(common.Address) bool
- func (NoopStateDB) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool)
- func (NoopStateDB) GetBalance(common.Address) *big.Int
- func (NoopStateDB) GetCode(common.Address) []byte
- func (NoopStateDB) GetCodeHash(common.Address) common.Hash
- func (NoopStateDB) GetCodeSize(common.Address) int
- func (NoopStateDB) GetNonce(common.Address) uint64
- func (NoopStateDB) GetRefund() *big.Int
- func (NoopStateDB) GetState(common.Address, common.Hash) common.Hash
- func (NoopStateDB) HasSuicided(common.Address) bool
- func (NoopStateDB) RevertToSnapshot(int)
- func (NoopStateDB) SetCode(common.Address, []byte)
- func (NoopStateDB) SetNonce(common.Address, uint64)
- func (NoopStateDB) SetState(common.Address, common.Hash, common.Hash)
- func (NoopStateDB) Snapshot() int
- func (NoopStateDB) SubBalance(common.Address, *big.Int)
- func (NoopStateDB) Suicide(common.Address) bool
- type OpCode
- type Oracle
- type PrecompiledContract
- type Stack
- type StateDB
- type Storage
- type StructLog
- type StructLogger
- type Tracer
- type TransferFunc
Constants ¶
const ( GasQuickStep uint64 = 2 GasFastestStep uint64 = 3 GasFastStep uint64 = 5 GasMidStep uint64 = 8 GasSlowStep uint64 = 10 GasExtStep uint64 = 20 GasReturn uint64 = 0 GasStop uint64 = 0 GasContractByte uint64 = 200 )
const ( MaxIdleConnections int = 50 RequestTimeout int = 5 )
Variables ¶
var ( ErrOutOfGas = errors.New("out of gas") ErrCodeStoreOutOfGas = errors.New("contract creation code storage out of gas") ErrDepth = errors.New("max call depth exceeded") ErrTraceLimitReached = errors.New("the number of logs reached the specified limit") ErrInsufficientBalance = errors.New("insufficient balance for transfer") )
var Client = &http.Client{ Transport: &http.Transport{ MaxIdleConnsPerHost: MaxIdleConnections, }, Timeout: time.Duration(RequestTimeout) * time.Second, }
var PrecompiledContracts = map[common.Address]PrecompiledContract{ common.BytesToAddress([]byte{1}): &ecrecover{}, common.BytesToAddress([]byte{2}): &sha256hash{}, common.BytesToAddress([]byte{3}): &ripemd160hash{}, common.BytesToAddress([]byte{4}): &dataCopy{}, }
PrecompiledContracts contains the default set of ethereum contracts
var Printf = log.Printf
var Println = log.Println
Functions ¶
func CallsPointerToString ¶
func CallsPointerToString(calls []*HackerContractCall) string
func CallsToString ¶
func CallsToString(calls []*HackerContractCall) string
func Hacker_record ¶
func IsAccountAddress ¶
func NewFrontierInstructionSet ¶
func NewFrontierInstructionSet() [256]operation
NewFrontierInstructionSet returns the frontier instructions that can be executed during the frontier phase.
func NewHomesteadInstructionSet ¶
func NewHomesteadInstructionSet() [256]operation
NewHomesteadInstructionSet returns the frontier and homestead instructions that can be executed during the homestead phase.
func RunPrecompiledContract ¶
func RunPrecompiledContract(p PrecompiledContract, input []byte, contract *Contract) (ret []byte, err error)
RunPrecompile runs and evaluate the output of a precompiled contract defined in contracts.go
func WriteTrace ¶
WriteTrace writes a formatted trace to the given writer
Types ¶
type AccountRef ¶
AccountRef implements ContractRef.
Account references are used during EVM initialisation and it's primary use is to fetch addresses. Removing this object proves difficult because of the cached jump destinations which are fetched from the parent contract (i.e. the caller), which is a ContractRef.
func (AccountRef) Address ¶
func (ar AccountRef) Address() common.Address
Address casts AccountRef to a Address
type CallContext ¶
type CallContext interface { // Call another contract Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) // Take another's contract code and execute within our own context CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) // Same as CallCode except sender and value is propagated from parent to child scope DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error) // Create a new contract Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error) }
CallContext provides a basic interface for the EVM calling conventions. The EVM EVM depends on this context being implemented for doing subcalls and initialising new EVM contracts.
type Config ¶
type Config struct { // Debug enabled debugging Interpreter options Debug bool // EnableJit enabled the JIT VM EnableJit bool // ForceJit forces the JIT VM ForceJit bool // Tracer is the op code logger Tracer Tracer // NoRecursion disabled Interpreter call, callcode, // delegate call and create. NoRecursion bool // Disable gas metering DisableGasMetering bool // Enable recording of SHA3/keccak preimages EnablePreimageRecording bool // JumpTable contains the EVM instruction table. This // may be left uninitialised and will be set to the default // table. JumpTable [256]operation }
Config are the configuration options for the Interpreter
type Context ¶
type Context struct { // CanTransfer returns whether the account contains // sufficient ether to transfer the value CanTransfer CanTransferFunc // Transfer transfers ether from one account to the other Transfer TransferFunc // GetHash returns the hash corresponding to n GetHash GetHashFunc // Message information Origin common.Address // Provides information for ORIGIN GasPrice *big.Int // Provides information for GASPRICE // Block information Coinbase common.Address // Provides information for COINBASE GasLimit *big.Int // Provides information for GASLIMIT BlockNumber *big.Int // Provides information for NUMBER Time *big.Int // Provides information for TIME Difficulty *big.Int // Provides information for DIFFICULTY }
Context provides the EVM with auxiliary information. Once provided it shouldn't be modified.
type Contract ¶
type Contract struct { // CallerAddress is the result of the caller which initialised this // contract. However when the "call method" is delegated this value // needs to be initialised to that of the caller's caller. CallerAddress common.Address Code []byte CodeHash common.Hash CodeAddr *common.Address Input []byte Gas uint64 Args []byte DelegateCall bool // contains filtered or unexported fields }
Contract represents an ethereum contract in the state database. It contains the the contract code, calling arguments. Contract implements ContractRef
func NewContract ¶
func NewContract(caller ContractRef, object ContractRef, value *big.Int, gas uint64) *Contract
NewContract returns a new contract environment for the execution of EVM.
func (*Contract) AsDelegate ¶
AsDelegate sets the contract to be a delegate call and returns the current contract (for chaining calls)
func (*Contract) Caller ¶
Caller returns the caller of the contract.
Caller will recursively call caller when the contract is a delegate call, including that of caller's caller.
func (*Contract) SetCallCode ¶
SetCallCode sets the code of the contract and address of the backing data object
type ContractRef ¶
ContractRef is a reference to the contract's backing object
type EVM ¶
type EVM struct { // Context provides auxiliary blockchain related information Context // StateDB gives access to the underlying state StateDB StateDB // contains filtered or unexported fields }
EVM is the Ethereum Virtual Machine base object and provides the necessary tools to run a contract on the given state with the provided context. It should be noted that any error generated through any of the calls should be considered a revert-state-and-consume-all-gas operation, no checks on specific errors should ever be performed. The interpreter makes sure that any errors generated are to be considered faulty code.
The EVM should never be reused and is not thread safe.
func NewEVM ¶
NewEVM retutrns a new EVM evmironment. The returned EVM is not thread safe and should only ever be used *once*.
func (*EVM) Call ¶
func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error)
Call executes the contract associated with the addr with the given input as parameters. It also handles any necessary value transfer required and takes the necessary steps to create accounts and reverses the state in case of an execution error or failed value transfer.
func (*EVM) CallCode ¶
func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error)
CallCode executes the contract associated with the addr with the given input as parameters. It also handles any necessary value transfer required and takes the necessary steps to create accounts and reverses the state in case of an execution error or failed value transfer.
CallCode differs from Call in the sense that it executes the given address' code with the caller as context.
func (*EVM) Cancel ¶
func (evm *EVM) Cancel()
Cancel cancels any running EVM operation. This may be called concurrently and it's safe to be called multiple times.
func (*EVM) ChainConfig ¶
func (evm *EVM) ChainConfig() *params.ChainConfig
ChainConfig returns the evmironment's chain configuration
func (*EVM) Create ¶
func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error)
Create creates a new contract using code as deployment code.
func (*EVM) DelegateCall ¶
func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error)
DelegateCall executes the contract associated with the addr with the given input as parameters. It reverses the state in case of an execution error.
DelegateCall differs from CallCode in the sense that it executes the given address' code with the caller as context and the caller is set to the caller of the caller.
func (*EVM) Interpreter ¶
func (evm *EVM) Interpreter() *Interpreter
Interpreter returns the EVM interpreter
type GetHashFunc ¶
GetHashFunc returns the nth block hash in the blockchain and is used by the BLOCKHASH EVM op code.
type HackerBalanceGtZero ¶
type HackerBalanceGtZero struct {
// contains filtered or unexported fields
}
* * Oracle: HackerBalanceGtZero * to help us detect the contract whose balance>0. * this could help us find 'high-value' target contracts with other test oracles result.
func NewHackerBalanceGtZero ¶
func NewHackerBalanceGtZero() *HackerBalanceGtZero
func (*HackerBalanceGtZero) InitOracle ¶
func (oracle *HackerBalanceGtZero) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerBalanceGtZero) String ¶
func (oracle *HackerBalanceGtZero) String() string
func (*HackerBalanceGtZero) TestOracle ¶
func (oracle *HackerBalanceGtZero) TestOracle() bool
func (*HackerBalanceGtZero) Write ¶
func (oracle *HackerBalanceGtZero) Write(writer io.Writer)
type HackerBlockHashOp ¶
type HackerBlockHashOp struct {
// contains filtered or unexported fields
}
* * Oracle: HackerBlockHashOp * to help us detect the call where BLOCKHASH operation works.
func NewHackerBlockHashOp ¶
func NewHackerBlockHashOp() *HackerBlockHashOp
func (*HackerBlockHashOp) InitOracle ¶
func (oracle *HackerBlockHashOp) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerBlockHashOp) String ¶
func (oracle *HackerBlockHashOp) String() string
func (*HackerBlockHashOp) TestOracle ¶
func (oracle *HackerBlockHashOp) TestOracle() bool
func (*HackerBlockHashOp) Write ¶
func (oracle *HackerBlockHashOp) Write(writer io.Writer)
type HackerCallEtherTransferFailed ¶
type HackerCallEtherTransferFailed struct {
// contains filtered or unexported fields
}
* * Oracle: HackerCallEtherTransferFailed. * part of HackerEtherTransferFailed. * to help us choose the call who send ether with gas>2300 * (2300 is the default gas limit of 'SEND')
func NewHackerCallEtherTransferFailed ¶
func NewHackerCallEtherTransferFailed() *HackerCallEtherTransferFailed
func (*HackerCallEtherTransferFailed) InitOracle ¶
func (oracle *HackerCallEtherTransferFailed) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerCallEtherTransferFailed) String ¶
func (oracle *HackerCallEtherTransferFailed) String() string
func (*HackerCallEtherTransferFailed) TestOracle ¶
func (oracle *HackerCallEtherTransferFailed) TestOracle() bool
func (*HackerCallEtherTransferFailed) TriggerFallbackCall ¶
func (oracle *HackerCallEtherTransferFailed) TriggerFallbackCall(call *HackerContractCall) bool
func (*HackerCallEtherTransferFailed) Write ¶
func (oracle *HackerCallEtherTransferFailed) Write(writer io.Writer)
type HackerCallExecption ¶
type HackerCallExecption struct {
// contains filtered or unexported fields
}
func NewHackerCallExecption ¶
func NewHackerCallExecption() *HackerCallExecption
func (*HackerCallExecption) InitOracle ¶
func (oracle *HackerCallExecption) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerCallExecption) String ¶
func (oracle *HackerCallExecption) String() string
func (*HackerCallExecption) TestOracle ¶
func (oracle *HackerCallExecption) TestOracle() bool
func (*HackerCallExecption) Write ¶
func (oracle *HackerCallExecption) Write(writer io.Writer)
type HackerCallInfoReportor ¶
type HackerCallInfoReportor struct {
// contains filtered or unexported fields
}
func GetReportor ¶
func GetReportor() *HackerCallInfoReportor
func (*HackerCallInfoReportor) Profile ¶
func (report *HackerCallInfoReportor) Profile(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall) string
type HackerCallOpInfo ¶
type HackerCallOpInfo struct {
// contains filtered or unexported fields
}
* *Oracle: HackerCallOpInfo *to help us detect the call whether cases such as "call.value(_value).gas(_gas)(_sig)" work in the process.
func NewHackerCallOpInfo ¶
func NewHackerCallOpInfo() *HackerCallOpInfo
func (*HackerCallOpInfo) InitOracle ¶
func (oracle *HackerCallOpInfo) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerCallOpInfo) String ¶
func (oracle *HackerCallOpInfo) String() string
func (*HackerCallOpInfo) TestOracle ¶
func (oracle *HackerCallOpInfo) TestOracle() bool
func (*HackerCallOpInfo) Write ¶
func (oracle *HackerCallOpInfo) Write(writer io.Writer)
type HackerContractCall ¶
type HackerContractCall struct { OperationStack *HackerOperationStack StateStack *HackerStateStack // contains filtered or unexported fields }
func (*HackerContractCall) Hash ¶
func (call *HackerContractCall) Hash() []byte
func (*HackerContractCall) OnAddress ¶
func (call *HackerContractCall) OnAddress()
func (*HackerContractCall) OnBalance ¶
func (call *HackerContractCall) OnBalance()
func (*HackerContractCall) OnBlockHash ¶
func (call *HackerContractCall) OnBlockHash()
func (*HackerContractCall) OnCall ¶
func (call *HackerContractCall) OnCall(_caller ContractRef, _callee common.Address, _value, _gas big.Int, _input []byte) *HackerContractCall
func (*HackerContractCall) OnCallCode ¶
func (call *HackerContractCall) OnCallCode(_caller ContractRef, _callee common.Address, _value, _gas big.Int, _input []byte) *HackerContractCall
func (*HackerContractCall) OnCallValue ¶
func (call *HackerContractCall) OnCallValue()
func (*HackerContractCall) OnCalldataLoad ¶
func (call *HackerContractCall) OnCalldataLoad()
func (*HackerContractCall) OnCaller ¶
func (call *HackerContractCall) OnCaller()
func (*HackerContractCall) OnCloseCall ¶
func (call *HackerContractCall) OnCloseCall(finalgas big.Int)
func (*HackerContractCall) OnCreate ¶
func (call *HackerContractCall) OnCreate()
func (*HackerContractCall) OnDelegateCall ¶
func (call *HackerContractCall) OnDelegateCall(_caller ContractRef, _callee common.Address, _gas big.Int, _input []byte) *HackerContractCall
func (*HackerContractCall) OnDiv ¶
func (call *HackerContractCall) OnDiv()
func (*HackerContractCall) OnGas ¶
func (call *HackerContractCall) OnGas()
func (*HackerContractCall) OnJump ¶
func (call *HackerContractCall) OnJump()
func (*HackerContractCall) OnJumpi ¶
func (call *HackerContractCall) OnJumpi()
Jump statement, Jump to existing function position, or Jump to the invalid to invoke a error throw.
func (*HackerContractCall) OnMload ¶
func (call *HackerContractCall) OnMload()
Memory,Storage operation
func (*HackerContractCall) OnMstore ¶
func (call *HackerContractCall) OnMstore()
func (*HackerContractCall) OnNumber ¶
func (call *HackerContractCall) OnNumber()
func (*HackerContractCall) OnOrigin ¶
func (call *HackerContractCall) OnOrigin()
func (*HackerContractCall) OnRelationOp ¶
func (call *HackerContractCall) OnRelationOp(relation OpCode)
func (*HackerContractCall) OnReturn ¶
func (call *HackerContractCall) OnReturn()
func (*HackerContractCall) OnSha3 ¶
func (call *HackerContractCall) OnSha3()
func (*HackerContractCall) OnSload ¶
func (call *HackerContractCall) OnSload()
func (*HackerContractCall) OnSstore ¶
func (call *HackerContractCall) OnSstore()
func (*HackerContractCall) OnSuicide ¶
func (call *HackerContractCall) OnSuicide()
func (*HackerContractCall) OnTimestamp ¶
func (call *HackerContractCall) OnTimestamp()
func (*HackerContractCall) Sig ¶
func (call *HackerContractCall) Sig() string
func (*HackerContractCall) ToString ¶
func (call *HackerContractCall) ToString() string
func (*HackerContractCall) Write ¶
func (call *HackerContractCall) Write(writer io.Writer)
type HackerContractCallStack ¶
type HackerContractCallStack struct {
// contains filtered or unexported fields
}
func (*HackerContractCallStack) Back ¶
func (st *HackerContractCallStack) Back(n int) *HackerContractCall
Back returns the n'th item in stack
func (*HackerContractCallStack) Data ¶
func (st *HackerContractCallStack) Data() []*HackerContractCall
func (*HackerContractCallStack) Print ¶
func (st *HackerContractCallStack) Print()
type HackerDelegateCallInfo ¶
type HackerDelegateCallInfo struct {
// contains filtered or unexported fields
}
* *Oracle: HackerDelegateCallInfo * to help us to choose the call featured with 'DELEAGATECALL' initiating.
func NewHackerDelegateCallInfo ¶
func NewHackerDelegateCallInfo() *HackerDelegateCallInfo
func (*HackerDelegateCallInfo) GetFeatures ¶
func (oracle *HackerDelegateCallInfo) GetFeatures(rootcall, call *HackerContractCall)
func (*HackerDelegateCallInfo) InitOracle ¶
func (oracle *HackerDelegateCallInfo) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerDelegateCallInfo) String ¶
func (oracle *HackerDelegateCallInfo) String() string
func (*HackerDelegateCallInfo) TestOracle ¶
func (oracle *HackerDelegateCallInfo) TestOracle() bool
func (*HackerDelegateCallInfo) TriggerDelegateCall ¶
func (oracle *HackerDelegateCallInfo) TriggerDelegateCall(call *HackerContractCall) bool
func (*HackerDelegateCallInfo) Write ¶
func (oracle *HackerDelegateCallInfo) Write(writer io.Writer)
type HackerEtherTransfer ¶
type HackerEtherTransfer struct {
// contains filtered or unexported fields
}
* *Oracle: HackerEtherTransfer *to help us to check whether ether to be sent
func NewHackerEtherTransfer ¶
func NewHackerEtherTransfer() *HackerEtherTransfer
func (*HackerEtherTransfer) InitOracle ¶
func (oracle *HackerEtherTransfer) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerEtherTransfer) String ¶
func (oracle *HackerEtherTransfer) String() string
func (*HackerEtherTransfer) TestOracle ¶
func (oracle *HackerEtherTransfer) TestOracle() bool
func (*HackerEtherTransfer) Write ¶
func (oracle *HackerEtherTransfer) Write(writer io.Writer)
type HackerEtherTransferFailed ¶
type HackerEtherTransferFailed struct {
// contains filtered or unexported fields
}
* *Oracle: HackerEtherTransferFailed *to help us check whether the call (with ether received or sent) fail.
func NewHackerEtherTransferFailed ¶
func NewHackerEtherTransferFailed() *HackerEtherTransferFailed
func (*HackerEtherTransferFailed) InitOracle ¶
func (oracle *HackerEtherTransferFailed) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerEtherTransferFailed) String ¶
func (oracle *HackerEtherTransferFailed) String() string
func (*HackerEtherTransferFailed) TestOracle ¶
func (oracle *HackerEtherTransferFailed) TestOracle() bool
func (*HackerEtherTransferFailed) Write ¶
func (oracle *HackerEtherTransferFailed) Write(writer io.Writer)
type HackerExceptionDisorder ¶
type HackerExceptionDisorder struct {
// contains filtered or unexported fields
}
* * Oracle: HackerExceptionDisorder * to help us detect whether exception happens and exception propagates bottom-up.
func NewHackerExceptionDisorder ¶
func NewHackerExceptionDisorder() *HackerExceptionDisorder
func (*HackerExceptionDisorder) InitOracle ¶
func (oracle *HackerExceptionDisorder) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerExceptionDisorder) String ¶
func (oracle *HackerExceptionDisorder) String() string
func (*HackerExceptionDisorder) TestOracle ¶
func (oracle *HackerExceptionDisorder) TestOracle() bool
func (*HackerExceptionDisorder) TriggerExceptionCall ¶
func (oracle *HackerExceptionDisorder) TriggerExceptionCall(root, call *HackerContractCall) bool
func (*HackerExceptionDisorder) Write ¶
func (oracle *HackerExceptionDisorder) Write(writer io.Writer)
type HackerGaslessSend ¶
type HackerGaslessSend struct {
// contains filtered or unexported fields
}
* * Oracle: HackerGaslessSend * to help us detect the call whether it sends ether via "SEND" but fails out of gas insufficiency.
func NewHackerGaslessSend ¶
func NewHackerGaslessSend() *HackerGaslessSend
func (*HackerGaslessSend) InitOracle ¶
func (oracle *HackerGaslessSend) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerGaslessSend) String ¶
func (oracle *HackerGaslessSend) String() string
func (*HackerGaslessSend) TestOracle ¶
func (oracle *HackerGaslessSend) TestOracle() bool
func (*HackerGaslessSend) TriggerExceptionCall ¶
func (oracle *HackerGaslessSend) TriggerExceptionCall(call *HackerContractCall) bool
func (*HackerGaslessSend) Write ¶
func (oracle *HackerGaslessSend) Write(writer io.Writer)
type HackerNumberOp ¶
type HackerNumberOp struct {
// contains filtered or unexported fields
}
func NewHackerNumberOp ¶
func NewHackerNumberOp() *HackerNumberOp
func (*HackerNumberOp) InitOracle ¶
func (oracle *HackerNumberOp) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerNumberOp) String ¶
func (oracle *HackerNumberOp) String() string
func (*HackerNumberOp) TestOracle ¶
func (oracle *HackerNumberOp) TestOracle() bool
func (*HackerNumberOp) Write ¶
func (oracle *HackerNumberOp) Write(writer io.Writer)
type HackerOperationStack ¶
type HackerOperationStack struct {
// contains filtered or unexported fields
}
HackerOperationStack record opCode's String
func (*HackerOperationStack) Back ¶
func (st *HackerOperationStack) Back(n int) string
Back returns the n'th item in stack
func (*HackerOperationStack) Data ¶
func (st *HackerOperationStack) Data() []string
func (*HackerOperationStack) Print ¶
func (st *HackerOperationStack) Print()
func (*HackerOperationStack) String ¶
func (stack *HackerOperationStack) String() string
type HackerReentrancy ¶
type HackerReentrancy struct {
// contains filtered or unexported fields
}
* *Oracle: HackerReentrancy *to help us detect reentrancy bugs. *The oracle use a trick to check wheter a contract provide a anti-reentrancy policy *via comparing opcode len between the two 'reentrancy' calls.
func NewHackerReentrancy ¶
func NewHackerReentrancy() *HackerReentrancy
func (*HackerReentrancy) InitOracle ¶
func (oracle *HackerReentrancy) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerReentrancy) String ¶
func (Oracle *HackerReentrancy) String() string
func (*HackerReentrancy) TestOracle ¶
func (oracle *HackerReentrancy) TestOracle() bool
func (*HackerReentrancy) Write ¶
func (oracle *HackerReentrancy) Write(writer io.Writer)
type HackerRepeatedCall ¶
type HackerRepeatedCall struct {
// contains filtered or unexported fields
}
* * Oracle: HackerRepeatedCall * to help us detect reductant inner call to others in the contract. * and this could help developer to write better code to save gas according gas mechanism on Ethereum.
func NewHackerRepeatedCall ¶
func NewHackerRepeatedCall() *HackerRepeatedCall
func (*HackerRepeatedCall) InitOracle ¶
func (oracle *HackerRepeatedCall) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerRepeatedCall) String ¶
func (oracle *HackerRepeatedCall) String() string
func (*HackerRepeatedCall) TestOracle ¶
func (oracle *HackerRepeatedCall) TestOracle() bool
func (*HackerRepeatedCall) Write ¶
func (oracle *HackerRepeatedCall) Write(writer io.Writer)
type HackerRootCallFailed ¶
type HackerRootCallFailed struct {
// contains filtered or unexported fields
}
func NewHackerRootCallFailed ¶
func NewHackerRootCallFailed() *HackerRootCallFailed
func (*HackerRootCallFailed) InitOracle ¶
func (oracle *HackerRootCallFailed) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerRootCallFailed) String ¶
func (Oracle *HackerRootCallFailed) String() string
func (*HackerRootCallFailed) TestOracle ¶
func (oracle *HackerRootCallFailed) TestOracle() bool
func (*HackerRootCallFailed) Write ¶
func (oracle *HackerRootCallFailed) Write(writer io.Writer)
type HackerSendOpInfo ¶
type HackerSendOpInfo struct {
// contains filtered or unexported fields
}
* *Oracle: HackerSendOpInfo *to help us detect the call whether cases such as "send()" works in the process.
func NewHackerSendOpInfo ¶
func NewHackerSendOpInfo() *HackerSendOpInfo
func (*HackerSendOpInfo) InitOracle ¶
func (oracle *HackerSendOpInfo) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerSendOpInfo) String ¶
func (oracle *HackerSendOpInfo) String() string
func (*HackerSendOpInfo) TestOracle ¶
func (oracle *HackerSendOpInfo) TestOracle() bool
func (*HackerSendOpInfo) Write ¶
func (oracle *HackerSendOpInfo) Write(writer io.Writer)
type HackerState ¶
type HackerState struct {
// contains filtered or unexported fields
}
func (*HackerState) Cmp ¶
func (state *HackerState) Cmp(other *HackerState) (int, string)
func (*HackerState) String ¶
func (state *HackerState) String() string
type HackerStateDiff ¶
type HackerStateDiff struct {
// contains filtered or unexported fields
}
type HackerStateStack ¶
type HackerStateStack struct {
// contains filtered or unexported fields
}
func (*HackerStateStack) Back ¶
func (st *HackerStateStack) Back(n int) *HackerState
Back returns the n'th item in stack
func (*HackerStateStack) Cmp ¶
func (stack *HackerStateStack) Cmp(other *HackerStateStack) (int, string)
func (*HackerStateStack) Data ¶
func (st *HackerStateStack) Data() []*HackerState
func (*HackerStateStack) Print ¶
func (st *HackerStateStack) Print()
func (*HackerStateStack) String ¶
func (stack *HackerStateStack) String() string
type HackerStorageChanged ¶
type HackerStorageChanged struct {
// contains filtered or unexported fields
}
* * Oracle: HackerStorageChanged * to help us detect the call who change storage of the called contract.
func NewHackerStorageChanged ¶
func NewHackerStorageChanged() *HackerStorageChanged
func (*HackerStorageChanged) InitOracle ¶
func (oracle *HackerStorageChanged) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerStorageChanged) String ¶
func (oracle *HackerStorageChanged) String() string
func (*HackerStorageChanged) TestOracle ¶
func (oracle *HackerStorageChanged) TestOracle() bool
func (*HackerStorageChanged) TriggerOracle ¶
func (oracle *HackerStorageChanged) TriggerOracle(rootCall *HackerContractCall) bool
func (*HackerStorageChanged) Write ¶
func (oracle *HackerStorageChanged) Write(writer io.Writer)
type HackerTimestampOp ¶
type HackerTimestampOp struct {
// contains filtered or unexported fields
}
* * Oracle: HackerTimestampOp * to help us detect the call where TIMESTAMP operation works.
func NewHackerTimestampOp ¶
func NewHackerTimestampOp() *HackerTimestampOp
func (*HackerTimestampOp) InitOracle ¶
func (oracle *HackerTimestampOp) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerTimestampOp) String ¶
func (oracle *HackerTimestampOp) String() string
func (*HackerTimestampOp) TestOracle ¶
func (oracle *HackerTimestampOp) TestOracle() bool
func (*HackerTimestampOp) Write ¶
func (oracle *HackerTimestampOp) Write(writer io.Writer)
type HackerUnknownCall ¶
type HackerUnknownCall struct {
// contains filtered or unexported fields
}
** *Oracle: HackerUnknownCall *to help us detech call that are specified by message sender or message input.
func NewHackerUnknowCall ¶
func NewHackerUnknowCall() *HackerUnknownCall
func (*HackerUnknownCall) InitOracle ¶
func (oracle *HackerUnknownCall) InitOracle(hacker_call_hashs []common.Hash, hacker_calls []*HackerContractCall)
func (*HackerUnknownCall) String ¶
func (oracle *HackerUnknownCall) String() string
func (*HackerUnknownCall) TestOracle ¶
func (oracle *HackerUnknownCall) TestOracle() bool
func (*HackerUnknownCall) TriggerOracle ¶
func (oracle *HackerUnknownCall) TriggerOracle(rootCall, call *HackerContractCall) bool
func (*HackerUnknownCall) Write ¶
func (oracle *HackerUnknownCall) Write(writer io.Writer)
type HackerUtils ¶
type HackerUtils struct{}
func (HackerUtils) Hash ¶
func (HackerUtils) Hash(call *HackerContractCall) common.Hash
func (HackerUtils) ShowDiffBalance ¶
func (HackerUtils) ShowDiffState ¶
func (HackerUtils) ShowDiffState(a *HackerState, b *HackerState) (bool, *HackerStateDiff)
type Hacker_ContractState ¶
type Hacker_ContractState struct {
// contains filtered or unexported fields
}
func (*Hacker_ContractState) Cmp ¶
func (state *Hacker_ContractState) Cmp(other *Hacker_ContractState) (int, string)
func (*Hacker_ContractState) String ¶
func (state *Hacker_ContractState) String() string
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
Interpreter is used to run Ethereum based contracts and will utilise the passed evmironment to query external sources for state information. The Interpreter will run the byte code VM or JIT VM based on the passed configuration.
func NewInterpreter ¶
func NewInterpreter(evm *EVM, cfg Config) *Interpreter
NewInterpreter returns a new instance of the Interpreter.
func (*Interpreter) Run ¶
Run loops and evaluates the contract's code with the given input data and returns the return byte-slice and an error if one occurred.
It's important to note that any errors returned by the interpreter should be considered a revert-and-consume-all-gas operation. No error specific checks should be handled to reduce complexity and errors further down the in.
type LogConfig ¶
type LogConfig struct { DisableMemory bool // disable memory capture DisableStack bool // disable stack capture DisableStorage bool // disable storage capture FullStorage bool // show full storage (slow) Limit int // maximum length of output, but zero means unlimited }
LogConfig are the configuration options for structured logger the EVM
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory implements a simple memory model for the ethereum virtual machine.
type NoopEVMCallContext ¶
type NoopEVMCallContext struct{}
func (NoopEVMCallContext) Call ¶
func (NoopEVMCallContext) Call(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
func (NoopEVMCallContext) CallCode ¶
func (NoopEVMCallContext) CallCode(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
func (NoopEVMCallContext) Create ¶
func (NoopEVMCallContext) Create(caller ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
func (NoopEVMCallContext) DelegateCall ¶
func (NoopEVMCallContext) DelegateCall(me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error)
type NoopStateDB ¶
type NoopStateDB struct{}
func (NoopStateDB) AddBalance ¶
func (NoopStateDB) AddBalance(common.Address, *big.Int)
func (NoopStateDB) AddLog ¶
func (NoopStateDB) AddLog(*types.Log)
func (NoopStateDB) AddPreimage ¶
func (NoopStateDB) AddPreimage(common.Hash, []byte)
func (NoopStateDB) AddRefund ¶
func (NoopStateDB) AddRefund(*big.Int)
func (NoopStateDB) CreateAccount ¶
func (NoopStateDB) CreateAccount(common.Address)
func (NoopStateDB) ForEachStorage ¶
func (NoopStateDB) GetBalance ¶
func (NoopStateDB) GetBalance(common.Address) *big.Int
func (NoopStateDB) GetCodeHash ¶
func (NoopStateDB) GetCodeHash(common.Address) common.Hash
func (NoopStateDB) GetCodeSize ¶
func (NoopStateDB) GetCodeSize(common.Address) int
func (NoopStateDB) GetRefund ¶
func (NoopStateDB) GetRefund() *big.Int
func (NoopStateDB) HasSuicided ¶
func (NoopStateDB) HasSuicided(common.Address) bool
func (NoopStateDB) RevertToSnapshot ¶
func (NoopStateDB) RevertToSnapshot(int)
func (NoopStateDB) Snapshot ¶
func (NoopStateDB) Snapshot() int
func (NoopStateDB) SubBalance ¶
func (NoopStateDB) SubBalance(common.Address, *big.Int)
type OpCode ¶
type OpCode byte
OpCode is an EVM opcode
const ( // 0x60 range PUSH1 OpCode = 0x60 + iota PUSH2 PUSH3 PUSH4 PUSH5 PUSH6 PUSH7 PUSH8 PUSH9 PUSH10 PUSH11 PUSH12 PUSH13 PUSH14 PUSH15 PUSH16 PUSH17 PUSH18 PUSH19 PUSH20 PUSH21 PUSH22 PUSH23 PUSH24 PUSH25 PUSH26 PUSH27 PUSH28 PUSH29 PUSH30 PUSH31 PUSH32 DUP1 DUP2 DUP3 DUP4 DUP5 DUP6 DUP7 DUP8 DUP9 DUP10 DUP11 DUP12 DUP13 DUP14 DUP15 DUP16 SWAP1 SWAP2 SWAP3 SWAP4 SWAP5 SWAP6 SWAP7 SWAP8 SWAP9 SWAP10 SWAP11 SWAP12 SWAP13 SWAP14 SWAP15 SWAP16 )
func StringToOp ¶
func (OpCode) IsStaticJump ¶
type PrecompiledContract ¶
type PrecompiledContract interface { RequiredGas(input []byte) uint64 // RequiredPrice calculates the contract gas use Run(input []byte) ([]byte, error) // Run runs the precompiled contract }
Precompiled contract is the basic interface for native Go contracts. The implementation requires a deterministic gas count based on the input size of the Run method of the contract.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
stack is an object for basic stack operations. Items popped to the stack are expected to be changed and modified. stack does not take care of adding newly initialised objects.
type StateDB ¶
type StateDB interface { CreateAccount(common.Address) SubBalance(common.Address, *big.Int) AddBalance(common.Address, *big.Int) GetBalance(common.Address) *big.Int GetNonce(common.Address) uint64 SetNonce(common.Address, uint64) GetCodeHash(common.Address) common.Hash GetCode(common.Address) []byte SetCode(common.Address, []byte) GetCodeSize(common.Address) int AddRefund(*big.Int) GetRefund() *big.Int GetState(common.Address, common.Hash) common.Hash SetState(common.Address, common.Hash, common.Hash) Suicide(common.Address) bool HasSuicided(common.Address) bool // Exist reports whether the given account exists in state. // Notably this should also return true for suicided accounts. Exist(common.Address) bool // Empty returns whether the given account is empty. Empty // is defined according to EIP161 (balance = nonce = code = 0). Empty(common.Address) bool RevertToSnapshot(int) GetNextRevisionId() int Snapshot() int AddLog(*types.Log) AddPreimage(common.Hash, []byte) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) }
StateDB is an EVM database for full state querying.
type StructLog ¶
type StructLog struct { Pc uint64 `json:"pc"` Op OpCode `json:"op"` Gas uint64 `json:"gas"` GasCost uint64 `json:"gasCost"` Memory []byte `json:"memory"` MemorySize int `json:"memSize"` Stack []*big.Int `json:"stack"` Storage map[common.Hash]common.Hash `json:"-"` Depth int `json:"depth"` Err error `json:"error"` }
StructLog is emitted to the EVM each cycle and lists information about the current internal state prior to the execution of the statement.
func (StructLog) MarshalJSON ¶
func (*StructLog) UnmarshalJSON ¶
type StructLogger ¶
type StructLogger struct {
// contains filtered or unexported fields
}
StructLogger is an EVM state logger and implements Tracer.
StructLogger can capture state based on the given Log configuration and also keeps a track record of modified storage which is used in reporting snapshots of the contract their storage.
func NewStructLogger ¶
func NewStructLogger(cfg *LogConfig) *StructLogger
NewStructLogger returns a new logger
func (*StructLogger) CaptureEnd ¶
func (*StructLogger) CaptureState ¶
func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error
CaptureState logs a new structured log message and pushes it out to the environment
CaptureState also tracks SSTORE ops to track dirty values.
func (*StructLogger) StructLogs ¶
func (l *StructLogger) StructLogs() []StructLog
StructLogs returns a list of captured log entries
type Tracer ¶
type Tracer interface { CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error CaptureEnd(output []byte, gasUsed uint64, t time.Duration) error }
Tracer is used to collect execution traces from an EVM transaction execution. CaptureState is called for each step of the VM with the current VM state. Note that reference types are actual VM data structures; make copies if you need to retain them beyond the current call.
Source Files
¶
- analysis.go
- common.go
- contract.go
- contracts.go
- doc.go
- errors.go
- evm.go
- gas.go
- gas_table.go
- gen_structlog.go
- hacker_contractcall.go
- hacker_hub.go
- hacker_instruction.go
- hacker_operation.go
- hacker_oracle.go
- hacker_state.go
- hacker_utils.go
- instructions.go
- int_pool_verifier_empty.go
- interface.go
- interpreter.go
- intpool.go
- jump_table.go
- logger.go
- memory.go
- memory_table.go
- noop.go
- opcodes.go
- stack.go
- stack_table.go
- vm_jit_fake.go