Skip to content

Commit 43605d9

Browse files
committed
Tests and Changelog for basefee.
1 parent cb9b52c commit 43605d9

File tree

6 files changed

+62
-1
lines changed

6 files changed

+62
-1
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
### 0.8.7 (unreleased)
22

33
Language Features:
4+
* Introduce global ``block.basefee`` for retrieving the base fee of the current block.
5+
* Yul: Introduce builtin ``basefee()`` for retrieving the base fee of the current block.
46

57

68
Compiler Features:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
contract C {
2+
function f() public view returns (uint) {
3+
return block.basefee;
4+
}
5+
function g() public view returns (uint ret) {
6+
assembly {
7+
ret := basefee()
8+
}
9+
}
10+
}
11+
// ====
12+
// EVMVersion: >=london
13+
// compileViaYul: also
14+
// ----
15+
// f() -> 7
16+
// g() -> 7
17+
// f() -> 7
18+
// g() -> 7
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
contract C {
2+
function f() public view returns (uint) {
3+
return block.basefee;
4+
}
5+
function g() public view returns (uint ret) {
6+
assembly {
7+
ret := basefee()
8+
}
9+
}
10+
}
11+
// ====
12+
// EVMVersion: =berlin
13+
// ----
14+
// TypeError 5921: (74-87): "basefee" is not supported by the VM version.
15+
// TypeError 5430: (183-190): The "basefee" instruction is only available for London-compatible VMs (you are currently compiling for "berlin").
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
contract C {
2+
function f() public view returns (uint) {
3+
return block.basefee;
4+
}
5+
function g() public view returns (uint ret) {
6+
assembly {
7+
ret := basefee()
8+
}
9+
}
10+
}
11+
// ====
12+
// EVMVersion: >=london
13+
// ----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
contract C {
2+
function f() public pure {
3+
assembly { pop(basefee()) }
4+
}
5+
function g() public pure returns (uint) {
6+
return block.basefee;
7+
}
8+
}
9+
// ====
10+
// EVMVersion: >=london
11+
// ----
12+
// TypeError 2527: (67-76): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
13+
// TypeError 2527: (147-160): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".

test/libyul/objectCompiler/dataoffset_data.yul

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ object "a" {
1313
// stop
1414
// data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421
1515
// Bytecode: 6006600055fe48656c6c6f2c20576f726c6421
16-
// Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID 0x48 PUSH6 0x6C6C6F2C2057 PUSH16 0x726C6421000000000000000000000000
16+
// Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID BASEFEE PUSH6 0x6C6C6F2C2057 PUSH16 0x726C6421000000000000000000000000
1717
// SourceMappings: 32:19:0:-:0;29:1;22:30

0 commit comments

Comments
 (0)