Skip to content

Commit

Permalink
fix typos and errors in examples (#2471)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadkaouk authored Oct 6, 2023
1 parent 2ed75af commit a861fc2
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions MBIPS/MBIP-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,41 @@ created: 2023-05-11

## Simple Summary

Increases the used gas based on storage increase in transaction to deal with storage congestion.
Increases the gas used based on storage increase in transactions to deal with storage congestion.

## Abstract

Introduce a new mechanism when executing a transaction that will increase the gas used when
a transaction increases the storage stage.
Introduce a new mechanism for executing transactions that increases the gas used when
the transaction increases the storage state.

## Motivation

Moonbeam chain state needs to be sustainable for collators and archive nodes. With its current
fee mechanism, it doesn't account sufficiently for new storage data being added.
The Moonbeam chain state needs to be sustainable for collators and archive nodes. The current
fee mechanism does not adequately account for new storage data being added.

## Specification

A block will have a limit of 40_000 bytes of storage growth.
A block will have a storage growth limit of 40,960 bytes.

A transaction increasing the state by `X bytes` will consume `X * 15_000_000 / 40_000` additional
gas.
A transaction that increases the state by `X` bytes will consume `X * 15,000,000 / 40,960` gas.

## Comments

Considering the baseFee is only increasing when the block has 25% or more gas consumed, it is
possible to `25% * 40kB * 2628000 blocks => 26.2GB`
Considering that the base fee only increases when the block has consumed 25% or more gas, it is
possible to have `25% * 40KB * 2,628,000 blocks => 25.06 GB`.

### Example

Deploying a Smart Contract of 24kB using 3_300_000 gas would require:
`24_000 * 15_000_000 / 40_000 + 3_300_000 => 12_300_000 gas`
Deploying a smart contract with 20kB of bytecode stored on the chain would require:
`20KB * 15,000,000 / 40KB => 7,500,000 gas`

Execution of a transaction using 48_000 gas and adding 3 storage items (444 bytes) would require:
`444 * 15_000_000 / 40_000 + 48_000 => 214_500 gas`
Executing a transaction that adds 3 storage items (116 bytes) would require:
`348 * 15,000,000 / 40,906 => 127,609 gas`

## Impact

Increase the gas being used in the block, even if the computational part stays the same.
This can lead to blocks being full because of the storage being used without any computation at all.
Increase the gas used in the block, even if the computational part remains the same.
This can lead to blocks being full due to storage usage without any computation.

This will cause smart contracts which assume fixed gas limit on subcall to fail. Those are however
rare.
This may cause smart contracts that assume a fixed gas limit on subcalls to fail. However, such
cases are rare.

0 comments on commit a861fc2

Please sign in to comment.