Skip to content

Commit 58e82a0

Browse files
authored
Update EIP-4844: Rename "data gas" to "blob gas"
Merged by EIP-Bot.
1 parent 3cf49e6 commit 58e82a0

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

EIPS/eip-4844.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ Compared to full data sharding, this EIP has a reduced cap on the number of thes
4545
| `BLOB_COMMITMENT_VERSION_KZG` | `Bytes1(0x01)` |
4646
| `POINT_EVALUATION_PRECOMPILE_ADDRESS` | `Bytes20(0x0A)` |
4747
| `POINT_EVALUATION_PRECOMPILE_GAS` | `50000` |
48-
| `MAX_DATA_GAS_PER_BLOCK` | `786432` |
49-
| `TARGET_DATA_GAS_PER_BLOCK` | `393216` |
50-
| `MIN_DATA_GASPRICE` | `1` |
51-
| `DATA_GASPRICE_UPDATE_FRACTION` | `3338477` |
48+
| `MAX_BLOB_GAS_PER_BLOCK` | `786432` |
49+
| `TARGET_BLOB_GAS_PER_BLOCK` | `393216` |
50+
| `MIN_BLOB_GASPRICE` | `1` |
51+
| `BLOB_GASPRICE_UPDATE_FRACTION` | `3338477` |
5252
| `MAX_VERSIONED_HASHES_LIST_SIZE` | `2**24` |
5353
| `MAX_CALLDATA_SIZE` | `2**24` |
5454
| `MAX_ACCESS_LIST_SIZE` | `2**24` |
5555
| `MAX_ACCESS_LIST_STORAGE_KEYS` | `2**24` |
5656
| `MAX_TX_WRAP_COMMITMENTS` | `2**12` |
5757
| `LIMIT_BLOBS_PER_TX` | `2**12` |
58-
| `DATA_GAS_PER_BLOB` | `2**17` |
58+
| `GAS_PER_BLOB` | `2**17` |
5959
| `HASH_OPCODE_BYTE` | `Bytes1(0x49)` |
6060
| `HASH_OPCODE_GAS` | `3` |
6161

@@ -104,29 +104,29 @@ def fake_exponential(factor: int, numerator: int, denominator: int) -> int:
104104
We introduce a new [EIP-2718](./eip-2718.md) transaction, "blob transaction", where the `TransactionType` is `BLOB_TX_TYPE` and the `TransactionPayload` is the RLP serialization of the following `TransactionPayloadBody`:
105105

106106
```
107-
[chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data, access_list, max_fee_per_data_gas, blob_versioned_hashes, y_parity, r, s]
107+
[chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data, access_list, max_fee_per_blob_gas, blob_versioned_hashes, y_parity, r, s]
108108
```
109109

110110
The fields `chain_id`, `nonce`, `max_priority_fee_per_gas`, `max_fee_per_gas`, `gas_limit`, `value`, `data`, and `access_list` follow the same semantics as [EIP-1559](./eip-1559.md).
111111

112112
The field `to` deviates slightly from the semantics with the exception that it MUST NOT be `nil` and therefore must always represent a 20-byte address. This means that blob transactions cannot have the form of a create transaction.
113113

114-
The field `max_fee_per_data_gas` is a `uint256` and the field `blob_versioned_hashes` represents a list of hash outputs from `kzg_to_versioned_hash`.
114+
The field `max_fee_per_blob_gas` is a `uint256` and the field `blob_versioned_hashes` represents a list of hash outputs from `kzg_to_versioned_hash`.
115115

116116
The [EIP-2718](./eip-2718.md) `ReceiptPayload` for this transaction is `rlp([status, cumulative_transaction_gas_used, logs_bloom, logs])`.
117117

118118
#### Signature
119119

120120
The signature values `y_parity`, `r`, and `s` are calculated by constructing a secp256k1 signature over the following digest:
121121

122-
`keccak256(BLOB_TX_TYPE || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data, access_list, max_fee_per_data_gas, blob_versioned_hashes]))`.
122+
`keccak256(BLOB_TX_TYPE || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data, access_list, max_fee_per_blob_gas, blob_versioned_hashes]))`.
123123

124124
### Header extension
125125

126126
The current header encoding is extended with two new 64-bit unsigned integer fields:
127127

128-
- `data_gas_used` is the total amount of data gas consumed by the transactions within the block.
129-
- `excess_data_gas` is a running total of data gas consumed in excess of the target, prior to the block. Blocks with above-target data gas consumption increase this value, blocks with below-target data gas consumption decrease it (bounded at 0).
128+
- `blob_gas_used` is the total amount of blob gas consumed by the transactions within the block.
129+
- `excess_blob_gas` is a running total of blob gas consumed in excess of the target, prior to the block. Blocks with above-target blob gas consumption increase this value, blocks with below-target blob gas consumption decrease it (bounded at 0).
130130

131131
The resulting RLP encoding of the header is therefore:
132132

@@ -149,44 +149,44 @@ rlp([
149149
0x0000000000000000, # nonce
150150
base_fee_per_gas,
151151
withdrawals_root,
152-
data_gas_used,
153-
excess_data_gas,
152+
blob_gas_used,
153+
excess_blob_gas,
154154
])
155155
```
156156

157-
The value of `excess_data_gas` can be calculated using the parent header.
157+
The value of `excess_blob_gas` can be calculated using the parent header.
158158

159159
```python
160-
def calc_excess_data_gas(parent: Header) -> int:
161-
if parent.excess_data_gas + parent.data_gas_used < TARGET_DATA_GAS_PER_BLOCK:
160+
def calc_excess_blob_gas(parent: Header) -> int:
161+
if parent.excess_blob_gas + parent.blob_gas_used < TARGET_BLOB_GAS_PER_BLOCK:
162162
return 0
163163
else:
164-
return parent.excess_data_gas + parent.data_gas_used - TARGET_DATA_GAS_PER_BLOCK
164+
return parent.excess_blob_gas + parent.blob_gas_used - TARGET_BLOB_GAS_PER_BLOCK
165165
```
166166

167-
For the first post-fork block, both `parent.data_gas_used` and `parent.excess_data_gas` are evaluated as `0`.
167+
For the first post-fork block, both `parent.blob_gas_used` and `parent.excess_blob_gas` are evaluated as `0`.
168168

169169
### Gas accounting
170170

171-
We introduce data gas as a new type of gas. It is independent of normal gas and follows its own targeting rule, similar to EIP-1559.
172-
We use the `excess_data_gas` header field to store persistent data needed to compute the data gas price. For now, only blobs are priced in data gas.
171+
We introduce blob gas as a new type of gas. It is independent of normal gas and follows its own targeting rule, similar to EIP-1559.
172+
We use the `excess_blob_gas` header field to store persistent data needed to compute the blob gas price. For now, only blobs are priced in blob gas.
173173

174174
```python
175175
def calc_data_fee(header: Header, tx: SignedBlobTransaction) -> int:
176-
return get_total_data_gas(tx) * get_data_gasprice(header)
176+
return get_total_blob_gas(tx) * get_blob_gasprice(header)
177177

178-
def get_total_data_gas(tx: SignedBlobTransaction) -> int:
179-
return DATA_GAS_PER_BLOB * len(tx.blob_versioned_hashes)
178+
def get_total_blob_gas(tx: SignedBlobTransaction) -> int:
179+
return GAS_PER_BLOB * len(tx.blob_versioned_hashes)
180180

181-
def get_data_gasprice(header: Header) -> int:
181+
def get_blob_gasprice(header: Header) -> int:
182182
return fake_exponential(
183-
MIN_DATA_GASPRICE,
184-
header.excess_data_gas,
185-
DATA_GASPRICE_UPDATE_FRACTION
183+
MIN_BLOB_GASPRICE,
184+
header.excess_blob_gas,
185+
BLOB_GASPRICE_UPDATE_FRACTION
186186
)
187187
```
188188

189-
The block validity conditions are modified to include data gas checks (see the [Execution layer validation](#execution-layer-validation) section below).
189+
The block validity conditions are modified to include blob gas checks (see the [Execution layer validation](#execution-layer-validation) section below).
190190

191191
The actual `data_fee` as calculated via `calc_data_fee` is deducted from the sender balance before transaction execution and burned, and is not refunded in case of transaction failure.
192192

@@ -254,18 +254,18 @@ On the execution layer, the block validity conditions are extended as follows:
254254
def validate_block(block: Block) -> None:
255255
...
256256

257-
# check that the excess data gas was updated correctly
258-
assert block.header.excess_data_gas == calc_excess_data_gas(block.parent.header)
257+
# check that the excess blob gas was updated correctly
258+
assert block.header.excess_blob_gas == calc_excess_blob_gas(block.parent.header)
259259

260-
data_gas_used = 0
260+
blob_gas_used = 0
261261

262262
for tx in block.transactions:
263263
...
264264

265265
# modify the check for sufficient balance
266266
max_total_fee = tx.gas * tx.max_fee_per_gas
267267
if type(tx) is SignedBlobTransaction:
268-
max_total_fee += get_total_data_gas(tx) * tx.max_fee_per_data_gas
268+
max_total_fee += get_total_blob_gas(tx) * tx.max_fee_per_blob_gas
269269
assert signer(tx).balance >= max_total_fee
270270

271271
...
@@ -279,17 +279,17 @@ def validate_block(block: Block) -> None:
279279
for h in tx.blob_versioned_hashes:
280280
assert h[0] == BLOB_COMMITMENT_VERSION_KZG
281281

282-
# ensure that the user was willing to at least pay the current data gasprice
283-
assert tx.max_fee_per_data_gas >= get_data_gasprice(block.header)
282+
# ensure that the user was willing to at least pay the current blob gasprice
283+
assert tx.max_fee_per_blob_gas >= get_blob_gasprice(block.header)
284284

285-
# keep track of total data gas spent in the block
286-
data_gas_used += get_total_data_gas(tx)
285+
# keep track of total blob gas spent in the block
286+
blob_gas_used += get_total_blob_gas(tx)
287287

288-
# ensure the total data gas spent is at most equal to the limit
289-
assert data_gas_used <= MAX_DATA_GAS_PER_BLOCK
288+
# ensure the total blob gas spent is at most equal to the limit
289+
assert blob_gas_used <= MAX_BLOB_GAS_PER_BLOCK
290290

291-
# ensure data_gas_used matches header
292-
assert block.header.data_gas_used == data_gas_used
291+
# ensure blob_gas_used matches header
292+
assert block.header.blob_gas_used == blob_gas_used
293293

294294
```
295295

@@ -387,22 +387,22 @@ However, the point evaluation happens inside a finite field, and it is only well
387387

388388
In the interest of not adding another precompile, we return the modulus and the polynomial degree directly from the point evaluation precompile. It can then be used by the caller. It is also "free" in that the caller can just ignore this part of the return value without incurring an extra cost -- systems that remain upgradable for the foreseeable future will likely use this route for now.
389389

390-
### Data gasprice update rule
390+
### Blob gasprice update rule
391391

392-
The data gasprice update rule is intended to approximate the formula `data_gasprice = MIN_DATA_GASPRICE * e**(excess_data_gas / DATA_GASPRICE_UPDATE_FRACTION)`,
393-
where `excess_data_gas` is the total "extra" amount of data gas that the chain has consumed relative to the "targeted" number (`TARGET_DATA_GAS_PER_BLOCK` per block).
394-
Like EIP-1559, it's a self-correcting formula: as the excess goes higher, the `data_gasprice` increases exponentially, reducing usage and eventually forcing the excess back down.
392+
The blob gasprice update rule is intended to approximate the formula `blob_gasprice = MIN_BLOB_GASPRICE * e**(excess_blob_gas / BLOB_GASPRICE_UPDATE_FRACTION)`,
393+
where `excess_blob_gas` is the total "extra" amount of blob gas that the chain has consumed relative to the "targeted" number (`TARGET_BLOB_GAS_PER_BLOCK` per block).
394+
Like EIP-1559, it's a self-correcting formula: as the excess goes higher, the `blob_gasprice` increases exponentially, reducing usage and eventually forcing the excess back down.
395395

396396
The block-by-block behavior is roughly as follows.
397-
If block `N` consumes `X` data gas, then in block `N+1` `excess_data_gas` increases by `X - TARGET_DATA_GAS_PER_BLOCK`,
398-
and so the `data_gasprice` of block `N+1` increases by a factor of `e**((X - TARGET_DATA_GAS_PER_BLOCK) / DATA_GASPRICE_UPDATE_FRACTION)`.
397+
If block `N` consumes `X` blob gas, then in block `N+1` `excess_blob_gas` increases by `X - TARGET_BLOB_GAS_PER_BLOCK`,
398+
and so the `blob_gasprice` of block `N+1` increases by a factor of `e**((X - TARGET_BLOB_GAS_PER_BLOCK) / BLOB_GASPRICE_UPDATE_FRACTION)`.
399399
Hence, it has a similar effect to the existing EIP-1559, but is more "stable" in the sense that it responds in the same way to the same total usage regardless of how it's distributed.
400400

401-
The parameter `DATA_GASPRICE_UPDATE_FRACTION` controls the maximum rate of change of the blob gas price. It is chosen to target a maximum change rate of `e(TARGET_DATA_GAS_PER_BLOCK / DATA_GASPRICE_UPDATE_FRACTION) ≈ 1.125` per block.
401+
The parameter `BLOB_GASPRICE_UPDATE_FRACTION` controls the maximum rate of change of the blob gas price. It is chosen to target a maximum change rate of `e(TARGET_BLOB_GAS_PER_BLOCK / BLOB_GASPRICE_UPDATE_FRACTION) ≈ 1.125` per block.
402402

403403
### Throughput
404404

405-
The values for `TARGET_DATA_GAS_PER_BLOCK` and `MAX_DATA_GAS_PER_BLOCK` are chosen to correspond to a target of 3 blobs (0.375 MB) and maximum of 6 blobs (0.75 MB) per block. These small initial limits are intended to minimize the strain on the network created by this EIP and are expected to be increased in future upgrades as the network demonstrates reliability under larger blocks.
405+
The values for `TARGET_BLOB_GAS_PER_BLOCK` and `MAX_BLOB_GAS_PER_BLOCK` are chosen to correspond to a target of 3 blobs (0.375 MB) and maximum of 6 blobs (0.75 MB) per block. These small initial limits are intended to minimize the strain on the network created by this EIP and are expected to be increased in future upgrades as the network demonstrates reliability under larger blocks.
406406

407407
## Backwards Compatibility
408408

@@ -421,7 +421,7 @@ By only broadcasting announcements for blob transactions, receiving nodes will h
421421
allowing them to throttle throughput to an acceptable level.
422422
[EIP-5793](./eip-5793.md) will give further fine-grained control to nodes by extending the `NewPooledTransactionHashes` announcement messages to include the transaction type and size.
423423

424-
In addition, we recommend including a 1.1x data gasprice bump requirement to the mempool transaction replacement rules.
424+
In addition, we recommend including a 1.1x blob gasprice bump requirement to the mempool transaction replacement rules.
425425

426426
## Test Cases
427427

0 commit comments

Comments
 (0)