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

feat(cheatcodes): adding an L1 data fee estimation method similar to vm.lastCallGas #9514

Open
St0rmBr3w opened this issue Dec 7, 2024 · 2 comments
Labels
A-cheatcodes Area: cheatcodes T-feature Type: feature

Comments

@St0rmBr3w
Copy link

St0rmBr3w commented Dec 7, 2024

Component

Forge

Describe the feature you would like

Currently, Foundry’s vm.lastCallGas() provides developers with the amount of gas used in the last call from the callee’s perspective.

This works well for L1 or pure L2 execution gas, but does not incorporate the L1 data fee that certain L2 environments impose when posting call data to their underlying L1 for data availability and finality.

As a result, when testing complex cross-chain calls, developers must manually compute or approximate the L1 data fee portion from external data sources or heuristics.

The problem is that in many L2 ecosystems (e.g., OP Stack rollups, Arbitrum Orbit chains, zkSync Elastic, Linea), a portion of the transaction’s total cost is determined by how much data must be posted back to L1. This L1 data fee isn’t reflected in the raw L2 execution gas usage that vm.lastCallGas() reports.

Ideally, it would be great to have a built-in Foundry feature that:

  1. Identifies the chain model type (OP-like, Arbitrum-like, etc.) from the current fork configuration, or allows specifying it.
  2. Retrieves relevant parameters (like L1 gasPrice, gasPerL1Byte, overhead constants, etc.) from known on-chain contracts or a standardized mapping.
  3. Calculates the approximate L1 data fee based on the transaction’s input size and the chain’s known formula.

Having a standard cheatcode, say vm.lastCallL1DataFee() or an extended structure returned by vm.lastCallGas() that includes an L1 fee estimate, would simplify this process.

In essence, this feature would extend Foundry’s goal of providing realistic, in-depth EVM testing to also cover a crucial part of the L2 cost model: the L1 data fee.

Additional context

No response

@St0rmBr3w St0rmBr3w added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Dec 7, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Dec 7, 2024
@grandizzy
Copy link
Collaborator

somehow related to #7514 (comment)

@mattsse
Copy link
Member

mattsse commented Dec 9, 2024

we have L1 gas/fee functions available in op-alloy for optimism, so we could add integrate them if we find a nice way of doing this

@zerosnacks zerosnacks changed the title Adding an L1 Data Fee Estimation Method Similar to vm.lastCallGas feat(cheatcodes): adding an L1 data fee estimation method similar to vm.lastCallGas Dec 13, 2024
@zerosnacks zerosnacks added A-cheatcodes Area: cheatcodes and removed T-needs-triage Type: this issue needs to be labelled labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes T-feature Type: feature
Projects
Status: Todo
Development

No branches or pull requests

4 participants