Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isthmus: operator fee #382

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f4ef24d
holocene exec-engine
yuwen01 Sep 19, 2024
d2f40a0
update other files in holocene directory
yuwen01 Sep 19, 2024
7ddbce3
update feevault
yuwen01 Sep 19, 2024
2e12898
dont change the function signature
yuwen01 Sep 19, 2024
1407fa9
specify initial configurablefee
yuwen01 Sep 19, 2024
50c22ec
typos in exec engine
yuwen01 Sep 19, 2024
78cb4cb
remove configurablefeevault
yuwen01 Sep 19, 2024
6a78e21
linter
yuwen01 Sep 19, 2024
fb53c85
clean up + pack storage slots
yuwen01 Sep 20, 2024
b56048a
optimize packing a little
yuwen01 Sep 20, 2024
7c90f2b
oxford comma
yuwen01 Sep 20, 2024
f4e27b3
rephrase
yuwen01 Sep 20, 2024
1526415
move changes to isthmus
yuwen01 Sep 20, 2024
7085d98
reset holocene
yuwen01 Sep 20, 2024
148230b
linter
yuwen01 Sep 20, 2024
fbf8dfb
update configupdate version
yuwen01 Sep 20, 2024
48a25af
removed mention of holocene, added isthmus to SUMMARY
yuwen01 Sep 20, 2024
98fdb84
merged main
yuwen01 Sep 20, 2024
ead7704
fixed link
yuwen01 Sep 20, 2024
1ade65a
add predeploys and system-config
yuwen01 Sep 20, 2024
4673839
update summary
yuwen01 Sep 20, 2024
b945faf
rerun doctoc
yuwen01 Sep 20, 2024
2f73dc2
fix calldata
yuwen01 Sep 20, 2024
43c5ea9
Update specs/protocol/isthmus/configurability.md
yuwen01 Sep 23, 2024
2efe231
sebastians suggestions
yuwen01 Sep 23, 2024
816cc6c
typo in l1-attributes
yuwen01 Sep 24, 2024
a8e094e
Merge branch 'main' of github.com:ethereum-optimism/specs into yuwen/…
yuwen01 Sep 25, 2024
1314351
also change the gaspriceoracle
yuwen01 Sep 26, 2024
63d1760
Merge branch 'main' into yuwen/additional-fee-scalars
yuwen01 Sep 27, 2024
76fa61a
WIP: move everything to holocene
yuwen01 Sep 30, 2024
3afa960
move to holocene
yuwen01 Sep 30, 2024
f45744f
update summary
yuwen01 Sep 30, 2024
2a64355
Merge branch 'main' into yuwen/additional-fee-scalars
yuwen01 Sep 30, 2024
2f0187f
fix typos
yuwen01 Sep 30, 2024
1625dab
typo
yuwen01 Sep 30, 2024
bc293f2
add the operatorFeeVault back
yuwen01 Oct 1, 2024
ff1aa7f
gas price oracle clarifications
yuwen01 Oct 1, 2024
317ac76
fix typos
yuwen01 Oct 1, 2024
bbb9e05
another typo
yuwen01 Oct 1, 2024
4c3eaca
update overview
yuwen01 Oct 1, 2024
cfdc6fc
new role
yuwen01 Oct 2, 2024
3db2793
operator fee manager doesnt collect fees
yuwen01 Oct 2, 2024
e2af323
fill in constants
yuwen01 Oct 2, 2024
b88dcf8
add operator fee vault address
yuwen01 Oct 2, 2024
dcf4bdd
dont emit new configupdate
yuwen01 Oct 2, 2024
6ad2938
typo
yuwen01 Oct 2, 2024
3d9f967
typos
yuwen01 Oct 2, 2024
3c99591
add more support for operator fee manager
yuwen01 Oct 2, 2024
2bf6246
migrate to isthmus
yuwen01 Oct 3, 2024
4e0f724
typos
yuwen01 Oct 3, 2024
9ab37f9
run linter
yuwen01 Oct 3, 2024
c7efd31
merge main
yuwen01 Oct 20, 2024
6c57838
set fee manager in roles
yuwen01 Nov 8, 2024
1aa27f4
merge main again
yuwen01 Nov 8, 2024
219e72c
add sysconfig to summary
yuwen01 Nov 8, 2024
762dbf7
move roles to root configurability.md + typo
yuwen01 Nov 18, 2024
99c9f4d
typo
yuwen01 Nov 18, 2024
18c8127
operator fee manager
yuwen01 Nov 20, 2024
54ea6a4
Merge branch 'main' into yuwen/additional-fee-scalars
yuwen01 Nov 20, 2024
6512664
clarification on l1 block attributes function selector
yuwen01 Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions specs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@
- [Execution Engine](./protocol/holocene/exec-engine.md)
- [System Config](./protocol/holocene/system-config.md)
- [Isthmus](./protocol/isthmus/overview.md)
- [Configurability](./protocol/isthmus/configurability.md)
- [Derivation](./protocol/isthmus/derivation.md)
- [Execution Engine](./protocol/isthmus/exec-engine.md)
- [L1 Attributes](./protocol/isthmus/l1-attributes.md)
- [Predeploys](./protocol/isthmus/predeploys.md)
- [Superchain Config](./protocol/isthmus/superchain-config.md)
- [System Config](./protocol/isthmus/system-config.md)
- [Governance]()
- [Governance Token](./governance/gov-token.md)
- [Experimental]()
Expand Down
94 changes: 89 additions & 5 deletions specs/protocol/isthmus/configurability.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,33 @@
- [`SystemConfig`](#systemconfig)
- [`ConfigUpdate`](#configupdate)
- [Initialization](#initialization)
- [Modifying Operator Fee Parameters](#modifying-operator-fee-parameters)
- [Interface](#interface)
- [Operator fee parameters](#operator-fee-parameters)
- [`operatorFeeScalar`](#operatorfeescalar)
- [`operatorFeeConstant`](#operatorfeeconstant)
- [`setOperatorFeeScalars`](#setoperatorfeescalars)
- [Fee Vault Config](#fee-vault-config)
- [`setBaseFeeVaultConfig`](#setbasefeevaultconfig)
- [`setL1FeeVaultConfig`](#setl1feevaultconfig)
- [`setSequencerFeeVaultConfig`](#setsequencerfeevaultconfig)
- [`setOperatorFeeVaultConfig`](#setoperatorfeevaultconfig)
- [`OptimismPortal`](#optimismportal)
- [Interface](#interface-1)
- [`setConfig`](#setconfig)
- [`upgrade`](#upgrade)
- [Consensus Parameters](#consensus-parameters)
- [Operator Fee Scalar](#operator-fee-scalar)
- [Operator Fee Constant](#operator-fee-constant)
- [Service Roles](#service-roles)
- [Operator Fee Manager](#operator-fee-manager)

<!-- 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.
configurability. A new service role `OperatorFeeManager` is added to manage the operator fee collection.

## Constants

Expand All @@ -39,10 +50,11 @@ The `ConfigType` enum represents configuration that can be modified.
| `BASE_FEE_VAULT_CONFIG` | `uint8(1)` | Sets the Fee Vault Config for the `BaseFeeVault` |
| `L1_FEE_VAULT_CONFIG` | `uint8(2)` | Sets the Fee Vault Config for the `L1FeeVault` |
| `SEQUENCER_FEE_VAULT_CONFIG` | `uint8(3)` | Sets the Fee Vault Config for the `SequencerFeeVault` |
| `L1_CROSS_DOMAIN_MESSENGER_ADDRESS` | `uint8(4)` | Sets the `L1CrossDomainMessenger` address |
| `L1_ERC_721_BRIDGE_ADDRESS` | `uint8(5)` | Sets the `L1ERC721Bridge` address |
| `L1_STANDARD_BRIDGE_ADDRESS` | `uint8(6)` | Sets the `L1StandardBridge` address |
| `REMOTE_CHAIN_ID` | `uint8(7)` | Sets the chain id of the base chain |
| `OPERATOR_FEE_VAULT_CONFIG` | `uint8(4)` | Sets the Fee Vault Config for the `OperatorFeeVault` |
| `L1_CROSS_DOMAIN_MESSENGER_ADDRESS` | `uint8(5)` | Sets the `L1CrossDomainMessenger` address |
| `L1_ERC_721_BRIDGE_ADDRESS` | `uint8(6)` | Sets the `L1ERC721Bridge` address |
| `L1_STANDARD_BRIDGE_ADDRESS` | `uint8(7)` | Sets the `L1StandardBridge` address |
| `REMOTE_CHAIN_ID` | `uint8(8)` | Sets the chain id of the base chain |

## `SystemConfig`

Expand All @@ -57,6 +69,7 @@ The following `ConfigUpdate` event is defined where the `CONFIG_VERSION` is `uin
| `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(uint32(_denominator))) << 32 \| uint64(uint32(_elasticity))` | Modifies the EIP-1559 denominator and elasticity |
| `OPERATOR_FEE_PARAMS` | `uint8(5)` | `uint256(_operatorFeeScalar) << 64 \| _operatorFeeConstant` | Modifies the operator fee parameters |

### Initialization

Expand All @@ -67,19 +80,59 @@ The following actions should happen during the initialization of the `SystemConf
- `emit ConfigUpdate.GAS_LIMIT`
- `emit ConfigUpdate.UNSAFE_BLOCK_SIGNER`
- `emit ConfigUpdate.EIP_1559_PARAMS`
- `emit ConfigUpdate.OPERATOR_FEE_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_OPERATOR_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.

Since the `OperatorFeeVault` is new in Isthmus, the `setConfig(SET_OPERATOR_FEE_VAULT_CONFIG)` MUST be emitted.

`ConfigUpdate.OPERATOR_FEE_PARAMS` MAY be emitted. If it is not emitted, the `operatorFeeScalar` and
`operatorFeeConstant` are set to 0 by default.

### Modifying Operator Fee Parameters

A new `SystemConfig` `UpdateType` is introduced that enables the modification of
the `operatorFeeScalar` and `operatorFeeConstant` by the [`OperatorFeeManager`](#operator-fee-manager).

### Interface

#### Operator fee parameters

##### `operatorFeeScalar`

This function returns the currently configured operator fee scalar.

```solidity
function operatorFeeScalar()(uint32)
```

##### `operatorFeeConstant`

This function returns the currently configured operator fee constant.

```solidity
function operatorFeeConstant()(uint64)
```

##### `setOperatorFeeScalars`

This function sets the `operatorFeeScalar` and `operatorFeeConstant`.

This function MUST only be callable by the [`OperatorFeeManager`](#operator-fee-manager).

```solidity
function setOperatorFeeScalar(uint32 _operatorFeeScalar, uint64 _operatorFeeConstant)()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit: I think its fine to omit the trailing () when there is no return arg

```

#### Fee Vault Config

For each `FeeVault`, there is a setter for its config. The arguments to the setter include
Expand All @@ -106,6 +159,12 @@ function setL1FeeVaultConfig(address,uint256,WithdrawalNetwork)
function setSequencerFeeVaultConfig(address,uint256,WithdrawalNetwork)
```

##### `setOperatorFeeVaultConfig`

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

## `OptimismPortal`

The `OptimismPortal` is updated to emit a special system `TransactionDeposited` event.
Expand Down Expand Up @@ -157,3 +216,28 @@ The following fields are included:
- `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 the data passed into `upgrade`.

## Consensus Parameters

The operator fee scalar and constant are new consensus parameters, so we define standard values for them.

### [Operator Fee Scalar](exec-engine.md#operator-fees)

**Description:** Operator fee scalar -- used to calculate the operator fee<br/>
**Administrator:** [Operator Fee Manager](#operator-fee-manager)<br/>
**Requirement:** Between 0 and 0.5 * (baseFee + priorityFee) <br/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't noted anywhere, apologies about that, but its probably best to put these configurability requirements in this file so they are all in a single place

Also we would like to say that the requirement for these values is 0 for now for the superchain, with op-succinct you can use them however you would like, then when we do add zk as part of the superchain's proof system we can define the ranges of values. We don't have bandwidth to really think deeply about what the standard values should be from a product perspective and while what you have now could make sense, I don't want to ratify something thru gov that ultimately isnt right


### [Operator Fee Constant](exec-engine.md#operator-fees)

**Description:** Operator fee constant -- used to calculate the operator fee<br/>
**Administrator:** [Operator Fee Manager](#operator-fee-manager)<br/>
**Requirement:** Between 0 and 600 Gwei <br/>

## Service Roles

### Operator Fee Manager

**Description:** Account authorized to modify the operator fee scalar. <br/>
**Administrator:** [System Config Owner](../configurability.md#system-config)<br/>
**Requirement:** <br/>
**Notes:** <br/>
25 changes: 25 additions & 0 deletions specs/protocol/isthmus/derivation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Isthmus L2 Chain Derivation Changes

<!-- 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 Isthmus 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 Isthmus
- GasPriceOracle deployment
- Update GasPriceOracle Proxy ERC-1967 Implementation
- GasPriceOracle Enable Isthmus
- OptimismMintableERC20Factory deployment
- Update OptimismMintableERC20Factory Proxy ERC-1967 Implementation
43 changes: 43 additions & 0 deletions specs/protocol/isthmus/exec-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
- [Engine API Updates](#engine-api-updates)
- [Update to `ExecutableData`](#update-to-executabledata)
- [`engine_newPayloadV3` API](#engine_newpayloadv3-api)
- [Fees](#fees)
- [Operator Fee](#operator-fee)
- [Configuring Parameters](#configuring-parameters)
- [Fee Vaults](#fee-vaults)

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

Expand Down Expand Up @@ -141,3 +145,42 @@ Withdrawals list in the block body is encoded as an empty RLP list.

Post Isthmus, `engine_newPayloadV3` will be used with the additional `ExecutionPayload` attribute. This attribute
is omitted prior to Isthmus.

## Fees

New OP stack variants have different resource consumption patterns, and thus require a more flexible
pricing model. To enable more customizable fee structures, Isthmus adds a new component to the fee
calculation: the `operatorFee`, which is parameterized by two scalars: the `operatorFeeScalar`
and the `operatorFeeConstant`.

### Operator Fee

The operator fee, is set as follows:

`operatorFee = (gasUsed * operatorFeeScalar / 1e6) + operatorFeeConstant`

Where:

- `gasUsed` is amount of gas used by the transaction.
- `operatorFeeScalar` is a `uint32` scalar set by the chain operator, scaled by `1e6`.
- `operatorFeeConstant` is a `uint64` scalar set by the chain operator.

#### Configuring Parameters

`operatorFeeScalar` and `operatorFeeConstant` are loaded in a similar way to the `baseFeeScalar` and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw comment somewhere, maybe gone by now, that there would be restrictions on how large the operator fee scalar and fee constant should be set. If this feature becomes a standard chain features I think that this restriction is very important to protect user funds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the operator fee will probably not become part of the superchain config since it adds complexity. Its purpose is more intended for non-standard chains, like op-succinct chains, for example.

My previous proposal wa the at the constant was between 0 and 600 Gwei and that the scalar was between 0 and 0.5x (basefee + priorityfee).

`blobBaseFeeScalar` used in the [`L1Fee`](../../protocol/exec-engine.md#ecotone-l1-cost-fee-changes-eip-4844-da).
calculation. In more detail, these paramters can be accessed in two interchangable ways.

- read from the deposited L1 attributes (`operatorFeeScalar` and `operatorFeeConstant`) of the current L2 block
- read from the L1 Block Info contract (`0x4200000000000000000000000000000000000015`)
- using the respective solidity getter functions (`operatorFeeScalar`, `operatorFeeConstant`)
- using direct storage-reads:
- Operator fee scalar as big-endian `uint32` in slot `8` at offset `0`.
- Operator fee constant as big-endian `uint64` in slot `8` at offset `4`.

### Fee Vaults

These collected fees are sent to a new vault for the `operatorFee`: the [`OperatorFeeVault`](predeploys.md#operatorfeevault).

Like the existing vaults, this is a hardcoded address, pointing at a pre-deployed proxy contract.
The proxy is backed by a vault contract deployment, based on `FeeVault`, to route vault funds to L1 securely.
37 changes: 37 additions & 0 deletions specs/protocol/isthmus/l1-attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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 operator fee parameters.

| Input arg | Type | Calldata bytes | Segment |
| ----------------- | ------- | -------------- | ------- |
| {0x098999be} | | 0-3 | n/a |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the call signature for the function. Those 4 bytes are the first four bytes of keccak("setL1BlockValuesIsthmus()"). I'll clarify this in the spec.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump on adding this to the spec to make it clear what this is

| 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 |
| operatorFeeScalar | uint32 | 164-167 | 6 |
| operatorFeeConstant | uint64 | 168-175 | |

In the first L2 block after the Isthmus activation block, the Isthmus L1 attributes are first used.

The pre-Isthmus values are migrated over 1:1.
Blocks after the Isthmus activation block contain all pre-Isthmus values 1:1,
and also set the following new attributes:

- The `operatorFeeScalar` is set to `0`.
- The `operatorFeeConstant` is set to `0`.
7 changes: 7 additions & 0 deletions specs/protocol/isthmus/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ This document is not finalized and should be considered experimental.
## Execution Layer

- [L2ToL1MessagePasser Storage Root in Header](./exec-engine.md##l2tol1messagepasser-storage-root-in-header)
- [Operator Fee](./exec-engine.md#operator-fee)

## Consensus Layer

- [Isthmus Derivation](./derivation.md#isthmus-derivation)
- [Configurability](./configurability.md)

## Smart Contracts

- [SuperchainConfig](./superchain-config.md)
- [Predeploys](./predeploys.md)
- [L1 Block Attributes](./l1-attributes.md)
- [System Config](./system-config.md)
Loading