-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Compiler stack: Protect loadGeneratedIR from contracts that cannot be deployed #15505
Conversation
I would also add a test case like: // SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
abstract contract C {
function f() public virtual returns (string memory);
} and // SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
interface I {
function f() external returns (string memory);
} Could be similar to our current ast ir command-line test (https://github.com/ethereum/solidity/blob/e8b5ca83f37b6a126db6a0a1dcfa00decff63647/test/cmdlineTests/ast_ir/args). And also one, or more, for standard Json output (https://github.com/ethereum/solidity/blob/e8b5ca83f37b6a126db6a0a1dcfa00decff63647/test/cmdlineTests/standard_ir_ast_requested/input.json): {
"language": "Solidity",
"sources":
{
"C":
{
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; abstract contract C {}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"details": {
"yul": true
}
},
"viaIR": true,
"outputSelection": {
"*": {
"*": ["irAst", "irOptimizedAst", "yulCFGJson"]
}
}
}
} |
test/cmdlineTests/standard_ir_ast_interface_requested/output.json
Outdated
Show resolved
Hide resolved
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.
Good catch. Looks like I unwittingly introduced this bug in the last release via #15451.
The fix is not wrong, but I'd do it differently in CompilerStack
to make this kind of mistake harder to make in the future.
test/cmdlineTests/standard_ir_ast_interface_requested/output.json
Outdated
Show resolved
Hide resolved
f2cd9a1
to
84e08d5
Compare
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 have only one suggestion. But it looks good to me anyway :)
84e08d5
to
a4d66c4
Compare
This should probably also get a bugfix changelog entry. A bit annoying that this is in the release now, but I guess people rarely use these json artifacts anyways - might be a good indicator for how much they're used in the wild actually (since if they're used, people will quickly run into this I guess) |
a4d66c4
to
b7f7244
Compare
3548b2d
to
1f20ccd
Compare
1f20ccd
to
a7eaac7
Compare
a7eaac7
to
7972c51
Compare
If a contract is not deployable (ie interface / abstract), no
yulIR
will be generated. This causes the object parser to error out inloadGeneratedIR
, as it expectsobject {}
as a bare minimum, but gets an empty string instead.