Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is debugging mainnet transactions with Infura possible? #890

Closed
chapati23 opened this issue Apr 11, 2018 · 7 comments

Comments

@chapati23
Copy link

commented Apr 11, 2018


Issue

Can't debug mainnet transactions using infura

Steps to Reproduce

// truffle.js
const HDWalletProvider = require('truffle-hdwallet-provider')

module.exports = {
  networks: {
    mainnet: {
      provider: new HDWalletProvider(
        'some randomly made up mnemonic',
        'https://mainnet.infura.io/'
      ),
      network_id: '1'
    }
  }
}

Expected Behavior

truffle debug <tx-id>  --network mainnet

should have debugged my transaction

Actual Results

Got an error

screen shot 2018-04-11 at 12 24 09

Environment

  • Operating System: MacOS 10.13.4
  • Ethereum client: Infura
  • Truffle version (truffle version): v4.1.5
  • node version (node --version): v9.8.0
  • npm version (npm --version): v5.6.0
@cgewecke

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2018

@chapati23 AFAIK Infura doesn't support geth's debugging API, possibly for security reasons. The debugger requires that the client implement the debug_traceTransaction endpoint and geth allows that method to pass arbitrary JS code in as an option and run it on the client as a trace processor. It would be risky for a public facing service to allow anyone to do that.

However, you should be be able to debug mainnet transactions via a local geth node by running truffle debug 0x... --network mainnet.

@chapati23

This comment has been minimized.

Copy link
Author

commented Apr 11, 2018

@cgewecke thanks, that's what I feared. been syncing for a few hours already…

would it work with geth --fast (syncing only tx receipts and current state DB as far as i understand the docs) or do i need a full full node locally?

@cgewecke

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2018

@chapati23 It looks like it depends on which transaction you want to inspect. There's a nice overview of this subject at the Geth docs here.

@chapati23

This comment has been minimized.

Copy link
Author

commented Apr 11, 2018

Thanks @cgewecke, will give it a read and report back here after my local geth node is fully synced.

@chapati23 chapati23 closed this Apr 11, 2018
@chapati23

This comment has been minimized.

Copy link
Author

commented Apr 12, 2018

Haven't finished syncing yet but I guess this paragraph from the docs answers my question:

In order for an Ethereum node to reexecute a transaction, it needs to have available all historical state accessed by the transaction:

  • Balance, nonce, bytecode and storage of both the recipient as well as all internally invoked contracts.
  • Block metadata referenced during execution of both the outer as well as all internally created transactions.
  • Intermediate state generated by all preceding transactions contained in the same block as the one being traced.

This sounds like it'd only work with a full geth node which sadly is too big for a normal dev machine these days. Guess the best alternative would be to have a full geth node running on AWS.

@cgewecke

This comment has been minimized.

Copy link
Contributor

commented Apr 12, 2018

@chapati23 Ai! That's good to know. . . .thank you.

@chapati23

This comment has been minimized.

Copy link
Author

commented Apr 13, 2018

Can confirm for sure now. In fully synced geth --fast node, i get Error: required historical state unavailable when trying to run debug.traceTransaction(<tx-id>).

was worth a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.