Merge pull request #12132 from ethereum/userDefinedSideEffectsCodeTransform

Use side-effects of user defined functions in evm code transform.
This commit is contained in:
Daniel
2022-11-22 14:26:57 +01:00
committed by GitHub
20 changed files with 185 additions and 122 deletions
+3
View File
@@ -69,6 +69,9 @@ function zeppelin_test
sed -i "s|it(\('reverts \)|it.skip(\1|g" math/SignedSafeMath.test.js
sed -i "s|it(\('reverts \)|it.skip(\1|g" structs/EnumerableSet.behavior.js
popd
pushd test/proxy/
sed -i "s|it(\('proxy admin cannot call delegated functions',\)|it.skip(\1|g" transparent/TransparentUpgradeableProxy.behaviour.js
popd
# In some cases Hardhat does not detect revert reasons properly via IR.
@@ -63,6 +63,6 @@ contract C {
// gas legacy: 414569
// gas legacyOptimized: 319271
// test_uint256() ->
// gas irOptimized: 511919
// gas irOptimized: 511451
// gas legacy: 581876
// gas legacyOptimized: 442757
@@ -64,6 +64,6 @@ contract C {
// gas legacy: 414569
// gas legacyOptimized: 319271
// test_uint256() ->
// gas irOptimized: 511919
// gas irOptimized: 511451
// gas legacy: 581876
// gas legacyOptimized: 442757
@@ -52,18 +52,18 @@ contract C {
// ----
// test_zeroed_indicies(uint256): 1 ->
// test_zeroed_indicies(uint256): 5 ->
// gas irOptimized: 132036
// gas irOptimized: 131998
// gas legacy: 132961
// gas legacyOptimized: 130752
// test_zeroed_indicies(uint256): 10 ->
// gas irOptimized: 226094
// gas irOptimized: 226012
// gas legacy: 228071
// gas legacyOptimized: 224010
// test_zeroed_indicies(uint256): 15 ->
// gas irOptimized: 324266
// gas irOptimized: 324140
// gas legacy: 327311
// gas legacyOptimized: 321462
// test_zeroed_indicies(uint256): 0xFF ->
// gas irOptimized: 5122626
// gas irOptimized: 5120200
// gas legacy: 5172987
// gas legacyOptimized: 5066462
@@ -15,7 +15,7 @@ contract c {
}
// ----
// test() ->
// gas irOptimized: 114023
// gas irOptimized: 113892
// gas legacy: 131544
// gas legacyOptimized: 126811
// storageEmpty -> 1
@@ -28,7 +28,7 @@ contract C {
// compileViaYul: also
// ----
// constructor() ->
// gas irOptimized: 464753
// gas irOptimized: 449704
// gas legacy: 729908
// gas legacyOptimized: 493347
// h() -> 0x20, 0x40, 0x00, 0
@@ -33,7 +33,7 @@ contract test {
// EVMVersion: >=constantinople
// ----
// constructor()
// gas irOptimized: 438376
// gas irOptimized: 414909
// gas legacy: 750723
// gas legacyOptimized: 536620
// encode_inline_asm(bytes): 0x20, 0 -> 0x20, 0
@@ -51,10 +51,10 @@ contract test {
// encode_no_asm(bytes): 0x20, 5, "fooba" -> 0x20, 8, "Zm9vYmE="
// encode_no_asm(bytes): 0x20, 6, "foobar" -> 0x20, 8, "Zm9vYmFy"
// encode_inline_asm_large()
// gas irOptimized: 1387039
// gas irOptimized: 1374039
// gas legacy: 1688033
// gas legacyOptimized: 1205033
// encode_no_asm_large()
// gas irOptimized: 3316107
// gas irOptimized: 3291100
// gas legacy: 4765077
// gas legacyOptimized: 2908077
@@ -294,11 +294,11 @@ contract Test {
// f() -> true
// g() -> true
// pair() -> true
// gas irOptimized: 270080
// gas irOptimized: 269938
// gas legacy: 275952
// gas legacyOptimized: 267239
// verifyTx() -> true
// ~ emit Verified(string): 0x20, 0x16, "Successfully verified."
// gas irOptimized: 784027
// gas irOptimized: 783501
// gas legacy: 805423
// gas legacyOptimized: 772571
@@ -49,7 +49,7 @@ contract test {
}
// ----
// constructor()
// gas irOptimized: 670586
// gas irOptimized: 642624
// gas legacy: 1096108
// gas legacyOptimized: 741962
// toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0
@@ -69,6 +69,6 @@ contract test {
// gas legacy: 31621
// gas legacyOptimized: 27914
// benchmark(string,bytes32): 0x40, 0x0842021, 8, "solidity" -> 0x2020
// gas irOptimized: 2017770
// gas irOptimized: 1989966
// gas legacy: 4294552
// gas legacyOptimized: 2327981
@@ -26,7 +26,7 @@ contract C {
// revertStrings: debug
// ----
// constructor(), 1 ether ->
// gas irOptimized: 424088
// gas irOptimized: 391081
// gas legacy: 823681
// gas legacyOptimized: 505900
// f(uint256): 0 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code"
@@ -0,0 +1,22 @@
{
let b := f(1, 2)
function f(a, r) -> t { revert(0, 0) }
b := f(3, 4)
}
// ====
// stackOptimization: true
// ----
// /* "":17:18 */
// 0x02
// /* "":14:15 */
// 0x01
// /* "":12:19 */
// tag_1
// jump // in
// /* "":21:59 */
// tag_1:
// /* "":55:56 */
// 0x00
// /* "":45:57 */
// dup1
// revert
+4 -6
View File
@@ -28,10 +28,9 @@
// Block0 [label="\
// i: [ RET[i] ] => [ TMP[i, 0] TMP[i, 1] ]\l\
// Assignment(x, y): [ TMP[i, 0] TMP[i, 1] ] => [ x y ]\l\
// h: [ RET[h] x ] => [ ]\l\
// h: [ RET[h] y ] => [ ]\l\
// h: [ x ] => [ ]\l\
// "];
// Block0Exit [label="MainExit"];
// Block0Exit [label="Terminated"];
// Block0 -> Block0Exit;
//
// FunctionEntry_f_1 [label="function f(a, b) -> r"];
@@ -57,10 +56,9 @@
// FunctionEntry_h_3 -> Block3;
// Block3 [label="\
// f: [ RET[f] 0x00 x ] => [ TMP[f, 0] ]\l\
// h: [ RET[h] TMP[f, 0] ] => [ ]\l\
// g: [ RET[g] ] => [ ]\l\
// h: [ TMP[f, 0] ] => [ ]\l\
// "];
// Block3Exit [label="FunctionReturn[h]"];
// Block3Exit [label="Terminated"];
// Block3 -> Block3Exit;
//
// FunctionEntry_i_4 [label="function i() -> v, w"];
+13 -19
View File
@@ -27,21 +27,18 @@
// Entry -> Block0;
// Block0 [label="\
// [ ]\l\
// [ RET[h] RET[h] RET[i] ]\l\
// [ RET[i] ]\l\
// i\l\
// [ RET[h] RET[h] TMP[i, 0] TMP[i, 1] ]\l\
// [ RET[h] RET[h] TMP[i, 0] TMP[i, 1] ]\l\
// [ TMP[i, 0] TMP[i, 1] ]\l\
// [ TMP[i, 0] TMP[i, 1] ]\l\
// Assignment(x, y)\l\
// [ RET[h] RET[h] x y ]\l\
// [ RET[h] y RET[h] x ]\l\
// h\l\
// [ RET[h] y ]\l\
// [ RET[h] y ]\l\
// [ x y ]\l\
// [ x ]\l\
// h\l\
// [ ]\l\
// [ ]\l\
// "];
// Block0Exit [label="MainExit"];
// Block0Exit [label="Terminated"];
// Block0 -> Block0Exit;
//
// FunctionEntry_f [label="function f(a, b) -> r\l\
@@ -83,19 +80,16 @@
// [ RET x ]"];
// FunctionEntry_h -> Block3;
// Block3 [label="\
// [ RET RET[h] RET[f] 0x00 x ]\l\
// [ RET RET[h] RET[f] 0x00 x ]\l\
// [ RET[f] 0x00 x ]\l\
// [ RET[f] 0x00 x ]\l\
// f\l\
// [ RET RET[h] TMP[f, 0] ]\l\
// [ RET RET[h] TMP[f, 0] ]\l\
// [ TMP[f, 0] ]\l\
// [ TMP[f, 0] ]\l\
// h\l\
// [ RET ]\l\
// [ RET RET[g] ]\l\
// g\l\
// [ RET ]\l\
// [ RET ]\l\
// [ ]\l\
// [ ]\l\
// "];
// Block3Exit [label="FunctionReturn[h]"];
// Block3Exit [label="Terminated"];
// Block3 -> Block3Exit;
//
// FunctionEntry_i [label="function i() -> v, w\l\