-
Notifications
You must be signed in to change notification settings - Fork 269
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
Constant / view / pure functions still requiring .call() #182
Comments
Hi @sohkai, thank you for saying #161 seems reasonable - unfortunately it was the least bad of two bad choices. It also only works if the compilation step runs twice rather than three times. I think the underlying issue is the placement of solidity mocks in the testing folder. Truffle assumes these are files it should process specially as solidity tests and compiles them on the fly. FWIW Zeppelin (whose engineers proposed this clever ABI rewriting strategy) structured their tests the way you have at Aragon and ultimately had to move their mocks into the root contracts folder and npm ignore them for publication. That work was done in ZS PR 617. Does that seem like it maps to your case? There's a more extensive discussion here at #146. |
Yes, that does. I just saw another repo do this, and was about to try it myself. Thanks for the heads up, I'll report back on how it goes! As an aside, let's put something in the docs for this (unless it's already there and I missed something?) :). |
Agree! I'll do that this morning. |
Trying this now, and it seems to work if you're running JS tests 🎉. However, for solidity tests, would it still force a third compile? |
@sohkai Yes, it will recompile anything in the This tool is scheduled to be re-written to use an in-memory execution trace instead of an event based instrumentation strategy. We're kind of hoping to get around a bunch of these issues that way - the current approach is increasingly difficult to set up and quite brittle. |
Updated the docs here. Let me know if you think anything's missing or could be clearer - sorry about the confusion around this. |
Awesome, it looks good! We might not be able to upgrade yet because we do have some solidity test files, so looking forward to the new version :). |
Closing with aaaab91 |
There's a ton of changes in this PR, the main goals were updating to the new compiler version and doing some clean up to reduce the number of compiler warnings (close #385): - Bumps truffle dependency to a more recent one that comes with Solidity 0.4.24. - Fixes almost all compiler warnings we care about - Changes all constructors to the new `constructor()` syntax - Adds `emit` keyword to all events - Passing anything other than a bytes array to `keccak256()` is now deprecated, a manual `abi.encodePacked(...)` has been added when calculating all hashes. - 💥Removes all the fun [custom abi encoding](https://github.com/aragon/aragonOS/pull/383/files#diff-6d2e88efa27690b63879e31ffb310725L9) in favor of using `abi.encodeWithSelector` - Update solidity-coverage to `0.5.7`. Solidity mocks and tests had to be moved to `contracts/tests` so they could be instrumented correctly (see sc-forks/solidity-coverage#182) and not interfere with the ABI-swapping.
Using 0.4.9.
#161 seems like a pretty reasonable thing to do, and it should work, but I'm having trouble with it on aragonOS.
From what I gather, the problem seems to be from
truffle test
compiling the contracts again. I see the compiler running three times: once for the original, once for the modified, (at this point the modified's ABI is switched out for the original, and I can verify this in thecoverageEnv/builds
folder), and then again whentruffle test
is run.I'm not familiar with how everything is hooked up in truffle, but running through the code, it seems to be that:
truffle test
will compile any necessary files with the test files (it first checks for any updated files, and here it doesn't find any).call()
for us. This last bit is the weird part: I can confirm in thecoverageEnv/build
folder that the ABIs have been swapped, and that any constant functions are appropriately marked. However, the above check when creating the contract artifacts seems to be failing for a lot of these functions, leading me to think that the re-compile done bytruffle test
is causing a newer version of the ABI to be used.I tried to see if not compiling the tests' dependencies would work... but that started giving me parser/compiler errors D:
The text was updated successfully, but these errors were encountered: