Coder Social home page Coder Social logo

Comments (10)

andrewshvv avatar andrewshvv commented on July 27, 2024 8

First calculation:
Screen Shot 2022-01-24 at 6 29 43 AM

from eth-gas-reporter.

smartcontracts avatar smartcontracts commented on July 27, 2024 4

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

from eth-gas-reporter.

smartcontracts avatar smartcontracts commented on July 27, 2024 3

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)).

from eth-gas-reporter.

andrewshvv avatar andrewshvv commented on July 27, 2024 2

(in progress, will update with time)

Optimism research:

eth-gas-reporter research:

Open questions:

  • Is estimation is sufficient or do we need to get the actual gas cost?
  • What is required to get the actual L1 gas cost on Optimism?
  • How exactly injectL2Context function works in Optimism? Do we need to replicate it in sync rpc?

from eth-gas-reporter.

cgewecke avatar cgewecke commented on July 27, 2024

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?

from eth-gas-reporter.

cgewecke avatar cgewecke commented on July 27, 2024

Cross-linking relevant issue at hardhat-gas-reporter

cgewecke/hardhat-gas-reporter#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

from eth-gas-reporter.

andrewshvv avatar andrewshvv commented on July 27, 2024

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.

from eth-gas-reporter.

math77 avatar math77 commented on July 27, 2024

this was implemented?

from eth-gas-reporter.

andrewshvv avatar andrewshvv commented on July 27, 2024

@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

from eth-gas-reporter.

cgewecke avatar cgewecke commented on July 27, 2024

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

from eth-gas-reporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.