Menu

#123 WIP: Propose the gas system for mutation and query session

open
nobody
2022-12-26
2022-11-06
Anonymous
No

Originally created by: imotai
Originally owned by: jingchen2222

Key points

  • why we need gas fee
  • how much gas the mutation will cost
  • how much gas the query session will cost
  • the max gas per block - BlockGasMeter

Solution

Alternatives

Additional context

How did the others do

Discussion

  • Anonymous

    Anonymous - 2022-12-24
     
  • Anonymous

    Anonymous - 2022-12-25

    Originally posted by: jingchen2222

    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

     

Log in to post a comment.

MongoDB Logo MongoDB