From c353eb0af53b46f28a2ea116a0d8240986c4d4d9 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 11 Nov 2022 12:15:35 +0100 Subject: [PATCH] Document difficulty vs. prevrandao --- docs/using-the-compiler.rst | 2 +- docs/yul.rst | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 89cce88a6..e5b5f00ec 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -173,7 +173,7 @@ at each version. Backward compatibility is not guaranteed between each version. - ``london`` (**default**) - The block's base fee (`EIP-3198 `_ and `EIP-1559 `_) can be accessed via the global ``block.basefee`` or ``basefee()`` in inline assembly. - ``paris`` - - No changes. + - No changes, however the semantics of the ``difficulty`` value have changed (see `EIP-4399 `_). .. index:: ! standard JSON, ! --standard-json .. _compiler-api: diff --git a/docs/yul.rst b/docs/yul.rst index c8068de98..861f5d532 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -933,7 +933,7 @@ the ``dup`` and ``swap`` instructions as well as ``jump`` instructions, labels a +-------------------------+-----+---+-----------------------------------------------------------------+ | number() | | F | current block number | +-------------------------+-----+---+-----------------------------------------------------------------+ -| difficulty() | | F | difficulty of the current block | +| difficulty() | | F | difficulty of the current block (see note below) | +-------------------------+-----+---+-----------------------------------------------------------------+ | gaslimit() | | F | block gas limit of the current block | +-------------------------+-----+---+-----------------------------------------------------------------+ @@ -948,6 +948,13 @@ the ``dup`` and ``swap`` instructions as well as ``jump`` instructions, labels a You need to use the ``returndatasize`` opcode to check which part of this memory area contains the return data. The remaining bytes will retain their values as of before the call. +.. note:: + With the Paris network upgrade the semantics of ``difficulty`` have been changed. + It returns the value of ``prevrandao``, which is a 256-bit value, whereas the highest recorded + difficulty value within Ethash was ~54 bits. + This change is described in `EIP-4399 `_. + Please note that irrelevant to which EVM version is selected in the compiler, the semantics of + instructions depend on the final chain of deployment. In some internal dialects, there are additional functions: