-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Make legacy codegen remove custom errors when compiler option revert-strings=strip is requested
#16466
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
base: develop
Are you sure you want to change the base?
Make legacy codegen remove custom errors when compiler option revert-strings=strip is requested
#16466
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --revert-strings strip --debug-info none --asm --optimize |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| pragma solidity >=0.0; | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
| contract C { | ||
| error MyError(string errorMsg); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd give this an argument or two more, e.g. |
||
| function f() pure external { | ||
| require(false, MyError("error")); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the callsite, declare variables, assign them values, and pass them as arguments to the error constructor call. string errorMsg = "error";
uint256 errorId = 111;
require(false, MyError(errorMsg, errorId));I wanna see some pushes to the stack. |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
|
|
||
| ======= input.sol:C ======= | ||
| EVM assembly: | ||
| mstore(0x40, 0x80) | ||
| callvalue | ||
| dup1 | ||
| iszero | ||
| tag_1 | ||
| jumpi | ||
| revert(0x00, 0x00) | ||
| tag_1: | ||
| pop | ||
| dataSize(sub_0) | ||
| dup1 | ||
| dataOffset(sub_0) | ||
| 0x00 | ||
| codecopy | ||
| 0x00 | ||
| return | ||
| stop | ||
|
|
||
| sub_0: assembly { | ||
| mstore(0x40, 0x80) | ||
| callvalue | ||
| dup1 | ||
| iszero | ||
| tag_1 | ||
| jumpi | ||
| revert(0x00, 0x00) | ||
| tag_1: | ||
| pop | ||
| jumpi(tag_2, lt(calldatasize, 0x04)) | ||
| shr(0xe0, calldataload(0x00)) | ||
| dup1 | ||
| 0x26121ff0 | ||
| eq | ||
| tag_3 | ||
| jumpi | ||
| tag_2: | ||
| revert(0x00, 0x00) | ||
| tag_3: | ||
| tag_4 | ||
| revert(0x00, 0x00) | ||
| tag_4: | ||
| stop | ||
|
|
||
| auxdata: <AUXDATA REMOVED> | ||
| } |
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.
My suspicion is that you'll leave the stack dirty here (i.e. when we iterate and handle the constructor call arguments (loop at 1279), we'll also push any non literal arguments to the stack, which will not be popped anywhere.
Take a look at the revert with error(string) implementation.