commands

package
v0.0.0-...-140c642 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2021 License: GPL-3.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CALL               = "call"
	CALLCODE           = "callcode"
	DELEGATECALL       = "delegatecall"
	STATICCALL         = "staticcall"
	CREATE             = "create"
	SUICIDE            = "suicide"
	TraceTypeTrace     = "trace"
	TraceTypeStateDiff = "stateDiff"
	TraceTypeVmTrace   = "vmTrace"
)
View Source
const NotAvailableChainData = "the function %s is not available, please use --private.api.addr option instead of --chaindata option"

NotAvailableChainData x

View Source
const NotAvailableDeprecated = "the method has been deprecated: %s"

NotAvailableDeprecated x

View Source
const NotImplemented = "the method is currently not implemented: %s"

NotImplemented is the URI prefix for smartcard wallets.

Variables

This section is empty.

Functions

func APIList

func APIList(db ethdb.Database, eth ethdb.Backend, filters *filters.Filters, cfg cli.Flags, customAPIList []rpc.API) []rpc.API

APIList describes the list of available RPC apis

Types

type APIImpl

type APIImpl struct {
	*BaseAPI

	GasCap uint64
	// contains filtered or unexported fields
}

APIImpl is implementation of the EthAPI interface based on remote Db access

func NewEthAPI

func NewEthAPI(db ethdb.Database, eth ethdb.Backend, gascap uint64, filters *rpcfilters.Filters) *APIImpl

NewEthAPI returns APIImpl instance

func (*APIImpl) Accounts

func (api *APIImpl) Accounts(ctx context.Context) ([]common.Address, error)

Accounts implements eth_accounts. Returns a list of addresses owned by the client. Deprecated: This function will be removed in the future.

func (*APIImpl) BlockByNumber

func (api *APIImpl) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)

BlockByNumber is necessary for gasprice.OracleBackend implementation

func (*APIImpl) BlockNumber

func (api *APIImpl) BlockNumber(_ context.Context) (hexutil.Uint64, error)

BlockNumber implements eth_blockNumber. Returns the block number of most recent block.

func (*APIImpl) Call

func (api *APIImpl) Call(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *map[common.Address]ethapi.Account) (hexutil.Bytes, error)

Call implements eth_call. Executes a new message call immediately without creating a transaction on the block chain.

func (*APIImpl) ChainConfig

func (api *APIImpl) ChainConfig() *params.ChainConfig

ChainConfig is necessary for gasprice.OracleBackend implementation

func (*APIImpl) ChainId

func (api *APIImpl) ChainId(ctx context.Context) (hexutil.Uint64, error)

ChainId implements eth_chainId. Returns the current ethereum chainId.

func (*APIImpl) Coinbase

func (api *APIImpl) Coinbase(_ context.Context) (common.Address, error)

Coinbase implements eth_coinbase. Returns the current client coinbase address.

func (*APIImpl) CompileLLL

func (api *APIImpl) CompileLLL(_ context.Context, _ string) (hexutil.Bytes, error)

CompileLLL implements eth_compileLLL. Returns compiled LLL code. Deprecated: This function will be removed in the future.

func (*APIImpl) CompileSerpent

func (api *APIImpl) CompileSerpent(ctx context.Context, _ string) (hexutil.Bytes, error)

CompileSerpent implements eth_compileSerpent. Returns compiled serpent code. Deprecated: This function will be removed in the future.

func (*APIImpl) CompileSolidity

func (api *APIImpl) CompileSolidity(ctx context.Context, _ string) (hexutil.Bytes, error)

CompileSolidity implements eth_compileSolidity. Returns compiled solidity code. Deprecated: This function will be removed in the future.

func (*APIImpl) EstimateGas

func (api *APIImpl) EstimateGas(ctx context.Context, args ethapi.CallArgs) (hexutil.Uint64, error)

EstimateGas implements eth_estimateGas. Returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain.

func (*APIImpl) GasPrice

func (api *APIImpl) GasPrice(ctx context.Context) (*hexutil.Big, error)

GasPrice implements eth_gasPrice. Returns the current price per gas in wei.

func (*APIImpl) GetBalance

func (api *APIImpl) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

GetBalance implements eth_getBalance. Returns the balance of an account for a given address.

func (*APIImpl) GetBlockByHash

func (api *APIImpl) GetBlockByHash(ctx context.Context, numberOrHash rpc.BlockNumberOrHash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash implements eth_getBlockByHash. Returns information about a block given the block's hash.

func (*APIImpl) GetBlockByNumber

func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber implements eth_getBlockByNumber. Returns information about a block given the block's number.

func (*APIImpl) GetBlockTransactionCountByHash

func (api *APIImpl) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) (*hexutil.Uint, error)

GetBlockTransactionCountByHash implements eth_getBlockTransactionCountByHash. Returns the number of transactions in a block given the block's block hash.

func (*APIImpl) GetBlockTransactionCountByNumber

func (api *APIImpl) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*hexutil.Uint, error)

GetBlockTransactionCountByNumber implements eth_getBlockTransactionCountByNumber. Returns the number of transactions in a block given the block's block number.

func (*APIImpl) GetCode

func (api *APIImpl) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetCode implements eth_getCode. Returns the byte code at a given address (if it's a smart contract).

func (*APIImpl) GetCompilers

func (api *APIImpl) GetCompilers(_ context.Context) ([]string, error)

GetCompilers implements eth_getCompilers. Returns a list of available compilers in the client. Deprecated: This function will be removed in the future.

func (*APIImpl) GetFilterChanges

func (api *APIImpl) GetFilterChanges(_ context.Context, index hexutil.Uint64) ([]interface{}, error)

GetFilterChanges implements eth_getFilterChanges. Polling method for a previously-created filter, which returns an array of logs which occurred since last poll.

func (*APIImpl) GetLogs

func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*types.Log, error)

GetLogs implements eth_getLogs. Returns an array of logs matching a given filter object.

func (*APIImpl) GetProof

func (api *APIImpl) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNr rpc.BlockNumber) (*interface{}, error)

GetProof not implemented

func (*APIImpl) GetStorageAt

func (api *APIImpl) GetStorageAt(ctx context.Context, address common.Address, index string, blockNrOrHash rpc.BlockNumberOrHash) (string, error)

GetStorageAt implements eth_getStorageAt. Returns the value from a storage position at a given address.

func (*APIImpl) GetTransactionByBlockHashAndIndex

func (api *APIImpl) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, txIndex hexutil.Uint64) (*RPCTransaction, error)

GetTransactionByBlockHashAndIndex implements eth_getTransactionByBlockHashAndIndex. Returns information about a transaction given the block's hash and a transaction index.

func (*APIImpl) GetTransactionByBlockNumberAndIndex

func (api *APIImpl) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, txIndex hexutil.Uint) (*RPCTransaction, error)

GetTransactionByBlockNumberAndIndex implements eth_getTransactionByBlockNumberAndIndex. Returns information about a transaction given a block number and transaction index.

func (*APIImpl) GetTransactionByHash

func (api *APIImpl) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error)

GetTransactionByHash implements eth_getTransactionByHash. Returns information about a transaction given the transaction's hash.

func (*APIImpl) GetTransactionCount

func (api *APIImpl) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)

GetTransactionCount implements eth_getTransactionCount. Returns the number of transactions sent from an address (the nonce).

func (*APIImpl) GetTransactionReceipt

func (api *APIImpl) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt implements eth_getTransactionReceipt. Returns the receipt of a transaction given the transaction's hash.

func (*APIImpl) GetUncleByBlockHashAndIndex

func (api *APIImpl) GetUncleByBlockHashAndIndex(ctx context.Context, hash common.Hash, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockHashAndIndex implements eth_getUncleByBlockHashAndIndex. Returns information about an uncle given a block's hash and the index of the uncle.

func (*APIImpl) GetUncleByBlockNumberAndIndex

func (api *APIImpl) GetUncleByBlockNumberAndIndex(ctx context.Context, number rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockNumberAndIndex implements eth_getUncleByBlockNumberAndIndex. Returns information about an uncle given a block's number and the index of the uncle.

func (*APIImpl) GetUncleCountByBlockHash

func (api *APIImpl) GetUncleCountByBlockHash(ctx context.Context, hash common.Hash) (*hexutil.Uint, error)

GetUncleCountByBlockHash implements eth_getUncleCountByBlockHash. Returns the number of uncles in the block, if any.

func (*APIImpl) GetUncleCountByBlockNumber

func (api *APIImpl) GetUncleCountByBlockNumber(ctx context.Context, number rpc.BlockNumber) (*hexutil.Uint, error)

GetUncleCountByBlockNumber implements eth_getUncleCountByBlockNumber. Returns the number of uncles in the block, if any.

func (*APIImpl) GetWork

func (api *APIImpl) GetWork(_ context.Context) ([]interface{}, error)

GetWork implements eth_getWork. Returns the hash of the current block, the seedHash, and the boundary condition to be met ('target').

func (*APIImpl) Hashrate

func (api *APIImpl) Hashrate(_ context.Context) (uint64, error)

Hashrate implements eth_hashrate. Returns the number of hashes per second that the node is mining with.

func (*APIImpl) HeaderByNumber

func (api *APIImpl) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)

HeaderByNumber is necessary for gasprice.OracleBackend implementation

func (*APIImpl) Mining

func (api *APIImpl) Mining(_ context.Context) (bool, error)

Mining implements eth_mining. Returns true if client is actively mining new blocks.

func (*APIImpl) NewBlockFilter

func (api *APIImpl) NewBlockFilter(_ context.Context) (hexutil.Uint64, error)

NewBlockFilter new transaction filter

func (*APIImpl) NewFilter

func (api *APIImpl) NewFilter(_ context.Context, filter interface{}) (hexutil.Uint64, error)

NewFilter implements eth_newFilter. Creates an arbitrary filter object, based on filter options, to notify when the state changes (logs).

func (*APIImpl) NewHeads

func (api *APIImpl) NewHeads(ctx context.Context) (*rpc.Subscription, error)

NewHeads send a notification each time a new (header) block is appended to the chain.

func (*APIImpl) NewPendingTransactionFilter

func (api *APIImpl) NewPendingTransactionFilter(_ context.Context) (hexutil.Uint64, error)

NewPendingTransactionFilter new transaction filter

func (*APIImpl) ProtocolVersion

func (api *APIImpl) ProtocolVersion(_ context.Context) (hexutil.Uint, error)

ProtocolVersion implements eth_protocolVersion. Returns the current ethereum protocol version.

func (*APIImpl) SendRawTransaction

func (api *APIImpl) SendRawTransaction(_ context.Context, encodedTx hexutil.Bytes) (common.Hash, error)

SendRawTransaction implements eth_sendRawTransaction. Creates new message call transaction or a contract creation for previously-signed transactions.

func (*APIImpl) SendTransaction

func (api *APIImpl) SendTransaction(_ context.Context, txObject interface{}) (common.Hash, error)

SendTransaction implements eth_sendTransaction. Creates new message call transaction or a contract creation if the data field contains code.

func (*APIImpl) Sign

func (api *APIImpl) Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error)

Sign implements eth_sign. Calculates an Ethereum specific signature with: sign(keccak256('\\x19Ethereum Signed Message:\\n' + len(message) + message))). Deprecated: This function will be removed in the future.

func (*APIImpl) SignTransaction

func (api *APIImpl) SignTransaction(_ context.Context, txObject interface{}) (common.Hash, error)

SignTransaction deprecated

func (*APIImpl) SubmitHashrate

func (api *APIImpl) SubmitHashrate(_ context.Context, hashRate common.Hash, id string) (bool, error)

SubmitHashrate implements eth_submitHashrate. Submit the mining hashrate to the blockchain.

func (*APIImpl) SubmitWork

func (api *APIImpl) SubmitWork(_ context.Context, nonce rpc.BlockNumber, powHash, digest common.Hash) (bool, error)

SubmitWork implements eth_submitWork. Submits a proof-of-work solution to the blockchain.

func (*APIImpl) Syncing

func (api *APIImpl) Syncing(ctx context.Context) (interface{}, error)

Syncing implements eth_syncing. Returns a data object detaling the status of the sync process or false if not syncing.

func (*APIImpl) UninstallFilter

func (api *APIImpl) UninstallFilter(_ context.Context, index hexutil.Uint64) (bool, error)

UninstallFilter new transaction filter

type AccountResult

type AccountResult struct {
	Balance  hexutil.Big    `json:"balance"`
	Nonce    hexutil.Uint64 `json:"nonce"`
	Code     hexutil.Bytes  `json:"code"`
	CodeHash common.Hash    `json:"codeHash"`
}

type BaseAPI

type BaseAPI struct {
	// contains filtered or unexported fields
}

type CallTraceAction

type CallTraceAction struct {
	From     common.Address `json:"from"`
	To       common.Address `json:"to"`
	CallType string         `json:"callType"`
	Gas      hexutil.Big    `json:"gas"`
	Input    hexutil.Bytes  `json:"input"`
	Value    hexutil.Big    `json:"value"`
}

type CreateTraceAction

type CreateTraceAction struct {
	From  common.Address `json:"from"`
	Gas   hexutil.Big    `json:"gas"`
	Init  hexutil.Bytes  `json:"init"`
	Value hexutil.Big    `json:"value"`
}

type CreateTraceResult

type CreateTraceResult struct {
	// Do not change the ordering of these fields -- allows for easier comparison with other clients
	Address *common.Address `json:"address,omitempty"`
	Code    hexutil.Bytes   `json:"code"`
	GasUsed *hexutil.Big    `json:"gasUsed"`
}

type DBAPI

type DBAPI interface {
	GetString(_ context.Context, _ string, _ string) (string, error)
	PutString(_ context.Context, _ string, _ string, _ string) (bool, error)
	GetHex(_ context.Context, _ string, _ string) (hexutil.Bytes, error)
	PutHex(_ context.Context, _ string, _ string, _ hexutil.Bytes) (bool, error)
}

DBAPI the interface for the db_ RPC commands (deprecated)

type DBAPIImpl

type DBAPIImpl struct {
	// contains filtered or unexported fields
}

DBAPIImpl data structure to store things needed for db_ commands

func NewDBAPIImpl

func NewDBAPIImpl() *DBAPIImpl

NewDBAPIImpl returns NetAPIImplImpl instance

func (*DBAPIImpl) GetHex

func (api *DBAPIImpl) GetHex(_ context.Context, _ string, _ string) (hexutil.Bytes, error)

GetHex implements db_getHex. Returns binary data from the local database. Deprecated: This function will be removed in the future.

func (*DBAPIImpl) GetString

func (api *DBAPIImpl) GetString(_ context.Context, _ string, _ string) (string, error)

GetString implements db_getString. Returns string from the local database. Deprecated: This function will be removed in the future.

func (*DBAPIImpl) PutHex

func (api *DBAPIImpl) PutHex(_ context.Context, _ string, _ string, _ hexutil.Bytes) (bool, error)

PutHex implements db_putHex. Stores binary data in the local database. Deprecated: This function will be removed in the future.

func (*DBAPIImpl) PutString

func (api *DBAPIImpl) PutString(_ context.Context, _ string, _ string, _ string) (bool, error)

PutString implements db_putString. Stores a string in the local database. Deprecated: This function will be removed in the future.

type EthAPI

type EthAPI interface {
	// Block related (proposed file: ./eth_blocks.go)
	GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
	GetBlockByHash(ctx context.Context, hash rpc.BlockNumberOrHash, fullTx bool) (map[string]interface{}, error)
	GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*hexutil.Uint, error)
	GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) (*hexutil.Uint, error)

	// Transaction related (see ./eth_txs.go)
	GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error)
	GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, txIndex hexutil.Uint64) (*RPCTransaction, error)
	GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, txIndex hexutil.Uint) (*RPCTransaction, error)

	// Receipt related (see ./eth_receipts.go)
	GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)
	GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*types.Log, error)

	// Uncle related (see ./eth_uncles.go)
	GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)
	GetUncleByBlockHashAndIndex(ctx context.Context, hash common.Hash, index hexutil.Uint) (map[string]interface{}, error)
	GetUncleCountByBlockNumber(ctx context.Context, number rpc.BlockNumber) (*hexutil.Uint, error)
	GetUncleCountByBlockHash(ctx context.Context, hash common.Hash) (*hexutil.Uint, error)

	// Filter related (see ./eth_filters.go)
	NewPendingTransactionFilter(_ context.Context) (hexutil.Uint64, error)
	NewBlockFilter(_ context.Context) (hexutil.Uint64, error)
	NewFilter(_ context.Context, filter interface{}) (hexutil.Uint64, error)
	UninstallFilter(_ context.Context, index hexutil.Uint64) (bool, error)
	GetFilterChanges(_ context.Context, index hexutil.Uint64) ([]interface{}, error)

	// Account related (see ./eth_accounts.go)
	Accounts(ctx context.Context) ([]common.Address, error)
	GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)
	GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)
	GetStorageAt(ctx context.Context, address common.Address, index string, blockNrOrHash rpc.BlockNumberOrHash) (string, error)
	GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

	// System related (see ./eth_system.go)
	BlockNumber(ctx context.Context) (hexutil.Uint64, error)
	Syncing(ctx context.Context) (interface{}, error)
	ChainId(ctx context.Context) (hexutil.Uint64, error) /* called eth_protocolVersion elsewhere */
	ProtocolVersion(_ context.Context) (hexutil.Uint, error)
	GasPrice(_ context.Context) (*hexutil.Big, error)

	// Sending related (see ./eth_call.go)
	Call(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *map[common.Address]ethapi.Account) (hexutil.Bytes, error)
	EstimateGas(ctx context.Context, args ethapi.CallArgs) (hexutil.Uint64, error)
	SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)
	SendTransaction(_ context.Context, txObject interface{}) (common.Hash, error)
	Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error)
	SignTransaction(_ context.Context, txObject interface{}) (common.Hash, error)
	GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNr rpc.BlockNumber) (*interface{}, error)

	// Mining related (see ./eth_mining.go)
	Coinbase(_ context.Context) (common.Address, error)
	Hashrate(_ context.Context) (uint64, error)
	Mining(_ context.Context) (bool, error)
	GetWork(_ context.Context) ([]interface{}, error)
	SubmitWork(_ context.Context, nonce rpc.BlockNumber, powHash, digest common.Hash) (bool, error)
	SubmitHashrate(_ context.Context, hashRate common.Hash, id string) (bool, error)

	// Deprecated commands in eth_ (proposed file: ./eth_deprecated.go)
	GetCompilers(_ context.Context) ([]string, error)
	CompileLLL(_ context.Context, _ string) (hexutil.Bytes, error)
	CompileSolidity(ctx context.Context, _ string) (hexutil.Bytes, error)
	CompileSerpent(ctx context.Context, _ string) (hexutil.Bytes, error)
}

EthAPI is a collection of functions that are exposed in the

type Forks

type Forks struct {
	GenesisHash common.Hash `json:"genesis"`
	Forks       []uint64    `json:"forks"`
}

Forks is a data type to record a list of forks passed by this node

type GethTrace

type GethTrace struct {
	Type    string     `json:"type"`
	Error   string     `json:"error"`
	From    string     `json:"from"`
	To      string     `json:"to"`
	Value   string     `json:"value"`
	Gas     string     `json:"gas"`
	GasUsed string     `json:"gasUsed"`
	Input   string     `json:"input"`
	Output  string     `json:"output"`
	Time    string     `json:"time"`
	Calls   GethTraces `json:"calls"`
}

GethTrace The trace as received from the existing Geth javascript tracer 'callTracer'

func (GethTrace) String

func (p GethTrace) String() string

Allows for easy printing of a geth trace for debugging

type GethTraces

type GethTraces []*GethTrace

GethTraces an array of GethTraces

type Issuance

type Issuance struct {
	BlockReward string `json:"blockReward,omitempty"`
	UncleReward string `json:"uncleReward,omitempty"`
	Issuance    string `json:"issuance,omitempty"`
}

Issuance structure to return information about issuance

type NetAPI

type NetAPI interface {
	Listening(_ context.Context) (bool, error)
	Version(_ context.Context) (string, error)
	PeerCount(_ context.Context) (hexutil.Uint, error)
}

NetAPI the interface for the net_ RPC commands

type NetAPIImpl

type NetAPIImpl struct {
	// contains filtered or unexported fields
}

NetAPIImpl data structure to store things needed for net_ commands

func NewNetAPIImpl

func NewNetAPIImpl(eth ethdb.Backend) *NetAPIImpl

NewNetAPIImpl returns NetAPIImplImpl instance

func (*NetAPIImpl) Listening

func (api *NetAPIImpl) Listening(_ context.Context) (bool, error)

Listening implements net_listening. Returns true if client is actively listening for network connections. TODO: Remove hard coded value

func (*NetAPIImpl) PeerCount

func (api *NetAPIImpl) PeerCount(_ context.Context) (hexutil.Uint, error)

PeerCount implements net_peerCount. Returns number of peers currently connected to the client. TODO: This routine currently returns a hard coded value of '25'

func (*NetAPIImpl) Version

func (api *NetAPIImpl) Version(_ context.Context) (string, error)

Version implements net_version. Returns the current network id.

type OeTracer

type OeTracer struct {
	// contains filtered or unexported fields
}

OpenEthereum-style tracer

func (*OeTracer) CaptureAccountRead

func (ot *OeTracer) CaptureAccountRead(account common.Address) error

func (*OeTracer) CaptureAccountWrite

func (ot *OeTracer) CaptureAccountWrite(account common.Address) error

func (*OeTracer) CaptureEnd

func (ot *OeTracer) CaptureEnd(depth int, output []byte, gasUsed uint64, t time.Duration, err error) error

func (*OeTracer) CaptureFault

func (ot *OeTracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *stack.Stack, contract *vm.Contract, opDepth int, err error) error

func (*OeTracer) CaptureSelfDestruct

func (ot *OeTracer) CaptureSelfDestruct(from common.Address, to common.Address, value *big.Int)

func (*OeTracer) CaptureStart

func (ot *OeTracer) CaptureStart(depth int, from common.Address, to common.Address, precompile bool, create bool, calltype vm.CallType, input []byte, gas uint64, value *big.Int) error

func (*OeTracer) CaptureState

func (ot *OeTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, st *stack.Stack, rData []byte, contract *vm.Contract, opDepth int, err error) error

type ParityTrace

type ParityTrace struct {
	// Do not change the ordering of these fields -- allows for easier comparison with other clients
	Action              interface{}  `json:"action"` // Can be either CallTraceAction or CreateTraceAction
	BlockHash           *common.Hash `json:"blockHash,omitempty"`
	BlockNumber         *uint64      `json:"blockNumber,omitempty"`
	Error               string       `json:"error,omitempty"`
	Result              interface{}  `json:"result,omitempty"`
	Subtraces           int          `json:"subtraces"`
	TraceAddress        []int        `json:"traceAddress"`
	TransactionHash     *common.Hash `json:"transactionHash,omitempty"`
	TransactionPosition *uint64      `json:"transactionPosition,omitempty"`
	Type                string       `json:"type"`
}

ParityTrace A trace in the desired format (Parity/OpenEtherum) See: https://openethereum.github.io/wiki/JSONRPC-trace-module

func (ParityTrace) String

func (t ParityTrace) String() string

Allows for easy printing of a parity trace for debugging

type ParityTraces

type ParityTraces []ParityTrace

ParityTraces An array of parity traces

type PrivateDebugAPI

type PrivateDebugAPI interface {
	StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex uint64, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error)
	TraceTransaction(ctx context.Context, hash common.Hash, config *tracers.TraceConfig) (interface{}, error)
	AccountRange(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, start []byte, maxResults int, nocode, nostorage, incompletes bool) (state.IteratorDump, error)
	GetModifiedAccountsByNumber(ctx context.Context, startNum rpc.BlockNumber, endNum *rpc.BlockNumber) ([]common.Address, error)
	GetModifiedAccountsByHash(_ context.Context, startHash common.Hash, endHash *common.Hash) ([]common.Address, error)
	TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *tracers.TraceConfig) (interface{}, error)
	AccountAt(ctx context.Context, blockHash common.Hash, txIndex uint64, account common.Address) (*AccountResult, error)
}

PrivateDebugAPI Exposed RPC endpoints for debugging use

type PrivateDebugAPIImpl

type PrivateDebugAPIImpl struct {
	*BaseAPI

	GasCap uint64
	// contains filtered or unexported fields
}

PrivateDebugAPIImpl is implementation of the PrivateDebugAPI interface based on remote Db access

func NewPrivateDebugAPI

func NewPrivateDebugAPI(dbReader ethdb.Database, gascap uint64) *PrivateDebugAPIImpl

NewPrivateDebugAPI returns PrivateDebugAPIImpl instance

func (*PrivateDebugAPIImpl) AccountAt

func (api *PrivateDebugAPIImpl) AccountAt(ctx context.Context, blockHash common.Hash, txIndex uint64, address common.Address) (*AccountResult, error)

func (*PrivateDebugAPIImpl) AccountRange

func (api *PrivateDebugAPIImpl) AccountRange(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, startKey []byte, maxResults int, excludeCode, excludeStorage, excludeMissingPreimages bool) (state.IteratorDump, error)

AccountRange implements debug_accountRange. Returns a range of accounts involved in the given block range

func (*PrivateDebugAPIImpl) GetModifiedAccountsByHash

func (api *PrivateDebugAPIImpl) GetModifiedAccountsByHash(ctx context.Context, startHash common.Hash, endHash *common.Hash) ([]common.Address, error)

GetModifiedAccountsByHash implements debug_getModifiedAccountsByHash. Returns a list of accounts modified in the given block.

func (*PrivateDebugAPIImpl) GetModifiedAccountsByNumber

func (api *PrivateDebugAPIImpl) GetModifiedAccountsByNumber(ctx context.Context, startNumber rpc.BlockNumber, endNumber *rpc.BlockNumber) ([]common.Address, error)

GetModifiedAccountsByNumber implements debug_getModifiedAccountsByNumber. Returns a list of accounts modified in the given block.

func (*PrivateDebugAPIImpl) StorageRangeAt

func (api *PrivateDebugAPIImpl) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex uint64, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error)

StorageRangeAt implements debug_storageRangeAt. Returns information about a range of storage locations (if any) for the given address.

func (*PrivateDebugAPIImpl) TraceCall

func (api *PrivateDebugAPIImpl) TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *tracers.TraceConfig) (interface{}, error)

func (*PrivateDebugAPIImpl) TraceTransaction

func (api *PrivateDebugAPIImpl) TraceTransaction(ctx context.Context, hash common.Hash, config *tracers.TraceConfig) (interface{}, error)

TraceTransaction implements debug_traceTransaction. Returns Geth style transaction traces.

type RPCTransaction

type RPCTransaction struct {
	BlockHash        *common.Hash    `json:"blockHash"`
	BlockNumber      *hexutil.Big    `json:"blockNumber"`
	From             common.Address  `json:"from"`
	Gas              hexutil.Uint64  `json:"gas"`
	GasPrice         *hexutil.Big    `json:"gasPrice"`
	Hash             common.Hash     `json:"hash"`
	Input            hexutil.Bytes   `json:"input"`
	Nonce            hexutil.Uint64  `json:"nonce"`
	R                *hexutil.Big    `json:"r"`
	S                *hexutil.Big    `json:"s"`
	To               *common.Address `json:"to"`
	TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
	V                *hexutil.Big    `json:"v"`
	Value            *hexutil.Big    `json:"value"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

type SHHAPI

type SHHAPI interface {
	Post(_ context.Context, _ SHHPost) (bool, error)
	Version(_ context.Context) (string, error)
	NewIdentity(_ context.Context) (string, error)
	HasIdentity(_ context.Context, _ string) (bool, error)
	NewGroup(_ context.Context) (string, error)
	AddToGroup(_ context.Context, _ string) (bool, error)
	NewFilter(_ context.Context, _ SHHFilter) (hexutil.Uint, error)
	UninstallFilter(_ context.Context, _ hexutil.Uint) (bool, error)
	GetFilterChanges(_ context.Context, _ hexutil.Uint) ([]string, error)
	GetMessages(_ context.Context, _ hexutil.Uint) ([]string, error)
}

SHHAPI the interface for the shh_ RPC commands (deprecated)

type SHHAPIImpl

type SHHAPIImpl struct {
	// contains filtered or unexported fields
}

SHHAPIImpl data structure to store things needed for shh_ commands

func NewSHHAPIImpl

func NewSHHAPIImpl() *SHHAPIImpl

NewSHHAPIImpl returns NetAPIImplImpl instance

func (*SHHAPIImpl) AddToGroup

func (api *SHHAPIImpl) AddToGroup(_ context.Context, _ string) (bool, error)

AddToGroup implements shh_addToGroup. Add to a group. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) GetFilterChanges

func (api *SHHAPIImpl) GetFilterChanges(_ context.Context, _ hexutil.Uint) ([]string, error)

GetFilterChanges implements shh_getFilterChanges. Polling method for whisper filters. Returns new messages since the last call of this method. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) GetMessages

func (api *SHHAPIImpl) GetMessages(_ context.Context, _ hexutil.Uint) ([]string, error)

GetMessages implements shh_getMessages. Get all messages matching a filter. Unlike shh_getFilterChanges this returns all messages. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) HasIdentity

func (api *SHHAPIImpl) HasIdentity(_ context.Context, _ string) (bool, error)

HasIdentity implements shh_hasIdentity. Checks if the client hold the private keys for a given identity. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) NewFilter

func (api *SHHAPIImpl) NewFilter(_ context.Context, _ SHHFilter) (hexutil.Uint, error)

NewFilter implements shh_newFilter. Creates filter to notify, when client receives whisper message matching the filter options. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) NewGroup

func (api *SHHAPIImpl) NewGroup(_ context.Context) (string, error)

NewGroup implements shh_newGroup. Create a new group. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) NewIdentity

func (api *SHHAPIImpl) NewIdentity(_ context.Context) (string, error)

NewIdentity implements shh_newIdentity. Creates new whisper identity in the client. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) Post

func (api *SHHAPIImpl) Post(_ context.Context, _ SHHPost) (bool, error)

Post implements shh_post. Sends a whisper message. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) UninstallFilter

func (api *SHHAPIImpl) UninstallFilter(_ context.Context, _ hexutil.Uint) (bool, error)

UninstallFilter implements shh_uninstallFilter. Uninstalls a filter with given id. Deprecated: This function will be removed in the future.

func (*SHHAPIImpl) Version

func (api *SHHAPIImpl) Version(_ context.Context) (string, error)

Version implements shh_version. Returns the current whisper protocol version. Deprecated: This function will be removed in the future.

type SHHFilter

type SHHFilter struct {
	// contains filtered or unexported fields
}

SHHFilter type for shh_newFilter command

type SHHPost

type SHHPost struct {
	// contains filtered or unexported fields
}

SHHPost type for shh_post command (deprecated)

type StateDiff

type StateDiff struct {
	// contains filtered or unexported fields
}

Implements core/state/StateWriter to provide state diffs

func (*StateDiff) CompareStates

func (sd *StateDiff) CompareStates(initialIbs, ibs *state.IntraBlockState)

CompareStates uses the addresses accumulated in the sdMap and compares balances, nonces, and codes of the accounts, and fills the rest of the sdMap

func (*StateDiff) CreateContract

func (sd *StateDiff) CreateContract(address common.Address) error

func (*StateDiff) DeleteAccount

func (sd *StateDiff) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error

func (*StateDiff) UpdateAccountCode

func (sd *StateDiff) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error

func (*StateDiff) UpdateAccountData

func (sd *StateDiff) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error

func (*StateDiff) WriteAccountStorage

func (sd *StateDiff) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error

type StateDiffAccount

type StateDiffAccount struct {
	Balance interface{}                            `json:"balance"` // Can be either string "=" or mapping "*" => {"from": "hex", "to": "hex"}
	Code    interface{}                            `json:"code"`
	Nonce   interface{}                            `json:"nonce"`
	Storage map[common.Hash]map[string]interface{} `json:"storage"`
}

StateDiffAccount is the part of `trace_call` response that is under "stateDiff" tag

type StateDiffBalance

type StateDiffBalance struct {
	From *hexutil.Big `json:"from"`
	To   *hexutil.Big `json:"to"`
}

type StateDiffCode

type StateDiffCode struct {
	From hexutil.Bytes `json:"from"`
	To   hexutil.Bytes `json:"to"`
}

type StateDiffNonce

type StateDiffNonce struct {
	From hexutil.Uint64 `json:"from"`
	To   hexutil.Uint64 `json:"to"`
}

type StateDiffStorage

type StateDiffStorage struct {
	From common.Hash `json:"from"`
	To   common.Hash `json:"to"`
}

type StorageEntry

type StorageEntry struct {
	Key   *common.Hash `json:"key"`
	Value common.Hash  `json:"value"`
}

StorageEntry an entry in storage of the account

type StorageMap

type StorageMap map[common.Hash]StorageEntry

StorageMap a map from storage locations to StorageEntry items

type StorageRangeResult

type StorageRangeResult struct {
	Storage StorageMap   `json:"storage"`
	NextKey *common.Hash `json:"nextKey"` // nil if Storage includes the last key in the trie.
}

StorageRangeResult is the result of a debug_storageRangeAt API call.

func StorageRangeAt

func StorageRangeAt(stateReader *adapter.StateReader, contractAddress common.Address, start []byte, maxResult int) (StorageRangeResult, error)

type SuicideTraceAction

type SuicideTraceAction struct {
	Address       common.Address `json:"address"`
	RefundAddress common.Address `json:"refundAddress"`
	Balance       hexutil.Big    `json:"balance"`
}

type TgAPI

type TgAPI interface {
	// System related (see ./tg_system.go)
	Forks(ctx context.Context) (Forks, error)

	// Blocks related (see ./tg_blocks.go)
	GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
	GetHeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error)

	// Receipt related (see ./tg_receipts.go)
	GetLogsByHash(ctx context.Context, hash common.Hash) ([][]*types.Log, error)

	// Issuance / reward related (see ./tg_issuance.go)
	// BlockReward(ctx context.Context, blockNr rpc.BlockNumber) (Issuance, error)
	// UncleReward(ctx context.Context, blockNr rpc.BlockNumber) (Issuance, error)
	Issuance(ctx context.Context, blockNr rpc.BlockNumber) (Issuance, error)
}

TgAPI TurboGeth specific routines

type TgImpl

type TgImpl struct {
	*BaseAPI
	// contains filtered or unexported fields
}

TgImpl is implementation of the TgAPI interface

func NewTgAPI

func NewTgAPI(db ethdb.Database) *TgImpl

NewTgAPI returns TgImpl instance

func (*TgImpl) Forks

func (api *TgImpl) Forks(ctx context.Context) (Forks, error)

Forks implements tg_forks. Returns the genesis block hash and a sorted list of all forks block numbers

func (*TgImpl) GetHeaderByHash

func (api *TgImpl) GetHeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

GetHeaderByHash implements tg_getHeaderByHash. Returns a block's header given a block's hash.

func (*TgImpl) GetHeaderByNumber

func (api *TgImpl) GetHeaderByNumber(ctx context.Context, blockNumber rpc.BlockNumber) (*types.Header, error)

GetHeaderByNumber implements tg_getHeaderByNumber. Returns a block's header given a block number ignoring the block's transaction and uncle list (may be faster).

func (*TgImpl) GetLogsByHash

func (api *TgImpl) GetLogsByHash(ctx context.Context, hash common.Hash) ([][]*types.Log, error)

GetLogsByHash implements tg_getLogsByHash. Returns an array of arrays of logs generated by the transactions in the block given by the block's hash.

func (*TgImpl) Issuance

func (api *TgImpl) Issuance(ctx context.Context, blockNr rpc.BlockNumber) (Issuance, error)

Issuance implements tg_issuance. Returns the total issuance (block reward plus uncle reward) for the given block.

type TraceAPI

type TraceAPI interface {
	// Ad-hoc (see ./trace_adhoc.go)
	ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumber, traceTypes []string) ([]interface{}, error)
	ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)
	Call(ctx context.Context, call TraceCallParam, types []string, blockNr *rpc.BlockNumberOrHash) (*TraceCallResult, error)
	CallMany(ctx context.Context, calls json.RawMessage, blockNr *rpc.BlockNumberOrHash) ([]*TraceCallResult, error)
	RawTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)

	// Filtering (see ./trace_filtering.go)
	Transaction(ctx context.Context, txHash common.Hash) (ParityTraces, error)
	Get(ctx context.Context, txHash common.Hash, txIndicies []hexutil.Uint64) (*ParityTrace, error)
	Block(ctx context.Context, blockNr rpc.BlockNumber) (ParityTraces, error)
	Filter(ctx context.Context, req TraceFilterRequest) (ParityTraces, error)
}

TraceAPI RPC interface into tracing API

type TraceAPIImpl

type TraceAPIImpl struct {
	*BaseAPI
	// contains filtered or unexported fields
}

TraceAPIImpl is implementation of the TraceAPI interface based on remote Db access

func NewTraceAPI

func NewTraceAPI(dbReader ethdb.Database, cfg *cli.Flags) *TraceAPIImpl

NewTraceAPI returns NewTraceAPI instance

func (*TraceAPIImpl) Block

func (api *TraceAPIImpl) Block(ctx context.Context, blockNr rpc.BlockNumber) (ParityTraces, error)

Block implements trace_block

func (*TraceAPIImpl) Call

func (api *TraceAPIImpl) Call(ctx context.Context, args TraceCallParam, traceTypes []string, blockNrOrHash *rpc.BlockNumberOrHash) (*TraceCallResult, error)

Call implements trace_call.

func (*TraceAPIImpl) CallMany

func (api *TraceAPIImpl) CallMany(ctx context.Context, calls json.RawMessage, blockNrOrHash *rpc.BlockNumberOrHash) ([]*TraceCallResult, error)

CallMany implements trace_callMany.

func (*TraceAPIImpl) Filter

Filter implements trace_filter TODO(tjayrush): Eventually, we will need to protect ourselves from 'large' queries. Parity crashes when a range query of a very large size is sent. We need to protect ourselves with maxTraces. It may already be done

func (*TraceAPIImpl) Get

func (api *TraceAPIImpl) Get(ctx context.Context, txHash common.Hash, indicies []hexutil.Uint64) (*ParityTrace, error)

Get implements trace_get TODO(tjayrush): This command should take an rpc.BlockNumber .This would allow blockNumbers and 'latest', TODO(tjayrush): 'pending', etc. Parity only accepts block hash. TODO(tjayrush): Also, for some reason, Parity definesthe second parameter as an array of indexes, but TODO(tjayrush): only accepts a single one TODO(tjayrush): I think this should return an interface{}, so we can return both Parity and Geth traces

func (*TraceAPIImpl) RawTransaction

func (api *TraceAPIImpl) RawTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)

RawTransaction implements trace_rawTransaction.

func (*TraceAPIImpl) ReplayBlockTransactions

func (api *TraceAPIImpl) ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumber, traceTypes []string) ([]interface{}, error)

ReplayBlockTransactions implements trace_replayBlockTransactions.

func (*TraceAPIImpl) ReplayTransaction

func (api *TraceAPIImpl) ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)

ReplayTransaction implements trace_replayTransaction.

func (*TraceAPIImpl) Transaction

func (api *TraceAPIImpl) Transaction(ctx context.Context, txHash common.Hash) (ParityTraces, error)

Transaction implements trace_transaction TODO(tjayrush): I think this should return an []interface{}, so we can return both Parity and Geth traces

type TraceAction

type TraceAction struct {
	// Do not change the ordering of these fields -- allows for easier comparison with other clients
	Author         string         `json:"author,omitempty"`
	RewardType     string         `json:"rewardType,omitempty"`
	SelfDestructed string         `json:"address,omitempty"`
	Balance        string         `json:"balance,omitempty"`
	CallType       string         `json:"callType,omitempty"`
	From           common.Address `json:"from"`
	Gas            hexutil.Big    `json:"gas"`
	Init           hexutil.Bytes  `json:"init,omitempty"`
	Input          hexutil.Bytes  `json:"input,omitempty"`
	RefundAddress  string         `json:"refundAddress,omitempty"`
	To             string         `json:"to,omitempty"`
	Value          string         `json:"value,omitempty"`
}

TraceAction A parity formatted trace action

type TraceCallParam

type TraceCallParam struct {
	From     *common.Address `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Value    *hexutil.Big    `json:"value"`
	Data     hexutil.Bytes   `json:"data"`
}

TraceCallParam (see SendTxArgs -- this allows optional prams plus don't use MixedcaseAddress

func (*TraceCallParam) ToMessage

func (args *TraceCallParam) ToMessage(globalGasCap uint64) types.Message

ToMessage converts CallArgs to the Message type used by the core evm

type TraceCallResult

type TraceCallResult struct {
	Output    hexutil.Bytes                        `json:"output"`
	StateDiff map[common.Address]*StateDiffAccount `json:"stateDiff"`
	Trace     []*ParityTrace                       `json:"trace"`
	VmTrace   *TraceCallVmTrace                    `json:"vmTrace"`
}

TraceCallResult is the response to `trace_call` method

type TraceCallVmTrace

type TraceCallVmTrace struct {
}

TraceCallVmTrace is the part of `trace_call` response that is under "vmTrace" tag

type TraceFilterRequest

type TraceFilterRequest struct {
	FromBlock   *hexutil.Uint64   `json:"fromBlock"`
	ToBlock     *hexutil.Uint64   `json:"toBlock"`
	FromAddress []*common.Address `json:"fromAddress"`
	ToAddress   []*common.Address `json:"toAddress"`
	After       *uint64           `json:"after"`
	Count       *uint64           `json:"count"`
}

TraceFilterRequest represents the arguments for trace_filter

type TraceResult

type TraceResult struct {
	// Do not change the ordering of these fields -- allows for easier comparison with other clients
	GasUsed *hexutil.Big  `json:"gasUsed"`
	Output  hexutil.Bytes `json:"output"`
}

TraceResult A parity formatted trace result

type Web3API

type Web3API interface {
	ClientVersion(_ context.Context) (string, error)
	Sha3(_ context.Context, input hexutil.Bytes) hexutil.Bytes
}

Web3API provides interfaces for the web3_ RPC commands

type Web3APIImpl

type Web3APIImpl struct {
	*BaseAPI
}

func NewWeb3APIImpl

func NewWeb3APIImpl() *Web3APIImpl

NewWeb3APIImpl returns Web3APIImpl instance

func (*Web3APIImpl) ClientVersion

func (api *Web3APIImpl) ClientVersion(_ context.Context) (string, error)

ClientVersion implements web3_clientVersion. Returns the current client version.

func (*Web3APIImpl) Sha3

func (api *Web3APIImpl) Sha3(_ context.Context, input hexutil.Bytes) hexutil.Bytes

Sha3 implements web3_sha3. Returns Keccak-256 (not the standardized SHA3-256) of the given data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL