💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### debug\_backtraceAt 设置日志回溯位置。设置回溯位置并在该位置发出日志消息时,执行log语句的goroutine堆栈将被打印到stderr。 该位置指定为`<filename>:<line>`。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.backtraceAt(string)` | | RPC | `{"method": "debug_backtraceAt", "params": [string]}` | 例: ~~~ > debug.backtraceAt("server.go:443") ~~~ ### debug\_blockProfile 在给定的时间段内打开块分析,并将配置文件数据写入磁盘。它使用1的配置文件速率来获取最准确的信息。如果需要不同的速率,请设置速率并使用手动写入配置文件`debug_writeBlockProfile`。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.blockProfile(file, seconds)` | | RPC | `{"method": "debug_blockProfile", "params": [string, number]}` | ### debug\_cpuProfile 在给定的时间间隔内打开CPU性能分析,并将配置文件数据写入磁盘。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.cpuProfile(file, seconds)` | | RPC | `{"method": "debug_cpuProfile", "params": [string, number]}` | ### debug\_dumpBlock 检索与块编号相对应的状态,并返回帐户列表(包括存储和代码)。 | 命令方式 | 调用方法 | | --- | --- | | GO | `debug.DumpBlock(number uint64) (state.World, error)` | | Console | `debug.traceBlockByHash(number, [options])` | | RPC | `{"method": "debug_dumpBlock", "params": [number]}` | #### 例 ~~~ > debug.dumpBlock(10) { fff7ac99c8e4feb60c9750054bdc14ce1857f181: { balance: "49358640978154672", code: "", codeHash: "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", nonce: 2, root: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", storage: {} }, fffbca3a38c3c5fcb3adbb8e63c04c3e629aafce: { balance: "3460945928", code: "", codeHash: "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", nonce: 657, root: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", storage: {} } }, root: "19f4ed94e188dd9c7eb04226bd240fa6b449401a6c656d6d2816a87ccaf206f1" } ~~~ ### debug\_gcStats 返回GC统计信息。 有关返回的对象的字段的信息。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.gcStats()` | | RPC | `{"method": "debug_gcStats", "params": []}` | ### debug\_getBlockRlp 按编号检索并返回RLP编码的块。 | 命令方式 | 调用方法 | | --- | --- | | GO| `debug.GetBlockRlp(number uint64) (string, error)` | | Console | `debug.getBlockRlp(number, [options])` | | RPC | `{"method": "debug_getBlockRlp", "params": [number]}` | ### debug\_goTrace 在给定的持续时间内打开Go运行时跟踪,并将跟踪数据写入磁盘。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.goTrace(file, seconds)` | | RPC | `{"method": "debug_goTrace", "params": [string, number]}` | ### debug\_memStats 返回详细的运行时内存统计信息。 有关返回的对象的字段的信息。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.memStats()` | | RPC | `{"method": "debug_memStats", "params": []}` | ### debug\_seedHash 按编号获取和检索块的种子哈希 | 命令方式 | 调用方法 | | --- | --- | | GO | `debug.SeedHash(number uint64) (string, error)` | | Console | `debug.seedHash(number, [options])` | | RPC | `{"method": "debug_seedHash", "params": [number]}` | ### debug\_setHead 通过块号设置本地链的当前区块头。**请注意**,这是一种破坏性行为,可能会严重损坏您的链。使用时要*格外*小心。 | 命令方式 | 调用方法 | | --- | --- | | GO | `debug.SetHead(number uint64)` | | Console | `debug.setHead(number)` | | RPC | `{"method": "debug_setHead", "params": [number]}` | ### debug\_setBlockProfileRate 设置goroutine块概要文件数据收集的速率(以样本/秒为单位)。非零速率启用块分析,将其设置为零将停止配置文件。收集的配置文件数据可以使用写入`debug_writeBlockProfile`。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.setBlockProfileRate(rate)` | | RPC | `{"method": "debug_setBlockProfileRate", "params": [number]}` | ### debug\_stacks 返回所有goroutine堆栈的打印表示形式。请注意,此方法的web3包装器负责打印,并且不返回字符串。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.stacks()` | | RPC | `{"method": "debug_stacks", "params": []}` | ### debug\_startCPUProfile 无限期打开CPU配置文件,写入文件。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.startCPUProfile(file)` | | RPC | `{"method": "debug_startCPUProfile", "params": [string]}` | ### debug\_startGoTrace 开始将Go运行时跟踪信息写入文件。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.startGoTrace(file)` | | RPC | `{"method": "debug_startGoTrace", "params": [string]}` | ### debug\_stopCPUProfile 停止正在进行的CPU配置文件。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.stopCPUProfile()` | | RPC | `{"method": "debug_stopCPUProfile", "params": []}` | ### debug\_stopGoTrace 停止编写Go运行时跟踪。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.startGoTrace(file)` | | RPC | `{"method": "debug_stopGoTrace", "params": []}` | ### debug\_traceBlock 该`traceBlock`方法将返回此块中包括的所有事务的所有已调用操作码的完整堆栈跟踪。**注意**,此块的父级必须存在,否则将失败。 | 命令方式 | 调用方法 | | --- | --- | | GO | `debug.TraceBlock(blockRlp []byte, config. *vm.Config) BlockTraceResult` | | Console | `debug.traceBlock(tblockRlp, [options])` | | RPC | `{"method": "debug_traceBlock", "params": [blockRlp, {}]}` | #### 例 ~~~ > debug.traceBlock("0xblock_rlp") { gas: 85301, returnValue: "", structLogs: [{ depth: 1, error: "", gas: 162106, gasCost: 3, memory: null, op: "PUSH1", pc: 0, stack: [], storage: {} }, /* snip */ { depth: 1, error: "", gas: 100000, gasCost: 0, memory: ["0000000000000000000000000000000000000000000000000000000000000006", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000060"], op: "STOP", pc: 120, stack: ["00000000000000000000000000000000000000000000000000000000d67cbec9"], storage: { 0000000000000000000000000000000000000000000000000000000000000004: "8241fa522772837f0d05511f20caa6da1d5a3209000000000000000400000001", 0000000000000000000000000000000000000000000000000000000000000006: "0000000000000000000000000000000000000000000000000000000000000001", f652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f: "00000000000000000000000002e816afc1b5c0f39852131959d946eb3b07b5ad" } }] ~~~ ### debug\_traceBlockByNumber 与[debug\_traceBlock]相似,`traceBlockByNumber`接受一个块号并重播数据库中已经存在的块。 | 命令方式 | 调用方法 | | --- | --- | | GO | `debug.TraceBlockByNumber(number uint64, config. *vm.Config) BlockTraceResult` | | Console | `debug.traceBlockByNumber(number, [options])` | | RPC | `{"method": "debug_traceBlockByNumber", "params": [number, {}]}` | ### debug\_traceBlockByHash 与[debug\_traceBlock]相似,`traceBlockByHash`接受块哈希并重播数据库中已经存在的块。 | 命令方式 | 调用方法 | | --- | --- | | GO | `debug.TraceBlockByHash(hash common.Hash, config. *vm.Config) BlockTraceResult` | | Console | `debug.traceBlockByHash(hash, [options])` | | RPC | `{"method": "debug_traceBlockByHash", "params": [hash {}]}` | ### debug\_traceBlockFromFile 与[debug\_traceBlock]相似,`traceBlockFromFile`接受包含该块的RLP的文件。 | 命令方式 | 调用方法 | | --- | --- | | GO | `debug.TraceBlockFromFile(fileName string, config. *vm.Config) BlockTraceResult` | | Console | `debug.traceBlockFromFile(fileName, [options])` | | RPC | `{"method": "debug_traceBlockFromFile", "params": [fileName, {}]}` | ### debug\_standardTraceBlockToFile 首次实现基于JS的跟踪(见下文)时,预期的用例是启用长时间运行的跟踪器,这些跟踪器可以通过订阅通道将结果流回。此方法的工作方式略有不同。 * 它在执行期间将输出流传输到磁盘,以免消耗节点上的内存使用量 * 它`jsonl`用作输出格式(允许流式传输) * 使用跨客户端标准化输出,即所谓的“标准json” * 用途`op`为操作码的字符串表示,而不是`op`/`opName`对数字/串,和其他小simlar差异。 * 有`refund` * 将内存表示为连续的数据块,而不是`32`像-byte段这样的列表`debug_traceTransaction` 这意味着该方法仅对控制该节点的调用者“有用”,至少可以在事发后从文件系统中读取伪像。 该方法可用于将特定事务转出给定块: ~~~ > debug.standardTraceBlockToFile("0x0bbe9f1484668a2bf159c63f0cf556ed8c8282f99e3ffdb03ad2175a863bca63", {txHash:"0x4049f61ffbb0747bb88dc1c85dd6686ebf225a3c10c282c45a8e0c644739f7e9", disableMemory:true}) ["/tmp/block_0x0bbe9f14-14-0x4049f61f-099048234"] ~~~ 或某个区块中的所有TX: ~~~ > debug.standardTraceBlockToFile("0x0bbe9f1484668a2bf159c63f0cf556ed8c8282f99e3ffdb03ad2175a863bca63", {disableMemory:true}) ["/tmp/block_0x0bbe9f14-0-0xb4502ea7-409046657", "/tmp/block_0x0bbe9f14-1-0xe839be8f-954614764", "/tmp/block_0x0bbe9f14-2-0xc6e2052f-542255195", "/tmp/block_0x0bbe9f14-3-0x01b7f3fe-209673214", "/tmp/block_0x0bbe9f14-4-0x0f290422-320999749", "/tmp/block_0x0bbe9f14-5-0x2dc0fb80-844117472", "/tmp/block_0x0bbe9f14-6-0x35542da1-256306111", "/tmp/block_0x0bbe9f14-7-0x3e199a08-086370834", "/tmp/block_0x0bbe9f14-8-0x87778b88-194603593", "/tmp/block_0x0bbe9f14-9-0xbcb081ba-629580052", "/tmp/block_0x0bbe9f14-10-0xc254381a-578605923", "/tmp/block_0x0bbe9f14-11-0xcc434d58-405931366", "/tmp/block_0x0bbe9f14-12-0xce61967d-874423181", "/tmp/block_0x0bbe9f14-13-0x05a20b35-267153288", "/tmp/block_0x0bbe9f14-14-0x4049f61f-606653767", "/tmp/block_0x0bbe9f14-15-0x46d473d2-614457338", "/tmp/block_0x0bbe9f14-16-0x35cf5500-411906321", "/tmp/block_0x0bbe9f14-17-0x79222961-278569788", "/tmp/block_0x0bbe9f14-18-0xad84e7b1-095032683", "/tmp/block_0x0bbe9f14-19-0x4bd48260-019097038", "/tmp/block_0x0bbe9f14-20-0x1517411d-292624085", "/tmp/block_0x0bbe9f14-21-0x6857e350-971385904", "/tmp/block_0x0bbe9f14-22-0xbe3ae2ca-236639695"] ~~~ 使用命名标准在临时位置创建文件`block_<blockhash:4>-<txindex>-<txhash:4>-<random suffix>`。每个操作码都会立即流到文件,除了os正常进行的缓冲外,没有缓冲缓冲。 在服务器端,当重新生成历史状态时,它还会添加一些更多信息,即`required historical state is not avaiable`遇到reexec-number时,以便用户可以尝试增加该设置。它还打印出剩余的块,直到到达目标: ~~~ INFO [10-15|13:48:25.263] Regenerating historical state block=2385959 target=2386012 remaining=53 elapsed=3m30.990537767s INFO [10-15|13:48:33.342] Regenerating historical state block=2386012 target=2386012 remaining=0 elapsed=3m39.070073163s INFO [10-15|13:48:33.343] Historical state regenerated block=2386012 elapsed=3m39.070454362s nodes=10.03mB preimages=652.08kB INFO [10-15|13:48:33.352] Wrote trace file=/tmp/block_0x14490c57-0-0xfbbd6d91-715824834 INFO [10-15|13:48:33.352] Wrote trace file=/tmp/block_0x14490c57-1-0x71076194-187462969 INFO [10-15|13:48:34.421] Wrote trace file=/tmp/block_0x14490c57-2-0x3f4263fe-056924484 ~~~ 该`options`如下: ~~~ type StdTraceConfig struct { *vm.LogConfig Reexec *uint64 TxHash *common.Hash } ~~~ ### debug\_standardTraceBadBlockToFile 此方法与相似`debug_standardTraceBlockToFile`,但可用于获取有关已被*拒绝*为无效(由于某种原因)的块的信息。 ### debug\_traceTransaction **OBS**在大多数情况下,`debug.standardTraceBlockToFile`更适合于跟踪! 的`traceTransaction`调试方法将尝试,因为它是在网络上执行以完全相同的方式来运行事务。在最终尝试执行与给定哈希对应的事务之前,它将重放在此之前可能已执行的任何事务。 除了事务的哈希值,您还可以给它一个辅助的*可选*参数,它指定此特定调用的选项。可能的选项是: * `disableStorage`:`BOOL`。将此设置为true将禁用存储捕获(默认= false)。 * `disableMemory`:`BOOL`。将此设置为true将禁用内存捕获(默认= false)。 * `disableStack`:`BOOL`。将此设置为true将禁用堆栈捕获(默认= false)。 * `tracer`:`STRING`。设置此选项将启用基于JavaScript的事务跟踪,如下所述。如果设置,则前四个参数将被忽略。 * `timeout`:`STRING`。覆盖基于JavaScript的跟踪调用的默认超时5秒。有效值描述。 | 客户 | 方法调用 | | --- | --- | | GO | `debug.TraceTransaction(txHash common.Hash, logger *vm.LogConfig) (*ExecutionResurt, error)` | | Console | `debug.traceTransaction(txHash, [options])` | | RPC | `{"method": "debug_traceTransaction", "params": [txHash, {}]}` | #### 例 ~~~ > debug.traceTransaction("0x2059dd53ecac9827faad14d364f9e04b1d5fe5b506e3acc886eff7a6f88a696a") { gas: 85301, returnValue: "", structLogs: [{ depth: 1, error: "", gas: 162106, gasCost: 3, memory: null, op: "PUSH1", pc: 0, stack: [], storage: {} }, /* snip */ { depth: 1, error: "", gas: 100000, gasCost: 0, memory: ["0000000000000000000000000000000000000000000000000000000000000006", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000060"], op: "STOP", pc: 120, stack: ["00000000000000000000000000000000000000000000000000000000d67cbec9"], storage: { 0000000000000000000000000000000000000000000000000000000000000004: "8241fa522772837f0d05511f20caa6da1d5a3209000000000000000400000001", 0000000000000000000000000000000000000000000000000000000000000006: "0000000000000000000000000000000000000000000000000000000000000001", f652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f: "00000000000000000000000002e816afc1b5c0f39852131959d946eb3b07b5ad" } }] ~~~ #### 基于JavaScript的跟踪 `tracer`在第二个参数中指定选项将启用基于JavaScript的跟踪。在此模式下,`tracer`被解释为一个JavaScript表达式,该表达式应使用(至少)两个方法(名为`step`和)对一个对象求值`result`。 `step`是一个带有两个参数log和db的函数,该函数针对EVM的每个步骤或在跟踪指定事务时发生错误时被调用。 `log`具有以下字段: * `pc`:编号,当前程序计数器 * `op`:对象,代表当前操作码的OpCode对象 * `gas`:数量,剩余gas量 * `gasPrice`:数量,每单位GAS的单位为单位的成本 * `memory`:对象,表示合同的内存空间的结构 * `stack`:array \[big.Int\],EVM执行堆栈 * `depth`:执行深度 * `account`:执行当前操作的帐户的地址 * `err`:如果发生错误,则有关该错误的信息 如果`err`为非null,则应忽略所有其他字段。 为了提高效率,同一`log`对象在每个执行步骤中都被重用,并用当前值进行更新;确保将要保留的值复制到当前调用之外。例如,此步骤功能将不起作用: ~~~ function(log) { this.logs.append(log); } ~~~ 但是此步骤功能将: ~~~ function(log) { this.logs.append({gas: log.gas, pc: log.pc, ...}); } ~~~ `log.op`具有以下方法: * `isPush()`\-如果操作码为PUSHn,则返回true * `toString()`\-返回操作码的字符串表示形式 * `toNumber()`\-返回操作码的编号 `log.memory`具有以下方法: * `slice(start, stop)`\-将指定的内存段作为字节片返回 * `length()`\-返回内存的长度 `log.stack`具有以下方法: * `peek(idx)`\-从堆栈的顶部返回第idx个元素(0是最顶部的元素)为big.Int * `length()`\-返回堆栈中的元素数 `db`具有以下方法: * `getBalance(address)`\-返回`big.Int`具有指定帐户余额的 * `getNonce(address)`\-返回带有指定帐户随机数的数字 * `getCode(address)`\-返回带有指定帐户代码的字节片 * `getState(address, hash)`\-返回指定帐户和指定哈希的状态值 * `exists(address)`\-如果指定的地址存在,则返回true 第二个函数'result'不带任何参数,并且期望返回一个JSON可序列化的值以返回给RPC调用者。 如果step函数在任何时候引发异常或执行非法操作,则将不会在任何其他VM步骤上调用它,并且该错误将返回给调用方。 请注意,有几个值是Golang big.Int对象,而不是JavaScript数字或JS bigints。因此,它们具有与godocs中所述相同的界面。它们默认的序列化为JSON是一个Javascript数字。要序列化大量数字,请准确调用`.String()`它们。为方便起见,`big.NewInt(x)`提供了,并将uint转换为Go BigInt。 用法示例,仅在每个CALL操作码处返回堆栈的顶部元素: ~~~ debug.traceTransaction(txhash, {tracer: '{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == "CALL") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}'}); ~~~ ### debug\_verbosity 设置日志记录的详细信息上限。将打印级别达到并包括给定级别的日志消息。 可以使用来提高单个软件包和源文件的详细程度`debug_vmodule`。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.verbosity(level)` | | RPC | `{"method": "debug_vmodule", "params": [number]}` | ### debug\_vmodule 设置日志记录的详细模式。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.vmodule(string)` | | RPC | `{"method": "debug_vmodule", "params": [string]}` | #### 例子 如果要查看来自特定Go包(目录)和所有子目录的消息,请使用: ~~~ > debug.vmodule("wsc/*=6") ~~~ 如果要将消息限制为特定的程序包(例如p2p),但排除子目录,请使用: ~~~ > debug.vmodule("p2p=6") ~~~ 如果要查看来自特定源文件的日志消息,请使用 ~~~ > debug.vmodule("server.go=6") ~~~ 您可以组成这些基本模式。如果要在wsc(wsc / peer.go,wsc / downloader / peer.go)之下的包中查看peer.go的所有输出,以及级别<= 5的p2p包的输出,请使用: ~~~ debug.vmodule("wsc/*/peer.go=6,p2p=5") ~~~ ### debug\_writeBlockProfile 将goroutine阻止配置文件写入文件。 | 命令方式 | 调用方法 | | --- | --- | | Console | `debug.writeBlockProfile(file)` | | RPC | `{"method": "debug_writeBlockProfile", "params": [string]}` | ### debug\_writeMemProfile 将分配配置文件写入给定文件。请注意,无法通过API来设置分析速率,必须在命令行中使用`--memprofilerate`标志来设置分析速率。 | 命令方式 | 调用方法 | | --- | --- | |Console | `debug.writeMemProfile(file string)` | | RPC | `{"method": "debug_writeBlockProfile", "params": [string]}` |