GithubHelp home page GithubHelp logo

Comments (1)

jingchen2222 avatar jingchen2222 commented on July 18, 2024 1

Concept of Gas and Fee

Gas

The concept of Gas represents the amount of computational effort required to execute specific operations on the state machine.

Gas is used to track the resource usage of operations during the execution

GasMeter

GasMeter: keeps track of the gas consumed during executions that lead to state transitions. It is reset on every transaction execution.

BlockGasMeter

BlockGasMeter: keeps track of the gas consumed in a block and enforces that the gas does not go over a predefined limit. This limit is defined in the Tendermint consensus parameters and can be changed via governance parameter change proposals.

why we need gas fee

Gas is used to evaluate the estimation effort or resource required to execute transactions, including read, write and computation.

EIP Gas Fee Model

EIP 1599

https://eips.ethereum.org/EIPS/eip-1559

  • Basefee
  • Capacity
  • Miner tip

image

How to estimate gas for mutation and query

In this section, we are looking into ways to evaluate mutation and query.

https://ethereum.org/en/developers/docs/evm/opcodes/

Mutation gas

Regarding mutation, we are considering proposing a gas formula as shown below:

Mutation_(gas) = kvs_len * COMPUTAION_GAS_PRICE  + data_bytes * STORAGE_GAS_PRICE

Query gas

KVQuert_(gas) = kv_query_count * COMPUTAION_GAS_PRICE

BlockGasMeter

It is necessary to set up a limit on the maximum gas for each block so that we can guarantee every node can finish the execution with the given minimum configuration.

Block Gas Check

  • Configurate BlockGasLimit based on the given configuration

  • Put block_gas into BlockState
  • Verify block_gas < BlockGasLimit inside check_tx

Reference

from db3.

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.