-
Notifications
You must be signed in to change notification settings - Fork 331
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
Extract Storage Read costs for dev tests involved in #2786 #2915
Conversation
Coverage Report@@ Coverage Diff @@
## master pablo/extract-test-constants +/- ##
===============================================================
Coverage 80.93% 80.93% 0.00%
Files 284 284
Lines 81724 81724
===============================================================
Hits 66136 66136
Misses 15588 15588
|
test/helpers/constants.ts
Outdated
@@ -77,6 +77,9 @@ export const RUNTIME_CONSTANTS = { | |||
EXTRINSIC_GAS_LIMIT: 52_000_000n, | |||
// Maximum Gas to PoV ratio used in the gasometer | |||
GAS_PER_POV_BYTES: 16n, | |||
// Storage read/write costs | |||
STORAGE_READ_COST: 41_742_000n, | |||
STORAGE_READ_GAS_COST: 1669n, |
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.
I am not sure about this value. From where did you extract it?
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.
It is mainly based on the changes to the rust tests on #2786, which I might be misreading. There, several precompiles tests changed their estimated gas cost from 1000 to 1669 and other worked with doubled values.
Will do some more research on them to see if we can keep the extracted constant (even if the value needs to change), but we could remove it for the purpose of this PR and only have 1 test affected; not that impactful.
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.
I think we should only keep STORAGE_READ_COST
for now since it is a known constant.
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.
Giving it a another look, the 1669
updates present in #2786 refer exactly to STORAGE_READ_COST / WEIGHT_TO_GAS_RATIO
(47_000_000 / 25_000). This confirms it is the DB read cost. I'll update so we can keep STORAGE_READ_GAS_COST
and use it in a way that it is relative to the STORAGE_READ_COST
.
WASM runtime size check:Compared to target branchMoonbase runtime: 2168 KB (no changes) ✅ Moonbeam runtime: 2116 KB (no changes) ✅ Moonriver runtime: 2116 KB (no changes) ✅ Compared to latest release (runtime-3100)Moonbase runtime: 2168 KB (+152 KB compared to latest release) Moonbeam runtime: 2116 KB (+140 KB compared to latest release) Moonriver runtime: 2116 KB (+148 KB compared to latest release) |
* add: storage read cost constant * update test-pov * update xcm-v3 tests * update xcm-v4 tests * add storage read gas cost to constants * update test-precompile * load constant in beforeAll * replace gas cost with weight to gas ratio
What does it do?
This PR extracts two
moonbase
constants used in several dev-tests involved in PR #2786 in order to ease future changes. Constants extracted are now included inhelpers/constants.ts
and exposed via theConstantStore
fn:Only tests changed in #2786 were updated to use the new constants.
What important points reviewers should know?
Constants were extracted by identifying which tests had changes in #2786 to expected values related to either
41_742_000n
or1669n
, which reference Storage Read weight and gas cost. Expected values had the Storage costs deducted and then added using the new constants.Tests which already used named variables for the Storage read costs only had the local variable removed in favor of importing it through the
ConstantStore
.One of the more obscure extractions is in
test/suites/dev/moonbase/test-precompile/test-precompile-batch.ts
. The used gas changes in #2786 match the changes from1000
to1669
reflected in rust-tests. This led to the extraction of the Storage Read gas cost into a new constant.Is there something left for follow-up PRs?
What alternative implementations were considered?
Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?
What value does it bring to the blockchain users?