This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
Introduce subprovider for printing revert stack traces #705
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
albrow
changed the title
[WIP] Introduce subprovider for printing revert stack traces
Introduce subprovider for printing revert stack traces
Jun 14, 2018
LogvinovLeon
approved these changes
Jun 14, 2018
const enabledSubproviderCount = _.filter([isCoverageEnabled, isProfilerEnabled, isRevertTraceEnabled], _.identity) | ||
.length; | ||
if (enabledSubproviderCount > 1) { | ||
throw new Error(`Only one of coverage, profiler, and revert trace subproviders can be enabled at a time`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use or instead of and?
I just added revert trace for @trufflesuite. Have to manage Thanks for inspiration :) @dekz |
I created If you have the plan to support it in |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new subprovider,
RevertTraceSubprovider
, which can be enabled in the contracts tests by settingSOLIDITY_REVERT_TRACE=true
(or runningyarn wsrun test:trace contracts
).Much like the coverage and profiler subproviders, the
RevertTraceSubprovider
will inject itself into calls toeth_sendTransaction
,eth_call
, andeth_estimateGas
. It gets the trace data for each transaction, keeps track of the call stack, and looks for theREVERT
opcode. If it sees theREVERT
opcode, it will simply print out the stack trace which led to the revert.In effect this means that if our tests cause a revert, we will be able to see the origin of that revert as a line number in a Solidity file 🎉
It's not perfect, but it's a good starting point. One thing we would like to add in the future is including function calls in the stack trace. Right now, entries only appear in the stack trace when we call to another contract (e.g., via the
CALL
opcode) and we don't track function calls within the same contract.Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: