Adds support for the EVM version "Paris".

Deprecates `block.difficulty` and disallow `difficulty()` in inline assembly for EVM versions >= paris.
The change is due to the renaming introduced by EIP-4399 (see: https://eips.ethereum.org/EIPS/eip-4399).
Introduces `block.prevrandao` in Solidity and `prevrandao()` in inline assembly for EVM versions >= paris.

Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
Co-authored-by: Daniel <daniel@ekpyron.org>
Co-authored-by: matheusaaguiar <95899911+matheusaaguiar@users.noreply.github.com>
Co-authored-by: Nikola Matić <nikola.matic@ethereum.org>
This commit is contained in:
Rodrigo Q. Saramago
2023-01-23 18:50:36 +00:00
co-authored by Alex Beregszaszi Daniel matheusaaguiar Nikola Matić
parent d70d79af4a
commit ef6ff2f055
114 changed files with 842 additions and 221 deletions
@@ -0,0 +1 @@
--no-cbor-metadata --via-ir --optimize --opcodes --asm --debug-info none --evm-version paris
@@ -0,0 +1,5 @@
Warning: Since the VM version paris, "difficulty" was replaced by "prevrandao", which now returns a random number based on the beacon chain.
--> evmasm_difficulty_post_paris/input.sol:6:21:
|
6 | uint256 x = block.difficulty;
| ^^^^^^^^^^^^^^^^
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0.0;
contract C {
constructor() payable {
uint256 x = block.difficulty;
assembly {
sstore(0, x)
stop()
}
}
fallback() external payable {
assembly {
stop()
}
}
}
@@ -0,0 +1,13 @@
======= evmasm_difficulty_post_paris/input.sol:C =======
EVM assembly:
sstore(0x00, prevrandao)
stop
stop
sub_0: assembly {
stop
}
Opcodes:
PREVRANDAO PUSH1 0x0 SSTORE STOP INVALID
@@ -0,0 +1 @@
--no-cbor-metadata --via-ir --optimize --opcodes --asm --debug-info none --evm-version london
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0.0;
contract C {
constructor() payable {
uint256 x = block.difficulty;
assembly {
sstore(0, x)
stop()
}
}
fallback() external payable {
assembly {
stop()
}
}
}
@@ -0,0 +1,13 @@
======= evmasm_difficulty_pre_paris/input.sol:C =======
EVM assembly:
sstore(0x00, difficulty)
stop
stop
sub_0: assembly {
stop
}
Opcodes:
DIFFICULTY PUSH1 0x0 SSTORE STOP INVALID
@@ -0,0 +1 @@
--no-cbor-metadata --via-ir --optimize --opcodes --asm --debug-info none --evm-version paris
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0.0;
contract C {
constructor() payable {
uint256 x = block.prevrandao;
assembly {
sstore(0, x)
stop()
}
}
fallback() external payable {
assembly {
stop()
}
}
}
@@ -0,0 +1,13 @@
======= evmasm_prevrandao_post_paris/input.sol:C =======
EVM assembly:
sstore(0x00, prevrandao)
stop
stop
sub_0: assembly {
stop
}
Opcodes:
PREVRANDAO PUSH1 0x0 SSTORE STOP INVALID
@@ -0,0 +1 @@
--no-cbor-metadata --via-ir --optimize --opcodes --asm --debug-info none --evm-version london
@@ -0,0 +1,5 @@
Warning: "prevrandao" is not supported by the VM version and will be treated as "difficulty".
--> evmasm_prevrandao_pre_paris/input.sol:6:21:
|
6 | uint256 x = block.prevrandao;
| ^^^^^^^^^^^^^^^^
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0.0;
contract C {
constructor() payable {
uint256 x = block.prevrandao;
assembly {
sstore(0, x)
stop()
}
}
fallback() external payable {
assembly {
stop()
}
}
}
@@ -0,0 +1,13 @@
======= evmasm_prevrandao_pre_paris/input.sol:C =======
EVM assembly:
sstore(0x00, difficulty)
stop
stop
sub_0: assembly {
stop
}
Opcodes:
DIFFICULTY PUSH1 0x0 SSTORE STOP INVALID