Skip to content

Commit

Permalink
add normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Nov 22, 2024
1 parent 5b82513 commit 97e7b0d
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions EIPS/eip-7742.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ Hence we entirely deprecated the `MAX_BLOB_GAS_PER_BLOCK` checks from [EIP-4844]

The target is currently specified as a fixed value in relation to the blobs per block. The Ethereum community intends to increase the blob parameters as part of its scaling strategy and the ability to have a more flexible target value in relation to the blob max is desirable to reduce rigidity in this protocol parameter.

Even if the EL keeps a fixed target value based on the max, removing the max implies the EL would not know what the target value should be. To address this lack of information, this EIP proposes the CL sends the current target value to the EL with each provided payload over the Engine API. The EL block header will also need to be extended with this `target_blobs_per_block` value to preserve the security of optimistic sync.
This target is now driven by the CL which sends the current target value to the EL for purposes of `excess_blob_gas` accumulation and validation. The EL block header will also need to be extended with this `target_blobs_per_block` value to preserve the security of optimistic sync.

#### Updated Fee calculations

With the changing target, we also need to scale the `BLOB_BASE_FEE_UPDATE_FRACTION` from [EIP-4844](./eip-4844.md) accordingly to bound the price jumps by +-12.5%. But this introduces some irregularity on the fork block because excess blob gas is effectively scaled down by this changed factor in the fee calculations.
With the changing target, we also need to scale the `BLOB_BASE_FEE_UPDATE_FRACTION` from [EIP-4844](./eip-4844.md) accordingly to bound the price jumps by +-12.5%. But this introduces some irregularity whenever target gets updated because excess blob gas (accumulated via old target) is now effectively scaled down by this changed fraction in the fee calculations.

However we consider the target change events to be few and far between and hence not a cause of concern. The likely effect of this factor update will be to bring down the base fee on the fork block and hence would not negatively impact the transactions in txpool.
To mitigate this irregularity, we now save a _normalized_ excess gas with respect to a fixed `EXCESS_BLOB_GAS_NORMALIZATION_TARGET` and use a corresponding `BLOB_BASE_FEE_UPDATE_FRACTION_NORMALIZED` in the base fee calculations.

## Specification

Expand All @@ -77,33 +77,39 @@ Furthermore `get_base_fee_per_blob_gas` as specified by [EIP-4844](./eip-4844.md

| Constant | Value |
| - | - |
| `BLOB_BASE_FEE_UPDATE_FRACTION_PER_TARGET_BLOB` | `1112825` |
| `EXCESS_BLOB_GAS_NORMALIZATION_TARGET_BLOBS` | `128` | normalize to a target of 128 blobs |
| `BLOB_BASE_FEE_UPDATE_FRACTION_PER_TARGET_BLOB` | `1112825` | used to calculate normalized update fraction |
| `BLOB_BASE_FEE_UPDATE_FRACTION_NORMALIZED` | `142441600`| update fraction for the normalized target of 128 blobs |
| `OLD_TARGET_BLOBS_PER_BLOCK` | `3` | blobs target corresponding to [EIP-4844](./eip-4844.md)'s target gas |


```python
def calc_excess_blob_gas(parent: Header) -> int:
parent_target_blob_gas = parent.target_blobs_per_block * GAS_PER_BLOB
if parent.excess_blob_gas + parent.blob_gas_used < parent_target_blob_gas:
return 0
else:
return parent.excess_blob_gas + parent.blob_gas_used - parent_target_blob_gas
# normalize parent's excess blob gas if this block was fork block
if(parent.timestamp < FORK_TIMESTAMP)
normalized_parent_excess_blob_gas = parent.excess_blob_gas * EXCESS_BLOB_GAS_NORMALIZATION_TARGET_BLOBS // OLD_TARGET_BLOBS_PER_BLOCK
target_blobs_per_block = OLD_TARGET_BLOBS_PER_BLOCK
else
normalized_parent_excess_blob_gas = parent.excess_blob_gas
target_blobs_per_block = parent.target_blobs_per_block

return (normalized_parent_excess_blob_gas + (parent.blob_gas_used - target_blob_gas) * EXCESS_BLOB_GAS_NORMALIZATION_TARGET_BLOBS // target_blobs_per_block)

def get_base_fee_per_blob_gas(header: Header) -> int:
update_fraction = BLOB_BASE_FEE_UPDATE_FRACTION_PER_TARGET_BLOB * header.target_blobs_per_block
return fake_exponential(
MIN_BASE_FEE_PER_BLOB_GAS,
header.excess_blob_gas,
update_fraction
BLOB_BASE_FEE_UPDATE_FRACTION_NORMALIZED
)
```

Rest of the [EIP-4844](./eip-4844.md) specification is not changed

### Block construction

To kickstart block construction, CL will now provide EL a target and a maximum blobs per block. These values should be used to ensure the correct number of blobs are included in any constructed payload, and to ensure that the blob base fee accounting is correctly done as specified above.
To kickstart block construction, CL provides EL a target and a maximum blobs per block. These values should be used to ensure the correct number of blobs are included in any constructed payload, and to ensure that the blob base fee accounting is correctly done as specified above.

For a genesis block with no existing parent, the value should be set according to the agreed specification for the target blobs per block given by that genesis block's protocol rule set. For the purposes of this EIP, the `target_blobs_per_block` at genesis is set equivalent to [EIP-4844](./eip-4844.md)'s `TARGET_BLOB_GAS_PER_BLOCK`.
For a genesis block with no existing parent, the value should be set according to the agreed specification for the target blobs per block given by that genesis block's protocol rule set. For the purposes of this EIP, the `target_blobs_per_block` at genesis is set to `OLD_TARGET_BLOBS_PER_BLOCK`.

## Rationale

Expand Down

0 comments on commit 97e7b0d

Please sign in to comment.