From d3de1db4c55e89815462b95e024a01ef95836e60 Mon Sep 17 00:00:00 2001 From: JianGuo Date: Thu, 25 Jan 2024 10:01:10 +0800 Subject: [PATCH] Fix wasm bug (#56) * fix wasm bug * update --- CHANGELOG.md | 2 + Cargo.lock | 16 +++--- contracts/burner/Cargo.lock | 12 ++--- contracts/crypto-verify/Cargo.lock | 12 ++--- contracts/cyberpunk/Cargo.lock | 12 ++--- contracts/floaty/Cargo.lock | 12 ++--- contracts/hackatom/Cargo.lock | 12 ++--- contracts/ibc-reflect-send/Cargo.lock | 12 ++--- contracts/ibc-reflect/Cargo.lock | 12 ++--- contracts/queue/Cargo.lock | 12 ++--- contracts/reflect/Cargo.lock | 12 ++--- contracts/staking/Cargo.lock | 12 ++--- contracts/virus/Cargo.lock | 12 ++--- docs/CAPABILITIES-BUILT-IN.md | 2 +- packages/check/Cargo.toml | 6 +-- packages/crypto/Cargo.toml | 2 +- packages/derive/Cargo.toml | 2 +- packages/schema-derive/Cargo.toml | 2 +- packages/schema/Cargo.toml | 6 +-- packages/std/Cargo.toml | 8 +-- packages/storage/Cargo.toml | 4 +- packages/vm/Cargo.toml | 6 +-- packages/vm/src/compatibility.rs | 54 +++++++++++++++++++- packages/vm/src/modules/file_system_cache.rs | 10 ++-- 24 files changed, 155 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0608ca69e1..b5e409a849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.3.1] - 2024-01-15 + ## [1.3.0] - 2023-08-24 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index f5d617efa0..8f7192087b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -417,7 +417,7 @@ dependencies = [ [[package]] name = "cosmwasm-check" -version = "1.3.0" +version = "1.3.1" dependencies = [ "anyhow", "assert_cmd", @@ -430,7 +430,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "criterion", @@ -449,7 +449,7 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-std", "syn 1.0.109", @@ -457,7 +457,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "anyhow", "cosmwasm-schema-derive", @@ -472,7 +472,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -481,7 +481,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -503,7 +503,7 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-std", "serde", @@ -511,7 +511,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 8e5dc9aba7..c9768e70da 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -193,7 +193,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -204,14 +204,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -222,7 +222,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -231,7 +231,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -249,7 +249,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 8fe3c3b231..9bf71100d9 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index b5c0b4ec3b..a65d507e3b 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -222,14 +222,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -240,7 +240,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -249,7 +249,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -267,7 +267,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 92b19c33ab..45cc4ca444 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index fa745cfa4f..cd8e9089f6 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index d48fccc9aa..a9bc4eac90 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 844282d14f..ae4c0c4d50 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 6f28d16340..33f37b6592 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index fcd335dd5f..06edf32f00 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 1f8eb40d03..27611862a7 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 9e3e0dff33..7ba215129e 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -193,14 +193,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" dependencies = [ "proc-macro2", "quote", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64", "bnum", @@ -238,7 +238,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" dependencies = [ "bitflags", "bytecheck", diff --git a/docs/CAPABILITIES-BUILT-IN.md b/docs/CAPABILITIES-BUILT-IN.md index 2f2268e4e7..38ea85048b 100644 --- a/docs/CAPABILITIES-BUILT-IN.md +++ b/docs/CAPABILITIES-BUILT-IN.md @@ -18,4 +18,4 @@ might define others. - `cosmwasm_1_3` enables the `BankQuery::AllDenomMetadata`, `BankQuery::DenomMetadata` and `DistributionQuery::DelegatorWithdrawAddress` queries, as well as `DistributionMsg::FundCommunityPool`. Only chains running - CosmWasm `1.3.0` or higher support this. + CosmWasm `1.3.1` or higher support this. diff --git a/packages/check/Cargo.toml b/packages/check/Cargo.toml index 5888b7f26c..5b3f633b45 100644 --- a/packages/check/Cargo.toml +++ b/packages/check/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-check" -version = "1.3.0" +version = "1.3.1" authors = ["Mauro Lacy "] edition = "2021" description = "A CLI tool for verifying CosmWasm smart contracts" @@ -11,8 +11,8 @@ license = "Apache-2.0" anyhow = "1.0.57" clap = "4" colored = "2" -cosmwasm-vm = { path = "../vm", version = "1.3.0" } -cosmwasm-std = { path = "../std", version = "1.3.0" } +cosmwasm-vm = { path = "../vm", version = "1.3.1" } +cosmwasm-std = { path = "../std", version = "1.3.1" } [dev-dependencies] assert_cmd = "=2.0.10" # 2.0.11+ requires Rust 1.65.0 which we currently don't want to make the minimum if possible diff --git a/packages/crypto/Cargo.toml b/packages/crypto/Cargo.toml index 480808b805..bd894f27a7 100644 --- a/packages/crypto/Cargo.toml +++ b/packages/crypto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-crypto" -version = "1.3.0" +version = "1.3.1" authors = ["Mauro Lacy "] edition = "2021" description = "Crypto bindings for cosmwasm contracts" diff --git a/packages/derive/Cargo.toml b/packages/derive/Cargo.toml index 3e8f640ee9..d1ddfacd33 100644 --- a/packages/derive/Cargo.toml +++ b/packages/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-derive" -version = "1.3.0" +version = "1.3.1" authors = ["Simon Warta "] edition = "2021" description = "A package for auto-generated code used for CosmWasm contract development. This is shipped as part of cosmwasm-std. Do not use directly." diff --git a/packages/schema-derive/Cargo.toml b/packages/schema-derive/Cargo.toml index ccebd5fd9f..96f66eddb0 100644 --- a/packages/schema-derive/Cargo.toml +++ b/packages/schema-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-schema-derive" -version = "1.3.0" +version = "1.3.1" authors = ["Tomasz Kurcz "] edition = "2021" description = "Derive macros for cosmwasm-schema" diff --git a/packages/schema/Cargo.toml b/packages/schema/Cargo.toml index 4f22af3473..f4906527b9 100644 --- a/packages/schema/Cargo.toml +++ b/packages/schema/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-schema" -version = "1.3.0" +version = "1.3.1" authors = ["Simon Warta ", "Ethan Frey "] edition = "2021" description = "A dev-dependency for CosmWasm contracts to generate JSON Schema files." @@ -8,7 +8,7 @@ repository = "https://github.com/CosmWasm/cosmwasm/tree/main/packages/schema" license = "Apache-2.0" [dependencies] -cosmwasm-schema-derive = { version = "=1.3.0", path = "../schema-derive" } +cosmwasm-schema-derive = { version = "=1.3.1", path = "../schema-derive" } schemars = "0.8.3" serde = "1.0" serde_json = "1.0.40" @@ -16,6 +16,6 @@ thiserror = "1.0.26" [dev-dependencies] anyhow = "1.0.57" -cosmwasm-std = { version = "1.3.0", path = "../std" } +cosmwasm-std = { version = "1.3.1", path = "../std" } semver = "1" tempfile = "3" diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 41e4935170..aad739649d 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-std" -version = "1.3.0" +version = "1.3.1" authors = ["Ethan Frey "] edition = "2021" description = "Standard library for Wasm based smart contracts on Cosmos blockchains" @@ -40,12 +40,12 @@ cosmwasm_1_1 = [] # the host blockchain to run CosmWasm `1.2.0` or higher. cosmwasm_1_2 = ["cosmwasm_1_1"] # This feature makes `BankQuery::DenomMetadata` available for the contract to call, but requires -# the host blockchain to run CosmWasm `1.3.0` or higher. +# the host blockchain to run CosmWasm `1.3.1` or higher. cosmwasm_1_3 = ["cosmwasm_1_2"] [dependencies] base64 = "0.13.0" -cosmwasm-derive = { path = "../derive", version = "1.3.0" } +cosmwasm-derive = { path = "../derive", version = "1.3.1" } derivative = "2" forward_ref = "1" hex = "0.4" @@ -57,7 +57,7 @@ thiserror = "1.0.26" bnum = "0.7.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -cosmwasm-crypto = { path = "../crypto", version = "1.3.0" } +cosmwasm-crypto = { path = "../crypto", version = "1.3.1" } [dev-dependencies] cosmwasm-schema = { path = "../schema" } diff --git a/packages/storage/Cargo.toml b/packages/storage/Cargo.toml index e2dd2012a3..4bf9e84087 100644 --- a/packages/storage/Cargo.toml +++ b/packages/storage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-storage" -version = "1.3.0" +version = "1.3.1" authors = ["Ethan Frey "] edition = "2021" description = "CosmWasm library with useful helpers for Storage patterns" @@ -16,5 +16,5 @@ iterator = ["cosmwasm-std/iterator"] [dependencies] # Uses the path when built locally; uses the given version from crates.io when published -cosmwasm-std = { path = "../std", version = "1.3.0", default-features = false } +cosmwasm-std = { path = "../std", version = "1.3.1", default-features = false } serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 7b3f93e8d2..fc085029d7 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-vm" -version = "1.3.0" +version = "1.3.1" authors = ["Ethan Frey "] edition = "2021" description = "VM bindings to run cosmwams contracts" @@ -39,8 +39,8 @@ bytes = "1.4.0" # need a higher version than the one required by Wasmer for the clru = "0.4.0" crc32fast = "1.3.2" # Uses the path when built locally; uses the given version from crates.io when published -cosmwasm-std = { path = "../std", version = "1.3.0", default-features = false } -cosmwasm-crypto = { path = "../crypto", version = "1.3.0" } +cosmwasm-std = { path = "../std", version = "1.3.1", default-features = false } +cosmwasm-crypto = { path = "../crypto", version = "1.3.1" } derivative = "2" hex = "0.4" parity-wasm = { version = "0.45", features = ["sign_ext"] } diff --git a/packages/vm/src/compatibility.rs b/packages/vm/src/compatibility.rs index a09faed79d..81c701eb7a 100644 --- a/packages/vm/src/compatibility.rs +++ b/packages/vm/src/compatibility.rs @@ -1,4 +1,4 @@ -use parity_wasm::elements::{External, ImportEntry, Module, TableType}; +use parity_wasm::elements::{External, ImportEntry, Module, TableType, Type}; use std::collections::BTreeSet; use std::collections::HashSet; @@ -95,6 +95,12 @@ const MEMORY_LIMIT: u32 = 512; // in pages /// is 485. Most are between 100 and 300. const TABLE_SIZE_LIMIT: u32 = 2500; // entries +const MAX_FUNCTIONS: usize = 10000; + +const MAX_FUNCTION_PARAMS: usize = 50; + +const MAX_FUNCTION_RESULTS: usize = 1; + /// If the contract has more than this amount of imports, it will be rejected /// during static validation before even looking into the imports. We keep this /// number high since failing early gives less detailed error messages. Especially @@ -114,6 +120,7 @@ pub fn check_wasm( check_wasm_exports(&module)?; check_wasm_imports(&module, supported_imports)?; check_wasm_capabilities(&module, available_capabilities)?; + check_wasm_functions(&module)?; Ok(()) } @@ -285,6 +292,51 @@ fn check_wasm_capabilities( Ok(()) } +fn check_wasm_functions(module: &Module) -> VmResult<()> { + let functions = module + .function_section() + .map(|fs| fs.entries()) + .unwrap_or_default(); + + if functions.len() > MAX_FUNCTIONS { + return Err(VmError::static_validation_err(format!( + "Wasm contract contains more than {MAX_FUNCTIONS} functions" + ))); + } + + let types = module + .type_section() + .map(|ts| ts.types()) + .unwrap_or_default(); + + let max_func_params = types + .iter() + .map(|t| match t { + Type::Function(f) => f.params().len(), + }) + .max() + .unwrap_or_default(); + let max_func_results = types + .iter() + .map(|t| match t { + Type::Function(f) => f.results().len(), + }) + .max() + .unwrap_or_default(); + + if max_func_params > MAX_FUNCTION_PARAMS { + return Err(VmError::static_validation_err(format!( + "Wasm contract contains function with more than {MAX_FUNCTION_PARAMS} parameters" + ))); + } + if max_func_results > MAX_FUNCTION_RESULTS { + return Err(VmError::static_validation_err(format!( + "Wasm contract contains function with more than {MAX_FUNCTION_RESULTS} results" + ))); + } + Ok(()) +} + #[cfg(test)] mod tests { use super::*; diff --git a/packages/vm/src/modules/file_system_cache.rs b/packages/vm/src/modules/file_system_cache.rs index d3c9679417..487ab4b261 100644 --- a/packages/vm/src/modules/file_system_cache.rs +++ b/packages/vm/src/modules/file_system_cache.rs @@ -1,6 +1,7 @@ use std::fs; use std::hash::Hash; use std::io; +use std::panic::catch_unwind; use std::path::{Path, PathBuf}; use thiserror::Error; @@ -154,9 +155,12 @@ impl FileSystemCache { let filename = checksum.to_hex(); let path = self.modules_path.join(filename); - module - .serialize_to_file(&path) - .map_err(|e| VmError::cache_err(format!("Error writing module to disk: {e}")))?; + catch_unwind(|| { + module + .serialize_to_file(&path) + .map_err(|e| VmError::cache_err(format!("Error writing module to disk: {e}"))) + }) + .map_err(|_| VmError::cache_err("Could not write module to disk"))??; let module_size = module_size(&path)?; Ok(module_size) }