-
Notifications
You must be signed in to change notification settings - Fork 6k
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
eof: Semantic tests update #15665
Merged
Merged
eof: Semantic tests update #15665
Changes from all commits
Commits
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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -11,5 +11,7 @@ contract D { | |
return test(); | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// f() -> true |
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
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
16 changes: 16 additions & 0 deletions
16
test/libsolidity/semanticTests/functionCall/eof/call_options_overload.sol
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,16 @@ | ||
contract C { | ||
function f(uint x) external payable returns (uint) { return 1; } | ||
function f(uint x, uint y) external payable returns (uint) { return 2; } | ||
function call() public payable returns (uint x, uint y) { | ||
x = this.f{value: 10}(2); | ||
y = this.f{value: 10}(2, 3); | ||
} | ||
function bal() external returns (uint) { return address(this).balance; } | ||
receive() external payable {} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// (), 1 ether | ||
// call() -> 1, 2 | ||
// bal() -> 1000000000000000000 |
25 changes: 25 additions & 0 deletions
25
test/libsolidity/semanticTests/functionCall/eof/calling_nonexisting_contract.sol
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,25 @@ | ||
abstract contract D { | ||
function g() public virtual; | ||
} | ||
|
||
|
||
contract C { | ||
D d = D(address(0x1212)); | ||
|
||
function f() public returns (uint256) { | ||
// This call throws on legacy bytecode because of calling nonexisting contract. Legacy checks that there is | ||
// a non-empty code under under an address. EOF doesn't do it because non-observability assumption | ||
d.g(); | ||
return 7; | ||
} | ||
|
||
function h() public returns (uint256) { | ||
address(d).call(""); // this does not throw (low-level) | ||
return 7; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f() -> 7 | ||
// h() -> 7 |
24 changes: 24 additions & 0 deletions
24
test/libsolidity/semanticTests/functionCall/eof/external_call_at_construction_time.sol
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,24 @@ | ||
// This tests skipping the extcodesize check. | ||
|
||
contract T { | ||
constructor() { this.f(); } | ||
function f() external {} | ||
} | ||
contract U { | ||
constructor() { this.f(); } | ||
function f() external returns (uint) {} | ||
} | ||
|
||
contract C { | ||
function f(uint c) external returns (uint) { | ||
if (c == 0) new T(); | ||
else if (c == 1) new U(); | ||
return 1 + c; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f(uint256): 0 -> 1 | ||
// f(uint256): 1 -> FAILURE | ||
// f(uint256): 2 -> 3 |
39 changes: 39 additions & 0 deletions
39
test/libsolidity/semanticTests/functionCall/eof/external_call_to_nonexisting.sol
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,39 @@ | ||
// This tests skipping the extcodesize check. | ||
|
||
interface I { | ||
function a() external pure; | ||
function b() external; | ||
function c() external payable; | ||
function x() external returns (uint); | ||
function y() external returns (string memory); | ||
} | ||
contract C { | ||
I i = I(address(0xcafecafe)); | ||
constructor() payable {} | ||
function f(uint c) external returns (uint) { | ||
if (c == 0) i.a(); | ||
else if (c == 1) i.b(); | ||
else if (c == 2) i.c(); | ||
else if (c == 3) i.c{value: 1}(); | ||
else if (c == 4) i.x(); | ||
else if (c == 5) i.y(); | ||
return 1 + c; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// constructor(), 1 ether -> | ||
// gas irOptimized: 88853 | ||
// gas irOptimized code: 164400 | ||
// gas legacy: 102721 | ||
// gas legacy code: 334400 | ||
// gas legacyOptimized: 91499 | ||
// gas legacyOptimized code: 196400 | ||
// f(uint256): 0 -> 1 | ||
// f(uint256): 1 -> 2 | ||
// f(uint256): 2 -> 3 | ||
// f(uint256): 3 -> 4 | ||
// f(uint256): 4 -> FAILURE | ||
// f(uint256): 5 -> FAILURE | ||
// f(uint256): 6 -> 7 |
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
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
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
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
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 |
---|---|---|
|
@@ -19,5 +19,7 @@ contract C { | |
return true; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// test_function() -> true |
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
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
19 changes: 19 additions & 0 deletions
19
test/libsolidity/semanticTests/reverts/eof/revert_return_area.sol
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,19 @@ | ||
contract C { | ||
fallback() external { | ||
revert("abc"); | ||
} | ||
|
||
function f() public returns (uint s, uint r) { | ||
address x = address(this); | ||
assembly { | ||
mstore(0, 7) | ||
s := extcall(x, 0, 0, 0) | ||
returndatacopy(0, 0, 32) | ||
r := mload(0) | ||
} | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f() -> 0x01, 0x08c379a000000000000000000000000000000000000000000000000000000000 |
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
23 changes: 23 additions & 0 deletions
23
test/libsolidity/semanticTests/saltedCreate/eof/salted_create_with_value.sol
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,23 @@ | ||
contract B | ||
{ | ||
uint x; | ||
function getBalance() public view returns (uint) { | ||
return address(this).balance * 1000 + x; | ||
} | ||
constructor(uint _x) payable { | ||
x = _x; | ||
} | ||
} | ||
|
||
contract A { | ||
function f() public payable returns (uint, uint, uint) { | ||
B x = new B{salt: "abc1", value: 3}(7); | ||
B y = new B{value: 3, salt: "abc2"}(8); | ||
B z = new B{salt: "abc3", value: 3}(9); | ||
return (x.getBalance(), y.getBalance(), z.getBalance()); | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f(), 10 ether -> 3007, 3008, 3009 |
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
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.
This one should have an EOF version.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Also:
salted_create/prediction_example.sol
: calculation on EOF is different, but should still be covered.various/create_calldata.sol
: on EOF the calldata accessible viamsg.data
does contain constructor arguments and this should be tested.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.
Problem with
event_emit_from_other_contact
is that the address inDeposit
event expectation depends on contract bytecode. Which makes testing this in semantic tests impossible.Regarding
prediction_example
I don't see any option to jest it as we don't have access to contract bytecode and more over the bytecode differs between opt and non-opt versions.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.
Ah, true. I guess we can't test that now.
Right, my bad. That will only be possible when address calculation in
eofcreate
gets changed not to include the bytecode hash.I mean, we could technically consider allowing access to
type(C).creationCode
, because we know the bytecode, but we probably shouldn't.