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

holocene: operator fee #382

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 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
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
2 changes: 2 additions & 0 deletions specs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
- [Predeploys](./protocol/holocene/predeploys.md)
- [L1 Block Attributes](./protocol/holocene/l1-attributes.md)
- [Configurability](./protocol/holocene/configurability.md)
- [System Config](./protocol/holocene/system-config.md)

- [Governance]()
- [Governance Token](./governance/gov-token.md)
- [Experimental]()
Expand Down
1 change: 0 additions & 1 deletion specs/experimental/op-contracts-manager.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# OP Contracts Manager

[`op-contracts/v1.4.0`]: https://github.com/ethereum-optimism/optimism/releases/tag/op-contracts%2Fv1.6.0
[Optimism Monorepo releases]: https://github.com/ethereum-optimism/optimism/releases
[contract releases]: https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/VERSIONING.md
[standard configuration]: ../protocol/configurability.md
Expand Down
8 changes: 4 additions & 4 deletions specs/protocol/configurability.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ existing [permissioned dispute games](../fault-proof/stage-one/bridge-integratio
[^of-gnosis-safe-l1]<br/>
**Notes:** Optimism Foundation (OF) multisig
leveraging [battle-tested software](https://github.com/safe-global/safe-smart-account). This role is only active when
the `OptimismPortal` respected game type is [
`PERMISSIONED_CANNON`](https://github.com/ethereum-optimism/optimism/blob/op-contracts/v1.5.0/packages/contracts-bedrock/src/dispute/lib/Types.sol#L31).<br/>
the `OptimismPortal` respected game type is [`PERMISSIONED_CANNON`]
(<https://github.com/ethereum-optimism/optimism/blob/op-contracts/v1.5.0/packages/contracts-bedrock/src/dispute/lib/Types.sol#L31>).<br/>

### [Guardian address](https://github.com/ethereum-optimism/optimism/blob/c927ed9e8af501fd330349607a2b09a876a9a1fb/packages/contracts-bedrock/src/L1/SuperchainConfig.sol#L50)

Expand All @@ -429,8 +429,8 @@ with [permissioned dispute games](../fault-proof/stage-one/bridge-integration.md
L1.<br/>
**Administrator:** [L1 Proxy Admin](#admin-roles)<br/>
**Requirement:** No requirement<br/>
**Notes:** This role is only active when the `OptimismPortal` respected game type is [
`PERMISSIONED_CANNON`](https://github.com/ethereum-optimism/optimism/blob/op-contracts/v1.5.0/packages/contracts-bedrock/src/dispute/lib/Types.sol#L31).
**Notes:** This role is only active when the `OptimismPortal` respected game type is [`PERMISSIONED_CANNON`]
(<https://github.com/ethereum-optimism/optimism/blob/op-contracts/v1.5.0/packages/contracts-bedrock/src/dispute/lib/Types.sol#L31>).
The `L1ProxyAdmin` sets the implementation of the `PERMISSIONED_CANNON` game type. Thus, it determines the proposer
configuration of the permissioned dispute game.<br/>

Expand Down
2 changes: 1 addition & 1 deletion specs/protocol/holocene/configurability.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The following `ConfigUpdate` enum is defined where the `CONFIG_VERSION` is `uint
| 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)` | `(uint256(0x01) << 248) \| (uint256(_operatorFeeScalar) << 108 \| (uint256(_operatorFeeConstant) << 96 \| (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 |
Expand Down
2 changes: 2 additions & 0 deletions specs/protocol/holocene/derivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,7 @@ The Holocene hardfork activation block contains the following transactions, in t
- L1Block deployment
- Update L1Block Proxy ERC-1967 Implementation
- L1Block Enable Holocene
- GasPriceOracle deployment
- Update GasPriceOracle Proxy ERC-1967 Implementation
- OptimismMintableERC20Factory deployment
- Update OptimismMintableERC20Factory Proxy ERC-1967 Implementation
37 changes: 37 additions & 0 deletions specs/protocol/holocene/exec-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
- [Rationale](#rationale)
- [Forwards Compatibility Considerations](#forwards-compatibility-considerations)
- [Client Implementation Considerations](#client-implementation-considerations)
- [Fees](#fees)
- [Operator fees](#operator-fees)
- [Configuring scalars](#configuring-scalars)

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

Expand Down Expand Up @@ -75,3 +78,37 @@ directly store this information.

[l2-to-l1-mp]: ../../protocol/predeploys.md#L2ToL1MessagePasser
[output-root]: ../../glossary.md#l2-output-root

## Fees

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

### Operator fees

The operator fee, in wei, 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.

These collected fees are sent to the `SequencerFeeVault`.

#### Configuring scalars

`operatorFeeScalar` and `operatorFeeConstant` are loaded in a similar way to the `baseFeeScalar` and
`blobBaseFeeScalar` used in the [`L1Fee`](../../protocol/exec-engine.md#ecotone-l1-cost-fee-changes-eip-4844-da).
calculation. In more detail, these scalars 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 `3` at offset `20`.
- Operator fee constant as big-endian `uint64` in slot `3` at offset `16`.
11 changes: 11 additions & 0 deletions specs/protocol/holocene/l1-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ The L1 block attributes transaction is updated to include the EIP-1559 parameter
| batcherHash | bytes32 | 132-163 | 5 |
| eip1559Denominator | uint64 | 164-171 | 6 |
| eip1559Elasticity | uint64 | 172-179 | |
| operatorFeeScalar | uint32 | 180-183 | |
| operatorFeeConstant | uint64 | 184-191 | |

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

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

- The `operatorFeeScalar` is set to `0`.
- The `operatorFeeConstant` is set to `0`.
1 change: 1 addition & 0 deletions specs/protocol/holocene/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ This document is not finalized and should be considered experimental.
- [Predeploys](./predeploys.md)
- [L1 Block Attributes](./l1-attributes.md)
- [Configurability](./configurability.md)
- [System Config](./system-config.md)
18 changes: 18 additions & 0 deletions specs/protocol/holocene/predeploys.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
- [Interface](#interface-3)
- [L2StandardBridge](#l2standardbridge)
- [Interface](#interface-4)
- [GasPriceOracle](#gaspriceoracle)
- [Interface](#interface-5)
- [`getOperatorFee`](#getoperatorfee)
- [OptimismMintableERC721Factory](#optimismmintableerc721factory)
- [Security Considerations](#security-considerations)
- [GovernanceToken](#governancetoken)
Expand Down Expand Up @@ -255,6 +258,21 @@ The following functions are updated to read from the `L1Block` contract by calli
- `otherBridge()(address)`
- `OTHER_BRIDGE()(address)`

### GasPriceOracle

In order to maintain accurate offchain fee estimation, the `GasPriceOracle` must be updated to allow users
to estimate the operator fee.

#### Interface

##### `getOperatorFee`

This function calculates the operator fee based on the expected amount of gas used for a certain transaction.

```function
function getOperatorFee(uint256 gasUsed)(uint256)
```

Copy link
Contributor

Choose a reason for hiding this comment

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

We will also need an isHolocene bool as well as branching logic in the fee estimation functions

### OptimismMintableERC721Factory

The chain id is no longer read from storage but instead is read from the `L1Block` contract by calling
Expand Down
39 changes: 39 additions & 0 deletions specs/protocol/holocene/system-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# System Config

<!-- 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**

- [System config contents (version 0)](#system-config-contents-version-0)
- [Scalars](#scalars)
- [Holocene `scalar`, `overhead` (`uint256,uint256`) change](#holocene-scalar-overhead-uint256uint256-change)

Copy link
Contributor

Choose a reason for hiding this comment

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

We will also want to include the specific ABI changes to the SystemConfig

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

## System config contents (version 0)

### Scalars

In order to allow rollup operators to adjust the new `operatorFeeScalar` and `operatorFeeConstant`, a change to
the `scalar` and `overhead` encoding is necessary.

#### Holocene `scalar`, `overhead` (`uint256,uint256`) change

After Holocene activation:

- A new version to the `scalar` encoding is added. It is described as follows.

\*Byte ranges are indicated with `[` (inclusive) and `)` (exclusive).

- `0`: scalar-version byte
- `[1, 32)`: depending scalar-version:
- Scalar-version `2`:
- `[1, 8)`: padding, must be zero.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this should be padded to the start of the operatorFeeScalar.

i.e.

Suggested change
- `[1, 8)`: padding, must be zero.
- `[1, 12)`: padding, must be zero.

- `[12, 16)`: big-endian `uint32`, encoding the `operatorFeeScalar`
- `[16, 24)`: big-endian `uint64`, encoding the `operatorFeeConstant`
- `[24, 28)`: big-endian `uint32`, encoding the `blobBaseFeeScalar`
- `[28, 32)`: big-endian `uint32`, encoding the `baseFeeScalar`
- This version adds the `operatorFeeScalar` and the `operatorFeeConstant`.

The `operatorFeeScalar` and `operatorFeeConstant` are incorporated into the L2 through the
[Holocene L1 attributes deposit transaction calldata](l1-attributes.md).