Tests and Changelog for basefee.

This commit is contained in:
hrkrshnn 2021-07-12 16:51:56 +02:00
parent cb9b52c242
commit 43605d9299
6 changed files with 62 additions and 1 deletions

View File

@ -1,6 +1,8 @@
### 0.8.7 (unreleased)
Language Features:
* Introduce global ``block.basefee`` for retrieving the base fee of the current block.
* Yul: Introduce builtin ``basefee()`` for retrieving the base fee of the current block.
Compiler Features:

View File

@ -0,0 +1,18 @@
contract C {
function f() public view returns (uint) {
return block.basefee;
}
function g() public view returns (uint ret) {
assembly {
ret := basefee()
}
}
}
// ====
// EVMVersion: >=london
// compileViaYul: also
// ----
// f() -> 7
// g() -> 7
// f() -> 7
// g() -> 7

View File

@ -0,0 +1,15 @@
contract C {
function f() public view returns (uint) {
return block.basefee;
}
function g() public view returns (uint ret) {
assembly {
ret := basefee()
}
}
}
// ====
// EVMVersion: =berlin
// ----
// TypeError 5921: (74-87): "basefee" is not supported by the VM version.
// TypeError 5430: (183-190): The "basefee" instruction is only available for London-compatible VMs (you are currently compiling for "berlin").

View File

@ -0,0 +1,13 @@
contract C {
function f() public view returns (uint) {
return block.basefee;
}
function g() public view returns (uint ret) {
assembly {
ret := basefee()
}
}
}
// ====
// EVMVersion: >=london
// ----

View File

@ -0,0 +1,13 @@
contract C {
function f() public pure {
assembly { pop(basefee()) }
}
function g() public pure returns (uint) {
return block.basefee;
}
}
// ====
// EVMVersion: >=london
// ----
// TypeError 2527: (67-76): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
// TypeError 2527: (147-160): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".

View File

@ -13,5 +13,5 @@ object "a" {
// stop
// data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421
// Bytecode: 6006600055fe48656c6c6f2c20576f726c6421
// Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID 0x48 PUSH6 0x6C6C6F2C2057 PUSH16 0x726C6421000000000000000000000000
// Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID BASEFEE PUSH6 0x6C6C6F2C2057 PUSH16 0x726C6421000000000000000000000000
// SourceMappings: 32:19:0:-:0;29:1;22:30