EIP-7516 Blob base fee query opcode (BLOBBASEFEE instruction)

Final · EVM & execution · EIP status Final · created 2023-09-11

Adds the EVM opcode BLOBBASEFEE (0x4a), which lets smart contracts directly read the blob base fee of the current block.

Why it is needed

Ethereum introduced a separate data space called blobs with EIP-4844. It is a space where services such as rollups post large amounts of data cheaply, and its price, the blob base fee, is set separately from regular transaction fees. However, smart contracts had no way to read this price directly on chain. As a result, it was hard for rollup contracts to settle the cost of blob data usage trustlessly, and hard to build products such as blob gas futures that smooth out blob price fluctuations. The base fee of regular transactions can already be read with the BASEFEE opcode (EIP-3198). This EIP fills that gap by adding to the EVM an opcode that reads the blob base fee in exactly the same way.

What changes

Today

After EIP-7516

Who is affected

In depth

Opcode specification: opcode 0x4a, inputs 0, outputs 1, gas 2

Adds the BLOBBASEFEE opcode at opcode 0x4a. It takes 0 inputs from the stack, pushes 1 output onto the stack, and costs 2 gas. Its structure is identical to the BASEFEE opcode of EIP-3198, except that it returns the blob base fee defined by EIP-4844 instead of the regular base fee. The returned value is the blob base fee of the current block in which the opcode is executing.

The return value is get_blob_gasprice(header) from EIP-4844

The value BLOBBASEFEE pushes onto the stack is the result of applying the function get_blob_gasprice(header) -> int, defined in the Gas accounting section of EIP-4844, to the current block header. It does not introduce a new calculation rule and reuses the blob gas price function that EIP-4844 already defines, so the price used to process blob transactions and the price contracts read are always the same. The Motivation section of the original text cites use cases built on this value, such as rollup contracts settling blob data costs trustlessly and implementing blob gas futures.

Rationale for the gas cost of 2

The blob base fee is a value needed to process blob transactions, so it is already available before any EVM code is executed. This opcode merely exposes the value in the header and creates no additional complexity or separate read or write operations. For that reason the gas cost was set to 2, which is also the same as the cost of the BASEFEE opcode in EIP-3198, an opcode of the same nature.

Test cases

The representative case is as follows. If applying get_blob_gasprice(header) to the current block header yields 7 wei, BLOBBASEFEE must push 7 onto the stack as a 32-byte value left-padded with zeros. Executing the bytecode 0x4a00 (BLOBBASEFEE, STOP) produces output 0x and consumes 2 gas. The full test suite is in tests/cancun/eip7516_blobgasfee/test_blobgasfee_opcode.py in the ethereum/execution-spec-tests repository.

Compatibility, security, and status

No backward compatibility issues are known from this opcode. On the security side as well, the blob base fee is not sensitive information and is a value publicly available in the block header, so there are no known security implications. The status of this EIP is Final, meaning the specification is settled, and the test suite is in the cancun directory of execution-spec-tests. It lists EIP-3198 and EIP-4844 as prerequisites (requires).

Original EIP · ← EIPs