Skip to content
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

Fix for tracebacks and dev reverts in solc 0.8.0 #907

Merged
merged 2 commits into from
Dec 26, 2020

Conversation

iamdefinitelyahuman
Copy link
Member

@iamdefinitelyahuman iamdefinitelyahuman commented Dec 26, 2020

What I did

Fix tracebacks and dev revert reasons for solc 0.8.0 when optimization is enabled.

Closes #897

How I did it

Solidity 0.8.0 introduces a new optimization where all reverts/requires that include an error string are handled by the same bytecode. The source mapping for this bytecode points at the first revert statement that the compiler encounters - as such, when attempting to generate a traceback, all reverting tx's that include an error string will appear to fail at the same location.

To fix this, I'm flagging that first revert as the "optimizer revert". When it's encountered, I step back through the trace until I find a jumpdest (arriving at the optimizer revert from a yul optimization), and then further until i find an instruction with a source offset. This offset is the actual location of the failing revert/require.

This, as with many of Brownie's trace operations, is a hacky heuristic that almost certainly has some failing edge cases and will likely be invalidated by a future change in a patch release of Solidity. But it works right now, so.. this is what we're doing.

How to verify it

Don't even try. Just hope and pray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Solidity compilation broken for solc0.8.0
1 participant