Send / Transfer fails with 'invalid opcode' if destination fallback function instrumented.
lewisbarber opened this issue ยท 13 comments
So I've tried everything in the FAQ, but I'm still getting 'invalid opcode' error messages when trying to call the sendTransaction method of web3. Any idea why this might be happening?
When running the tests using only truffle it works... Perhaps I'm missing something?
@lewisbarber If you could share a link to the code that's producing this error (or generate a minimal truffle project example that produces it) I'll happily take a look at it.
Hey @cgewecke, thanks!
https://github.com/sharpe-capital/sharpe-token/tree/feature/presale-bounties
This branch produces the problem:
truffle test - everything works
npm run coverage - nothing works!
@lewisbarber Thanks, I'm getting these errors on the coverage run.
Is that what you're seeing as well?
When I run the regular tests: npm test
(or truffle test
) I see:
Using Node 7.10.0, on OSX.
Could you verify you're getting a clean run on your end? Or advise re: getting everything to pass so there's a baseline to compare to?
So your problem with truffle test is you need to run testrpc with more gas per block (so it's more like the live network - our code does quite a bit)... The command is:
testrpc -a 10 -l 4000000000
The first error you show for the coverage is the same as what I see.
@lewisbarber Thanks for reporting this.
The problem is with the transfer
here. It's gas constrained by design and because the MultiSigWallet's fallback function is getting instrumented with some expensive events the call maxes out.
Tests will pass if you exclude the MultiSigWallet from the instrumentation process by adding the following to .solcover.js
:
skipFiles: ['lib/MultiSigWallet.sol']
Don't know if you have a pressing audit coming up or something but that Wallet's been combed over pretty carefully so leaving it out might not matter much.
Renaming your issue to reflect the underlying problem.
Ah - that makes perfect sense. I think it's acceptable for us to exclude the MultiSigWallet from the coverage report. In fact, we should probably exclude all third-party libs.
Thanks for taking a look at this so quickly, it's great to have such an important Solidity library properly supported!
Add this to the growing list of reasons to motivate us to move to the debug_tracetransaction
approach!
@lewisbarber Just a heads up - we're reverting our fix for this. I don't think that will affect you since you were going to exclude all 3rd party code in the skipFiles
....
Re-opening. This will continue to happen for the time being.
@cgewecke is this supposed to be fixed now? I'm confused about why I'm still seeing errors for it in 0.6.0. Specifically when unwrapping WETH, the WETH contracts sends ETH to an empty fallback function that reverts when under coverage
@BrendanChou Yes it looks like it's fixed on 0.6.2
(testrpc-sc v6.4.5-sc.3). If you're still seeing it with 0.6.2
could you link to a repro when you have a chance?
We have a passing unit test for the send/transfer case here. Its relevant solidity source and js test are here:
Awesome, 0.6.2 fixed it, thank you!