Closed andrewshvv closed 6 months ago
Yes, that looks right to me.
As a practical matter this tool is usually run with HardhatEVM or ganache-cli (both ethereumjs-vm based) It would nice to know if gasUsedL2 on an optimism vm is reasonably similar to what is used on an L1 ethereum vm.
Do you know if that's the case?
Cross-linking relevant issue at hardhat-gas-reporter
https://github.com/cgewecke/hardhat-gas-reporter/issues/78
Will think a little bit about how this should be done....if we take the simplest approach and don't worry about representing the different layer costs in the table, most of the code changes would be in this file where the utilities to fetch and calculate gasPrices are:
https://github.com/cgewecke/eth-gas-reporter/blob/master/lib/utils.js
Cool, glad to hear that!
It would nice to know if gasUsedL2 on an optimism vm is reasonably similar to what is used on an L1 ethereum VM. Do you know if that's the case?
By reading this it seems so https://research.paradigm.xyz/optimism But I will take a deeper dive in a couple of days.
Cross-linking relevant issue at hardhat-gas-reporter
Yeah, hardhat-gas-reporter
is what I am actually using.
https://github.com/cgewecke/eth-gas-reporter/blob/master/lib/utils.js
Alright, I will take a look in utils.js, optimism rpc node documentation, ethereumjs-vm docs.
(in progress, will update with time)
Optimism research:
eth-gas-reporter research:
Open questions:
FYI, we just updated the Optimism docs to give more information about how to accurately estimate the current L1 data cost for a given transaction: https://community.optimism.io/docs/developers/build/transaction-fees/#estimating-the-l1-data-fee
When computing the total cost for a transaction on Optimism you need to account for two things, the L2 "execution" fee and the L1 "data" fee.
The L2 execution fee can be computed with the standard formula of provider.estimateGas(tx) * provider.getGasPrice()
.
The L1 data fee can be most easily estimated by making a query to OVM_GasPriceOracle.getL1Fee(serialize(tx))
.
First calculation:
this was implemented?
@math77 nah, sorry, never got it working properly I ended up rewriting too much, and got stuck introducing new bugs It is open for anyone to take
Hi! eth-gas-reporter
is being deprecated in favor of hardhat-gas-reporter
.
In the latest version at Hardhat, Optimism Ecotone l1GasUsed and total cost are available by setting the L2
option to "optimism". The reporter synthesizes these costs locally so there's no performance hit for collecting this data while running your tests.
https://github.com/cgewecke/hardhat-gas-reporter/releases/tag/v2.0.0
@cgewecke
Hey, pretty new in web3 space, I am wondering - can the eth-gas-reporter support Optimism?
I am not familiar with eth-gas-reporter internals and thought that maybe you can give me initial guidance on what kind of changes are necessary to make it work and the place where to start looking?
Depending on the work required I may try to implement it.
From an initial naive glance it seems we need:
gasPrice
ongasPriceL1
, andgasPriceL2
.gasUsed
ongasUsedL1
, andgasUsedL2
.gasPriceL1
andgasUsedL1
.gasPriceL2
andgasUsedL2
.About Optimism fees: https://community.optimism.io/docs/developers/l2/new-fees.html#frontmatter-title