From 1b703466076bab5a49e57f877cf6f3d88bb77469 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 11 Jun 2024 17:40:07 +0300 Subject: [PATCH 01/25] add bitmap lib contract --- contracts/src/utils/mod.rs | 2 + contracts/src/utils/structs/bitmap.rs | 117 ++++++++++++++++++++++++++ contracts/src/utils/structs/mod.rs | 1 + 3 files changed, 120 insertions(+) create mode 100644 contracts/src/utils/structs/bitmap.rs create mode 100644 contracts/src/utils/structs/mod.rs diff --git a/contracts/src/utils/mod.rs b/contracts/src/utils/mod.rs index 7e310559d..14c84808b 100644 --- a/contracts/src/utils/mod.rs +++ b/contracts/src/utils/mod.rs @@ -1,5 +1,7 @@ //! Common Smart Contracts utilities. +pub mod structs; + cfg_if::cfg_if! { if #[cfg(any(test, feature = "erc20_metadata", feature = "erc721_metadata"))] { pub mod metadata; diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs new file mode 100644 index 000000000..303c4eb3d --- /dev/null +++ b/contracts/src/utils/structs/bitmap.rs @@ -0,0 +1,117 @@ +//! Contract module for managing uint256 to bool mapping in a compact and +//! efficient way, provided the keys are sequential. Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. +//! +//! BitMaps pack 256 booleans across each bit of a single 256-bit slot of +//! `uint256` type. Hence, booleans corresponding to 256 _sequential_ indices +//! would only consume a single slot, unlike the regular `bool` which would +//! consume an entire slot for a single value. +//! +//! This results in gas savings in two ways: +//! +//! - Setting a zero value to non-zero only once every 256 times +//! - Accessing the same warm slot for every 256 _sequential_ indices +use alloy_primitives::U256; +use stylus_proc::sol_storage; + +sol_storage! { + /// State of bit map. + pub struct BitMap { + mapping(uint256 => uint256) _data; + } +} + +impl BitMap { + /// Returns whether the bit at `index` is set. + /// + /// # Arguments + /// + /// * `index` - index of boolean value at the bit map. + fn get(&self, index: U256) -> bool { + let bucket = index >> 8; + let mask = U256::from(1) << (index & U256::from(0xff)); + let value = self._data.get(bucket); + (value & mask) != U256::ZERO + } + + /// Sets the bit at `index` to the boolean `value`. + /// + /// # Arguments + /// + /// * `index` - index of boolean value at the bit map. + /// * `value` - boolean value to set into the bit map. + fn set_to(&mut self, index: U256, value: bool) { + if value { + self.set(index); + } else { + self.unset(index); + } + } + + /// Sets the bit at `index`. + /// + /// # Arguments + /// + /// * `index` - index of boolean value that should be set `true`. + fn set(&mut self, index: U256) { + let bucket = index >> 8; + let mask = U256::from(1) << (index & U256::from(0xff)); + let mut value = self._data.setter(bucket); + let prev = value.get(); + value.set(prev | mask); + } + + /// Unsets the bit at `index`. + /// + /// # Arguments + /// + /// * `index` - index of boolean value that should be set `false`. + fn unset(&mut self, index: U256) { + let bucket = index >> 8; + let mask = U256::from(1) << (index & U256::from(0xff)); + let mut value = self._data.setter(bucket); + let prev = value.get(); + value.set(prev & !mask); + } +} + +#[cfg(all(test, feature = "std"))] +mod tests { + use alloy_primitives::U256; + use stylus_sdk::{prelude::*, storage::StorageMap}; + + use crate::utils::structs::bitmap::BitMap; + + impl Default for BitMap { + fn default() -> Self { + let root = U256::ZERO; + BitMap { _data: unsafe { StorageMap::new(root, 0) } } + } + } + + // TODO#q: add proptest or smth + #[motsu::test] + fn set_value(bit_map: BitMap) { + let value = U256::from(42); + assert_eq!(bit_map.get(value), false); + bit_map.set(value); + assert_eq!(bit_map.get(value), true); + } + + #[motsu::test] + fn unset_value(bit_map: BitMap) { + let value = U256::from(42); + bit_map.set(value); + assert_eq!(bit_map.get(value), true); + bit_map.unset(value); + assert_eq!(bit_map.get(value), false); + } + + #[motsu::test] + fn set_to_value(bit_map: BitMap) { + let value = U256::from(42); + bit_map.set_to(value, true); + assert_eq!(bit_map.get(value), true); + bit_map.set_to(value, false); + assert_eq!(bit_map.get(value), false); + } +} diff --git a/contracts/src/utils/structs/mod.rs b/contracts/src/utils/structs/mod.rs new file mode 100644 index 000000000..163f8968d --- /dev/null +++ b/contracts/src/utils/structs/mod.rs @@ -0,0 +1 @@ +pub mod bitmap; From d7016f974ea4bf0a00a01c8b89d51b5d9045a501 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 13 Jun 2024 17:50:38 +0300 Subject: [PATCH 02/25] ++ --- contracts/src/utils/structs/bitmap.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 303c4eb3d..509392640 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -1,7 +1,7 @@ //! Contract module for managing uint256 to bool mapping in a compact and -//! efficient way, provided the keys are sequential. Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. +//! efficient way, provided the keys are sequential. Largely inspired by Uniswap's [merkle-distributor]. //! -//! BitMaps pack 256 booleans across each bit of a single 256-bit slot of +//! `BitMap` packs 256 booleans across each bit of a single 256-bit slot of //! `uint256` type. Hence, booleans corresponding to 256 _sequential_ indices //! would only consume a single slot, unlike the regular `bool` which would //! consume an entire slot for a single value. @@ -16,6 +16,7 @@ use stylus_proc::sol_storage; sol_storage! { /// State of bit map. pub struct BitMap { + /// Inner laying mapping. mapping(uint256 => uint256) _data; } } From 7a237f4e542a58f56fa7b390cae9464fda3d5c9e Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 13 Jun 2024 17:52:09 +0300 Subject: [PATCH 03/25] ++ --- contracts/src/utils/structs/bitmap.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 509392640..a16951496 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -27,7 +27,7 @@ impl BitMap { /// # Arguments /// /// * `index` - index of boolean value at the bit map. - fn get(&self, index: U256) -> bool { + pub fn get(&self, index: U256) -> bool { let bucket = index >> 8; let mask = U256::from(1) << (index & U256::from(0xff)); let value = self._data.get(bucket); @@ -40,7 +40,7 @@ impl BitMap { /// /// * `index` - index of boolean value at the bit map. /// * `value` - boolean value to set into the bit map. - fn set_to(&mut self, index: U256, value: bool) { + pub fn set_to(&mut self, index: U256, value: bool) { if value { self.set(index); } else { @@ -53,7 +53,7 @@ impl BitMap { /// # Arguments /// /// * `index` - index of boolean value that should be set `true`. - fn set(&mut self, index: U256) { + pub fn set(&mut self, index: U256) { let bucket = index >> 8; let mask = U256::from(1) << (index & U256::from(0xff)); let mut value = self._data.setter(bucket); @@ -66,7 +66,7 @@ impl BitMap { /// # Arguments /// /// * `index` - index of boolean value that should be set `false`. - fn unset(&mut self, index: U256) { + pub fn unset(&mut self, index: U256) { let bucket = index >> 8; let mask = U256::from(1) << (index & U256::from(0xff)); let mut value = self._data.setter(bucket); From b83aa0487b7b7ccfca1b6d90f265fec26d5c25cb Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 13 Jun 2024 17:55:16 +0300 Subject: [PATCH 04/25] ++ --- contracts/src/utils/structs/bitmap.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index a16951496..e867a6bf5 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -27,6 +27,7 @@ impl BitMap { /// # Arguments /// /// * `index` - index of boolean value at the bit map. + #[must_use] pub fn get(&self, index: U256) -> bool { let bucket = index >> 8; let mask = U256::from(1) << (index & U256::from(0xff)); From 5f31b569e87b75a8282353d470a5df688f261574 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 13 Jun 2024 17:57:47 +0300 Subject: [PATCH 05/25] ++ --- contracts/src/utils/structs/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/src/utils/structs/mod.rs b/contracts/src/utils/structs/mod.rs index 163f8968d..f5510ad5e 100644 --- a/contracts/src/utils/structs/mod.rs +++ b/contracts/src/utils/structs/mod.rs @@ -1 +1,2 @@ +//! Solidity storage types used by other contracts. pub mod bitmap; From 20c55d63c0778b161345a891c3ad17620b965e8f Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 13 Jun 2024 18:53:44 +0300 Subject: [PATCH 06/25] add save always --- .github/workflows/e2e-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index bc868c54d..19e5856ed 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -48,6 +48,7 @@ jobs: target: wasm32-unknown-unknown components: rust-src toolchain: nightly-2024-01-01 + save-always: true - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From 6301fdaf30668a9c91599f225e05098d6fccea5d Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 14 Jun 2024 00:06:22 +0300 Subject: [PATCH 07/25] Revert "add save always" This reverts commit 20c55d63c0778b161345a891c3ad17620b965e8f. --- .github/workflows/e2e-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 19e5856ed..bc868c54d 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -48,7 +48,6 @@ jobs: target: wasm32-unknown-unknown components: rust-src toolchain: nightly-2024-01-01 - save-always: true - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From de42aac7c7eb2afec4eb440a604b80fd48a544a1 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 15:10:43 +0400 Subject: [PATCH 08/25] ++ --- contracts/src/utils/structs/bitmap.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index e867a6bf5..4cf1e89a5 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -1,9 +1,9 @@ -//! Contract module for managing uint256 to bool mapping in a compact and +//! Contract module for managing `U256` to boolean mapping in a compact and //! efficient way, provided the keys are sequential. Largely inspired by Uniswap's [merkle-distributor]. //! //! `BitMap` packs 256 booleans across each bit of a single 256-bit slot of -//! `uint256` type. Hence, booleans corresponding to 256 _sequential_ indices -//! would only consume a single slot, unlike the regular `bool` which would +//! `U256` type. Hence, booleans corresponding to 256 _sequential_ indices +//! would only consume a single slot, unlike the regular boolean which would //! consume an entire slot for a single value. //! //! This results in gas savings in two ways: From 954f7424aad2332c453581c8cbaf5521957f6a89 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 15:25:23 +0400 Subject: [PATCH 09/25] ++ --- contracts/src/utils/structs/bitmap.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 4cf1e89a5..0456d8149 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -10,7 +10,7 @@ //! //! - Setting a zero value to non-zero only once every 256 times //! - Accessing the same warm slot for every 256 _sequential_ indices -use alloy_primitives::U256; +use alloy_primitives::{U256, Uint}; use stylus_proc::sol_storage; sol_storage! { @@ -55,8 +55,8 @@ impl BitMap { /// /// * `index` - index of boolean value that should be set `true`. pub fn set(&mut self, index: U256) { - let bucket = index >> 8; - let mask = U256::from(1) << (index & U256::from(0xff)); + let bucket = Self::get_bucket(index); + let mask = Self::get_mask(index); let mut value = self._data.setter(bucket); let prev = value.get(); value.set(prev | mask); @@ -68,12 +68,22 @@ impl BitMap { /// /// * `index` - index of boolean value that should be set `false`. pub fn unset(&mut self, index: U256) { - let bucket = index >> 8; - let mask = U256::from(1) << (index & U256::from(0xff)); + let bucket = Self::get_bucket(index); + let mask = Self::get_mask(index); let mut value = self._data.setter(bucket); let prev = value.get(); value.set(prev & !mask); } + + /// Get mask of value in the bucket. + fn get_mask(index: U256) -> U256 { + U256::from(1) << (index & U256::from(0xff)) + } + + /// Get bucket index. + fn get_bucket(index: U256) -> U256 { + index >> 8 + } } #[cfg(all(test, feature = "std"))] From 3e0bfba1fc76240f881cec36671b5a866304ff46 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 16:53:17 +0400 Subject: [PATCH 10/25] proptest --- Cargo.lock | 258 ++++++++++++++++---------- Cargo.toml | 62 +++---- contracts/src/lib.rs | 1 + contracts/src/utils/structs/bitmap.rs | 58 ++++-- 4 files changed, 236 insertions(+), 143 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc8be968c..193e066b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -349,13 +349,19 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e416903084d3392ebd32d94735c395d6709415b76c7728e594d3f996f2b03e65" dependencies = [ + "alloy-rlp", + "arbitrary", "bytes", "cfg-if 1.0.0", "const-hex", + "derive_arbitrary", "derive_more", "hex-literal", "itoa", + "proptest", + "proptest-derive", "ruint", + "serde", "tiny-keccak", ] @@ -460,8 +466,8 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -651,8 +657,8 @@ checksum = "a74ceeffdacf9dd0910404d743d07273776fd17b85f9cb17b49a97e5c6055ce9" dependencies = [ "dunce", "heck 0.4.1", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", "syn-solidity 0.3.1", "tiny-keccak", @@ -667,8 +673,8 @@ dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -684,8 +690,8 @@ dependencies = [ "heck 0.4.1", "indexmap 2.2.6", "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", "syn-solidity 0.7.4", "tiny-keccak", @@ -701,8 +707,8 @@ dependencies = [ "const-hex", "dunce", "heck 0.5.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "serde_json", "syn 2.0.66", "syn-solidity 0.7.4", @@ -854,6 +860,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + [[package]] name = "ark-ff" version = "0.3.0" @@ -898,7 +910,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" dependencies = [ - "quote", + "quote 1.0.36", "syn 1.0.109", ] @@ -908,7 +920,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ - "quote", + "quote 1.0.36", "syn 1.0.109", ] @@ -920,7 +932,7 @@ checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ "num-bigint", "num-traits", - "quote", + "quote 1.0.36", "syn 1.0.109", ] @@ -932,8 +944,8 @@ checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", "num-traits", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1001,8 +1013,8 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1012,8 +1024,8 @@ version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1023,8 +1035,8 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1176,8 +1188,8 @@ version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1273,8 +1285,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ "heck 0.5.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1535,8 +1547,8 @@ checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1547,7 +1559,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", - "quote", + "quote 1.0.36", "syn 2.0.66", ] @@ -1580,11 +1592,22 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1592,8 +1615,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case 0.4.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "rustc_version 0.4.0", "syn 1.0.109", ] @@ -1643,8 +1666,8 @@ dependencies = [ name = "e2e-proc" version = "0.1.0" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1702,8 +1725,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1723,8 +1746,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ "darling", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1942,8 +1965,8 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -2235,8 +2258,8 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2548,8 +2571,8 @@ dependencies = [ name = "motsu-proc" version = "0.1.0" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -2624,8 +2647,8 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -2665,8 +2688,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -2740,8 +2763,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ "proc-macro-crate", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2815,8 +2838,8 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -2881,8 +2904,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", "version_check", ] @@ -2893,11 +2916,20 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "version_check", ] +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + [[package]] name = "proc-macro2" version = "1.0.85" @@ -2927,6 +2959,17 @@ dependencies = [ "unarray", ] +[[package]] +name = "proptest-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90b46295382dc76166cb7cf2bb4a97952464e4b7ed5a43e6cd34e1fec3349ddc" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + [[package]] name = "ptr_meta" version = "0.1.4" @@ -2942,8 +2985,8 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2953,13 +2996,22 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.85", ] [[package]] @@ -3172,8 +3224,8 @@ version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -3194,6 +3246,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" dependencies = [ "alloy-rlp", + "arbitrary", "ark-ff 0.3.0", "ark-ff 0.4.2", "bytes", @@ -3429,8 +3482,8 @@ version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3597,8 +3650,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87" dependencies = [ "heck 0.5.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "rustversion", "syn 2.0.66", ] @@ -3614,8 +3667,8 @@ dependencies = [ "cfg-if 1.0.0", "convert_case 0.6.0", "lazy_static", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "regex", "sha3", "syn 1.0.109", @@ -3644,14 +3697,25 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid", +] + [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "unicode-ident", ] @@ -3661,8 +3725,8 @@ version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "unicode-ident", ] @@ -3672,8 +3736,8 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5f995d2140b0f751dbe94365be2591edbf3d1b75dcfaeac14183abbd2ff07bd" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3684,8 +3748,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8db114c44cf843a8bacd37a146e37987a0b823a0e8bc4fdc610c9c72ab397a5" dependencies = [ "paste", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3734,8 +3798,8 @@ version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3797,8 +3861,8 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3928,8 +3992,8 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -4011,6 +4075,12 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "url" version = "2.5.0" @@ -4105,8 +4175,8 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", "wasm-bindgen-shared", ] @@ -4129,8 +4199,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -4152,7 +4222,7 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ - "quote", + "quote 1.0.36", "wasm-bindgen-macro-support", ] @@ -4162,8 +4232,8 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -4261,8 +4331,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97901fdbaae383dbb90ea162cc3a76a9fa58ac39aec7948b4c0b9bbef9307738" dependencies = [ "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -4619,8 +4689,8 @@ version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -4639,7 +4709,7 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] diff --git a/Cargo.toml b/Cargo.toml index 74e169528..f560cfddb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,28 +1,28 @@ [workspace] members = [ - "contracts", - "lib/crypto", - "lib/motsu", - "lib/motsu-proc", - "examples/erc20", - "examples/erc721", - "examples/merkle-proofs", - "examples/ownable", - "examples/access-control", - "lib/e2e", - "lib/e2e-proc", + "contracts", + "lib/crypto", + "lib/motsu", + "lib/motsu-proc", + "examples/erc20", + "examples/erc721", + "examples/merkle-proofs", + "examples/ownable", + "examples/access-control", + "lib/e2e", + "lib/e2e-proc", ] default-members = [ - "contracts", - "lib/crypto", - "lib/motsu", - "lib/motsu-proc", - "examples/erc20", - "examples/erc721", - "examples/merkle-proofs", - "examples/ownable", - "examples/access-control", - "lib/e2e-proc", + "contracts", + "lib/crypto", + "lib/motsu", + "lib/motsu-proc", + "examples/erc20", + "examples/erc721", + "examples/merkle-proofs", + "examples/ownable", + "examples/access-control", + "lib/e2e-proc", ] # Explicitly set the resolver to version 2, which is the default for packages @@ -38,7 +38,7 @@ keywords = ["arbitrum", "ethereum", "stylus"] repository = "https://github.com/OpenZeppelin/rust-contracts-stylus" [workspace.dependencies] -alloy-primitives = { version = "0.3.1", default-features = false } +alloy-primitives = { version = "0.3.1", default-features = false, features = ["arbitrary"] } alloy-sol-types = { version = "0.3.1", default-features = false } # TODO: lift stylus-sdk and stylus-proc versions once nitro test node will be compatible stylus-sdk = { version = "0.4.3", default-features = false } @@ -46,15 +46,15 @@ stylus-proc = { version = "0.4.3", default-features = false } mini-alloc = "0.4.2" alloy = { git = "https://github.com/alloy-rs/alloy", rev = "0928b92", features = [ - "contract", - "network", - "providers", - "provider-http", - "rpc-client", - "rpc-types-eth", - "signers", - "signer-wallet", - "getrandom", + "contract", + "network", + "providers", + "provider-http", + "rpc-client", + "rpc-types-eth", + "signers", + "signer-wallet", + "getrandom", ] } [profile.release] diff --git a/contracts/src/lib.rs b/contracts/src/lib.rs index 1a2ba3258..2eb50a1ca 100644 --- a/contracts/src/lib.rs +++ b/contracts/src/lib.rs @@ -4,6 +4,7 @@ #![allow(clippy::pub_underscore_fields, clippy::module_name_repetitions)] #![cfg_attr(not(feature = "std"), no_std, no_main)] extern crate alloc; +extern crate core; #[global_allocator] static ALLOC: mini_alloc::MiniAlloc = mini_alloc::MiniAlloc::INIT; diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 0456d8149..1a8343eb9 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -10,7 +10,7 @@ //! //! - Setting a zero value to non-zero only once every 256 times //! - Accessing the same warm slot for every 256 _sequential_ indices -use alloy_primitives::{U256, Uint}; +use alloy_primitives::{Uint, U256}; use stylus_proc::sol_storage; sol_storage! { @@ -88,7 +88,15 @@ impl BitMap { #[cfg(all(test, feature = "std"))] mod tests { - use alloy_primitives::U256; + use core::str::FromStr; + + use alloy_primitives::{ + private::proptest::{ + prelude::{Arbitrary, ProptestConfig}, + proptest, + }, + U256, + }; use stylus_sdk::{prelude::*, storage::StorageMap}; use crate::utils::structs::bitmap::BitMap; @@ -100,30 +108,44 @@ mod tests { } } - // TODO#q: add proptest or smth #[motsu::test] - fn set_value(bit_map: BitMap) { - let value = U256::from(42); - assert_eq!(bit_map.get(value), false); - bit_map.set(value); - assert_eq!(bit_map.get(value), true); + fn set_value() { + proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { + let mut bit_map = BitMap::default(); + assert_eq!(bit_map.get(value), false); + bit_map.set(value); + assert_eq!(bit_map.get(value), true); + }); } #[motsu::test] - fn unset_value(bit_map: BitMap) { - let value = U256::from(42); - bit_map.set(value); - assert_eq!(bit_map.get(value), true); - bit_map.unset(value); - assert_eq!(bit_map.get(value), false); + fn unset_value() { + proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { + let mut bit_map = BitMap::default(); + bit_map.set(value); + assert_eq!(bit_map.get(value), true); + bit_map.unset(value); + assert_eq!(bit_map.get(value), false); + }); + } + + #[motsu::test] + fn set_to_value() { + proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { + let mut bit_map = BitMap::default(); + bit_map.set_to(value, true); + assert_eq!(bit_map.get(value), true); + bit_map.set_to(value, false); + assert_eq!(bit_map.get(value), false); + }); } #[motsu::test] - fn set_to_value(bit_map: BitMap) { - let value = U256::from(42); - bit_map.set_to(value, true); + fn set_to_value_fail(bit_map: BitMap) { + let value = U256::from_str("0x3addf0d5a644504e89618dcb19fe6f7ce797bc52e91dbd1dcf3fddb22cdbce17").expect("parsed U256"); + bit_map.set(value); assert_eq!(bit_map.get(value), true); - bit_map.set_to(value, false); + bit_map.unset(value); assert_eq!(bit_map.get(value), false); } } From 4139ee775dc69b41087bc1babc2101e5b552828e Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 17:34:25 +0400 Subject: [PATCH 11/25] proptest ++ --- contracts/src/utils/structs/bitmap.rs | 32 +++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 1a8343eb9..e80c1da5f 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -97,6 +97,7 @@ mod tests { }, U256, }; + use motsu::prelude::with_context; use stylus_sdk::{prelude::*, storage::StorageMap}; use crate::utils::structs::bitmap::BitMap; @@ -111,32 +112,35 @@ mod tests { #[motsu::test] fn set_value() { proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { - let mut bit_map = BitMap::default(); - assert_eq!(bit_map.get(value), false); - bit_map.set(value); - assert_eq!(bit_map.get(value), true); + with_context::(|bit_map|{ + assert_eq!(bit_map.get(value), false); + bit_map.set(value); + assert_eq!(bit_map.get(value), true); + }); }); } #[motsu::test] fn unset_value() { proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { - let mut bit_map = BitMap::default(); - bit_map.set(value); - assert_eq!(bit_map.get(value), true); - bit_map.unset(value); - assert_eq!(bit_map.get(value), false); + with_context::(|bit_map|{ + bit_map.set(value); + assert_eq!(bit_map.get(value), true); + bit_map.unset(value); + assert_eq!(bit_map.get(value), false); + }); }); } #[motsu::test] fn set_to_value() { proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { - let mut bit_map = BitMap::default(); - bit_map.set_to(value, true); - assert_eq!(bit_map.get(value), true); - bit_map.set_to(value, false); - assert_eq!(bit_map.get(value), false); + with_context::(|bit_map|{ + bit_map.set_to(value, true); + assert_eq!(bit_map.get(value), true); + bit_map.set_to(value, false); + assert_eq!(bit_map.get(value), false); + }); }); } From db4df4d25688f07f3cf94601e1f594c710aaaf14 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 18:00:32 +0400 Subject: [PATCH 12/25] proptest ++ --- .gitignore | 2 ++ Cargo.toml | 2 +- contracts/Cargo.toml | 1 + contracts/src/utils/structs/bitmap.rs | 9 --------- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 28adb4fad..5f10397f6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ docs/build/ **/.DS_Store **/nitro-testnode + +**/proptest-regressions \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index f560cfddb..110f271be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ keywords = ["arbitrum", "ethereum", "stylus"] repository = "https://github.com/OpenZeppelin/rust-contracts-stylus" [workspace.dependencies] -alloy-primitives = { version = "0.3.1", default-features = false, features = ["arbitrary"] } +alloy-primitives = { version = "0.3.1", default-features = false } alloy-sol-types = { version = "0.3.1", default-features = false } # TODO: lift stylus-sdk and stylus-proc versions once nitro test node will be compatible stylus-sdk = { version = "0.4.3", default-features = false } diff --git a/contracts/Cargo.toml b/contracts/Cargo.toml index 1a479d742..d642b540b 100644 --- a/contracts/Cargo.toml +++ b/contracts/Cargo.toml @@ -17,6 +17,7 @@ mini-alloc.workspace = true cfg-if = "1.0" [dev-dependencies] +alloy-primitives = { version = "0.3.1", features = ["arbitrary"] } motsu = { path = "../lib/motsu" } rand = "0.8.5" diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index e80c1da5f..18c0cb8cc 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -143,13 +143,4 @@ mod tests { }); }); } - - #[motsu::test] - fn set_to_value_fail(bit_map: BitMap) { - let value = U256::from_str("0x3addf0d5a644504e89618dcb19fe6f7ce797bc52e91dbd1dcf3fddb22cdbce17").expect("parsed U256"); - bit_map.set(value); - assert_eq!(bit_map.get(value), true); - bit_map.unset(value); - assert_eq!(bit_map.get(value), false); - } } From a11dd57e2eed7765112d5b27858dc5d498bc071c Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 19:13:29 +0400 Subject: [PATCH 13/25] proptest ++ --- contracts/src/utils/structs/bitmap.rs | 34 +++++++++++---------------- lib/motsu-proc/src/test.rs | 8 +++++-- lib/motsu/src/context.rs | 2 +- lib/motsu/src/prelude.rs | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 18c0cb8cc..6b610aac2 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -88,8 +88,6 @@ impl BitMap { #[cfg(all(test, feature = "std"))] mod tests { - use core::str::FromStr; - use alloy_primitives::{ private::proptest::{ prelude::{Arbitrary, ProptestConfig}, @@ -97,7 +95,6 @@ mod tests { }, U256, }; - use motsu::prelude::with_context; use stylus_sdk::{prelude::*, storage::StorageMap}; use crate::utils::structs::bitmap::BitMap; @@ -112,35 +109,32 @@ mod tests { #[motsu::test] fn set_value() { proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { - with_context::(|bit_map|{ - assert_eq!(bit_map.get(value), false); - bit_map.set(value); - assert_eq!(bit_map.get(value), true); - }); + let mut bit_map = BitMap::default(); + assert_eq!(bit_map.get(value), false); + bit_map.set(value); + assert_eq!(bit_map.get(value), true); }); } #[motsu::test] fn unset_value() { proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { - with_context::(|bit_map|{ - bit_map.set(value); - assert_eq!(bit_map.get(value), true); - bit_map.unset(value); - assert_eq!(bit_map.get(value), false); - }); + let mut bit_map = BitMap::default(); + bit_map.set(value); + assert_eq!(bit_map.get(value), true); + bit_map.unset(value); + assert_eq!(bit_map.get(value), false); }); } #[motsu::test] fn set_to_value() { proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { - with_context::(|bit_map|{ - bit_map.set_to(value, true); - assert_eq!(bit_map.get(value), true); - bit_map.set_to(value, false); - assert_eq!(bit_map.get(value), false); - }); + let mut bit_map = BitMap::default(); + bit_map.set_to(value, true); + assert_eq!(bit_map.get(value), true); + bit_map.set_to(value, false); + assert_eq!(bit_map.get(value), false); }); } } diff --git a/lib/motsu-proc/src/test.rs b/lib/motsu-proc/src/test.rs index 4f9b4e79a..685a1a73a 100644 --- a/lib/motsu-proc/src/test.rs +++ b/lib/motsu-proc/src/test.rs @@ -29,11 +29,15 @@ pub fn test(_attr: TokenStream, input: TokenStream) -> TokenStream { // If the test function has no params, then it doesn't need access to the // contract, so it is just a regular test. if fn_args.is_empty() { - let vis = &item_fn.vis; return quote! { #( #attrs )* #[test] - #vis #sig #fn_block + fn #fn_name() #fn_return_type { + let _lock = ::motsu::prelude::acquire_storage(); + let res = #fn_block; + ::motsu::prelude::reset_storage(); + res + } } .into(); } diff --git a/lib/motsu/src/context.rs b/lib/motsu/src/context.rs index 0e222484b..e9afa5837 100644 --- a/lib/motsu/src/context.rs +++ b/lib/motsu/src/context.rs @@ -13,7 +13,7 @@ use crate::storage::reset_storage; pub(crate) static STORAGE_MUTEX: Mutex<()> = Mutex::new(()); /// Acquires access to storage. -pub(crate) fn acquire_storage() -> MutexGuard<'static, ()> { +pub fn acquire_storage() -> MutexGuard<'static, ()> { STORAGE_MUTEX.lock().unwrap_or_else(|e| { reset_storage(); e.into_inner() diff --git a/lib/motsu/src/prelude.rs b/lib/motsu/src/prelude.rs index ef0123e42..caea2b1c2 100644 --- a/lib/motsu/src/prelude.rs +++ b/lib/motsu/src/prelude.rs @@ -1,2 +1,2 @@ //! Common imports for `motsu` tests. -pub use crate::{context::with_context, shims::*, storage::reset_storage}; +pub use crate::{context::{with_context, acquire_storage}, shims::*, storage::reset_storage}; From 51589ee547698ddf8ec2e600c8b3722bff0fff74 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 19:16:29 +0400 Subject: [PATCH 14/25] ++ --- contracts/src/utils/structs/bitmap.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 6b610aac2..85d15a6ef 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -108,7 +108,7 @@ mod tests { #[motsu::test] fn set_value() { - proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { + proptest!(|(value: U256)| { let mut bit_map = BitMap::default(); assert_eq!(bit_map.get(value), false); bit_map.set(value); @@ -118,7 +118,7 @@ mod tests { #[motsu::test] fn unset_value() { - proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { + proptest!(|(value: U256)| { let mut bit_map = BitMap::default(); bit_map.set(value); assert_eq!(bit_map.get(value), true); @@ -129,7 +129,7 @@ mod tests { #[motsu::test] fn set_to_value() { - proptest!(ProptestConfig::with_cases(1000), |(value: U256)| { + proptest!(|(value: U256)| { let mut bit_map = BitMap::default(); bit_map.set_to(value, true); assert_eq!(bit_map.get(value), true); From e91cbe0bf66c75c76d4ef757bb15b6a65313afa3 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 19:18:40 +0400 Subject: [PATCH 15/25] ++ --- lib/motsu/src/prelude.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/motsu/src/prelude.rs b/lib/motsu/src/prelude.rs index caea2b1c2..1150ef75b 100644 --- a/lib/motsu/src/prelude.rs +++ b/lib/motsu/src/prelude.rs @@ -1,2 +1,6 @@ //! Common imports for `motsu` tests. -pub use crate::{context::{with_context, acquire_storage}, shims::*, storage::reset_storage}; +pub use crate::{ + context::{acquire_storage, with_context}, + shims::*, + storage::reset_storage, +}; From ba68dd57df28dd8ef650d833a98264aa982295f8 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 19:24:32 +0400 Subject: [PATCH 16/25] ++ --- Cargo.lock | 786 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 545 insertions(+), 241 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a80a390f..78751fa23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.1.18" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fd095a9d70f4b1c5c102c84a4c782867a5c6416dbf6dcd42a63e7c7a89d3c8" +checksum = "d2feb5f466b3a786d5a622d8926418bc6a0d38bf632909f6ee9298a4a1d8c6e0" dependencies = [ "num_enum", "strum", @@ -137,7 +137,7 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=0928b92#0928b92000d1a56370531d5d3d825729b03dfed9" dependencies = [ "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rlp", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "c-kzg", @@ -150,7 +150,7 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=c6c91cc#c6c91cc197c79c456433c79d60f81c8c5aa13001" dependencies = [ "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rlp", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "c-kzg", @@ -165,10 +165,10 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-network 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-provider 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-sol-types 0.7.4", + "alloy-sol-types 0.7.6", "alloy-transport 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "futures", "futures-util", @@ -183,10 +183,10 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-network 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-provider 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-sol-types 0.7.4", + "alloy-sol-types 0.7.6", "alloy-transport 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "futures", "futures-util", @@ -195,31 +195,31 @@ dependencies = [ [[package]] name = "alloy-core" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7253846c7bf55147775fd66c334abc1dd0a41e97e6155577b3dc513c6e66ef2" +checksum = "5af3faff14c12c8b11037e0a093dd157c3702becb8435577a2408534d0758315" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", - "alloy-primitives 0.7.4", - "alloy-sol-types 0.7.4", + "alloy-primitives 0.7.6", + "alloy-sol-types 0.7.6", ] [[package]] name = "alloy-dyn-abi" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8425a283510106b1a6ad25dd4bb648ecde7da3fd2baeb9400a85ad62f51ec90b" +checksum = "cb6e6436a9530f25010d13653e206fab4c9feddacf21a54de8d7311b275bc56b" dependencies = [ "alloy-json-abi", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-sol-type-parser", - "alloy-sol-types 0.7.4", + "alloy-sol-types 0.7.6", "const-hex", "itoa", "serde", "serde_json", - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] @@ -227,7 +227,7 @@ name = "alloy-eips" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=0928b92#0928b92000d1a56370531d5d3d825729b03dfed9" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rlp", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "c-kzg", @@ -241,7 +241,7 @@ name = "alloy-eips" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=c6c91cc#c6c91cc197c79c456433c79d60f81c8c5aa13001" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rlp", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "c-kzg", @@ -255,7 +255,7 @@ name = "alloy-genesis" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=0928b92#0928b92000d1a56370531d5d3d825729b03dfed9" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "serde", "serde_json", @@ -266,7 +266,7 @@ name = "alloy-genesis" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=c6c91cc#c6c91cc197c79c456433c79d60f81c8c5aa13001" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "serde", "serde_json", @@ -274,11 +274,11 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e30946aa6173020259055a44971f5cf40a7d76c931d209caeb51b333263df4f" +checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-sol-type-parser", "serde", "serde_json", @@ -289,7 +289,7 @@ name = "alloy-json-rpc" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=0928b92#0928b92000d1a56370531d5d3d825729b03dfed9" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "serde", "serde_json", "thiserror", @@ -301,7 +301,7 @@ name = "alloy-json-rpc" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=c6c91cc#c6c91cc197c79c456433c79d60f81c8c5aa13001" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "serde", "serde_json", "thiserror", @@ -316,10 +316,10 @@ dependencies = [ "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-signer 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-sol-types 0.7.4", + "alloy-sol-types 0.7.6", "async-trait", "auto_impl", "futures-utils-wasm", @@ -334,10 +334,10 @@ dependencies = [ "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-signer 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-sol-types 0.7.4", + "alloy-sol-types 0.7.6", "async-trait", "futures-utils-wasm", "thiserror", @@ -349,21 +349,27 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e416903084d3392ebd32d94735c395d6709415b76c7728e594d3f996f2b03e65" dependencies = [ + "alloy-rlp", + "arbitrary", "bytes", "cfg-if 1.0.0", "const-hex", + "derive_arbitrary", "derive_more", "hex-literal", "itoa", + "proptest", + "proptest-derive", "ruint", + "serde", "tiny-keccak", ] [[package]] name = "alloy-primitives" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8aa973e647ec336810a9356af8aea787249c9d00b1525359f3db29a68d231b" +checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" dependencies = [ "alloy-rlp", "bytes", @@ -392,7 +398,7 @@ dependencies = [ "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-network 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rpc-client 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", @@ -422,7 +428,7 @@ dependencies = [ "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-network 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rpc-client 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", @@ -460,8 +466,8 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -513,10 +519,10 @@ dependencies = [ "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rlp", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-sol-types 0.7.4", + "alloy-sol-types 0.7.6", "itertools 0.12.1", "serde", "serde_json", @@ -531,10 +537,10 @@ dependencies = [ "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rlp", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-sol-types 0.7.4", + "alloy-sol-types 0.7.6", "itertools 0.12.1", "serde", "serde_json", @@ -546,7 +552,7 @@ name = "alloy-rpc-types-trace" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=0928b92#0928b92000d1a56370531d5d3d825729b03dfed9" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "serde", @@ -558,7 +564,7 @@ name = "alloy-rpc-types-trace" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=c6c91cc#c6c91cc197c79c456433c79d60f81c8c5aa13001" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "serde", @@ -570,7 +576,7 @@ name = "alloy-serde" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=0928b92#0928b92000d1a56370531d5d3d825729b03dfed9" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "serde", "serde_json", ] @@ -580,7 +586,7 @@ name = "alloy-serde" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=c6c91cc#c6c91cc197c79c456433c79d60f81c8c5aa13001" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "serde", "serde_json", ] @@ -590,7 +596,7 @@ name = "alloy-signer" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=0928b92#0928b92000d1a56370531d5d3d825729b03dfed9" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "async-trait", "auto_impl", "elliptic-curve", @@ -603,7 +609,7 @@ name = "alloy-signer" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=c6c91cc#c6c91cc197c79c456433c79d60f81c8c5aa13001" dependencies = [ - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "async-trait", "auto_impl", "elliptic-curve", @@ -618,7 +624,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=0928b92#0928b92000d1a5637053 dependencies = [ "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "alloy-network 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-signer 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=0928b92)", "async-trait", "k256", @@ -633,7 +639,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=c6c91cc#c6c91cc197c79c456433 dependencies = [ "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "alloy-network 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", - "alloy-primitives 0.7.4", + "alloy-primitives 0.7.6", "alloy-signer 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c6c91cc)", "async-trait", "elliptic-curve", @@ -651,8 +657,8 @@ checksum = "a74ceeffdacf9dd0910404d743d07273776fd17b85f9cb17b49a97e5c6055ce9" dependencies = [ "dunce", "heck 0.4.1", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", "syn-solidity 0.3.1", "tiny-keccak", @@ -660,61 +666,61 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dbd17d67f3e89478c8a634416358e539e577899666c927bc3d2b1328ee9b6ca" +checksum = "4bad41a7c19498e3f6079f7744656328699f8ea3e783bdd10d85788cd439f572" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6da95adcf4760bb4b108fefa51d50096c5e5fdd29ee72fed3e86ee414f2e34" +checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", "const-hex", - "heck 0.4.1", + "heck 0.5.0", "indexmap 2.2.6", "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", - "syn-solidity 0.7.4", + "syn-solidity 0.7.6", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32c8da04c1343871fb6ce5a489218f9c85323c8340a36e9106b5fc98d4dd59d5" +checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" dependencies = [ "alloy-json-abi", "const-hex", "dunce", "heck 0.5.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "serde_json", "syn 2.0.66", - "syn-solidity 0.7.4", + "syn-solidity 0.7.6", ] [[package]] name = "alloy-sol-type-parser" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368cae4dc052cad1d8f72eb2ae0c38027116933eeb49213c200a9e9875f208d7" +checksum = "baa2fbd22d353d8685bd9fee11ba2d8b5c3b1d11e56adb3265fcf1f32bfdf404" dependencies = [ - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] @@ -730,13 +736,13 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a64d2d2395c1ac636b62419a7b17ec39031d6b2367e66e9acbf566e6055e9c" +checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" dependencies = [ "alloy-json-abi", - "alloy-primitives 0.7.4", - "alloy-sol-macro 0.7.4", + "alloy-primitives 0.7.6", + "alloy-sol-macro 0.7.6", "const-hex", "serde", ] @@ -837,9 +843,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -854,6 +860,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + [[package]] name = "ark-ff" version = "0.3.0" @@ -898,7 +910,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" dependencies = [ - "quote", + "quote 1.0.36", "syn 1.0.109", ] @@ -908,7 +920,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ - "quote", + "quote 1.0.36", "syn 1.0.109", ] @@ -920,7 +932,7 @@ checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ "num-bigint", "num-traits", - "quote", + "quote 1.0.36", "syn 1.0.109", ] @@ -932,8 +944,8 @@ checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", "num-traits", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1001,8 +1013,8 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1012,8 +1024,8 @@ version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1023,8 +1035,8 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1036,9 +1048,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -1176,8 +1188,8 @@ version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1218,9 +1230,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -1246,9 +1258,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", "clap_derive", @@ -1256,9 +1268,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", @@ -1268,21 +1280,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck 0.5.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "colorchoice" @@ -1535,8 +1547,8 @@ checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1547,7 +1559,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", - "quote", + "quote 1.0.36", "syn 2.0.66", ] @@ -1580,22 +1592,33 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", +] + [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case 0.4.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "rustc_version 0.4.0", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -1619,6 +1642,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", +] + [[package]] name = "dunce" version = "1.0.4" @@ -1643,8 +1677,8 @@ dependencies = [ name = "e2e-proc" version = "0.1.0" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1702,8 +1736,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1723,8 +1757,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ "darling", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -1942,8 +1976,8 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -2132,12 +2166,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http", "http-body", "pin-project-lite", @@ -2145,9 +2179,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "hyper" @@ -2204,6 +2238,124 @@ dependencies = [ "tracing", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -2212,12 +2364,14 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", + "smallvec", + "utf8_iter", ] [[package]] @@ -2235,8 +2389,8 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2407,6 +2561,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -2452,9 +2612,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -2551,8 +2711,8 @@ dependencies = [ "alloy-primitives 0.3.3", "alloy-sol-types 0.3.1", "motsu", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "stylus-proc", "stylus-sdk", "syn 2.0.66", @@ -2629,16 +2789,16 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] [[package]] name = "object" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -2670,8 +2830,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -2745,8 +2905,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ "proc-macro-crate", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2820,8 +2980,8 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -2886,8 +3046,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", "version_check", ] @@ -2898,11 +3058,20 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "version_check", ] +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + [[package]] name = "proc-macro2" version = "1.0.85" @@ -2932,6 +3101,17 @@ dependencies = [ "unarray", ] +[[package]] +name = "proptest-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90b46295382dc76166cb7cf2bb4a97952464e4b7ed5a43e6cd34e1fec3349ddc" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + [[package]] name = "ptr_meta" version = "0.1.4" @@ -2947,8 +3127,8 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2958,13 +3138,22 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.85", ] [[package]] @@ -3034,9 +3223,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] @@ -3055,9 +3244,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -3067,9 +3256,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -3078,9 +3267,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "region" @@ -3105,9 +3294,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64", "bytes", @@ -3177,8 +3366,8 @@ version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -3194,11 +3383,12 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", + "arbitrary", "ark-ff 0.3.0", "ark-ff 0.4.2", "bytes", @@ -3218,9 +3408,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rustc-demangle" @@ -3434,8 +3624,8 @@ version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3597,13 +3787,13 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ "heck 0.5.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "rustversion", "syn 2.0.66", ] @@ -3619,8 +3809,8 @@ dependencies = [ "cfg-if 1.0.0", "convert_case 0.6.0", "lazy_static", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "regex", "sha3", "syn 1.0.109", @@ -3649,14 +3839,25 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid", +] + [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "unicode-ident", ] @@ -3666,8 +3867,8 @@ version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "unicode-ident", ] @@ -3677,28 +3878,39 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5f995d2140b0f751dbe94365be2591edbf3d1b75dcfaeac14183abbd2ff07bd" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] [[package]] name = "syn-solidity" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8db114c44cf843a8bacd37a146e37987a0b823a0e8bc4fdc610c9c72ab397a5" +checksum = "8d71e19bca02c807c9faa67b5a47673ff231b6e7449b251695188522f1dc44b2" dependencies = [ "paste", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + +[[package]] +name = "synstructure" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", +] [[package]] name = "tap" @@ -3739,8 +3951,8 @@ version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3762,6 +3974,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -3802,8 +4024,8 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3844,14 +4066,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.13", + "toml_edit 0.22.14", ] [[package]] @@ -3876,15 +4098,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] @@ -3933,8 +4155,8 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] @@ -3983,27 +4205,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-normalization" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -4012,26 +4219,44 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "unicode-xid" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" [[package]] name = "url" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -4110,8 +4335,8 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", "wasm-bindgen-shared", ] @@ -4134,8 +4359,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -4157,7 +4382,7 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ - "quote", + "quote 1.0.36", "wasm-bindgen-macro-support", ] @@ -4167,8 +4392,8 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -4182,9 +4407,9 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-encoder" -version = "0.209.1" +version = "0.210.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4a05336882dae732ce6bd48b7e11fe597293cb72c13da4f35d7d5f8d53b2a7" +checksum = "e7e3764d9d6edabd8c9e16195e177be0d20f6ab942ad18af52860f12f82bc59a" dependencies = [ "leb128", ] @@ -4266,8 +4491,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97901fdbaae383dbb90ea162cc3a76a9fa58ac39aec7948b4c0b9bbef9307738" dependencies = [ "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -4326,9 +4551,9 @@ dependencies = [ [[package]] name = "wast" -version = "209.0.1" +version = "210.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fffef2ff6147e4d12e972765fd75332c6a11c722571d4ab7a780d81ffc8f0a4" +checksum = "aa835c59bd615e00f16be65705d85517d40b44b3c831d724e450244685176c3c" dependencies = [ "bumpalo", "leb128", @@ -4339,9 +4564,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.209.1" +version = "1.210.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42203ec0271d113f8eb1f77ebc624886530cecb35915a7f63a497131f16e4d24" +checksum = "67faece8487996430c6812be7f8776dc563ca0efcd3db77f8839070480c0d1a6" dependencies = [ "wast", ] @@ -4583,9 +4808,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.9" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -4600,6 +4825,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "wyz" version = "0.5.1" @@ -4609,6 +4846,30 @@ dependencies = [ "tap", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.34" @@ -4624,9 +4885,30 @@ version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", + "synstructure", ] [[package]] @@ -4644,7 +4926,29 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", +] + +[[package]] +name = "zerovec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" +dependencies = [ + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 2.0.66", ] From 12b7cfb29d2bec35ada49df77ba94df0c23395d8 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 19:31:12 +0400 Subject: [PATCH 17/25] ++ --- contracts/src/utils/structs/bitmap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 85d15a6ef..ee0548471 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -10,7 +10,7 @@ //! //! - Setting a zero value to non-zero only once every 256 times //! - Accessing the same warm slot for every 256 _sequential_ indices -use alloy_primitives::{Uint, U256}; +use alloy_primitives::U256; use stylus_proc::sol_storage; sol_storage! { From 0d9098a74d2008bab0581bb683ef0af8899f86e4 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 21:13:01 +0400 Subject: [PATCH 18/25] ++ --- Cargo.toml | 60 +++++++++++++-------------- contracts/src/utils/structs/bitmap.rs | 12 ++---- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 110f271be..74e169528 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,28 +1,28 @@ [workspace] members = [ - "contracts", - "lib/crypto", - "lib/motsu", - "lib/motsu-proc", - "examples/erc20", - "examples/erc721", - "examples/merkle-proofs", - "examples/ownable", - "examples/access-control", - "lib/e2e", - "lib/e2e-proc", + "contracts", + "lib/crypto", + "lib/motsu", + "lib/motsu-proc", + "examples/erc20", + "examples/erc721", + "examples/merkle-proofs", + "examples/ownable", + "examples/access-control", + "lib/e2e", + "lib/e2e-proc", ] default-members = [ - "contracts", - "lib/crypto", - "lib/motsu", - "lib/motsu-proc", - "examples/erc20", - "examples/erc721", - "examples/merkle-proofs", - "examples/ownable", - "examples/access-control", - "lib/e2e-proc", + "contracts", + "lib/crypto", + "lib/motsu", + "lib/motsu-proc", + "examples/erc20", + "examples/erc721", + "examples/merkle-proofs", + "examples/ownable", + "examples/access-control", + "lib/e2e-proc", ] # Explicitly set the resolver to version 2, which is the default for packages @@ -46,15 +46,15 @@ stylus-proc = { version = "0.4.3", default-features = false } mini-alloc = "0.4.2" alloy = { git = "https://github.com/alloy-rs/alloy", rev = "0928b92", features = [ - "contract", - "network", - "providers", - "provider-http", - "rpc-client", - "rpc-types-eth", - "signers", - "signer-wallet", - "getrandom", + "contract", + "network", + "providers", + "provider-http", + "rpc-client", + "rpc-types-eth", + "signers", + "signer-wallet", + "getrandom", ] } [profile.release] diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index ee0548471..7e7dea3d9 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -15,6 +15,7 @@ use stylus_proc::sol_storage; sol_storage! { /// State of bit map. + #[cfg_attr(all(test, feature = "std"), derive(motsu::DefaultStorageLayout))] pub struct BitMap { /// Inner laying mapping. mapping(uint256 => uint256) _data; @@ -29,8 +30,8 @@ impl BitMap { /// * `index` - index of boolean value at the bit map. #[must_use] pub fn get(&self, index: U256) -> bool { - let bucket = index >> 8; - let mask = U256::from(1) << (index & U256::from(0xff)); + let bucket = Self::get_bucket(index); + let mask = Self::get_mask(index); let value = self._data.get(bucket); (value & mask) != U256::ZERO } @@ -99,13 +100,6 @@ mod tests { use crate::utils::structs::bitmap::BitMap; - impl Default for BitMap { - fn default() -> Self { - let root = U256::ZERO; - BitMap { _data: unsafe { StorageMap::new(root, 0) } } - } - } - #[motsu::test] fn set_value() { proptest!(|(value: U256)| { From 4cc718e2f53b3367bd96bbd73124d1c306650a3c Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh <37006439+qalisander@users.noreply.github.com> Date: Mon, 17 Jun 2024 22:43:41 +0400 Subject: [PATCH 19/25] Update contracts/src/utils/structs/bitmap.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander González --- contracts/src/utils/structs/bitmap.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 7e7dea3d9..d2e856adc 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -1,5 +1,6 @@ //! Contract module for managing `U256` to boolean mapping in a compact and -//! efficient way, provided the keys are sequential. Largely inspired by Uniswap's [merkle-distributor]. +//! efficient way, provided the keys are sequential. Largely inspired by Uniswap's +//! [merkle-distributor]. //! //! `BitMap` packs 256 booleans across each bit of a single 256-bit slot of //! `U256` type. Hence, booleans corresponding to 256 _sequential_ indices @@ -10,6 +11,8 @@ //! //! - Setting a zero value to non-zero only once every 256 times //! - Accessing the same warm slot for every 256 _sequential_ indices +//! +//! [merkle-distributor]: https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol use alloy_primitives::U256; use stylus_proc::sol_storage; From f0cd787e0c0ff86f6eb02192c16c6b7406c09b42 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh <37006439+qalisander@users.noreply.github.com> Date: Mon, 17 Jun 2024 22:47:36 +0400 Subject: [PATCH 20/25] Update contracts/src/utils/structs/bitmap.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander González --- contracts/src/utils/structs/bitmap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index d2e856adc..e41d9f25f 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -43,8 +43,8 @@ impl BitMap { /// /// # Arguments /// - /// * `index` - index of boolean value at the bit map. - /// * `value` - boolean value to set into the bit map. + /// * `index` - index of boolean value in the bit map. + /// * `value` - boolean value to set in the bit map. pub fn set_to(&mut self, index: U256, value: bool) { if value { self.set(index); From a56e9baa093c9284f3d4e5726552dedec8e5eb75 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 22:54:18 +0400 Subject: [PATCH 21/25] ++ --- .gitignore | 2 -- contracts/src/lib.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5f10397f6..28adb4fad 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,3 @@ docs/build/ **/.DS_Store **/nitro-testnode - -**/proptest-regressions \ No newline at end of file diff --git a/contracts/src/lib.rs b/contracts/src/lib.rs index 2eb50a1ca..1a2ba3258 100644 --- a/contracts/src/lib.rs +++ b/contracts/src/lib.rs @@ -4,7 +4,6 @@ #![allow(clippy::pub_underscore_fields, clippy::module_name_repetitions)] #![cfg_attr(not(feature = "std"), no_std, no_main)] extern crate alloc; -extern crate core; #[global_allocator] static ALLOC: mini_alloc::MiniAlloc = mini_alloc::MiniAlloc::INIT; From 785a1bd7beedab300b9569787c2bbbf90faf10fe Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 22:58:29 +0400 Subject: [PATCH 22/25] ++ --- contracts/src/utils/structs/bitmap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index e41d9f25f..cefa21f1a 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -1,6 +1,6 @@ //! Contract module for managing `U256` to boolean mapping in a compact and -//! efficient way, provided the keys are sequential. Largely inspired by Uniswap's -//! [merkle-distributor]. +//! efficient way, provided the keys are sequential. Largely inspired by +//! Uniswap's [merkle-distributor]. //! //! `BitMap` packs 256 booleans across each bit of a single 256-bit slot of //! `U256` type. Hence, booleans corresponding to 256 _sequential_ indices From 16dbba496dcc217dec85aabc27ca4d0e94fff96a Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 23:03:13 +0400 Subject: [PATCH 23/25] ++ --- contracts/src/utils/structs/bitmap.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index cefa21f1a..4cd8ef3ca 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -16,6 +16,9 @@ use alloy_primitives::U256; use stylus_proc::sol_storage; +pub const ONE: U256 = U256::from_limbs([1, 0, 0, 0]); +pub const HEX_FF: U256 = U256::from_limbs([255, 0, 0, 0]); + sol_storage! { /// State of bit map. #[cfg_attr(all(test, feature = "std"), derive(motsu::DefaultStorageLayout))] @@ -81,7 +84,7 @@ impl BitMap { /// Get mask of value in the bucket. fn get_mask(index: U256) -> U256 { - U256::from(1) << (index & U256::from(0xff)) + ONE << (index & HEX_FF) } /// Get bucket index. From d71f48a8b2139bf5c4298d8abde5b0c9945205e6 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 17 Jun 2024 23:08:47 +0400 Subject: [PATCH 24/25] ++ --- contracts/src/utils/structs/bitmap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 4cd8ef3ca..aa8fc2a2b 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -16,8 +16,8 @@ use alloy_primitives::U256; use stylus_proc::sol_storage; -pub const ONE: U256 = U256::from_limbs([1, 0, 0, 0]); -pub const HEX_FF: U256 = U256::from_limbs([255, 0, 0, 0]); +const ONE: U256 = U256::from_limbs([1, 0, 0, 0]); +const HEX_FF: U256 = U256::from_limbs([255, 0, 0, 0]); sol_storage! { /// State of bit map. From ab7f3c77b78a7a2f273abbe39b3551ec48331d49 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh <37006439+qalisander@users.noreply.github.com> Date: Mon, 17 Jun 2024 23:09:50 +0400 Subject: [PATCH 25/25] Update contracts/src/utils/structs/bitmap.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander González --- contracts/src/utils/structs/bitmap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index aa8fc2a2b..0bb88606f 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -33,7 +33,7 @@ impl BitMap { /// /// # Arguments /// - /// * `index` - index of boolean value at the bit map. + /// * `index` - index of the boolean value in the bit map. #[must_use] pub fn get(&self, index: U256) -> bool { let bucket = Self::get_bucket(index);