Skip to content

Commit

Permalink
feat(holocene): Simplify eip1559Params (#404)
Browse files Browse the repository at this point in the history
* chore(holocene): Simplify `eip1559Params`

* lint

* add section on header extension

* toc

* change attrs validity rules

* fork activation rule

* toc

* change from QUANTITY -> DATA

* update types

* review

* toc
  • Loading branch information
clabby authored Oct 1, 2024
1 parent 7958598 commit fb1fb8e
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 70 deletions.
1 change: 0 additions & 1 deletion specs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
- [Derivation](./protocol/holocene/derivation.md)
- [Execution Engine](./protocol/holocene/exec-engine.md)
- [Predeploys](./protocol/holocene/predeploys.md)
- [L1 Block Attributes](./protocol/holocene/l1-attributes.md)
- [Configurability](./protocol/holocene/configurability.md)
- [Governance]()
- [Governance Token](./governance/gov-token.md)
Expand Down
24 changes: 21 additions & 3 deletions specs/protocol/holocene/configurability.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- [Interface](#interface)
- [EIP-1559 Params](#eip-1559-params)
- [`setEIP1559Params`](#seteip1559params)
- [`eip1559Elasticity`](#eip1559elasticity)
- [`eip1559Denominator`](#eip1559denominator)
- [Fee Vault Config](#fee-vault-config)
- [`setBaseFeeVaultConfig`](#setbasefeevaultconfig)
- [`setL1FeeVaultConfig`](#setl1feevaultconfig)
Expand Down Expand Up @@ -50,15 +52,15 @@ The `ConfigType` enum represents configuration that can be modified.

### `ConfigUpdate`

The following `ConfigUpdate` enum is defined where the `CONFIG_VERSION` is `uint256(0)`:
The following `ConfigUpdate` event is defined where the `CONFIG_VERSION` is `uint256(0)`:

| 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 |
| `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(uint64(_denominator)) << 32 \| uint64(_elasticity)` | Modifies the EIP-1559 denominator and elasticity |
| `EIP_1559_PARAMS` | `uint8(4)` | `uint256(uint64(uint32(_denominator))) << 32 \| uint64(uint32(_elasticity))` | Modifies the EIP-1559 denominator and elasticity |

### Initialization

Expand Down Expand Up @@ -95,12 +97,28 @@ operator to modify the `BASE_FEE_MAX_CHANGE_DENOMINATOR` and the `ELASTICITY_MUL
This function MUST only be callable by the chain governor.

```solidity
function setEIP1559Params(uint64 _denominator, uint64 _elasticity)
function setEIP1559Params(uint32 _denominator, uint32 _elasticity)
```

The `_denominator` and `_elasticity` MUST be set to values greater to than 0.
It is possible for the chain operator to set EIP-1559 parameters that result in poor user experience.

##### `eip1559Elasticity`

This function returns the currently configured EIP-1559 elasticity.

```solidity
function eip1559Elasticity()(uint64)
```

##### `eip1559Denominator`

This function returns the currently configured EIP-1559 denominator.

```solidity
function eip1559Denominator()(uint64)
```

#### Fee Vault Config

For each `FeeVault`, there is a setter for its config. The arguments to the setter include
Expand Down
14 changes: 14 additions & 0 deletions specs/protocol/holocene/derivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [Batch Queue](#batch-queue)
- [Fast Channel Invalidation](#fast-channel-invalidation)
- [Engine Queue](#engine-queue)
- [Attributes Builder](#attributes-builder)
- [Activation](#activation)
- [Rationale](#rationale)
- [Strict Frame and Batch Ordering](#strict-frame-and-batch-ordering)
Expand Down Expand Up @@ -177,6 +178,19 @@ As before, a failure to then process the deposit-only attributes is a critical e
If an invalid payload is replaced by a deposit-only payload, for consistency reasons, the remaining
span batch, if applicable, and channel it originated from are dropped as well.

## Attributes Builder

Starting after the fork activation block, the `PayloadAttributes` produced by the attributes builder will include
the `eip1559Params` field described in the [execution engine specs](./exec-engine.md#eip1559params-encoding). This
value exists within the `SystemConfig`.

On the fork activation block, the attributes builder will include a 0'd out `eip1559Params`, as to instruct
the engine to use the [canyon base fee parameter constants](../exec-engine.md#1559-parameters). This
is to prime the pipeline's view of the `SystemConfig` with the default EIP-1559 parameter values. After the first
Holocene payload has been processed, future payloads should use the `SystemConfig`'s EIP-1559 denominator and elasticity
parameter as the `eip1559Params` field's value. When the pipeline encounters a `UpdateType.EIP_1559_PARAMS`,
`ConfigUpdate` event, the pipeline's system config will be synchronized with the `SystemConfig` contract's.

## Activation

The new batch rules activate when the _L1 inclusion block timestamp_ is greater or equal to the
Expand Down
92 changes: 83 additions & 9 deletions specs/protocol/holocene/exec-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [Timestamp Activation](#timestamp-activation)
- [`L2ToL1MessagePasser` Storage Root in Header](#l2tol1messagepasser-storage-root-in-header)
- [Timestamp Activation](#timestamp-activation)
- [Header Validity Rules](#header-validity-rules)
- [Header Withdrawals Root](#header-withdrawals-root)
- [Rationale](#rationale)
- [Forwards Compatibility Considerations](#forwards-compatibility-considerations)
- [Client Implementation Considerations](#client-implementation-considerations)
- [Extended `PayloadAttributesV3`](#extended-payloadattributesv3)
- [`eip1559Params` encoding](#eip1559params-encoding)
- [Execution](#execution)
- [Rationale](#rationale-1)
- [`eip1559Params` in Header](#eip1559params-in-header)
- [Header Validity Rules](#header-validity-rules-1)
- [Encoding](#encoding)
- [Rationale](#rationale-2)

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

## Timestamp Activation

Holocene, like other network upgrades, is activated at a timestamp.
Changes to the L2 Block execution rules are applied when the `L2 Timestamp >= activation time`.

## `L2ToL1MessagePasser` Storage Root in Header

After the Holocene hardfork's activation, the L2 block header's `withdrawalsRoot` field will consist of the 32-byte
After Holocene's activation, the L2 block header's `withdrawalsRoot` field will consist of the 32-byte
[`L2ToL1MessagePasser`][l2-to-l1-mp] account storage root _after_ the block has been executed, and _after_ the
insertions and deletions have been applied to the trie. In other words, the storage root should be the same root
that is returned by `eth_getProof` at the given block number.

### Timestamp Activation

Holocene, like other network upgrades, is activated at a timestamp.
Changes to the L2 Block execution rules are applied when the `L2 Timestamp >= activation time`.
Changes to the L2 block header are applied when it is considering data from a L1 Block whose timestamp
is greater than or equal to the activation timestamp.

### Header Validity Rules

Prior to holocene activation, the L2 block header's `withdrawalsRoot` field must be:
Expand Down Expand Up @@ -73,5 +79,73 @@ an outbound withdrawal for a long period of time, the node may not have access t
clients are able to at the very least reconstruct the account storage root at a given block on the fly if it does not
directly store this information.

## Extended `PayloadAttributesV3`

The [`PayloadAttributesV3`](https://github.com/ethereum/execution-apis/blob/cea7eeb642052f4c2e03449dc48296def4aafc24/src/engine/cancun.md#payloadattributesv3)
type is extended to:

```rs
PayloadAttributesV3: {
timestamp: QUANTITY
random: DATA (32 bytes)
suggestedFeeRecipient: DATA (20 bytes)
withdrawals: array of WithdrawalV1
parentBeaconBlockRoot: DATA (32 bytes)
transactions: array of DATA
noTxPool: bool
gasLimit: QUANTITY or null
eip1559Params: DATA (8 bytes)
}
```

### `eip1559Params` encoding

| Name | Type | Byte Offset |
| ------------- | ------------------ | ----------- |
| `denominator` | `u32 (big-endian)` | `[0, 4)` |
| `elasticity` | `u32 (big-endian)` | `[4, 8)` |

### Execution

During execution, the EIP-1559 parameters used to calculate the next block base fee should come from the
`PayloadAttributesV3` type rather than the previous protocol constants, if it is non-null.

- If, before Holocene activation, `eip1559Parameters` is non-zero, the attributes are to be considered invalid by the
engine.
- After Holocene activation:
- if `eip1559Params` is zero, the [canyon base fee parameter constants](../exec-engine.md#1559-parameters) are
used.
- if `eip1559Params` are non-null, the values from the attributes are used.

### Rationale

This type is made available in the payload attributes to allow the block builder to dynamically control the EIP-1559
parameters of the chain. As described in the [derivation - AttributesBuilder](./derivation.md#attributes-builder)
section, the derivation pipeline must populate this field from the `SystemConfig` during payload building, similar to
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.

### Header Validity Rules

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

After Holocene activation, The L2 block header's `nonce` field is valid iff it is non-zero.

### Encoding

The encoding of the `eip1559Params` value is 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
28 changes: 0 additions & 28 deletions specs/protocol/holocene/l1-attributes.md

This file was deleted.

1 change: 0 additions & 1 deletion specs/protocol/holocene/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ This document is not finalized and should be considered experimental.
## Smart Contracts

- [Predeploys](./predeploys.md)
- [L1 Block Attributes](./l1-attributes.md)
- [Configurability](./configurability.md)
28 changes: 0 additions & 28 deletions specs/protocol/holocene/predeploys.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
- [L1Block](#l1block)
- [Storage](#storage)
- [Interface](#interface)
- [`setL1BlockValuesHolocene`](#setl1blockvaluesholocene)
- [`setHolocene`](#setholocene)
- [`eip1559Elasticity`](#eip1559elasticity)
- [`eip1559Denominator`](#eip1559denominator)
- [`setConfig`](#setconfig)
- [`baseFeeVaultConfig`](#basefeevaultconfig)
- [`sequencerFeeVaultConfig`](#sequencerfeevaultconfig)
Expand Down Expand Up @@ -101,37 +98,12 @@ via a deposit transaction from the `DEPOSITOR_ACCOUNT`.

#### Interface

##### `setL1BlockValuesHolocene`

This function MUST only be callable by the `DEPOSITOR_ACCOUNT`. It is a replacement
for `setL1BlockValuesEcotone` and its calldata is defined in [L1 Attributes](./l1-attributes.md).

```function
function setL1BlockValuesHolocene()
```

##### `setHolocene`

This function is meant to be called once on the activation block of the holocene network upgrade.
It MUST only be callable by the `DEPOSITOR_ACCOUNT` once. When it is called, it MUST call
call each getter for the network specific config and set the returndata into storage.

##### `eip1559Elasticity`

This function returns the currently configured EIP-1559 elasticity.

```solidity
function eip1559Elasticity()(uint64)
```

##### `eip1559Denominator`

This function returns the currently configured EIP-1559 denominator.

```solidity
function eip1559Denominator()(uint64)
```

##### `setConfig`

This function MUST only be callable by the `DEPOSITOR_ACCOUNT`. It modifies the storage directly
Expand Down

0 comments on commit fb1fb8e

Please sign in to comment.