feat: introduce EVM Version Shanghai

Note: Paris is still the default
This commit is contained in:
hrkrshnn 2023-04-09 16:19:55 +02:00
parent 0bfcdaf794
commit 802f895062
2 changed files with 6 additions and 3 deletions

View File

@ -58,10 +58,11 @@ public:
static EVMVersion berlin() { return {Version::Berlin}; }
static EVMVersion london() { return {Version::London}; }
static EVMVersion paris() { return {Version::Paris}; }
static EVMVersion shanghai() { return {Version::Shanghai}; }
static std::optional<EVMVersion> fromString(std::string const& _version)
{
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london(), paris()})
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london(), paris(), shanghai()})
if (_version == v.name())
return v;
return std::nullopt;
@ -84,6 +85,7 @@ public:
case Version::Berlin: return "berlin";
case Version::London: return "london";
case Version::Paris: return "paris";
case Version::Shanghai: return "shanghai";
}
return "INVALID";
}
@ -98,6 +100,7 @@ public:
bool hasSelfBalance() const { return *this >= istanbul(); }
bool hasBaseFee() const { return *this >= london(); }
bool hasPrevRandao() const { return *this >= paris(); }
bool hasPush0() const { return *this >= shanghai(); }
bool hasOpcode(evmasm::Instruction _opcode) const;
@ -106,7 +109,7 @@ public:
bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); }
private:
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris };
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris, Shanghai };
EVMVersion(Version _version): m_version(_version) {}

View File

@ -593,7 +593,7 @@ General Information)").c_str(),
g_strEVMVersion.c_str(),
po::value<string>()->value_name("version")->default_value(EVMVersion{}.name()),
"Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, "
"byzantium, constantinople, petersburg, istanbul, berlin, london or paris."
"byzantium, constantinople, petersburg, istanbul, berlin, london, paris or shanghai."
)
;
if (!_forHelp) // Note: We intentionally keep this undocumented for now.