Skip to content

Commit

Permalink
holocene: smart contract changes (#358)
Browse files Browse the repository at this point in the history
* holocene: standard L2 genesis

This scopes out the work for implementing the standard L2 genesis smart
contract changes. The additional diff on top of this smart contract work
is defining the network upgrade transactions, the public interface for
the `SystemConfig` for setting these values and the enum `ConfigType`
definition.

* lint

* lint: escape

* specs: fixup

* specs: fixup

* specs: fixup

* lint: fix

* lint: fix

* specs: update

* specs: lintspecs: lintspecs: lintspecs: lintspecs: lintspecs: lintspecs:
lintspecs: lint

* lint: fix

* specs: cleanup

* specs: toc

* specs: update

* toc: update

* specs: fix

* lint: fix

* lint: fix

* lint: fix

* lint

* specs: update

* lint: specs

* specs: update

* specs: more updates

* specs: toc

* specs: update name

* specs: update

* specs: specify initialize

* specs: toc

* lint: fix

* specs: delete dead spec

* specs: lint fix
  • Loading branch information
tynes authored Sep 18, 2024
1 parent 5576914 commit fbe5f81
Show file tree
Hide file tree
Showing 7 changed files with 488 additions and 2 deletions.
5 changes: 5 additions & 0 deletions specs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
- [Execution Engine](./protocol/granite/exec-engine.md)
- [Derivation](./protocol/granite/derivation.md)
- [Holocene](./protocol/holocene/overview.md)
- [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)
- [Experimental]()
Expand Down
157 changes: 157 additions & 0 deletions specs/protocol/holocene/configurability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Configurability

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [Overview](#overview)
- [Constants](#constants)
- [`ConfigType`](#configtype)
- [`SystemConfig`](#systemconfig)
- [`ConfigUpdate`](#configupdate)
- [Initialization](#initialization)
- [Modifying EIP-1559 Parameters](#modifying-eip-1559-parameters)
- [Interface](#interface)
- [EIP-1559 Params](#eip-1559-params)
- [`setEIP1559Params`](#seteip1559params)
- [Fee Vault Config](#fee-vault-config)
- [`setBaseFeeVaultConfig`](#setbasefeevaultconfig)
- [`setL1FeeVaultConfig`](#setl1feevaultconfig)
- [`setSequencerFeeVaultConfig`](#setsequencerfeevaultconfig)
- [`OptimismPortal`](#optimismportal)
- [Interface](#interface-1)
- [`setConfig`](#setconfig)

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

## Overview

The `SystemConfig` and `OptimismPortal` are updated with a new flow for chain
configurability.

## Constants

### `ConfigType`

The `ConfigType` enum represents configuration that can be modified.

| Name | Value | Description |
| ---- | ----- | --- |
| `SET_GAS_PAYING_TOKEN` | `uint8(0)` | Modifies the gas paying token for the chain |
| `SET_BASE_FEE_VAULT_CONFIG` | `uint8(1)` | Sets the Fee Vault Config for the `BaseFeeVault` |
| `SET_L1_FEE_VAULT_CONFIG` | `uint8(2)` | Sets the Fee Vault Config for the `L1FeeVault` |
| `SET_SEQUENCER_FEE_VAULT_CONFIG` | `uint8(3)` | Sets the Fee Vault Config for the `SequencerFeeVault` |
| `SET_L1_CROSS_DOMAIN_MESSENGER_ADDRESS` | `uint8(4)` | Sets the `L1CrossDomainMessenger` address |
| `SET_L1_ERC_721_BRIDGE_ADDRESS` | `uint8(5)` | Sets the `L1ERC721Bridge` address |
| `SET_L1_STANDARD_BRIDGE_ADDRESS` | `uint8(6)` | Sets the `L1StandardBridge` address |
| `SET_REMOTE_CHAIN_ID` | `uint8(7)` | Sets the chain id of the base chain |

## `SystemConfig`

### `ConfigUpdate`

The following `ConfigUpdate` enum 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 |

### Initialization

The following actions should happen during the initialization of the `SystemConfig`:

- `emit ConfigUpdate.BATCHER`
- `emit ConfigUpdate.FEE_SCALARS`
- `emit ConfigUpdate.GAS_LIMIT`
- `emit ConfigUpdate.UNSAFE_BLOCK_SIGNER`
- `emit ConfigUpdate.EIP_1559_PARAMS`
- `setConfig(SET_GAS_PAYING_TOKEN)`
- `setConfig(SET_BASE_FEE_VAULT_CONFIG)`
- `setConfig(SET_L1_FEE_VAULT_CONFIG)`
- `setConfig(SET_SEQUENCER_FEE_VAULT_CONFIG)`
- `setConfig(SET_L1_CROSS_DOMAIN_MESSENGER_ADDRESS)`
- `setConfig(SET_L1_ERC_721_BRIDGE_ADDRESS)`
- `setConfig(SET_L1_STANDARD_BRIDGE_ADDRESS)`
- `setConfig(SET_REMOTE_CHAIN_ID)`

These actions MAY only be triggered if there is a diff to the value.

### Modifying EIP-1559 Parameters

A new `SystemConfig` `UpdateType` is introduced that enables the modification of
[EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) parameters. This allows for the chain
operator to modify the `BASE_FEE_MAX_CHANGE_DENOMINATOR` and the `ELASTICITY_MULTIPLIER`.

### Interface

#### EIP-1559 Params

##### `setEIP1559Params`

This function MUST only be callable by the chain governor.

```solidity
function setEIP1559Params(uint64 _denominator, uint64 _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.

#### Fee Vault Config

For each `FeeVault`, there is a setter for its config. The arguments to the setter include
the `RECIPIENT`, the `MIN_WITHDRAWAL_AMOUNT` and the `WithdrawalNetwork`.
Each of these functions should be `public` and only callable by the chain governor.

Each function calls `OptimismPortal.setConfig(ConfigType,bytes)` with its corresponding `ConfigType`.

##### `setBaseFeeVaultConfig`

```solidity
function setBaseFeeVaultConfig(address,uint256,WithdrawalNetwork)
```

##### `setL1FeeVaultConfig`

```solidity
function setL1FeeVaultConfig(address,uint256,WithdrawalNetwork)
```

##### `setSequencerFeeVaultConfig`

```solidity
function setSequencerFeeVaultConfig(address,uint256,WithdrawalNetwork)
```

## `OptimismPortal`

The `OptimismPortal` is updated to emit a special system `TransactionDeposited` event.

### Interface

#### `setConfig`

The `setConfig` function MUST only be callable by the `SystemConfig`. This ensures that the `SystemConfig`
is the single source of truth for chain operator ownership.

```solidity
function setConfig(ConfigType,bytes)
```

This function emits a `TransactionDeposited` event.

```solidity
event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData);
```

The following fields are included:

- `from` is the `DEPOSITOR_ACCOUNT`
- `to` is `Predeploys.L1Block`
- `version` is `uint256(0)`
- `opaqueData` is the tightly packed transaction data where `mint` is `0`, `value` is `0`, the `gasLimit`
is `200_000`, `isCreation` is `false` and the `data` is `abi.encodeCall(L1Block.setConfig, (_type, _value))`
22 changes: 22 additions & 0 deletions specs/protocol/holocene/derivation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Derivation

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [Network upgrade automation transactions](#network-upgrade-automation-transactions)

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

# Network upgrade automation transactions

The Holocene hardfork activation block contains the following transactions, in this order:

- L1 Attributes Transaction
- User deposits from L1
- Network Upgrade Transactions
- L1Block deployment
- Update L1Block Proxy ERC-1967 Implementation
- L1Block Enable Holocene
- OptimismMintableERC20Factory deployment
- Update OptimismMintableERC20Factory Proxy ERC-1967 Implementation
4 changes: 2 additions & 2 deletions specs/protocol/holocene/exec-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ 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.

[l2-to-l1-mp]: ../protocol/predeploys.md#L2ToL1MessagePasser
[output-root]: ../glossary.md#l2-output-root
[l2-to-l1-mp]: ../../protocol/predeploys.md#L2ToL1MessagePasser
[output-root]: ../../glossary.md#l2-output-root
28 changes: 28 additions & 0 deletions specs/protocol/holocene/l1-attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# L1 Block Attributes

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [Overview](#overview)

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

## Overview

The L1 block attributes transaction is updated to include the EIP-1559 parameters.

| Input arg | Type | Calldata bytes | Segment |
| ----------------- | ------- | -------------- | ------- |
| {0xd1fbe15b} | | 0-3 | n/a |
| baseFeeScalar | uint32 | 4-7 | 1 |
| blobBaseFeeScalar | uint32 | 8-11 | |
| sequenceNumber | uint64 | 12-19 | |
| l1BlockTimestamp | uint64 | 20-27 | |
| l1BlockNumber | uint64 | 28-35 | |
| basefee | uint256 | 36-67 | 2 |
| blobBaseFee | uint256 | 68-99 | 3 |
| l1BlockHash | bytes32 | 100-131 | 4 |
| batcherHash | bytes32 | 132-163 | 5 |
| eip1559Denominator | uint64 | 164-171 | 6 |
| eip1559Elasticity | uint64 | 172-179 | |
6 changes: 6 additions & 0 deletions specs/protocol/holocene/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ This document is not finalized and should be considered experimental.

## Consensus Layer

- [Derivation](./derivation.md)

## Smart Contracts

- [Predeploys](./predeploys.md)
- [L1 Block Attributes](./l1-attributes.md)
- [Configurability](./configurability.md)
Loading

0 comments on commit fbe5f81

Please sign in to comment.