diff --git a/Cargo.lock b/Cargo.lock index 4151d6b2a2..5ad22abad6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7d5a2cecb58716e47d67d5703a249964b14c7be1ec3cad3affc295b2d1c35d" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", @@ -159,7 +159,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -274,7 +274,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -382,11 +382,10 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.83" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856" dependencies = [ - "jobserver", "libc", ] @@ -457,14 +456,14 @@ checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", - "libloading", + "libloading 0.7.4", ] [[package]] name = "clap" -version = "4.4.6" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", @@ -472,9 +471,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", @@ -484,21 +483,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "cli-wallet" @@ -619,9 +618,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -643,9 +642,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "28f85c3514d2a6e64160359b45a3918c3b4178bcbf4ae5d03ab2d02e521c479a" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -670,7 +669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" dependencies = [ "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -714,13 +713,13 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -744,7 +743,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -755,7 +754,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -816,7 +815,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -1022,9 +1021,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -1086,9 +1085,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "f69037fe1b785e84986b4f2cbcf647381876a00671d25ceef715d7812dd7e1dd" [[package]] name = "field-offset" @@ -1120,7 +1119,7 @@ checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ "futures-core", "futures-sink", - "spin 0.9.8", + "spin", ] [[package]] @@ -1146,9 +1145,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -1161,9 +1160,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -1171,15 +1170,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -1189,38 +1188,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -1247,9 +1246,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -1438,9 +1437,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -1496,9 +1495,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -1565,9 +1564,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.2", @@ -1786,20 +1785,11 @@ 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.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -1869,9 +1859,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.149" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libloading" @@ -1883,6 +1873,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "libloading" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] + [[package]] name = "librocksdb-sys" version = "0.11.0+8.1.1" @@ -1923,9 +1934,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lock_api" @@ -2014,9 +2025,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.13.3" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd063c93b900149304e3ba96ce5bf210cd4f81ef5eb80ded0d100df3e85a3ac0" +checksum = "f9d90182620f32fe34b6ac9b52cba898af26e94c7f5abc01eb4094c417ae2e6c" dependencies = [ "bitflags 2.4.1", "ctor", @@ -2028,15 +2039,15 @@ dependencies = [ [[package]] name = "napi-build" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882a73d9ef23e8dc2ebbffb6a6ae2ef467c0f18ac10711e4cc59c5485d41df0e" +checksum = "d4b4532cf86bfef556348ac65e561e3123879f0e7566cca6d43a6ff5326f13df" [[package]] name = "napi-derive" -version = "2.13.0" +version = "2.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da1c6a8fa84d549aa8708fcd062372bf8ec6e849de39016ab921067d21bde367" +checksum = "3619fa472d23cd5af94d63a2bae454a77a8863251f40230fbf59ce20eafa8a86" dependencies = [ "cfg-if", "convert_case", @@ -2048,9 +2059,9 @@ dependencies = [ [[package]] name = "napi-derive-backend" -version = "1.0.52" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20bbc7c69168d06a848f925ec5f0e0997f98e8c8d4f2cc30157f0da51c009e17" +checksum = "ecd3ea4b54020c73d591a49cd192f6334c5f37f71a63ead54dbc851fa991ef00" dependencies = [ "convert_case", "proc-macro2", @@ -2060,11 +2071,11 @@ dependencies = [ [[package]] name = "napi-sys" -version = "2.2.3" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "166b5ef52a3ab5575047a9fe8d4a030cdd0f63c96f071cd6907674453b07bae3" +checksum = "2503fa6af34dc83fb74888df8b22afe933b58d37daf7d80424b1c60c68196b8b" dependencies = [ - "libloading", + "libloading 0.8.1", ] [[package]] @@ -2172,9 +2183,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "packable" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11259b086696fc9256f790485d8f14f11f0fa60a60351af9693e3d49fd24fdb6" +checksum = "eee4180de5473e336f075507fea07003183e059bc0d35398b0b0039419747e76" dependencies = [ "autocfg", "packable-derive", @@ -2184,9 +2195,9 @@ dependencies = [ [[package]] name = "packable-derive" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9567693dd2f9a4339cb0a54adfcc0cb431c0ac88b2e46c6ddfb5f5d11a1cc4f" +checksum = "26a5ee3cb4c60754a0b49a3b7a6f5067a191ff5ec9d90414f6c4cfd21ce9acff" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -2298,9 +2309,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" -version = "3.1.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" [[package]] name = "poly1305" @@ -2365,7 +2376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2486,21 +2497,21 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall", + "libredox", "thiserror", ] @@ -2583,21 +2594,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.5" @@ -2607,8 +2603,8 @@ dependencies = [ "cc", "getrandom", "libc", - "spin 0.9.8", - "untrusted 0.9.0", + "spin", + "untrusted", "windows-sys 0.48.0", ] @@ -2684,9 +2680,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.20" +version = "0.38.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +checksum = "80109a168d9bc0c7f483083244543a6eb0dba02295d33ca268145e6190d6df0c" dependencies = [ "bitflags 2.4.1", "errno", @@ -2702,7 +2698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring 0.17.5", + "ring", "rustls-webpki", "sct", ] @@ -2721,9 +2717,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ "base64 0.21.5", ] @@ -2734,8 +2730,8 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.5", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -2770,7 +2766,7 @@ checksum = "5a32af5427251d2e4be14fc151eabe18abb4a7aad5efee7044da9f096c906a43" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2825,12 +2821,12 @@ dependencies = [ [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring", + "untrusted", ] [[package]] @@ -2879,29 +2875,29 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2910,13 +2906,13 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2996,9 +2992,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "snafu" @@ -3042,12 +3038,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -3162,9 +3152,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -3215,7 +3205,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3284,9 +3274,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -3301,13 +3291,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3322,9 +3312,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -3346,7 +3336,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", "toml_datetime", "winnow", ] @@ -3376,7 +3366,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3486,12 +3476,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -3561,9 +3545,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3571,24 +3555,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", @@ -3598,9 +3582,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3608,28 +3592,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -3867,9 +3851,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.17" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" dependencies = [ "memchr", ] @@ -3932,22 +3916,22 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.11" +version = "0.7.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.11" +version = "0.7.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3968,5 +3952,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index 761e579065..aaff827018 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -23,20 +23,20 @@ iota-crypto = { version = "0.23.0", default-features = false, features = [ "bip44", ] } log = { version = "0.4.20", default-features = false } -packable = { version = "0.8.3", default-features = false } +packable = { version = "0.9.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 } serde_json = { version = "1.0.107", default-features = false } thiserror = { version = "1.0.49", default-features = false } tokio = { version = "1.33.0", default-features = false } -url = { version = "2.4.1", default-features = false, features = [ - "serde", -] } +url = { version = "2.4.1", default-features = false, features = ["serde"] } zeroize = { version = "1.6.0", default-features = false } [dev-dependencies] -pretty_assertions = { version = "1.4.0", default-features = false, features = [ "alloc" ] } +pretty_assertions = { version = "1.4.0", default-features = false, features = [ + "alloc", +] } [features] events = ["iota-sdk/events"] diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 0a7e81eb33..b5471cd7a4 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.8.3", default-features = false, features = [ +packable = { version = "0.9.0", 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 e66da44416..b4f59e2284 100644 --- a/sdk/src/types/block/address/multi.rs +++ b/sdk/src/types/block/address/multi.rs @@ -6,14 +6,7 @@ use core::{fmt, ops::RangeInclusive}; use derive_more::{AsRef, Deref, Display, From}; use iterator_sorted::is_unique_sorted; -use packable::{ - bounded::BoundedU8, - error::{UnpackError, UnpackErrorExt}, - packer::Packer, - prefix::BoxedSlicePrefix, - unpacker::Unpacker, - Packable, -}; +use packable::{bounded::BoundedU8, prefix::BoxedSlicePrefix, Packable}; use crate::types::block::{address::Address, output::StorageScore, Error}; @@ -77,12 +70,17 @@ fn verify_weight(weight: &u8, _visitor: &()) -> Result<(), E /// An address that consists of addresses with weights and a threshold value. /// The Multi Address can be unlocked if the cumulative weight of all unlocked addresses is equal to or exceeds the /// threshold. -#[derive(Clone, Debug, Deref, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Clone, Debug, Deref, Eq, PartialEq, Ord, PartialOrd, Hash, Packable)] +#[packable(unpack_error = Error)] +#[packable(verify_with = verify_multi_address)] pub struct MultiAddress { /// The weighted unlocked addresses. #[deref] + #[packable(verify_with = verify_addresses)] + #[packable(unpack_error_with = |e| e.unwrap_item_err_or_else(|p| Error::InvalidWeightedAddressCount(p.into())))] addresses: BoxedSlicePrefix, /// The threshold that needs to be reached by the unlocked addresses in order to unlock the multi address. + #[packable(verify_with = verify_threshold)] threshold: u16, } @@ -103,9 +101,11 @@ impl MultiAddress { let addresses = BoxedSlicePrefix::::try_from(addresses) .map_err(Error::InvalidWeightedAddressCount)?; - verify_cumulative_weight::(&addresses, &threshold, &())?; + let multi_address = Self { addresses, threshold }; - Ok(Self { addresses, threshold }) + verify_multi_address::(&multi_address, &())?; + + Ok(multi_address) } /// Returns the addresses of a [`MultiAddress`]. @@ -121,38 +121,6 @@ impl MultiAddress { } } -impl Packable for MultiAddress { - type UnpackError = Error; - type UnpackVisitor = (); - - #[inline] - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - self.addresses.pack(packer)?; - self.threshold.pack(packer)?; - - Ok(()) - } - - #[inline] - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - let addresses = - BoxedSlicePrefix::::unpack::<_, VERIFY>(unpacker, visitor) - .map_packable_err(|e| e.unwrap_item_err_or_else(|e| Error::InvalidWeightedAddressCount(e.into())))?; - - verify_addresses::(&addresses, &()).map_err(UnpackError::Packable)?; - - let threshold = u16::unpack::<_, VERIFY>(unpacker, visitor).coerce()?; - - verify_threshold::(&threshold, &()).map_err(UnpackError::Packable)?; - verify_cumulative_weight::(&addresses, &threshold, &()).map_err(UnpackError::Packable)?; - - Ok(Self { addresses, threshold }) - } -} - fn verify_addresses(addresses: &[WeightedAddress], _visitor: &()) -> Result<(), Error> { if VERIFY && !is_unique_sorted(addresses.iter().map(WeightedAddress::address)) { return Err(Error::WeightedAddressesNotUniqueSorted); @@ -169,18 +137,14 @@ fn verify_threshold(threshold: &u16, _visitor: &()) -> Resul } } -fn verify_cumulative_weight( - addresses: &[WeightedAddress], - threshold: &u16, - _visitor: &(), -) -> Result<(), Error> { +fn verify_multi_address(address: &MultiAddress, _visitor: &()) -> Result<(), Error> { if VERIFY { - let cumulative_weight = addresses.iter().map(|address| address.weight as u16).sum::(); + let cumulative_weight = address.iter().map(|address| address.weight as u16).sum::(); - if cumulative_weight < *threshold { + if cumulative_weight < address.threshold { return Err(Error::InvalidMultiAddressCumulativeWeight { cumulative_weight, - threshold: *threshold, + threshold: address.threshold, }); } } diff --git a/sdk/src/types/block/core/basic.rs b/sdk/src/types/block/core/basic.rs index 5535c70075..1ce750986e 100644 --- a/sdk/src/types/block/core/basic.rs +++ b/sdk/src/types/block/core/basic.rs @@ -1,12 +1,7 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use packable::{ - error::{UnpackError, UnpackErrorExt}, - packer::Packer, - unpacker::Unpacker, - Packable, -}; +use packable::Packable; use crate::types::block::{ core::{parent::verify_parents_sets, Block, Parents}, @@ -107,7 +102,10 @@ impl From for BasicBlockBuilder { } } -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Packable)] +#[packable(unpack_error = Error)] +#[packable(unpack_visitor = ProtocolParameters)] +#[packable(verify_with = verify_basic_block)] pub struct BasicBlock { /// Blocks that are strongly directly approved. strong_parents: StrongParents, @@ -156,45 +154,16 @@ impl BasicBlock { } } -impl Packable for BasicBlock { - type UnpackError = Error; - type UnpackVisitor = ProtocolParameters; - - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - self.strong_parents.pack(packer)?; - self.weak_parents.pack(packer)?; - self.shallow_like_parents.pack(packer)?; - self.payload.pack(packer)?; - self.max_burned_mana.pack(packer)?; - - Ok(()) +fn verify_basic_block(basic_block: &BasicBlock, _: &ProtocolParameters) -> Result<(), Error> { + if VERIFY { + verify_parents_sets( + &basic_block.strong_parents, + &basic_block.weak_parents, + &basic_block.shallow_like_parents, + )?; } - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - let strong_parents = StrongParents::unpack::<_, VERIFY>(unpacker, &())?; - let weak_parents = WeakParents::unpack::<_, VERIFY>(unpacker, &())?; - let shallow_like_parents = ShallowLikeParents::unpack::<_, VERIFY>(unpacker, &())?; - - if VERIFY { - verify_parents_sets(&strong_parents, &weak_parents, &shallow_like_parents) - .map_err(UnpackError::Packable)?; - } - - let payload = OptionalPayload::unpack::<_, VERIFY>(unpacker, visitor)?; - - let max_burned_mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - - Ok(Self { - strong_parents, - weak_parents, - shallow_like_parents, - payload, - max_burned_mana, - }) - } + Ok(()) } #[cfg(feature = "serde")] diff --git a/sdk/src/types/block/core/mod.rs b/sdk/src/types/block/core/mod.rs index a6f8b6cd9d..c873d35dff 100644 --- a/sdk/src/types/block/core/mod.rs +++ b/sdk/src/types/block/core/mod.rs @@ -10,12 +10,7 @@ use alloc::boxed::Box; use crypto::hashes::{blake2b::Blake2b256, Digest}; use derive_more::From; -use packable::{ - error::{UnpackError, UnpackErrorExt}, - packer::Packer, - unpacker::Unpacker, - Packable, PackableExt, -}; +use packable::{Packable, PackableExt}; pub use self::{ basic::{BasicBlock, BasicBlockBuilder}, @@ -28,9 +23,14 @@ use crate::types::block::{ Error, }; -#[derive(Clone, Debug, Eq, PartialEq, From)] +#[derive(Clone, Debug, Eq, PartialEq, From, Packable)] +#[packable(unpack_error = Error)] +#[packable(unpack_visitor = ProtocolParameters)] +#[packable(tag_type = u8, with_error = Error::InvalidBlockKind)] pub enum Block { + #[packable(tag = BasicBlock::KIND)] Basic(Box), + #[packable(tag = ValidationBlock::KIND)] Validation(Box), } @@ -102,37 +102,6 @@ impl Block { } } -impl Packable for Block { - type UnpackError = Error; - type UnpackVisitor = ProtocolParameters; - - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - match self { - Self::Basic(block) => { - BasicBlock::KIND.pack(packer)?; - block.pack(packer) - } - Self::Validation(block) => { - ValidationBlock::KIND.pack(packer)?; - block.pack(packer) - } - }?; - - Ok(()) - } - - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - Ok(match u8::unpack::<_, VERIFY>(unpacker, &()).coerce()? { - BasicBlock::KIND => Self::from(BasicBlock::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - ValidationBlock::KIND => Self::from(ValidationBlock::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - k => return Err(UnpackError::Packable(Error::InvalidBlockKind(k))), - }) - } -} - #[cfg(feature = "serde")] pub(crate) mod dto { use alloc::format; diff --git a/sdk/src/types/block/core/validation.rs b/sdk/src/types/block/core/validation.rs index f93970c41b..3e37275bc7 100644 --- a/sdk/src/types/block/core/validation.rs +++ b/sdk/src/types/block/core/validation.rs @@ -1,12 +1,7 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use packable::{ - error::{UnpackError, UnpackErrorExt}, - packer::Packer, - unpacker::Unpacker, - Packable, -}; +use packable::Packable; use crate::types::block::{ core::{parent::verify_parents_sets, Block, Parents}, @@ -113,7 +108,10 @@ impl From for ValidationBlockBuilder { /// A Validation Block is a special type of block used by validators to secure the network. It is recognized by the /// Congestion Control of the IOTA 2.0 protocol and can be issued without burning Mana within the constraints of the /// allowed validator throughput. It is allowed to reference more parent blocks than a normal Basic Block. -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Packable)] +#[packable(unpack_error = Error)] +#[packable(unpack_visitor = ProtocolParameters)] +#[packable(verify_with = verify_validation_block)] pub struct ValidationBlock { /// Blocks that are strongly directly approved. strong_parents: StrongParents, @@ -124,6 +122,7 @@ pub struct ValidationBlock { /// The highest supported protocol version the issuer of this block supports. highest_supported_version: u8, /// The hash of the protocol parameters for the Highest Supported Version. + #[packable(verify_with = verify_protocol_parameters_hash)] protocol_parameters_hash: ProtocolParametersHash, } @@ -161,59 +160,34 @@ impl ValidationBlock { } } -impl Packable for ValidationBlock { - type UnpackError = Error; - type UnpackVisitor = ProtocolParameters; - - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - self.strong_parents.pack(packer)?; - self.weak_parents.pack(packer)?; - self.shallow_like_parents.pack(packer)?; - self.highest_supported_version.pack(packer)?; - self.protocol_parameters_hash.pack(packer)?; - - Ok(()) - } - - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - let strong_parents = StrongParents::unpack::<_, VERIFY>(unpacker, &())?; - let weak_parents = WeakParents::unpack::<_, VERIFY>(unpacker, &())?; - let shallow_like_parents = ShallowLikeParents::unpack::<_, VERIFY>(unpacker, &())?; - - if VERIFY { - verify_parents_sets(&strong_parents, &weak_parents, &shallow_like_parents) - .map_err(UnpackError::Packable)?; - } - - let highest_supported_version = u8::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - - let protocol_parameters_hash = ProtocolParametersHash::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - - if VERIFY { - validate_protocol_params_hash(&protocol_parameters_hash, visitor).map_err(UnpackError::Packable)?; +fn verify_protocol_parameters_hash( + hash: &ProtocolParametersHash, + params: &ProtocolParameters, +) -> Result<(), Error> { + if VERIFY { + let params_hash = params.hash(); + + if hash != ¶ms_hash { + return Err(Error::InvalidProtocolParametersHash { + expected: params_hash, + actual: *hash, + }); } - - Ok(Self { - strong_parents, - weak_parents, - shallow_like_parents, - highest_supported_version, - protocol_parameters_hash, - }) } -} -fn validate_protocol_params_hash(hash: &ProtocolParametersHash, params: &ProtocolParameters) -> Result<(), Error> { - let params_hash = params.hash(); + Ok(()) +} - if hash != ¶ms_hash { - return Err(Error::InvalidProtocolParametersHash { - expected: params_hash, - actual: *hash, - }); +fn verify_validation_block( + validation_block: &ValidationBlock, + _: &ProtocolParameters, +) -> Result<(), Error> { + if VERIFY { + verify_parents_sets( + &validation_block.strong_parents, + &validation_block.weak_parents, + &validation_block.shallow_like_parents, + )?; } Ok(()) @@ -262,7 +236,7 @@ pub(crate) mod dto { fn try_from_dto_with_params_inner(dto: Self::Dto, params: ValidationParams<'_>) -> Result { if let Some(protocol_params) = params.protocol_parameters() { - validate_protocol_params_hash(&dto.protocol_parameters_hash, protocol_params)?; + verify_protocol_parameters_hash::(&dto.protocol_parameters_hash, protocol_params)?; } ValidationBlockBuilder::new( diff --git a/sdk/src/types/block/mana/allotment.rs b/sdk/src/types/block/mana/allotment.rs index 16ad2ff509..fbb319f4d2 100644 --- a/sdk/src/types/block/mana/allotment.rs +++ b/sdk/src/types/block/mana/allotment.rs @@ -1,20 +1,18 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use packable::{ - error::{UnpackError, UnpackErrorExt}, - packer::Packer, - unpacker::Unpacker, - Packable, -}; +use packable::Packable; use crate::types::block::{output::AccountId, protocol::ProtocolParameters, Error}; /// An allotment of Mana which will be added upon commitment of the slot in which the containing transaction was issued, /// in the form of Block Issuance Credits to the account. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Packable)] +#[packable(unpack_error = Error)] +#[packable(unpack_visitor = ProtocolParameters)] pub struct ManaAllotment { pub(crate) account_id: AccountId, + #[packable(verify_with = verify_mana)] pub(crate) mana: u64, } @@ -32,9 +30,8 @@ impl Ord for ManaAllotment { impl ManaAllotment { pub fn new(account_id: AccountId, mana: u64, protocol_params: &ProtocolParameters) -> Result { - if mana > protocol_params.mana_parameters().max_mana() { - return Err(Error::InvalidManaValue(mana)); - } + verify_mana::(&mana, protocol_params)?; + Ok(Self { account_id, mana }) } @@ -47,26 +44,12 @@ impl ManaAllotment { } } -impl Packable for ManaAllotment { - type UnpackError = Error; - type UnpackVisitor = ProtocolParameters; - - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - self.account_id.pack(packer)?; - self.mana.pack(packer)?; - - Ok(()) +fn verify_mana(mana: &u64, params: &ProtocolParameters) -> Result<(), Error> { + if VERIFY && *mana > params.mana_parameters().max_mana() { + return Err(Error::InvalidManaValue(*mana)); } - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - let account_id = AccountId::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - - Self::new(account_id, mana, visitor).map_err(UnpackError::Packable) - } + Ok(()) } #[cfg(feature = "serde")] diff --git a/sdk/src/types/block/output/mod.rs b/sdk/src/types/block/output/mod.rs index dd4de9391a..0bdc494244 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -27,12 +27,7 @@ pub mod unlock_condition; use core::ops::RangeInclusive; use derive_more::From; -use packable::{ - error::{UnpackError, UnpackErrorExt}, - packer::Packer, - unpacker::Unpacker, - Packable, -}; +use packable::Packable; pub use self::{ account::{AccountId, AccountOutput, AccountOutputBuilder}, @@ -111,19 +106,28 @@ impl OutputWithMetadata { } /// A generic output that can represent different types defining the deposit of funds. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, From)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, From, Packable)] +#[packable(unpack_error = Error)] +#[packable(unpack_visitor = ProtocolParameters)] +#[packable(tag_type = u8, with_error = Error::InvalidOutputKind)] pub enum Output { /// A basic output. + #[packable(tag = BasicOutput::KIND)] Basic(BasicOutput), /// An account output. + #[packable(tag = AccountOutput::KIND)] Account(AccountOutput), /// An anchor output. + #[packable(tag = AnchorOutput::KIND)] Anchor(AnchorOutput), /// A foundry output. + #[packable(tag = FoundryOutput::KIND)] Foundry(FoundryOutput), /// An NFT output. + #[packable(tag = NftOutput::KIND)] Nft(NftOutput), /// A delegation output. + #[packable(tag = DelegationOutput::KIND)] Delegation(DelegationOutput), } @@ -382,57 +386,6 @@ impl Output { } } -impl Packable for Output { - type UnpackError = Error; - type UnpackVisitor = ProtocolParameters; - - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - match self { - Self::Basic(output) => { - BasicOutput::KIND.pack(packer)?; - output.pack(packer) - } - Self::Account(output) => { - AccountOutput::KIND.pack(packer)?; - output.pack(packer) - } - Self::Anchor(output) => { - AnchorOutput::KIND.pack(packer)?; - output.pack(packer) - } - Self::Foundry(output) => { - FoundryOutput::KIND.pack(packer)?; - output.pack(packer) - } - Self::Nft(output) => { - NftOutput::KIND.pack(packer)?; - output.pack(packer) - } - Self::Delegation(output) => { - DelegationOutput::KIND.pack(packer)?; - output.pack(packer) - } - }?; - - Ok(()) - } - - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - Ok(match u8::unpack::<_, VERIFY>(unpacker, &()).coerce()? { - BasicOutput::KIND => Self::from(BasicOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - AccountOutput::KIND => Self::from(AccountOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - AnchorOutput::KIND => Self::from(AnchorOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - FoundryOutput::KIND => Self::from(FoundryOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - NftOutput::KIND => Self::from(NftOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - DelegationOutput::KIND => Self::from(DelegationOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - k => return Err(UnpackError::Packable(Error::InvalidOutputKind(k))), - }) - } -} - impl StorageScore for Output { fn storage_score(&self, params: StorageScoreParameters) -> u64 { match self { diff --git a/sdk/src/types/block/output/token_scheme/simple.rs b/sdk/src/types/block/output/token_scheme/simple.rs index 229ba6b905..b675bcbc69 100644 --- a/sdk/src/types/block/output/token_scheme/simple.rs +++ b/sdk/src/types/block/output/token_scheme/simple.rs @@ -1,18 +1,15 @@ // Copyright 2022 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use packable::{ - error::{UnpackError, UnpackErrorExt}, - packer::Packer, - unpacker::Unpacker, - Packable, -}; +use packable::Packable; use primitive_types::U256; use crate::types::block::Error; /// -#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Packable)] +#[packable(unpack_error = Error)] +#[packable(verify_with = verify_simple_token_scheme)] pub struct SimpleTokenScheme { // Amount of tokens minted by a foundry. minted_tokens: U256, @@ -37,13 +34,15 @@ impl SimpleTokenScheme { let melted_tokens = melted_tokens.into(); let maximum_supply = maximum_supply.into(); - verify_supply(&minted_tokens, &melted_tokens, &maximum_supply)?; - - Ok(Self { + let token_scheme = Self { minted_tokens, melted_tokens, maximum_supply, - }) + }; + + verify_simple_token_scheme::(&token_scheme, &())?; + + Ok(token_scheme) } /// Returns the number of minted tokens of the [`SimpleTokenScheme`]. @@ -71,45 +70,20 @@ impl SimpleTokenScheme { } } -impl Packable for SimpleTokenScheme { - type UnpackError = Error; - type UnpackVisitor = (); - - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - self.minted_tokens.pack(packer)?; - self.melted_tokens.pack(packer)?; - self.maximum_supply.pack(packer)?; - - Ok(()) - } - - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - let minted_tokens = U256::unpack::<_, VERIFY>(unpacker, visitor).coerce()?; - let melted_tokens = U256::unpack::<_, VERIFY>(unpacker, visitor).coerce()?; - let maximum_supply = U256::unpack::<_, VERIFY>(unpacker, visitor).coerce()?; - - if VERIFY { - verify_supply(&minted_tokens, &melted_tokens, &maximum_supply).map_err(UnpackError::Packable)?; - } - - Ok(Self { - minted_tokens, - melted_tokens, - maximum_supply, - }) - } -} - #[inline] -fn verify_supply(minted_tokens: &U256, melted_tokens: &U256, maximum_supply: &U256) -> Result<(), Error> { - if maximum_supply.is_zero() || melted_tokens > minted_tokens || minted_tokens - melted_tokens > *maximum_supply { +fn verify_simple_token_scheme( + token_scheme: &SimpleTokenScheme, + _visitor: &(), +) -> Result<(), Error> { + if VERIFY + && (token_scheme.maximum_supply.is_zero() + || token_scheme.melted_tokens > token_scheme.minted_tokens + || token_scheme.minted_tokens - token_scheme.melted_tokens > token_scheme.maximum_supply) + { return Err(Error::InvalidFoundryOutputSupply { - minted: *minted_tokens, - melted: *melted_tokens, - max: *maximum_supply, + minted: token_scheme.minted_tokens, + melted: token_scheme.melted_tokens, + max: token_scheme.maximum_supply, }); } diff --git a/sdk/src/types/block/output/unlock_condition/mod.rs b/sdk/src/types/block/output/unlock_condition/mod.rs index ec53550580..0c3e2d3d70 100644 --- a/sdk/src/types/block/output/unlock_condition/mod.rs +++ b/sdk/src/types/block/output/unlock_condition/mod.rs @@ -14,14 +14,7 @@ use alloc::{boxed::Box, collections::BTreeSet, vec::Vec}; use bitflags::bitflags; use derive_more::{Deref, From}; use iterator_sorted::is_unique_sorted; -use packable::{ - bounded::BoundedU8, - error::{UnpackError, UnpackErrorExt}, - packer::Packer, - prefix::BoxedSlicePrefix, - unpacker::Unpacker, - Packable, -}; +use packable::{bounded::BoundedU8, prefix::BoxedSlicePrefix, Packable}; pub use self::{ address::AddressUnlockCondition, expiration::ExpirationUnlockCondition, @@ -39,21 +32,31 @@ use crate::types::block::{ }; /// -#[derive(Clone, Eq, PartialEq, Hash, From)] +#[derive(Clone, Eq, PartialEq, Hash, From, Packable)] +#[packable(unpack_error = Error)] +#[packable(unpack_visitor = ProtocolParameters)] +#[packable(tag_type = u8, with_error = Error::InvalidUnlockConditionKind)] pub enum UnlockCondition { /// An address unlock condition. + #[packable(tag = AddressUnlockCondition::KIND)] Address(AddressUnlockCondition), /// A storage deposit return unlock condition. + #[packable(tag = StorageDepositReturnUnlockCondition::KIND)] StorageDepositReturn(StorageDepositReturnUnlockCondition), /// A timelock unlock condition. + #[packable(tag = TimelockUnlockCondition::KIND)] Timelock(TimelockUnlockCondition), /// An expiration unlock condition. + #[packable(tag = ExpirationUnlockCondition::KIND)] Expiration(ExpirationUnlockCondition), /// A state controller address unlock condition. + #[packable(tag = StateControllerAddressUnlockCondition::KIND)] StateControllerAddress(StateControllerAddressUnlockCondition), /// A governor address unlock condition. + #[packable(tag = GovernorAddressUnlockCondition::KIND)] GovernorAddress(GovernorAddressUnlockCondition), /// An immutable account address unlock condition. + #[packable(tag = ImmutableAccountAddressUnlockCondition::KIND)] ImmutableAccountAddress(ImmutableAccountAddressUnlockCondition), } @@ -149,76 +152,6 @@ crate::create_bitflags!( ] ); -impl Packable for UnlockCondition { - type UnpackError = Error; - type UnpackVisitor = ProtocolParameters; - - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - match self { - Self::Address(unlock_condition) => { - AddressUnlockCondition::KIND.pack(packer)?; - unlock_condition.pack(packer) - } - Self::StorageDepositReturn(unlock_condition) => { - StorageDepositReturnUnlockCondition::KIND.pack(packer)?; - unlock_condition.pack(packer) - } - Self::Timelock(unlock_condition) => { - TimelockUnlockCondition::KIND.pack(packer)?; - unlock_condition.pack(packer) - } - Self::Expiration(unlock_condition) => { - ExpirationUnlockCondition::KIND.pack(packer)?; - unlock_condition.pack(packer) - } - Self::StateControllerAddress(unlock_condition) => { - StateControllerAddressUnlockCondition::KIND.pack(packer)?; - unlock_condition.pack(packer) - } - Self::GovernorAddress(unlock_condition) => { - GovernorAddressUnlockCondition::KIND.pack(packer)?; - unlock_condition.pack(packer) - } - Self::ImmutableAccountAddress(unlock_condition) => { - ImmutableAccountAddressUnlockCondition::KIND.pack(packer)?; - unlock_condition.pack(packer) - } - }?; - - Ok(()) - } - - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - Ok(match u8::unpack::<_, VERIFY>(unpacker, &()).coerce()? { - AddressUnlockCondition::KIND => { - Self::from(AddressUnlockCondition::unpack::<_, VERIFY>(unpacker, &()).coerce()?) - } - StorageDepositReturnUnlockCondition::KIND => { - Self::from(StorageDepositReturnUnlockCondition::unpack::<_, VERIFY>(unpacker, visitor).coerce()?) - } - TimelockUnlockCondition::KIND => { - Self::from(TimelockUnlockCondition::unpack::<_, VERIFY>(unpacker, &()).coerce()?) - } - ExpirationUnlockCondition::KIND => { - Self::from(ExpirationUnlockCondition::unpack::<_, VERIFY>(unpacker, &()).coerce()?) - } - StateControllerAddressUnlockCondition::KIND => { - Self::from(StateControllerAddressUnlockCondition::unpack::<_, VERIFY>(unpacker, &()).coerce()?) - } - GovernorAddressUnlockCondition::KIND => { - Self::from(GovernorAddressUnlockCondition::unpack::<_, VERIFY>(unpacker, &()).coerce()?) - } - ImmutableAccountAddressUnlockCondition::KIND => { - Self::from(ImmutableAccountAddressUnlockCondition::unpack::<_, VERIFY>(unpacker, &()).coerce()?) - } - k => return Err(UnpackError::Packable(Error::InvalidOutputKind(k))), - }) - } -} - pub(crate) type UnlockConditionCount = BoundedU8<0, { UnlockConditions::COUNT_MAX }>; /// diff --git a/sdk/src/types/block/payload/candidacy_announcement.rs b/sdk/src/types/block/payload/candidacy_announcement.rs index 0934e05cdd..b21916515b 100644 --- a/sdk/src/types/block/payload/candidacy_announcement.rs +++ b/sdk/src/types/block/payload/candidacy_announcement.rs @@ -1,8 +1,10 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +use packable::Packable; + /// A payload which is used to indicate candidacy for committee selection for the next epoch. -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Packable)] pub struct CandidacyAnnouncementPayload; impl CandidacyAnnouncementPayload { diff --git a/sdk/src/types/block/payload/mod.rs b/sdk/src/types/block/payload/mod.rs index 8a86eb63e4..c88fcad25f 100644 --- a/sdk/src/types/block/payload/mod.rs +++ b/sdk/src/types/block/payload/mod.rs @@ -29,13 +29,19 @@ pub(crate) use self::{ use crate::types::block::{protocol::ProtocolParameters, Error}; /// A generic payload that can represent different types defining block payloads. -#[derive(Clone, Eq, PartialEq, From)] +#[derive(Clone, Eq, PartialEq, From, Packable)] +#[packable(unpack_error = Error)] +#[packable(unpack_visitor = ProtocolParameters)] +#[packable(tag_type = u8, with_error = Error::InvalidPayloadKind)] pub enum Payload { /// A tagged data payload. + #[packable(tag = TaggedDataPayload::KIND)] TaggedData(Box), /// A signed transaction payload. + #[packable(tag = SignedTransactionPayload::KIND)] SignedTransaction(Box), /// A candidacy announcement payload. + #[packable(tag = CandidacyAnnouncementPayload::KIND)] CandidacyAnnouncement(CandidacyAnnouncementPayload), } @@ -74,41 +80,6 @@ impl Payload { crate::def_is_as_opt!(Payload: SignedTransaction, TaggedData); } -impl Packable for Payload { - type UnpackError = Error; - type UnpackVisitor = ProtocolParameters; - - fn pack(&self, packer: &mut P) -> Result<(), P::Error> { - match self { - Self::TaggedData(tagged_data) => { - TaggedDataPayload::KIND.pack(packer)?; - tagged_data.pack(packer) - } - Self::SignedTransaction(transaction) => { - SignedTransactionPayload::KIND.pack(packer)?; - transaction.pack(packer) - } - Self::CandidacyAnnouncement(_) => CandidacyAnnouncementPayload::KIND.pack(packer), - }?; - - Ok(()) - } - - fn unpack( - unpacker: &mut U, - visitor: &Self::UnpackVisitor, - ) -> Result> { - Ok(match u8::unpack::<_, VERIFY>(unpacker, &()).coerce()? { - TaggedDataPayload::KIND => Self::from(TaggedDataPayload::unpack::<_, VERIFY>(unpacker, &()).coerce()?), - SignedTransactionPayload::KIND => { - Self::from(SignedTransactionPayload::unpack::<_, VERIFY>(unpacker, visitor).coerce()?) - } - CandidacyAnnouncementPayload::KIND => Self::from(CandidacyAnnouncementPayload), - k => return Err(UnpackError::Packable(Error::InvalidPayloadKind(k))), - }) - } -} - /// Representation of an optional [`Payload`]. /// Essentially an `Option` with a different [`Packable`] implementation, to conform to specs. #[derive(Clone, Debug, Default, Eq, PartialEq)] diff --git a/sdk/src/types/fuzz/Cargo.toml b/sdk/src/types/fuzz/Cargo.toml index 44190bc39e..787a244911 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.8.3", default-features = false } +packable = { version = "0.9.0", default-features = false } # Prevent this from interfering with workspaces [workspace]