Geth – How to Check the VM Trace in Geth

evmgo-ethereum

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?

Best Answer

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:

Related Topic