From c88b03564237d090a01bd820005ad0637200ea3d Mon Sep 17 00:00:00 2001 From: kogisin Date: Sun, 23 Apr 2023 15:13:52 +0900 Subject: [PATCH 01/29] fix: remove as well --- SEMANTICS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SEMANTICS.md b/SEMANTICS.md index 9534693616..33cab27441 100644 --- a/SEMANTICS.md +++ b/SEMANTICS.md @@ -295,7 +295,7 @@ After the `submessage` is finished, the caller will get a chance to handle the result. It will get the original `id` of the subcall so it can switch on how to process this, and the `Result` of the execution, both success and error. Note that it includes all events returned by the submessage, which applies to native -sdk modules as well (like Bank) as well as the data returned from below. This +sdk modules (like Bank) as well as the data returned from below. This and the original call id provide all context to continue processing it. If you need more state, you must save some local context to the store (under the `id`) before returning the `submessage` in the original `execute`, and load it in From 761fff1ef52d52ca771eff4c9fbbc0817f23e77a Mon Sep 17 00:00:00 2001 From: kogisin Date: Sun, 23 Apr 2023 15:21:16 +0900 Subject: [PATCH 02/29] fix: typographic errors --- SEMANTICS.md | 2 +- contracts/README.md | 2 +- contracts/staking/README.md | 2 +- docs/USING_COSMWASM_STD.md | 6 +++--- packages/crypto/README.md | 4 ++-- packages/storage/README.md | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SEMANTICS.md b/SEMANTICS.md index 33cab27441..d675e71421 100644 --- a/SEMANTICS.md +++ b/SEMANTICS.md @@ -366,7 +366,7 @@ of reentrancy, as the query cannot modify any state or execute our contract. When we "make a query", we serialize a [`QueryRequest` struct](https://github.com/CosmWasm/cosmwasm/blob/v0.14.0-beta4/packages/std/src/query/mod.rs#L27-L48) that represents all possible calls, and then pass that over FFI to the runtime, -where it is interpretted in the `x/wasm` SDK module. This is extensible with +where it is interpreted in the `x/wasm` SDK module. This is extensible with blockchain-specific custom queries just like `CosmosMsg` accepts custom results. Also note the ability to perform raw protobuf "Stargate" queries: diff --git a/contracts/README.md b/contracts/README.md index 845af6995d..7ed97a842b 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -19,7 +19,7 @@ Introducing the development contracts in the order they were created. which allows the user to send messages to the contract which are then emitted with the contract as the sender. It later got support to handle sub messages and replys ([#796](https://github.com/CosmWasm/cosmwasm/pull/796)). -4. **staking** is a staking derivates example showing how the contract itself +4. **staking** is a staking derivatives example showing how the contract itself can be a delegator. 5. **burner** shows how contract migrations work, which were added in CosmWasm 0.9 ([#413](https://github.com/CosmWasm/cosmwasm/pull/413)). It shuts down diff --git a/contracts/staking/README.md b/contracts/staking/README.md index 3221f42946..5ecaa7ac78 100644 --- a/contracts/staking/README.md +++ b/contracts/staking/README.md @@ -22,7 +22,7 @@ unbonding period). To show an example of charging for such a service, we allow the contract owner to take a small exit tax, thus maybe 98% of the tokens will be unbonded and sent to the original account, and 2% of the tokens are not unbonded, but rather -transfered to the owners account. (The ownership can also be transfered). +transferred to the owners account. (The ownership can also be transferred). ## Using this project diff --git a/docs/USING_COSMWASM_STD.md b/docs/USING_COSMWASM_STD.md index 45841e908b..5452faa398 100644 --- a/docs/USING_COSMWASM_STD.md +++ b/docs/USING_COSMWASM_STD.md @@ -2,7 +2,7 @@ cosmwasm-std is the standard library for building contracts in CosmWasm. It is compiled as part of the contract to Wasm. When creating a dependency to -cosmwasm-std, the required Wasm imports and exports are created implicitely via +cosmwasm-std, the required Wasm imports and exports are created implicitly via C interfaces, e.g.: ```rust @@ -37,11 +37,11 @@ The libarary comes with the following features: | Feature | Enabled by default | Description | | ------------ | ------------------ | -------------------------------------------------------------------------- | | iterator | x | Storage iterators | -| abort | x | A panic handler that aborts the contract execution with a helpfull message | +| abort | x | A panic handler that aborts the contract execution with a helpful message | | stargate | | Cosmos SDK 0.40+ features and IBC | | ibc3 | | New fields added in IBC v3 | | staking | | Access to the staking module | -| baktraces | | Add backtraces to errors (for unit testing) | +| backtraces | | Add backtraces to errors (for unit testing) | | cosmwasm_1_1 | | Features that require CosmWasm 1.1+ on the chain | | cosmwasm_1_2 | | Features that require CosmWasm 1.2+ on the chain | diff --git a/packages/crypto/README.md b/packages/crypto/README.md index b1dc660d0e..cf927879a7 100644 --- a/packages/crypto/README.md +++ b/packages/crypto/README.md @@ -11,9 +11,9 @@ and [cosmwasm-std](`https://crates.io/crates/cosmwasm-std`) crates. - `secp256k1_verify()`: Digital signature verification using the ECDSA sepc256k1 scheme, for Cosmos signature / public key formats. - `ed25519_verify()`: Digital signature verification using the EdDSA ed25519 - scheme, for Tendemint signature / public key formats. + scheme, for Tendermint signature / public key formats. - `ed25519_batch_verify()`: Batch digital signature verification using the EdDSA - ed25519 scheme, for Tendemint signature / public key formats. + ed25519 scheme, for Tendermint signature / public key formats. ## Benchmarking diff --git a/packages/storage/README.md b/packages/storage/README.md index 5ed7379226..933028028e 100644 --- a/packages/storage/README.md +++ b/packages/storage/README.md @@ -4,7 +4,7 @@ CosmWasm library with useful helpers for Storage patterns. You can use `Storage` implementations in `cosmwasm-std`, or rely on these to remove some common -boilterplate. +boilerplate. ## Contents From cd3749c5ab254b9ddf5a25761aefecb0ba9e7f95 Mon Sep 17 00:00:00 2001 From: kogisin Date: Sun, 23 Apr 2023 15:25:40 +0900 Subject: [PATCH 03/29] fix: fix The to They --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb619b1dff..7536c89f59 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ See [Minimum Supported Rust Version (MSRV)](./docs/MSRV.md). ## API entry points -WebAssembly contracts are basically black boxes. The have no default entry +WebAssembly contracts are basically black boxes. They have no default entry points, and no access to the outside world by default. To make them useful, we need to add a few elements. From 0a04e658252f8c3166025d903867f28c23d6e715 Mon Sep 17 00:00:00 2001 From: kogisin Date: Mon, 24 Apr 2023 15:49:36 +0900 Subject: [PATCH 04/29] fix: fix validate markdown files issue by running format_md script --- SEMANTICS.md | 14 +++++++------- docs/USING_COSMWASM_STD.md | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/SEMANTICS.md b/SEMANTICS.md index d675e71421..dc6afcb66a 100644 --- a/SEMANTICS.md +++ b/SEMANTICS.md @@ -295,13 +295,13 @@ After the `submessage` is finished, the caller will get a chance to handle the result. It will get the original `id` of the subcall so it can switch on how to process this, and the `Result` of the execution, both success and error. Note that it includes all events returned by the submessage, which applies to native -sdk modules (like Bank) as well as the data returned from below. This -and the original call id provide all context to continue processing it. If you -need more state, you must save some local context to the store (under the `id`) -before returning the `submessage` in the original `execute`, and load it in -`reply`. We explicitly prohibit passing information in contract memory, as that -is the key vector for reentrancy attacks, which are a large security surface -area in Ethereum. +sdk modules (like Bank) as well as the data returned from below. This and the +original call id provide all context to continue processing it. If you need more +state, you must save some local context to the store (under the `id`) before +returning the `submessage` in the original `execute`, and load it in `reply`. We +explicitly prohibit passing information in contract memory, as that is the key +vector for reentrancy attacks, which are a large security surface area in +Ethereum. The `reply` call may return `Err` itself, in which case it is treated like the caller errored, and aborting the transaction. However, on successful processing, diff --git a/docs/USING_COSMWASM_STD.md b/docs/USING_COSMWASM_STD.md index 5452faa398..7da8fa6e92 100644 --- a/docs/USING_COSMWASM_STD.md +++ b/docs/USING_COSMWASM_STD.md @@ -2,8 +2,8 @@ cosmwasm-std is the standard library for building contracts in CosmWasm. It is compiled as part of the contract to Wasm. When creating a dependency to -cosmwasm-std, the required Wasm imports and exports are created implicitly via -C interfaces, e.g.: +cosmwasm-std, the required Wasm imports and exports are created implicitly via C +interfaces, e.g.: ```rust // Exports @@ -34,16 +34,16 @@ in the dependency tree. Otherwise conflicting C exports are created. The libarary comes with the following features: -| Feature | Enabled by default | Description | -| ------------ | ------------------ | -------------------------------------------------------------------------- | -| iterator | x | Storage iterators | -| abort | x | A panic handler that aborts the contract execution with a helpful message | -| stargate | | Cosmos SDK 0.40+ features and IBC | -| ibc3 | | New fields added in IBC v3 | -| staking | | Access to the staking module | -| backtraces | | Add backtraces to errors (for unit testing) | -| cosmwasm_1_1 | | Features that require CosmWasm 1.1+ on the chain | -| cosmwasm_1_2 | | Features that require CosmWasm 1.2+ on the chain | +| Feature | Enabled by default | Description | +| ------------ | ------------------ | ------------------------------------------------------------------------- | +| iterator | x | Storage iterators | +| abort | x | A panic handler that aborts the contract execution with a helpful message | +| stargate | | Cosmos SDK 0.40+ features and IBC | +| ibc3 | | New fields added in IBC v3 | +| staking | | Access to the staking module | +| backtraces | | Add backtraces to errors (for unit testing) | +| cosmwasm_1_1 | | Features that require CosmWasm 1.1+ on the chain | +| cosmwasm_1_2 | | Features that require CosmWasm 1.2+ on the chain | ## The cosmwasm-std dependency for contract developers From 18625054e9ec0b27459bc56336663702e911e13a Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 3 May 2023 12:18:29 +0200 Subject: [PATCH 05/29] Deprecate all cosmwasm-storage types --- CHANGELOG.md | 7 +++++++ packages/storage/src/bucket.rs | 12 ++++++++++++ packages/storage/src/lib.rs | 2 ++ packages/storage/src/prefixed_storage.rs | 12 ++++++++++++ packages/storage/src/sequence.rs | 9 +++++++++ packages/storage/src/singleton.rs | 12 ++++++++++++ 6 files changed, 54 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a512a2112c..75136e9c10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,13 @@ and this project adheres to [#1664]: https://github.com/CosmWasm/cosmwasm/pull/1664 [#1667]: https://github.com/CosmWasm/cosmwasm/pull/1667 +### Deprecated + +- cosmwasm-storage: All exports are deprecated because this crate will be + removed with CosmWasm 2.0 ([#1596]). + +[#1596]: https://github.com/CosmWasm/cosmwasm/issues/1596 + ## [1.2.5] - 2023-05-02 ### Added diff --git a/packages/storage/src/bucket.rs b/packages/storage/src/bucket.rs index 5f68abafa7..c349f1edd5 100644 --- a/packages/storage/src/bucket.rs +++ b/packages/storage/src/bucket.rs @@ -16,6 +16,9 @@ use crate::type_helpers::deserialize_kv; use crate::type_helpers::{may_deserialize, must_deserialize}; /// An alias of Bucket::new for less verbose usage +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn bucket<'a, T>(storage: &'a mut dyn Storage, namespace: &[u8]) -> Bucket<'a, T> where T: Serialize + DeserializeOwned, @@ -24,6 +27,9 @@ where } /// An alias of ReadonlyBucket::new for less verbose usage +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn bucket_read<'a, T>(storage: &'a dyn Storage, namespace: &[u8]) -> ReadonlyBucket<'a, T> where T: Serialize + DeserializeOwned, @@ -31,6 +37,9 @@ where ReadonlyBucket::new(storage, namespace) } +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub struct Bucket<'a, T> where T: Serialize + DeserializeOwned, @@ -112,6 +121,9 @@ where } } +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub struct ReadonlyBucket<'a, T> where T: Serialize + DeserializeOwned, diff --git a/packages/storage/src/lib.rs b/packages/storage/src/lib.rs index 5e5b72d764..3fd3a37946 100644 --- a/packages/storage/src/lib.rs +++ b/packages/storage/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + mod bucket; mod namespace_helpers; mod prefixed_storage; diff --git a/packages/storage/src/prefixed_storage.rs b/packages/storage/src/prefixed_storage.rs index cbe853b7e7..97f5bb63a5 100644 --- a/packages/storage/src/prefixed_storage.rs +++ b/packages/storage/src/prefixed_storage.rs @@ -10,11 +10,17 @@ use crate::namespace_helpers::range_with_prefix; use crate::namespace_helpers::{get_with_prefix, remove_with_prefix, set_with_prefix}; /// An alias of PrefixedStorage::new for less verbose usage +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn prefixed<'a>(storage: &'a mut dyn Storage, namespace: &[u8]) -> PrefixedStorage<'a> { PrefixedStorage::new(storage, namespace) } /// An alias of ReadonlyPrefixedStorage::new for less verbose usage +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn prefixed_read<'a>( storage: &'a dyn Storage, namespace: &[u8], @@ -22,6 +28,9 @@ pub fn prefixed_read<'a>( ReadonlyPrefixedStorage::new(storage, namespace) } +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub struct PrefixedStorage<'a> { storage: &'a mut dyn Storage, prefix: Vec, @@ -71,6 +80,9 @@ impl<'a> Storage for PrefixedStorage<'a> { } } +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub struct ReadonlyPrefixedStorage<'a> { storage: &'a dyn Storage, prefix: Vec, diff --git a/packages/storage/src/sequence.rs b/packages/storage/src/sequence.rs index 30f9491cb2..6d953f79c5 100644 --- a/packages/storage/src/sequence.rs +++ b/packages/storage/src/sequence.rs @@ -3,18 +3,27 @@ use cosmwasm_std::{StdResult, Storage}; use crate::Singleton; /// Sequence creates a custom Singleton to hold an empty sequence +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn sequence<'a>(storage: &'a mut dyn Storage, key: &[u8]) -> Singleton<'a, u64> { Singleton::new(storage, key) } /// currval returns the last value returned by nextval. If the sequence has never been used, /// then it will return 0. +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn currval(seq: &Singleton) -> StdResult { Ok(seq.may_load()?.unwrap_or_default()) } /// nextval increments the counter by 1 and returns the new value. /// On the first time it is called (no sequence info in db) it will return 1. +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn nextval(seq: &mut Singleton) -> StdResult { let val = currval(seq)? + 1; seq.save(&val)?; diff --git a/packages/storage/src/singleton.rs b/packages/storage/src/singleton.rs index d89848576d..c274a41dc8 100644 --- a/packages/storage/src/singleton.rs +++ b/packages/storage/src/singleton.rs @@ -6,6 +6,9 @@ use cosmwasm_std::{storage_keys::to_length_prefixed, to_vec, StdError, StdResult use crate::type_helpers::{may_deserialize, must_deserialize}; /// An alias of Singleton::new for less verbose usage +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn singleton<'a, T>(storage: &'a mut dyn Storage, key: &[u8]) -> Singleton<'a, T> where T: Serialize + DeserializeOwned, @@ -14,6 +17,9 @@ where } /// An alias of ReadonlySingleton::new for less verbose usage +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub fn singleton_read<'a, T>(storage: &'a dyn Storage, key: &[u8]) -> ReadonlySingleton<'a, T> where T: Serialize + DeserializeOwned, @@ -25,6 +31,9 @@ where /// work on a single storage key. It performs the to_length_prefixed transformation /// on the given name to ensure no collisions, and then provides the standard /// TypedStorage accessors, without requiring a key (which is defined in the constructor) +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub struct Singleton<'a, T> where T: Serialize + DeserializeOwned, @@ -88,6 +97,9 @@ where /// ReadonlySingleton only requires a Storage and exposes only the /// methods of Singleton that don't modify state. +#[deprecated( + note = "The crate cosmwasm-storage is unmaintained and will be removed in CosmWasm 2.0. Please consider migrating to cw-storage-plus or simple cosmwasm-std storage calls." +)] pub struct ReadonlySingleton<'a, T> where T: Serialize + DeserializeOwned, From 93bd6da006cd9d2ed94c06b733e091f321e27983 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 3 May 2023 16:21:01 +0200 Subject: [PATCH 06/29] Remove unused cosmwasm-storage dependencies --- contracts/crypto-verify/Cargo.toml | 1 - contracts/cyberpunk/Cargo.toml | 1 - contracts/floaty/Cargo.toml | 1 - contracts/hackatom/Cargo.toml | 1 - 4 files changed, 4 deletions(-) diff --git a/contracts/crypto-verify/Cargo.toml b/contracts/crypto-verify/Cargo.toml index 0661d6c484..e31fe6242b 100644 --- a/contracts/crypto-verify/Cargo.toml +++ b/contracts/crypto-verify/Cargo.toml @@ -34,7 +34,6 @@ backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] cosmwasm-schema = { path = "../../packages/schema" } cosmwasm-std = { path = "../../packages/std", features = ["iterator"] } -cosmwasm-storage = { path = "../../packages/storage", features = ["iterator"] } hex = "0.4" rlp = "0.5" schemars = "0.8.3" diff --git a/contracts/cyberpunk/Cargo.toml b/contracts/cyberpunk/Cargo.toml index 32f43bf413..f7a5c43575 100644 --- a/contracts/cyberpunk/Cargo.toml +++ b/contracts/cyberpunk/Cargo.toml @@ -35,5 +35,4 @@ rust-argon2 = "0.8" thiserror = "1.0.26" [dev-dependencies] -cosmwasm-storage = { path = "../../packages/storage", default-features = false } cosmwasm-vm = { path = "../../packages/vm", default-features = false } diff --git a/contracts/floaty/Cargo.toml b/contracts/floaty/Cargo.toml index b16a2c282b..0aee91625c 100644 --- a/contracts/floaty/Cargo.toml +++ b/contracts/floaty/Cargo.toml @@ -38,5 +38,4 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.26" [dev-dependencies] -cosmwasm-storage = { path = "../../packages/storage" } cosmwasm-vm = { path = "../../packages/vm", default-features = false, features = ["iterator"] } diff --git a/contracts/hackatom/Cargo.toml b/contracts/hackatom/Cargo.toml index fa1b8ccf7d..240bdb1476 100644 --- a/contracts/hackatom/Cargo.toml +++ b/contracts/hackatom/Cargo.toml @@ -39,5 +39,4 @@ sha2 = "0.10" thiserror = "1.0.26" [dev-dependencies] -cosmwasm-storage = { path = "../../packages/storage", default-features = false } cosmwasm-vm = { path = "../../packages/vm", default-features = false } From 097593e413ad6ebd38815aab3a9ec16c7a26e9fa Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 3 May 2023 16:22:35 +0200 Subject: [PATCH 07/29] Handle storage manually for reflect contracts --- contracts/ibc-reflect-send/src/contract.rs | 32 +++++------ contracts/ibc-reflect-send/src/ibc.rs | 57 +++++++++--------- contracts/ibc-reflect-send/src/state.rs | 63 +++++++++++++++----- contracts/ibc-reflect/src/contract.rs | 46 ++++++++------- contracts/ibc-reflect/src/state.rs | 67 ++++++++++++++++------ contracts/reflect/src/contract.rs | 39 +++++++------ contracts/reflect/src/state.rs | 37 ++++++++---- 7 files changed, 211 insertions(+), 130 deletions(-) diff --git a/contracts/ibc-reflect-send/src/contract.rs b/contracts/ibc-reflect-send/src/contract.rs index 3784fc57cd..50d074f3a8 100644 --- a/contracts/ibc-reflect-send/src/contract.rs +++ b/contracts/ibc-reflect-send/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ - entry_point, to_binary, CosmosMsg, Deps, DepsMut, Env, IbcMsg, MessageInfo, Order, - QueryResponse, Response, StdError, StdResult, + entry_point, to_binary, CosmosMsg, Deps, DepsMut, Env, IbcMsg, MessageInfo, QueryResponse, + Response, StdError, StdResult, }; use crate::ibc::PACKET_LIFETIME; @@ -9,7 +9,7 @@ use crate::msg::{ AccountInfo, AccountResponse, AdminResponse, ExecuteMsg, InstantiateMsg, ListAccountsResponse, QueryMsg, }; -use crate::state::{accounts, accounts_read, config, config_read, Config}; +use crate::state::{load_account, load_config, range_accounts, save_config, Config}; #[entry_point] pub fn instantiate( @@ -20,7 +20,7 @@ pub fn instantiate( ) -> StdResult { // we store the reflect_id for creating accounts later let cfg = Config { admin: info.sender }; - config(deps.storage).save(&cfg)?; + save_config(deps.storage, &cfg)?; Ok(Response::new().add_attribute("action", "instantiate")) } @@ -48,12 +48,12 @@ pub fn handle_update_admin( new_admin: String, ) -> StdResult { // auth check - let mut cfg = config(deps.storage).load()?; + let mut cfg = load_config(deps.storage)?; if info.sender != cfg.admin { return Err(StdError::generic_err("Only admin may set new admin")); } cfg.admin = deps.api.addr_validate(&new_admin)?; - config(deps.storage).save(&cfg)?; + save_config(deps.storage, &cfg)?; Ok(Response::new() .add_attribute("action", "handle_update_admin") @@ -68,12 +68,12 @@ pub fn handle_send_msgs( msgs: Vec, ) -> StdResult { // auth check - let cfg = config(deps.storage).load()?; + let cfg = load_config(deps.storage)?; if info.sender != cfg.admin { return Err(StdError::generic_err("Only admin may send messages")); } // ensure the channel exists (not found if not registered) - accounts(deps.storage).load(channel_id.as_bytes())?; + load_account(deps.storage, &channel_id)?; // construct a packet to send let packet = PacketMsg::Dispatch { msgs }; @@ -96,12 +96,12 @@ pub fn handle_check_remote_balance( channel_id: String, ) -> StdResult { // auth check - let cfg = config(deps.storage).load()?; + let cfg = load_config(deps.storage)?; if info.sender != cfg.admin { return Err(StdError::generic_err("Only admin may send messages")); } // ensure the channel exists (not found if not registered) - accounts(deps.storage).load(channel_id.as_bytes())?; + load_account(deps.storage, &channel_id)?; // construct a packet to send let packet = PacketMsg::Balances {}; @@ -141,7 +141,7 @@ pub fn handle_send_funds( } // load remote account - let data = accounts(deps.storage).load(reflect_channel_id.as_bytes())?; + let data = load_account(deps.storage, &reflect_channel_id)?; let remote_addr = match data.remote_addr { Some(addr) => addr, None => { @@ -175,16 +175,14 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { } fn query_account(deps: Deps, channel_id: String) -> StdResult { - let account = accounts_read(deps.storage).load(channel_id.as_bytes())?; + let account = load_account(deps.storage, &channel_id)?; Ok(account.into()) } fn query_list_accounts(deps: Deps) -> StdResult { - let accounts: StdResult> = accounts_read(deps.storage) - .range(None, None, Order::Ascending) + let accounts: StdResult> = range_accounts(deps.storage) .map(|r| { - let (k, account) = r?; - let channel_id = String::from_utf8(k)?; + let (channel_id, account) = r?; Ok(AccountInfo::convert(channel_id, account)) }) .collect(); @@ -194,7 +192,7 @@ fn query_list_accounts(deps: Deps) -> StdResult { } fn query_admin(deps: Deps) -> StdResult { - let Config { admin } = config_read(deps.storage).load()?; + let Config { admin } = load_config(deps.storage)?; Ok(AdminResponse { admin: admin.into(), }) diff --git a/contracts/ibc-reflect-send/src/ibc.rs b/contracts/ibc-reflect-send/src/ibc.rs index 2284c48457..76939acea8 100644 --- a/contracts/ibc-reflect-send/src/ibc.rs +++ b/contracts/ibc-reflect-send/src/ibc.rs @@ -7,7 +7,7 @@ use cosmwasm_std::{ use crate::ibc_msg::{ AcknowledgementMsg, BalancesResponse, DispatchResponse, PacketMsg, WhoAmIResponse, }; -use crate::state::{accounts, AccountData}; +use crate::state::{may_load_account, remove_account, save_account, AccountData}; pub const IBC_APP_VERSION: &str = "ibc-reflect-v1"; @@ -55,7 +55,7 @@ pub fn ibc_channel_connect( // create an account holder the channel exists (not found if not registered) let data = AccountData::default(); - accounts(deps.storage).save(channel_id.as_bytes(), &data)?; + save_account(deps.storage, channel_id, &data)?; // construct a packet to send let packet = PacketMsg::WhoAmI {}; @@ -82,7 +82,7 @@ pub fn ibc_channel_close( // remove the channel let channel_id = &channel.endpoint.channel_id; - accounts(deps.storage).remove(channel_id.as_bytes()); + remove_account(deps.storage, channel_id); Ok(IbcBasicResponse::new() .add_attribute("action", "ibc_close") @@ -154,19 +154,16 @@ fn acknowledge_who_am_i( .add_attribute("error", e)) } }; - - accounts(deps.storage).update(caller.as_bytes(), |acct| -> StdResult<_> { - match acct { - Some(mut acct) => { - // set the account the first time - if acct.remote_addr.is_none() { - acct.remote_addr = Some(account); - } - Ok(acct) + match may_load_account(deps.storage, &caller)? { + Some(mut acct) => { + // set the account the first time + if acct.remote_addr.is_none() { + acct.remote_addr = Some(account); } - None => Err(StdError::generic_err("no account to update")), + save_account(deps.storage, &caller, &acct)?; } - })?; + None => return Err(StdError::generic_err("no account to update")), + } Ok(IbcBasicResponse::new().add_attribute("action", "acknowledge_who_am_i")) } @@ -188,26 +185,28 @@ fn acknowledge_balances( } }; - accounts(deps.storage).update(caller.as_bytes(), |acct| -> StdResult<_> { - match acct { - Some(acct) => { - if let Some(old_addr) = acct.remote_addr { - if old_addr != account { - return Err(StdError::generic_err(format!( - "remote account changed from {} to {}", - old_addr, account - ))); - } + match may_load_account(deps.storage, &caller)? { + Some(acct) => { + if let Some(old_addr) = acct.remote_addr { + if old_addr != account { + return Err(StdError::generic_err(format!( + "remote account changed from {} to {}", + old_addr, account + ))); } - Ok(AccountData { + } + save_account( + deps.storage, + &caller, + &AccountData { last_update_time: env.block.time, remote_addr: Some(account), remote_balance: balances, - }) - } - None => Err(StdError::generic_err("no account to update")), + }, + )?; } - })?; + None => return Err(StdError::generic_err("no account to update")), + } Ok(IbcBasicResponse::new().add_attribute("action", "acknowledge_balances")) } diff --git a/contracts/ibc-reflect-send/src/state.rs b/contracts/ibc-reflect-send/src/state.rs index a44d66b1d5..ab7960463d 100644 --- a/contracts/ibc-reflect-send/src/state.rs +++ b/contracts/ibc-reflect-send/src/state.rs @@ -1,13 +1,15 @@ use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, Coin, Storage, Timestamp}; -use cosmwasm_storage::{ - bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton, - Singleton, +use cosmwasm_std::{ + from_slice, storage_keys::namespace_with_key, to_vec, Addr, Coin, Order, StdError, StdResult, + Storage, Timestamp, }; pub const KEY_CONFIG: &[u8] = b"config"; +/// accounts is lookup of channel_id to reflect contract pub const PREFIX_ACCOUNTS: &[u8] = b"accounts"; +/// Upper bound for ranging over accounts +const PREFIX_ACCOUNTS_UPPER_BOUND: &[u8] = b"accountt"; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct Config { @@ -27,19 +29,54 @@ pub struct AccountData { pub remote_balance: Vec, } -/// accounts is lookup of channel_id to reflect contract -pub fn accounts(storage: &mut dyn Storage) -> Bucket { - bucket(storage, PREFIX_ACCOUNTS) +pub fn may_load_account(storage: &dyn Storage, id: &str) -> StdResult> { + storage + .get(&namespace_with_key(&[PREFIX_ACCOUNTS], id.as_bytes())) + .map(|v| from_slice(&v)) + .transpose() +} + +pub fn load_account(storage: &dyn Storage, id: &str) -> StdResult { + may_load_account(storage, id)?.ok_or_else(|| StdError::not_found(format!("account {}", id))) +} + +pub fn save_account(storage: &mut dyn Storage, id: &str, account: &AccountData) -> StdResult<()> { + storage.set( + &namespace_with_key(&[PREFIX_ACCOUNTS], id.as_bytes()), + &to_vec(account)?, + ); + Ok(()) +} + +pub fn remove_account(storage: &mut dyn Storage, id: &str) { + storage.remove(&namespace_with_key(&[PREFIX_ACCOUNTS], id.as_bytes())); } -pub fn accounts_read(storage: &dyn Storage) -> ReadonlyBucket { - bucket_read(storage, PREFIX_ACCOUNTS) +pub fn range_accounts( + storage: &dyn Storage, +) -> impl Iterator> + '_ { + storage + .range( + Some(PREFIX_ACCOUNTS), + Some(PREFIX_ACCOUNTS_UPPER_BOUND), + Order::Ascending, + ) + .map(|(key, val)| { + Ok(( + String::from_utf8(key[PREFIX_ACCOUNTS.len()..].to_vec())?, + from_slice(&val)?, + )) + }) } -pub fn config(storage: &mut dyn Storage) -> Singleton { - singleton(storage, KEY_CONFIG) +pub fn load_config(storage: &dyn Storage) -> StdResult { + storage + .get(KEY_CONFIG) + .ok_or_else(|| StdError::not_found("config")) + .and_then(|v| from_slice(&v)) } -pub fn config_read(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, KEY_CONFIG) +pub fn save_config(storage: &mut dyn Storage, item: &Config) -> StdResult<()> { + storage.set(KEY_CONFIG, &to_vec(item)?); + Ok(()) } diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index 04750f00ec..0e3e3673b7 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{ entry_point, from_slice, to_binary, wasm_execute, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, Event, Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcOrder, IbcPacketAckMsg, - IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, MessageInfo, Never, Order, + IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, MessageInfo, Never, QueryResponse, Reply, Response, StdError, StdResult, SubMsg, SubMsgResponse, SubMsgResult, WasmMsg, }; @@ -11,7 +11,10 @@ use crate::msg::{ AccountInfo, AccountResponse, AcknowledgementMsg, BalancesResponse, DispatchResponse, InstantiateMsg, ListAccountsResponse, PacketMsg, QueryMsg, ReflectExecuteMsg, WhoAmIResponse, }; -use crate::state::{accounts, accounts_read, config, pending_channel, Config}; +use crate::state::{ + load_account, load_item, may_load_account, range_accounts, remove_account, save_account, + save_item, Config, KEY_CONFIG, KEY_PENDING_CHANNEL, +}; pub const IBC_APP_VERSION: &str = "ibc-reflect-v1"; pub const RECEIVE_DISPATCH_ID: u64 = 1234; @@ -28,7 +31,7 @@ pub fn instantiate( let cfg = Config { reflect_code_id: msg.reflect_code_id, }; - config(deps.storage).save(&cfg)?; + save_item(deps.storage, KEY_CONFIG, &cfg)?; Ok(Response::new().add_attribute("action", "instantiate")) } @@ -59,8 +62,8 @@ fn parse_contract_from_event(events: Vec) -> Option { pub fn handle_init_callback(deps: DepsMut, response: SubMsgResponse) -> StdResult { // we use storage to pass info from the caller to the reply - let id = pending_channel(deps.storage).load()?; - pending_channel(deps.storage).remove(); + let id: String = load_item(deps.storage, KEY_PENDING_CHANNEL)?; + deps.storage.remove(KEY_PENDING_CHANNEL); // parse contract info from events let contract_addr = match parse_contract_from_event(response.events) { @@ -72,14 +75,14 @@ pub fn handle_init_callback(deps: DepsMut, response: SubMsgResponse) -> StdResul // store id -> contract_addr if it is empty // id comes from: `let chan_id = msg.endpoint.channel_id;` in `ibc_channel_connect` - accounts(deps.storage).update(id.as_bytes(), |val| -> StdResult<_> { - match val { - Some(_) => Err(StdError::generic_err( + match may_load_account(deps.storage, &id)? { + Some(_) => { + return Err(StdError::generic_err( "Cannot register over an existing channel", - )), - None => Ok(contract_addr), + )) } - })?; + None => save_account(deps.storage, &id, &contract_addr)?, + } Ok(Response::new().add_attribute("action", "execute_init_callback")) } @@ -93,20 +96,19 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { } pub fn query_account(deps: Deps, channel_id: String) -> StdResult { - let account = accounts_read(deps.storage).load(channel_id.as_bytes())?; + let account = load_account(deps.storage, &channel_id)?; Ok(AccountResponse { account: Some(account.into()), }) } pub fn query_list_accounts(deps: Deps) -> StdResult { - let accounts: StdResult> = accounts_read(deps.storage) - .range(None, None, Order::Ascending) + let accounts: StdResult> = range_accounts(deps.storage) .map(|item| { let (key, account) = item?; Ok(AccountInfo { account: account.into(), - channel_id: String::from_utf8(key)?, + channel_id: key, }) }) .collect(); @@ -153,7 +155,7 @@ pub fn ibc_channel_connect( msg: IbcChannelConnectMsg, ) -> StdResult { let channel = msg.channel(); - let cfg = config(deps.storage).load()?; + let cfg: Config = load_item(deps.storage, KEY_CONFIG)?; let chan_id = &channel.endpoint.channel_id; let msg = WasmMsg::Instantiate { @@ -166,7 +168,7 @@ pub fn ibc_channel_connect( let msg = SubMsg::reply_on_success(msg, INIT_CALLBACK_ID); // store the channel id for the reply handler - pending_channel(deps.storage).save(chan_id)?; + save_item(deps.storage, KEY_PENDING_CHANNEL, chan_id)?; Ok(IbcBasicResponse::new() .add_submessage(msg) @@ -186,8 +188,8 @@ pub fn ibc_channel_close( let channel = msg.channel(); // get contract address and remove lookup let channel_id = channel.endpoint.channel_id.as_str(); - let reflect_addr = accounts(deps.storage).load(channel_id.as_bytes())?; - accounts(deps.storage).remove(channel_id.as_bytes()); + let reflect_addr = load_account(deps.storage, channel_id)?; + remove_account(deps.storage, channel_id); // transfer current balance if any (steal the money) let amount = deps.querier.query_all_balances(&reflect_addr)?; @@ -258,7 +260,7 @@ pub fn ibc_packet_receive( // processes PacketMsg::WhoAmI variant fn receive_who_am_i(deps: DepsMut, caller: String) -> StdResult { - let account = accounts(deps.storage).load(caller.as_bytes())?; + let account = load_account(deps.storage, &caller)?; let response = WhoAmIResponse { account: account.into(), }; @@ -271,7 +273,7 @@ fn receive_who_am_i(deps: DepsMut, caller: String) -> StdResult StdResult { - let account = accounts(deps.storage).load(caller.as_bytes())?; + let account = load_account(deps.storage, &caller)?; let balances = deps.querier.query_all_balances(&account)?; let response = BalancesResponse { account: account.into(), @@ -291,7 +293,7 @@ fn receive_dispatch( msgs: Vec, ) -> StdResult { // what is the reflect contract here - let reflect_addr = accounts(deps.storage).load(caller.as_bytes())?; + let reflect_addr = load_account(deps.storage, &caller)?; // let them know we're fine let acknowledgement = to_binary(&AcknowledgementMsg::::Ok(()))?; diff --git a/contracts/ibc-reflect/src/state.rs b/contracts/ibc-reflect/src/state.rs index 9b0bbfe524..71d22827a7 100644 --- a/contracts/ibc-reflect/src/state.rs +++ b/contracts/ibc-reflect/src/state.rs @@ -1,39 +1,70 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use std::any::type_name; -use cosmwasm_std::{Addr, Storage}; -use cosmwasm_storage::{ - bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton, - Singleton, +use cosmwasm_std::{ + from_slice, storage_keys::namespace_with_key, to_vec, Addr, Order, StdError, StdResult, Storage, }; +use schemars::JsonSchema; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; pub const KEY_CONFIG: &[u8] = b"config"; pub const KEY_PENDING_CHANNEL: &[u8] = b"pending"; pub const PREFIX_ACCOUNTS: &[u8] = b"accounts"; +/// Upper bound for ranging over accounts +const PREFIX_ACCOUNTS_UPPER_BOUND: &[u8] = b"accountt"; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct Config { pub reflect_code_id: u64, } -/// accounts is lookup of channel_id to reflect contract -pub fn accounts(storage: &mut dyn Storage) -> Bucket { - bucket(storage, PREFIX_ACCOUNTS) +pub fn may_load_account(storage: &dyn Storage, id: &str) -> StdResult> { + storage + .get(&namespace_with_key(&[PREFIX_ACCOUNTS], id.as_bytes())) + .map(|v| from_slice(&v)) + .transpose() +} + +pub fn load_account(storage: &dyn Storage, id: &str) -> StdResult { + may_load_account(storage, id)?.ok_or_else(|| StdError::not_found(format!("account {}", id))) +} + +pub fn save_account(storage: &mut dyn Storage, id: &str, account: &Addr) -> StdResult<()> { + storage.set( + &namespace_with_key(&[PREFIX_ACCOUNTS], id.as_bytes()), + &to_vec(account)?, + ); + Ok(()) } -pub fn accounts_read(storage: &dyn Storage) -> ReadonlyBucket { - bucket_read(storage, PREFIX_ACCOUNTS) +pub fn remove_account(storage: &mut dyn Storage, id: &str) { + storage.remove(&namespace_with_key(&[PREFIX_ACCOUNTS], id.as_bytes())); } -pub fn config(storage: &mut dyn Storage) -> Singleton { - singleton(storage, KEY_CONFIG) +pub fn range_accounts( + storage: &dyn Storage, +) -> impl Iterator> + '_ { + storage + .range( + Some(PREFIX_ACCOUNTS), + Some(PREFIX_ACCOUNTS_UPPER_BOUND), + Order::Ascending, + ) + .map(|(key, val)| { + Ok(( + String::from_utf8(key[PREFIX_ACCOUNTS.len()..].to_vec())?, + from_slice(&val)?, + )) + }) } -pub fn config_read(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, KEY_CONFIG) +pub fn load_item(storage: &dyn Storage, key: &[u8]) -> StdResult { + storage + .get(key) + .ok_or_else(|| StdError::not_found(type_name::())) + .and_then(|v| from_slice(&v)) } -/// pending_channel is used to pass info from ibc_channel_connect to the reply handler -pub fn pending_channel(storage: &mut dyn Storage) -> Singleton { - singleton(storage, KEY_PENDING_CHANNEL) +pub fn save_item(storage: &mut dyn Storage, key: &[u8], item: &T) -> StdResult<()> { + storage.set(key, &to_vec(item)?); + Ok(()) } diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index f760a9a271..5334dbcbc1 100644 --- a/contracts/reflect/src/contract.rs +++ b/contracts/reflect/src/contract.rs @@ -9,7 +9,7 @@ use crate::msg::{ CapitalizedResponse, ChainResponse, CustomMsg, ExecuteMsg, InstantiateMsg, OwnerResponse, QueryMsg, RawResponse, SpecialQuery, SpecialResponse, }; -use crate::state::{config, config_read, replies, replies_read, State}; +use crate::state::{load_config, load_reply, save_config, save_reply, State}; #[entry_point] pub fn instantiate( @@ -19,7 +19,7 @@ pub fn instantiate( _msg: InstantiateMsg, ) -> StdResult> { let state = State { owner: info.sender }; - config(deps.storage).save(&state)?; + save_config(deps.storage, &state)?; Ok(Response::default()) } @@ -43,7 +43,7 @@ pub fn try_reflect( info: MessageInfo, msgs: Vec>, ) -> Result, ReflectError> { - let state = config(deps.storage).load()?; + let state = load_config(deps.storage)?; if info.sender != state.owner { return Err(ReflectError::NotCurrentOwner { @@ -67,7 +67,7 @@ pub fn try_reflect_subcall( info: MessageInfo, msgs: Vec>, ) -> Result, ReflectError> { - let state = config(deps.storage).load()?; + let state = load_config(deps.storage)?; if info.sender != state.owner { return Err(ReflectError::NotCurrentOwner { expected: state.owner.into(), @@ -91,16 +91,19 @@ pub fn try_change_owner( new_owner: String, ) -> Result, ReflectError> { let api = deps.api; - config(deps.storage).update(|mut state| { - if info.sender != state.owner { - return Err(ReflectError::NotCurrentOwner { - expected: state.owner.into(), - actual: info.sender.into(), - }); - } - state.owner = api.addr_validate(&new_owner)?; - Ok(state) - })?; + + let mut state = load_config(deps.storage)?; + + if info.sender != state.owner { + return Err(ReflectError::NotCurrentOwner { + expected: state.owner.into(), + actual: info.sender.into(), + }); + } + state.owner = api.addr_validate(&new_owner)?; + + save_config(deps.storage, &state)?; + Ok(Response::new() .add_attribute("action", "change_owner") .add_attribute("owner", new_owner)) @@ -109,8 +112,7 @@ pub fn try_change_owner( /// This just stores the result for future query #[entry_point] pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result { - let key = msg.id.to_be_bytes(); - replies(deps.storage).save(&key, &msg)?; + save_reply(deps.storage, msg.id, &msg)?; Ok(Response::default()) } @@ -126,7 +128,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult) -> StdResult { - let state = config_read(deps.storage).load()?; + let state = load_config(deps.storage)?; let resp = OwnerResponse { owner: state.owner.into(), }; @@ -134,8 +136,7 @@ fn query_owner(deps: Deps) -> StdResult { } fn query_subcall(deps: Deps, id: u64) -> StdResult { - let key = id.to_be_bytes(); - replies_read(deps.storage).load(&key) + load_reply(deps.storage, id) } fn query_capitalized(deps: Deps, text: String) -> StdResult { diff --git a/contracts/reflect/src/state.rs b/contracts/reflect/src/state.rs index b1d52aa3e6..df39f4ed58 100644 --- a/contracts/reflect/src/state.rs +++ b/contracts/reflect/src/state.rs @@ -1,10 +1,8 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, Reply, Storage}; -use cosmwasm_storage::{ - bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton, - Singleton, +use cosmwasm_std::{ + from_slice, storage_keys::namespace_with_key, to_vec, Addr, Reply, StdError, StdResult, Storage, }; const CONFIG_KEY: &[u8] = b"config"; @@ -15,18 +13,33 @@ pub struct State { pub owner: Addr, } -pub fn config(storage: &mut dyn Storage) -> Singleton { - singleton(storage, CONFIG_KEY) +pub fn load_reply(storage: &dyn Storage, id: u64) -> StdResult { + storage + .get(&namespace_with_key(&[RESULT_PREFIX], &id.to_be_bytes())) + .ok_or_else(|| StdError::not_found(format!("reply {}", id))) + .and_then(|v| from_slice(&v)) } -pub fn config_read(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, CONFIG_KEY) +pub fn save_reply(storage: &mut dyn Storage, id: u64, reply: &Reply) -> StdResult<()> { + storage.set( + &namespace_with_key(&[RESULT_PREFIX], &id.to_be_bytes()), + &to_vec(reply)?, + ); + Ok(()) } -pub fn replies(storage: &mut dyn Storage) -> Bucket { - bucket(storage, RESULT_PREFIX) +pub fn remove_reply(storage: &mut dyn Storage, id: u64) { + storage.remove(&namespace_with_key(&[RESULT_PREFIX], &id.to_be_bytes())); } -pub fn replies_read(storage: &dyn Storage) -> ReadonlyBucket { - bucket_read(storage, RESULT_PREFIX) +pub fn load_config(storage: &dyn Storage) -> StdResult { + storage + .get(CONFIG_KEY) + .ok_or_else(|| StdError::not_found("config")) + .and_then(|v| from_slice(&v)) +} + +pub fn save_config(storage: &mut dyn Storage, item: &State) -> StdResult<()> { + storage.set(CONFIG_KEY, &to_vec(item)?); + Ok(()) } From 9612d2c1d26ac5da0fcc46dca2a610912c1f9f37 Mon Sep 17 00:00:00 2001 From: Andrei Petrovich Date: Wed, 3 May 2023 20:52:16 +0200 Subject: [PATCH 08/29] Bump min rust version to 1.64.0 --- .circleci/config.yml | 144 +++++++++++++++++++-------------------- .github/workflows/ci.yml | 2 +- 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 05d72ae197..a3b30467f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -72,7 +72,7 @@ workflows: matrix: parameters: # Run with MSRV and some modern stable Rust - rust-version: ["1.60.0", "1.68.2"] + rust-version: ["1.64.0", "1.68.2"] - benchmarking: requires: - package_vm @@ -117,7 +117,7 @@ jobs: command: | wget https://static.rust-lang.org/rustup/dist/aarch64-unknown-linux-gnu/rustup-init chmod +x rustup-init - ./rustup-init -y --default-toolchain 1.60.0 --profile minimal + ./rustup-init -y --default-toolchain 1.64.0 --profile minimal - run: name: Version information command: rustc --version; cargo --version; rustup --version; rustup target list --installed @@ -126,12 +126,12 @@ jobs: command: rustup target add wasm32-unknown-unknown && rustup target list --installed - restore_cache: keys: - - v4-arm64-workspace-rust:1.60.0-{{ checksum "Cargo.lock" }} - - v4-arm64-workspace-rust:1.60.0- + - v4-arm64-workspace-rust:1.64.0-{{ checksum "Cargo.lock" }} + - v4-arm64-workspace-rust:1.64.0- - restore_cache: keys: - - v4-arm64-contracts-rust:1.60.0-{{ checksum "contracts/crypto-verify/Cargo.lock" }}-{{ checksum "contracts/hackatom/Cargo.lock" }}-{{ checksum "contracts/queue/Cargo.lock" }}-{{ checksum "contracts/reflect/Cargo.lock" }}-{{ checksum "contracts/staking/Cargo.lock" }} - - v4-arm64-contracts-rust:1.60.0- + - v4-arm64-contracts-rust:1.64.0-{{ checksum "contracts/crypto-verify/Cargo.lock" }}-{{ checksum "contracts/hackatom/Cargo.lock" }}-{{ checksum "contracts/queue/Cargo.lock" }}-{{ checksum "contracts/reflect/Cargo.lock" }}-{{ checksum "contracts/staking/Cargo.lock" }} + - v4-arm64-contracts-rust:1.64.0- # Test a few contracts that do something potentially interesting in the VM # to test contract execution on ARM64. # No need to add all contracts here. @@ -169,14 +169,14 @@ jobs: # use all features command: cargo test --locked --features iterator,staking,stargate - save_cache: - key: v4-arm64-workspace-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: v4-arm64-workspace-rust:1.64.0-{{ checksum "Cargo.lock" }} paths: - ~/.cargo/registry - target/debug/.fingerprint - target/debug/build - target/debug/deps - save_cache: - key: v4-arm64-contracts-rust:1.60.0-{{ checksum "contracts/crypto-verify/Cargo.lock" }}-{{ checksum "contracts/hackatom/Cargo.lock" }}-{{ checksum "contracts/queue/Cargo.lock" }}-{{ checksum "contracts/reflect/Cargo.lock" }}-{{ checksum "contracts/staking/Cargo.lock" }} + key: v4-arm64-contracts-rust:1.64.0-{{ checksum "contracts/crypto-verify/Cargo.lock" }}-{{ checksum "contracts/hackatom/Cargo.lock" }}-{{ checksum "contracts/queue/Cargo.lock" }}-{{ checksum "contracts/reflect/Cargo.lock" }}-{{ checksum "contracts/staking/Cargo.lock" }} paths: - ~/.cargo/registry # crypto-verify @@ -217,7 +217,7 @@ jobs: package_crypto: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 steps: - checkout - run: @@ -225,7 +225,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_crypto-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_crypto-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/crypto @@ -240,11 +240,11 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_crypto-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_crypto-rust:1.64.0-{{ checksum "Cargo.lock" }} package_check: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 steps: - checkout - run: @@ -252,7 +252,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_check-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_check-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/check @@ -267,11 +267,11 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_check-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_check-rust:1.64.0-{{ checksum "Cargo.lock" }} package_schema: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 steps: - checkout - run: @@ -279,7 +279,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_schema-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_schema-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/schema @@ -294,11 +294,11 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_schema-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_schema-rust:1.64.0-{{ checksum "Cargo.lock" }} package_schema_derive: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 steps: - checkout - run: @@ -306,7 +306,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_schema_derive-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_schema_derive-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/schema-derive @@ -321,11 +321,11 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_schema_derive-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_schema_derive-rust:1.64.0-{{ checksum "Cargo.lock" }} package_std: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: # Limit the number of parallel jobs to avoid OOM crashes during doc testing RUST_TEST_THREADS: 8 @@ -336,7 +336,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_std-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_std-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Add wasm32 target command: rustup target add wasm32-unknown-unknown && rustup target list --installed @@ -370,11 +370,11 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_std-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_std-rust:1.64.0-{{ checksum "Cargo.lock" }} package_storage: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 steps: - checkout - run: @@ -382,7 +382,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_storage-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_storage-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Build library for native target working_directory: ~/project/packages/storage @@ -401,11 +401,11 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_storage-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_storage-rust:1.64.0-{{ checksum "Cargo.lock" }} package_vm: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 steps: - checkout - run: @@ -413,7 +413,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_vm-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_vm-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/vm @@ -442,7 +442,7 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_vm-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_vm-rust:1.64.0-{{ checksum "Cargo.lock" }} package_vm_windows: executor: @@ -490,7 +490,7 @@ jobs: contract_burner: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/burner @@ -502,7 +502,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_burner-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_burner-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -513,11 +513,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_burner-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_burner-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_crypto_verify: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/crypto-verify @@ -529,7 +529,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_crypto_verify-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_crypto_verify-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -540,11 +540,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_crypto_verify-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_crypto_verify-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_cyberpunk: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/cyberpunk @@ -556,7 +556,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_cyberpunk-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_cyberpunk-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -567,11 +567,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_cyberpunk-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_cyberpunk-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_hackatom: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/hackatom @@ -583,7 +583,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_hackatom-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_hackatom-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -594,11 +594,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_hackatom-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_hackatom-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_ibc_reflect: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/ibc-reflect @@ -610,7 +610,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_ibc_reflect-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_ibc_reflect-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -621,11 +621,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_ibc_reflect-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_ibc_reflect-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_ibc_reflect_send: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/ibc-reflect-send @@ -637,7 +637,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_ibc_reflect_send-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_ibc_reflect_send-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -648,11 +648,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_ibc_reflect_send-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_ibc_reflect_send-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_floaty: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/floaty @@ -664,7 +664,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_floaty-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_floaty-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -675,11 +675,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_floaty-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_floaty-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_queue: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/queue @@ -691,7 +691,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_queue-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_queue-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -702,11 +702,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_queue-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_queue-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_reflect: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/reflect @@ -718,7 +718,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_reflect-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_reflect-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -729,11 +729,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_reflect-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_reflect-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_staking: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/staking @@ -745,7 +745,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_staking-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_staking-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -756,11 +756,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_staking-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_staking-rust:1.64.0-{{ checksum "Cargo.lock" }} contract_virus: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 working_directory: ~/cosmwasm/contracts/virus @@ -772,7 +772,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-v2-contract_virus-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-contract_virus-rust:1.64.0-{{ checksum "Cargo.lock" }} - check_contract - save_cache: paths: @@ -783,11 +783,11 @@ jobs: - target/wasm32-unknown-unknown/release/.fingerprint - target/wasm32-unknown-unknown/release/build - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_virus-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-contract_virus-rust:1.64.0-{{ checksum "Cargo.lock" }} fmt: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 steps: - checkout - run: @@ -795,7 +795,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-fmt-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-fmt-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Add rustfmt component command: rustup component add rustfmt @@ -808,7 +808,7 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-fmt-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-fmt-rust:1.64.0-{{ checksum "Cargo.lock" }} fmt_extra: docker: @@ -830,7 +830,7 @@ jobs: deadlinks: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 steps: - checkout - run: @@ -838,7 +838,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-deadlinks-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-deadlinks-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Generate docs command: cargo doc @@ -858,7 +858,7 @@ jobs: - target/debug/build - target/debug/deps - /root/.cache/pip - key: cargocache-v2-deadlinks-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-deadlinks-rust:1.64.0-{{ checksum "Cargo.lock" }} clippy: parameters: @@ -934,7 +934,7 @@ jobs: benchmarking: docker: - - image: rust:1.60.0 + - image: rust:1.64.0 environment: RUST_BACKTRACE: 1 steps: @@ -944,7 +944,7 @@ jobs: command: rustc --version && cargo --version - restore_cache: keys: - - cargocache-v2-benchmarking-rust:1.60.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-benchmarking-rust:1.64.0-{{ checksum "Cargo.lock" }} - run: name: Run vm benchmarks (Singlepass) working_directory: ~/project/packages/vm @@ -962,7 +962,7 @@ jobs: - target/release/.fingerprint - target/release/build - target/release/deps - key: cargocache-v2-benchmarking-rust:1.60.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-benchmarking-rust:1.64.0-{{ checksum "Cargo.lock" }} coverage: # https://circleci.com/developer/images?imageType=machine @@ -1034,7 +1034,7 @@ jobs: name: Check development contracts command: | echo "Checking all contracts under ./artifacts" - docker run --volumes-from with_code rust:1.60.0 \ + docker run --volumes-from with_code rust:1.64.0 \ /bin/bash -e -c 'export GLOBIGNORE="artifacts/floaty.wasm"; cd ./code; cargo run --bin cosmwasm-check artifacts/*.wasm' docker cp with_code:/code/artifacts . - run: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d50ccbda5..3235e56020 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.60.0 + toolchain: 1.64.0 target: wasm32-unknown-unknown profile: minimal override: true From 647b7be86b73e1990ba4c51aca398a5b74f93739 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 May 2023 12:24:42 +0200 Subject: [PATCH 09/29] Fix manual range implementation --- contracts/ibc-reflect-send/src/state.rs | 11 +++++------ contracts/ibc-reflect/src/contract.rs | 2 +- contracts/ibc-reflect/src/state.rs | 11 +++++------ contracts/ibc-reflect/tests/integration.rs | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/contracts/ibc-reflect-send/src/state.rs b/contracts/ibc-reflect-send/src/state.rs index ab7960463d..92110c697a 100644 --- a/contracts/ibc-reflect-send/src/state.rs +++ b/contracts/ibc-reflect-send/src/state.rs @@ -1,3 +1,4 @@ +use cosmwasm_storage::to_length_prefixed; use serde::{Deserialize, Serialize}; use cosmwasm_std::{ @@ -55,15 +56,13 @@ pub fn remove_account(storage: &mut dyn Storage, id: &str) { pub fn range_accounts( storage: &dyn Storage, ) -> impl Iterator> + '_ { + let prefix = to_length_prefixed(PREFIX_ACCOUNTS); + let upper_bound = to_length_prefixed(PREFIX_ACCOUNTS_UPPER_BOUND); storage - .range( - Some(PREFIX_ACCOUNTS), - Some(PREFIX_ACCOUNTS_UPPER_BOUND), - Order::Ascending, - ) + .range(Some(&prefix), Some(&upper_bound), Order::Ascending) .map(|(key, val)| { Ok(( - String::from_utf8(key[PREFIX_ACCOUNTS.len()..].to_vec())?, + String::from_utf8(key[PREFIX_ACCOUNTS.len() + 2..].to_vec())?, from_slice(&val)?, )) }) diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index 0e3e3673b7..a2c9117c55 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -529,7 +529,7 @@ mod tests { let ack: AcknowledgementMsg = from_slice(&res.acknowledgement).unwrap(); assert_eq!( ack.unwrap_err(), - "invalid packet: cosmwasm_std::addresses::Addr not found" + "invalid packet: account channel-123 not found" ); // register the channel diff --git a/contracts/ibc-reflect/src/state.rs b/contracts/ibc-reflect/src/state.rs index 71d22827a7..86802d7a4e 100644 --- a/contracts/ibc-reflect/src/state.rs +++ b/contracts/ibc-reflect/src/state.rs @@ -3,6 +3,7 @@ use std::any::type_name; use cosmwasm_std::{ from_slice, storage_keys::namespace_with_key, to_vec, Addr, Order, StdError, StdResult, Storage, }; +use cosmwasm_storage::to_length_prefixed; use schemars::JsonSchema; use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -43,15 +44,13 @@ pub fn remove_account(storage: &mut dyn Storage, id: &str) { pub fn range_accounts( storage: &dyn Storage, ) -> impl Iterator> + '_ { + let prefix = to_length_prefixed(PREFIX_ACCOUNTS); + let upper_bound = to_length_prefixed(PREFIX_ACCOUNTS_UPPER_BOUND); storage - .range( - Some(PREFIX_ACCOUNTS), - Some(PREFIX_ACCOUNTS_UPPER_BOUND), - Order::Ascending, - ) + .range(Some(&prefix), Some(&upper_bound), Order::Ascending) .map(|(key, val)| { Ok(( - String::from_utf8(key[PREFIX_ACCOUNTS.len()..].to_vec())?, + String::from_utf8(key[PREFIX_ACCOUNTS.len() + 2..].to_vec())?, from_slice(&val)?, )) }) diff --git a/contracts/ibc-reflect/tests/integration.rs b/contracts/ibc-reflect/tests/integration.rs index d28e3369a4..edeb91e989 100644 --- a/contracts/ibc-reflect/tests/integration.rs +++ b/contracts/ibc-reflect/tests/integration.rs @@ -236,7 +236,7 @@ fn handle_dispatch_packet() { from_slice(&res.acknowledgement, DESERIALIZATION_LIMIT).unwrap(); assert_eq!( ack.unwrap_err(), - "invalid packet: cosmwasm_std::addresses::Addr not found" + "invalid packet: account channel-123 not found" ); // register the channel From 7ed67400de819d67363f803f5cd8f4f2d88376b5 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 May 2023 13:48:57 +0200 Subject: [PATCH 10/29] Use length-prefixing for contract keys --- contracts/ibc-reflect-send/src/state.rs | 4 ++-- contracts/ibc-reflect/src/state.rs | 4 ++-- contracts/reflect/src/state.rs | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/contracts/ibc-reflect-send/src/state.rs b/contracts/ibc-reflect-send/src/state.rs index 92110c697a..a04e815dc9 100644 --- a/contracts/ibc-reflect-send/src/state.rs +++ b/contracts/ibc-reflect-send/src/state.rs @@ -70,12 +70,12 @@ pub fn range_accounts( pub fn load_config(storage: &dyn Storage) -> StdResult { storage - .get(KEY_CONFIG) + .get(&to_length_prefixed(KEY_CONFIG)) .ok_or_else(|| StdError::not_found("config")) .and_then(|v| from_slice(&v)) } pub fn save_config(storage: &mut dyn Storage, item: &Config) -> StdResult<()> { - storage.set(KEY_CONFIG, &to_vec(item)?); + storage.set(&to_length_prefixed(KEY_CONFIG), &to_vec(item)?); Ok(()) } diff --git a/contracts/ibc-reflect/src/state.rs b/contracts/ibc-reflect/src/state.rs index 86802d7a4e..491ac1c638 100644 --- a/contracts/ibc-reflect/src/state.rs +++ b/contracts/ibc-reflect/src/state.rs @@ -58,12 +58,12 @@ pub fn range_accounts( pub fn load_item(storage: &dyn Storage, key: &[u8]) -> StdResult { storage - .get(key) + .get(&to_length_prefixed(key)) .ok_or_else(|| StdError::not_found(type_name::())) .and_then(|v| from_slice(&v)) } pub fn save_item(storage: &mut dyn Storage, key: &[u8], item: &T) -> StdResult<()> { - storage.set(key, &to_vec(item)?); + storage.set(&to_length_prefixed(key), &to_vec(item)?); Ok(()) } diff --git a/contracts/reflect/src/state.rs b/contracts/reflect/src/state.rs index df39f4ed58..428a451df9 100644 --- a/contracts/reflect/src/state.rs +++ b/contracts/reflect/src/state.rs @@ -2,7 +2,9 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{ - from_slice, storage_keys::namespace_with_key, to_vec, Addr, Reply, StdError, StdResult, Storage, + from_slice, + storage_keys::{namespace_with_key, to_length_prefixed}, + to_vec, Addr, Reply, StdError, StdResult, Storage, }; const CONFIG_KEY: &[u8] = b"config"; @@ -34,12 +36,12 @@ pub fn remove_reply(storage: &mut dyn Storage, id: u64) { pub fn load_config(storage: &dyn Storage) -> StdResult { storage - .get(CONFIG_KEY) + .get(&to_length_prefixed(CONFIG_KEY)) .ok_or_else(|| StdError::not_found("config")) .and_then(|v| from_slice(&v)) } pub fn save_config(storage: &mut dyn Storage, item: &State) -> StdResult<()> { - storage.set(CONFIG_KEY, &to_vec(item)?); + storage.set(&to_length_prefixed(CONFIG_KEY), &to_vec(item)?); Ok(()) } From 336ce91197738c0fb3bed12fa8345abc1667681c Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 May 2023 13:49:25 +0200 Subject: [PATCH 11/29] Handle storage manually for staking contract --- contracts/staking/src/contract.rs | 110 +++++++++++++++--------------- contracts/staking/src/state.rs | 80 ++++++++++++---------- 2 files changed, 99 insertions(+), 91 deletions(-) diff --git a/contracts/staking/src/contract.rs b/contracts/staking/src/contract.rs index 5582652090..456fdb6c9d 100644 --- a/contracts/staking/src/contract.rs +++ b/contracts/staking/src/contract.rs @@ -10,8 +10,8 @@ use crate::msg::{ TokenInfoResponse, }; use crate::state::{ - balances, balances_read, claims, claims_read, invest_info, invest_info_read, token_info, - token_info_read, total_supply, total_supply_read, InvestmentInfo, Supply, TokenInfo, + load_item, may_load_map, save_item, save_map, update_item, InvestmentInfo, Supply, TokenInfo, + KEY_INVESTMENT, KEY_TOKEN_INFO, KEY_TOTAL_SUPPLY, PREFIX_BALANCE, PREFIX_CLAIMS, }; const FALLBACK_RATIO: Decimal = Decimal::one(); @@ -37,7 +37,7 @@ pub fn instantiate( symbol: msg.symbol, decimals: msg.decimals, }; - token_info(deps.storage).save(&token)?; + save_item(deps.storage, KEY_TOKEN_INFO, &token)?; let denom = deps.querier.query_bonded_denom()?; let invest = InvestmentInfo { @@ -47,11 +47,11 @@ pub fn instantiate( validator: msg.validator, min_withdrawal: msg.min_withdrawal, }; - invest_info(deps.storage).save(&invest)?; + save_item(deps.storage, KEY_INVESTMENT, &invest)?; // set supply to 0 let supply = Supply::default(); - total_supply(deps.storage).save(&supply)?; + save_item(deps.storage, KEY_TOTAL_SUPPLY, &supply)?; Ok(Response::default()) } @@ -85,13 +85,15 @@ pub fn transfer( let rcpt_raw = deps.api.addr_canonicalize(&recipient)?; let sender_raw = deps.api.addr_canonicalize(info.sender.as_str())?; - let mut accounts = balances(deps.storage); - accounts.update(&sender_raw, |balance: Option| -> StdResult<_> { - Ok(balance.unwrap_or_default().checked_sub(send)?) - })?; - accounts.update(&rcpt_raw, |balance: Option| -> StdResult<_> { - Ok(balance.unwrap_or_default() + send) - })?; + let balance = may_load_map(deps.storage, PREFIX_BALANCE, &sender_raw)?.unwrap_or_default(); + save_map( + deps.storage, + PREFIX_BALANCE, + &sender_raw, + balance.checked_sub(send)?, + )?; + let balance = may_load_map(deps.storage, PREFIX_BALANCE, &rcpt_raw)?.unwrap_or_default(); + save_map(deps.storage, PREFIX_BALANCE, &rcpt_raw, balance + send)?; let res = Response::new() .add_attribute("action", "transfer") @@ -137,7 +139,7 @@ pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult { let sender_raw = deps.api.addr_canonicalize(info.sender.as_str())?; // ensure we have the proper denom - let invest = invest_info_read(deps.storage).load()?; + let invest: InvestmentInfo = load_item(deps.storage, KEY_INVESTMENT)?; // payment finds the proper coin (or throws an error) let payment = info .funds @@ -149,8 +151,7 @@ pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult { let bonded = get_bonded(&deps.querier, env.contract.address)?; // calculate to_mint and update total supply - let mut totals = total_supply(deps.storage); - let mut supply = totals.load()?; + let mut supply: Supply = load_item(deps.storage, KEY_TOTAL_SUPPLY)?; // TODO: this is just temporary check - we should use dynamic query or have a way to recover assert_bonds(&supply, bonded)?; let to_mint = if supply.issued.is_zero() || bonded.is_zero() { @@ -160,12 +161,11 @@ pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult { }; supply.bonded = bonded + payment.amount; supply.issued += to_mint; - totals.save(&supply)?; + save_item(deps.storage, KEY_TOTAL_SUPPLY, &supply)?; // update the balance of the sender - balances(deps.storage).update(&sender_raw, |balance| -> StdResult<_> { - Ok(balance.unwrap_or_default() + to_mint) - })?; + let balance = may_load_map(deps.storage, PREFIX_BALANCE, &sender_raw)?.unwrap_or_default(); + save_map(deps.storage, PREFIX_BALANCE, &sender_raw, balance + to_mint)?; // bond them to the validator let res = Response::new() @@ -181,7 +181,7 @@ pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult { } pub fn unbond(deps: DepsMut, env: Env, info: MessageInfo, amount: Uint128) -> StdResult { - let invest = invest_info_read(deps.storage).load()?; + let invest: InvestmentInfo = load_item(deps.storage, KEY_INVESTMENT)?; // ensure it is big enough to care if amount < invest.min_withdrawal { return Err(StdError::generic_err(format!( @@ -197,15 +197,17 @@ pub fn unbond(deps: DepsMut, env: Env, info: MessageInfo, amount: Uint128) -> St let tax = amount * invest.exit_tax; // deduct all from the account - let mut accounts = balances(deps.storage); - accounts.update(&sender_raw, |balance| -> StdResult<_> { - Ok(balance.unwrap_or_default().checked_sub(amount)?) - })?; + let balance = may_load_map(deps.storage, PREFIX_BALANCE, &sender_raw)?.unwrap_or_default(); + save_map( + deps.storage, + PREFIX_BALANCE, + &sender_raw, + balance.checked_sub(amount)?, + )?; if tax > Uint128::new(0) { // add tax to the owner - accounts.update(&owner_raw, |balance: Option| -> StdResult<_> { - Ok(balance.unwrap_or_default() + tax) - })?; + let balance = may_load_map(deps.storage, PREFIX_BALANCE, &owner_raw)?.unwrap_or_default(); + save_map(deps.storage, PREFIX_BALANCE, &owner_raw, balance + tax)?; } // re-calculate bonded to ensure we have real values @@ -214,20 +216,18 @@ pub fn unbond(deps: DepsMut, env: Env, info: MessageInfo, amount: Uint128) -> St // calculate how many native tokens this is worth and update supply let remainder = amount.checked_sub(tax)?; - let mut totals = total_supply(deps.storage); - let mut supply = totals.load()?; + let mut supply: Supply = load_item(deps.storage, KEY_TOTAL_SUPPLY)?; // TODO: this is just temporary check - we should use dynamic query or have a way to recover assert_bonds(&supply, bonded)?; let unbond = remainder.multiply_ratio(bonded, supply.issued); supply.bonded = bonded.checked_sub(unbond)?; supply.issued = supply.issued.checked_sub(remainder)?; supply.claims += unbond; - totals.save(&supply)?; + save_item(deps.storage, KEY_TOTAL_SUPPLY, &supply)?; // add a claim to this user to get their tokens after the unbonding period - claims(deps.storage).update(&sender_raw, |claim| -> StdResult<_> { - Ok(claim.unwrap_or_default() + unbond) - })?; + let claim = may_load_map(deps.storage, PREFIX_CLAIMS, &sender_raw)?.unwrap_or_default(); + save_map(deps.storage, PREFIX_CLAIMS, &sender_raw, claim + unbond)?; // unbond them let res = Response::new() @@ -244,7 +244,7 @@ pub fn unbond(deps: DepsMut, env: Env, info: MessageInfo, amount: Uint128) -> St pub fn claim(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult { // find how many tokens the contract has - let invest = invest_info_read(deps.storage).load()?; + let invest: InvestmentInfo = load_item(deps.storage, KEY_INVESTMENT)?; let mut balance = deps .querier .query_balance(env.contract.address, invest.bond_denom)?; @@ -256,18 +256,20 @@ pub fn claim(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult // check how much to send - min(balance, claims[sender]), and reduce the claim let sender_raw = deps.api.addr_canonicalize(info.sender.as_str())?; - let mut to_send = balance.amount; - claims(deps.storage).update(sender_raw.as_slice(), |claim| -> StdResult<_> { - let claim = claim.ok_or_else(|| StdError::generic_err("no claim for this address"))?; - to_send = to_send.min(claim); - Ok(claim.checked_sub(to_send)?) - })?; + let claim = may_load_map(deps.storage, PREFIX_CLAIMS, &sender_raw)? + .ok_or_else(|| StdError::generic_err("no claim for this address"))?; + let to_send = balance.amount.min(claim); + save_map( + deps.storage, + PREFIX_CLAIMS, + &sender_raw, + claim.checked_sub(to_send)?, + )?; // update total supply (lower claim) - total_supply(deps.storage).update(|mut supply| -> StdResult<_> { - supply.claims = supply.claims.checked_sub(to_send)?; - Ok(supply) - })?; + let mut supply: Supply = load_item(deps.storage, KEY_TOTAL_SUPPLY)?; + supply.claims = supply.claims.checked_sub(to_send)?; + save_item(deps.storage, KEY_TOTAL_SUPPLY, &supply)?; // transfer tokens to the sender balance.amount = to_send; @@ -287,7 +289,7 @@ pub fn claim(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult /// to reinvest the new earnings (and anything else that accumulated) pub fn reinvest(deps: DepsMut, env: Env, _info: MessageInfo) -> StdResult { let contract_addr = env.contract.address; - let invest = invest_info_read(deps.storage).load()?; + let invest: InvestmentInfo = load_item(deps.storage, KEY_INVESTMENT)?; let msg = to_binary(&ExecuteMsg::_BondAllTokens {})?; // and bond them to the validator @@ -314,14 +316,14 @@ pub fn _bond_all_tokens( } // find how many tokens we have to bond - let invest = invest_info_read(deps.storage).load()?; + let invest: InvestmentInfo = load_item(deps.storage, KEY_INVESTMENT)?; let mut balance = deps .querier .query_balance(env.contract.address, &invest.bond_denom)?; // we deduct pending claims from our account balance before reinvesting. // if there is not enough funds, we just return a no-op - match total_supply(deps.storage).update(|mut supply| { + match update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| { balance.amount = balance.amount.checked_sub(supply.claims)?; // this just triggers the "no op" case if we don't have min_withdrawal left to reinvest balance.amount.checked_sub(invest.min_withdrawal)?; @@ -360,7 +362,7 @@ pub fn query_token_info(deps: Deps) -> StdResult { name, symbol, decimals, - } = token_info_read(deps.storage).load()?; + } = load_item(deps.storage, KEY_TOKEN_INFO)?; Ok(TokenInfoResponse { name, @@ -371,23 +373,19 @@ pub fn query_token_info(deps: Deps) -> StdResult { pub fn query_balance(deps: Deps, address: &str) -> StdResult { let address_raw = deps.api.addr_canonicalize(address)?; - let balance = balances_read(deps.storage) - .may_load(address_raw.as_slice())? - .unwrap_or_default(); + let balance = may_load_map(deps.storage, PREFIX_BALANCE, &address_raw)?.unwrap_or_default(); Ok(BalanceResponse { balance }) } pub fn query_claims(deps: Deps, address: &str) -> StdResult { let address_raw = deps.api.addr_canonicalize(address)?; - let claims = claims_read(deps.storage) - .may_load(address_raw.as_slice())? - .unwrap_or_default(); + let claims = may_load_map(deps.storage, PREFIX_CLAIMS, &address_raw)?.unwrap_or_default(); Ok(ClaimsResponse { claims }) } pub fn query_investment(deps: Deps) -> StdResult { - let invest = invest_info_read(deps.storage).load()?; - let supply = total_supply_read(deps.storage).load()?; + let invest: InvestmentInfo = load_item(deps.storage, KEY_INVESTMENT)?; + let supply: Supply = load_item(deps.storage, KEY_TOTAL_SUPPLY)?; let res = InvestmentResponse { owner: invest.owner.into(), diff --git a/contracts/staking/src/state.rs b/contracts/staking/src/state.rs index 99a9f3b9dc..0b99fe75c6 100644 --- a/contracts/staking/src/state.rs +++ b/contracts/staking/src/state.rs @@ -1,10 +1,12 @@ +use std::any::type_name; + use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use cosmwasm_std::{Addr, Decimal, Storage, Uint128}; -use cosmwasm_storage::{ - bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton, - Singleton, +use cosmwasm_std::{ + from_slice, + storage_keys::{namespace_with_key, to_length_prefixed}, + to_vec, Addr, CanonicalAddr, Decimal, StdError, StdResult, Storage, Uint128, }; pub const KEY_INVESTMENT: &[u8] = b"invest"; @@ -14,22 +16,30 @@ pub const KEY_TOTAL_SUPPLY: &[u8] = b"total_supply"; pub const PREFIX_BALANCE: &[u8] = b"balance"; pub const PREFIX_CLAIMS: &[u8] = b"claim"; -/// balances are state of the erc20 tokens -pub fn balances(storage: &mut dyn Storage) -> Bucket { - bucket(storage, PREFIX_BALANCE) -} - -pub fn balances_read(storage: &dyn Storage) -> ReadonlyBucket { - bucket_read(storage, PREFIX_BALANCE) +pub fn may_load_map( + storage: &dyn Storage, + prefix: &[u8], + key: &CanonicalAddr, +) -> StdResult> { + storage + .get(&namespace_with_key(&[prefix], key)) + .map(|v| from_slice(&v)) + .transpose() } -/// claims are the claims to money being unbonded -pub fn claims(storage: &mut dyn Storage) -> Bucket { - bucket(storage, PREFIX_CLAIMS) +pub fn save_map( + storage: &mut dyn Storage, + prefix: &[u8], + key: &CanonicalAddr, + value: Uint128, +) -> StdResult<()> { + storage.set(&namespace_with_key(&[prefix], key), &to_vec(&value)?); + Ok(()) } -pub fn claims_read(storage: &dyn Storage) -> ReadonlyBucket { - bucket_read(storage, PREFIX_CLAIMS) +pub fn load_map(storage: &dyn Storage, prefix: &[u8], key: &CanonicalAddr) -> StdResult { + may_load_map(storage, prefix, key)? + .ok_or_else(|| StdError::not_found(format!("map value for {}", key))) } /// Investment info is fixed at initialization, and is used to control the function of the contract @@ -71,26 +81,26 @@ pub struct Supply { pub claims: Uint128, } -pub fn invest_info(storage: &mut dyn Storage) -> Singleton { - singleton(storage, KEY_INVESTMENT) -} - -pub fn invest_info_read(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, KEY_INVESTMENT) -} - -pub fn token_info(storage: &mut dyn Storage) -> Singleton { - singleton(storage, KEY_TOKEN_INFO) -} - -pub fn token_info_read(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, KEY_TOKEN_INFO) +pub fn load_item(storage: &dyn Storage, key: &[u8]) -> StdResult { + storage + .get(&to_length_prefixed(key)) + .ok_or_else(|| StdError::not_found(type_name::())) + .and_then(|v| from_slice(&v)) } -pub fn total_supply(storage: &mut dyn Storage) -> Singleton { - singleton(storage, KEY_TOTAL_SUPPLY) +pub fn save_item(storage: &mut dyn Storage, key: &[u8], item: &T) -> StdResult<()> { + storage.set(&to_length_prefixed(key), &to_vec(item)?); + Ok(()) } -pub fn total_supply_read(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, KEY_TOTAL_SUPPLY) +pub fn update_item(storage: &mut dyn Storage, key: &[u8], action: A) -> Result +where + T: Serialize + DeserializeOwned, + A: FnOnce(T) -> Result, + E: From, +{ + let input = load_item(storage, key)?; + let output = action(input)?; + save_item(storage, key, &output)?; + Ok(output) } From bdcd5287dc0dac3ffe7a6c96e7858ddc450c6ab5 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 May 2023 14:23:23 +0200 Subject: [PATCH 12/29] Remove all cosmwasm-storage contract dependencies --- contracts/crypto-verify/Cargo.lock | 9 --------- contracts/cyberpunk/Cargo.lock | 9 --------- contracts/floaty/Cargo.lock | 9 --------- contracts/hackatom/Cargo.lock | 9 --------- contracts/ibc-reflect-send/Cargo.lock | 9 --------- contracts/ibc-reflect-send/Cargo.toml | 1 - contracts/ibc-reflect-send/src/state.rs | 6 +++--- contracts/ibc-reflect/Cargo.lock | 9 --------- contracts/ibc-reflect/Cargo.toml | 1 - contracts/ibc-reflect/src/state.rs | 5 +++-- contracts/reflect/Cargo.lock | 9 --------- contracts/reflect/Cargo.toml | 1 - contracts/staking/Cargo.lock | 9 --------- contracts/staking/Cargo.toml | 1 - 14 files changed, 6 insertions(+), 81 deletions(-) diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index efe0607322..202c2ea136 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -223,14 +223,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.5" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cosmwasm-vm" version = "1.2.5" @@ -419,7 +411,6 @@ version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cosmwasm-vm", "hex", "hex-literal", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 0e97b8bcff..b8dced8ea1 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -246,14 +246,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.5" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cosmwasm-vm" version = "1.2.5" @@ -455,7 +447,6 @@ version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cosmwasm-vm", "rust-argon2", "thiserror", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 0ad6b6a8ee..53dce5aef0 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -217,14 +217,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.5" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cosmwasm-vm" version = "1.2.5" @@ -644,7 +636,6 @@ version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cosmwasm-vm", "schemars", "serde", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 97027614d8..ecac374554 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -217,14 +217,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.5" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cosmwasm-vm" version = "1.2.5" @@ -716,7 +708,6 @@ version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cosmwasm-vm", "schemars", "serde", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 80f7103e6a..e7ae1bdfbc 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -217,14 +217,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.5" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cosmwasm-vm" version = "1.2.5" @@ -758,7 +750,6 @@ version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cosmwasm-vm", "schemars", "serde", diff --git a/contracts/ibc-reflect-send/Cargo.toml b/contracts/ibc-reflect-send/Cargo.toml index 396f36b019..dcbde4a4fe 100644 --- a/contracts/ibc-reflect-send/Cargo.toml +++ b/contracts/ibc-reflect-send/Cargo.toml @@ -34,7 +34,6 @@ backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] cosmwasm-schema = { path = "../../packages/schema" } cosmwasm-std = { path = "../../packages/std", features = ["iterator", "staking", "stargate"] } -cosmwasm-storage = { path = "../../packages/storage", features = ["iterator"] } schemars = "0.8.3" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/ibc-reflect-send/src/state.rs b/contracts/ibc-reflect-send/src/state.rs index a04e815dc9..3da062710d 100644 --- a/contracts/ibc-reflect-send/src/state.rs +++ b/contracts/ibc-reflect-send/src/state.rs @@ -1,9 +1,9 @@ -use cosmwasm_storage::to_length_prefixed; use serde::{Deserialize, Serialize}; use cosmwasm_std::{ - from_slice, storage_keys::namespace_with_key, to_vec, Addr, Coin, Order, StdError, StdResult, - Storage, Timestamp, + from_slice, + storage_keys::{namespace_with_key, to_length_prefixed}, + to_vec, Addr, Coin, Order, StdError, StdResult, Storage, Timestamp, }; pub const KEY_CONFIG: &[u8] = b"config"; diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index cdd2e868d0..d738d521d8 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -217,14 +217,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.5" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cosmwasm-vm" version = "1.2.5" @@ -758,7 +750,6 @@ version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cosmwasm-vm", "schemars", "serde", diff --git a/contracts/ibc-reflect/Cargo.toml b/contracts/ibc-reflect/Cargo.toml index ca0b44bd38..ead27d3725 100644 --- a/contracts/ibc-reflect/Cargo.toml +++ b/contracts/ibc-reflect/Cargo.toml @@ -34,7 +34,6 @@ backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] cosmwasm-schema = { path = "../../packages/schema" } cosmwasm-std = { path = "../../packages/std", features = ["iterator", "ibc3"] } -cosmwasm-storage = { path = "../../packages/storage", features = ["iterator"] } schemars = "0.8.3" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/ibc-reflect/src/state.rs b/contracts/ibc-reflect/src/state.rs index 491ac1c638..bd9a342247 100644 --- a/contracts/ibc-reflect/src/state.rs +++ b/contracts/ibc-reflect/src/state.rs @@ -1,9 +1,10 @@ use std::any::type_name; use cosmwasm_std::{ - from_slice, storage_keys::namespace_with_key, to_vec, Addr, Order, StdError, StdResult, Storage, + from_slice, + storage_keys::{namespace_with_key, to_length_prefixed}, + to_vec, Addr, Order, StdError, StdResult, Storage, }; -use cosmwasm_storage::to_length_prefixed; use schemars::JsonSchema; use serde::{de::DeserializeOwned, Deserialize, Serialize}; diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 6a84dfb35d..28ba22cf0f 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -217,14 +217,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.5" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cosmwasm-vm" version = "1.2.5" @@ -1125,7 +1117,6 @@ version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cosmwasm-vm", "schemars", "serde", diff --git a/contracts/reflect/Cargo.toml b/contracts/reflect/Cargo.toml index c331845ac1..0bdd45558e 100644 --- a/contracts/reflect/Cargo.toml +++ b/contracts/reflect/Cargo.toml @@ -35,7 +35,6 @@ backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] cosmwasm-schema = { path = "../../packages/schema" } cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["staking", "stargate", "cosmwasm_1_1"] } -cosmwasm-storage = { path = "../../packages/storage", default-features = false } schemars = "0.8.3" serde = { version = "=1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.26" diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 1da584a358..50a97ee382 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -217,14 +217,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.5" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cosmwasm-vm" version = "1.2.5" @@ -1419,7 +1411,6 @@ version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cosmwasm-vm", "schemars", "serde", diff --git a/contracts/staking/Cargo.toml b/contracts/staking/Cargo.toml index 2cb5e43fa8..ff7e7f796d 100644 --- a/contracts/staking/Cargo.toml +++ b/contracts/staking/Cargo.toml @@ -34,7 +34,6 @@ backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] cosmwasm-schema = { path = "../../packages/schema" } cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["staking"] } -cosmwasm-storage = { path = "../../packages/storage", default-features = false } schemars = "0.8.3" serde = { version = "1.0.103", default-features = false, features = ["derive"] } snafu = "0.6.6" From cf70538073c834d3e50265266e4b9b113d934c17 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 May 2023 15:35:51 +0200 Subject: [PATCH 13/29] Add FromStr implementation for Coin, closes #1575 --- packages/std/src/coin.rs | 58 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index 289911deef..cfaf748fda 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -1,8 +1,8 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::fmt; +use std::{fmt, str::FromStr}; -use crate::math::Uint128; +use crate::{math::Uint128, StdError}; #[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] pub struct Coin { @@ -19,6 +19,25 @@ impl Coin { } } +impl FromStr for Coin { + type Err = StdError; + + fn from_str(s: &str) -> Result { + let pos = s + .find(|c: char| !c.is_ascii_digit()) + .ok_or_else(|| StdError::generic_err("Parsing Coin: missing denominator"))?; + let (amount, denom) = s.split_at(pos); + + match amount.parse::() { + Ok(amount) => Ok(Coin { + amount: amount.into(), + denom: denom.to_string(), + }), + Err(e) => Err(StdError::generic_err(format!("Parsing Coin: {}", e))), + } + } +} + impl fmt::Display for Coin { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // We use the formatting without a space between amount and denom, @@ -166,4 +185,39 @@ mod tests { // less than same type assert!(has_coins(&wallet, &coin(777, "ETH"))); } + + #[test] + fn parse_coin() { + let expected = Coin::new(123, "ucosm"); + assert_eq!(expected, "123ucosm".parse().unwrap()); + // leading zeroes should be ignored + assert_eq!(expected, "00123ucosm".parse().unwrap()); + // 0 amount parses correctly + assert_eq!(Coin::new(0, "ucosm"), "0ucosm".parse().unwrap()); + // ibc denom should work + let ibc_str = "11111ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"; + let ibc_coin = Coin::new( + 11111, + "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", + ); + assert_eq!(ibc_coin, ibc_str.parse().unwrap()); + + // error cases + assert_eq!( + StdError::generic_err("Parsing Coin: missing denominator"), + Coin::from_str("123").unwrap_err() + ); + assert_eq!( + StdError::generic_err("Parsing Coin: cannot parse integer from empty string"), + Coin::from_str("ucosm").unwrap_err() + ); + assert_eq!( + StdError::generic_err("Parsing Coin: cannot parse integer from empty string"), + Coin::from_str("-123ucosm").unwrap_err() + ); + assert_eq!( + StdError::generic_err("Parsing Coin: number too large to fit in target type"), + Coin::from_str("340282366920938463463374607431768211456ucosm").unwrap_err() + ); + } } From eb341dc6106b04b4b7ad2c125ba7d23aae9b7efb Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 May 2023 16:12:11 +0200 Subject: [PATCH 14/29] Swap expected and actual value in assertions --- packages/std/src/coin.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index cfaf748fda..baabe24110 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -189,35 +189,35 @@ mod tests { #[test] fn parse_coin() { let expected = Coin::new(123, "ucosm"); - assert_eq!(expected, "123ucosm".parse().unwrap()); + assert_eq!("123ucosm".parse::().unwrap(), expected); // leading zeroes should be ignored - assert_eq!(expected, "00123ucosm".parse().unwrap()); + assert_eq!("00123ucosm".parse::().unwrap(), expected); // 0 amount parses correctly - assert_eq!(Coin::new(0, "ucosm"), "0ucosm".parse().unwrap()); + assert_eq!("0ucosm".parse::().unwrap(), Coin::new(0, "ucosm")); // ibc denom should work let ibc_str = "11111ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"; let ibc_coin = Coin::new( 11111, "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", ); - assert_eq!(ibc_coin, ibc_str.parse().unwrap()); + assert_eq!(ibc_str.parse::().unwrap(), ibc_coin); // error cases assert_eq!( - StdError::generic_err("Parsing Coin: missing denominator"), - Coin::from_str("123").unwrap_err() + Coin::from_str("123").unwrap_err(), + StdError::generic_err("Parsing Coin: missing denominator") ); assert_eq!( - StdError::generic_err("Parsing Coin: cannot parse integer from empty string"), - Coin::from_str("ucosm").unwrap_err() + Coin::from_str("ucosm").unwrap_err(), + StdError::generic_err("Parsing Coin: cannot parse integer from empty string") ); assert_eq!( - StdError::generic_err("Parsing Coin: cannot parse integer from empty string"), - Coin::from_str("-123ucosm").unwrap_err() + Coin::from_str("-123ucosm").unwrap_err(), + StdError::generic_err("Parsing Coin: cannot parse integer from empty string") ); assert_eq!( - StdError::generic_err("Parsing Coin: number too large to fit in target type"), - Coin::from_str("340282366920938463463374607431768211456ucosm").unwrap_err() + Coin::from_str("340282366920938463463374607431768211456ucosm").unwrap_err(), + StdError::generic_err("Parsing Coin: number too large to fit in target type") ); } } From b81d90da82496e6b2d22b34e7ff40dee059484c5 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 May 2023 17:17:09 +0200 Subject: [PATCH 15/29] Add special error type for Coin's FromStr --- packages/std/src/coin.rs | 33 ++++++++++++++-------------- packages/std/src/errors/mod.rs | 2 +- packages/std/src/errors/std_error.rs | 20 +++++++++++++++++ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index baabe24110..7df95c87bc 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::{fmt, str::FromStr}; -use crate::{math::Uint128, StdError}; +use crate::{errors::CoinFromStrError, math::Uint128, StdError}; #[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] pub struct Coin { @@ -20,21 +20,18 @@ impl Coin { } impl FromStr for Coin { - type Err = StdError; + type Err = CoinFromStrError; fn from_str(s: &str) -> Result { let pos = s .find(|c: char| !c.is_ascii_digit()) - .ok_or_else(|| StdError::generic_err("Parsing Coin: missing denominator"))?; + .ok_or(CoinFromStrError::MissingDenom)?; let (amount, denom) = s.split_at(pos); - match amount.parse::() { - Ok(amount) => Ok(Coin { - amount: amount.into(), - denom: denom.to_string(), - }), - Err(e) => Err(StdError::generic_err(format!("Parsing Coin: {}", e))), - } + Ok(Coin { + amount: amount.parse::()?.into(), + denom: denom.to_string(), + }) } } @@ -205,19 +202,21 @@ mod tests { // error cases assert_eq!( Coin::from_str("123").unwrap_err(), - StdError::generic_err("Parsing Coin: missing denominator") + CoinFromStrError::MissingDenom ); assert_eq!( - Coin::from_str("ucosm").unwrap_err(), - StdError::generic_err("Parsing Coin: cannot parse integer from empty string") + Coin::from_str("ucosm").unwrap_err().to_string(), + "Invalid amount: cannot parse integer from empty string" ); assert_eq!( - Coin::from_str("-123ucosm").unwrap_err(), - StdError::generic_err("Parsing Coin: cannot parse integer from empty string") + Coin::from_str("-123ucosm").unwrap_err().to_string(), + "Invalid amount: cannot parse integer from empty string" ); assert_eq!( - Coin::from_str("340282366920938463463374607431768211456ucosm").unwrap_err(), - StdError::generic_err("Parsing Coin: number too large to fit in target type") + Coin::from_str("340282366920938463463374607431768211456ucosm") + .unwrap_err() + .to_string(), + "Invalid amount: number too large to fit in target type" ); } } diff --git a/packages/std/src/errors/mod.rs b/packages/std/src/errors/mod.rs index 705382b732..5535479bdf 100644 --- a/packages/std/src/errors/mod.rs +++ b/packages/std/src/errors/mod.rs @@ -6,7 +6,7 @@ mod verification_error; pub use recover_pubkey_error::RecoverPubkeyError; pub use std_error::{ CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, - ConversionOverflowError, DivideByZeroError, OverflowError, OverflowOperation, + CoinFromStrError, ConversionOverflowError, DivideByZeroError, OverflowError, OverflowOperation, RoundUpOverflowError, StdError, StdResult, }; pub use system_error::SystemError; diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index 79b6a82f27..7093167590 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -590,6 +590,26 @@ pub enum CheckedFromRatioError { #[error("Round up operation failed because of overflow")] pub struct RoundUpOverflowError; +#[derive(Error, Debug, PartialEq, Eq)] +pub enum CoinFromStrError { + #[error("Missing denominator")] + MissingDenom, + #[error("Invalid amount: {0}")] + InvalidAmount(std::num::ParseIntError), +} + +impl From for CoinFromStrError { + fn from(value: std::num::ParseIntError) -> Self { + Self::InvalidAmount(value) + } +} + +impl From for StdError { + fn from(value: CoinFromStrError) -> Self { + Self::generic_err(format!("Parsing Coin: {}", value)) + } +} + #[cfg(test)] mod tests { use super::*; From 8297a7a8af519ea1faf2ba9dde177cc7b5d62eb9 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 May 2023 17:26:32 +0200 Subject: [PATCH 16/29] Fix lint --- packages/std/src/coin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index 7df95c87bc..9c8798a005 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::{fmt, str::FromStr}; -use crate::{errors::CoinFromStrError, math::Uint128, StdError}; +use crate::{errors::CoinFromStrError, math::Uint128}; #[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] pub struct Coin { From 0d1be8634d870063000fb5d1dec163909132bb42 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Thu, 4 May 2023 17:52:16 +0200 Subject: [PATCH 17/29] contact: support more test scenarios --- contracts/ibc-reflect/src/contract.rs | 11 +++++++++++ contracts/ibc-reflect/src/msg.rs | 2 ++ 2 files changed, 13 insertions(+) diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index 04750f00ec..1c46da8265 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -244,6 +244,8 @@ pub fn ibc_packet_receive( PacketMsg::Dispatch { msgs } => receive_dispatch(deps, caller, msgs), PacketMsg::WhoAmI {} => receive_who_am_i(deps, caller), PacketMsg::Balances {} => receive_balances(deps, caller), + PacketMsg::Panic {} => execute_panic(), + PacketMsg::ReturnErr {text} => execute_error(text), } })() .or_else(|e| { @@ -308,6 +310,15 @@ fn receive_dispatch( .add_attribute("action", "receive_dispatch")) } +fn execute_panic() -> StdResult { + panic!("This page intentionally faulted"); +} + +fn execute_error(text: String) -> StdResult { + return Err(StdError::generic_err(text).into()); +} + + #[entry_point] /// never should be called as we do not send packets pub fn ibc_packet_ack( diff --git a/contracts/ibc-reflect/src/msg.rs b/contracts/ibc-reflect/src/msg.rs index 9e9551be00..4c65aba127 100644 --- a/contracts/ibc-reflect/src/msg.rs +++ b/contracts/ibc-reflect/src/msg.rs @@ -46,6 +46,8 @@ pub enum PacketMsg { Dispatch { msgs: Vec }, WhoAmI {}, Balances {}, + Panic {}, + ReturnErr {text: String}, } /// All acknowledgements are wrapped in `ContractResult`. From df7ca1611f7b12a6c67b2db2b612338665fd2e15 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Fri, 5 May 2023 08:33:43 +0200 Subject: [PATCH 18/29] Formatting only --- contracts/ibc-reflect/src/contract.rs | 3 +-- contracts/ibc-reflect/src/msg.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index 1c46da8265..c161bd7cc5 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -245,7 +245,7 @@ pub fn ibc_packet_receive( PacketMsg::WhoAmI {} => receive_who_am_i(deps, caller), PacketMsg::Balances {} => receive_balances(deps, caller), PacketMsg::Panic {} => execute_panic(), - PacketMsg::ReturnErr {text} => execute_error(text), + PacketMsg::ReturnErr { text } => execute_error(text), } })() .or_else(|e| { @@ -318,7 +318,6 @@ fn execute_error(text: String) -> StdResult { return Err(StdError::generic_err(text).into()); } - #[entry_point] /// never should be called as we do not send packets pub fn ibc_packet_ack( diff --git a/contracts/ibc-reflect/src/msg.rs b/contracts/ibc-reflect/src/msg.rs index 4c65aba127..723b21478b 100644 --- a/contracts/ibc-reflect/src/msg.rs +++ b/contracts/ibc-reflect/src/msg.rs @@ -47,7 +47,7 @@ pub enum PacketMsg { WhoAmI {}, Balances {}, Panic {}, - ReturnErr {text: String}, + ReturnErr { text: String }, } /// All acknowledgements are wrapped in `ContractResult`. From bba7a9627d5176f35c0d517315a6133fd3250816 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Fri, 5 May 2023 09:38:41 +0200 Subject: [PATCH 19/29] Add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a512a2112c..c71c5ecbc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,10 @@ and this project adheres to - cosmwasm-vm: Add `Cache::save_wasm_unchecked` to save Wasm blobs that have been checked before. This is useful for state-sync where we know the Wasm code was checked when it was first uploaded. ([#1635]) +- cosmwasm-std: Add `FromStr` impl for `Coin`. ([#1684]) [#1635]: https://github.com/CosmWasm/cosmwasm/pull/1635 +[#1684]: https://github.com/CosmWasm/cosmwasm/pull/1684 ### Changed From 80caa65f757807ca1e1b50f44e1356ced33a530c Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Fri, 5 May 2023 10:19:31 +0200 Subject: [PATCH 20/29] Add .wasm file extension to wasm files, fixes #1665 --- packages/vm/src/cache.rs | 55 +++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index dcedd488cc..d95e060b91 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -381,7 +381,7 @@ fn save_wasm_to_disk(dir: impl Into, wasm: &[u8]) -> VmResult // calculate filename let checksum = Checksum::generate(wasm); let filename = checksum.to_hex(); - let filepath = dir.into().join(filename); + let filepath = dir.into().join(filename).with_extension("wasm"); // write data to file // Since the same filename (a collision resistent hash) cannot be generated from two different byte codes @@ -399,9 +399,12 @@ fn save_wasm_to_disk(dir: impl Into, wasm: &[u8]) -> VmResult fn load_wasm_from_disk(dir: impl Into, checksum: &Checksum) -> VmResult> { // this requires the directory and file to exist + // The files previously had no extension, so to allow for a smooth transition, + // we also try to load the file without the wasm extension. let path = dir.into().join(checksum.to_hex()); - let mut file = - File::open(path).map_err(|_e| VmError::cache_err("Error opening Wasm file for reading"))?; + let mut file = File::open(path.with_extension("wasm")) + .or_else(|_| File::open(path)) + .map_err(|_e| VmError::cache_err("Error opening Wasm file for reading"))?; let mut wasm = Vec::::new(); file.read_to_end(&mut wasm) @@ -415,13 +418,25 @@ fn load_wasm_from_disk(dir: impl Into, checksum: &Checksum) -> VmResult /// code is required. So a non-existent file leads to an error as it /// indicates a bug. fn remove_wasm_from_disk(dir: impl Into, checksum: &Checksum) -> VmResult<()> { + // the files previously had no extension, so to allow for a smooth transition, we delete both let path = dir.into().join(checksum.to_hex()); + let wasm_path = path.with_extension("wasm"); - if !path.exists() { + let path_exists = path.exists(); + let wasm_path_exists = wasm_path.exists(); + if !path_exists && !wasm_path_exists { return Err(VmError::cache_err("Wasm file does not exist")); } - fs::remove_file(path).map_err(|_e| VmError::cache_err("Error removing Wasm file from disk"))?; + if path_exists { + fs::remove_file(path) + .map_err(|_e| VmError::cache_err("Error removing Wasm file from disk"))?; + } + + if wasm_path_exists { + fs::remove_file(wasm_path) + .map_err(|_e| VmError::cache_err("Error removing Wasm file from disk"))?; + } Ok(()) } @@ -637,7 +652,8 @@ mod tests { .path() .join(STATE_DIR) .join(WASM_DIR) - .join(checksum.to_hex()); + .join(checksum.to_hex()) + .with_extension("wasm"); let mut file = OpenOptions::new().write(true).open(filepath).unwrap(); file.write_all(b"broken data").unwrap(); @@ -1200,4 +1216,31 @@ mod tests { let non_id = Checksum::generate(b"non_existent"); cache.unpin(&non_id).unwrap(); } + + #[test] + fn loading_without_extension_works() { + let tmp_dir = TempDir::new().unwrap(); + let options = CacheOptions { + base_dir: tmp_dir.path().to_path_buf(), + available_capabilities: default_capabilities(), + memory_cache_size: TESTING_MEMORY_CACHE_SIZE, + instance_memory_limit: TESTING_MEMORY_LIMIT, + }; + let cache: Cache = + unsafe { Cache::new(options).unwrap() }; + let checksum = cache.save_wasm(CONTRACT).unwrap(); + + // Move the saved wasm to the old path (without extension) + let old_path = tmp_dir + .path() + .join(STATE_DIR) + .join(WASM_DIR) + .join(checksum.to_hex()); + let new_path = old_path.with_extension("wasm"); + fs::rename(new_path, old_path).unwrap(); + + // loading wasm from before the wasm extension was added should still work + let restored = cache.load_wasm(&checksum).unwrap(); + assert_eq!(restored, CONTRACT); + } } From 0696b2a7015e5712a408cd08d24b8680ca2ff69f Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Fri, 5 May 2023 10:28:04 +0200 Subject: [PATCH 21/29] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75136e9c10..494fd3e046 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,12 +29,14 @@ and this project adheres to STDERR instead of STDOUT by default ([#1667]). - cosmwasm-vm: Add `Instance::set_debug_handler`/`unset_debug_handler` to allow customizing the handling of debug messages emitted by the contract ([#1667]). +- cosmwasm-vm: Add `.wasm` extension to stored wasm files ([#1686]). [#1511]: https://github.com/CosmWasm/cosmwasm/issues/1511 [#1629]: https://github.com/CosmWasm/cosmwasm/pull/1629 [#1631]: https://github.com/CosmWasm/cosmwasm/pull/1631 [#1664]: https://github.com/CosmWasm/cosmwasm/pull/1664 [#1667]: https://github.com/CosmWasm/cosmwasm/pull/1667 +[#1686]: https://github.com/CosmWasm/cosmwasm/pull/1686 ### Deprecated From b0bb92824fa4420d584a2644247d8a8f32f62133 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Mon, 8 May 2023 14:42:30 +0200 Subject: [PATCH 22/29] Add new test method to ibc-reflect --- contracts/ibc-reflect/src/contract.rs | 14 ++++++++++++++ contracts/ibc-reflect/src/msg.rs | 1 + 2 files changed, 15 insertions(+) diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index c161bd7cc5..c99ae67d89 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -246,6 +246,8 @@ pub fn ibc_packet_receive( PacketMsg::Balances {} => receive_balances(deps, caller), PacketMsg::Panic {} => execute_panic(), PacketMsg::ReturnErr { text } => execute_error(text), + PacketMsg::ReturnMsgs { msgs } => execute_return_msgs(msgs), + } })() .or_else(|e| { @@ -318,6 +320,18 @@ fn execute_error(text: String) -> StdResult { return Err(StdError::generic_err(text).into()); } +fn execute_return_msgs( + msgs: Vec, +) -> StdResult { + let acknowledgement = to_binary(&AcknowledgementMsg::::Ok(()))?; + + Ok(IbcReceiveResponse::new() + .set_ack(acknowledgement) + .add_messages(msgs) + .add_attribute("action", "receive_dispatch")) +} + + #[entry_point] /// never should be called as we do not send packets pub fn ibc_packet_ack( diff --git a/contracts/ibc-reflect/src/msg.rs b/contracts/ibc-reflect/src/msg.rs index 723b21478b..d50ffa5c48 100644 --- a/contracts/ibc-reflect/src/msg.rs +++ b/contracts/ibc-reflect/src/msg.rs @@ -48,6 +48,7 @@ pub enum PacketMsg { Balances {}, Panic {}, ReturnErr { text: String }, + ReturnMsgs { msgs: Vec }, } /// All acknowledgements are wrapped in `ContractResult`. From 66d026bcda634f7d81892670531e6d1d5047eb73 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 15 May 2023 13:04:01 +0200 Subject: [PATCH 23/29] Check for missing amount when parsing Coin --- packages/std/src/coin.rs | 24 ++++++++++++++++++++---- packages/std/src/errors/std_error.rs | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index 9c8798a005..b88a6da3ee 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -28,6 +28,10 @@ impl FromStr for Coin { .ok_or(CoinFromStrError::MissingDenom)?; let (amount, denom) = s.split_at(pos); + if amount.is_empty() { + return Err(CoinFromStrError::MissingAmount); + } + Ok(Coin { amount: amount.parse::()?.into(), denom: denom.to_string(), @@ -205,12 +209,24 @@ mod tests { CoinFromStrError::MissingDenom ); assert_eq!( - Coin::from_str("ucosm").unwrap_err().to_string(), - "Invalid amount: cannot parse integer from empty string" + Coin::from_str("ucosm").unwrap_err(), // no amount + CoinFromStrError::MissingAmount + ); + assert_eq!( + Coin::from_str("-123ucosm").unwrap_err(), // negative amount + CoinFromStrError::MissingAmount + ); + assert_eq!( + Coin::from_str("").unwrap_err(), // empty input + CoinFromStrError::MissingDenom + ); + assert_eq!( + Coin::from_str(" 1ucosm").unwrap_err(), // unsupported whitespace + CoinFromStrError::MissingAmount ); assert_eq!( - Coin::from_str("-123ucosm").unwrap_err().to_string(), - "Invalid amount: cannot parse integer from empty string" + Coin::from_str("�1ucosm").unwrap_err(), // other broken data + CoinFromStrError::MissingAmount ); assert_eq!( Coin::from_str("340282366920938463463374607431768211456ucosm") diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index 7093167590..d90171c74c 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -594,6 +594,8 @@ pub struct RoundUpOverflowError; pub enum CoinFromStrError { #[error("Missing denominator")] MissingDenom, + #[error("Missing amount or non-digit characters in amount")] + MissingAmount, #[error("Invalid amount: {0}")] InvalidAmount(std::num::ParseIntError), } From 80cba9ad862d668f69517dc60e26dfa24be0c1fd Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 22 May 2023 16:26:52 +0200 Subject: [PATCH 24/29] Add ReturnMsgResponse to ibc-reflect contract --- contracts/ibc-reflect/src/contract.rs | 11 ++++------- contracts/ibc-reflect/src/msg.rs | 4 ++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index c99ae67d89..8130473bdf 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -9,7 +9,8 @@ use cosmwasm_std::{ use crate::msg::{ AccountInfo, AccountResponse, AcknowledgementMsg, BalancesResponse, DispatchResponse, - InstantiateMsg, ListAccountsResponse, PacketMsg, QueryMsg, ReflectExecuteMsg, WhoAmIResponse, + InstantiateMsg, ListAccountsResponse, PacketMsg, QueryMsg, ReflectExecuteMsg, + ReturnMsgsResponse, WhoAmIResponse, }; use crate::state::{accounts, accounts_read, config, pending_channel, Config}; @@ -247,7 +248,6 @@ pub fn ibc_packet_receive( PacketMsg::Panic {} => execute_panic(), PacketMsg::ReturnErr { text } => execute_error(text), PacketMsg::ReturnMsgs { msgs } => execute_return_msgs(msgs), - } })() .or_else(|e| { @@ -320,10 +320,8 @@ fn execute_error(text: String) -> StdResult { return Err(StdError::generic_err(text).into()); } -fn execute_return_msgs( - msgs: Vec, -) -> StdResult { - let acknowledgement = to_binary(&AcknowledgementMsg::::Ok(()))?; +fn execute_return_msgs(msgs: Vec) -> StdResult { + let acknowledgement = to_binary(&AcknowledgementMsg::::Ok(()))?; Ok(IbcReceiveResponse::new() .set_ack(acknowledgement) @@ -331,7 +329,6 @@ fn execute_return_msgs( .add_attribute("action", "receive_dispatch")) } - #[entry_point] /// never should be called as we do not send packets pub fn ibc_packet_ack( diff --git a/contracts/ibc-reflect/src/msg.rs b/contracts/ibc-reflect/src/msg.rs index d50ffa5c48..acd49baf63 100644 --- a/contracts/ibc-reflect/src/msg.rs +++ b/contracts/ibc-reflect/src/msg.rs @@ -73,3 +73,7 @@ pub struct BalancesResponse { pub account: String, pub balances: Vec, } + +/// This is the success response we send on ack for PacketMsg::ReturnMsgs. +/// Just acknowledge success or error +pub type ReturnMsgsResponse = (); From 81fe3a08559a9212503ea7064ab184dff50e1cb1 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 22 May 2023 16:32:50 +0200 Subject: [PATCH 25/29] Fix clippy lints --- contracts/ibc-reflect/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index 8130473bdf..3b31aab4f4 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -317,7 +317,7 @@ fn execute_panic() -> StdResult { } fn execute_error(text: String) -> StdResult { - return Err(StdError::generic_err(text).into()); + Err(StdError::generic_err(text)) } fn execute_return_msgs(msgs: Vec) -> StdResult { From fe6e8b3fb6d19f7339add7f9f1bcf608d4e2e590 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 22 May 2023 16:49:59 +0200 Subject: [PATCH 26/29] Fix test --- contracts/ibc-reflect/src/contract.rs | 2 +- contracts/ibc-reflect/tests/integration.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index 3b31aab4f4..11e9049ebf 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -597,7 +597,7 @@ mod tests { assert_eq!(0, res.messages.len()); // acknowledgement is an error let ack: AcknowledgementMsg = from_slice(&res.acknowledgement).unwrap(); - assert_eq!(ack.unwrap_err(), "invalid packet: Error parsing into type ibc_reflect::msg::PacketMsg: unknown variant `reflect_code_id`, expected one of `dispatch`, `who_am_i`, `balances`"); + assert_eq!(ack.unwrap_err(), "invalid packet: Error parsing into type ibc_reflect::msg::PacketMsg: unknown variant `reflect_code_id`, expected one of `dispatch`, `who_am_i`, `balances`, `panic`, `return_err`, `return_msgs`"); } #[test] diff --git a/contracts/ibc-reflect/tests/integration.rs b/contracts/ibc-reflect/tests/integration.rs index d28e3369a4..66dc430026 100644 --- a/contracts/ibc-reflect/tests/integration.rs +++ b/contracts/ibc-reflect/tests/integration.rs @@ -287,5 +287,5 @@ fn handle_dispatch_packet() { // acknowledgement is an error let ack: AcknowledgementMsg = from_slice(&res.acknowledgement, DESERIALIZATION_LIMIT).unwrap(); - assert_eq!(ack.unwrap_err(), "invalid packet: Error parsing into type ibc_reflect::msg::PacketMsg: unknown variant `reflect_code_id`, expected one of `dispatch`, `who_am_i`, `balances`"); + assert_eq!(ack.unwrap_err(), "invalid packet: Error parsing into type ibc_reflect::msg::PacketMsg: unknown variant `reflect_code_id`, expected one of `dispatch`, `who_am_i`, `balances`, `panic`, `return_err`, `return_msgs`"); } From 9412b136e53dcf0b774b0e1660ecdd694f65ea04 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 22 May 2023 17:03:51 +0200 Subject: [PATCH 27/29] Update schema --- contracts/ibc-reflect/schema/packet_msg.json | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/contracts/ibc-reflect/schema/packet_msg.json b/contracts/ibc-reflect/schema/packet_msg.json index bd940ab4f0..547c6fe054 100644 --- a/contracts/ibc-reflect/schema/packet_msg.json +++ b/contracts/ibc-reflect/schema/packet_msg.json @@ -51,6 +51,64 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "panic" + ], + "properties": { + "panic": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "return_err" + ], + "properties": { + "return_err": { + "type": "object", + "required": [ + "text" + ], + "properties": { + "text": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "return_msgs" + ], + "properties": { + "return_msgs": { + "type": "object", + "required": [ + "msgs" + ], + "properties": { + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + } + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false } ], "definitions": { From 4e6d923cc5ff3d7e03f41488567631bfb5692b3e Mon Sep 17 00:00:00 2001 From: Andrei Petrovich Date: Thu, 4 May 2023 07:37:49 +0200 Subject: [PATCH 28/29] 1518 cosmwasm-check: update Clap to version 4 --- CHANGELOG.md | 1 + Cargo.lock | 1076 +++++++++++++----- packages/check/Cargo.toml | 6 +- packages/check/src/main.rs | 21 +- packages/check/tests/cosmwasm_check_tests.rs | 74 ++ packages/vm/src/modules/file_system_cache.rs | 8 +- 6 files changed, 859 insertions(+), 327 deletions(-) create mode 100644 packages/check/tests/cosmwasm_check_tests.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index bbbd9f12f3..e6bd33b3bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to - cosmwasm-vm: Add `Instance::set_debug_handler`/`unset_debug_handler` to allow customizing the handling of debug messages emitted by the contract ([#1667]). - cosmwasm-vm: Add `.wasm` extension to stored wasm files ([#1686]). +- cosmwasm-check: Update clap dependency to version 4 [#1511]: https://github.com/CosmWasm/cosmwasm/issues/1511 [#1629]: https://github.com/CosmWasm/cosmwasm/pull/1629 diff --git a/Cargo.lock b/Cargo.lock index dda8806a5f..b82f6bab75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,11 +4,11 @@ version = 3 [[package]] name = "addr2line" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli", + "gimli 0.27.2", ] [[package]] @@ -23,11 +23,20 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.6", + "getrandom", "once_cell", "version_check", ] +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + [[package]] name = "anes" version = "0.1.6" @@ -43,11 +52,81 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle 1.0.0", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" + +[[package]] +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle 1.0.0", + "windows-sys 0.48.0", +] + [[package]] name = "anyhow" -version = "1.0.57" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" + +[[package]] +name = "assert_cmd" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0dcbed38184f9219183fcf38beb4cdbf5df7163a6d7cd227c6ac89b7966d6fe" +dependencies = [ + "anstyle 0.3.5", + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] [[package]] name = "atty" @@ -55,7 +134,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -68,16 +147,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.65" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.30.3", "rustc-demangle", ] @@ -89,15 +168,15 @@ checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64ct" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bitflags" @@ -116,38 +195,51 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.2" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] +[[package]] +name = "bstr" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d4260bcc2e8fc9df1eac4919a720effeb63a3f0952f5bf4944adfa18897f09" +dependencies = [ + "memchr", + "once_cell", + "regex-automata", + "serde", +] + [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "bytecheck" -version = "0.6.8" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a31f923c2db9513e4298b72df143e6e655a759b3d6a0966df18f81223fff54f" +checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" dependencies = [ "bytecheck_derive", "ptr_meta", + "simdutf8", ] [[package]] name = "bytecheck_derive" -version = "0.6.8" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb17c862a905d912174daa27ae002326fff56dc8b8ada50a0a5f0976cb174f0" +checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -164,9 +256,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-if" @@ -176,9 +268,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "num-integer", "num-traits", @@ -220,7 +312,7 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", "vec_map", @@ -228,16 +320,38 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.23" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "bitflags", - "clap_lex", + "clap_lex 0.2.4", "indexmap", "textwrap 0.16.0", ] +[[package]] +name = "clap" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle 1.0.0", + "bitflags", + "clap_lex 0.4.1", + "strsim 0.10.0", +] + [[package]] name = "clap_lex" version = "0.2.4" @@ -247,12 +361,24 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "clap_lex" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" + [[package]] name = "clru" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "colored" version = "2.0.0" @@ -266,9 +392,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "corosensei" @@ -280,7 +406,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys", + "windows-sys 0.33.0", ] [[package]] @@ -288,10 +414,12 @@ name = "cosmwasm-check" version = "1.2.5" dependencies = [ "anyhow", - "clap 2.34.0", + "assert_cmd", + "clap 4.2.7", "colored", "cosmwasm-std", "cosmwasm-vm", + "predicates", ] [[package]] @@ -300,16 +428,16 @@ version = "1.2.5" dependencies = [ "base64", "criterion", - "digest 0.10.3", + "digest 0.10.6", "ed25519-zebra", "english-numbers", "hex", "hex-literal", "k256", - "rand_core 0.6.3", + "rand_core 0.6.4", "serde", "serde_json", - "sha2 0.10.3", + "sha2 0.10.6", "thiserror", ] @@ -318,7 +446,7 @@ name = "cosmwasm-derive" version = "1.2.5" dependencies = [ "cosmwasm-std", - "syn", + "syn 1.0.109", ] [[package]] @@ -342,7 +470,7 @@ version = "1.2.5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -362,7 +490,7 @@ dependencies = [ "serde", "serde-json-wasm", "serde_json", - "sha2 0.10.3", + "sha2 0.10.6", "thiserror", "uint", ] @@ -399,7 +527,7 @@ dependencies = [ "schemars", "serde", "serde_json", - "sha2 0.10.3", + "sha2 0.10.6", "target-lexicon", "tempfile", "thiserror", @@ -410,9 +538,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -436,7 +564,7 @@ dependencies = [ "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli", + "gimli 0.26.2", "log", "regalloc", "smallvec", @@ -495,7 +623,7 @@ dependencies = [ "atty", "cast", "ciborium", - "clap 3.2.23", + "clap 3.2.25", "criterion-plot", "itertools", "lazy_static", @@ -523,9 +651,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.4" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -533,9 +661,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -544,26 +672,24 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.8" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", - "lazy_static", ] [[package]] @@ -574,12 +700,12 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f2b443d17d49dad5ef0ede301c3179cc923b8822f3393b4d2c28c269dd4a122" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ "generic-array", - "rand_core 0.6.3", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -609,9 +735,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" dependencies = [ "darling_core", "darling_macro", @@ -619,33 +745,33 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "darling_macro" -version = "0.13.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "der" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" dependencies = [ "const-oid", "zeroize", @@ -659,9 +785,15 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + [[package]] name = "digest" version = "0.9.0" @@ -673,20 +805,26 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.3" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.2", + "block-buffer 0.10.4", "crypto-common", "subtle", ] +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "dyn-clone" -version = "1.0.5" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "dynasm" @@ -700,7 +838,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -716,9 +854,9 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.14.3" +version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bd46e0c364655e5baf2f5e99b603e7a09905da9966d7928d7470af393b28670" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ "der", "elliptic-curve", @@ -728,40 +866,40 @@ dependencies = [ [[package]] name = "ed25519-zebra" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403ef3e961ab98f0ba902771d29f842058578bb1ce7e3c59dad5a6a93e784c69" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ "curve25519-dalek", + "hashbrown 0.12.3", "hex", - "rand_core 0.6.3", + "rand_core 0.6.4", "serde", "sha2 0.9.9", - "thiserror", "zeroize", ] [[package]] name = "either" -version = "1.6.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c47abd0a791d2ac0c7aa1118715f85b83689e4522c4e3a244e159d4fc9848a8d" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ "base16ct", "crypto-bigint", "der", - "digest 0.10.3", + "digest 0.10.6", "ff", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -790,28 +928,49 @@ checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "enumset" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4799cdb24d48f1f8a7a98d06b7fde65a85a2d1e42b25a889f5406aa1fbefe074" +checksum = "59b025475ad197bd8b4a9bdce339216b6cf3bd568bf2e107c286b51613f0b3cf" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea83a3fbdc1d999ccfbcbee717eab36f8edf2d71693a23ce0d7cca19e085304c" +checksum = "14c2852ff17a4c9a2bb2abbca3074737919cb05dc24b0a8ca9498081a7033dd6" dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.15", +] + +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", ] [[package]] @@ -822,23 +981,32 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] [[package]] name = "ff" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df689201f395c6b90dfe87127685f8dbfc083a5e779e613575d8bd7314300c3e" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ - "rand_core 0.6.3", + "rand_core 0.6.4", "subtle", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -853,9 +1021,9 @@ checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -863,37 +1031,32 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.6" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" + [[package]] name = "glob" version = "0.3.1" @@ -902,12 +1065,12 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "group" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7391856def869c1c81063a03457c676fbcd419709c3dfb33d8d319de484b154d" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.6.4", "subtle", ] @@ -928,9 +1091,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", ] @@ -944,6 +1107,21 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -962,7 +1140,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.3", + "digest 0.10.6", ] [[package]] @@ -973,12 +1151,12 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "1.8.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown 0.11.2", + "hashbrown 0.12.3", "serde", ] @@ -991,40 +1169,63 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "itertools" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.57" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.11.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c8a5a96d92d849c4499d99461da81c9cdc1467418a8ed2aaeb407e8d85940ed" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.10.3", + "sha2 0.10.6", ] [[package]] @@ -1041,20 +1242,26 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.125" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "libloading" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", "winapi", ] +[[package]] +name = "linux-raw-sys" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b64f40e5e03e0d54f03845c8197d0291253cdbedfb1cb46b13c2c117554a9f4c" + [[package]] name = "log" version = "0.4.17" @@ -1082,7 +1289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1102,9 +1309,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" -version = "0.5.3" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057a3db23999c867821a7a59feb06a578fcb03685e983dff90daf9e7d24ac08f" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" dependencies = [ "libc", ] @@ -1118,11 +1325,20 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + [[package]] name = "miniz_oxide" -version = "0.5.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] @@ -1133,6 +1349,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "num-integer" version = "0.1.45" @@ -1154,19 +1376,19 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] [[package]] name = "object" -version = "0.28.3" +version = "0.28.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40bec70ba014595f99f7aa110b84331ffe1ee9aece7fe6f387cc7e3ecda4d456" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" dependencies = [ "crc32fast", "hashbrown 0.11.2", @@ -1174,11 +1396,20 @@ dependencies = [ "memchr", ] +[[package]] +name = "object" +version = "0.30.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" -version = "1.10.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "oorandom" @@ -1222,9 +1453,9 @@ dependencies = [ [[package]] name = "plotters" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ "num-traits", "plotters-backend", @@ -1235,24 +1466,55 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" dependencies = [ "plotters-backend", ] [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "predicates" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" +dependencies = [ + "anstyle 1.0.0", + "difflib", + "float-cmp", + "itertools", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] [[package]] name = "proc-macro-error" @@ -1263,7 +1525,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1280,11 +1542,11 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.37" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1304,14 +1566,14 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "quote" -version = "1.0.18" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -1324,7 +1586,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -1334,7 +1596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -1342,36 +1604,31 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.6", + "getrandom", ] [[package]] name = "rayon" -version = "1.5.2" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.2" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -1381,9 +1638,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1401,18 +1658,26 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.5" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ + "aho-corasick", + "memchr", "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "region" @@ -1426,29 +1691,20 @@ dependencies = [ "winapi", ] -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "rend" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95" +checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" dependencies = [ "bytecheck", ] [[package]] name = "rfc6979" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88c86280f057430a52f4861551b092a01b419b8eacefc7c995eacb9dc132fe32" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ "crypto-bigint", "hmac", @@ -1457,12 +1713,12 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.38" +version = "0.7.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "517a3034eb2b1499714e9d1e49b2367ad567e07639b69776d35e259d9c27cca6" +checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" dependencies = [ "bytecheck", - "hashbrown 0.12.1", + "hashbrown 0.12.3", "ptr_meta", "rend", "rkyv_derive", @@ -1471,20 +1727,20 @@ dependencies = [ [[package]] name = "rkyv_derive" -version = "0.7.38" +version = "0.7.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "505c209ee04111a006431abf39696e640838364d67a107c559ababaf6fd8c9dd" +checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -1492,17 +1748,31 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustix" +version = "0.37.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bbfc1d1c7c40c01715f47d71444744a81669ca84e8b63e25a55e169b1f86433" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + [[package]] name = "rustversion" -version = "1.0.6" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -1534,7 +1804,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 1.0.109", ] [[package]] @@ -1565,46 +1835,46 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.9" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.137" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15bee9b04dd165c3f4e142628982ddde884c2022a89e8ddf99c4829bf2c3a58" +checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" dependencies = [ "serde", ] [[package]] name = "serde_bytes" -version = "0.11.6" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212e73464ebcde48d723aa02eb270ba62eff38a9b732df31f33f1b4e145f3a54" +checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -1615,14 +1885,14 @@ checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -1644,30 +1914,36 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.3", + "digest 0.10.6", ] [[package]] name = "signature" -version = "1.5.0" +version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.3", - "rand_core 0.6.3", + "digest 0.10.6", + "rand_core 0.6.4", ] +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "smallvec" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "spki" @@ -1697,6 +1973,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "subtle" version = "2.4.1" @@ -1705,35 +1987,51 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.92" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "target-lexicon" -version = "0.12.3" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fa7e55043acb85fca6b3c01485a2eeb6b69c5d21002e273c79e465f43b7ac1" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys 0.45.0", ] +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + [[package]] name = "textwrap" version = "0.11.0" @@ -1751,22 +2049,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -1781,9 +2079,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.34" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", @@ -1794,35 +2092,35 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.21" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "tracing-core" -version = "0.1.26" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "uint" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", @@ -1830,17 +2128,23 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] -name = "unicode-xid" -version = "0.2.3" +name = "utf8parse" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "vec_map" @@ -1855,33 +2159,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "walkdir" -version = "2.3.2" +name = "wait-timeout" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" dependencies = [ - "same-file", - "winapi", - "winapi-util", + "libc", ] [[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +name = "walkdir" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +dependencies = [ + "same-file", + "winapi-util", +] [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.80" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1889,24 +2195,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.80" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.80" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1914,22 +2220,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.80" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.80" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "wasm-encoder" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" +checksum = "d05d0b6fcd0aeb98adf16e7975331b3c17222aa815148f5b976370ce589d80ef" +dependencies = [ + "leb128", +] [[package]] name = "wasmer" @@ -1998,7 +2313,7 @@ dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "gimli", + "gimli 0.26.2", "loupe", "more-asserts", "rayon", @@ -2018,7 +2333,7 @@ dependencies = [ "byteorder", "dynasm", "dynasmrt", - "gimli", + "gimli 0.26.2", "lazy_static", "loupe", "more-asserts", @@ -2037,7 +2352,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2075,7 +2390,7 @@ dependencies = [ "leb128", "libloading", "loupe", - "object", + "object 0.28.4", "rkyv", "serde", "tempfile", @@ -2143,7 +2458,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d831335ff3a44ecf451303f6f891175c642488036b92ceceb24ac8623a8fa8b" dependencies = [ - "object", + "object 0.28.4", "thiserror", "wasmer-compiler", "wasmer-types", @@ -2181,7 +2496,7 @@ dependencies = [ "libc", "loupe", "mach", - "memoffset", + "memoffset 0.6.5", "more-asserts", "region", "rkyv", @@ -2201,29 +2516,30 @@ checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" [[package]] name = "wast" -version = "40.0.0" +version = "57.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb4f48a8b083dbc50e291e430afb8f524092bb00428957bcc63f49f856c64ac" +checksum = "6eb0f5ed17ac4421193c7477da05892c2edafd67f9639e3c11a82086416662dc" dependencies = [ "leb128", "memchr", "unicode-width", + "wasm-encoder", ] [[package]] name = "wat" -version = "1.0.42" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0401b6395ce0db91629a75b29597ccb66ea29950af9fc859f1bb3a736609c76e" +checksum = "ab9ab0d87337c3be2bb6fc5cd331c4ba9fd6bcb4ee85048a0dd59ed9ecf92e53" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.57" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" dependencies = [ "js-sys", "wasm-bindgen", @@ -2231,13 +2547,13 @@ dependencies = [ [[package]] name = "which" -version = "4.2.5" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" dependencies = [ "either", - "lazy_static", "libc", + "once_cell", ] [[package]] @@ -2277,45 +2593,177 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43dbb096663629518eb1dfa72d80243ca5a6aca764cae62a2df70af760a9be75" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.33.0", + "windows_i686_gnu 0.33.0", + "windows_i686_msvc 0.33.0", + "windows_x86_64_gnu 0.33.0", + "windows_x86_64_msvc 0.33.0", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "zeroize" -version = "1.5.5" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/packages/check/Cargo.toml b/packages/check/Cargo.toml index c046e1b39b..5f96586c95 100644 --- a/packages/check/Cargo.toml +++ b/packages/check/Cargo.toml @@ -9,7 +9,11 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.57" -clap = "2" +clap = "4" colored = "2" cosmwasm-vm = { path = "../vm", version = "1.2.5" } cosmwasm-std = { path = "../std", version = "1.2.5" } + +[dev-dependencies] +assert_cmd = "2" +predicates = "3" diff --git a/packages/check/src/main.rs b/packages/check/src/main.rs index c1f7da1784..b73ff4f07c 100644 --- a/packages/check/src/main.rs +++ b/packages/check/src/main.rs @@ -4,7 +4,7 @@ use std::io::Read; use std::path::Path; use std::process::exit; -use clap::{App, Arg}; +use clap::{Arg, ArgAction, Command}; use colored::Colorize; use cosmwasm_vm::capabilities_from_csv; @@ -13,38 +13,43 @@ use cosmwasm_vm::internals::{check_wasm, compile}; const DEFAULT_AVAILABLE_CAPABILITIES: &str = "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2"; pub fn main() { - let matches = App::new("Contract checking") + let matches = Command::new("Contract checking") .version(env!("CARGO_PKG_VERSION")) .long_about("Checks the given wasm file (memories, exports, imports, available capabilities, and non-determinism).") .author("Mauro Lacy ") .arg( - Arg::with_name("CAPABILITIES") + Arg::new("CAPABILITIES") // `long` setting required to turn the position argument into an option 🤷 .long("available-capabilities") .aliases(&["FEATURES", "supported-features"]) // Old names .value_name("CAPABILITIES") .help("Sets the available capabilities that the desired target chain has") - .takes_value(true) + .num_args(1) + .action(ArgAction::Set), ) .arg( - Arg::with_name("WASM") + Arg::new("WASM") .help("Wasm file to read and compile") .required(true) .index(1) - .multiple(true), + .num_args(0..) + .action(ArgAction::Append), ) .get_matches(); // Available capabilities let available_capabilities_csv = matches - .value_of("CAPABILITIES") + .get_one::("CAPABILITIES") + .map(|s| s.as_str()) .unwrap_or(DEFAULT_AVAILABLE_CAPABILITIES); let available_capabilities = capabilities_from_csv(available_capabilities_csv); println!("Available capabilities: {:?}", available_capabilities); println!(); // File - let paths = matches.values_of("WASM").expect("Error parsing file names"); + let paths = matches + .get_many::("WASM") + .expect("Error parsing file names"); let (passes, failures): (Vec<_>, _) = paths .map(|p| { diff --git a/packages/check/tests/cosmwasm_check_tests.rs b/packages/check/tests/cosmwasm_check_tests.rs new file mode 100644 index 0000000000..0c4301d683 --- /dev/null +++ b/packages/check/tests/cosmwasm_check_tests.rs @@ -0,0 +1,74 @@ +use assert_cmd::prelude::*; +use predicates::prelude::*; +use std::process::Command; + +#[test] +fn valid_contract_check() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("cosmwasm-check")?; + + cmd.arg("../vm/testdata/hackatom.wasm"); + cmd.assert() + .success() + .stdout(predicate::str::contains("pass")); + + Ok(()) +} + +#[test] +fn invalid_contract_check() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("cosmwasm-check")?; + + cmd.arg("../vm/testdata/corrupted.wasm"); + cmd.assert() + .failure() + .stdout(predicate::str::contains("Deserialization error")); + + Ok(()) +} + +#[test] +fn invalid_contract_check_float_operator() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("cosmwasm-check")?; + + cmd.arg("../vm/testdata/floaty.wasm"); + cmd.assert() + .failure() + .stdout(predicate::str::contains("Float operator detected")) + .stdout(predicate::str::contains( + "The use of floats is not supported", + )); + + Ok(()) +} + +#[test] +fn several_contracts_check() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("cosmwasm-check")?; + + cmd.arg("../vm/testdata/hackatom.wasm") + .arg("../vm/testdata/corrupted.wasm"); + cmd.assert() + .failure() + .stdout(predicate::str::contains("failure")) + .stdout(predicate::str::contains("Deserialization error")) + .stdout(predicate::str::contains("Passes: 1, failures: 1")); + + Ok(()) +} + +#[test] +fn custom_capabilities_check() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("cosmwasm-check")?; + + cmd.arg("--available-capabilities") + .arg("iterator,osmosis,friendship") + .arg("../vm/testdata/hackatom.wasm"); + cmd.assert() + .success() + .stdout(predicate::str::contains("Available capabilities:")) + .stdout(predicate::str::contains("iterator")) + .stdout(predicate::str::contains("osmosis")) + .stdout(predicate::str::contains("friendship")); + + Ok(()) +} diff --git a/packages/vm/src/modules/file_system_cache.rs b/packages/vm/src/modules/file_system_cache.rs index f8b3cceebd..41a4d80167 100644 --- a/packages/vm/src/modules/file_system_cache.rs +++ b/packages/vm/src/modules/file_system_cache.rs @@ -310,11 +310,11 @@ mod tests { }; let target = Target::new(triple.clone(), wasmer::CpuFeature::POPCNT.into()); let id = target_id(&target); - assert_eq!(id, "x86_64-nintendo-fuchsia-gnu-coff-4721E3F4"); + assert_eq!(id, "x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE"); // Changing CPU features changes the hash part let target = Target::new(triple, wasmer::CpuFeature::AVX512DQ.into()); let id = target_id(&target); - assert_eq!(id, "x86_64-nintendo-fuchsia-gnu-coff-D5C8034F"); + assert_eq!(id, "x86_64-nintendo-fuchsia-gnu-coff-93001945"); // Works for durrect target (hashing is deterministic); let target = Target::default(); @@ -338,9 +338,9 @@ mod tests { assert_eq!( p.as_os_str(), if cfg!(windows) { - "modules\\v5-wasmer17\\x86_64-nintendo-fuchsia-gnu-coff-4721E3F4" + "modules\\v5-wasmer17\\x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE" } else { - "modules/v5-wasmer17/x86_64-nintendo-fuchsia-gnu-coff-4721E3F4" + "modules/v5-wasmer17/x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE" } ); } From 433f57058c28dc07d3073d1980292fa2b3389167 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 23 May 2023 16:53:18 +0200 Subject: [PATCH 29/29] Add PR link to changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6bd33b3bd..389e6290f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,13 +32,14 @@ and this project adheres to - cosmwasm-vm: Add `Instance::set_debug_handler`/`unset_debug_handler` to allow customizing the handling of debug messages emitted by the contract ([#1667]). - cosmwasm-vm: Add `.wasm` extension to stored wasm files ([#1686]). -- cosmwasm-check: Update clap dependency to version 4 +- cosmwasm-check: Update clap dependency to version 4 ([#1677]) [#1511]: https://github.com/CosmWasm/cosmwasm/issues/1511 [#1629]: https://github.com/CosmWasm/cosmwasm/pull/1629 [#1631]: https://github.com/CosmWasm/cosmwasm/pull/1631 [#1664]: https://github.com/CosmWasm/cosmwasm/pull/1664 [#1667]: https://github.com/CosmWasm/cosmwasm/pull/1667 +[#1677]: https://github.com/CosmWasm/cosmwasm/pull/1677 [#1686]: https://github.com/CosmWasm/cosmwasm/pull/1686 ### Deprecated