Documentation
¶
Overview ¶
Package vm implements the Ethereum Virtual Machine.
The vm package implements one EVM, a byte code 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.
Index ¶
- Constants
- Variables
- func IdToAddress(id coreTypes.NodeID) common.Address
- func PackAddDKGComplaint(complaint *dkgTypes.Complaint) ([]byte, error)
- func PackAddDKGFinalize(final *dkgTypes.Finalize) ([]byte, error)
- func PackAddDKGMPKReady(ready *dkgTypes.MPKReady) ([]byte, error)
- func PackAddDKGMasterPublicKey(mpk *dkgTypes.MasterPublicKey) ([]byte, error)
- func PackAddDKGSuccess(final *dkgTypes.Success) ([]byte, error)
- func PackProposeCRS(round uint64, signedCRS []byte) ([]byte, error)
- func PackReportForkBlock(block1, block2 *coreTypes.Block) ([]byte, error)
- func PackReportForkVote(vote1, vote2 *coreTypes.Vote) ([]byte, error)
- func PackResetDKG(newSignedCRS []byte) ([]byte, error)
- func RunOracleContract(oracle OracleContract, evm *EVM, input []byte, contract *Contract) (ret []byte, err error)
- func RunPrecompiledContract(p PrecompiledContract, input []byte, contract *Contract) (ret []byte, err error)
- func WriteLogs(writer io.Writer, logs []*types.Log)
- func WriteTrace(writer io.Writer, logs []StructLog)
- type AccountRef
- type Bytes32
- 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 (c *Contract) SetCallCode(addr *common.Address, hash common.Hash, code []byte)
- func (c *Contract) SetCodeOptionalHash(addr *common.Address, codeAndHash *codeAndHash)
- 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) Create2(caller ContractRef, code []byte, gas uint64, endowment *big.Int, salt *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
- func (evm *EVM) IsBlockProposer() bool
- func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error)
- type EVMInterpreter
- type FineType
- type GetHashFunc
- type GetRoundHeightFunc
- type GovUtil
- type GovUtilInterface
- type GovernanceContract
- func (g *GovernanceContract) Address() common.Address
- func (g *GovernanceContract) GetHeadGovState() (*GovernanceState, error)
- func (g *GovernanceContract) Run(evm *EVM, input []byte, contract *Contract) (ret []byte, err error)
- func (g *GovernanceContract) StateAt(height uint64) (*state.StateDB, error)
- type GovernanceState
- func (s *GovernanceState) AddToWhitelist(addr common.Address) *big.Int
- func (s *GovernanceState) AddressWhitelist(index *big.Int) common.Address
- func (s *GovernanceState) AddressWhitelists() []common.Address
- func (s *GovernanceState) BlockGasLimit() *big.Int
- func (s *GovernanceState) CRS() common.Hash
- func (s *GovernanceState) CRSRound() *big.Int
- func (s *GovernanceState) CalNotarySetSize()
- func (s *GovernanceState) ClearDKGComplaintProposed()
- func (s *GovernanceState) ClearDKGComplaints()
- func (s *GovernanceState) ClearDKGFinalizeds(dkgSet map[coreTypes.NodeID]struct{})
- func (s *GovernanceState) ClearDKGMPKReadys(notarySet map[coreTypes.NodeID]struct{})
- func (s *GovernanceState) ClearDKGMasterPublicKeyOffset()
- func (s *GovernanceState) ClearDKGMasterPublicKeys()
- func (s *GovernanceState) ClearDKGSuccesses(dkgSet map[coreTypes.NodeID]struct{})
- func (s *GovernanceState) Configuration() *params.DexconConfig
- func (s *GovernanceState) DKGComplaint(offset *big.Int) []byte
- func (s *GovernanceState) DKGComplaintItems() []*dkgTypes.Complaint
- func (s *GovernanceState) DKGComplaintProposed(id Bytes32) bool
- func (s *GovernanceState) DKGComplaints() [][]byte
- func (s *GovernanceState) DKGFinalized(addr common.Address) bool
- func (s *GovernanceState) DKGFinalizedsCount() *big.Int
- func (s *GovernanceState) DKGMPKReady(addr common.Address) bool
- func (s *GovernanceState) DKGMPKReadysCount() *big.Int
- func (s *GovernanceState) DKGMasterPublicKey(offset *big.Int) []byte
- func (s *GovernanceState) DKGMasterPublicKeyItem(offset *big.Int) *dkgTypes.MasterPublicKey
- func (s *GovernanceState) DKGMasterPublicKeyItems() []*dkgTypes.MasterPublicKey
- func (s *GovernanceState) DKGMasterPublicKeyOffset(id Bytes32) *big.Int
- func (s *GovernanceState) DKGMasterPublicKeys() [][]byte
- func (s *GovernanceState) DKGResetCount(round *big.Int) *big.Int
- func (s *GovernanceState) DKGRound() *big.Int
- func (s *GovernanceState) DKGSuccess(addr common.Address) bool
- func (s *GovernanceState) DKGSuccessesCount() *big.Int
- func (s *GovernanceState) DecTotalStaked(amount *big.Int)
- func (s *GovernanceState) DecTotalSupply(amount *big.Int)
- func (s *GovernanceState) DeleteAddressWhitelist(addr common.Address) *big.Int
- func (s *GovernanceState) DeleteNodeOffsets(n *nodeInfo)
- func (s *GovernanceState) DeleteNodesOffsetByAddress(addr common.Address)
- func (s *GovernanceState) DeleteNodesOffsetByNodeKeyAddress(addr common.Address)
- func (s *GovernanceState) DeleteWhitelistOffsetByAddress(addr common.Address)
- func (s *GovernanceState) Disqualify(n *nodeInfo) error
- func (s *GovernanceState) EnableConsortium()
- func (s *GovernanceState) EraseNode(index *big.Int)
- func (s *GovernanceState) FineRecords(recordHash Bytes32) bool
- func (s *GovernanceState) FineValue(index *big.Int) *big.Int
- func (s *GovernanceState) FineValues() []*big.Int
- func (s *GovernanceState) FinedNodes() []*nodeInfo
- func (s *GovernanceState) GetNodeByID(id coreTypes.NodeID) (*nodeInfo, error)
- func (s *GovernanceState) HalfLastHalvedAmount()
- func (s *GovernanceState) HalfMiningVelocity()
- func (s *GovernanceState) IncDKGFinalizedsCount()
- func (s *GovernanceState) IncDKGMPKReadysCount()
- func (s *GovernanceState) IncDKGResetCount(round *big.Int)
- func (s *GovernanceState) IncDKGSuccessesCount()
- func (s *GovernanceState) IncNextHalvingSupply(amount *big.Int)
- func (s *GovernanceState) IncTotalStaked(amount *big.Int)
- func (s *GovernanceState) IncTotalSupply(amount *big.Int)
- func (s *GovernanceState) Initialize(config *params.DexconConfig, totalSupply *big.Int)
- func (s *GovernanceState) IsConsortium() bool
- func (s *GovernanceState) LambdaBA() *big.Int
- func (s *GovernanceState) LambdaDKG() *big.Int
- func (s *GovernanceState) LastHalvedAmount() *big.Int
- func (s *GovernanceState) LastProposedHeight(addr common.Address) *big.Int
- func (s *GovernanceState) LenDKGComplaints() *big.Int
- func (s *GovernanceState) LenDKGMasterPublicKeys() *big.Int
- func (s *GovernanceState) LenNodes() *big.Int
- func (s *GovernanceState) LenWhitelist() *big.Int
- func (s *GovernanceState) LockupPeriod() *big.Int
- func (s *GovernanceState) MinBlockInterval() *big.Int
- func (s *GovernanceState) MinGasPrice() *big.Int
- func (s *GovernanceState) MinStake() *big.Int
- func (s *GovernanceState) MiningHalved()
- func (s *GovernanceState) MiningVelocity() *big.Int
- func (s *GovernanceState) NextHalvingSupply() *big.Int
- func (s *GovernanceState) Node(index *big.Int) *nodeInfo
- func (s *GovernanceState) Nodes() []*nodeInfo
- func (s *GovernanceState) NodesOffsetByAddress(addr common.Address) *big.Int
- func (s *GovernanceState) NodesOffsetByNodeKeyAddress(addr common.Address) *big.Int
- func (s *GovernanceState) NotaryParamAlpha() *big.Int
- func (s *GovernanceState) NotaryParamBeta() *big.Int
- func (s *GovernanceState) NotarySetSize() *big.Int
- func (s *GovernanceState) Owner() common.Address
- func (s *GovernanceState) PopLastNode()
- func (s *GovernanceState) PushDKGComplaint(complaint []byte)
- func (s *GovernanceState) PushDKGMasterPublicKey(mpk []byte)
- func (s *GovernanceState) PushNode(n *nodeInfo)
- func (s *GovernanceState) PushRoundHeight(height *big.Int)
- func (s *GovernanceState) PutDKGComplaintProposed(id Bytes32, status bool)
- func (s *GovernanceState) PutDKGFinalized(addr common.Address, finalized bool)
- func (s *GovernanceState) PutDKGMPKReady(addr common.Address, ready bool)
- func (s *GovernanceState) PutDKGMasterPublicKeyOffset(id Bytes32, offset *big.Int)
- func (s *GovernanceState) PutDKGSuccess(addr common.Address, success bool)
- func (s *GovernanceState) PutLastProposedHeight(addr common.Address, height *big.Int)
- func (s *GovernanceState) PutNodeOffsets(n *nodeInfo, offset *big.Int)
- func (s *GovernanceState) PutNodesOffsetByAddress(addr common.Address, offset *big.Int)
- func (s *GovernanceState) PutNodesOffsetByNodeKeyAddress(addr common.Address, offset *big.Int)
- func (s *GovernanceState) QualifiedNodes() []*nodeInfo
- func (s *GovernanceState) Register(addr common.Address, publicKey []byte, name, email, location, url string, ...)
- func (s *GovernanceState) ResetDKGFinalizedsCount()
- func (s *GovernanceState) ResetDKGMPKReadysCount()
- func (s *GovernanceState) ResetDKGSuccessesCount()
- func (s *GovernanceState) RoundHeight(round *big.Int) *big.Int
- func (s *GovernanceState) RoundLength() *big.Int
- func (s *GovernanceState) SetBlockGasLimit(reward *big.Int)
- func (s *GovernanceState) SetCRS(crs common.Hash)
- func (s *GovernanceState) SetCRSRound(round *big.Int)
- func (s *GovernanceState) SetDKGRound(round *big.Int)
- func (s *GovernanceState) SetFineRecords(recordHash Bytes32, status bool)
- func (s *GovernanceState) SetFineValues(values []*big.Int)
- func (s *GovernanceState) SetOwner(newOwner common.Address)
- func (s *GovernanceState) TotalStaked() *big.Int
- func (s *GovernanceState) TotalSupply() *big.Int
- func (s *GovernanceState) UpdateConfiguration(cfg *params.DexconConfig)
- func (s *GovernanceState) UpdateConfigurationRaw(cfg *rawConfigStruct)
- func (s *GovernanceState) UpdateNode(index *big.Int, n *nodeInfo)
- func (s *GovernanceState) UpdateNodeInfo(index *big.Int, n *nodeInfo)
- func (s *GovernanceState) WhitelistOffsetByAddress(addr common.Address) *big.Int
- type Interpreter
- type JSONLogger
- func (l *JSONLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error
- func (l *JSONLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, ...) error
- func (l *JSONLogger) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, ...) error
- func (l *JSONLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, ...) error
- type LogConfig
- type Memory
- func (m *Memory) Data() []byte
- func (m *Memory) Get(offset, size int64) (cpy []byte)
- func (m *Memory) GetPtr(offset, size int64) []byte
- func (m *Memory) Len() int
- func (m *Memory) Print()
- func (m *Memory) Resize(size uint64)
- func (m *Memory) Set(offset, size uint64, value []byte)
- func (m *Memory) Set32(offset uint64, val *big.Int)
- type OpCode
- type OracleContract
- type OracleContractABI
- type PrecompiledContract
- type RandomContract
- type Stack
- type StateAtNumberFunc
- type StateDB
- type Storage
- type StructLog
- type StructLogger
- func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error
- func (l *StructLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, ...) error
- func (l *StructLogger) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, ...) error
- func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, ...) error
- func (l *StructLogger) Error() error
- func (l *StructLogger) Output() []byte
- func (l *StructLogger) StructLogs() []StructLog
- 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 )
Gas costs
const ( FineTypeFailStop = iota FineTypeFailStopDKG FineTypeInvalidDKG FineTypeForkVote FineTypeForkBlock )
const GovernanceABIJSON = `` /* 22783-byte string literal not displayed */
const GovernanceActionGasCost = 200000
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") ErrContractAddressCollision = errors.New("contract address collision") ErrNoCompatibleInterpreter = errors.New("no compatible interpreter") )
List execution errors
var GovernanceContractAddress = common.HexToAddress("0x246fcde58581e2754f215a523c0718c4bfc8041f")
Tangerine Network Governance
var OracleContracts = map[common.Address]func() OracleContract{ GovernanceContractAddress: func() OracleContract { return &GovernanceContract{ coreDKGUtil: &defaultCoreDKGUtil{}, } }, RandomContractAddress: func() OracleContract { return &RandomContract{} }, }
A map representing available system oracle contracts.
var PrecompiledContractsByzantium = map[common.Address]PrecompiledContract{ common.BytesToAddress([]byte{1}): &ecrecover{}, common.BytesToAddress([]byte{2}): &sha256hash{}, common.BytesToAddress([]byte{3}): &ripemd160hash{}, common.BytesToAddress([]byte{4}): &dataCopy{}, common.BytesToAddress([]byte{5}): &bigModExp{}, common.BytesToAddress([]byte{6}): &bn256Add{}, common.BytesToAddress([]byte{7}): &bn256ScalarMul{}, common.BytesToAddress([]byte{8}): &bn256Pairing{}, }
PrecompiledContractsByzantium contains the default set of pre-compiled Ethereum contracts used in the Byzantium release.
var PrecompiledContractsHomestead = map[common.Address]PrecompiledContract{ common.BytesToAddress([]byte{1}): &ecrecover{}, common.BytesToAddress([]byte{2}): &sha256hash{}, common.BytesToAddress([]byte{3}): &ripemd160hash{}, common.BytesToAddress([]byte{4}): &dataCopy{}, }
PrecompiledContractsHomestead contains the default set of pre-compiled Ethereum contracts used in the Frontier and Homestead releases.
var RandomContractAddress = common.HexToAddress("0xc327ff1025c5b3d2deb5e3f0f161b3f7e557579a")
Tangerine Network Random
Functions ¶
func PackAddDKGMasterPublicKey ¶
func PackAddDKGMasterPublicKey(mpk *dkgTypes.MasterPublicKey) ([]byte, error)
func PackReportForkBlock ¶
func PackResetDKG ¶
func RunOracleContract ¶
func RunOracleContract(oracle OracleContract, evm *EVM, input []byte, contract *Contract) (ret []byte, err error)
Run oracle contract.
func RunPrecompiledContract ¶ added in v1.5.6
func RunPrecompiledContract(p PrecompiledContract, input []byte, contract *Contract) (ret []byte, err error)
RunPrecompiledContract runs and evaluates the output of a precompiled contract.
func WriteTrace ¶ added in v1.6.0
WriteTrace writes a formatted trace to the given writer
Types ¶
type AccountRef ¶ added in v1.6.0
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 ¶ added in v1.6.0
func (ar AccountRef) Address() common.Address
Address casts AccountRef to a Address
type CallContext ¶ added in v1.5.5
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 depends on this context being implemented for doing subcalls and initialising new EVM contracts.
type CanTransferFunc ¶ added in v1.5.5
CanTransferFunc is the signature of a transfer guard function
type Config ¶ added in v1.4.0
type Config struct { // Debug enabled debugging Interpreter options Debug bool // Tracer is the op code logger Tracer Tracer // NoRecursion disabled Interpreter call, callcode, // delegate call and create. NoRecursion 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 // Type of the EWASM interpreter EWASMInterpreter string // Type of the EVM interpreter EVMInterpreter string // Whether or not we are a block proposer. IsBlockProposer bool }
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 // StateAtNumber returns the statedb given a root hash. StateAtNumber StateAtNumberFunc // GetRoundHeight returns the round height. GetRoundHeight GetRoundHeightFunc // 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 uint64 // Provides information for GASLIMIT BlockNumber *big.Int // Provides information for NUMBER Time *big.Int // Provides information for TIME Randomness []byte // Provides information for RAND Difficulty *big.Int // Provides information for DIFFICULTY Round *big.Int // Current round number. RandCallIndex uint64 // Number of times RandomContract is called }
Context provides the EVM with auxiliary information. Once provided it shouldn't be modified.
type Contract ¶ added in v1.3.1
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 // contains filtered or unexported fields }
Contract represents an ethereum contract in the state database. It contains the contract code, calling arguments. Contract implements ContractRef
func NewContract ¶ added in v1.3.1
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 ¶ added in v1.3.4
AsDelegate sets the contract to be a delegate call and returns the current contract (for chaining calls)
func (*Contract) Caller ¶ added in v1.3.4
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) GetByte ¶ added in v1.3.1
GetByte returns the n'th byte in the contract's byte array
func (*Contract) GetOp ¶ added in v1.3.1
GetOp returns the n'th element in the contract's byte array
func (*Contract) SetCallCode ¶ added in v1.3.1
SetCallCode sets the code of the contract and address of the backing data object
func (*Contract) SetCodeOptionalHash ¶ added in v1.8.17
SetCodeOptionalHash can be used to provide code, but it's optional to provide hash. In case hash is not provided, the jumpdest analysis will not be saved to the parent context
type ContractRef ¶ added in v1.3.1
ContractRef is a reference to the contract's backing object
type EVM ¶ added in v1.4.0
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 ¶ added in v1.5.6
NewEVM returns a new EVM. The returned EVM is not thread safe and should only ever be used *once*.
func (*EVM) Call ¶ added in v1.5.6
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 ¶ added in v1.5.6
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 ¶ added in v1.5.6
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 ¶ added in v1.5.6
func (evm *EVM) ChainConfig() *params.ChainConfig
ChainConfig returns the environment's chain configuration
func (*EVM) Create ¶ added in v1.5.6
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) Create2 ¶ added in v1.8.13
func (evm *EVM) Create2(caller ContractRef, code []byte, gas uint64, endowment *big.Int, salt *big.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error)
Create2 creates a new contract using code as deployment code.
The different between Create2 with Create is Create2 uses sha3(0xff ++ msg.sender ++ salt ++ sha3(init_code))[12:] instead of the usual sender-and-nonce-hash as the address where the contract is initialized at.
func (*EVM) DelegateCall ¶ added in v1.5.6
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 ¶ added in v1.5.6
func (evm *EVM) Interpreter() Interpreter
Interpreter returns the current interpreter
func (*EVM) IsBlockProposer ¶
IsBlockProposer returns whether or not we are a block proposer.
func (*EVM) StaticCall ¶ added in v1.7.0
func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error)
StaticCall executes the contract associated with the addr with the given input as parameters while disallowing any modifications to the state during the call. Opcodes that attempt to perform such modifications will result in exceptions instead of performing the modifications.
type EVMInterpreter ¶ added in v1.8.13
type EVMInterpreter struct {
// contains filtered or unexported fields
}
EVMInterpreter represents an EVM interpreter
func NewEVMInterpreter ¶ added in v1.8.13
func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter
NewEVMInterpreter returns a new instance of the Interpreter.
func (*EVMInterpreter) CanRun ¶ added in v1.8.13
func (in *EVMInterpreter) CanRun(code []byte) bool
CanRun tells if the contract, passed as an argument, can be run by the current interpreter.
func (*EVMInterpreter) Run ¶ added in v1.8.13
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error)
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 except for errExecutionReverted which means revert-and-keep-gas-left.
type GetHashFunc ¶ added in v1.5.5
GetHashFunc returns the nth block hash in the blockchain and is used by the BLOCKHASH EVM op code.
type GetRoundHeightFunc ¶
GetRoundHeightFunc returns the round height.
type GovUtil ¶
type GovUtil struct {
Intf GovUtilInterface
}
func (GovUtil) GetConfigState ¶
func (g GovUtil) GetConfigState(round uint64) (*GovernanceState, error)
func (GovUtil) GetRoundHeight ¶
func (GovUtil) GetStateAtRound ¶
func (g GovUtil) GetStateAtRound(round uint64) (*GovernanceState, error)
type GovUtilInterface ¶
type GovernanceContract ¶
type GovernanceContract struct {
// contains filtered or unexported fields
}
GovernanceContract represents the governance contract of DEXCON.
func (*GovernanceContract) Address ¶
func (g *GovernanceContract) Address() common.Address
func (*GovernanceContract) GetHeadGovState ¶
func (g *GovernanceContract) GetHeadGovState() (*GovernanceState, error)
type GovernanceState ¶
type GovernanceState struct {
StateDB StateDB
}
State manipulation helper for the governance contract.
func (*GovernanceState) AddToWhitelist ¶
func (s *GovernanceState) AddToWhitelist(addr common.Address) *big.Int
func (*GovernanceState) AddressWhitelist ¶
func (s *GovernanceState) AddressWhitelist(index *big.Int) common.Address
func (*GovernanceState) AddressWhitelists ¶
func (s *GovernanceState) AddressWhitelists() []common.Address
func (*GovernanceState) BlockGasLimit ¶
func (s *GovernanceState) BlockGasLimit() *big.Int
uint256 public blockGasLimit;
func (*GovernanceState) CRSRound ¶
func (s *GovernanceState) CRSRound() *big.Int
uint256 public crsRound;
func (*GovernanceState) CalNotarySetSize ¶
func (s *GovernanceState) CalNotarySetSize()
func (*GovernanceState) ClearDKGComplaintProposed ¶
func (s *GovernanceState) ClearDKGComplaintProposed()
func (*GovernanceState) ClearDKGComplaints ¶
func (s *GovernanceState) ClearDKGComplaints()
func (*GovernanceState) ClearDKGFinalizeds ¶
func (s *GovernanceState) ClearDKGFinalizeds(dkgSet map[coreTypes.NodeID]struct{})
func (*GovernanceState) ClearDKGMPKReadys ¶
func (s *GovernanceState) ClearDKGMPKReadys(notarySet map[coreTypes.NodeID]struct{})
func (*GovernanceState) ClearDKGMasterPublicKeyOffset ¶
func (s *GovernanceState) ClearDKGMasterPublicKeyOffset()
func (*GovernanceState) ClearDKGMasterPublicKeys ¶
func (s *GovernanceState) ClearDKGMasterPublicKeys()
func (*GovernanceState) ClearDKGSuccesses ¶
func (s *GovernanceState) ClearDKGSuccesses(dkgSet map[coreTypes.NodeID]struct{})
func (*GovernanceState) Configuration ¶
func (s *GovernanceState) Configuration() *params.DexconConfig
Configuration returns the current configuration.
func (*GovernanceState) DKGComplaint ¶
func (s *GovernanceState) DKGComplaint(offset *big.Int) []byte
func (*GovernanceState) DKGComplaintItems ¶
func (s *GovernanceState) DKGComplaintItems() []*dkgTypes.Complaint
func (*GovernanceState) DKGComplaintProposed ¶
func (s *GovernanceState) DKGComplaintProposed(id Bytes32) bool
mapping(bytes32 => bool) public dkgComplaintsProposed;
func (*GovernanceState) DKGComplaints ¶
func (s *GovernanceState) DKGComplaints() [][]byte
func (*GovernanceState) DKGFinalized ¶
func (s *GovernanceState) DKGFinalized(addr common.Address) bool
mapping(address => bool) public dkgFinalizeds;
func (*GovernanceState) DKGFinalizedsCount ¶
func (s *GovernanceState) DKGFinalizedsCount() *big.Int
uint256 public dkgFinalizedsCount;
func (*GovernanceState) DKGMPKReady ¶
func (s *GovernanceState) DKGMPKReady(addr common.Address) bool
mapping(address => bool) public dkgMPKReadys;
func (*GovernanceState) DKGMPKReadysCount ¶
func (s *GovernanceState) DKGMPKReadysCount() *big.Int
uint256 public dkgMPKReadysCount;
func (*GovernanceState) DKGMasterPublicKey ¶
func (s *GovernanceState) DKGMasterPublicKey(offset *big.Int) []byte
func (*GovernanceState) DKGMasterPublicKeyItem ¶
func (s *GovernanceState) DKGMasterPublicKeyItem(offset *big.Int) *dkgTypes.MasterPublicKey
func (*GovernanceState) DKGMasterPublicKeyItems ¶
func (s *GovernanceState) DKGMasterPublicKeyItems() []*dkgTypes.MasterPublicKey
func (*GovernanceState) DKGMasterPublicKeyOffset ¶
func (s *GovernanceState) DKGMasterPublicKeyOffset(id Bytes32) *big.Int
mapping(bytes32 => uint256) public dkgMasterPublicKeyOffset;
func (*GovernanceState) DKGMasterPublicKeys ¶
func (s *GovernanceState) DKGMasterPublicKeys() [][]byte
func (*GovernanceState) DKGResetCount ¶
func (s *GovernanceState) DKGResetCount(round *big.Int) *big.Int
uint256[] public dkgResetCount;
func (*GovernanceState) DKGRound ¶
func (s *GovernanceState) DKGRound() *big.Int
uint256 public dkgRound;
func (*GovernanceState) DKGSuccess ¶
func (s *GovernanceState) DKGSuccess(addr common.Address) bool
mapping(address => bool) public dkgSuccesses;
func (*GovernanceState) DKGSuccessesCount ¶
func (s *GovernanceState) DKGSuccessesCount() *big.Int
uint256 public dkgSuccessesCount;
func (*GovernanceState) DecTotalStaked ¶
func (s *GovernanceState) DecTotalStaked(amount *big.Int)
func (*GovernanceState) DecTotalSupply ¶
func (s *GovernanceState) DecTotalSupply(amount *big.Int)
func (*GovernanceState) DeleteAddressWhitelist ¶
func (s *GovernanceState) DeleteAddressWhitelist(addr common.Address) *big.Int
func (*GovernanceState) DeleteNodeOffsets ¶
func (s *GovernanceState) DeleteNodeOffsets(n *nodeInfo)
func (*GovernanceState) DeleteNodesOffsetByAddress ¶
func (s *GovernanceState) DeleteNodesOffsetByAddress(addr common.Address)
func (*GovernanceState) DeleteNodesOffsetByNodeKeyAddress ¶
func (s *GovernanceState) DeleteNodesOffsetByNodeKeyAddress(addr common.Address)
func (*GovernanceState) DeleteWhitelistOffsetByAddress ¶
func (s *GovernanceState) DeleteWhitelistOffsetByAddress(addr common.Address)
func (*GovernanceState) Disqualify ¶
func (s *GovernanceState) Disqualify(n *nodeInfo) error
func (*GovernanceState) EnableConsortium ¶
func (s *GovernanceState) EnableConsortium()
func (*GovernanceState) EraseNode ¶
func (s *GovernanceState) EraseNode(index *big.Int)
func (*GovernanceState) FineRecords ¶
func (s *GovernanceState) FineRecords(recordHash Bytes32) bool
mapping(bytes32 => bool) public fineRdecords;
func (*GovernanceState) FineValue ¶
func (s *GovernanceState) FineValue(index *big.Int) *big.Int
uint256[] public fineValues;
func (*GovernanceState) FineValues ¶
func (s *GovernanceState) FineValues() []*big.Int
func (*GovernanceState) FinedNodes ¶
func (s *GovernanceState) FinedNodes() []*nodeInfo
func (*GovernanceState) GetNodeByID ¶
func (s *GovernanceState) GetNodeByID(id coreTypes.NodeID) (*nodeInfo, error)
func (*GovernanceState) HalfLastHalvedAmount ¶
func (s *GovernanceState) HalfLastHalvedAmount()
func (*GovernanceState) HalfMiningVelocity ¶
func (s *GovernanceState) HalfMiningVelocity()
func (*GovernanceState) IncDKGFinalizedsCount ¶
func (s *GovernanceState) IncDKGFinalizedsCount()
func (*GovernanceState) IncDKGMPKReadysCount ¶
func (s *GovernanceState) IncDKGMPKReadysCount()
func (*GovernanceState) IncDKGResetCount ¶
func (s *GovernanceState) IncDKGResetCount(round *big.Int)
func (*GovernanceState) IncDKGSuccessesCount ¶
func (s *GovernanceState) IncDKGSuccessesCount()
func (*GovernanceState) IncNextHalvingSupply ¶
func (s *GovernanceState) IncNextHalvingSupply(amount *big.Int)
func (*GovernanceState) IncTotalStaked ¶
func (s *GovernanceState) IncTotalStaked(amount *big.Int)
func (*GovernanceState) IncTotalSupply ¶
func (s *GovernanceState) IncTotalSupply(amount *big.Int)
func (*GovernanceState) Initialize ¶
func (s *GovernanceState) Initialize(config *params.DexconConfig, totalSupply *big.Int)
Initialize initializes governance contract state.
func (*GovernanceState) IsConsortium ¶
func (s *GovernanceState) IsConsortium() bool
bool public isConsortium;
func (*GovernanceState) LambdaBA ¶
func (s *GovernanceState) LambdaBA() *big.Int
uint256 public lambdaBA;
func (*GovernanceState) LambdaDKG ¶
func (s *GovernanceState) LambdaDKG() *big.Int
uint256 public lambdaDKG;
func (*GovernanceState) LastHalvedAmount ¶
func (s *GovernanceState) LastHalvedAmount() *big.Int
uint256 public lastHalvedAmount;
func (*GovernanceState) LastProposedHeight ¶
func (s *GovernanceState) LastProposedHeight(addr common.Address) *big.Int
mapping(address => uint256) public lastProposedHeight;
func (*GovernanceState) LenDKGComplaints ¶
func (s *GovernanceState) LenDKGComplaints() *big.Int
bytes[] public dkgComplaints;
func (*GovernanceState) LenDKGMasterPublicKeys ¶
func (s *GovernanceState) LenDKGMasterPublicKeys() *big.Int
bytes[] public dkgMasterPublicKeys;
func (*GovernanceState) LenNodes ¶
func (s *GovernanceState) LenNodes() *big.Int
func (*GovernanceState) LenWhitelist ¶
func (s *GovernanceState) LenWhitelist() *big.Int
address[] public addressWhitelist;
func (*GovernanceState) LockupPeriod ¶
func (s *GovernanceState) LockupPeriod() *big.Int
uint256 public lockupPeriod;
func (*GovernanceState) MinBlockInterval ¶
func (s *GovernanceState) MinBlockInterval() *big.Int
uint256 public minBlockInterval;
func (*GovernanceState) MinGasPrice ¶
func (s *GovernanceState) MinGasPrice() *big.Int
uint256 public minGasPrice;
func (*GovernanceState) MinStake ¶
func (s *GovernanceState) MinStake() *big.Int
uint256 public minStake;
func (*GovernanceState) MiningHalved ¶
func (s *GovernanceState) MiningHalved()
func (*GovernanceState) MiningVelocity ¶
func (s *GovernanceState) MiningVelocity() *big.Int
uint256 public miningVelocity;
func (*GovernanceState) NextHalvingSupply ¶
func (s *GovernanceState) NextHalvingSupply() *big.Int
uint256 public nextHalvingSupply;
func (*GovernanceState) Node ¶
func (s *GovernanceState) Node(index *big.Int) *nodeInfo
func (*GovernanceState) Nodes ¶
func (s *GovernanceState) Nodes() []*nodeInfo
func (*GovernanceState) NodesOffsetByAddress ¶
func (s *GovernanceState) NodesOffsetByAddress(addr common.Address) *big.Int
mapping(address => uint256) public nodesOffsetByAddress;
func (*GovernanceState) NodesOffsetByNodeKeyAddress ¶
func (s *GovernanceState) NodesOffsetByNodeKeyAddress(addr common.Address) *big.Int
mapping(address => uint256) public nodesOffsetByNodeKeyAddress;
func (*GovernanceState) NotaryParamAlpha ¶
func (s *GovernanceState) NotaryParamAlpha() *big.Int
uint256 public notaryParamAlpha;
func (*GovernanceState) NotaryParamBeta ¶
func (s *GovernanceState) NotaryParamBeta() *big.Int
uint256 public notaryParamBeta;
func (*GovernanceState) NotarySetSize ¶
func (s *GovernanceState) NotarySetSize() *big.Int
uint256 public notarySetSize;
func (*GovernanceState) Owner ¶
func (s *GovernanceState) Owner() common.Address
address public owner;
func (*GovernanceState) PopLastNode ¶
func (s *GovernanceState) PopLastNode()
func (*GovernanceState) PushDKGComplaint ¶
func (s *GovernanceState) PushDKGComplaint(complaint []byte)
func (*GovernanceState) PushDKGMasterPublicKey ¶
func (s *GovernanceState) PushDKGMasterPublicKey(mpk []byte)
func (*GovernanceState) PushNode ¶
func (s *GovernanceState) PushNode(n *nodeInfo)
func (*GovernanceState) PushRoundHeight ¶
func (s *GovernanceState) PushRoundHeight(height *big.Int)
func (*GovernanceState) PutDKGComplaintProposed ¶
func (s *GovernanceState) PutDKGComplaintProposed(id Bytes32, status bool)
func (*GovernanceState) PutDKGFinalized ¶
func (s *GovernanceState) PutDKGFinalized(addr common.Address, finalized bool)
func (*GovernanceState) PutDKGMPKReady ¶
func (s *GovernanceState) PutDKGMPKReady(addr common.Address, ready bool)
func (*GovernanceState) PutDKGMasterPublicKeyOffset ¶
func (s *GovernanceState) PutDKGMasterPublicKeyOffset(id Bytes32, offset *big.Int)
func (*GovernanceState) PutDKGSuccess ¶
func (s *GovernanceState) PutDKGSuccess(addr common.Address, success bool)
func (*GovernanceState) PutLastProposedHeight ¶
func (s *GovernanceState) PutLastProposedHeight(addr common.Address, height *big.Int)
func (*GovernanceState) PutNodeOffsets ¶
func (s *GovernanceState) PutNodeOffsets(n *nodeInfo, offset *big.Int)
func (*GovernanceState) PutNodesOffsetByAddress ¶
func (s *GovernanceState) PutNodesOffsetByAddress(addr common.Address, offset *big.Int)
func (*GovernanceState) PutNodesOffsetByNodeKeyAddress ¶
func (s *GovernanceState) PutNodesOffsetByNodeKeyAddress(addr common.Address, offset *big.Int)
func (*GovernanceState) QualifiedNodes ¶
func (s *GovernanceState) QualifiedNodes() []*nodeInfo
func (*GovernanceState) Register ¶
func (s *GovernanceState) Register( addr common.Address, publicKey []byte, name, email, location, url string, staked *big.Int)
Register is a helper function for creating genesis state.
func (*GovernanceState) ResetDKGFinalizedsCount ¶
func (s *GovernanceState) ResetDKGFinalizedsCount()
func (*GovernanceState) ResetDKGMPKReadysCount ¶
func (s *GovernanceState) ResetDKGMPKReadysCount()
func (*GovernanceState) ResetDKGSuccessesCount ¶
func (s *GovernanceState) ResetDKGSuccessesCount()
func (*GovernanceState) RoundHeight ¶
func (s *GovernanceState) RoundHeight(round *big.Int) *big.Int
uint256[] public roundHeight;
func (*GovernanceState) RoundLength ¶
func (s *GovernanceState) RoundLength() *big.Int
uint256 public roundLength;
func (*GovernanceState) SetBlockGasLimit ¶
func (s *GovernanceState) SetBlockGasLimit(reward *big.Int)
func (*GovernanceState) SetCRS ¶
func (s *GovernanceState) SetCRS(crs common.Hash)
func (*GovernanceState) SetCRSRound ¶
func (s *GovernanceState) SetCRSRound(round *big.Int)
func (*GovernanceState) SetDKGRound ¶
func (s *GovernanceState) SetDKGRound(round *big.Int)
func (*GovernanceState) SetFineRecords ¶
func (s *GovernanceState) SetFineRecords(recordHash Bytes32, status bool)
func (*GovernanceState) SetFineValues ¶
func (s *GovernanceState) SetFineValues(values []*big.Int)
func (*GovernanceState) SetOwner ¶
func (s *GovernanceState) SetOwner(newOwner common.Address)
func (*GovernanceState) TotalStaked ¶
func (s *GovernanceState) TotalStaked() *big.Int
uint256 public totalStaked;
func (*GovernanceState) TotalSupply ¶
func (s *GovernanceState) TotalSupply() *big.Int
uint256 public totalSupply;
func (*GovernanceState) UpdateConfiguration ¶
func (s *GovernanceState) UpdateConfiguration(cfg *params.DexconConfig)
UpdateConfiguration updates system configuration.
func (*GovernanceState) UpdateConfigurationRaw ¶
func (s *GovernanceState) UpdateConfigurationRaw(cfg *rawConfigStruct)
UpdateConfigurationRaw updates system configuration.
func (*GovernanceState) UpdateNode ¶
func (s *GovernanceState) UpdateNode(index *big.Int, n *nodeInfo)
func (*GovernanceState) UpdateNodeInfo ¶
func (s *GovernanceState) UpdateNodeInfo(index *big.Int, n *nodeInfo)
func (*GovernanceState) WhitelistOffsetByAddress ¶
func (s *GovernanceState) WhitelistOffsetByAddress(addr common.Address) *big.Int
mapping(address => int256) whitelistOffsetByAddress
type Interpreter ¶ added in v1.5.6
type Interpreter interface { // 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. Run(contract *Contract, input []byte, static bool) ([]byte, error) // CanRun tells if the contract, passed as an argument, can be // run by the current interpreter. This is meant so that the // caller can do something like: // // “`golang // for _, interpreter := range interpreters { // if interpreter.CanRun(contract.code) { // interpreter.Run(contract.code, input) // } // } // “` CanRun([]byte) bool }
Interpreter is used to run Ethereum based contracts and will utilise the passed environment to query external sources for state information. The Interpreter will run the byte code VM based on the passed configuration.
type JSONLogger ¶ added in v1.8.20
type JSONLogger struct {
// contains filtered or unexported fields
}
func NewJSONLogger ¶ added in v1.8.20
func NewJSONLogger(cfg *LogConfig, writer io.Writer) *JSONLogger
NewJSONLogger creates a new EVM tracer that prints execution steps as JSON objects into the provided stream.
func (*JSONLogger) CaptureEnd ¶ added in v1.8.20
CaptureEnd is triggered at end of execution.
func (*JSONLogger) CaptureFault ¶ added in v1.8.20
func (l *JSONLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error
CaptureFault outputs state information on the logger.
func (*JSONLogger) CaptureStart ¶ added in v1.8.20
type LogConfig ¶ added in v1.4.0
type LogConfig struct { DisableMemory bool // disable memory capture DisableStack bool // disable stack capture DisableStorage bool // disable storage capture Debug bool // print output during capture end 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 OpCode ¶
type OpCode byte
OpCode is an EVM opcode
0x0 range - arithmetic ops.
0x10 range - comparison ops.
const ( ADDRESS OpCode = 0x30 + iota BALANCE ORIGIN CALLER CALLVALUE CALLDATALOAD CALLDATASIZE CALLDATACOPY CODESIZE CODECOPY GASPRICE EXTCODESIZE EXTCODECOPY RETURNDATASIZE RETURNDATACOPY EXTCODEHASH )
0x30 range - closure state.
0x40 range - block operations.
const ( POP OpCode = 0x50 + iota MLOAD MSTORE MSTORE8 SLOAD SSTORE JUMP JUMPI PC MSIZE GAS JUMPDEST )
0x50 range - 'storage' and execution.
const ( 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 )
0x60 range.
const ( CREATE OpCode = 0xf0 + iota CALL CALLCODE RETURN DELEGATECALL CREATE2 STATICCALL = 0xfa REVERT = 0xfd SELFDESTRUCT = 0xff )
0xf0 range - closures.
func StringToOp ¶
StringToOp finds the opcode whose name is stored in `str`.
func (OpCode) IsStaticJump ¶ added in v1.3.1
IsStaticJump specifies if an opcode is JUMP.
type OracleContract ¶
type OracleContract interface {
Run(evm *EVM, input []byte, contract *Contract) (ret []byte, err error)
}
OracleContract represent special system contracts written in Go.
type OracleContractABI ¶
type OracleContractABI struct { ABI abi.ABI Name2Method map[string]abi.Method Sig2Method map[string]abi.Method Events map[string]abi.Event }
OracleContractABI represents ABI information for a given contract.
var GovernanceABI *OracleContractABI
func NewOracleContractABI ¶
func NewOracleContractABI(abiDefinition string) *OracleContractABI
NewOracleContractABI parse the ABI.
type PrecompiledContract ¶ added in v1.5.6
type PrecompiledContract interface { RequiredGas(input []byte) uint64 // RequiredPrice calculates the contract gas use Run(input []byte) ([]byte, error) // Run runs the precompiled contract }
PrecompiledContract 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 RandomContract ¶
type RandomContract struct {
// contains filtered or unexported fields
}
RandomContract provides access to on chain randomness.
type Stack ¶ added in v1.5.0
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 StateAtNumberFunc ¶
StateAtFunc returns the statedb given a root hash.
type StateDB ¶ added in v1.5.5
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(uint64) SubRefund(uint64) GetRefund() uint64 GetCommittedState(common.Address, common.Hash) common.Hash 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) 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"` RefundCounter uint64 `json:"refund"` Err error `json:"-"` }
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) ErrorString ¶ added in v1.8.0
ErrorString formats the log's error as a string.
func (StructLog) MarshalJSON ¶ added in v1.6.6
MarshalJSON marshals as JSON.
func (*StructLog) OpName ¶ added in v1.6.6
OpName formats the operand name in a human-readable format.
func (*StructLog) UnmarshalJSON ¶ added in v1.6.6
UnmarshalJSON unmarshals from JSON.
type StructLogger ¶ added in v1.5.0
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 ¶ added in v1.5.0
func NewStructLogger(cfg *LogConfig) *StructLogger
NewStructLogger returns a new logger
func (*StructLogger) CaptureEnd ¶ added in v1.6.6
CaptureEnd is called after the call finishes to finalize the tracing.
func (*StructLogger) CaptureFault ¶ added in v1.8.0
func (l *StructLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error
CaptureFault implements the Tracer interface to trace an execution fault while running an opcode.
func (*StructLogger) CaptureStart ¶ added in v1.8.0
func (l *StructLogger) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error
CaptureStart implements the Tracer interface to initialize the tracing operation.
func (*StructLogger) CaptureState ¶ added in v1.5.0
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) Error ¶ added in v1.8.0
func (l *StructLogger) Error() error
Error returns the VM error captured by the trace.
func (*StructLogger) Output ¶ added in v1.8.0
func (l *StructLogger) Output() []byte
Output returns the VM return value captured by the trace.
func (*StructLogger) StructLogs ¶ added in v1.5.0
func (l *StructLogger) StructLogs() []StructLog
StructLogs returns the captured log entries.
type Tracer ¶ added in v1.5.0
type Tracer interface { CaptureStart(from common.Address, to common.Address, call bool, input []byte, gas uint64, value *big.Int) error CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error CaptureFault(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, err error) 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
- instructions.go
- int_pool_verifier_empty.go
- interface.go
- interpreter.go
- intpool.go
- jump_table.go
- logger.go
- logger_json.go
- memory.go
- memory_table.go
- opcodes.go
- oracle.go
- oracle_contract_abi.go
- oracle_contracts.go
- stack.go
- stack_table.go
- utils.go