mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
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:
co-authored by
Alex Beregszaszi
Daniel
matheusaaguiar
Nikola Matić
parent
d70d79af4a
commit
ef6ff2f055
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function f() public view returns (uint256) {
|
||||
return block.difficulty;
|
||||
}
|
||||
|
||||
function g() public view returns (uint256 ret) {
|
||||
assembly {
|
||||
ret := difficulty()
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: <paris
|
||||
// ----
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f() public view returns (uint256 ret) {
|
||||
assembly {
|
||||
let difficulty := sload(0)
|
||||
ret := difficulty
|
||||
}
|
||||
}
|
||||
|
||||
function g() public pure returns (uint256 ret) {
|
||||
assembly {
|
||||
function difficulty() -> r {
|
||||
r := 1000
|
||||
}
|
||||
ret := difficulty()
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: <paris
|
||||
// ----
|
||||
// ParserError 5568: (101-111): Cannot use builtin function name "difficulty" as identifier name.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() public view returns (uint256) {
|
||||
return block.difficulty;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=paris
|
||||
// ----
|
||||
// Warning 8417: (77-93): Since the VM version paris, "difficulty" was replaced by "prevrandao", which now returns a random number based on the beacon chain.
|
||||
@@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
assembly {
|
||||
pop(difficulty())
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=paris
|
||||
// ----
|
||||
// DeclarationError 4619: (74-84): Function "difficulty" not found.
|
||||
// TypeError 3950: (74-86): Expected expression to evaluate to one value, but got 0 values instead.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
function f() public view returns (uint256 ret) {
|
||||
assembly {
|
||||
let difficulty := sload(0)
|
||||
ret := difficulty
|
||||
}
|
||||
}
|
||||
|
||||
function g() public pure returns (uint256 ret) {
|
||||
assembly {
|
||||
function difficulty() -> r {
|
||||
r := 1000
|
||||
}
|
||||
ret := difficulty()
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=paris
|
||||
// ----
|
||||
// DeclarationError 5017: (101-111): The identifier "difficulty" is reserved and can not be used.
|
||||
// DeclarationError 5017: (255-323): The identifier "difficulty" is reserved and can not be used.
|
||||
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function f() public view returns (uint256 ret) {
|
||||
assembly {
|
||||
let prevrandao := sload(0)
|
||||
ret := prevrandao
|
||||
}
|
||||
}
|
||||
|
||||
function g() public pure returns (uint256 ret) {
|
||||
assembly {
|
||||
function prevrandao() -> r {
|
||||
r := 1000
|
||||
}
|
||||
ret := prevrandao()
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: <paris
|
||||
// ----
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function f() public view returns (uint256) {
|
||||
return block.prevrandao;
|
||||
}
|
||||
|
||||
function g() public view returns (uint256 ret) {
|
||||
assembly {
|
||||
ret := prevrandao()
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=paris
|
||||
// ----
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f() public view returns (uint256 ret) {
|
||||
assembly {
|
||||
let prevrandao := sload(0)
|
||||
ret := prevrandao
|
||||
}
|
||||
}
|
||||
|
||||
function g() public pure returns (uint256 ret) {
|
||||
assembly {
|
||||
function prevrandao() -> r {
|
||||
r := 1000
|
||||
}
|
||||
ret := prevrandao()
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=paris
|
||||
// ----
|
||||
// ParserError 5568: (101-111): Cannot use builtin function name "prevrandao" as identifier name.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() public view returns (uint256) {
|
||||
return block.prevrandao;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: <paris
|
||||
// ----
|
||||
// Warning 9432: (77-93): "prevrandao" is not supported by the VM version and will be treated as "difficulty".
|
||||
@@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
assembly {
|
||||
pop(prevrandao())
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: <paris
|
||||
// ----
|
||||
// DeclarationError 4619: (74-84): Function "prevrandao" not found.
|
||||
// TypeError 3950: (74-86): Expected expression to evaluate to one value, but got 0 values instead.
|
||||
Reference in New Issue
Block a user