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

VRFV2Plus L1 fee calculation updates for Optimism and Base #13335

Merged
merged 45 commits into from
Jul 8, 2024

Conversation

ibrajer
Copy link
Contributor

@ibrajer ibrajer commented May 27, 2024

Motivation

Optimism provides a way of calculating L1 gas fees via a predeploy OracleGasPrice contract. Gas usage of this gas calculation function is too high. This is an attempt to reduce the cost for the customer, but also to provide several options to calculate L1 gas fees in the future (after the Fjord upgrade).

Overview of changes

The most major change for Optimism is incorporating three different versions of L1 fee calculation:

  • using the getL1Fee function on predeploy OracleGasPrice contract (the most accurate one, but gas expensive)
  • using getL1FeeUpperBound gas cost approximation on predeploy OracleGasPrice contract (upper bound calculation available after Fjord upgrade), this is used with having a pricing coefficient in mind to reduce overcharging
  • using our estimation built on top of the getL1Fee calculation for Ecotone (with average payload data layout taken into account), this is used with having a pricing coefficient in mind to reduce overcharging

The changes above inspired (and forced) some other necessary changes to existing contracts:

  • extracted L1 fee calculation away from the VRFCoordinatorV2_5 and VRFV2PlusWrapper contract to separate abstract contracts OptimismL1Fees and AbritrumL1Fees
  • combining L1 fee calculations necessary for the VRFV2PlusWrapper contract in a new single VRFV2PlusWrapperL1Fees contract (replacing ChainSpecificUtil used before), abstracting this calculation away from the VRFV2PlusWrapper
  • created new coordinator contracts specific for Optimism and Arbitrum (with L1 fee calculation and other L2 opcode specifics on top of the base VRFCoordinatorV2_5 contract)
  • applied several Coordinator contract size optimizations according to this branch so that VRFCoordinatorV2_5_Optimism doesn't break the contract size limit (thanks to @leeyikjiun)
  • recalibrated padding size on Optimism and resolved incorrect padding issues (thanks to @jinhoonbang)

contracts/src/v0.8/ChainSpecificUtil.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/vrf/dev/VRFV2PlusWrapper.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/vrf/dev/VRFV2PlusWrapper.sol Outdated Show resolved Hide resolved
@ibrajer ibrajer changed the title VRFV2Plus wrapper L1 fee calculation updates for Optimism and Base VRFV2Plus L1 fee calculation updates for Optimism and Base Jun 5, 2024
@cl-sonarqube-production
Copy link

@ibrajer ibrajer added this pull request to the merge queue Jul 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 3, 2024
@ibrajer ibrajer added this pull request to the merge queue Jul 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 4, 2024
@ibrajer ibrajer added this pull request to the merge queue Jul 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 4, 2024
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.

5 participants