From dc792748712fd6b652fd8f92a52359b4fa24860d Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 4 Dec 2019 10:42:14 +0100 Subject: [PATCH 1/2] Set default EVM version to Istanbul. --- .circleci/soltest_all.sh | 2 +- Changelog.md | 1 + docs/using-the-compiler.rst | 4 ++-- liblangutil/EVMVersion.h | 2 +- solc/CommandLineInterface.cpp | 3 ++- test/libsolidity/StandardCompiler.cpp | 4 +++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.circleci/soltest_all.sh b/.circleci/soltest_all.sh index 3a2acd1ac..74b3f1197 100755 --- a/.circleci/soltest_all.sh +++ b/.circleci/soltest_all.sh @@ -34,4 +34,4 @@ for OPTIMIZE in 0 1; do done done -EVM=constantinople OPTIMIZE=1 ABI_ENCODER_V2=1 ${REPODIR}/.circleci/soltest.sh \ No newline at end of file +EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 ${REPODIR}/.circleci/soltest.sh diff --git a/Changelog.md b/Changelog.md index b95736856..f3aa6d0fb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ Language Features: Compiler Features: + * Set the default EVM version to "Istanbul". * Commandline Interface: Allow translation from yul / strict assembly to EWasm using ``solc --yul --yul-dialect evm --machine eWasm`` * SMTChecker: Add support to constructors including constructor inheritance. * Yul: When compiling via Yul, string literals from the Solidity code are kept as string literals if every character is safely printable. diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 2a02322cf..fe2d316ba 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -120,9 +120,9 @@ at each version. Backward compatibility is not guaranteed between each version. - ``constantinople`` - Opcodes ``create2`, ``extcodehash``, ``shl``, ``shr`` and ``sar`` are available in assembly. - Shifting operators use shifting opcodes and thus need less gas. -- ``petersburg`` (**default**) +- ``petersburg`` - The compiler behaves the same way as with constantinople. -- ``istanbul`` +- ``istanbul`` (**default**) - Opcodes ``chainid`` and ``selfbalance`` are available in assembly. - ``berlin`` (**experimental**) diff --git a/liblangutil/EVMVersion.h b/liblangutil/EVMVersion.h index 95a9eb089..5151d85a9 100644 --- a/liblangutil/EVMVersion.h +++ b/liblangutil/EVMVersion.h @@ -98,7 +98,7 @@ private: EVMVersion(Version _version): m_version(_version) {} - Version m_version = Version::Petersburg; + Version m_version = Version::Istanbul; }; } diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 48f04d564..05b021379 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -656,7 +656,8 @@ Allowed options)", ( g_strEVMVersion.c_str(), po::value()->value_name("version"), - "Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg (default), istanbul or berlin." + "Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, " + "byzantium, constantinople, petersburg, istanbul (default) or berlin." ) (g_argOptimize.c_str(), "Enable bytecode optimizer.") ( diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index f737ac99d..17b39b2e6 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -900,9 +900,11 @@ BOOST_AUTO_TEST_CASE(evm_version) BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"constantinople\"") != string::npos); result = compile(inputForVersion("\"evmVersion\": \"petersburg\",")); BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"petersburg\"") != string::npos); + result = compile(inputForVersion("\"evmVersion\": \"istanbul\",")); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"istanbul\"") != string::npos); // test default result = compile(inputForVersion("")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"petersburg\"") != string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"istanbul\"") != string::npos); // test invalid result = compile(inputForVersion("\"evmVersion\": \"invalid\",")); BOOST_CHECK(result["errors"][0]["message"].asString() == "Invalid EVM version requested."); From af482470f92464fc2b6b1ce5f74c041cfff337ba Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 4 Dec 2019 11:41:42 +0100 Subject: [PATCH 2/2] Update gas costs. --- test/libsolidity/gasTests/abiv2.sol | 2 +- test/libsolidity/gasTests/abiv2_optimised.sol | 4 +- test/libsolidity/gasTests/dispatch_large.sol | 40 +++++++++---------- .../gasTests/dispatch_large_optimised.sol | 40 +++++++++---------- test/libsolidity/gasTests/dispatch_medium.sol | 16 ++++---- .../gasTests/dispatch_medium_optimised.sol | 16 ++++---- test/libsolidity/gasTests/dispatch_small.sol | 6 +-- .../gasTests/dispatch_small_optimised.sol | 6 +-- 8 files changed, 65 insertions(+), 65 deletions(-) diff --git a/test/libsolidity/gasTests/abiv2.sol b/test/libsolidity/gasTests/abiv2.sol index 2ee698008..390811a0b 100644 --- a/test/libsolidity/gasTests/abiv2.sol +++ b/test/libsolidity/gasTests/abiv2.sol @@ -18,7 +18,7 @@ contract C { // executionCost: 1167 // totalCost: 1123767 // external: -// a(): 530 +// a(): 1130 // b(uint256): infinite // f1(uint256): infinite // f2(uint256[],string[],uint16,address): infinite diff --git a/test/libsolidity/gasTests/abiv2_optimised.sol b/test/libsolidity/gasTests/abiv2_optimised.sol index 83d07911f..35b9b8057 100644 --- a/test/libsolidity/gasTests/abiv2_optimised.sol +++ b/test/libsolidity/gasTests/abiv2_optimised.sol @@ -21,8 +21,8 @@ contract C { // executionCost: 645 // totalCost: 609045 // external: -// a(): 429 -// b(uint256): 884 +// a(): 1029 +// b(uint256): 2084 // f1(uint256): 351 // f2(uint256[],string[],uint16,address): infinite // f3(uint16[],string[],uint16,address): infinite diff --git a/test/libsolidity/gasTests/dispatch_large.sol b/test/libsolidity/gasTests/dispatch_large.sol index 7fc28339c..014eb1a9a 100644 --- a/test/libsolidity/gasTests/dispatch_large.sol +++ b/test/libsolidity/gasTests/dispatch_large.sol @@ -28,25 +28,25 @@ contract Large { // executionCost: 670 // totalCost: 637470 // external: -// a(): 451 -// b(uint256): 846 +// a(): 1051 +// b(uint256): 2046 // f0(uint256): 427 -// f1(uint256): 40752 -// f2(uint256): 20693 -// f3(uint256): 20781 -// f4(uint256): 20759 -// f5(uint256): 20737 -// f6(uint256): 20760 -// f7(uint256): 20672 -// f8(uint256): 20672 -// f9(uint256): 20694 +// f1(uint256): 41352 +// f2(uint256): 21293 +// f3(uint256): 21381 +// f4(uint256): 21359 +// f5(uint256): 21337 +// f6(uint256): 21360 +// f7(uint256): 21272 +// f8(uint256): 21272 +// f9(uint256): 21294 // g0(uint256): 313 -// g1(uint256): 40707 -// g2(uint256): 20670 -// g3(uint256): 20758 -// g4(uint256): 20736 -// g5(uint256): 20692 -// g6(uint256): 20715 -// g7(uint256): 20714 -// g8(uint256): 20692 -// g9(uint256): 20649 +// g1(uint256): 41307 +// g2(uint256): 21270 +// g3(uint256): 21358 +// g4(uint256): 21336 +// g5(uint256): 21292 +// g6(uint256): 21315 +// g7(uint256): 21314 +// g8(uint256): 21292 +// g9(uint256): 21249 diff --git a/test/libsolidity/gasTests/dispatch_large_optimised.sol b/test/libsolidity/gasTests/dispatch_large_optimised.sol index cee223b4c..bb80d1e8e 100644 --- a/test/libsolidity/gasTests/dispatch_large_optimised.sol +++ b/test/libsolidity/gasTests/dispatch_large_optimised.sol @@ -31,25 +31,25 @@ contract Large { // executionCost: 300 // totalCost: 260700 // external: -// a(): 398 -// b(uint256): 1105 +// a(): 998 +// b(uint256): 2305 // f0(uint256): 334 -// f1(uint256): 40874 -// f2(uint256): 20940 -// f3(uint256): 21028 -// f4(uint256): 21006 -// f5(uint256): 20984 -// f6(uint256): 20896 -// f7(uint256): 20676 -// f8(uint256): 20808 -// f9(uint256): 20830 +// f1(uint256): 41474 +// f2(uint256): 21540 +// f3(uint256): 21628 +// f4(uint256): 21606 +// f5(uint256): 21584 +// f6(uint256): 21496 +// f7(uint256): 21276 +// f8(uint256): 21408 +// f9(uint256): 21430 // g0(uint256): 574 -// g1(uint256): 40586 -// g2(uint256): 20674 -// g3(uint256): 20762 -// g4(uint256): 20740 -// g5(uint256): 20828 -// g6(uint256): 20608 -// g7(uint256): 20718 -// g8(uint256): 20696 -// g9(uint256): 20542 +// g1(uint256): 41186 +// g2(uint256): 21274 +// g3(uint256): 21362 +// g4(uint256): 21340 +// g5(uint256): 21428 +// g6(uint256): 21208 +// g7(uint256): 21318 +// g8(uint256): 21296 +// g9(uint256): 21142 diff --git a/test/libsolidity/gasTests/dispatch_medium.sol b/test/libsolidity/gasTests/dispatch_medium.sol index 0c1d80126..c1bc1176e 100644 --- a/test/libsolidity/gasTests/dispatch_medium.sol +++ b/test/libsolidity/gasTests/dispatch_medium.sol @@ -15,12 +15,12 @@ contract Medium { // executionCost: 294 // totalCost: 253294 // external: -// a(): 428 -// b(uint256): 846 -// f1(uint256): 40663 -// f2(uint256): 20693 -// f3(uint256): 20737 +// a(): 1028 +// b(uint256): 2046 +// f1(uint256): 41263 +// f2(uint256): 21293 +// f3(uint256): 21337 // g0(uint256): 313 -// g7(uint256): 20692 -// g8(uint256): 20670 -// g9(uint256): 20626 +// g7(uint256): 21292 +// g8(uint256): 21270 +// g9(uint256): 21226 diff --git a/test/libsolidity/gasTests/dispatch_medium_optimised.sol b/test/libsolidity/gasTests/dispatch_medium_optimised.sol index b2c76140a..db4686a84 100644 --- a/test/libsolidity/gasTests/dispatch_medium_optimised.sol +++ b/test/libsolidity/gasTests/dispatch_medium_optimised.sol @@ -18,12 +18,12 @@ contract Medium { // executionCost: 183 // totalCost: 140983 // external: -// a(): 398 -// b(uint256): 863 -// f1(uint256): 40654 -// f2(uint256): 20698 -// f3(uint256): 20742 +// a(): 998 +// b(uint256): 2063 +// f1(uint256): 41254 +// f2(uint256): 21298 +// f3(uint256): 21342 // g0(uint256): 332 -// g7(uint256): 20608 -// g8(uint256): 20586 -// g9(uint256): 20542 +// g7(uint256): 21208 +// g8(uint256): 21186 +// g9(uint256): 21142 diff --git a/test/libsolidity/gasTests/dispatch_small.sol b/test/libsolidity/gasTests/dispatch_small.sol index cb163d1ba..3d48a4543 100644 --- a/test/libsolidity/gasTests/dispatch_small.sol +++ b/test/libsolidity/gasTests/dispatch_small.sol @@ -11,6 +11,6 @@ contract Small { // totalCost: 83735 // external: // fallback: 118 -// a(): 383 -// b(uint256): 802 -// f1(uint256): 40663 +// a(): 983 +// b(uint256): 2002 +// f1(uint256): 41263 diff --git a/test/libsolidity/gasTests/dispatch_small_optimised.sol b/test/libsolidity/gasTests/dispatch_small_optimised.sol index 7153a784c..9012dbd43 100644 --- a/test/libsolidity/gasTests/dispatch_small_optimised.sol +++ b/test/libsolidity/gasTests/dispatch_small_optimised.sol @@ -14,6 +14,6 @@ contract Small { // totalCost: 60511 // external: // fallback: 118 -// a(): 376 -// b(uint256): 753 -// f1(uint256): 40588 +// a(): 976 +// b(uint256): 1953 +// f1(uint256): 41188