diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index ba9b8c431..3a1e0bf4f 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -175,8 +175,8 @@ enum class Instruction: uint8_t LOG3, ///< Makes a log entry; 3 topics. LOG4, ///< Makes a log entry; 4 topics. - SWAP_N = 0xB0, - DUP_N, + DUP_N = 0xB3, + SWAP_N, CREATE = 0xf0, ///< create a new account with associated code CALL, ///< message-call into an account diff --git a/liblangutil/EVMVersion.h b/liblangutil/EVMVersion.h index d36633845..2f907d192 100644 --- a/liblangutil/EVMVersion.h +++ b/liblangutil/EVMVersion.h @@ -57,10 +57,12 @@ 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 EVMVersion cancun() { return {Version::Cancun}; } static std::optional 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(), cancun()}) if (_version == v.name()) return v; return std::nullopt; @@ -83,6 +85,8 @@ public: case Version::Berlin: return "berlin"; case Version::London: return "london"; case Version::Paris: return "paris"; + case Version::Shanghai: return "shanghai"; + case Version::Cancun: return "cancun"; } return "INVALID"; } @@ -104,7 +108,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, Cancun }; EVMVersion(Version _version): m_version(_version) {} diff --git a/libyul/CompilabilityChecker.cpp b/libyul/CompilabilityChecker.cpp index 32b38211c..c08f82e0a 100644 --- a/libyul/CompilabilityChecker.cpp +++ b/libyul/CompilabilityChecker.cpp @@ -65,6 +65,7 @@ CompilabilityChecker::CompilabilityChecker( for (StackTooDeepError const& error: transform.stackErrors()) { + yulAssert(false, "Still stack too deeps??"); unreachableVariables[error.functionName].emplace(error.variable); int& deficit = stackDeficit[error.functionName]; deficit = std::max(error.depth, deficit); diff --git a/libyul/backends/evm/EVMObjectCompiler.cpp b/libyul/backends/evm/EVMObjectCompiler.cpp index e7eae69ba..5405c213f 100644 --- a/libyul/backends/evm/EVMObjectCompiler.cpp +++ b/libyul/backends/evm/EVMObjectCompiler.cpp @@ -76,7 +76,7 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize) yulAssert(_object.code, "No code."); if (m_eofVersion.has_value()) yulAssert( - _optimize && (m_dialect.evmVersion() == langutil::EVMVersion()), + _optimize && (m_dialect.evmVersion() >= langutil::EVMVersion()), "Experimental EOF support is only available for optimized via-IR compilation and the most recent EVM version." ); if (_optimize && m_dialect.evmVersion().canOverchargeGasForCall()) diff --git a/libyul/optimiser/StackToMemoryMover.cpp b/libyul/optimiser/StackToMemoryMover.cpp index 74d05635e..0ae31f8d3 100644 --- a/libyul/optimiser/StackToMemoryMover.cpp +++ b/libyul/optimiser/StackToMemoryMover.cpp @@ -82,6 +82,7 @@ void StackToMemoryMover::run( Block& _block ) { + yulAssert(_numRequiredSlots == 0, "NEEDED STACK TO MEMORY AFTER ALL???"); VariableMemoryOffsetTracker memoryOffsetTracker(_reservedMemory, _memorySlots, _numRequiredSlots); StackToMemoryMover stackToMemoryMover( _context, diff --git a/test/Common.cpp b/test/Common.cpp index 3af23c782..693d74fc6 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -148,7 +148,7 @@ void CommonOptions::validate() const if (enforceGasTest) { assertThrow( - evmVersion() == langutil::EVMVersion{}, + evmVersion() >= langutil::EVMVersion{}, ConfigException, "Gas costs can only be enforced on latest evm version." ); diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 222b4e443..a656024c5 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -124,6 +124,10 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm): m_evmRevision = EVMC_LONDON; else if (_evmVersion == langutil::EVMVersion::paris()) m_evmRevision = EVMC_PARIS; + else if (_evmVersion == langutil::EVMVersion::shanghai()) + m_evmRevision = EVMC_SHANGHAI; + else if (_evmVersion == langutil::EVMVersion::cancun()) + m_evmRevision = EVMC_CANCUN; else assertThrow(false, Exception, "Unsupported EVM version");