From c760bd88e15a48378ad5b66502b9580ac1c0e65f Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Wed, 10 Jan 2024 11:25:08 +0100 Subject: [PATCH] Review comments --- docs/using-the-compiler.rst | 2 ++ test/EVMHost.cpp | 3 ++- .../inlineAssembly/blobbasefee_shanghai_function.sol | 4 ++-- .../semanticTests/state/block_blobbasefee.sol | 8 ++++---- .../inlineAssembly/blobbasefee_reserved_cancun.sol | 2 +- .../types/magic_block_blobbasefee_error.sol | 2 +- test/libyul/yulInterpreterTests/blobbasefee.yul | 10 ++++++++++ .../blobbasefee_identifier_pre_cancun.sol | 6 ++++++ .../blobbasefee_reserved_identifier_post_cancun.sol | 7 +++++++ test/tools/yulInterpreter/Interpreter.h | 3 ++- 10 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 test/libyul/yulInterpreterTests/blobbasefee.yul create mode 100644 test/libyul/yulSyntaxTests/blobbasefee_identifier_pre_cancun.sol create mode 100644 test/libyul/yulSyntaxTests/blobbasefee_reserved_identifier_post_cancun.sol diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 0adcbf4132bb..60fbd0884a89 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -176,6 +176,8 @@ at each version. Backward compatibility is not guaranteed between each version. - Introduces ``prevrandao()`` and ``block.prevrandao``, and changes the semantics of the now deprecated ``block.difficulty``, disallowing ``difficulty()`` in inline assembly (see `EIP-4399 `_). - ``shanghai`` (**default**) - Smaller code size and gas savings due to the introduction of ``push0`` (see `EIP-3855 `_). +- ``cancun`` + - The block's blob base fee (`EIP-7516 `_ and `EIP-4844 `_) can be accessed via the global ``block.blobbasefee`` or ``blobbasefee()`` in inline assembly. .. index:: ! standard JSON, ! --standard-json .. _compiler-api: diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index e511bd201736..813d28fdbf78 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -136,7 +136,8 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm): tx_context.chain_id = evmc::uint256be{1}; // The minimum value of basefee tx_context.block_base_fee = evmc::bytes32{7}; - tx_context.blob_base_fee = evmc::bytes32{7}; + // The minimum value of blobbasefee + tx_context.blob_base_fee = evmc::bytes32{1}; // Reserve space for recording calls. if (!recorded_calls.capacity()) diff --git a/test/libsolidity/semanticTests/inlineAssembly/blobbasefee_shanghai_function.sol b/test/libsolidity/semanticTests/inlineAssembly/blobbasefee_shanghai_function.sol index 389e37daf70f..d06457133e36 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/blobbasefee_shanghai_function.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/blobbasefee_shanghai_function.sol @@ -1,7 +1,7 @@ contract C { function f() public view returns (uint ret) { assembly { - let blobbasefee := sload(0) + let blobbasefee := 999 ret := blobbasefee } } @@ -17,5 +17,5 @@ contract C { // ==== // EVMVersion: <=shanghai // ---- -// f() -> 0 +// f() -> 999 // g() -> 1000 diff --git a/test/libsolidity/semanticTests/state/block_blobbasefee.sol b/test/libsolidity/semanticTests/state/block_blobbasefee.sol index 5c06439a67ee..23da779e40f2 100644 --- a/test/libsolidity/semanticTests/state/block_blobbasefee.sol +++ b/test/libsolidity/semanticTests/state/block_blobbasefee.sol @@ -11,7 +11,7 @@ contract C { // ==== // EVMVersion: >=cancun // ---- -// f() -> 7 -// g() -> 7 -// f() -> 7 -// g() -> 7 +// f() -> 1 +// g() -> 1 +// f() -> 1 +// g() -> 1 diff --git a/test/libsolidity/syntaxTests/inlineAssembly/blobbasefee_reserved_cancun.sol b/test/libsolidity/syntaxTests/inlineAssembly/blobbasefee_reserved_cancun.sol index 812c848ef619..0bab7e36c74e 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/blobbasefee_reserved_cancun.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/blobbasefee_reserved_cancun.sol @@ -7,6 +7,6 @@ contract C { } } // ==== -// EVMVersion: =cancun +// EVMVersion: >=cancun // ---- // ParserError 5568: (98-109): Cannot use builtin function name "blobbasefee" as identifier name. diff --git a/test/libsolidity/syntaxTests/types/magic_block_blobbasefee_error.sol b/test/libsolidity/syntaxTests/types/magic_block_blobbasefee_error.sol index d75d1115b4d1..11a5bd991ae4 100644 --- a/test/libsolidity/syntaxTests/types/magic_block_blobbasefee_error.sol +++ b/test/libsolidity/syntaxTests/types/magic_block_blobbasefee_error.sol @@ -9,7 +9,7 @@ contract C { } } // ==== -// EVMVersion: <=shanghai +// EVMVersion: =shanghai // ---- // TypeError 1006: (74-91): "blobbasefee" is not supported by the VM version. // DeclarationError 4619: (187-198): Function "blobbasefee" not found. diff --git a/test/libyul/yulInterpreterTests/blobbasefee.yul b/test/libyul/yulInterpreterTests/blobbasefee.yul new file mode 100644 index 000000000000..d863b1d8265f --- /dev/null +++ b/test/libyul/yulInterpreterTests/blobbasefee.yul @@ -0,0 +1,10 @@ +{ + sstore(0, blobbasefee()) +} +// ==== +// EVMVersion: >=cancun +// ---- +// Trace: +// Memory dump: +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000001 diff --git a/test/libyul/yulSyntaxTests/blobbasefee_identifier_pre_cancun.sol b/test/libyul/yulSyntaxTests/blobbasefee_identifier_pre_cancun.sol new file mode 100644 index 000000000000..42c1f2c0a680 --- /dev/null +++ b/test/libyul/yulSyntaxTests/blobbasefee_identifier_pre_cancun.sol @@ -0,0 +1,6 @@ +{ + function blobbasefee() {} +} +// ==== +// EVMVersion: <=shanghai +// ---- diff --git a/test/libyul/yulSyntaxTests/blobbasefee_reserved_identifier_post_cancun.sol b/test/libyul/yulSyntaxTests/blobbasefee_reserved_identifier_post_cancun.sol new file mode 100644 index 000000000000..61fa7d7e427a --- /dev/null +++ b/test/libyul/yulSyntaxTests/blobbasefee_reserved_identifier_post_cancun.sol @@ -0,0 +1,7 @@ +{ + function blobbasefee() {} +} +// ==== +// EVMVersion: >=cancun +// ---- +// ParserError 5568: (15-26): Cannot use builtin function name "blobbasefee" as identifier name. diff --git a/test/tools/yulInterpreter/Interpreter.h b/test/tools/yulInterpreter/Interpreter.h index 783c501e2594..66082b5b30f6 100644 --- a/test/tools/yulInterpreter/Interpreter.h +++ b/test/tools/yulInterpreter/Interpreter.h @@ -99,7 +99,8 @@ struct InterpreterState u256 chainid = 0x01; /// The minimum value of basefee: 7 wei. u256 basefee = 0x07; - u256 blobbasefee = 0x07; + /// The minimum value of blobbasefee: 1 wei. + u256 blobbasefee = 0x01; /// Log of changes / effects. Sholud be structured data in the future. std::vector trace; /// This is actually an input parameter that more or less limits the runtime.