Skip to content

Commit 5211d3d

Browse files
authored
Merge pull request #13698 from ethereum/evm-paris
Add basic support for the EVM version Paris
2 parents 50935db + c353eb0 commit 5211d3d

File tree

14 files changed

+45
-10
lines changed

14 files changed

+45
-10
lines changed

.circleci/soltest_all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ REPODIR="$(realpath "$(dirname "$0")"/..)"
3131
# shellcheck source=scripts/common.sh
3232
source "${REPODIR}/scripts/common.sh"
3333

34-
EVM_VALUES=(homestead byzantium constantinople petersburg istanbul berlin london)
34+
EVM_VALUES=(homestead byzantium constantinople petersburg istanbul berlin london paris)
3535
DEFAULT_EVM=london
3636
[[ " ${EVM_VALUES[*]} " =~ $DEFAULT_EVM ]]
3737
OPTIMIZE_VALUES=(0 1)

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Language Features:
66
Compiler Features:
77
* Commandline Interface: Return exit code ``2`` on uncaught exceptions.
88
* Commandline Interface: Add `--no-cbor-metadata` that skips CBOR metadata from getting appended at the end of the bytecode.
9+
* EVM: Basic support for the EVM version "Paris".
910
* Natspec: Add event Natspec inheritance for devdoc.
1011
* Standard JSON: Add a boolean field `settings.metadata.appendCBOR` that skips CBOR metadata from getting appended at the end of the bytecode.
1112
* Yul Optimizer: Allow replacing the previously hard-coded cleanup sequence by specifying custom steps after a colon delimiter (``:``) in the sequence string.

docs/using-the-compiler.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ at each version. Backward compatibility is not guaranteed between each version.
172172
the optimizer.
173173
- ``london`` (**default**)
174174
- 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.
175-
175+
- ``paris``
176+
- No changes, however the semantics of the ``difficulty`` value have changed (see `EIP-4399 <https://eips.ethereum.org/EIPS/eip-4399>`_).
176177

177178
.. index:: ! standard JSON, ! --standard-json
178179
.. _compiler-api:
@@ -305,7 +306,7 @@ Input Description
305306
},
306307
// Version of the EVM to compile for.
307308
// Affects type checking and code generation. Can be homestead,
308-
// tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul or berlin
309+
// tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, london or paris
309310
"evmVersion": "byzantium",
310311
// Optional: Change compilation pipeline to go through the Yul intermediate representation.
311312
// This is false by default.

docs/yul.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ the ``dup`` and ``swap`` instructions as well as ``jump`` instructions, labels a
933933
+-------------------------+-----+---+-----------------------------------------------------------------+
934934
| number() | | F | current block number |
935935
+-------------------------+-----+---+-----------------------------------------------------------------+
936-
| difficulty() | | F | difficulty of the current block |
936+
| difficulty() | | F | difficulty of the current block (see note below) |
937937
+-------------------------+-----+---+-----------------------------------------------------------------+
938938
| gaslimit() | | F | block gas limit of the current block |
939939
+-------------------------+-----+---+-----------------------------------------------------------------+
@@ -948,6 +948,13 @@ the ``dup`` and ``swap`` instructions as well as ``jump`` instructions, labels a
948948
You need to use the ``returndatasize`` opcode to check which part of this memory area contains the return data.
949949
The remaining bytes will retain their values as of before the call.
950950

951+
.. note::
952+
With the Paris network upgrade the semantics of ``difficulty`` have been changed.
953+
It returns the value of ``prevrandao``, which is a 256-bit value, whereas the highest recorded
954+
difficulty value within Ethash was ~54 bits.
955+
This change is described in `EIP-4399 <https://eips.ethereum.org/EIPS/eip-4399>`_.
956+
Please note that irrelevant to which EVM version is selected in the compiler, the semantics of
957+
instructions depend on the final chain of deployment.
951958

952959
In some internal dialects, there are additional functions:
953960

liblangutil/EVMVersion.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ class EVMVersion:
5656
static EVMVersion istanbul() { return {Version::Istanbul}; }
5757
static EVMVersion berlin() { return {Version::Berlin}; }
5858
static EVMVersion london() { return {Version::London}; }
59+
static EVMVersion paris() { return {Version::Paris}; }
5960

6061
static std::optional<EVMVersion> fromString(std::string const& _version)
6162
{
62-
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london()})
63+
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london(), paris()})
6364
if (_version == v.name())
6465
return v;
6566
return std::nullopt;
@@ -81,6 +82,7 @@ class EVMVersion:
8182
case Version::Istanbul: return "istanbul";
8283
case Version::Berlin: return "berlin";
8384
case Version::London: return "london";
85+
case Version::Paris: return "paris";
8486
}
8587
return "INVALID";
8688
}
@@ -102,7 +104,7 @@ class EVMVersion:
102104
bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); }
103105

104106
private:
105-
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London };
107+
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris };
106108

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

scripts/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ EVM_VERSIONS="homestead byzantium"
105105

106106
if [ -z "$CI" ]
107107
then
108-
EVM_VERSIONS+=" constantinople petersburg istanbul berlin london"
108+
EVM_VERSIONS+=" constantinople petersburg istanbul berlin london paris"
109109
fi
110110

111111
# And then run the Solidity unit-tests in the matrix combination of optimizer / no optimizer

solc/CommandLineParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ General Information)").c_str(),
586586
g_strEVMVersion.c_str(),
587587
po::value<string>()->value_name("version")->default_value(EVMVersion{}.name()),
588588
"Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, "
589-
"byzantium, constantinople, petersburg, istanbul, berlin or london."
589+
"byzantium, constantinople, petersburg, istanbul, berlin, london or paris."
590590
)
591591
(
592592
g_strExperimentalViaIR.c_str(),

test/EVMHost.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm):
122122
m_evmRevision = EVMC_BERLIN;
123123
else if (_evmVersion == langutil::EVMVersion::london())
124124
m_evmRevision = EVMC_LONDON;
125-
// TODO: support EVMVersion::paris()
125+
else if (_evmVersion == langutil::EVMVersion::paris())
126+
m_evmRevision = EVMC_PARIS;
126127
else
127128
assertThrow(false, Exception, "Unsupported EVM version");
128129

test/libsolidity/StandardCompiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,8 @@ BOOST_AUTO_TEST_CASE(evm_version)
10821082
BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"berlin\"") != string::npos);
10831083
result = compile(inputForVersion("\"evmVersion\": \"london\","));
10841084
BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"london\"") != string::npos);
1085+
result = compile(inputForVersion("\"evmVersion\": \"paris\","));
1086+
BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"paris\"") != string::npos);
10851087
// test default
10861088
result = compile(inputForVersion(""));
10871089
BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"london\"") != string::npos);

test/libsolidity/semanticTests/state/block_difficulty.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ contract C {
55
}
66
// ====
77
// compileToEwasm: also
8+
// EVMVersion: <paris
89
// ----
910
// f() -> 200000000
1011
// f() -> 200000000

0 commit comments

Comments
 (0)