Introduce istanbul and berlin versions

This commit is contained in:
Alex Beregszaszi 2019-08-26 13:09:55 +01:00
parent d47863ef35
commit 5749a5d7c9
4 changed files with 14 additions and 4 deletions

View File

@ -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. - Shifting operators use shifting opcodes and thus need less gas.
- ``petersburg`` (**default**) - ``petersburg`` (**default**)
- The compiler behaves the same way as with constantinople. - The compiler behaves the same way as with constantinople.
- ``istanbul`` (**experimental**)
- ``berlin`` (**experimental**)
.. _compiler-api: .. _compiler-api:
@ -229,7 +231,7 @@ Input Description
}, },
// Version of the EVM to compile for. // Version of the EVM to compile for.
// Affects type checking and code generation. Can be homestead, // 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", "evmVersion": "byzantium",
// Metadata settings (optional) // Metadata settings (optional)
"metadata": { "metadata": {

View File

@ -48,10 +48,12 @@ public:
static EVMVersion byzantium() { return {Version::Byzantium}; } static EVMVersion byzantium() { return {Version::Byzantium}; }
static EVMVersion constantinople() { return {Version::Constantinople}; } static EVMVersion constantinople() { return {Version::Constantinople}; }
static EVMVersion petersburg() { return {Version::Petersburg}; } static EVMVersion petersburg() { return {Version::Petersburg}; }
static EVMVersion istanbul() { return {Version::Istanbul}; }
static EVMVersion berlin() { return {Version::Berlin}; }
static boost::optional<EVMVersion> fromString(std::string const& _version) static boost::optional<EVMVersion> 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()) if (_version == v.name())
return v; return v;
return {}; return {};
@ -70,6 +72,8 @@ public:
case Version::Byzantium: return "byzantium"; case Version::Byzantium: return "byzantium";
case Version::Constantinople: return "constantinople"; case Version::Constantinople: return "constantinople";
case Version::Petersburg: return "petersburg"; case Version::Petersburg: return "petersburg";
case Version::Istanbul: return "istanbul";
case Version::Berlin: return "berlin";
} }
return "INVALID"; return "INVALID";
} }
@ -88,7 +92,7 @@ public:
bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); } bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); }
private: 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) {} EVMVersion(Version _version): m_version(_version) {}

View File

@ -641,7 +641,7 @@ Allowed options)",
( (
g_strEVMVersion.c_str(), g_strEVMVersion.c_str(),
po::value<string>()->value_name("version"), po::value<string>()->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.") (g_argOptimize.c_str(), "Enable bytecode optimizer.")
( (

View File

@ -75,6 +75,10 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::vm* _vm):
m_evmVersion = EVMC_BYZANTIUM; m_evmVersion = EVMC_BYZANTIUM;
else if (_evmVersion == langutil::EVMVersion::constantinople()) else if (_evmVersion == langutil::EVMVersion::constantinople())
m_evmVersion = EVMC_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()) else //if (_evmVersion == langutil::EVMVersion::petersburg())
m_evmVersion = EVMC_PETERSBURG; m_evmVersion = EVMC_PETERSBURG;
} }