Description
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:
- Identifies the chain model type (OP-like, Arbitrum-like, etc.) from the current fork configuration, or allows specifying it.
- Retrieves relevant parameters (like L1
gasPrice
,gasPerL1Byte
, overhead constants, etc.) from known on-chain contracts or a standardized mapping. - 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
Metadata
Metadata
Assignees
Type
Projects
Status