debug
The debug
API gives you access to several non-standard RPC methods, which will allow you to inspect, debug and set certain debugging flags during runtime.
debug_accountRange
Enumerates all accounts at a given block with paging capability. maxResults
are returned in the page and the items have keys that come after the start
key (hashed address).
If incompletes
is false, then accounts for which the key preimage (i.e: the address
) doesn't exist in db are skipped. NB: etn-sc by default does not store preimages.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.accountRange(blockNrOrHash, start, maxResults, nocode, nostorage, incompletes) |
RPC | {"method": "debug_accountRange", "params": [blockNrOrHash, start, maxResults, nocode, nostorage, incompletes]} |
debug_backtraceAt
Sets the logging backtrace location. When a backtrace location is set and a log message is emitted at that location, the stack of the goroutine executing the log statement will be printed to stderr.
The location is specified as <filename>:<line>
.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.backtraceAt(string) |
RPC | {"method": "debug_backtraceAt", "params": [string]} |
Example:
debug_blockProfile
Turns on block profiling for the given duration and writes profile data to disk. It uses a profile rate of 1 for most accurate information. If a different rate is desired, set the rate and write the profile manually using debug_writeBlockProfile
.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.blockProfile(file, seconds) |
RPC | {"method": "debug_blockProfile", "params": [string, number]} |
debug_chaindbCompact
Flattens the entire key-value database into a single level, removing all unused slots and merging all keys.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.chaindbCompact() |
RPC | {"method": "debug_chaindbCompact", "params": []} |
debug_chaindbProperty
Returns leveldb properties of the key-value database.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.chaindbProperty(property string) |
RPC | {"method": "debug_chaindbProperty", "params": [property]} |
debug_cpuProfile
Turns on CPU profiling for the given duration and writes profile data to disk.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.cpuProfile(file, seconds) |
RPC | {"method": "debug_cpuProfile", "params": [string, number]} |
debug_dbAncient
Retrieves an ancient binary blob from the freezer. The freezer is a collection of append-only immutable files. The first argument kind specifies which table to look up data from. The list of all table kinds are as follows:
headers
: block headershashes
: canonical hash table (block number -> block hash)bodies
: block bodiesreceipts
: block receiptsdiffs
: total difficulty table (block number -> td)
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.dbAncient(kind string, number uint64) |
RPC | {"method": "debug_dbAncient", "params": [string, number]} |
debug_dbAncients
Returns the number of ancient items in the ancient store.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.dbAncients() |
RPC | {"method": "debug_dbAncients"} |
debug_dbGet
Returns the raw value of a key stored in the database.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.dbGet(key string) |
RPC | {"method": "debug_dbGet", "params": [key]} |
debug_dumpBlock
Retrieves the state that corresponds to the block number and returns a list of accounts (including storage and code).
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.DumpBlock(number uint64) (state.World, error) |
Console | debug.traceBlockByHash(number, [options]) |
RPC | {"method": "debug_dumpBlock", "params": [number]} |
Example
debug_freeOSMemory
Forces garbage collection
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.FreeOSMemory() |
Console | debug.freeOSMemory() |
RPC | {"method": "debug_freeOSMemory", "params": []} |
debug_freezeClient
Forces a temporary client freeze, normally when the server is overloaded. Available as part of LES light server.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.freezeClient(node string) |
RPC | {"method": "debug_freezeClient", "params": [node]} |
debug_gcStats
Returns garbage collection statistics.
See https://golang.org/pkg/runtime/debug/#GCStats for information about the fields of the returned object.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.gcStats() |
RPC | {"method": "debug_gcStats", "params": []} |
debug_getAccessibleState
Returns the first number where the node has accessible state on disk. This is the post-state of that block and the pre-state of the next block. The (from, to) parameters are the sequence of blocks to search, which can go either forwards or backwards.
Note: to get the last state pass in the range of blocks in reverse, i.e. (last, first).
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.getAccessibleState(from, to rpc.BlockNumber) |
RPC | {"method": "debug_getAccessibleState", "params": [from, to]} |
debug_getBadBlocks
Returns a list of the last 'bad blocks' that the client has seen on the network and returns them as a JSON list of block-hashes.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.getBadBlocks() |
RPC | {"method": "debug_getBadBlocks", "params": []} |
debug_getRawBlock
Retrieves and returns the RLP encoded block by number.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.getRawBlock(blockNrOrHash) (string, error) |
Console | debug.getBlockRlp(blockNrOrHash) |
RPC | {"method": "debug_getRawBlock", "params": [blockNrOrHash]} |
References: RLP
debug_getRawHeader
Returns an RLP-encoded header.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.getRawHeader(blockNrOrHash) |
RPC | {"method": "debug_getRawHeader", "params": [blockNrOrHash]} |
debug_getRawTransaction
Returns the bytes of the transaction.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.getRawTransaction(blockNrOrHash) |
RPC | {"method": "debug_getRawTransaction", "params": [transactionHash]} |
debug_getModifiedAccountsByHash
Returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash. With one parameter, returns the list of accounts modified in the specified block.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.getModifiedAccountsByHash(startHash, endHash) |
RPC | {"method": "debug_getModifiedAccountsByHash", "params": [startHash, endHash]} |
debug_getModifiedAccountsByNumber
Returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash or storage hash.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.getModifiedAccountsByNumber(startNum uint64, endNum uint64) |
RPC | {"method": "debug_getModifiedAccountsByNumber", "params": [startNum, endNum]} |
Etn-sc only keeps recent trie nodes and preimages of keys in memory - for older blocks this information is deleted by Etn-sc's garbage collection. This means that calls to debug_GetModifiedAccountsByNumber
on blocks that are old enough to be eligible for garbage collection will return an error due to the trie nodes and preimages being unavailable. To fix this, run Etn-sc with --cache.preimages=true
to prevent the relevant data being lost to the garbage collector
debug_getRawReceipts
Returns the consensus-encoding of all receipts in a single block.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.getRawReceipts(blockNrOrHash) |
RPC | {"method": "debug_getRawReceipts", "params": [blockNrOrHash]} |
debug_goTrace
Turns on Go runtime tracing for the given duration and writes trace data to disk.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.goTrace(file, seconds) |
RPC | {"method": "debug_goTrace", "params": [string, number]} |
debug_intermediateRoots
Executes a block (bad- or canon- or side-), and returns a list of intermediate roots: the stateroot after each transaction.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.intermediateRoots(blockHash, [options]) |
RPC | {"method": "debug_intermediateRoots", "params": [blockHash, {}]} |
debug_memStats
Returns detailed runtime memory statistics.
See https://golang.org/pkg/runtime/#MemStats for information about the fields of the returned object.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.memStats() |
RPC | {"method": "debug_memStats", "params": []} |
debug_mutexProfile
Turns on mutex profiling for nsec seconds and writes profile data to file. It uses a profile rate of 1 for most accurate information. If a different rate is desired, set the rate and write the profile manually.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.mutexProfile(file, nsec) |
RPC | {"method": "debug_mutexProfile", "params": [file, nsec]} |
debug_preimage
Returns the preimage for a sha3 hash, if known.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.preimage(hash) |
RPC | {"method": "debug_preimage", "params": [hash]} |
debug_printBlock
Retrieves a block and returns its pretty printed form.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.printBlock(number uint64) |
RPC | {"method": "debug_printBlock", "params": [number]} |
debug_seedHash
Fetches and retrieves the seed hash of the block by number
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.SeedHash(number uint64) (string, error) |
Console | debug.seedHash(number, [options]) |
RPC | {"method": "debug_seedHash", "params": [number]} |
debug_setBlockProfileRate
Sets the rate (in samples/sec) of goroutine block profile data collection. A non-zero rate enables block profiling, setting it to zero stops the profile. Collected profile data can be written using debug_writeBlockProfile.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.setBlockProfileRate(rate) |
RPC | {"method": "debug_setBlockProfileRate", "params": [number]} |
debug_setGCPercent
Sets the garbage collection target percentage. A negative value disables garbage collection.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.SetGCPercent(v int) |
Console | debug.setGCPercent(v) |
RPC | {"method": "debug_setGCPercent", "params": [v]} |
debug_setHead
Sets the current head of the local chain by block number. Note, this is a destructive action and may severely damage your chain. Use with extreme caution.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.SetHead(number uint64) |
Console | debug.setHead(number) |
RPC | {"method": "debug_setHead", "params": [number]} |
debug_setMutexProfileFraction
Sets the rate of mutex profiling.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.setMutexProfileFraction(rate int) |
RPC | {"method": "debug_setMutexProfileFraction", "params": [rate]} |
debug_setTrieFlushInterval
Configures how often in-memory state tries are persisted to disk. The interval needs to be in a format parsable by a time.Duration. Note that the interval is not wall-clock time. Rather it is accumulated block processing time after which the state should be flushed. For example the value 0s will essentially turn on archive mode. If set to 1h, it means that after one hour of effective block processing time, the trie would be flushed. If one block takes 200ms, a flush would occur every 5*3600=18000 blocks. The default interval for mainnet is 1h.
This configuration will not be presisted through restarts.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.setTrieFlushInterval(interval string) |
RPC | {"method": "debug_setTrieFlushInterval", "params": [interval]} |
debug_stacks
Returns a printed representation of the stacks of all goroutines. Note that the web3 wrapper for this method takes care of the printing and does not return the string.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.stacks() |
RPC | {"method": "debug_stacks", "params": []} |
debug_standardTraceBlockToFile
When JS-based tracing (see below) was first implemented, the intended usecase was to enable long-running tracers that could stream results back via a subscription channel. This method works a bit differently. (For full details, see PR)
It streams output to disk during the execution, to not blow up the memory usage on the node
It uses jsonl as output format (to allow streaming)
Uses a cross-client standardized output, so called 'standard json'
Uses op for string-representation of opcode, instead of op/opName for numeric/string, and other simlar small differences.
has refund
Represents memory as a contiguous chunk of data, as opposed to a list of 32-byte segments like debug_traceTransaction
This means that this method is only 'useful' for callers who control the node -- at least sufficiently to be able to read the artefacts from the filesystem after the fact.
The method can be used to dump a certain transaction out of a given block:
Or all txs from a block:
Files are created in a temp-location, with the naming standard block_<blockhash:4>-<txindex>-<txhash:4>-<random suffix>
. Each opcode immediately streams to file, with no in-etn-sc buffering aside from whatever buffering the os normally does.
On the server side, it also adds some more info when regenerating historical state, namely, the reexec-number if required historical state is not avaiable is encountered, so a user can experiment with increasing that setting. It also prints out the remaining block until it reaches target:
The options is as follows:
debug_standardTraceBadBlockToFile
This method is similar to debug_standardTraceBlockToFile
, but can be used to obtain info about a block which has been rejected as invalid (for some reason).
debug_startCPUProfile
Turns on CPU profiling indefinitely, writing to the given file.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.startCPUProfile(file) |
RPC | {"method": "debug_startCPUProfile", "params": [string]} |
debug_startGoTrace
Starts writing a Go runtime trace to the given file.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.startGoTrace(file) |
RPC | {"method": "debug_startGoTrace", "params": [string]} |
debug_stopCPUProfile
Stops an ongoing CPU profile.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.stopCPUProfile() |
RPC | {"method": "debug_stopCPUProfile", "params": []} |
debug_stopGoTrace
Stops writing the Go runtime trace.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.startGoTrace(file) |
RPC | {"method": "debug_stopGoTrace", "params": []} |
debug_storageRangeAt
Returns the storage at the given block height and transaction index. The result can be paged by providing a maxResult to cap the number of storage slots returned as well as specifying the offset via keyStart (hash of storage key).
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.storageRangeAt(blockHash, txIdx, contractAddress, keyStart, maxResult) |
RPC | {"method": "debug_storageRangeAt", "params": [blockHash, txIdx, contractAddress, keyStart, maxResult]} |
debug_traceBadBlock
Returns the structured logs created during the execution of EVM against a block pulled from the pool of bad ones and returns them as a JSON object. For the second parameter see TraceConfig reference.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.traceBadBlock(blockHash, [options]) |
RPC | {"method": "debug_traceBadBlock", "params": [blockHash, {}]} |
debug_traceBlock
The traceBlock method will return a full stack trace of all invoked opcodes of all transaction that were included in this block. Note, the parent of this block must be present or it will fail. For the second parameter see TraceConfig reference.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.TraceBlock(blockRlp []byte, config *TraceConfig) BlockTraceResult |
Console | debug.traceBlock(tblockRlp, [options]) |
RPC | {"method": "debug_traceBlock", "params": [blockRlp, {}]} |
References: RLP
Example
debug_traceBlockByNumber
Similar to debug_traceBlock, traceBlockByNumber accepts a block number and will replay the block that is already present in the database. For the second parameter see TraceConfig reference.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.TraceBlockByNumber(number uint64, config *TraceConfig) BlockTraceResult |
Console | debug.traceBlockByNumber(number, [options]) |
RPC | {"method": "debug_traceBlockByNumber", "params": [number, {}]} |
References: RLP
debug_traceBlockByHash
Similar to debug_traceBlock, traceBlockByHash accepts a block hash and will replay the block that is already present in the database. For the second parameter see TraceConfig reference.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.TraceBlockByHash(hash common.Hash, config *TraceConfig) BlockTraceResult |
Console | debug.traceBlockByHash(hash, [options]) |
RPC | {"method": "debug_traceBlockByHash", "params": [hash {}]} |
References: RLP
debug_traceBlockFromFile
Similar to debug_traceBlock, traceBlockFromFile accepts a file containing the RLP of the block. For the second parameter see TraceConfig reference.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.TraceBlockFromFile(fileName string, config *TraceConfig) BlockTraceResult |
Console | debug.traceBlockFromFile(fileName, [options]) |
RPC | {"method": "debug_traceBlockFromFile", "params": [fileName, {}]} |
References: RLP
debug_traceCall
The debug_traceCall method lets you run an eth_call within the context of the given block execution using the final state of parent block as the base. The first argument (just as in eth_call) is a transaction object. The block can be specified either by hash or by number as the second argument. The trace can be configured similar to debug_traceTransaction, see TraceConfig. The method returns the same output as debug_traceTransaction.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.TraceCall(args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceConfig) (*ExecutionResult, error) |
Console | debug.traceCall(object, blockNrOrHash, [options]) |
RPC | {"method": "debug_traceCall", "params": [object, blockNrOrHash, {}]} |
Example
No specific call options:
Tracing a call with a destination and specific sender, disabling the storage and memory output (less data returned over RPC)
It is possible to supply 'overrides' for both state-data (accounts/storage) and block data (number, timestamp etc). In the example below, a call which executes NUMBER is performed, and the overridden number is placed on the stack:
Curl example:
debug_traceChain
Returns the structured logs created during the execution of EVM between two blocks (excluding start) as a JSON object. This endpoint must be invoked via debug_subscribe as follows:
please refer to the subscription page for more details.
debug_traceTransaction
OBS In most scenarios, debug.standardTraceBlockToFile is better suited for tracing!
The traceTransaction debugging method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.
CLIENT | METHOD INVOCATION |
---|---|
Go | debug.TraceTransaction(txHash common.Hash, config *TraceConfig) (*ExecutionResult, error) |
Console | debug.traceTransaction(txHash, [options]) |
RPC | {"method": "debug_traceTransaction", "params": [txHash, {}]} |
TraceConfig
In addition to the hash of the transaction you may give it a secondary optional argument, which specifies the options for this specific call. The possible options are:
disableStorage: BOOL. Setting this to true will disable storage capture (default = false).
disableStack: BOOL. Setting this to true will disable stack capture (default = false).
enableMemory: BOOL. Setting this to true will enable memory capture (default = false).
enableReturnData: BOOL. Setting this to true will enable return data capture (default = false).
tracer: STRING. Name for built-in tracer or Javascript expression. See below for more details.
If set, the previous four arguments will be ignored.
timeout: STRING. Overrides the default timeout of 5 seconds for JavaScript-based tracing calls. Valid values are described here.
tracerConfig: Config for the specified tracer. For example see callTracer's config.
Etn-sc comes with a bundle of built-in tracers, each providing various data about a transaction. This method defaults to the struct logger. The tracer field of the second parameter can be set to use any of the other tracers. Alternatively a custom tracer can be implemented in either Go or Javascript.
Example
debug_verbosity
Sets the logging verbosity ceiling. Log messages with level up to and including the given level will be printed.
The verbosity of individual packages and source files can be raised using debug_vmodule.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.verbosity(level) |
RPC | {"method": "debug_vmodule", "params": [number]} |
debug_vmodule
Sets the logging verbosity pattern.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.vmodule(string) |
RPC | {"method": "debug_vmodule", "params": [string]} |
Examples
If you want to see messages from a particular Go package (directory) and all subdirectories, use:
If you want to restrict messages to a particular package (e.g. p2p) but exclude subdirectories, use:
If you want to see log messages from a particular source file, use
You can compose these basic patterns. If you want to see all output from peer.go in a package below eth (eth/peer.go, eth/downloader/peer.go) as well as output from package p2p at level <= 5, use:
debug_writeBlockProfile
Writes a goroutine blocking profile to the given file.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.writeBlockProfile(file) |
RPC | {"method": "debug_writeBlockProfile", "params": [string]} |
debug_writeMemProfile
Writes an allocation profile to the given file. Note that the profiling rate cannot be set through the API, it must be set on the command line using the --pprof.memprofilerate flag.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.writeMemProfile(file string) |
RPC | {"method": "debug_writeBlockProfile", "params": [string]} |
debug_writeMutexProfile
Writes a goroutine blocking profile to the given file.
CLIENT | METHOD INVOCATION |
---|---|
Console | debug.writeMutexProfile(file) |
RPC | {"method": "debug_writeMutexProfile", "params": [file]} |
Last updated