Skip to content

Commit

Permalink
Merge pull request #15828 from ethereum/move-eof-osaka
Browse files Browse the repository at this point in the history
Moves EOF tests from Prague to Osaka
  • Loading branch information
nikola-matic authored Feb 10, 2025
2 parents 9ff6d26 + 462fd19 commit c315294
Show file tree
Hide file tree
Showing 23 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .circleci/soltest_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ REPODIR="$(realpath "$(dirname "$0")"/..)"
source "${REPODIR}/scripts/common.sh"

DEFAULT_EVM_VALUES=(constantinople petersburg istanbul berlin london paris shanghai cancun prague osaka)
EVMS_WITH_EOF=(prague)
EVMS_WITH_EOF=(osaka)

# Deserialize the EVM_VALUES array if it was provided as argument or
# set EVM_VALUES to the default values.
Expand Down
4 changes: 2 additions & 2 deletions liblangutil/EVMVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ using namespace solidity::langutil;

bool EVMVersion::hasOpcode(Instruction _opcode, std::optional<uint8_t> _eofVersion) const
{
// EOF version can be only defined since prague
assert(!_eofVersion.has_value() || *this >= prague());
// EOF version can be only defined since osaka
assert(!_eofVersion.has_value() || *this >= EVMVersion::firstWithEOF());

switch (_opcode)
{
Expand Down
3 changes: 3 additions & 0 deletions liblangutil/EVMVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class EVMVersion:
return std::nullopt;
}

static EVMVersion firstWithEOF() { return {Version::Osaka}; }

bool isExperimental() const {
return *this > EVMVersion{};
}
Expand Down Expand Up @@ -137,6 +139,7 @@ class EVMVersion:
bool hasBlobHash() const { return *this >= cancun(); }
bool hasMcopy() const { return *this >= cancun(); }
bool supportsTransientStorage() const { return *this >= cancun(); }
bool supportsEOF() const { return *this >= firstWithEOF(); }

bool hasOpcode(evmasm::Instruction _opcode, std::optional<uint8_t> _eofVersion) const;

Expand Down
5 changes: 2 additions & 3 deletions libyul/AsmAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,8 @@ bool AsmAnalyzer::validateInstructions(std::string_view _instructionIdentifier,
if (builtinHandle && defaultEVMDialect.builtin(*builtinHandle).instruction.has_value())
return validateInstructions(*defaultEVMDialect.builtin(*builtinHandle).instruction, _location);

solAssert(!m_eofVersion.has_value() || (*m_eofVersion == 1 && m_evmVersion == langutil::EVMVersion::prague()));
// TODO: Change `prague()` to `EVMVersion{}` once EOF gets deployed
auto const& eofDialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::prague(), 1);
solAssert(!m_eofVersion.has_value() || *m_eofVersion == 1);
auto const& eofDialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::firstWithEOF(), 1);
auto const eofBuiltinHandle = eofDialect.findBuiltin(_instructionIdentifier);
if (eofBuiltinHandle)
{
Expand Down
7 changes: 3 additions & 4 deletions libyul/backends/evm/EVMDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,12 @@ std::set<std::string, std::less<>> createReservedIdentifiers(langutil::EVMVersio

auto eofIdentifiersException = [&](evmasm::Instruction _instr) -> bool
{
solAssert(!_eofVersion.has_value() || (*_eofVersion == 1 && _evmVersion == langutil::EVMVersion::prague()));
solAssert(!_eofVersion.has_value() || (*_eofVersion == 1 && _evmVersion.supportsEOF()));
if (_eofVersion.has_value())
// For EOF every instruction is reserved identifier.
return false;
else
return langutil::EVMVersion::prague().hasOpcode(_instr, 1) &&
!langutil::EVMVersion::prague().hasOpcode(_instr, std::nullopt);
return langutil::EVMVersion::firstWithEOF().hasOpcode(_instr, 1) &&
!langutil::EVMVersion::firstWithEOF().hasOpcode(_instr, std::nullopt);
};

std::set<std::string, std::less<>> reserved;
Expand Down
8 changes: 4 additions & 4 deletions libyul/backends/evm/EVMObjectCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ void EVMObjectCompiler::run(Object const& _object, bool _optimize)
yulAssert(_object.analysisInfo, "No analysis info.");
yulAssert(_object.hasCode(), "No code.");
if (evmDialect->eofVersion().has_value())
yulAssert(
_optimize && (evmDialect->evmVersion() >= langutil::EVMVersion::prague()),
"Experimental EOF support is only available for optimized via-IR compilation and the most recent EVM version."
);
{
solUnimplementedAssert(_optimize, "EOF supported only for optimized compilation via IR.");
yulAssert(evmDialect->evmVersion().supportsEOF());
}
if (_optimize && evmDialect->evmVersion().canOverchargeGasForCall())
{
auto stackErrors = OptimizedEVMCodeTransform::run(
Expand Down
2 changes: 1 addition & 1 deletion test/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void CommonOptions::validate() const
std::cout << std::endl << "DO NOT COMMIT THE UPDATED EXPECTATIONS." << std::endl << std::endl;
}

assertThrow(!eofVersion().has_value() || evmVersion() >= langutil::EVMVersion::prague(), ConfigException, "EOF is unavailable before Prague fork.");
assertThrow(!eofVersion().has_value() || evmVersion().supportsEOF(), ConfigException, "EOF is unavailable before Osaka fork.");
}

bool CommonOptions::parse(int argc, char const* const* argv)
Expand Down
5 changes: 2 additions & 3 deletions test/TestCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@ void EVMVersionRestrictedTestCase::processEVMVersionSetting()
void EVMVersionRestrictedTestCase::processBytecodeFormatSetting()
{
std::optional<uint8_t> eofVersion = solidity::test::CommonOptions::get().eofVersion();
// TODO: Update if EOF moved to Osaka
// EOF only available since Prague
solAssert(!eofVersion.has_value() ||solidity::test::CommonOptions::get().evmVersion() >= langutil::EVMVersion::prague());
// EOF only available since Osaka
solAssert(!eofVersion.has_value() || solidity::test::CommonOptions::get().evmVersion().supportsEOF());

std::string bytecodeFormatString = m_reader.stringSetting("bytecodeFormat", "legacy,>=EOFv1");
if (bytecodeFormatString == "legacy,>=EOFv1" || bytecodeFormatString == ">=EOFv1,legacy")
Expand Down
1 change: 1 addition & 0 deletions test/cmdlineTests/strict_asm_eof_container_osaka/args
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--strict-assembly --experimental-eof-version 1 --evm-version osaka --asm --ir-optimized --bin --debug-info none
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

======= strict_asm_eof_container_prague/input.yul (EVM) =======
======= strict_asm_eof_container_osaka/input.yul (EVM) =======

Pretty printed source:
object "object" {
Expand Down
1 change: 0 additions & 1 deletion test/cmdlineTests/strict_asm_eof_container_prague/args

This file was deleted.

1 change: 1 addition & 0 deletions test/cmdlineTests/strict_asm_eof_dataloadn_osaka/args
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--strict-assembly --experimental-eof-version 1 --evm-version osaka --asm --ir-optimized --bin --debug-info none
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

======= strict_asm_eof_dataloadn_prague/input.yul (EVM) =======
======= strict_asm_eof_dataloadn_osaka/input.yul (EVM) =======

Pretty printed source:
object "a" {
Expand Down
1 change: 0 additions & 1 deletion test/cmdlineTests/strict_asm_eof_dataloadn_prague/args

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ contract C {
}
}
// ====
// EVMVersion: >=prague
// bytecodeFormat: >=EOFv1
// ----
// TypeError 2842: (56-96): Cannot set option "value" for staticcall.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ object "a" {
}

// ====
// EVMVersion: >=prague
// bytecodeFormat: >=EOFv1
// ----
// Assembly:
Expand Down
1 change: 0 additions & 1 deletion test/libyul/objectCompiler/eof/dataloadn.yul
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ object "a" {
}

// ====
// EVMVersion: >=prague
// bytecodeFormat: >=EOFv1
// ----
// Assembly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ object "a" {
}

// ====
// EVMVersion: >=prague
// bytecodeFormat: >=EOFv1
// ----
// Assembly:
Expand Down
1 change: 0 additions & 1 deletion test/libyul/objectCompiler/eof/rjumps.yul
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ object "a" {
}

// ====
// EVMVersion: >=prague
// bytecodeFormat: >=EOFv1
// ----
// Assembly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ object "a" {
}

// ====
// EVMVersion: >=prague
// bytecodeFormat: >=EOFv1
// ----
// TypeError 5859: (55-58): Function expects number literal.
1 change: 0 additions & 1 deletion test/libyul/yulSyntaxTests/eof/auxdataloadn_in_legacy.yul
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ object "a" {
}

// ====
// EVMVersion: >=prague
// bytecodeFormat: legacy
// ----
// DeclarationError 7223: (42-54): Builtin function "auxdataloadn" is only available in EOF.
Expand Down

0 comments on commit c315294

Please sign in to comment.