-
Notifications
You must be signed in to change notification settings - Fork 16
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: ignore unknown opcodes in source maps #764
Open
fvictorio
wants to merge
2
commits into
main
Choose a base branch
from
invalid-opcode-bug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nomicfoundation/edr": patch | ||
--- | ||
|
||
fix: ignore unknown opcodes in source maps |
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
Oops, something went wrong.
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.
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.
I don't think it's advisable to fail silently. It opens a whole can of worms when this should actually be panicking.
Both approaches have downsides:
I'd propose:
Minimal change:
Ideally, also:
2. Add a boolean in the configuration that sets whether to
ignore_invalid_opcodes
. If that's enabled, we don't panic, but log an error.3. Add documentation to Hardhat describing this option
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.
Thanks @Wodann, I agree that silent failing could be dangerous/frustrating.
Do we have any ability to do debug level logging (to be used when ignore_invalid_opcodes is enabled)?
Regardless, can we at least add the invalid op code to part of the panic message?
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.
We have debug logging using the
log
crate. For that you need to run withRUST_LOG=warning your-command
in the CLI. I don't think we currently enable the logger for Hardhat, though.We also use a logger to print things to Hardhat's logger.
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.
@Wodann I think you might have the wrong impression of what's going on here. I should've explained better the context of the change in the description, sorry about that.
I'm pretty sure it shouldn't. This code is part of the error inference heuristics, which "fail silently" all the time. From a user perspective, this means that you might get a plain "transaction reverted" instead of, say, "tried to send funds to non-payable function", or a "<unknown function>" label somewhere in a stack trace. Again, that's much better that a panic.
I'm not sure what you have in mind here. Maybe you think that an execution will have the wrong behavior, like an opcode being skipped instead of reverting? But, again, that's not the case here. Users would have less useful information about a revert, but the execution behavior (the fact that a tx reverted, the receipt, etc.) will be exactly the same.
I do agree that it's desirable to know that this is happening. I'm not sure that logging a warning is necessarily the best option though; sometimes (like here!) there's not much we can do, and that only leads to non-actionable user reports. I know because it's what happened in Hardhat for a long time, when those kinds of warnings reached diminishing returns after we fixed the actionable stuff.
In any case, I think this a telemetry question, and I wouldn't block this PR on that.
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.
Discussed this offline. We'll add a
log::debug
for future reference.