From 3ee7d517701e9f5e39a27abbf10690e09187889f Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Sat, 13 Jul 2024 15:46:44 +0200 Subject: [PATCH 1/8] Use better way to remove elements from vec --- packages/cw-utils/src/parse_reply.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cw-utils/src/parse_reply.rs b/packages/cw-utils/src/parse_reply.rs index d08f410f..45147529 100644 --- a/packages/cw-utils/src/parse_reply.rs +++ b/packages/cw-utils/src/parse_reply.rs @@ -43,7 +43,7 @@ fn parse_protobuf_varint(data: &mut Vec, field_number: u8) -> Result Date: Sat, 13 Jul 2024 15:50:40 +0200 Subject: [PATCH 2/8] Add ExternalStorage --- Cargo.lock | 626 +++++++++++++++++----- Cargo.toml | 3 +- packages/cw-utils/Cargo.toml | 3 +- packages/cw-utils/src/external_storage.rs | 148 +++++ packages/cw-utils/src/lib.rs | 9 +- 5 files changed, 647 insertions(+), 142 deletions(-) create mode 100644 packages/cw-utils/src/external_storage.rs diff --git a/Cargo.lock b/Cargo.lock index 40bc19f9..f3276822 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,54 +4,173 @@ version = 3 [[package]] name = "ahash" -version = "0.7.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ - "getrandom", + "cfg-if", "once_cell", "version_check", + "zerocopy", ] +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] -name = "base16ct" -version = "0.2.0" +name = "ark-bls12-381" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] [[package]] -name = "base64" -version = "0.21.7" +name = "ark-ec" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools 0.10.5", + "num-traits", + "rayon", + "zeroize", +] [[package]] -name = "base64ct" -version = "1.6.0" +name = "ark-ff" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rayon", + "rustc_version", + "zeroize", +] [[package]] -name = "bech32" -version = "0.9.1" +name = "ark-ff-asm" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] [[package]] -name = "block-buffer" -version = "0.9.0" +name = "ark-ff-macros" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ - "generic-array", + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", + "rayon", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + [[package]] name = "block-buffer" version = "0.10.4" @@ -63,15 +182,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" - -[[package]] -name = "byteorder" -version = "1.5.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" [[package]] name = "bytes" @@ -91,26 +204,44 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "cosmwasm-core" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d075f6bb1483a6ce83b5cbc73a3a1207e0316ac1e34ed1f2a4d9fc3a0f07bf6" + [[package]] name = "cosmwasm-crypto" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5fd9485d4f1f4330547a8a5aaf0958c68b4d620975ded2c15f2ed5c49e8e74" +checksum = "88ced5a6dd2801a383d3e14e5ae5caa7fdfeff1bd9f22b30e810e0aded8a5869" dependencies = [ - "digest 0.10.7", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "cosmwasm-core", + "digest", + "ecdsa", "ed25519-zebra", "k256", - "rand_core 0.6.4", + "num-traits", + "p256", + "rand_core", + "rayon", + "sha2", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d692944045feabbf46c75e8f072024bb885a7742025e40d46913296fe9fbbd06" +checksum = "35bd1873f84d9b17edf8a90ffe10a89a649b82feacc00e36788b81d2c3cbf03c" dependencies = [ - "syn 1.0.109", + "proc-macro2", + "quote", + "syn 2.0.48", ] [[package]] @@ -139,22 +270,23 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464f484b3f289935a41e374560c66c59a8f881aefc74742558e42008f1b0b7f3" +checksum = "2522fb5c9a0409712bb1d036128bccf3564e6b2ac82f942ae4cf3c8df3e26fa8" dependencies = [ "base64", "bech32", "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", - "forward_ref", + "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", - "sha2 0.10.8", + "sha2", "static_assertions", "thiserror", ] @@ -168,6 +300,31 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -175,7 +332,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -192,17 +349,31 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "cw-controllers" version = "2.0.0" @@ -210,12 +381,32 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", - "cw-utils", + "cw-utils 2.0.0", "schemars", "serde", "thiserror", ] +[[package]] +name = "cw-multi-test" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0034bfb4c06dfc8b50f0b1a06c3fc0f2312a1bae568a97db65930de071288ba" +dependencies = [ + "anyhow", + "bech32", + "cosmwasm-std", + "cw-storage-plus", + "cw-utils 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derivative", + "itertools 0.13.0", + "prost", + "schemars", + "serde", + "sha2", + "thiserror", +] + [[package]] name = "cw-storage-plus" version = "2.0.0" @@ -234,6 +425,7 @@ dependencies = [ "anyhow", "cosmwasm-schema", "cosmwasm-std", + "cw-multi-test", "cw-storage-plus", "ecdsa", "prost", @@ -242,6 +434,19 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-utils" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw2" version = "2.0.0" @@ -277,12 +482,24 @@ dependencies = [ ] [[package]] -name = "digest" -version = "0.9.0" +name = "derive_more" +version = "1.0.0-beta.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" dependencies = [ - "generic-array", + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", + "unicode-xid", ] [[package]] @@ -291,7 +508,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "const-oid", "crypto-common", "subtle", @@ -310,25 +527,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", - "digest 0.10.7", + "digest", "elliptic-curve", "rfc6979", "signature", - "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", ] [[package]] name = "ed25519-zebra" -version = "3.1.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek", - "hashbrown", + "ed25519", + "hashbrown 0.14.5", "hex", - "rand_core 0.6.4", - "serde", - "sha2 0.9.9", + "rand_core", + "sha2", "zeroize", ] @@ -346,12 +571,11 @@ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", - "digest 0.10.7", + "digest", "ff", "generic-array", "group", - "pkcs8", - "rand_core 0.6.4", + "rand_core", "sec1", "subtle", "zeroize", @@ -363,15 +587,15 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] [[package]] -name = "forward_ref" -version = "1.0.0" +name = "fiat-crypto" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "generic-array" @@ -402,19 +626,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core 0.6.4", + "rand_core", "subtle", ] [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + [[package]] name = "hex" version = "0.4.3" @@ -427,7 +661,16 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.7", + "digest", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", ] [[package]] @@ -439,6 +682,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -454,9 +706,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", - "sha2 0.10.8", - "signature", + "sha2", ] [[package]] @@ -465,6 +715,34 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -472,35 +750,52 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "p256" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] [[package]] -name = "pkcs8" -version = "0.10.2" +name = "paste" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" dependencies = [ - "der", - "spki", + "elliptic-curve", ] [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "prost" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", "prost-derive", @@ -508,12 +803,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.48", @@ -529,10 +824,24 @@ dependencies = [ ] [[package]] -name = "rand_core" -version = "0.5.1" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] [[package]] name = "rand_core" @@ -543,6 +852,26 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -553,6 +882,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.16" @@ -561,9 +899,9 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "schemars" -version = "0.8.16" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", "schemars_derive", @@ -573,14 +911,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.16" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -592,7 +930,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -605,9 +942,9 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.196" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -623,9 +960,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -634,13 +971,13 @@ dependencies = [ [[package]] name = "serde_derive_internals" -version = "0.26.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -654,19 +991,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.10.8" @@ -675,7 +999,7 @@ checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -684,18 +1008,8 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", + "digest", + "rand_core", ] [[package]] @@ -734,18 +1048,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" dependencies = [ "proc-macro2", "quote", @@ -764,6 +1078,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -776,8 +1096,42 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] diff --git a/Cargo.toml b/Cargo.toml index 56b69d6b..bb267595 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,10 +8,11 @@ resolver = "2" version = "2.0.0" [workspace.dependencies] -cw-utils = { path="packages/cw-utils", version="2.0.0" } +cw-utils = { path = "packages/cw-utils", version = "2.0.0" } cosmwasm-schema = "2.0.0" cosmwasm-std = { version = "2.0.0", default-features = false, features = ["std"] } cw-storage-plus = "2.0.0" +cw-multi-test = "2.1.0" [profile.release] rpath = false diff --git a/packages/cw-utils/Cargo.toml b/packages/cw-utils/Cargo.toml index 8530cf0f..ad6028bd 100644 --- a/packages/cw-utils/Cargo.toml +++ b/packages/cw-utils/Cargo.toml @@ -11,13 +11,14 @@ repository = "https://github.com/CosmWasm/cw-minus" [dependencies] cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } +cosmwasm-std = { workspace = true, features = ["std", "iterator"] } schemars = "0.8.15" serde = { version = "1.0.188", default-features = false, features = ["derive"] } thiserror = "1.0.49" [dev-dependencies] cw-storage-plus = { workspace = true } +cw-multi-test = { workspace = true } prost = "0.12.1" anyhow = "1.0.75" # Not used directly but prost-derive does not set a sufficiently high anyhow version diff --git a/packages/cw-utils/src/external_storage.rs b/packages/cw-utils/src/external_storage.rs new file mode 100644 index 00000000..212df8ce --- /dev/null +++ b/packages/cw-utils/src/external_storage.rs @@ -0,0 +1,148 @@ +use cosmwasm_std::{Addr, CustomQuery, Empty, QuerierWrapper, Storage}; + +/// A helper to read an external contract's storage. +/// This is useful if you want to avoid the gas cost of loading the contract and running a smart query +/// for a simple storage read. +/// +/// # Caveats +/// This is not a full storage implementation and cannot be used for range queries or mutations. +/// It will panic if you try. It is only for reading a single key at a time from another contract's storage. +/// +/// Using this means the contract you are reading from can break your contract by changing the storage layout. +pub struct ExternalStorage<'a, C: CustomQuery = Empty> { + contract_addr: Addr, + querier: QuerierWrapper<'a, C>, +} + +impl<'a, C: CustomQuery> ExternalStorage<'a, C> { + pub fn new(contract_addr: Addr, querier: QuerierWrapper<'a, C>) -> Self { + Self { + contract_addr, + querier, + } + } +} + +impl Storage for ExternalStorage<'_, C> { + fn get(&self, key: &[u8]) -> Option> { + self.querier + .query_wasm_raw(&self.contract_addr, key) + .expect("external storage query failed") + } + + // TODO: feature-gate? #[cfg(feature = "iterator")] + fn range<'a>( + &'a self, + _start: Option<&[u8]>, + _end: Option<&[u8]>, + _order: cosmwasm_std::Order, + ) -> Box + 'a> { + panic!("cannot range over external storage"); + } + + fn set(&mut self, _key: &[u8], _value: &[u8]) { + panic!("cannot mutate external storage"); + } + + fn remove(&mut self, _key: &[u8]) { + panic!("cannot mutate external storage"); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + use cosmwasm_std::{testing::mock_dependencies, StdResult}; + use cw_multi_test::{App, Executor}; + + mod storage_contract { + use super::*; + + use cosmwasm_schema::cw_serde; + use cosmwasm_std::{ + to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, + StdResult, + }; + use cw_multi_test::{Contract, ContractWrapper}; + use cw_storage_plus::{Item, Map}; + + const MAP: Map<&str, bool> = Map::new("map"); + const STORAGE_CONTRACT: Item = Item::new("storage_contract"); + + #[cw_serde] + pub struct InstantiateMsg { + /// The address of the contract that will store the data + /// This is only set for one of the instances of this contract + /// The other one will only write to its own storage + pub storage_contract: Option, + } + + fn instantiate( + deps: DepsMut, + _: Env, + _: MessageInfo, + msg: InstantiateMsg, + ) -> StdResult { + if let Some(contract) = msg.storage_contract { + STORAGE_CONTRACT.save(deps.storage, &deps.api.addr_validate(&contract)?)?; + } + Ok(Response::new()) + } + + fn execute(deps: DepsMut, _: Env, _: MessageInfo, _: Empty) -> StdResult { + // We'll call this in one instance + MAP.save(deps.storage, "entry", &true)?; + Ok(Response::new()) + } + + fn query(deps: Deps, _: Env, _: Empty) -> StdResult { + // We'll call this in another instance, getting the value set in execute of the first instance + let external_storage = + ExternalStorage::new(STORAGE_CONTRACT.load(deps.storage)?, deps.querier.clone()); + + let value = MAP.load(&external_storage, "entry")?; + to_json_binary(&value) + } + + pub fn contract() -> Box> { + Box::new(ContractWrapper::new(execute, instantiate, query)) + } + } + + #[test] + fn external_storage_works() { + let mut app = App::default(); + let user = app.api().addr_make("address"); + + let code_id = app.store_code(storage_contract::contract()); + let contract1 = app + .instantiate_contract(code_id, user.clone(), &Empty {}, &[], "cntrct", None) + .unwrap(); + + let contract2 = app + .instantiate_contract( + code_id, + user.clone(), + &storage_contract::InstantiateMsg { + storage_contract: Some(contract1.to_string()), + }, + &[], + "cntrct", + None, + ) + .unwrap(); + + // querying should fail as we have not set storage in contract1 yet + let result: StdResult = app.wrap().query_wasm_smart(contract2.clone(), &Empty {}); + assert!(result.is_err()); + + // set storage in contract1 + app.execute_contract(user, contract1, &Empty {}, &[]) + .unwrap(); + + // now querying should work + let result: bool = app.wrap().query_wasm_smart(contract2, &Empty {}).unwrap(); + assert!(result); + } +} diff --git a/packages/cw-utils/src/lib.rs b/packages/cw-utils/src/lib.rs index fa4c766a..90a5e415 100644 --- a/packages/cw-utils/src/lib.rs +++ b/packages/cw-utils/src/lib.rs @@ -8,12 +8,17 @@ a second contract, not "because we might need it" mod balance; mod expiration; +mod external_storage; mod pagination; mod parse_reply; mod payment; mod scheduled; mod threshold; +pub use crate::balance::NativeBalance; +pub use crate::expiration::{Duration, Expiration, DAY, HOUR, WEEK}; +pub use crate::external_storage::ExternalStorage; +pub use crate::scheduled::Scheduled; pub use pagination::{ calc_range_end, calc_range_start, calc_range_start_string, maybe_addr, maybe_canonical, }; @@ -23,7 +28,3 @@ pub use parse_reply::{ }; pub use payment::{may_pay, must_pay, nonpayable, one_coin, PaymentError}; pub use threshold::{Threshold, ThresholdError, ThresholdResponse}; - -pub use crate::balance::NativeBalance; -pub use crate::expiration::{Duration, Expiration, DAY, HOUR, WEEK}; -pub use crate::scheduled::Scheduled; From 55ab8a4c48256cbb2098f51b1953fd35d0ca500b Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 18 Jul 2024 12:35:35 +0200 Subject: [PATCH 3/8] Add iterator feature --- packages/cw-utils/Cargo.toml | 5 +++-- packages/cw-utils/src/external_storage.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cw-utils/Cargo.toml b/packages/cw-utils/Cargo.toml index ad6028bd..723f459c 100644 --- a/packages/cw-utils/Cargo.toml +++ b/packages/cw-utils/Cargo.toml @@ -7,11 +7,12 @@ description = "Common helpers for other cw specs" license = "Apache-2.0" repository = "https://github.com/CosmWasm/cw-minus" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +iterator = ["cosmwasm-std/iterator"] [dependencies] cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true, features = ["std", "iterator"] } +cosmwasm-std = { workspace = true } schemars = "0.8.15" serde = { version = "1.0.188", default-features = false, features = ["derive"] } thiserror = "1.0.49" diff --git a/packages/cw-utils/src/external_storage.rs b/packages/cw-utils/src/external_storage.rs index 212df8ce..74b724c5 100644 --- a/packages/cw-utils/src/external_storage.rs +++ b/packages/cw-utils/src/external_storage.rs @@ -30,7 +30,7 @@ impl Storage for ExternalStorage<'_, C> { .expect("external storage query failed") } - // TODO: feature-gate? #[cfg(feature = "iterator")] + #[cfg(feature = "iterator")] fn range<'a>( &'a self, _start: Option<&[u8]>, From 5ae69f0180ad89bd89fdaba0ca48212a832adbcc Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 18 Jul 2024 12:57:30 +0200 Subject: [PATCH 4/8] Bump ci rust version --- .circleci/config.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d92f8433..23a9ac3d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ workflows: - lint: matrix: parameters: - rust-version: ["1.70.0", "1.76.0"] + rust-version: ["1.72.0", "1.76.0"] - coverage nightly: triggers: @@ -35,7 +35,7 @@ workflows: jobs: package_cw_utils_build_and_test: docker: - - image: rust:1.70.0 + - image: rust:1.72.0 working_directory: ~/project/packages/cw-utils steps: - checkout @@ -50,8 +50,8 @@ jobs: command: cargo update - restore_cache: keys: - - v3-cw-utils-rust:1.70.0-{{ checksum "~/project/Cargo.lock" }} - - v3-cw-utils-rust:1.70.0- + - v3-cw-utils-rust:1.72.0-{{ checksum "~/project/Cargo.lock" }} + - v3-cw-utils-rust:1.72.0- - run: name: Build library for native target command: cargo build --locked @@ -68,7 +68,7 @@ jobs: paths: - /usr/local/cargo/registry - target - key: v3-cw-utils-rust:1.70.0-{{ checksum "~/project/Cargo.lock" }} + key: v3-cw-utils-rust:1.72.0-{{ checksum "~/project/Cargo.lock" }} package_cw_utils_build_minimal: docker: @@ -84,8 +84,8 @@ jobs: command: rm Cargo.lock - restore_cache: keys: - - v3-cw-utils-rust:1.70.0-minimal-{{ checksum "Cargo.toml" }} - - v3-cw-utils-rust:1.70.0-minimal- + - v3-cw-utils-rust:1.72.0-minimal-{{ checksum "Cargo.toml" }} + - v3-cw-utils-rust:1.72.0-minimal- - run: name: Build library for native target command: cargo build -Zminimal-versions --all-features @@ -96,11 +96,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: v3-cw-utils-rust:1.70.0-minimal-{{ checksum "Cargo.toml" }} + key: v3-cw-utils-rust:1.72.0-minimal-{{ checksum "Cargo.toml" }} package_cw_utils_build_maximal: docker: - - image: rust:1.70.0 + - image: rust:1.72.0 working_directory: ~/project/packages/cw-utils steps: - checkout @@ -112,8 +112,8 @@ jobs: command: cargo update - restore_cache: keys: - - v3-cw-utils-rust:1.70.0-{{ checksum "~/project/Cargo.lock" }} - - v3-cw-utils-rust:1.70.0- + - v3-cw-utils-rust:1.72.0-{{ checksum "~/project/Cargo.lock" }} + - v3-cw-utils-rust:1.72.0- - run: name: Build library for native target command: cargo build --locked --all-features @@ -124,7 +124,7 @@ jobs: paths: - /usr/local/cargo/registry - target - key: v3-cw-utils-rust:1.70.0-{{ checksum "~/project/Cargo.lock" }} + key: v3-cw-utils-rust:1.72.0-{{ checksum "~/project/Cargo.lock" }} lint: parameters: @@ -181,7 +181,7 @@ jobs: package_cw2: docker: - - image: rust:1.70.0 + - image: rust:1.72.0 working_directory: ~/project/packages/cw2 steps: - checkout: @@ -191,8 +191,8 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - v3-cw2-rust:1.70.0-{{ checksum "~/project/Cargo.lock" }} - - v3-cw2-rust:1.70.0- + - v3-cw2-rust:1.72.0-{{ checksum "~/project/Cargo.lock" }} + - v3-cw2-rust:1.72.0- - run: name: Build library for native target command: cargo build --locked @@ -204,11 +204,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: v3-cw2-rust:1.70.0-{{ checksum "~/project/Cargo.lock" }} + key: v3-cw2-rust:1.72.0-{{ checksum "~/project/Cargo.lock" }} package_controllers: docker: - - image: rust:1.70.0 + - image: rust:1.72.0 working_directory: ~/project/packages/controllers steps: - checkout: @@ -218,8 +218,8 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - v3-controllers-rust:1.70.0-{{ checksum "~/project/Cargo.lock" }} - - v3-controllers-rust:1.70.0- + - v3-controllers-rust:1.72.0-{{ checksum "~/project/Cargo.lock" }} + - v3-controllers-rust:1.72.0- - run: name: Build library for native target command: cargo build --locked @@ -230,4 +230,4 @@ jobs: paths: - /usr/local/cargo/registry - target - key: v3-controllers-rust:1.70.0-{{ checksum "~/project/Cargo.lock" }} + key: v3-controllers-rust:1.72.0-{{ checksum "~/project/Cargo.lock" }} From 503566c98cf3524c114d5b6ad01fcd86ad608dfe Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 18 Jul 2024 13:03:11 +0200 Subject: [PATCH 5/8] Fix lints --- packages/cw-utils/src/external_storage.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cw-utils/src/external_storage.rs b/packages/cw-utils/src/external_storage.rs index 74b724c5..fcce9140 100644 --- a/packages/cw-utils/src/external_storage.rs +++ b/packages/cw-utils/src/external_storage.rs @@ -53,7 +53,7 @@ impl Storage for ExternalStorage<'_, C> { mod tests { use super::*; - use cosmwasm_std::{testing::mock_dependencies, StdResult}; + use cosmwasm_std::StdResult; use cw_multi_test::{App, Executor}; mod storage_contract { @@ -99,7 +99,7 @@ mod tests { fn query(deps: Deps, _: Env, _: Empty) -> StdResult { // We'll call this in another instance, getting the value set in execute of the first instance let external_storage = - ExternalStorage::new(STORAGE_CONTRACT.load(deps.storage)?, deps.querier.clone()); + ExternalStorage::new(STORAGE_CONTRACT.load(deps.storage)?, deps.querier); let value = MAP.load(&external_storage, "entry")?; to_json_binary(&value) From 45a89e446397ae5cf45fd8ee37b8dbc5189f707a Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 18 Jul 2024 13:25:49 +0200 Subject: [PATCH 6/8] Fix features --- Cargo.toml | 4 ++-- packages/cw-utils/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb267595..0a739de4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ version = "2.0.0" cw-utils = { path = "packages/cw-utils", version = "2.0.0" } cosmwasm-schema = "2.0.0" cosmwasm-std = { version = "2.0.0", default-features = false, features = ["std"] } -cw-storage-plus = "2.0.0" -cw-multi-test = "2.1.0" +cw-storage-plus = { version = "2.0.0", default-features = false } +cw-multi-test = { version = "2.1.0", default-features = false } [profile.release] rpath = false diff --git a/packages/cw-utils/Cargo.toml b/packages/cw-utils/Cargo.toml index 723f459c..4a70ec98 100644 --- a/packages/cw-utils/Cargo.toml +++ b/packages/cw-utils/Cargo.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" repository = "https://github.com/CosmWasm/cw-minus" [features] -iterator = ["cosmwasm-std/iterator"] +iterator = ["cosmwasm-std/iterator", "cw-storage-plus/iterator"] [dependencies] cosmwasm-schema = { workspace = true } @@ -21,7 +21,7 @@ thiserror = "1.0.49" cw-storage-plus = { workspace = true } cw-multi-test = { workspace = true } prost = "0.12.1" -anyhow = "1.0.75" # Not used directly but prost-derive does not set a sufficiently high anyhow version +anyhow = "1.0.75" # Not used directly but prost-derive does not set a sufficiently high anyhow version # We don't use these dependencies directly, # we tighten versions that builds with `-Zminimal-versions` work. From f035c5b53ae85b276b3c9837de9f96f1bbcd0dcd Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 30 Jul 2024 13:09:38 +0200 Subject: [PATCH 7/8] Fix ExternalStorage --- Cargo.lock | 26 +++++++++++------------ Cargo.toml | 4 ++-- packages/cw-utils/Cargo.toml | 3 --- packages/cw-utils/src/external_storage.rs | 10 --------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3276822..0e5ec42b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -206,15 +206,15 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "cosmwasm-core" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d075f6bb1483a6ce83b5cbc73a3a1207e0316ac1e34ed1f2a4d9fc3a0f07bf6" +checksum = "367fc87c43759098a476ef90f915aadc66c300480ad9c155b512081fbf327bc1" [[package]] name = "cosmwasm-crypto" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ced5a6dd2801a383d3e14e5ae5caa7fdfeff1bd9f22b30e810e0aded8a5869" +checksum = "9b7c41f3e371ea457d3b98bb592c38858b46efcf614e0e988ec2ebbdb973954f" dependencies = [ "ark-bls12-381", "ark-ec", @@ -235,9 +235,9 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd1873f84d9b17edf8a90ffe10a89a649b82feacc00e36788b81d2c3cbf03c" +checksum = "c10510e8eb66cf7e109741b1e2c76ad18f30b5a1daa064f5f7115c1f733aaea0" dependencies = [ "proc-macro2", "quote", @@ -246,9 +246,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a67c099aba9e334bbc1fc8037fe8e7ba91d06b215d9ffa7af91893c44aa420c6" +checksum = "f79879b6b7ef6a331b05030ce91ce46a7c4b0baf1ed6b382cce2e9a168109380" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -259,20 +259,20 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2bb09168f6e86bf583361fdb0a0fed2625652e9edcfce731cb55ef4cb8de3d" +checksum = "82b53e33c0e97170c7ac9cb440f4bc599a07f9cbb9b7e87916cca37b1239d57b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] name = "cosmwasm-std" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2522fb5c9a0409712bb1d036128bccf3564e6b2ac82f942ae4cf3c8df3e26fa8" +checksum = "92011c39570876f340d5f9defa68bf92797b1c44421f1b9ea9b04a31d6defd33" dependencies = [ "base64", "bech32", diff --git a/Cargo.toml b/Cargo.toml index 0a739de4..89861fc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,8 @@ version = "2.0.0" [workspace.dependencies] cw-utils = { path = "packages/cw-utils", version = "2.0.0" } -cosmwasm-schema = "2.0.0" -cosmwasm-std = { version = "2.0.0", default-features = false, features = ["std"] } +cosmwasm-schema = "2.1.1" +cosmwasm-std = { version = "2.1.1", default-features = false, features = ["std"] } cw-storage-plus = { version = "2.0.0", default-features = false } cw-multi-test = { version = "2.1.0", default-features = false } diff --git a/packages/cw-utils/Cargo.toml b/packages/cw-utils/Cargo.toml index 4a70ec98..3f1c2e55 100644 --- a/packages/cw-utils/Cargo.toml +++ b/packages/cw-utils/Cargo.toml @@ -7,9 +7,6 @@ description = "Common helpers for other cw specs" license = "Apache-2.0" repository = "https://github.com/CosmWasm/cw-minus" -[features] -iterator = ["cosmwasm-std/iterator", "cw-storage-plus/iterator"] - [dependencies] cosmwasm-schema = { workspace = true } cosmwasm-std = { workspace = true } diff --git a/packages/cw-utils/src/external_storage.rs b/packages/cw-utils/src/external_storage.rs index fcce9140..43fff197 100644 --- a/packages/cw-utils/src/external_storage.rs +++ b/packages/cw-utils/src/external_storage.rs @@ -30,16 +30,6 @@ impl Storage for ExternalStorage<'_, C> { .expect("external storage query failed") } - #[cfg(feature = "iterator")] - fn range<'a>( - &'a self, - _start: Option<&[u8]>, - _end: Option<&[u8]>, - _order: cosmwasm_std::Order, - ) -> Box + 'a> { - panic!("cannot range over external storage"); - } - fn set(&mut self, _key: &[u8], _value: &[u8]) { panic!("cannot mutate external storage"); } From c1c8ab2ba5ecf6f63958774aa56e57cb12de8304 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 30 Jul 2024 13:14:03 +0200 Subject: [PATCH 8/8] Fix storage-plus dep --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 89861fc0..addf6da4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ version = "2.0.0" cw-utils = { path = "packages/cw-utils", version = "2.0.0" } cosmwasm-schema = "2.1.1" cosmwasm-std = { version = "2.1.1", default-features = false, features = ["std"] } -cw-storage-plus = { version = "2.0.0", default-features = false } +cw-storage-plus = "2.0.0" cw-multi-test = { version = "2.1.0", default-features = false } [profile.release]