diff --git a/CHANGELOG.md b/CHANGELOG.md index b1682da85b..09b018d8aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,37 @@ and this project adheres to [#1596]: https://github.com/CosmWasm/cosmwasm/issues/1596 +## [1.2.7] - 2023-06-19 + +### Added + +- cosmwasm-std: Add `<<` and `<<=` implementation for `Uint{64,128,256,512}` + types. ([#1723]) +- cosmwasm-std: Add `Timestamp::{plus,minus}_{minutes, hours, days}`. ([#1729]) +- cosmwasm-std: Add `Decimal::bps` and `Decimal256::bps` to create a decimal + from a basis point value ([#1715]). + +[#1723]: https://github.com/CosmWasm/cosmwasm/pull/1723 +[#1729]: https://github.com/CosmWasm/cosmwasm/pull/1729 +[#1715]: https://github.com/CosmWasm/cosmwasm/pull/1715 + +### Changed + +- cosmwasm-std: Coin uses shorter `Coin { 123 "ucosm" }` format for Debug + ([#1704]) + +[#1704]: https://github.com/CosmWasm/cosmwasm/pull/1704 + +## [1.2.6] - 2023-06-05 + +### Changed + +- cosmwasm-vm: Bumped module serialization version from v4 to v5 to invalidate + potentially corrupted caches caused by Rust update. See + https://github.com/CosmWasm/wasmvm/issues/426 for more information. ([#1708]) + +[#1708]: https://github.com/CosmWasm/cosmwasm/pull/1708 + ## [1.2.5] - 2023-05-02 ### Added @@ -1735,7 +1766,9 @@ Some main points: All future Changelog entries will reference this base -[unreleased]: https://github.com/CosmWasm/cosmwasm/compare/v1.2.5...HEAD +[unreleased]: https://github.com/CosmWasm/cosmwasm/compare/v1.2.7...HEAD +[1.2.7]: https://github.com/CosmWasm/cosmwasm/compare/v1.2.6...v1.2.7 +[1.2.6]: https://github.com/CosmWasm/cosmwasm/compare/v1.2.5...v1.2.6 [1.2.5]: https://github.com/CosmWasm/cosmwasm/compare/v1.2.4...v1.2.5 [1.2.4]: https://github.com/CosmWasm/cosmwasm/compare/v1.2.3...v1.2.4 [1.2.3]: https://github.com/CosmWasm/cosmwasm/compare/v1.2.2...v1.2.3 diff --git a/Cargo.lock b/Cargo.lock index 957d399272..e2121d4bc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,7 +411,7 @@ dependencies = [ [[package]] name = "cosmwasm-check" -version = "1.2.5" +version = "1.2.7" dependencies = [ "anyhow", "assert_cmd", @@ -424,7 +424,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "criterion", @@ -443,7 +443,7 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-std", "syn 1.0.109", @@ -451,7 +451,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "anyhow", "cosmwasm-schema-derive", @@ -466,7 +466,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -475,7 +475,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "chrono", @@ -497,7 +497,7 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-std", "serde", @@ -505,7 +505,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 058da123c4..314a1cf112 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -198,14 +198,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -216,7 +216,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -225,7 +225,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -243,7 +243,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index c3c00b3315..4724f87c89 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 01429ad9c3..37d9a76bcc 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -216,14 +216,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -234,7 +234,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -243,7 +243,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -261,7 +261,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 4a8afaeb96..3601db398d 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index a0fe89a43e..6bf57323fb 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 140b70d49b..cea2b67e8d 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index de789a8061..9320bc6b6a 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 77b62434b4..f4ac8cbcdc 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 71d20fac7d..ce9e6bbe72 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index ea3447f8d4..8a6d2d9d2d 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 960644f4bd..a8c9b9cc37 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" dependencies = [ "digest 0.10.3", "ed25519-zebra", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" dependencies = [ "proc-macro2", "quote", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" dependencies = [ "base64", "cosmwasm-crypto", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" dependencies = [ "bitflags", "bytecheck", diff --git a/packages/check/Cargo.toml b/packages/check/Cargo.toml index 6fd6bbff3c..ed6c920cfc 100644 --- a/packages/check/Cargo.toml +++ b/packages/check/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-check" -version = "1.2.5" +version = "1.2.7" 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.2.5" } -cosmwasm-std = { path = "../std", version = "1.2.5" } +cosmwasm-vm = { path = "../vm", version = "1.2.7" } +cosmwasm-std = { path = "../std", version = "1.2.7" } [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 7d79ed54ff..e5e16090a3 100644 --- a/packages/crypto/Cargo.toml +++ b/packages/crypto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-crypto" -version = "1.2.5" +version = "1.2.7" authors = ["Mauro Lacy "] edition = "2021" description = "Crypto bindings for cosmwasm contracts" diff --git a/packages/derive/Cargo.toml b/packages/derive/Cargo.toml index b0909ec357..c6ab3d563e 100644 --- a/packages/derive/Cargo.toml +++ b/packages/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-derive" -version = "1.2.5" +version = "1.2.7" 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 7f3b53933e..07b76b970d 100644 --- a/packages/schema-derive/Cargo.toml +++ b/packages/schema-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-schema-derive" -version = "1.2.5" +version = "1.2.7" authors = ["Tomasz Kurcz "] edition = "2021" description = "Derive macros for cosmwasm-schema" diff --git a/packages/schema/Cargo.toml b/packages/schema/Cargo.toml index 91ced79a03..153beae691 100644 --- a/packages/schema/Cargo.toml +++ b/packages/schema/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-schema" -version = "1.2.5" +version = "1.2.7" 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.2.5", path = "../schema-derive" } +cosmwasm-schema-derive = { version = "=1.2.7", 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.2.5", path = "../std" } +cosmwasm-std = { version = "1.2.7", path = "../std" } semver = "1" tempfile = "3" diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 2629690783..d5929f0ee6 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-std" -version = "1.2.5" +version = "1.2.7" authors = ["Ethan Frey "] edition = "2021" description = "Standard library for Wasm based smart contracts on Cosmos blockchains" @@ -42,7 +42,7 @@ cosmwasm_1_2 = ["cosmwasm_1_1"] [dependencies] base64 = "0.13.0" -cosmwasm-derive = { path = "../derive", version = "1.2.5" } +cosmwasm-derive = { path = "../derive", version = "1.2.7" } derivative = "2" forward_ref = "1" hex = "0.4" @@ -54,7 +54,7 @@ thiserror = "1.0.26" uint = "0.9.3" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -cosmwasm-crypto = { path = "../crypto", version = "1.2.5" } +cosmwasm-crypto = { path = "../crypto", version = "1.2.7" } [dev-dependencies] cosmwasm-schema = { path = "../schema" } diff --git a/packages/std/src/math/mod.rs b/packages/std/src/math/mod.rs index 706d23005d..72e55d9f1d 100644 --- a/packages/std/src/math/mod.rs +++ b/packages/std/src/math/mod.rs @@ -21,7 +21,7 @@ mod tests { use super::*; use std::ops::*; - /// An trait that ensures other traits are implemented for our number types + /// A trait that ensures other traits are implemented for our number types trait AllImpl<'a>: Add + Add<&'a Self> @@ -50,10 +50,28 @@ mod tests { { } + /// A trait that ensures other traits are implemented for our integer types + trait IntImpl<'a>: + AllImpl<'a> + + Shl + + Shl<&'a u32> + + ShlAssign + + ShlAssign<&'a u32> + + Shr + + Shr<&'a u32> + + ShrAssign + + ShrAssign<&'a u32> + { + } + impl AllImpl<'_> for Uint64 {} impl AllImpl<'_> for Uint128 {} impl AllImpl<'_> for Uint256 {} impl AllImpl<'_> for Uint512 {} + impl IntImpl<'_> for Uint64 {} + impl IntImpl<'_> for Uint128 {} + impl IntImpl<'_> for Uint256 {} + impl IntImpl<'_> for Uint512 {} impl AllImpl<'_> for Decimal {} impl AllImpl<'_> for Decimal256 {} } diff --git a/packages/std/src/math/uint128.rs b/packages/std/src/math/uint128.rs index 319ea92525..9c58c2cc3b 100644 --- a/packages/std/src/math/uint128.rs +++ b/packages/std/src/math/uint128.rs @@ -1,6 +1,7 @@ use std::fmt::{self}; use std::ops::{ - Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shr, ShrAssign, Sub, SubAssign, + Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, + Sub, SubAssign, }; use std::str::FromStr; @@ -197,6 +198,22 @@ impl Uint128 { .ok_or_else(|| DivideByZeroError::new(self)) } + pub fn checked_shr(self, other: u32) -> Result { + if other >= 128 { + return Err(OverflowError::new(OverflowOperation::Shr, self, other)); + } + + Ok(Self(self.0.shr(other))) + } + + pub fn checked_shl(self, other: u32) -> Result { + if other >= 128 { + return Err(OverflowError::new(OverflowOperation::Shl, self, other)); + } + + Ok(Self(self.0.shl(other))) + } + #[must_use = "this returns the result of the operation, without modifying the original"] #[inline] pub fn wrapping_add(self, other: Self) -> Self { @@ -441,6 +458,26 @@ impl<'a> Shr<&'a u32> for Uint128 { } } +impl Shl for Uint128 { + type Output = Self; + + fn shl(self, rhs: u32) -> Self::Output { + Self( + self.u128() + .checked_shl(rhs) + .expect("attempt to shift left with overflow"), + ) + } +} + +impl<'a> Shl<&'a u32> for Uint128 { + type Output = Self; + + fn shl(self, rhs: &'a u32) -> Self::Output { + self.shl(*rhs) + } +} + impl AddAssign for Uint128 { fn add_assign(&mut self, rhs: Uint128) { *self = *self + rhs; @@ -497,6 +534,18 @@ impl<'a> ShrAssign<&'a u32> for Uint128 { } } +impl ShlAssign for Uint128 { + fn shl_assign(&mut self, rhs: u32) { + *self = Shl::::shl(*self, rhs); + } +} + +impl<'a> ShlAssign<&'a u32> for Uint128 { + fn shl_assign(&mut self, rhs: &'a u32) { + *self = Shl::::shl(*self, *rhs); + } +} + impl Serialize for Uint128 { /// Serializes as an integer string using base 10 fn serialize(&self, serializer: S) -> Result @@ -889,6 +938,44 @@ mod tests { ); } + #[test] + fn uint128_shr_works() { + let original = Uint128::new(u128::from_be_bytes([ + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 2u8, 0u8, 4u8, 2u8, + ])); + + let shifted = Uint128::new(u128::from_be_bytes([ + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 128u8, 1u8, 0u8, + ])); + + assert_eq!(original >> 2u32, shifted); + } + + #[test] + #[should_panic] + fn uint128_shr_overflow_panics() { + let _ = Uint128::from(1u32) >> 128u32; + } + + #[test] + fn uint128_shl_works() { + let original = Uint128::new(u128::from_be_bytes([ + 64u8, 128u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + ])); + + let shifted = Uint128::new(u128::from_be_bytes([ + 2u8, 0u8, 4u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + ])); + + assert_eq!(original << 2u32, shifted); + } + + #[test] + #[should_panic] + fn uint128_shl_overflow_panics() { + let _ = Uint128::from(1u32) << 128u32; + } + #[test] fn sum_works() { let nums = vec![Uint128(17), Uint128(123), Uint128(540), Uint128(82)]; diff --git a/packages/std/src/math/uint256.rs b/packages/std/src/math/uint256.rs index 201342e387..e074be4a45 100644 --- a/packages/std/src/math/uint256.rs +++ b/packages/std/src/math/uint256.rs @@ -3,8 +3,8 @@ use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use std::fmt; use std::ops::{ - Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, Shr, ShrAssign, Sub, - SubAssign, + Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, + Sub, SubAssign, }; use std::str::FromStr; @@ -575,12 +575,8 @@ impl Shl for Uint256 { type Output = Self; fn shl(self, rhs: u32) -> Self::Output { - self.checked_shl(rhs).unwrap_or_else(|_| { - panic!( - "left shift error: {} is larger or equal than the number of bits in Uint256", - rhs, - ) - }) + self.checked_shl(rhs) + .expect("attempt to shift left with overflow") } } @@ -628,6 +624,18 @@ impl<'a> ShrAssign<&'a u32> for Uint256 { } } +impl ShlAssign for Uint256 { + fn shl_assign(&mut self, rhs: u32) { + *self = self.shl(rhs); + } +} + +impl<'a> ShlAssign<&'a u32> for Uint256 { + fn shl_assign(&mut self, rhs: &'a u32) { + *self = self.shl(*rhs); + } +} + impl Serialize for Uint256 { /// Serializes as an integer string using base 10 fn serialize(&self, serializer: S) -> Result @@ -1496,6 +1504,27 @@ mod tests { let _ = Uint256::from(1u32) >> 256u32; } + #[test] + fn uint256_shl_works() { + let original = Uint256::new([ + 64u8, 128u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + ]); + + let shifted = Uint256::new([ + 2u8, 0u8, 4u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + ]); + + assert_eq!(original << 2u32, shifted); + } + + #[test] + #[should_panic] + fn uint256_shl_overflow_panics() { + let _ = Uint256::from(1u32) << 256u32; + } + #[test] fn sum_works() { let nums = vec![ diff --git a/packages/std/src/math/uint512.rs b/packages/std/src/math/uint512.rs index 73a0512f26..9b5809d3d0 100644 --- a/packages/std/src/math/uint512.rs +++ b/packages/std/src/math/uint512.rs @@ -3,7 +3,8 @@ use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use std::fmt; use std::ops::{ - Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shr, ShrAssign, Sub, SubAssign, + Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, + Sub, SubAssign, }; use std::str::FromStr; @@ -262,6 +263,14 @@ impl Uint512 { Ok(Self(self.0.shr(other))) } + pub fn checked_shl(self, other: u32) -> Result { + if other >= 512 { + return Err(OverflowError::new(OverflowOperation::Shl, self, other)); + } + + Ok(Self(self.0.shl(other))) + } + #[must_use = "this returns the result of the operation, without modifying the original"] #[inline] pub fn wrapping_add(self, other: Self) -> Self { @@ -325,9 +334,10 @@ impl Uint512 { impl From for Uint512 { fn from(val: Uint256) -> Self { - let bytes = [[0u8; 32], val.to_be_bytes()].concat(); + let mut bytes = [0u8; 64]; + bytes[32..].copy_from_slice(&val.to_be_bytes()); - Self::from_be_bytes(bytes.try_into().unwrap()) + Self::from_be_bytes(bytes) } } @@ -542,6 +552,23 @@ impl<'a> Shr<&'a u32> for Uint512 { } } +impl Shl for Uint512 { + type Output = Self; + + fn shl(self, rhs: u32) -> Self::Output { + self.checked_shl(rhs) + .expect("attempt to shift left with overflow") + } +} + +impl<'a> Shl<&'a u32> for Uint512 { + type Output = Self; + + fn shl(self, rhs: &'a u32) -> Self::Output { + self.shl(*rhs) + } +} + impl AddAssign for Uint512 { fn add_assign(&mut self, rhs: Uint512) { self.0 = self.0.checked_add(rhs.0).unwrap(); @@ -578,6 +605,18 @@ impl<'a> ShrAssign<&'a u32> for Uint512 { } } +impl ShlAssign for Uint512 { + fn shl_assign(&mut self, rhs: u32) { + *self = self.shl(rhs); + } +} + +impl<'a> ShlAssign<&'a u32> for Uint512 { + fn shl_assign(&mut self, rhs: &'a u32) { + *self = self.shl(*rhs); + } +} + impl Serialize for Uint512 { /// Serializes as an integer string using base 10 fn serialize(&self, serializer: S) -> Result @@ -1119,6 +1158,31 @@ mod tests { let _ = Uint512::from(1u32) >> 512u32; } + #[test] + fn uint512_shl_works() { + let original = Uint512::new([ + 64u8, 128u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + ]); + + let shifted = Uint512::new([ + 2u8, 0u8, 4u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, + ]); + + assert_eq!(original << 2u32, shifted); + } + + #[test] + #[should_panic] + fn uint512_shl_overflow_panics() { + let _ = Uint512::from(1u32) << 512u32; + } + #[test] fn sum_works() { let nums = vec![ diff --git a/packages/std/src/math/uint64.rs b/packages/std/src/math/uint64.rs index e7a50339c0..9afd119647 100644 --- a/packages/std/src/math/uint64.rs +++ b/packages/std/src/math/uint64.rs @@ -3,7 +3,8 @@ use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use std::fmt::{self}; use std::ops::{ - Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shr, ShrAssign, Sub, SubAssign, + Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, + Sub, SubAssign, }; use crate::errors::{ @@ -190,6 +191,22 @@ impl Uint64 { .ok_or_else(|| DivideByZeroError::new(self)) } + pub fn checked_shr(self, other: u32) -> Result { + if other >= 64 { + return Err(OverflowError::new(OverflowOperation::Shr, self, other)); + } + + Ok(Self(self.0.shr(other))) + } + + pub fn checked_shl(self, other: u32) -> Result { + if other >= 64 { + return Err(OverflowError::new(OverflowOperation::Shl, self, other)); + } + + Ok(Self(self.0.shl(other))) + } + #[must_use = "this returns the result of the operation, without modifying the original"] #[inline] pub fn wrapping_add(self, other: Self) -> Self { @@ -412,6 +429,26 @@ impl<'a> Shr<&'a u32> for Uint64 { } } +impl Shl for Uint64 { + type Output = Self; + + fn shl(self, rhs: u32) -> Self::Output { + Self( + self.u64() + .checked_shl(rhs) + .expect("attempt to shift left with overflow"), + ) + } +} + +impl<'a> Shl<&'a u32> for Uint64 { + type Output = Self; + + fn shl(self, rhs: &'a u32) -> Self::Output { + self.shl(*rhs) + } +} + impl AddAssign for Uint64 { fn add_assign(&mut self, rhs: Uint64) { self.0 = self.0.checked_add(rhs.u64()).unwrap(); @@ -448,6 +485,18 @@ impl<'a> ShrAssign<&'a u32> for Uint64 { } } +impl ShlAssign for Uint64 { + fn shl_assign(&mut self, rhs: u32) { + *self = self.shl(rhs); + } +} + +impl<'a> ShlAssign<&'a u32> for Uint64 { + fn shl_assign(&mut self, rhs: &'a u32) { + *self = self.shl(*rhs); + } +} + impl Serialize for Uint64 { /// Serializes as an integer string using base 10 fn serialize(&self, serializer: S) -> Result @@ -800,6 +849,40 @@ mod tests { ); } + #[test] + fn uint64_shr_works() { + let original = Uint64::new(u64::from_be_bytes([0u8, 0u8, 0u8, 0u8, 2u8, 0u8, 4u8, 2u8])); + + let shifted = Uint64::new(u64::from_be_bytes([ + 0u8, 0u8, 0u8, 0u8, 0u8, 128u8, 1u8, 0u8, + ])); + + assert_eq!(original >> 2u32, shifted); + } + + #[test] + #[should_panic] + fn uint64_shr_overflow_panics() { + let _ = Uint64::from(1u32) >> 64u32; + } + + #[test] + fn uint64_shl_works() { + let original = Uint64::new(u64::from_be_bytes([ + 64u8, 128u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, + ])); + + let shifted = Uint64::new(u64::from_be_bytes([2u8, 0u8, 4u8, 0u8, 0u8, 0u8, 0u8, 0u8])); + + assert_eq!(original << 2u32, shifted); + } + + #[test] + #[should_panic] + fn uint64_shl_overflow_panics() { + let _ = Uint64::from(1u32) << 64u32; + } + #[test] fn sum_works() { let nums = vec![Uint64(17), Uint64(123), Uint64(540), Uint64(82)]; diff --git a/packages/std/src/timestamp.rs b/packages/std/src/timestamp.rs index a8e4ea8585..61c363e5d7 100644 --- a/packages/std/src/timestamp.rs +++ b/packages/std/src/timestamp.rs @@ -38,6 +38,24 @@ impl Timestamp { Timestamp(Uint64::new(seconds_since_epoch * 1_000_000_000)) } + #[must_use = "this returns the result of the operation, without modifying the original"] + #[inline] + pub const fn plus_days(&self, addition: u64) -> Timestamp { + self.plus_hours(addition * 24) + } + + #[must_use = "this returns the result of the operation, without modifying the original"] + #[inline] + pub const fn plus_hours(&self, addition: u64) -> Timestamp { + self.plus_minutes(addition * 60) + } + + #[must_use = "this returns the result of the operation, without modifying the original"] + #[inline] + pub const fn plus_minutes(&self, addition: u64) -> Timestamp { + self.plus_seconds(addition * 60) + } + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn plus_seconds(&self, addition: u64) -> Timestamp { self.plus_nanos(addition * 1_000_000_000) @@ -49,6 +67,24 @@ impl Timestamp { Timestamp(nanos) } + #[must_use = "this returns the result of the operation, without modifying the original"] + #[inline] + pub const fn minus_days(&self, subtrahend: u64) -> Timestamp { + self.minus_hours(subtrahend * 24) + } + + #[must_use = "this returns the result of the operation, without modifying the original"] + #[inline] + pub const fn minus_hours(&self, subtrahend: u64) -> Timestamp { + self.minus_minutes(subtrahend * 60) + } + + #[must_use = "this returns the result of the operation, without modifying the original"] + #[inline] + pub const fn minus_minutes(&self, subtrahend: u64) -> Timestamp { + self.minus_seconds(subtrahend * 60) + } + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp { self.minus_nanos(subtrahend * 1_000_000_000) @@ -156,6 +192,56 @@ mod tests { let _earlier = Timestamp::from_nanos(100).minus_nanos(101); } + #[test] + fn timestamp_plus_days() { + let ts = Timestamp::from_seconds(123).plus_days(0); + assert_eq!(ts.0.u64(), 123_000_000_000); + let ts = Timestamp::from_seconds(123).plus_days(10); + assert_eq!(ts.0.u64(), 864_123_000_000_000); + } + + #[test] + fn timestamp_minus_days() { + let ts = Timestamp::from_seconds(123).minus_days(0); + assert_eq!(ts.0.u64(), 123_000_000_000); + let ts = Timestamp::from_seconds(2 * 86400 + 123).minus_days(1); + assert_eq!(ts.0.u64(), 86_523_000_000_000); + let ts = Timestamp::from_seconds(86400).minus_days(1); + assert_eq!(ts.0.u64(), 0); + } + + #[test] + fn timestamp_plus_hours() { + let ts = Timestamp::from_seconds(123).plus_hours(0); + assert_eq!(ts.0.u64(), 123_000_000_000); + let ts = Timestamp::from_seconds(123).plus_hours(2); + assert_eq!(ts.0.u64(), 123_000_000_000 + 60 * 60 * 2 * 1_000_000_000); + } + + #[test] + fn timestamp_minus_hours() { + let ts = Timestamp::from_seconds(2 * 60 * 60).minus_hours(0); + assert_eq!(ts.0.u64(), 2 * 60 * 60 * 1_000_000_000); + let ts = Timestamp::from_seconds(2 * 60 * 60 + 123).minus_hours(1); + assert_eq!(ts.0.u64(), 60 * 60 * 1_000_000_000 + 123_000_000_000); + } + + #[test] + fn timestamp_plus_minutes() { + let ts = Timestamp::from_seconds(123).plus_minutes(0); + assert_eq!(ts.0.u64(), 123_000_000_000); + let ts = Timestamp::from_seconds(123).plus_minutes(2); + assert_eq!(ts.0.u64(), 123_000_000_000 + 60 * 2 * 1_000_000_000); + } + + #[test] + fn timestamp_minus_minutes() { + let ts = Timestamp::from_seconds(5 * 60).minus_minutes(0); + assert_eq!(ts.0.u64(), 5 * 60 * 1_000_000_000); + let ts = Timestamp::from_seconds(5 * 60 + 123).minus_minutes(1); + assert_eq!(ts.0.u64(), 4 * 60 * 1_000_000_000 + 123_000_000_000); + } + #[test] fn timestamp_nanos() { let sum = Timestamp::from_nanos(123); diff --git a/packages/storage/Cargo.toml b/packages/storage/Cargo.toml index 78ba760f7b..b5dbbab45a 100644 --- a/packages/storage/Cargo.toml +++ b/packages/storage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-storage" -version = "1.2.5" +version = "1.2.7" 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.2.5", default-features = false } +cosmwasm-std = { path = "../std", version = "1.2.7", 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 34eb20617e..1c78aafd0d 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmwasm-vm" -version = "1.2.5" +version = "1.2.7" 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.2.5", default-features = false } -cosmwasm-crypto = { path = "../crypto", version = "1.2.5" } +cosmwasm-std = { path = "../std", version = "1.2.7", default-features = false } +cosmwasm-crypto = { path = "../crypto", version = "1.2.7" } derivative = "2" hex = "0.4" parity-wasm = "0.45" diff --git a/packages/vm/src/modules/file_system_cache.rs b/packages/vm/src/modules/file_system_cache.rs index 3545aac599..0978187743 100644 --- a/packages/vm/src/modules/file_system_cache.rs +++ b/packages/vm/src/modules/file_system_cache.rs @@ -42,7 +42,9 @@ use crate::modules::current_wasmer_module_version; /// the old value "v3" is still used along with Wasmer 2.3.0 (bug). From cosmwasm 1.1.2 onwards, this is /// fixed by bumping to "v4". /// - **v5**:
-/// Version for cosmwasm_vm 1.3+ which adds a sub-folder with the target identier for the modules. +/// A change in memory layout of some types in Rust [std] caused +/// [issues with module deserialization](https://github.com/CosmWasm/wasmvm/issues/426). +/// To work around this, the version was bumped to "v5" here to invalidate these corrupt caches. const MODULE_SERIALIZATION_VERSION: &str = "v5"; /// Representation of a directory that contains compiled Wasm artifacts.