Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix: prevent DEBUG env var from crashing ganache #1740

Merged
merged 1 commit into from
Dec 6, 2021
Merged

Conversation

davidmurdoch
Copy link
Member

@ethereumjs/vm uses the DEBUG env var and the debug npm module to output debug information during runtime. We don't currently use the @ethereum/tx library for our transactions, so our transaction are "missing" some fields that are used only when DEBUG is true. This causes ganache to error when it shouldn't.

Other potential solutions:

  • implement all of the debug-related properties everywhere
  • use @ethereumjs/tx (and probably /account, and a `/block, too)

A benefit of just removing the debug module and replacing process.env.DEBUG with false is that the resulting build is smaller (and slightly faster due to the minifier removing dead code). Downside: no one can use debug for ganache's internals (I doubt anyone was wanting this anyway?) and if we want to use the debug module in the future we can't... because it's removed by the build process.

Copy link
Contributor

@MicaiahReid MicaiahReid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, do you have any repro steps for times when Ganache would error when it shouldn't before this fix?

@davidmurdoch
Copy link
Member Author

I'm curious, do you have any repro steps for times when Ganache would error when it shouldn't before this fix?

Woops. I should have provided this!

Using ganache 7.0.0-beta.1:

ganache -d

Then from a separate terminal run:

curl -H 'Content-Type: application/json'   --data '{"jsonrpc":"2.0","method": "eth_estimateGas", "params": [ {"from": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1", "to": "0x016c5aa3Fd1e8cF85b31F0F69F9BE82f2f52e764"} ],"id":1}' http://localhost:8545

and you'll get:

{"id":1,"jsonrpc":"2.0","error":{"message":"e.tx.isSigned is not a function","stack":"TypeError: e.tx.isSigned is not a function\n    at VM._runTx (/home/david/.nvm/versions/node/v12.0.0/lib/node_modules/ganache/dist/node/0.js:2:1115879)\n    at processTicksAndRejections (internal/process/task_queues.js:88:5)\n    at async VM.runTx (/home/david/.nvm/versions/node/v12.0.0/lib/node_modules/ganache/dist/node/0.js:2:1122709)\n    at async exactimate (/home/david/.nvm/versions/node/v12.0.0/lib/node_modules/ganache/dist/node/1.js:2:104682)","code":-32700}}

@davidmurdoch davidmurdoch merged commit 9db625f into develop Dec 6, 2021
@davidmurdoch davidmurdoch deleted the fix/DEBUG branch December 6, 2021 22:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants