From 5749a5d7c9d3d0c92a651543b97d8f447d339a39 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 26 Aug 2019 13:09:55 +0100 Subject: [PATCH] Introduce istanbul and berlin versions --- docs/using-the-compiler.rst | 4 +++- liblangutil/EVMVersion.h | 8 ++++++-- solc/CommandLineInterface.cpp | 2 +- test/EVMHost.cpp | 4 ++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index b63c36f19..5b2e9b8ca 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -122,6 +122,8 @@ at each version. Backward compatibility is not guaranteed between each version. - Shifting operators use shifting opcodes and thus need less gas. - ``petersburg`` (**default**) - The compiler behaves the same way as with constantinople. +- ``istanbul`` (**experimental**) +- ``berlin`` (**experimental**) .. _compiler-api: @@ -229,7 +231,7 @@ Input Description }, // Version of the EVM to compile for. // Affects type checking and code generation. Can be homestead, - // tangerineWhistle, spuriousDragon, byzantium, constantinople or petersburg + // tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul or berlin "evmVersion": "byzantium", // Metadata settings (optional) "metadata": { diff --git a/liblangutil/EVMVersion.h b/liblangutil/EVMVersion.h index f80a18708..6fb6f7e3e 100644 --- a/liblangutil/EVMVersion.h +++ b/liblangutil/EVMVersion.h @@ -48,10 +48,12 @@ public: static EVMVersion byzantium() { return {Version::Byzantium}; } static EVMVersion constantinople() { return {Version::Constantinople}; } static EVMVersion petersburg() { return {Version::Petersburg}; } + static EVMVersion istanbul() { return {Version::Istanbul}; } + static EVMVersion berlin() { return {Version::Berlin}; } static boost::optional fromString(std::string const& _version) { - for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg()}) + for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin()}) if (_version == v.name()) return v; return {}; @@ -70,6 +72,8 @@ public: case Version::Byzantium: return "byzantium"; case Version::Constantinople: return "constantinople"; case Version::Petersburg: return "petersburg"; + case Version::Istanbul: return "istanbul"; + case Version::Berlin: return "berlin"; } return "INVALID"; } @@ -88,7 +92,7 @@ public: bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); } private: - enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg }; + enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin }; EVMVersion(Version _version): m_version(_version) {} diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 34d4e8894..79d85d82f 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -641,7 +641,7 @@ Allowed options)", ( g_strEVMVersion.c_str(), po::value()->value_name("version"), - "Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople or petersburg (default)." + "Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg (default), istanbul or berlin." ) (g_argOptimize.c_str(), "Enable bytecode optimizer.") ( diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index f18abc10d..5122f3846 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -75,6 +75,10 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::vm* _vm): m_evmVersion = EVMC_BYZANTIUM; else if (_evmVersion == langutil::EVMVersion::constantinople()) m_evmVersion = EVMC_CONSTANTINOPLE; + else if (_evmVersion == langutil::EVMVersion::istanbul()) + assertThrow(false, Exception, "Istanbul is not supported yet."); + else if (_evmVersion == langutil::EVMVersion::berlin()) + assertThrow(false, Exception, "Berlin is not supported yet."); else //if (_evmVersion == langutil::EVMVersion::petersburg()) m_evmVersion = EVMC_PETERSBURG; }