-
Notifications
You must be signed in to change notification settings - Fork 346
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
Introduce a gas-based storage limit [MBIP-5] #2452
Conversation
Coverage generated "Tue Aug 29 23:23:22 UTC 2023": Master coverage: 87.39% |
test/suites/dev/test-storage-growth/test-evm-create-storage-growth.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Agustín Rodriguez <agus@moonsonglabs.com>
…owth.ts Co-authored-by: Agustín Rodriguez <agus@moonsonglabs.com>
test/suites/dev/test-storage-growth/test-tx-pool-storage-growth.ts
Outdated
Show resolved
Hide resolved
test/suites/dev/test-storage-growth/test-tx-pool-storage-growth.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please wait for a review from @librelois or @notlesh before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Co-authored-by: Éloïs <c@elo.tf>
@@ -58,9 +62,10 @@ where | |||
Runtime::RuntimeCall: Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo, | |||
{ | |||
#[inline(always)] | |||
pub fn record_weight_v2_cost( | |||
pub fn reocrd_external_cost( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in function
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-evm
that sets the ratio of gas to storage growth, defaulting to 366.storage_growth: Option<u64>
has been added to thetry_dispatch
function 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: