Skip to content

Commit

Permalink
Amend holocene spec to specify eip-1559 parameters should be in the e…
Browse files Browse the repository at this point in the history
…xecution payload
  • Loading branch information
roberto-bayardo committed Oct 15, 2024
1 parent b1de5f6 commit 78552cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
53 changes: 24 additions & 29 deletions specs/protocol/holocene/exec-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
- [Rationale](#rationale)
- [`eip1559Params` in Header](#eip1559params-in-header)
- [Header Validity Rules](#header-validity-rules)
- [Encoding](#encoding)
- [Rationale](#rationale-1)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Overview

The EIP-1559 parameters are encoded in the block header's `nonce` field and can be
The EIP-1559 parameters are encoded in the block header's `extraData` field and can be
configured dynamically through the `SystemConfig`.

## Timestamp Activation
Expand Down Expand Up @@ -64,19 +63,19 @@ field.

### Execution

During execution, the EIP-1559 parameters used to calculate the next block base fee should come from the
parent header's `nonce` field rather than the previous protocol constants, if it is non-zero.
During execution, the EIP-1559 parameters used to calculate the next block base fee should come from the parent header's
`extraData` field rather than the previous protocol constants, if it is non-empty.

- If, before Holocene activation, `eip1559Parameters` in the `PayloadAttributesV3` is non-null, the attributes are to be
considered invalid by the engine.

- If, before Holocene activation, `eip1559Parameters` in the `PayloadAttributesV3` is non-null, the attributes are to
be considered invalid by the engine.
- At and after Holocene activation:
- if `eip1559Params` in the `PayloadAttributesV3` is null, the attributes are to be considered invalid by the
engine.
- if `eip1559Params` in the `PayloadAttributesV3` is null, the attributes are to be considered invalid by the engine.
- if `eip1559Params`' `denominator` is `0`, the attributes are to be considered invalid by the engine.
- if `parent_header.nonce` is zero, the [canyon base fee parameter constants](../exec-engine.md#1559-parameters) are
used for the block's base fee parameters.
- if `parent_header.nonce` is non-zero, the EIP-1559 parameters encoded within the parent header's `nonce` field are
used for the block's base fee parameters.
- if `parent_header.extraData` is empty, the [canyon base fee parameter constants](../exec-engine.md#1559-parameters)
are used for the block's base fee parameters.
- if `parent_header.extraData` is non-empty with the version byte (first byte) value 0, the EIP-1559 remaining 64
bytes are used for the block's eip-1559 parameters.

### Rationale

Expand All @@ -87,27 +86,23 @@ how it must reference the `SystemConfig` for the `gasLimit` field.

### `eip1559Params` in Header

Upon Holocene activation, the L2 block header's `nonce` field will consist of the 8-byte `eip1559Params` value from
the `PayloadAttributesV3`, or the canyon EIP-1559 constants if `eip1559Params` is equal to zero.
Upon Holocene activation, the L2 block header's `extraData` field will consist of a version byte with value
byte(0), followed by an 8-byte `eip1559Params` value from the `PayloadAttributesV3`, or the canyon EIP-1559
constants if `eip1559Params` is equal to zero.

#### Header Validity Rules

Prior to Holocene activation, the L2 block header's `nonce` field is valid iff it is equal to `u64(0)`.

At and after Holocene activation, The L2 block header's `nonce` field is valid iff it is non-zero.
Prior to Holocene activation, the L2 block header's `extraData` field is valid iff it is empty.

#### Encoding

The encoding of the `eip1559Params` value is described in [`eip1559Params` encoding](#eip1559params-encoding).
At and after Holocene activation, The L2 block header's `extraData` field is valid iff it consists of a leading version
byte with value 0 followed by the eip-1559 parameters encoded as described in [`eip1559Params`
encoding](#eip1559params-encoding).

#### Rationale

By chosing to put the `eip1559Params` in the `PayloadAttributes` rather than in the L1 block info transaction,
the EIP-1559 parameters for the chain are not available within history. This would place a burden on performing
historical execution, as L1 would have to be consulted for fetching the values from the `SystemConfig` contract.
Instead, we re-use an unused field in the L1 block header as to make these parameters available, retaining the
purity of the function that computes the next block's base fee from the chain configuration, parent block header,
and next block timestamp.

[l2-to-l1-mp]: ../../protocol/predeploys.md#L2ToL1MessagePasser
[output-root]: ../../glossary.md#l2-output-root
By choosing to put the `eip1559Params` in the `PayloadAttributes` rather than in the L1 block info transaction, the
EIP-1559 parameters for the chain are not available within history. This would place a burden on performing historical
execution, as L1 would have to be consulted for fetching the values from the `SystemConfig` contract. Instead, we
re-use an unused field in the L2 block header as to make these parameters available, retaining the purity of the
function that computes the next block's base fee from the chain configuration, parent block header, and next block
timestamp.
4 changes: 2 additions & 2 deletions specs/protocol/holocene/system-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ The following `ConfigUpdate` event is defined where the `CONFIG_VERSION` is `uin
| Name | Value | Definition | Usage |
| ---- | ----- | --- | -- |
| `BATCHER` | `uint8(0)` | `abi.encode(address)` | Modifies the account that is authorized to progress the safe chain |
| `FEE_SCALARS` | `uint8(1)` | `(uint256(0x01) << 248) \| (uint256(_blobbasefeeScalar) << 32) \| _basefeeScalar` | Modifies the fee scalars |
| `FEE_SCALARS` | `uint8(1)` | `abi.encode(uint256(0), (uint256(0x01) << 248) \| (uint256(_blobbasefeeScalar) << 32) \| _basefeeScalar)` | Modifies the fee scalars |
| `GAS_LIMIT` | `uint8(2)` | `abi.encode(uint64 _gasLimit)` | Modifies the L2 gas limit |
| `UNSAFE_BLOCK_SIGNER` | `uint8(3)` | `abi.encode(address)` | Modifies the account that is authorized to progress the unsafe chain |
| `EIP_1559_PARAMS` | `uint8(4)` | `(uint256(_denominator) << 32) \| _elasticity` | Modifies the EIP-1559 denominator and elasticity |
| `EIP_1559_PARAMS` | `uint8(4)` | `abi.encode((uint256(_denominator) << 32) \| _elasticity)` | Modifies the EIP-1559 denominator and elasticity |

### Initialization

Expand Down

0 comments on commit 78552cd

Please sign in to comment.