Throws during pure calls to library functions
See original GitHub issueHello sc team,
Recently we have attempted to upgrade to newer version of solidity as well as solidity-coverage and found some issues that took a very long time to track down.
I have created a very minimal example to show the issue which can be found here.
Essentially, a .call()
to a pure
library function is throwing Error: VM Exception while processing transaction: revert
in the coverage environment.
If you take a look at the repo, the instructions to reproduce are there.
According to the docs of solidity 0.4.23 this should be possible and has worked in the past
Library functions can only be called directly (i.e. without the use of DELEGATECALL) if they do not modify the state (i.e. if they are view or pure functions), because libraries are assumed to be stateless
please let me know what other information I can help provide to get this resolved. I think the repo should help bring out the issue pretty clearly.
Thanks for all you guys do!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top GitHub Comments
Hi @pelsasser. Thanks so much for opening. Quite sorry because this issue is known and should have been documented. It was discovered by Zeppelin about a month ago (more detail in this thread)
The underlying issue is that
solidity-coverage
rewrites the contract ABIs of pure/view functions in order to sneak event-based instrumentation into the contracts during compilation. It then swaps the original ABIs back into the contract artifacts to gettruffle
to call the functions correctly. (e.g. as calls, not transactions).Since
0.4.20
, in response to Parity’s wallet being deleted, solc has added protections (at the bytecode level) that prevent non-view library methods from being called directly. TLDR, the pure library functions are being compiled as non-view functions and this triggers the error.A work-around is to call these library methods through a mock contract that uses the library.
contracts
directory (nottest
). You can put them in amocks
folder.skipFiles
option in.solcover.js
, e.gnpm
you’ll probably want to.npmignore
your mocks folderFixed with
0.7.0