Skip to content

Commit

Permalink
feat: introduce EVM Version Shanghai
Browse files Browse the repository at this point in the history
Note: Paris is still the default
  • Loading branch information
hrkrshnn committed Apr 11, 2023
1 parent 0bfcdaf commit 802f895
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions liblangutil/EVMVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ class EVMVersion:
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;
Expand All @@ -84,6 +85,7 @@ class EVMVersion:
case Version::Berlin: return "berlin";
case Version::London: return "london";
case Version::Paris: return "paris";
case Version::Shanghai: return "shanghai";
}
return "INVALID";
}
Expand All @@ -98,6 +100,7 @@ class EVMVersion:
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;

Expand All @@ -106,7 +109,7 @@ class EVMVersion:
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) {}

Expand Down
2 changes: 1 addition & 1 deletion solc/CommandLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 802f895

Please sign in to comment.