Skip to content

Commit

Permalink
Add basic support for the EVM version Paris
Browse files Browse the repository at this point in the history
This mostly means testing with evmone, but instruction renaming of difficulty->prevrandao is omitted.
  • Loading branch information
axic authored and cameel committed Nov 21, 2022
1 parent 0b4b104 commit eb8af2c
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/soltest_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ REPODIR="$(realpath "$(dirname "$0")"/..)"
# shellcheck source=scripts/common.sh
source "${REPODIR}/scripts/common.sh"

EVM_VALUES=(homestead byzantium constantinople petersburg istanbul berlin london)
EVM_VALUES=(homestead byzantium constantinople petersburg istanbul berlin london paris)
DEFAULT_EVM=london
[[ " ${EVM_VALUES[*]} " =~ $DEFAULT_EVM ]]
OPTIMIZE_VALUES=(0 1)
Expand Down
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Language Features:
Compiler Features:
* Commandline Interface: Return exit code ``2`` on uncaught exceptions.
* Commandline Interface: Add `--no-cbor-metadata` that skips CBOR metadata from getting appended at the end of the bytecode.
* EVM: Basic support for the EVM version "Paris".
* Natspec: Add event Natspec inheritance for devdoc.
* Standard JSON: Add a boolean field `settings.metadata.appendCBOR` that skips CBOR metadata from getting appended at the end of the bytecode.
* Yul Optimizer: Allow replacing the previously hard-coded cleanup sequence by specifying custom steps after a colon delimiter (``:``) in the sequence string.
Expand Down
5 changes: 3 additions & 2 deletions docs/using-the-compiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ at each version. Backward compatibility is not guaranteed between each version.
the optimizer.
- ``london`` (**default**)
- The block's base fee (`EIP-3198 <https://eips.ethereum.org/EIPS/eip-3198>`_ and `EIP-1559 <https://eips.ethereum.org/EIPS/eip-1559>`_) can be accessed via the global ``block.basefee`` or ``basefee()`` in inline assembly.

- ``paris``
- No changes.

.. index:: ! standard JSON, ! --standard-json
.. _compiler-api:
Expand Down Expand Up @@ -305,7 +306,7 @@ Input Description
},
// Version of the EVM to compile for.
// Affects type checking and code generation. Can be homestead,
// tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul or berlin
// tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, london or paris
"evmVersion": "byzantium",
// Optional: Change compilation pipeline to go through the Yul intermediate representation.
// This is false by default.
Expand Down
6 changes: 4 additions & 2 deletions liblangutil/EVMVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ class EVMVersion:
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 std::optional<EVMVersion> fromString(std::string const& _version)
{
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london()})
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london(), paris()})
if (_version == v.name())
return v;
return std::nullopt;
Expand All @@ -81,6 +82,7 @@ class EVMVersion:
case Version::Istanbul: return "istanbul";
case Version::Berlin: return "berlin";
case Version::London: return "london";
case Version::Paris: return "paris";
}
return "INVALID";
}
Expand All @@ -102,7 +104,7 @@ class EVMVersion:
bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); }

private:
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London };
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris };

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

Expand Down
2 changes: 1 addition & 1 deletion scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ EVM_VERSIONS="homestead byzantium"

if [ -z "$CI" ]
then
EVM_VERSIONS+=" constantinople petersburg istanbul berlin london"
EVM_VERSIONS+=" constantinople petersburg istanbul berlin london paris"
fi

# And then run the Solidity unit-tests in the matrix combination of optimizer / no optimizer
Expand Down
2 changes: 1 addition & 1 deletion solc/CommandLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,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 or london."
"byzantium, constantinople, petersburg, istanbul, berlin, london or paris."
)
(
g_strExperimentalViaIR.c_str(),
Expand Down
3 changes: 2 additions & 1 deletion test/EVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm):
m_evmRevision = EVMC_BERLIN;
else if (_evmVersion == langutil::EVMVersion::london())
m_evmRevision = EVMC_LONDON;
// TODO: support EVMVersion::paris()
else if (_evmVersion == langutil::EVMVersion::paris())
m_evmRevision = EVMC_PARIS;
else
assertThrow(false, Exception, "Unsupported EVM version");

Expand Down
2 changes: 2 additions & 0 deletions test/libsolidity/StandardCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,8 @@ BOOST_AUTO_TEST_CASE(evm_version)
BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"berlin\"") != string::npos);
result = compile(inputForVersion("\"evmVersion\": \"london\","));
BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"london\"") != string::npos);
result = compile(inputForVersion("\"evmVersion\": \"paris\","));
BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"paris\"") != string::npos);
// test default
result = compile(inputForVersion(""));
BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"london\"") != string::npos);
Expand Down
1 change: 1 addition & 0 deletions test/libsolidity/semanticTests/state/block_difficulty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contract C {
}
// ====
// compileToEwasm: also
// EVMVersion: <paris
// ----
// f() -> 200000000
// f() -> 200000000
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
contract C {
function f() public returns (uint) {
return block.difficulty;
}
}
// ====
// compileToEwasm: also
// EVMVersion: >=paris
// ----
// f() -> 0xa86c2e601b6c44eb4848f7d23d9df3113fbcac42041c49cbed5000cb4f118777
// f() -> 0xa86c2e601b6c44eb4848f7d23d9df3113fbcac42041c49cbed5000cb4f118777
// f() -> 0xa86c2e601b6c44eb4848f7d23d9df3113fbcac42041c49cbed5000cb4f118777
4 changes: 3 additions & 1 deletion test/tools/fuzzer_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ static vector<EVMVersion> s_evmVersions = {
EVMVersion::constantinople(),
EVMVersion::petersburg(),
EVMVersion::istanbul(),
EVMVersion::berlin()
EVMVersion::berlin(),
EVMVersion::london(),
EVMVersion::paris()
};

void FuzzerUtil::testCompilerJsonInterface(string const& _input, bool _optimize, bool _quiet)
Expand Down
4 changes: 4 additions & 0 deletions test/tools/ossfuzz/protoToYul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ EVMVersion ProtoConverter::evmVersionMapping(Program_Version const& _ver)
return EVMVersion::istanbul();
case Program::BERLIN:
return EVMVersion::berlin();
case Program::LONDON:
return EVMVersion::london();
case Program::PARIS:
return EVMVersion::paris();
}
}

Expand Down
2 changes: 2 additions & 0 deletions test/tools/ossfuzz/yulProto.proto
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ message Program {
PETERSBURG = 5;
ISTANBUL = 6;
BERLIN = 7;
LONDON = 8;
PARIS = 9;
}
oneof program_oneof {
Block block = 1;
Expand Down

0 comments on commit eb8af2c

Please sign in to comment.