Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
imotai opened this issue Nov 6, 2022 · 1 comment
Closed

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

imotai opened this issue Nov 6, 2022 · 1 comment

Comments

@imotai
Copy link
Contributor

imotai commented Nov 6, 2022

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

@imotai imotai changed the title add gas system to db3 WIP: design the gas system for mutation and query session Nov 22, 2022
@imotai imotai changed the title WIP: design the gas system for mutation and query session WIP: Design the gas system for mutation and query session Nov 22, 2022
@imotai imotai changed the title WIP: Design the gas system for mutation and query session WIP: Propose the gas system for mutation and query session Nov 22, 2022
@imotai imotai pinned this issue Nov 28, 2022
@jingchen2222 jingchen2222 self-assigned this Dec 24, 2022
@jingchen2222
Copy link
Collaborator

jingchen2222 commented Dec 25, 2022

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

@imotai imotai unpinned this issue Feb 16, 2023
@imotai imotai closed this as completed Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants