5

How to check the VM trace using Geth?

I've ran geth with --verbosity 6, and stuff like this gets logged:

I0525 01:26:12.418607 core/vm/vm.go:157] running byte VM b82addc7
I0525 01:26:12.419818 core/vm/vm.go:160] byte VM b82addc7 done. time: 1.196171ms instrc: 539
I0525 01:26:12.419852 core/state_transition.go:258] VM call err: Out of gas

But that is not the VM trace, I take it?

1 Answer 1

11

In the recent versions of geth, you can use the debug.traceTransaction(txid) call to trace your transaction.

For example, here is a transaction sending some ethers to The DAO contract:

> debug.traceTransaction("0x8e5b38db03e0941677ba65275d78fe18df999c11a7be1921831082121ae73390")
...
}, {
  depth: 1,
  error: "",
  gas: 96943,
  gasCost: 3,
  memory: ["000000000000000000000000b50a06ffe68c746fee498147481767f32ce16ea4", "0000000000000000000000000000000000000000000000000000000000000013", "0000000000000000000000000000000000000000000000000000000000000060", "0000000000000000000000000000000000000000000000000000000000000001"],
  op: "SWAP1",
  pc: 2422,
  stack: ["00000000000000000000000000000000000000000000000000000000baac5300", "0000000000000000000000000000000000000000000000000000000000000060", "0000000000000000000000000000000000000000000000000000000000000020"],
  storage: {
    0000000000000000000000000000000000000000000000000000000000000016: "000000000000000000000000000000000000000000096d2c34d6cb6b944ab9e8",
    8913b768e65415e14d5815e774a6dc351fe0f40ad272540c08c8e6a86fa6ae77: "00000000000000000000000000000000000000000000000402bf8582bb468000",
    eb8d4c8dfc1d31afefdf4361baf3da7164a6863a3e14531b2faef246b93c97bb: "000000000000000000000000000000000000000000000002ac7fae5727845554"
  }
}, {
  depth: 1,
  error: "",
  gas: 96943,
  gasCost: 0,
  memory: ["000000000000000000000000b50a06ffe68c746fee498147481767f32ce16ea4", "0000000000000000000000000000000000000000000000000000000000000013", "0000000000000000000000000000000000000000000000000000000000000060", "0000000000000000000000000000000000000000000000000000000000000001"],
  op: "RETURN",
  pc: 2423,
  stack: ["00000000000000000000000000000000000000000000000000000000baac5300", "0000000000000000000000000000000000000000000000000000000000000020", "0000000000000000000000000000000000000000000000000000000000000060"],
  storage: {
    0000000000000000000000000000000000000000000000000000000000000016: "000000000000000000000000000000000000000000096d2c34d6cb6b944ab9e8",
    8913b768e65415e14d5815e774a6dc351fe0f40ad272540c08c8e6a86fa6ae77: "00000000000000000000000000000000000000000000000402bf8582bb468000",
    eb8d4c8dfc1d31afefdf4361baf3da7164a6863a3e14531b2faef246b93c97bb: "000000000000000000000000000000000000000000000002ac7fae5727845554"
  }
}]

You can see the same tracing information in the VM-Trace tab in https://live.ether.camp .

EDIT: You will find more debugging functions in Management APIs, including:

3
  • Hello, I execute this command within my geth console, but it shows Error: transaction 8e5b38db03e0941677ba65275d78fe18df999c11a7be1921831082121ae73390 not found. Am I missed anything here? Thanks. Commented Nov 28, 2018 at 14:09
  • @The OfficiousBokkyPooBah does this require a full archival node? Commented Apr 28, 2020 at 19:13
  • If the transaction isn't found, the node may not have the data it needs, depending on the mode (archive, full, fast, light): see: geth.ethereum.org/docs/dapp/tracing
    – Justin
    Commented Sep 10, 2021 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.