trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

[truffle debug] TypeError: Cannot read property 'variables' of undefined #3721

Open shanshi opened 3 years ago

shanshi commented 3 years ago

Issue

When I try to debug a transaction, I get the following error: TypeError: Cannot read property 'variables' of undefined.

Steps to Reproduce

Expected Behavior

Being able to debug the transaction.

Actual Results

❯ truffle debug '0x3057987b561313e620765f76842ed9334cdc27e0e31fecb4d872ebbce8da2a7e'
Starting Truffle Debugger...
✔ Compiling your contracts...
⠋ Gathering information about your project and the transaction...TypeError: Cannot read property 'variables' of undefined
    at newScope.variables.concat.linearizedBaseContractsFromBase.map.contractId (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/packages/truffle-debugger/dist/debugger.js:2579:1)
    at Array.map (<anonymous>)
    at map (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/packages/truffle-debugger/dist/debugger.js:2579:1)
    at Array.map (<anonymous>)
    at data.info.scopes._ (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/packages/truffle-debugger/dist/debugger.js:2564:125)
    at /Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect/es/index.js:70:1
    at /Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect/es/index.js:30:1
    at /Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect/es/index.js:84:1
    at Function._ (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect/es/index.js:30:1)
    at args (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect-tree/index.js:209:1)
    at /Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect/es/index.js:80:1
    at Function._ (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect/es/index.js:30:1)
    at args (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect-tree/index.js:209:1)
    at /Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect/es/index.js:80:1
    at /Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/reselect/es/index.js:30:1
    at runSelectEffect (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:730:1)
    at runEffect (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1198:1)
    at digestEffect (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1265:1)
    at next (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1155:1)
    at currCb (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1245:1)
    at checkEnd (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/chunk-e922c950.js:154:1)
    at chCbAtKey (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/chunk-e922c950.js:170:1)
    at Object.currCb [as cont] (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1245:1)
    at end (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1008:1)
    at Object.task.cont (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:836:1)
    at next (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1164:1)
    at Object.currCb [as cont] (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1245:1)
    at end (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1008:1)
    at Object.task.cont (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:836:1)
    at next (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1164:1)
    at proc (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1102:1)
    at runCallEffect (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:533:1)
    at runEffect (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1198:1)
    at digestEffect (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1265:1)
    at next (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1155:1)
    at Object.currCb [as cont] (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1245:1)
    at end (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1008:1)
    at Object.task.cont (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:836:1)
    at next (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1164:1)
    at Object.currCb [as cont] (/Users/shanshi/.nvm/versions/node/v8.17.0/lib/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1245:1)
The above error occurred in task session.saga
Tasks cancelled due to error:
listenerSaga
controller.saga
data.saga
evm.saga
solidity.saga
trace.saga
web3.saga
⠹ Gathering information about your project and the transaction...

Environment

FWIW:

fainashalts commented 3 years ago

Hi @shanshi we think the issue may be that you are on an older version of Truffle. What is holding you back from upgrading your version? Node 8 has reached end of life -- can you upgrade that? Perhaps we can help figure that out if you can share a bit more about the versions you are using. Thanks!

shanshi commented 3 years ago

Hi @fainashalts, thanks for the prompt reply. One of the things that are holding us back from upgrading is the fact that the project uses zos library. We would have to change it for Open Zeppelin SDK in order to be able to upgrade Node and then Truffle.

So as you can imagine, it is a big deal of a change in a large project, and it is uncertain if we break anything else by doing these upgrades.

Is there something else I could do about the error with Truffle? Thanks in advance.

eggplantzzz commented 3 years ago

Sorry @shanshi, I'm not sure how much we can do if you can't update Truffle and Node. There are a number of bugs that we have fixed since the version that you are using. As a last resort you could try various old versions of Truffle even though that is not a very fun solution. When was the last time this worked? What changed to make it break?

shanshi commented 3 years ago

Hi @eggplantzzz, thanks for your reply. I'm afraid that updating Truffle and Node isn't a viable option, at least not for now (rest assured that we want to but it's not the right time).

I tried a few other versions of Truffle (both older and newer), and I had the same problem (I can't remember which versions right now, I'm so sorry). I also tried on a virtual machine with Ubuntu 20.04 installed, and the same version of Truffle that I now have installed on my Mac, but I came across some different errors (i.e. it said the the transaction was not found, even though it exists and the hash was copied directly from Ganache).

I would say that it used to work in the Ubuntu virtual machine I mentioned before, but not all the time. I had a bunch of different errors, but none of them looked like the one I reported. On my Mac, it never worked, no matter what I did.

In regards of what changed to make it break, honestly I'm not really sure. The environment changed (from Ubuntu to Mac), but it's not clear if this is enough to make it break. Besides, there have been many changes in the contracts' code, but again I don't think that this causes the problem because today I had to make changes in a really old branch, and when trying to debug a transaction I had the same error I reported.

I'm just wondering if Truffle works the same way in every operating system, or if there are subtle differences that make it work completely different and are error-prone.

gnidan commented 3 years ago

So sorry about this. I can't think of anything actionable here, since it'd be similarly unreasonable for Truffle to go back to supporting Node v8.

I'm just wondering if Truffle works the same way in every operating system, or if there are subtle differences that make it work completely different and are error-prone.

Once in awhile we get differences related to operating system, but usually not for Linux vs. Mac... usually only Windows causes problems. Certainly any OS-related Truffle problem is a Truffle bug, and we try to treat that as such.

We'll leave this issue open for now in case there's something we can do about it in the future.

Again, sincere apologies that you're in this tight spot with this issue. ☹️

shanshi commented 3 years ago

Hi @gnidan, thanks for your reply. I understand that this is a tricky situation and it may be particular for this project.

A few weeks ago I gave it a shot again and I tried to make it work (kinda). Let's say that my succeed rate was about 40%. Regardless, I would like to share the steps of my experiment in case it works for someone else:

These steps allowed me to debug some transactions but not all of them. Hope this helps.