feat(cheatcodes
): adding an L1 data fee estimation method similar to vm.lastCallGas
#9514
Labels
cheatcodes
): adding an L1 data fee estimation method similar to vm.lastCallGas
#9514
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:
gasPrice
,gasPerL1Byte
, overhead constants, etc.) from known on-chain contracts or a standardized mapping.Having a standard cheatcode, say
vm.lastCallL1DataFee()
or an extended structure returned byvm.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
The text was updated successfully, but these errors were encountered: