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 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
62 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
c7cffb1
Update to getL1Fee;
yuwen01 Dec 4, 2024
0accd5f
revert getL1Fee() update
leruaa Dec 9, 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
7 changes: 7 additions & 0 deletions specs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
- [Predeploys](./protocol/holocene/predeploys.md)
- [L1 Block Attributes](./protocol/holocene/l1-attributes.md)
- [Configurability](./protocol/holocene/configurability.md)
- [Isthmus](./protocol/isthmus/overview.md)
- [Execution Engine](./protocol/isthmus/exec-engine.md)
- [L1 Block Attributes](./protocol/isthmus/l1-attributes.md)
- [Configurability](./protocol/isthmus/configurability.md)
- [Predeploys](./protocol/isthmus/predeploys.md)
- [System Config](./protocol/isthmus/system-config.md)

- [Governance]()
- [Governance Token](./governance/gov-token.md)
- [Experimental]()
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 @@ -58,7 +58,7 @@ The following `ConfigUpdate` enum is defined where the `CONFIG_VERSION` is `uint
| `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(_denominator)) << 32 \| uint64(_elasticity)` | Modifies the EIP-1559 denominator and elasticity |

### Initialization

Expand Down
24 changes: 24 additions & 0 deletions specs/protocol/isthmus/configurability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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**

- [`SystemConfig`](#systemconfig)
- [`ConfigUpdate`](#configupdate)

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

## `SystemConfig`

### `ConfigUpdate`

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

| 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(_configurablefeescalar) << 128 \| (uint256(_configurablefeeconstant) << 64 \| (uint256(_blobbasefeeScalar) << 32) \| _basefeeScalar` | Modifies the fee scalars |
yuwen01 marked this conversation as resolved.
Show resolved Hide resolved
| `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 |
45 changes: 45 additions & 0 deletions specs/protocol/isthmus/exec-engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# L2 Execution Engine

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

- [Fees](#fees)
- [Configurable fees](#configurable-fees)
- [Configuring scalars](#configuring-scalars)

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

## 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 `ConfigurableFee`, which is parameterized by two scalars: the `configurableFeeScalar`
and the `configurableFeeConstant`.
Copy link
Member

Choose a reason for hiding this comment

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

I find the use of the prefix "configurable" a bit meaningless for this feature. Other fee parameters, like the (blob)BaseFeeScalars are also "configurable". Maybe we use a prefix that better describes the reason for their introduction, like

  • OperatorFee
  • operatorFeeScalar
  • operatorFeeConstant
    or something similar that attaches more meaning to them? fixedFee... could also work.


### Configurable fees

The configurable fee is set as follows:

`configurableFee = gas_used * configurableFeeScalar + configurableFeeConstant`
Copy link
Member

Choose a reason for hiding this comment

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

So we don't need any fractional scaling, like we introduced with Fjord for the model parameters? I mean something like

Suggested change
`configurableFee = gas_used * configurableFeeScalar + configurableFeeConstant`
`configurableFee = (gas_used * configurableFeeScalar + configurableFeeConstant) / 1e6`

to allow for a decimal precision of 6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point -- it makes sense for users to be able to have fractional scalars. However, I don't know why a user would want to have a fractional constant. The only reason I can think would be to save bits -- see my other comment.


Where:

- `gas_used` is amount of gas used by the transaction.
- `configurableFeeScalar` is a `uint64` scalar set by the chain operator.
- `configurableFeeConstant` is a `uint64` scalar set by the chain operator.

These collected fees are sent to the `SequencerFeeVault`.

#### Configuring scalars

`configurableFeeScalar` and `configurableFeeConstant` 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 (`configurableFeeScalar` and `configurableFeeConstant`) of the current L2 block
- read from the L1 Block Info contract (`0x4200000000000000000000000000000000000015`)
- using the respective solidity getter functions (`configurableFeeScalar`, `configurableFeeConstant`)
- using direct storage-reads:
- Configurable fee scalar as big-endian `uint64` in slot `3` at offset `24`.
- Configurable fee constant as big-endian `uint64` in slot `3` at offset `16`.
40 changes: 40 additions & 0 deletions specs/protocol/isthmus/l1-attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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 and the extra scalars
for the `configurableFee`.

| 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 |
| eip1559Denominator | uint64 | 164-171 | 6 |
| eip1559Elasticity | uint64 | 172-179 | |
| configurableFeeScalar | uint64 | 180-187 | |
| configurableFeeConstant | uint64 | 188-195 | |
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want or need 64 bits instead of 32 bits size for the new parameters? E.g. the (blob)baseFeeScalars also worked with 32 bits (and also a decimal scaling factor, see other comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I agree with your point about renaming to operatorFee and allowing for 6 decimal points of precision, but I was a little unsure about reducing the bit width of the operatorFeeConstant and operatorFeeScalar.

I think it should be fine to decrease the Scalar to 32 bits, but I'm concerned that 32 bits won't be enough to represent the constant factor. For example, in this transaction https://optimistic.etherscan.io/tx/0xa6dfc18c35bf39fa60823e9280bde18496e27e9016040f7ad9ded6797c374f05, the total transaction fee in wei requires 43 bits to represent.

If we scale the constant term by a fixed factor we could fit it in 32 bits. But I don't know how much control a user might want over this constant.


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 `configurableFeeScalar` is set to `0`.
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want to set it to 1? Otherwise there's no fees any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The configurableFeeScalar is only scaled by the gas used -- it doesn't scale any of the existing fees. The goal is to add a separate component to the fee calculation, like base fee and priority fee.

- The `configurableFeeConstant` is set to `0`.
6 changes: 5 additions & 1 deletion specs/protocol/isthmus/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ This document is not finalized and should be considered experimental.

## Execution Layer

- [Configurable Fee](./exec-engine.md#fees)

## Consensus Layer

- [Interop](../interop/overview.md)
- [L1 Block Attributes](./l1-attributes.md)
- [Configurability](./configurability.md)
- [Interop](../../interop/overview.md)
36 changes: 36 additions & 0 deletions specs/protocol/isthmus/predeploys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Overview

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

- [Predeploys](#predeploys)
- [L1Block](#l1block)
- [Interface](#interface)
- [`setL1BlockValuesIsthmus`](#setl1blockvaluesisthmus)
- [`setIsthmus`](#setisthmus)

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

Since we now need to include the configurable fee scalars in the L1 Attri

## Predeploys

### L1Block

#### Interface

##### `setL1BlockValuesIsthmus`

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

```function
function setL1BlockValuesIsthmus()
```

##### `setIsthmus`

This function is meant to be called once on the activation block of the isthmus network upgrade.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

on second thought maybe this isn't necessary -- if we read the scalars from the l1block before isthmus is set, we'll just read from uninitialized storage, which defaults to 0. So the derived operator fee will just be 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is useful for the GasOracle predeploy that attempts to do L2 fee estimation

Copy link
Contributor

Choose a reason for hiding this comment

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

You can see here how we have handled this in the past. I believe we will need to include a calculation of the operator fee in the GasPriceOracle now

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.
39 changes: 39 additions & 0 deletions specs/protocol/isthmus/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)
- [Isthmus `scalar`, `overhead` (`uint256,uint256`) change](#isthmus-scalar-overhead-uint256uint256-change)

<!-- 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 `ConfigurableFeeScalar` and `ConfigurableFeeConstant`, a change to
the `scalar` and `overhead` encoding is necessary.

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

After Isthmus 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.
- `[8, 16)`: big-endian `uint64`, encoding the `configurableFeeScalar`
- `[16, 24)`: big-endian `uint64`, encoding the `configurableFeeConstant`
- `[24, 28)`: big-endian `uint32`, encoding the `blobBaseFeeScalar`
- `[28, 32)`: big-endian `uint32`, encoding the `baseFeeScalar`
- This version adds the `configurableFeeScalar` and the `configurableFeeConstant`.

The `configurableFeeScalar` and `configurableFeeConstant` are incorporated into the L2 through the
[Isthmus L1 attributes deposit transaction calldata](l1-attributes.md).