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

Merge 2.1.2 and 2.1.3 release changes #2204

Merged
merged 10 commits into from
Aug 12, 2024
Prev Previous commit
Next Next commit
Add note about module serialization version to cost function
chipshort committed Aug 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit df673aa72e1eea9b3dfe1996bc0f78083d6db697
4 changes: 4 additions & 0 deletions packages/vm/src/wasm_backend/engine.rs
Original file line number Diff line number Diff line change
@@ -23,6 +23,10 @@ fn cost(operator: &Operator) -> u64 {
// In https://github.com/CosmWasm/cosmwasm/pull/1042 a profiler is developed to
// identify runtime differences between different Wasm operation, but this is not yet
// precise enough to derive insights from it.
//
// Please note that any changes to this function need to be accompanied by a bump of
// `MODULE_SERIALIZATION_VERSION` to avoid cached modules from using different amounts of gas
// compared to newly compiled ones.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Now I was wondering if/how we can turn this function into something we can hash and add to the caching path. Either by serializing the function (some scripting language) or serialize the op -> cost as a table/map. Could you create a ticket for that as mid or long-term improvement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also wondering if we can test the cache compatibility by having a test with a cache folder with one wasm + module file inside and testing that it can be executed and works as expected (same gas, etc.).
That would probably catch some panics on the wasmer side and if we assert gas, also gas cost changes.

const GAS_PER_OPERATION: u64 = 115;

match operator {