Skip to content

Better safeguard against incompatible builtin handles between dialects #15961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 34 additions & 28 deletions liblangutil/EVMVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@

#include <libsolutil/Assertions.h>

#include <array>
#include <cstdint>
#include <optional>
#include <string>
#include <vector>

#include <boost/operators.hpp>


namespace solidity::evmasm
Expand All @@ -44,30 +42,30 @@ namespace solidity::langutil
* A version specifier of the EVM we want to compile to.
* Defaults to the latest version deployed on Ethereum Mainnet at the time of compiler release.
*/
class EVMVersion:
boost::less_than_comparable<EVMVersion>,
boost::equality_comparable<EVMVersion>
class EVMVersion
{
public:
EVMVersion() = default;

static EVMVersion homestead() { return {Version::Homestead}; }
static EVMVersion tangerineWhistle() { return {Version::TangerineWhistle}; }
static EVMVersion spuriousDragon() { return {Version::SpuriousDragon}; }
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 EVMVersion london() { return {Version::London}; }
static EVMVersion paris() { return {Version::Paris}; }
static EVMVersion shanghai() { return {Version::Shanghai}; }
static EVMVersion cancun() { return {Version::Cancun}; }
static EVMVersion prague() { return {Version::Prague}; }
static EVMVersion osaka() { return {Version::Osaka}; }

static std::vector<EVMVersion> allVersions() {
return {
static EVMVersion current() { return {currentVersion}; }

static EVMVersion constexpr homestead() { return {Version::Homestead}; }
static EVMVersion constexpr tangerineWhistle() { return {Version::TangerineWhistle}; }
static EVMVersion constexpr spuriousDragon() { return {Version::SpuriousDragon}; }
static EVMVersion constexpr byzantium() { return {Version::Byzantium}; }
static EVMVersion constexpr constantinople() { return {Version::Constantinople}; }
static EVMVersion constexpr petersburg() { return {Version::Petersburg}; }
static EVMVersion constexpr istanbul() { return {Version::Istanbul}; }
static EVMVersion constexpr berlin() { return {Version::Berlin}; }
static EVMVersion constexpr london() { return {Version::London}; }
static EVMVersion constexpr paris() { return {Version::Paris}; }
static EVMVersion constexpr shanghai() { return {Version::Shanghai}; }
static EVMVersion constexpr cancun() { return {Version::Cancun}; }
static EVMVersion constexpr prague() { return {Version::Prague}; }
static EVMVersion constexpr osaka() { return {Version::Osaka}; }

static auto constexpr allVersions() {
return std::array{
homestead(),
tangerineWhistle(),
spuriousDragon(),
Expand All @@ -85,6 +83,14 @@ class EVMVersion:
};
}

static auto constexpr allEOFVersions()
{
return std::array{
std::optional<uint8_t>(),
std::make_optional<uint8_t>(1)
};
}

static std::optional<EVMVersion> fromString(std::string const& _version)
{
for (auto const& v: allVersions())
Expand All @@ -96,11 +102,10 @@ class EVMVersion:
static EVMVersion firstWithEOF() { return {Version::Osaka}; }

bool isExperimental() const {
return *this > EVMVersion{};
return m_version > currentVersion;
}

bool operator==(EVMVersion const& _other) const { return m_version == _other.m_version; }
bool operator<(EVMVersion const& _other) const { return m_version < _other.m_version; }
auto operator<=>(EVMVersion const&) const = default;

std::string name() const
{
Expand Down Expand Up @@ -164,10 +169,11 @@ class EVMVersion:
Prague,
Osaka,
};
static auto constexpr currentVersion = Version::Cancun;

EVMVersion(Version _version): m_version(_version) {}
constexpr EVMVersion(Version _version): m_version(_version) {}

Version m_version = Version::Cancun;
Version m_version = currentVersion;
};

}
2 changes: 2 additions & 0 deletions libyul/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ add_library(yul
backends/evm/ControlFlowGraphBuilder.h
backends/evm/EthAssemblyAdapter.cpp
backends/evm/EthAssemblyAdapter.h
backends/evm/EVMBuiltins.cpp
backends/evm/EVMBuiltins.h
backends/evm/EVMCodeTransform.cpp
backends/evm/EVMCodeTransform.h
backends/evm/EVMDialect.cpp
Expand Down
Loading