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 51 commits into
base: main
Choose a base branch
from

Conversation

yuwen01
Copy link
Contributor

@yuwen01 yuwen01 commented Sep 20, 2024

Overview

We propose adding additional fee scalars to the fee formula, which allow for more flexibility for chains that leverage alt-DA, ZK proving, or custom gas tokens.

This spec goes with this design doc.

@yuwen01 yuwen01 marked this pull request as ready for review September 20, 2024 06:01
Copy link
Member

@sebastianst sebastianst left a comment

Choose a reason for hiding this comment

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

Also curious to hear from @tynes and @roberto-bayardo, who's implemented changes to the fee function in Fjord.

I propose to use a prefix for this feature that conveys more meaning, like OperatorFee or FixedFee.

specs/protocol/isthmus/configurability.md Outdated Show resolved Hide resolved
Comment on lines 17 to 18
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.

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 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.

Comment on lines 30 to 31
| 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.

@yuwen01 yuwen01 changed the title isthmus: add operator fee scalars holocene: operator fee Sep 30, 2024
```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

- [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

Copy link
Contributor

@refcell refcell left a comment

Choose a reason for hiding this comment

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

Nice work.

- `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.

@yuwen01 yuwen01 changed the title holocene: operator fee isthmus: operator fee Oct 3, 2024
@yuwen01 yuwen01 marked this pull request as draft October 3, 2024 18:11

##### `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.

@yuwen01 yuwen01 marked this pull request as ready for review October 3, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants