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

[Profiler] Truffle sometimes fails to compile #1713

Closed maxsam4 closed 4 years ago

maxsam4 commented 5 years ago

Issue

When solidity code has changed a lot since the last compile, truffle compile fails most of the time. The exact error thrown is

Using network 'development'.

ReferenceError: e is not defined
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:267:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
ReferenceError: e is not defined
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:267:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:255:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)
    at async.whilst.fileFinished (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:278:1)
    at next (/home/max/Desktop/Ethereum/truffle 5/polymath-core/node_modules/truffle/build/webpack:/~/async/dist/async.js:5223:1)

:23
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var __GLOBAL__I_000101=Module["__GLOBAL__I_000101"]=asm["__GLOBAL__I_000101"];var __GLOBAL__sub_I_ABIFunctions_cpp=Module["__GLOBAL__sub_I_ABIFunctions_cpp"]=asm["__GLOBAL__sub_I_ABIFunctions_cpp"];var __GLOBAL__sub_I_ABI_cpp=Module["__GLOBAL__sub_I_ABI_cpp"]=asm["__GLOBAL__sub_I_ABI_cpp"];var __GLOBAL__sub_I_ASTJsonConverter_cpp=Module["__GLOBAL__sub_I_ASTJsonConverter_cpp"]=asm["__GLOBAL__sub_I_ASTJsonConverter_cpp"];var __GLOBAL__sub_I_AST_cpp=Module["__GLOBAL__sub_I_AST_cpp"]=asm["__GLOBAL__sub_I_AST_cpp"];var __GLOBAL__sub_I_ArrayUtils_cpp=Module["__GLOBAL__sub_I_ArrayUtils_cpp"]=asm["__GLOBAL__sub_I_ArrayUtils_cpp"];var __GLOBAL__sub_I_AsmAnalysis_cpp=Module["__GLOBAL__sub_I_AsmAnalysis_cpp"]=asm["__GLOBAL__sub_I_AsmAnalysis_cpp"];var __GLOBAL__sub_I_CompilerContext_cpp=Module["__GLOBAL__sub_I_CompilerContext_cpp"]=asm["__GLOBAL__sub_I_CompilerContext_cpp"];var __GLOBAL__sub_I_CompilerStack_cpp=Module["__GLOBAL__sub_I_CompilerStack_cpp"]=asm["__GLO
abort({}). Build with -s ASSERTIONS=1 for more info.

I suspect that the reason behind this is that solcjs is used by the parser in profiler (thanks to @gnidan for pointing that out in gitter) while I am using native solc for actual compilation. The native solc being used and solcjs being used are of different version which I suspect might be causing some issues. I am not sure though. The issue can very well be something completely different.

The issue goes away on clearing the build folder.

Steps to Reproduce

I don't have reliable steps to reproduce it. I reckon trying to compile something with solc 0.5.0 and then changing the hell outa it and recompiling. Make sure that a different version of solcjs is cached to be used by the profiler.

Environment

mattcrooks commented 5 years ago

Seeing something similar in our environment (same as above) when using Gulp watch task. Deleting build folder resolves it.

AC0DEM0NK3Y commented 5 years ago

This looks very similar to https://github.com/trufflesuite/truffle/issues/1659

gnidan commented 5 years ago

This might be fixed by the outstanding PR #1720, which needs to be revisited. Will add that to the to-dos for this week or next. Thanks all!

eggplantzzz commented 5 years ago

Is this still an issue on the latest version of Truffle (v5.0.21)?

maxsam4 commented 5 years ago

@eggplantzzz I tried it a bit with v5.0.21 and I did not get this error. However, instead of throwing this error, truffle compiled invalid code which caused invalid opcode error when running truffle migrate. I think that the fix you included for this (or something else) broke some other component.

Maybe this error is still present. I did not try much as truffle v5.0.21 was unusable for me.

eggplantzzz commented 5 years ago

To be honest I'm not sure if this was ever directly addressed or reproduced on my part but some of the code related to compilation/parsing has been worked on since 5.0.4. If you are able to provide specific reproduction steps then I would be happy to try and troubleshoot this. Let me know!

wbt commented 5 years ago

instead of throwing this error, truffle compiled invalid code which caused invalid opcode error when running truffle migrate. I think that the fix you included for this (or something else) broke some other component.

I wonder if this is related to Solidity issue 6977, which @chriseth thinks is actually a problem in Truffle?

eggplantzzz commented 5 years ago

@wbt Just to confirm, you said you are unable to reproduce this? If you ever figure out a way to do this reliably then I would appreciate it! In the meantime, however, I will keep a look out for this issue.

wbt commented 5 years ago

I have not reproduced the specific issue ReferenceError: e is not defined as described in OP above. I have seen the issue in Solidity issue 6977 several times but lately I have been avoiding recompilation, largely to avoid that issue and the associated delays in real development progress on the parts of the dapp that are not the smart contracts. If I do get reliable reproduction steps I will post them or at least a link to them in that Solidity issue.

I put the cross-link in here because there may be a relationship between the two, as suggested by OP on June 11, like a fix for the original problem causing the other one...or maybe they are two intermittent independent bugs.

eggplantzzz commented 4 years ago

Is this still a problem that exists on current Truffle (5.1.16)? I feel like this may have been solved. If someone can produce this error, let us know!

gnidan commented 4 years ago

So this issue is still a mystery, then.

The original issue is almost certainly out of date (we recently removed async/whilst in that code, e.g., and even before that commit, a misnamed e variable would've been caught ~1y ago when we set up a linter).

Unless there's evidence that there's still a real issue here, or something actionable for us, going to mark this one as closed for issue maintenance.

Happy to re-open if there's further work here; let us know! Thanks!