From ae1d11e4ee4a7330ece161f1fc10a44ca02256ed Mon Sep 17 00:00:00 2001 From: Thibault Martinez <thibault@iota.org> Date: Thu, 16 Nov 2023 13:34:14 +0100 Subject: [PATCH 1/3] Remove unit visitor from verify_with --- Cargo.lock | 86 +++++++++---------- bindings/core/Cargo.toml | 2 +- sdk/Cargo.toml | 2 +- sdk/src/types/block/address/multi.rs | 20 ++--- sdk/src/types/block/core/parent.rs | 2 +- .../block/output/feature/block_issuer.rs | 7 +- sdk/src/types/block/output/feature/mod.rs | 4 +- sdk/src/types/block/output/native_token.rs | 8 +- .../types/block/output/token_scheme/simple.rs | 7 +- .../output/unlock_condition/expiration.rs | 4 +- .../block/output/unlock_condition/timelock.rs | 4 +- sdk/src/types/block/unlock/mod.rs | 4 +- sdk/src/types/block/unlock/multi.rs | 4 +- sdk/src/types/fuzz/Cargo.toml | 2 +- 14 files changed, 71 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ad22abad6..10a9ed071e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -382,10 +382,11 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.84" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ + "jobserver", "libc", ] @@ -943,7 +944,7 @@ checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek 4.1.1", "ed25519", - "hashbrown 0.14.2", + "hashbrown", "hex", "rand_core 0.6.4", "serde", @@ -953,9 +954,9 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "e9775b22bc152ad86a0cf23f0f348b884b26add12bf741e7ffc4d4ab2ab4d205" dependencies = [ "base16ct", "crypto-bigint", @@ -1021,9 +1022,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", "windows-sys 0.48.0", @@ -1085,9 +1086,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f69037fe1b785e84986b4f2cbcf647381876a00671d25ceef715d7812dd7e1dd" +checksum = "53a56f0780318174bad1c127063fd0c5fdfb35398e3cd79ffaab931a6c79df80" [[package]] name = "field-offset" @@ -1344,9 +1345,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -1354,19 +1355,13 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap", "slab", "tokio", "tokio-util", "tracing", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.14.2" @@ -1552,16 +1547,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.1.0" @@ -1569,7 +1554,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown", ] [[package]] @@ -1666,7 +1651,7 @@ dependencies = [ "getset", "gloo-storage", "gloo-timers", - "hashbrown 0.14.2", + "hashbrown", "hex", "instant", "iota-crypto", @@ -1785,6 +1770,15 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.65" @@ -1796,9 +1790,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" dependencies = [ "cfg-if", "ecdsa", @@ -2183,9 +2177,8 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "packable" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee4180de5473e336f075507fea07003183e059bc0d35398b0b0039419747e76" +version = "0.10.0" +source = "git+https://github.com/thibault-martinez/common-rs?branch=conditional-visitor-param#d09c2cb3538d35c8d0191a16ef123a59ad809d2b" dependencies = [ "autocfg", "packable-derive", @@ -2195,9 +2188,8 @@ dependencies = [ [[package]] name = "packable-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5ee3cb4c60754a0b49a3b7a6f5067a191ff5ec9d90414f6c4cfd21ce9acff" +version = "0.9.0" +source = "git+https://github.com/thibault-martinez/common-rs?branch=conditional-visitor-param#d09c2cb3538d35c8d0191a16ef123a59ad809d2b" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -2680,9 +2672,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.22" +version = "0.38.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80109a168d9bc0c7f483083244543a6eb0dba02295d33ca268145e6190d6df0c" +checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" dependencies = [ "bitflags 2.4.1", "errno", @@ -3336,7 +3328,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.1.0", + "indexmap", "toml_datetime", "winnow", ] @@ -3916,18 +3908,18 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.25" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.25" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" dependencies = [ "proc-macro2", "quote", @@ -3936,9 +3928,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "12a3946ecfc929b583800f4629b6c25b88ac6e92a40ea5670f77112a85d40a8b" dependencies = [ "serde", "zeroize_derive", diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index aaff827018..0a2db46115 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -23,7 +23,7 @@ iota-crypto = { version = "0.23.0", default-features = false, features = [ "bip44", ] } log = { version = "0.4.20", default-features = false } -packable = { version = "0.9.0", default-features = false } +packable = { version = "0.10.0", git = "https://github.com/thibault-martinez/common-rs", branch = "conditional-visitor-param", default-features = false } prefix-hex = { version = "0.7.1", default-features = false } primitive-types = { version = "0.12.2", default-features = false } serde = { version = "1.0.188", default-features = false } diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index b5471cd7a4..4e2f5bd17c 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -45,7 +45,7 @@ iota-crypto = { version = "0.23.0", default-features = false, features = [ "secp256k1", ] } iterator-sorted = { version = "0.1.0", default-features = false } -packable = { version = "0.9.0", default-features = false, features = [ +packable = { version = "0.10.0", git = "https://github.com/thibault-martinez/common-rs", branch = "conditional-visitor-param", default-features = false, features = [ "primitive-types", ] } paste = { version = "1.0.14", default-features = false } diff --git a/sdk/src/types/block/address/multi.rs b/sdk/src/types/block/address/multi.rs index b4f59e2284..2941856815 100644 --- a/sdk/src/types/block/address/multi.rs +++ b/sdk/src/types/block/address/multi.rs @@ -30,8 +30,8 @@ pub struct WeightedAddress { impl WeightedAddress { /// Creates a new [`WeightedAddress`]. pub fn new(address: Address, weight: u8) -> Result<WeightedAddress, Error> { - verify_address::<true>(&address, &())?; - verify_weight::<true>(&weight, &())?; + verify_address::<true>(&address)?; + verify_weight::<true>(&weight)?; Ok(Self { address, weight }) } @@ -47,7 +47,7 @@ impl WeightedAddress { } } -fn verify_address<const VERIFY: bool>(address: &Address, _visitor: &()) -> Result<(), Error> { +fn verify_address<const VERIFY: bool>(address: &Address) -> Result<(), Error> { if VERIFY { if !matches!( address, @@ -59,7 +59,7 @@ fn verify_address<const VERIFY: bool>(address: &Address, _visitor: &()) -> Resul Ok(()) } -fn verify_weight<const VERIFY: bool>(weight: &u8, _visitor: &()) -> Result<(), Error> { +fn verify_weight<const VERIFY: bool>(weight: &u8) -> Result<(), Error> { if VERIFY && *weight == 0 { return Err(Error::InvalidAddressWeight(*weight)); } else { @@ -95,15 +95,15 @@ impl MultiAddress { pub fn new(addresses: impl IntoIterator<Item = WeightedAddress>, threshold: u16) -> Result<Self, Error> { let addresses = addresses.into_iter().collect::<Box<[_]>>(); - verify_addresses::<true>(&addresses, &())?; - verify_threshold::<true>(&threshold, &())?; + verify_addresses::<true>(&addresses)?; + verify_threshold::<true>(&threshold)?; let addresses = BoxedSlicePrefix::<WeightedAddress, WeightedAddressCount>::try_from(addresses) .map_err(Error::InvalidWeightedAddressCount)?; let multi_address = Self { addresses, threshold }; - verify_multi_address::<true>(&multi_address, &())?; + verify_multi_address::<true>(&multi_address)?; Ok(multi_address) } @@ -121,7 +121,7 @@ impl MultiAddress { } } -fn verify_addresses<const VERIFY: bool>(addresses: &[WeightedAddress], _visitor: &()) -> Result<(), Error> { +fn verify_addresses<const VERIFY: bool>(addresses: &[WeightedAddress]) -> Result<(), Error> { if VERIFY && !is_unique_sorted(addresses.iter().map(WeightedAddress::address)) { return Err(Error::WeightedAddressesNotUniqueSorted); } else { @@ -129,7 +129,7 @@ fn verify_addresses<const VERIFY: bool>(addresses: &[WeightedAddress], _visitor: } } -fn verify_threshold<const VERIFY: bool>(threshold: &u16, _visitor: &()) -> Result<(), Error> { +fn verify_threshold<const VERIFY: bool>(threshold: &u16) -> Result<(), Error> { if VERIFY && *threshold == 0 { return Err(Error::InvalidMultiAddressThreshold(*threshold)); } else { @@ -137,7 +137,7 @@ fn verify_threshold<const VERIFY: bool>(threshold: &u16, _visitor: &()) -> Resul } } -fn verify_multi_address<const VERIFY: bool>(address: &MultiAddress, _visitor: &()) -> Result<(), Error> { +fn verify_multi_address<const VERIFY: bool>(address: &MultiAddress) -> Result<(), Error> { if VERIFY { let cumulative_weight = address.iter().map(|address| address.weight as u16).sum::<u16>(); diff --git a/sdk/src/types/block/core/parent.rs b/sdk/src/types/block/core/parent.rs index 80f7cf30d6..d7166b7f77 100644 --- a/sdk/src/types/block/core/parent.rs +++ b/sdk/src/types/block/core/parent.rs @@ -75,7 +75,7 @@ impl<const MIN: u8, const MAX: u8> Parents<MIN, MAX> { } } -fn verify_parents<const VERIFY: bool>(parents: &[BlockId], _: &()) -> Result<(), Error> { +fn verify_parents<const VERIFY: bool>(parents: &[BlockId]) -> Result<(), Error> { if VERIFY && !is_unique_sorted(parents.iter().map(AsRef::as_ref)) { Err(Error::ParentsNotUniqueSorted) } else { diff --git a/sdk/src/types/block/output/feature/block_issuer.rs b/sdk/src/types/block/output/feature/block_issuer.rs index e948559958..6723d18741 100644 --- a/sdk/src/types/block/output/feature/block_issuer.rs +++ b/sdk/src/types/block/output/feature/block_issuer.rs @@ -122,10 +122,7 @@ pub struct BlockIssuerKeys( #[packable(verify_with = verify_block_issuer_keys)] BoxedSlicePrefix<BlockIssuerKey, BlockIssuerKeyCount>, ); -fn verify_block_issuer_keys<const VERIFY: bool>( - block_issuer_keys: &[BlockIssuerKey], - _visitor: &(), -) -> Result<(), Error> { +fn verify_block_issuer_keys<const VERIFY: bool>(block_issuer_keys: &[BlockIssuerKey]) -> Result<(), Error> { if VERIFY && !is_unique_sorted(block_issuer_keys.iter()) { return Err(Error::BlockIssuerKeysNotUniqueSorted); } @@ -177,7 +174,7 @@ impl BlockIssuerKeys { block_issuer_keys.sort(); // Still need to verify the duplicate block issuer keys. - verify_block_issuer_keys::<true>(&block_issuer_keys, &())?; + verify_block_issuer_keys::<true>(&block_issuer_keys)?; Ok(Self(block_issuer_keys)) } diff --git a/sdk/src/types/block/output/feature/mod.rs b/sdk/src/types/block/output/feature/mod.rs index ef936e372b..087e5607be 100644 --- a/sdk/src/types/block/output/feature/mod.rs +++ b/sdk/src/types/block/output/feature/mod.rs @@ -184,7 +184,7 @@ impl Features { features.sort_by_key(Feature::kind); // Sort is obviously fine now but uniqueness still needs to be checked. - verify_unique_sorted::<true>(&features, &())?; + verify_unique_sorted::<true>(&features)?; Ok(Self(features)) } @@ -248,7 +248,7 @@ impl StorageScore for Features { } #[inline] -fn verify_unique_sorted<const VERIFY: bool>(features: &[Feature], _: &()) -> Result<(), Error> { +fn verify_unique_sorted<const VERIFY: bool>(features: &[Feature]) -> Result<(), Error> { if VERIFY && !is_unique_sorted(features.iter().map(Feature::kind)) { Err(Error::FeaturesNotUniqueSorted) } else { diff --git a/sdk/src/types/block/output/native_token.rs b/sdk/src/types/block/output/native_token.rs index 767f4dce39..d2c430f718 100644 --- a/sdk/src/types/block/output/native_token.rs +++ b/sdk/src/types/block/output/native_token.rs @@ -51,7 +51,7 @@ impl NativeToken { pub fn new(token_id: TokenId, amount: impl Into<U256>) -> Result<Self, Error> { let amount = amount.into(); - verify_amount::<true>(&amount, &())?; + verify_amount::<true>(&amount)?; Ok(Self { token_id, amount }) } @@ -84,7 +84,7 @@ impl Ord for NativeToken { impl StorageScore for NativeToken {} #[inline] -fn verify_amount<const VERIFY: bool>(amount: &U256, _: &()) -> Result<(), Error> { +fn verify_amount<const VERIFY: bool>(amount: &U256) -> Result<(), Error> { if VERIFY && amount.is_zero() { Err(Error::NativeTokensNullAmount) } else { @@ -218,7 +218,7 @@ impl NativeTokens { native_tokens.sort_by(|a, b| a.token_id().cmp(b.token_id())); // Sort is obviously fine now but uniqueness still needs to be checked. - verify_unique_sorted::<true>(&native_tokens, &())?; + verify_unique_sorted::<true>(&native_tokens)?; Ok(Self(native_tokens)) } @@ -258,7 +258,7 @@ impl NativeTokens { } #[inline] -fn verify_unique_sorted<const VERIFY: bool>(native_tokens: &[NativeToken], _: &()) -> Result<(), Error> { +fn verify_unique_sorted<const VERIFY: bool>(native_tokens: &[NativeToken]) -> Result<(), Error> { if VERIFY && !is_unique_sorted(native_tokens.iter().map(NativeToken::token_id)) { Err(Error::NativeTokensNotUniqueSorted) } else { diff --git a/sdk/src/types/block/output/token_scheme/simple.rs b/sdk/src/types/block/output/token_scheme/simple.rs index b675bcbc69..1a971d91c6 100644 --- a/sdk/src/types/block/output/token_scheme/simple.rs +++ b/sdk/src/types/block/output/token_scheme/simple.rs @@ -40,7 +40,7 @@ impl SimpleTokenScheme { maximum_supply, }; - verify_simple_token_scheme::<true>(&token_scheme, &())?; + verify_simple_token_scheme::<true>(&token_scheme)?; Ok(token_scheme) } @@ -71,10 +71,7 @@ impl SimpleTokenScheme { } #[inline] -fn verify_simple_token_scheme<const VERIFY: bool>( - token_scheme: &SimpleTokenScheme, - _visitor: &(), -) -> Result<(), Error> { +fn verify_simple_token_scheme<const VERIFY: bool>(token_scheme: &SimpleTokenScheme) -> Result<(), Error> { if VERIFY && (token_scheme.maximum_supply.is_zero() || token_scheme.melted_tokens > token_scheme.minted_tokens diff --git a/sdk/src/types/block/output/unlock_condition/expiration.rs b/sdk/src/types/block/output/unlock_condition/expiration.rs index 41563f41c4..e1a4362867 100644 --- a/sdk/src/types/block/output/unlock_condition/expiration.rs +++ b/sdk/src/types/block/output/unlock_condition/expiration.rs @@ -30,7 +30,7 @@ impl ExpirationUnlockCondition { pub fn new(return_address: impl Into<Address>, slot_index: impl Into<SlotIndex>) -> Result<Self, Error> { let slot_index = slot_index.into(); - verify_slot_index::<true>(&slot_index, &())?; + verify_slot_index::<true>(&slot_index)?; Ok(Self { return_address: return_address.into(), @@ -67,7 +67,7 @@ impl StorageScore for ExpirationUnlockCondition { } #[inline] -fn verify_slot_index<const VERIFY: bool>(slot_index: &SlotIndex, _: &()) -> Result<(), Error> { +fn verify_slot_index<const VERIFY: bool>(slot_index: &SlotIndex) -> Result<(), Error> { if VERIFY && *slot_index == 0 { Err(Error::ExpirationUnlockConditionZero) } else { diff --git a/sdk/src/types/block/output/unlock_condition/timelock.rs b/sdk/src/types/block/output/unlock_condition/timelock.rs index a01faa6faf..0395668986 100644 --- a/sdk/src/types/block/output/unlock_condition/timelock.rs +++ b/sdk/src/types/block/output/unlock_condition/timelock.rs @@ -19,7 +19,7 @@ impl TimelockUnlockCondition { pub fn new(slot_index: impl Into<SlotIndex>) -> Result<Self, Error> { let slot_index = slot_index.into(); - verify_slot_index::<true>(&slot_index, &())?; + verify_slot_index::<true>(&slot_index)?; Ok(Self(slot_index)) } @@ -34,7 +34,7 @@ impl TimelockUnlockCondition { impl StorageScore for TimelockUnlockCondition {} #[inline] -fn verify_slot_index<const VERIFY: bool>(slot_index: &SlotIndex, _: &()) -> Result<(), Error> { +fn verify_slot_index<const VERIFY: bool>(slot_index: &SlotIndex) -> Result<(), Error> { if VERIFY && *slot_index == 0 { Err(Error::TimelockUnlockConditionZero) } else { diff --git a/sdk/src/types/block/unlock/mod.rs b/sdk/src/types/block/unlock/mod.rs index fce07f8150..35e0d6bdd6 100644 --- a/sdk/src/types/block/unlock/mod.rs +++ b/sdk/src/types/block/unlock/mod.rs @@ -117,7 +117,7 @@ impl Unlocks { let unlocks: BoxedSlicePrefix<Unlock, UnlockCount> = unlocks.into().try_into().map_err(Error::InvalidUnlockCount)?; - verify_unlocks::<true>(&unlocks, &())?; + verify_unlocks::<true>(&unlocks)?; Ok(Self(unlocks)) } @@ -177,7 +177,7 @@ fn verify_non_multi_unlock<'a>( Ok(()) } -fn verify_unlocks<const VERIFY: bool>(unlocks: &[Unlock], _: &()) -> Result<(), Error> { +fn verify_unlocks<const VERIFY: bool>(unlocks: &[Unlock]) -> Result<(), Error> { if VERIFY { let mut seen_signatures = HashSet::new(); diff --git a/sdk/src/types/block/unlock/multi.rs b/sdk/src/types/block/unlock/multi.rs index 99a2f2f0fd..58e41a24fb 100644 --- a/sdk/src/types/block/unlock/multi.rs +++ b/sdk/src/types/block/unlock/multi.rs @@ -24,7 +24,7 @@ impl MultiUnlock { pub fn new(unlocks: impl IntoIterator<Item = Unlock>) -> Result<Self, Error> { let unlocks = unlocks.into_iter().collect::<Box<[_]>>(); - verify_unlocks::<true>(&unlocks, &())?; + verify_unlocks::<true>(&unlocks)?; Ok(Self( BoxedSlicePrefix::<Unlock, UnlocksCount>::try_from(unlocks).map_err(Error::InvalidMultiUnlockCount)?, @@ -38,7 +38,7 @@ impl MultiUnlock { } } -fn verify_unlocks<const VERIFY: bool>(unlocks: &[Unlock], _visitor: &()) -> Result<(), Error> { +fn verify_unlocks<const VERIFY: bool>(unlocks: &[Unlock]) -> Result<(), Error> { if VERIFY && unlocks.iter().any(Unlock::is_multi) { return Err(Error::MultiUnlockRecursion); } else { diff --git a/sdk/src/types/fuzz/Cargo.toml b/sdk/src/types/fuzz/Cargo.toml index 787a244911..03055e3b88 100644 --- a/sdk/src/types/fuzz/Cargo.toml +++ b/sdk/src/types/fuzz/Cargo.toml @@ -12,7 +12,7 @@ cargo-fuzz = true iota-types = { path = "..", default-features = false } libfuzzer-sys = { version = "0.4.7", default-features = false } -packable = { version = "0.9.0", default-features = false } +packable = { version = "0.10.0", git = "https://github.com/thibault-martinez/common-rs", branch = "conditional-visitor-param", default-features = false } # Prevent this from interfering with workspaces [workspace] From 0b7d1dce9a8d0c032276a977e83aae663bc36ef7 Mon Sep 17 00:00:00 2001 From: Thibault Martinez <thibault@iota.org> Date: Fri, 17 Nov 2023 16:55:01 +0100 Subject: [PATCH 2/3] Fix compilation --- Cargo.lock | 24 ++++++++++++------------ sdk/src/types/block/mana/mod.rs | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10a9ed071e..147e655ef9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -913,9 +913,9 @@ checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest 0.10.7", @@ -1086,9 +1086,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a56f0780318174bad1c127063fd0c5fdfb35398e3cd79ffaab931a6c79df80" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "field-offset" @@ -2178,7 +2178,7 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "packable" version = "0.10.0" -source = "git+https://github.com/thibault-martinez/common-rs?branch=conditional-visitor-param#d09c2cb3538d35c8d0191a16ef123a59ad809d2b" +source = "git+https://github.com/thibault-martinez/common-rs?branch=conditional-visitor-param#2249da658d180e63e16855a2dcc0aa55c7c26a92" dependencies = [ "autocfg", "packable-derive", @@ -2189,7 +2189,7 @@ dependencies = [ [[package]] name = "packable-derive" version = "0.9.0" -source = "git+https://github.com/thibault-martinez/common-rs?branch=conditional-visitor-param#d09c2cb3538d35c8d0191a16ef123a59ad809d2b" +source = "git+https://github.com/thibault-martinez/common-rs?branch=conditional-visitor-param#2249da658d180e63e16855a2dcc0aa55c7c26a92" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -2685,9 +2685,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.8" +version = "0.21.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" +checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ "log", "ring", @@ -2965,9 +2965,9 @@ checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", "rand_core 0.6.4", @@ -3928,9 +3928,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12a3946ecfc929b583800f4629b6c25b88ac6e92a40ea5670f77112a85d40a8b" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "serde", "zeroize_derive", diff --git a/sdk/src/types/block/mana/mod.rs b/sdk/src/types/block/mana/mod.rs index 7f7bc665c5..72328c74db 100644 --- a/sdk/src/types/block/mana/mod.rs +++ b/sdk/src/types/block/mana/mod.rs @@ -22,6 +22,7 @@ pub(crate) type ManaAllotmentCount = /// A list of [`ManaAllotment`]s with unique [`AccountId`]s. #[derive(Clone, Debug, Eq, PartialEq, Deref, Packable)] +#[packable(unpack_visitor = ProtocolParameters)] #[packable(unpack_error = Error, with = |e| e.unwrap_item_err_or_else(|p| Error::InvalidManaAllotmentCount(p.into())))] pub struct ManaAllotments( #[packable(verify_with = verify_mana_allotments)] BoxedSlicePrefix<ManaAllotment, ManaAllotmentCount>, From b7e36353704f8633956764c1e0bf134e51006824 Mon Sep 17 00:00:00 2001 From: Thibault Martinez <thibault@iota.org> Date: Fri, 17 Nov 2023 17:39:30 +0100 Subject: [PATCH 3/3] Use released version --- Cargo.lock | 6 ++++-- bindings/core/Cargo.toml | 2 +- sdk/Cargo.toml | 2 +- sdk/src/types/fuzz/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 147e655ef9..cd4cd518d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2178,7 +2178,8 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "packable" version = "0.10.0" -source = "git+https://github.com/thibault-martinez/common-rs?branch=conditional-visitor-param#2249da658d180e63e16855a2dcc0aa55c7c26a92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe35ea7a5959be5a87d24bcb31ed984580d9cd321c264c266818fff8cd47b3d" dependencies = [ "autocfg", "packable-derive", @@ -2189,7 +2190,8 @@ dependencies = [ [[package]] name = "packable-derive" version = "0.9.0" -source = "git+https://github.com/thibault-martinez/common-rs?branch=conditional-visitor-param#2249da658d180e63e16855a2dcc0aa55c7c26a92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "858971e010057f7bcae183e545085b83d41280ca8abe0333613a7135fbb54430" dependencies = [ "proc-macro-crate", "proc-macro-error", diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index 0a2db46115..324ea5f9f0 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -23,7 +23,7 @@ iota-crypto = { version = "0.23.0", default-features = false, features = [ "bip44", ] } log = { version = "0.4.20", default-features = false } -packable = { version = "0.10.0", git = "https://github.com/thibault-martinez/common-rs", branch = "conditional-visitor-param", default-features = false } +packable = { version = "0.10.0", default-features = false } prefix-hex = { version = "0.7.1", default-features = false } primitive-types = { version = "0.12.2", default-features = false } serde = { version = "1.0.188", default-features = false } diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 4e2f5bd17c..bc619c340d 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -45,7 +45,7 @@ iota-crypto = { version = "0.23.0", default-features = false, features = [ "secp256k1", ] } iterator-sorted = { version = "0.1.0", default-features = false } -packable = { version = "0.10.0", git = "https://github.com/thibault-martinez/common-rs", branch = "conditional-visitor-param", default-features = false, features = [ +packable = { version = "0.10.0", default-features = false, features = [ "primitive-types", ] } paste = { version = "1.0.14", default-features = false } diff --git a/sdk/src/types/fuzz/Cargo.toml b/sdk/src/types/fuzz/Cargo.toml index 03055e3b88..be3e427c35 100644 --- a/sdk/src/types/fuzz/Cargo.toml +++ b/sdk/src/types/fuzz/Cargo.toml @@ -12,7 +12,7 @@ cargo-fuzz = true iota-types = { path = "..", default-features = false } libfuzzer-sys = { version = "0.4.7", default-features = false } -packable = { version = "0.10.0", git = "https://github.com/thibault-martinez/common-rs", branch = "conditional-visitor-param", default-features = false } +packable = { version = "0.10.0", default-features = false } # Prevent this from interfering with workspaces [workspace]