-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
base: develop
Are you sure you want to change the base?
eof: Semantic tests update #15665
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,17 @@ | ||
contract C { | ||
uint120[3] x; | ||
function f() public returns (bytes32 hash1, bytes32 hash2, bool hash3NonZero) { | ||
uint120[] memory y = new uint120[](3); | ||
x[0] = y[0] = uint120(type(uint).max - 1); | ||
x[1] = y[1] = uint120(type(uint).max - 2); | ||
x[2] = y[2] = uint120(type(uint).max - 3); | ||
hash1 = keccak256(abi.encodePacked(x)); | ||
hash2 = keccak256(abi.encodePacked(y)); | ||
hash3NonZero = bytes32(0) != keccak256(abi.encodePacked(this.f)); | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=prague | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f() -> 0xba4f20407251e4607cd66b90bfea19ec6971699c03e4a4f3ea737d5818ac27ae, 0xba4f20407251e4607cd66b90bfea19ec6971699c03e4a4f3ea737d5818ac27ae, true |
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. This one is currently hard to recreate on EOF because we're planning to disallow |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
contract A1 {} | ||
contract B1 is A1 { constructor() payable {} } | ||
|
||
contract A2 { constructor() {} } | ||
contract B2 is A2 { constructor() payable {} } | ||
|
||
contract B3 { constructor() payable {} } | ||
|
||
contract C { | ||
function f() public payable returns (bool) { | ||
// Make sure none of these revert. | ||
new B1{value: 10, salt: hex"00"}(); | ||
new B2{value: 10, salt: hex"01"}(); | ||
new B3{value: 10, salt: hex"02"}(); | ||
return true; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// EVMVersion: >=prague | ||
// ---- | ||
// f(), 2000 ether -> true | ||
// gas irOptimized: 117623 | ||
// gas irOptimized code: 1800 | ||
// gas legacy: 117821 | ||
// gas legacy code: 4800 | ||
// gas legacyOptimized: 117690 | ||
// gas legacyOptimized code: 4800 | ||
Comment on lines
+23
to
+28
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. Please remove gas expectations when you're creating EOF versions of tests. We're not calculating them for EOF and I think they're not even checked for correctness here (because |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,5 +36,7 @@ contract C { | |
return x < data.length; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// test() -> true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,5 +30,7 @@ contract C { | |
return x < data.length; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// test() -> true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,5 +32,7 @@ contract C { | |
return x < data.length; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// test() -> true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,7 @@ contract C is S { | |
return x < data.length; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// test() -> true |
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. All the tests from |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,7 @@ contract C is S { | |
return x < data.length; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// test() -> true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,5 +35,7 @@ contract C is X { | |
return x < data.length; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// test() -> true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
interface Parent { | ||
function parentFun() external returns (uint256); | ||
} | ||
|
||
interface SubA is Parent { | ||
function subAFun() external returns (uint256); | ||
} | ||
|
||
interface SubB is Parent { | ||
function subBFun() external returns (uint256); | ||
} | ||
|
||
contract Impl is SubA, SubB { | ||
function parentFun() override external returns (uint256) { return 1; } | ||
function subAFun() override external returns (uint256) { return 2; } | ||
function subBFun() override external returns (uint256) { return 3; } | ||
} | ||
|
||
contract C { | ||
function convertParent() public returns (uint256) { | ||
Parent p = new Impl(); | ||
return p.parentFun(); | ||
} | ||
|
||
function convertSubA() public returns (uint256, uint256) { | ||
bytes32 s = 0x0000000000000000000000000000000000000000000000000000000000000001; | ||
SubA sa = new Impl{salt: s}(); | ||
return (sa.parentFun(), sa.subAFun()); | ||
} | ||
|
||
function convertSubB() public returns (uint256, uint256) { | ||
bytes32 s = 0x0000000000000000000000000000000000000000000000000000000000000002; | ||
SubB sb = new Impl{salt: s}(); | ||
return (sb.parentFun(), sb.subBFun()); | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// convertParent() -> 1 | ||
// gas irOptimized: 85524 | ||
// convertSubA() -> 1, 2 | ||
// gas irOptimized: 86155 | ||
// gas legacy: 99047 | ||
// convertSubB() -> 1, 3 | ||
// gas irOptimized: 86098 | ||
// gas legacy: 98981 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
pragma abicoder v2; | ||
|
||
struct S { | ||
uint256 a; | ||
bool b; | ||
string s; | ||
} | ||
|
||
error E(); | ||
error E1(uint256); | ||
error E2(string); | ||
error E3(S); | ||
error E4(address); | ||
error E5(function() external pure); | ||
|
||
contract C { | ||
function a() external pure { | ||
require(false, E()); | ||
} | ||
function b() external pure { | ||
require(false, E1(1)); | ||
} | ||
function c() external pure { | ||
require(false, E2("string literal")); | ||
} | ||
function d() external pure { | ||
require(false, E3(S(1, true, "string literal"))); | ||
} | ||
function e() external view { | ||
require(false, E4(address(0x6AfCA7D4Df015A0Ba25dA0d02D175603a5fB40E6))); | ||
} | ||
function f(function() external pure x) external view { | ||
require(false, E5(x)); | ||
} | ||
} | ||
|
||
// ==== | ||
// EVMVersion: >=prague | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// a() -> FAILURE, hex"92bbf6e8" | ||
// b() -> FAILURE, hex"47e26897", hex"0000000000000000000000000000000000000000000000000000000000000001" | ||
// c() -> FAILURE, hex"8f372c34", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"000000000000000000000000000000000000000000000000000000000000000e", hex"737472696e67206c69746572616c000000000000000000000000000000000000" | ||
// d() -> FAILURE, hex"5717173e", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"0000000000000000000000000000000000000000000000000000000000000060", hex"000000000000000000000000000000000000000000000000000000000000000e", hex"737472696e67206c69746572616c000000000000000000000000000000000000" | ||
// e() -> FAILURE, hex"7efef9ea", hex"0000000000000000000000006afca7d4df015a0ba25da0d02d175603a5fb40e6" | ||
// f(function): left(0x6afca7d4df015a0ba25da0d02d175603a5fb40e60dbe671f0000000000000000) -> FAILURE, hex"0c3f12eb", hex"6afca7d4df015a0ba25da0d02d175603a5fb40e60dbe671f0000000000000000" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error CustomError(function(uint256) external pure returns (uint256)); | ||
|
||
contract C | ||
{ | ||
function f(function(uint256) external pure returns (uint256) x) external view | ||
{ | ||
// more than one stack slot | ||
require(false, CustomError(x)); | ||
} | ||
} | ||
|
||
// ==== | ||
// EVMVersion: >=prague | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f(function): left(0xa4dc3b5fce39438ce512c732ccb22e3212856bb6f37cdc8e0000000000000000) -> FAILURE, hex"271b1dfa", hex"a4dc3b5fce39438ce512c732ccb22e3212856bb6f37cdc8e0000000000000000" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
contract C { | ||
event Test(function() external indexed); | ||
function f(function() external x) public { | ||
emit Test(x); | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=prague | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f(function): left(0x8f8cc95dcbe7358c1cf1409d3a7ad079e89576bb26121ff00000000000000000) -> | ||
// ~ emit Test(function): #0x8f8cc95dcbe7358c1cf1409d3a7ad079e89576bb26121ff00000000000000000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
contract C { | ||
event TestA(function() external indexed); | ||
event TestB(function(uint256) external indexed); | ||
function f1(function() external x) public { | ||
emit TestA(x); | ||
} | ||
function f2(function(uint256) external x) public { | ||
emit TestB(x); | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=prague | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f1(function): left(0x347eaa94e3f63220b1f27af5888d33325ddbd4dec27fc3050000000000000000) -> | ||
// ~ emit TestA(function): #0x347eaa94e3f63220b1f27af5888d33325ddbd4dec27fc3050000000000000000 | ||
// f2(function): left(0x347eaa94e3f63220b1f27af5888d33325ddbd4debf3724af0000000000000000) -> | ||
// ~ emit TestB(function): #0x347eaa94e3f63220b1f27af5888d33325ddbd4debf3724af0000000000000000 |
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. This one should have an EOF version. 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. Same for:
Empty contracts do not revert on EOF, but that needs to be tested too. Does not need to be an exactly copy of these tests, could also be a new one that combines all the relevant points from those. 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. Also:
|
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.
EVMVersion: >=prague
is redundant when the test is already restricted to EOF. You have that in multiple tests.