Introduce a gas-based storage limit [MBIP-5]#2452
Merged
ahmadkaouk merged 26 commits intomasterfrom Aug 30, 2023
Merged
Conversation
crystalin
reviewed
Aug 25, 2023
Contributor
|
Coverage generated "Tue Aug 29 23:23:22 UTC 2023": Master coverage: 87.39% |
Agusrodri
reviewed
Aug 29, 2023
Co-authored-by: Agustín Rodriguez <agus@moonsonglabs.com>
Agusrodri
reviewed
Aug 29, 2023
…owth.ts Co-authored-by: Agustín Rodriguez <agus@moonsonglabs.com>
crystalin
requested changes
Aug 29, 2023
crystalin
approved these changes
Aug 29, 2023
Collaborator
crystalin
left a comment
There was a problem hiding this comment.
please wait for a review from @librelois or @notlesh before merging
notlesh
approved these changes
Aug 29, 2023
Contributor
notlesh
left a comment
There was a problem hiding this comment.
Looks good 🎉
Ideally we could see some test coverage that shows this is properly disabled for moonriver and moonbeam (or a test showing that a ratio of 0 does indeed disable the feature). However, I can clearly see here that it should work as intended.
librelois
reviewed
Aug 29, 2023
librelois
reviewed
Aug 29, 2023
Co-authored-by: Éloïs <c@elo.tf>
| { | ||
| #[inline(always)] | ||
| pub fn record_weight_v2_cost( | ||
| pub fn reocrd_external_cost( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduction
This PR implements a new mechanism as detailed in MBIP-5. The aim is to manage the unsustainable storage growth of the state by setting a block storage limit and increasing gas usage when a transaction results in an increase in storage state. Key features include:
This feature only enabled on Moonbase.
Example
Given:
BLOCK_GAS_LIMIT= 15,000,000 (Maximum gas per block)BLOCK_STORAGE_LIMIT= 40 * 1024 bytes (40 KB per block)The ratio between gas and storage is calculated as:
RATIO= 15,000,000 / (40 * 1024) ≈ 366Deploying a Smart Contract of 24 kB will cost:
GAS_COST= 24 * 1024 * 366 = 8,994,816Executing a transaction that increases the storage by 500 bytes will cost:
GAS_COST= 500 * 366 = 183,000Runtime Changes
pallet-evmthat sets the ratio of gas to storage growth, defaulting to 366.storage_growth: Option<u64>has been added to thetry_dispatchfunction to record the storage increase.Despite these changes, gas estimation will continue to function as intended, incorporating the new storage-related gas costs in their calculations.
Relevant PRs: