diff --git a/Cargo.lock b/Cargo.lock index d7c2a117e..741ea0e37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,25 +149,26 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", - "getrandom 0.2.10", + "getrandom 0.2.11", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -280,9 +281,9 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] name = "array-bytes" -version = "6.1.0" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" +checksum = "de17a919934ad8c5cc99a1a74de4e2dab95d6121a8f27f94755ff525b630382c" [[package]] name = "arrayref" @@ -382,28 +383,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] [[package]] name = "async-io" -version = "1.13.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ - "async-lock", - "autocfg", + "async-lock 3.1.1", "cfg-if", "concurrent-queue", + "futures-io", "futures-lite", - "log", "parking", "polling", - "rustix 0.37.25", + "rustix 0.38.25", "slab", - "socket2 0.4.9", + "tracing", "waker-fn", + "windows-sys 0.48.0", ] [[package]] @@ -412,7 +413,18 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" +dependencies = [ + "event-listener 3.1.0", + "event-listener-strategy", + "pin-project-lite 0.2.13", ] [[package]] @@ -423,7 +435,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -434,7 +446,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -541,9 +553,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -596,7 +608,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -751,9 +763,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" +checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" dependencies = [ "memchr", "serde", @@ -826,9 +838,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" +checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" dependencies = [ "serde", ] @@ -900,25 +912,24 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chacha20" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher 0.4.4", "cpufeatures", - "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.9.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ - "aead 0.4.3", + "aead 0.5.2", "chacha20", - "cipher 0.3.0", + "cipher 0.4.4", "poly1305", "zeroize", ] @@ -976,6 +987,7 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", + "zeroize", ] [[package]] @@ -1000,9 +1012,9 @@ dependencies = [ [[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", @@ -1010,9 +1022,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", @@ -1022,27 +1034,27 @@ 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 = "coarsetime" -version = "0.1.29" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a73ef0d00d14301df35d0f13f5ea32344de6b00837485c358458f1e7f2d27db4" +checksum = "71367d3385c716342014ad17e3d19f7788ae514885a1f4c24f500260fb365e1a" dependencies = [ "libc", "once_cell", @@ -1068,12 +1080,12 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "7.0.1" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" +checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ - "strum", - "strum_macros", + "strum 0.25.0", + "strum_macros 0.25.3", "unicode-width", ] @@ -1113,23 +1125,21 @@ checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "const-random" -version = "0.1.15" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368a7a772ead6ce7e1de82bfb04c485f3db8ec744f72925af5735e29a22cc18e" +checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" dependencies = [ "const-random-macro", - "proc-macro-hack", ] [[package]] name = "const-random-macro" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", "once_cell", - "proc-macro-hack", "tiny-keccak", ] @@ -1191,9 +1201,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -1307,9 +1317,9 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" @@ -1383,9 +1393,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", @@ -1737,7 +1747,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2044,20 +2054,20 @@ 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]] name = "cxx" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c390c123d671cc547244943ecad81bdaab756c6ea332d9ca9c1f48d952a24895" +checksum = "7129e341034ecb940c9072817cd9007974ea696844fc4dd582dc1653a7fbe2e8" dependencies = [ "cc", "cxxbridge-flags", @@ -2067,9 +2077,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d3d3ac9ffb900304edf51ca719187c779f4001bb544f26c4511d621de905cf" +checksum = "a2a24f3f5f8eed71936f21e570436f024f5c2e25628f7496aa7ccd03b90109d5" dependencies = [ "cc", "codespan-reporting", @@ -2077,24 +2087,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "cxxbridge-flags" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94415827ecfea0f0c74c8cad7d1a86ddb3f05354d6a6ddeda0adee5e875d2939" +checksum = "06fdd177fc61050d63f67f5bd6351fac6ab5526694ea8e359cd9cd3b75857f44" [[package]] name = "cxxbridge-macro" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33dbbe9f5621c9247f97ec14213b04f350bff4b6cebefe834c60055db266ecf" +checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2134,15 +2144,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "data-encoding-macro" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" +checksum = "20c01c06f5f429efdf2bae21eb67c28b3df3cf85b7dd2d8ef09c0838dac5d33e" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -2150,9 +2160,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" +checksum = "0047d07f2c89b17dd631c80450d69841a6b5d7fb17278cbc43d7e4cfcf2576f3" dependencies = [ "data-encoding", "syn 1.0.109", @@ -2310,7 +2320,7 @@ name = "did" version = "1.12.0-dev" dependencies = [ "ctype", - "env_logger 0.10.0", + "env_logger 0.10.1", "fluent-uri", "frame-benchmarking", "frame-support", @@ -2428,10 +2438,13 @@ dependencies = [ "cumulus-primitives-utility", "did", "dip-provider-runtime-template", + "frame-benchmarking", "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "hex-literal 0.3.4", "kilt-dip-support", "pallet-aura", "pallet-authorship", @@ -2463,6 +2476,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", + "sp-weights", "substrate-wasm-builder", ] @@ -2529,10 +2543,13 @@ dependencies = [ "cumulus-primitives-timestamp", "cumulus-primitives-utility", "did", + "frame-benchmarking", "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "hex-literal 0.3.4", "kilt-dip-support", "kilt-runtime-api-did", "kilt-runtime-api-dip-provider", @@ -2567,6 +2584,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", + "sp-weights", "substrate-wasm-builder", ] @@ -2619,7 +2637,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2643,7 +2661,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.38", + "syn 2.0.39", "termcolor", "walkdir", ] @@ -2683,9 +2701,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ecdsa" @@ -2701,15 +2719,15 @@ dependencies = [ [[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 0.7.8", "digest 0.10.7", - "elliptic-curve 0.13.6", + "elliptic-curve 0.13.8", "rfc6979 0.4.0", - "signature 2.1.0", + "signature 2.2.0", "spki 0.7.2", ] @@ -2729,7 +2747,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8 0.10.2", - "signature 2.1.0", + "signature 2.2.0", ] [[package]] @@ -2746,15 +2764,16 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" dependencies = [ "curve25519-dalek 4.1.1", "ed25519 2.2.3", "rand_core 0.6.4", "serde", "sha2 0.10.8", + "subtle", "zeroize", ] @@ -2802,12 +2821,12 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct 0.2.0", - "crypto-bigint 0.5.3", + "crypto-bigint 0.5.5", "digest 0.10.7", "ff 0.13.0", "generic-array 0.14.7", @@ -2854,7 +2873,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2865,7 +2884,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2883,9 +2902,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -2908,9 +2927,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", "windows-sys 0.48.0", @@ -2922,6 +2941,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite 0.2.13", +] + +[[package]] +name = "event-listener-strategy" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +dependencies = [ + "event-listener 3.1.0", + "pin-project-lite 0.2.13", +] + [[package]] name = "exit-future" version = "0.2.0" @@ -2965,7 +3005,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2980,15 +3020,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "fastrand" version = "2.0.1" @@ -3051,9 +3082,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "file-per-thread-logger" @@ -3061,7 +3092,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" dependencies = [ - "env_logger 0.10.0", + "env_logger 0.10.1", "log", ] @@ -3250,7 +3281,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3369,7 +3400,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3381,7 +3412,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3391,7 +3422,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3451,9 +3482,12 @@ dependencies = [ [[package]] name = "fs-err" -version = "2.9.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] [[package]] name = "fs2" @@ -3471,7 +3505,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.38.19", + "rustix 0.38.25", "windows-sys 0.48.0", ] @@ -3483,9 +3517,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", @@ -3498,9 +3532,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", @@ -3508,15 +3542,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", @@ -3526,34 +3560,29 @@ 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-lite" -version = "1.13.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" dependencies = [ - "fastrand 1.9.0", "futures-core", - "futures-io", - "memchr", - "parking", "pin-project-lite 0.2.13", - "waker-fn", ] [[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]] @@ -3569,15 +3598,15 @@ dependencies = [ [[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-timer" @@ -3587,9 +3616,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[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", @@ -3655,9 +3684,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", "libc", @@ -3744,9 +3773,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", @@ -3754,7 +3783,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -3763,9 +3792,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" +checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" dependencies = [ "log", "pest", @@ -3796,7 +3825,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] @@ -3805,14 +3834,14 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", ] [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "heck" @@ -3924,9 +3953,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", @@ -3985,7 +4014,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.13", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -3994,19 +4023,19 @@ 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", "hyper", "log", - "rustls 0.21.7", + "rustls 0.21.9", "rustls-native-certs", "tokio", "tokio-rustls", - "webpki-roots 0.23.1", + "webpki-roots 0.25.2", ] [[package]] @@ -4061,19 +4090,19 @@ dependencies = [ [[package]] name = "if-addrs" -version = "0.7.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" +checksum = "cabb0019d51a643781ff15c9c8a3e5dedc365c47211270f4e8f82812fedd8f0a" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "if-watch" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb892e5777fe09e16f3d44de7802f4daa7267ecbe8c466f19d94e25bb0c303e" +checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ "async-io", "core-foundation", @@ -4130,12 +4159,12 @@ 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.1", + "hashbrown 0.14.2", ] [[package]] @@ -4226,7 +4255,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.4", + "socket2 0.5.5", "widestring", "windows-sys 0.48.0", "winreg", @@ -4234,9 +4263,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" @@ -4245,7 +4274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.19", + "rustix 0.38.25", "windows-sys 0.48.0", ] @@ -4284,9 +4313,9 @@ dependencies = [ [[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", ] @@ -4335,7 +4364,7 @@ checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", "arrayvec 0.7.4", - "async-lock", + "async-lock 2.8.0", "async-trait", "beef", "futures-channel", @@ -4437,13 +4466,13 @@ 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 0.16.8", - "elliptic-curve 0.13.6", + "ecdsa 0.16.9", + "elliptic-curve 0.13.8", "once_cell", "sha2 0.10.8", ] @@ -4536,6 +4565,7 @@ dependencies = [ "frame-system", "hash-db", "hex-literal 0.3.4", + "kilt-support", "log", "pallet-did-lookup", "pallet-dip-consumer", @@ -4848,9 +4878,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[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" @@ -4871,7 +4901,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.10", + "getrandom 0.2.11", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4991,7 +5021,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58", - "ed25519-dalek 2.0.0", + "ed25519-dalek 2.1.0", "log", "multiaddr", "multihash", @@ -5045,7 +5075,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "trust-dns-proto", "void", @@ -5187,7 +5217,7 @@ dependencies = [ "libc", "libp2p-core", "log", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", ] @@ -5287,6 +5317,17 @@ dependencies = [ "yamux", ] +[[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 0.4.1", +] + [[package]] name = "librocksdb-sys" version = "0.11.0+8.1.1" @@ -5402,15 +5443,9 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[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" @@ -5493,7 +5528,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5507,7 +5542,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5518,7 +5553,7 @@ checksum = "d710e1214dffbab3b5dacb21475dde7d6ed84c69ff722b3a47a782668d44fbac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5529,7 +5564,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5591,7 +5626,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.19", + "rustix 0.38.25", ] [[package]] @@ -5679,9 +5714,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", @@ -6455,13 +6490,17 @@ dependencies = [ name = "pallet-deposit-storage" version = "1.12.0-dev" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "kilt-support", "log", + "pallet-balances", "pallet-dip-provider", "parity-scale-codec", "scale-info", + "sp-io", + "sp-keystore", "sp-runtime", "sp-std", ] @@ -6472,7 +6511,7 @@ version = "1.12.0-dev" dependencies = [ "base58", "blake2", - "env_logger 0.10.0", + "env_logger 0.10.1", "frame-benchmarking", "frame-support", "frame-system", @@ -6497,12 +6536,16 @@ dependencies = [ name = "pallet-dip-consumer" version = "1.12.0-dev" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "kilt-support", "parity-scale-codec", "scale-info", "sp-core", + "sp-io", + "sp-keystore", + "sp-runtime", "sp-std", ] @@ -6511,10 +6554,16 @@ name = "pallet-dip-provider" version = "1.12.0-dev" dependencies = [ "did", + "frame-benchmarking", "frame-support", "frame-system", + "kilt-support", "parity-scale-codec", "scale-info", + "sp-core", + "sp-io", + "sp-keystore", + "sp-runtime", "sp-std", ] @@ -6538,7 +6587,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] @@ -6728,7 +6777,7 @@ dependencies = [ "ctype", "delegation", "did", - "env_logger 0.10.0", + "env_logger 0.10.1", "frame-benchmarking", "frame-support", "frame-system", @@ -6991,12 +7040,16 @@ name = "pallet-relay-store" version = "1.12.0-dev" dependencies = [ "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "frame-benchmarking", "frame-support", "frame-system", "log", "parity-scale-codec", "scale-info", "sp-core", + "sp-io", + "sp-keystore", "sp-runtime", "sp-std", ] @@ -7105,7 +7158,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -7657,9 +7710,9 @@ dependencies = [ [[package]] name = "pest" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ "memchr", "thiserror", @@ -7668,9 +7721,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ "pest", "pest_generator", @@ -7678,22 +7731,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "pest_meta" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" dependencies = [ "once_cell", "pest", @@ -7707,7 +7760,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.2", + "indexmap 2.1.0", ] [[package]] @@ -7727,7 +7780,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -7776,9 +7829,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 = "polkadot-approval-distribution" @@ -8395,7 +8448,7 @@ dependencies = [ "rand 0.8.5", "sc-authority-discovery", "sc-network", - "strum", + "strum 0.24.1", "thiserror", "tracing-gum", ] @@ -8968,29 +9021,27 @@ dependencies = [ [[package]] name = "polling" -version = "2.8.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" dependencies = [ - "autocfg", - "bitflags 1.3.2", "cfg-if", "concurrent-queue", - "libc", - "log", "pin-project-lite 0.2.13", + "rustix 0.38.25", + "tracing", "windows-sys 0.48.0", ] [[package]] name = "poly1305" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "universal-hash 0.5.1", ] [[package]] @@ -9019,9 +9070,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.3" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" [[package]] name = "powerfmt" @@ -9082,7 +9133,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]] @@ -9148,12 +9199,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro-warning" version = "0.4.2" @@ -9162,7 +9207,7 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -9208,7 +9253,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -9425,7 +9470,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", ] [[package]] @@ -9526,12 +9571,12 @@ dependencies = [ [[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 0.2.10", - "redox_syscall 0.2.16", + "getrandom 0.2.11", + "libredox", "thiserror", ] @@ -9565,7 +9610,7 @@ checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -9672,12 +9717,12 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.4" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce3045ffa7c981a6ee93f640b538952e155f1ae3a1a02b84547fc7a56b7059a" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", - "getrandom 0.2.10", + "getrandom 0.2.11", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -9797,13 +9842,13 @@ dependencies = [ [[package]] name = "rpassword" -version = "7.2.0" +version = "7.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" +checksum = "80472be3c897911d0137b2d2b9055faf6eeac5b14e324073d83bc17b191d7e3f" dependencies = [ "libc", "rtoolbox", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -9834,12 +9879,12 @@ dependencies = [ [[package]] name = "rtoolbox" -version = "0.0.1" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +checksum = "c247d24e63230cdb56463ae328478bd5eac8b8faa8c69461a77e8e323afac90e" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -9866,6 +9911,7 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "did", + "frame-benchmarking", "frame-support", "frame-system", "kilt-asset-dids", @@ -9937,9 +9983,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.16" +version = "0.36.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6da3636faa25820d8648e0e31c5d519bbb01f72fdf57131f0f5f7da5fed36eab" +checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" dependencies = [ "bitflags 1.3.2", "errno", @@ -9951,28 +9997,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.25" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.10", + "linux-raw-sys 0.4.11", "windows-sys 0.48.0", ] @@ -9997,20 +10029,20 @@ checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", "ring 0.16.20", - "sct 0.7.0", + "sct 0.7.1", "webpki 0.22.4", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ "log", - "ring 0.16.20", - "rustls-webpki 0.101.6", - "sct 0.7.0", + "ring 0.17.5", + "rustls-webpki", + "sct 0.7.1", ] [[package]] @@ -10027,31 +10059,21 @@ 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.4", + "base64 0.21.5", ] [[package]] name = "rustls-webpki" -version = "0.100.3" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -10199,7 +10221,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -10476,7 +10498,7 @@ name = "sc-consensus-grandpa" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "array-bytes", "async-trait", "dyn-clone", @@ -10598,7 +10620,7 @@ dependencies = [ "cfg-if", "libc", "log", - "rustix 0.36.16", + "rustix 0.36.17", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -10719,7 +10741,7 @@ name = "sc-network-gossip" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "futures", "futures-timer", "libp2p", @@ -11122,7 +11144,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -11184,9 +11206,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -11198,9 +11220,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11223,7 +11245,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "cfg-if", "hashbrown 0.13.2", ] @@ -11270,12 +11292,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 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -11394,29 +11416,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" 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", @@ -11425,9 +11447,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -11538,9 +11560,9 @@ dependencies = [ [[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", @@ -11603,9 +11625,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 = "snap" @@ -11615,16 +11637,16 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" +checksum = "58021967fd0a5eeeb23b08df6cc244a4d4a5b4aec1d27c9e02fad1a58b4cd74e" dependencies = [ - "aes-gcm 0.9.4", + "aes-gcm 0.10.3", "blake2", "chacha20poly1305", "curve25519-dalek 4.1.1", "rand_core 0.6.4", - "ring 0.16.20", + "ring 0.17.5", "rustc_version", "sha2 0.10.8", "subtle", @@ -11632,9 +11654,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -11642,9 +11664,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", @@ -11699,7 +11721,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -11838,7 +11860,7 @@ dependencies = [ "sp-mmr-primitives", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] @@ -11936,7 +11958,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "quote", "sp-core-hashing", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -11955,7 +11977,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -12016,7 +12038,7 @@ dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum", + "strum 0.24.1", ] [[package]] @@ -12162,7 +12184,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -12304,7 +12326,7 @@ name = "sp-trie" version = "22.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "hash-db", "hashbrown 0.13.2", "lazy_static", @@ -12347,7 +12369,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -12392,13 +12414,13 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spinners" -version = "4.1.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" +checksum = "a0ef947f358b9c238923f764c72a4a9d42f2d637c46e059dbd319d6e7cfb4f82" dependencies = [ "lazy_static", "maplit", - "strum", + "strum 0.24.1", ] [[package]] @@ -12502,9 +12524,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" +checksum = "35935738370302d5e33963665b77541e4b990a3e919ec904c837a56cfc891de1" dependencies = [ "Inflector", "num-format", @@ -12613,9 +12635,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", ] +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + [[package]] name = "strum_macros" version = "0.24.3" @@ -12629,6 +12657,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.39", +] + [[package]] name = "stun" version = "0.4.4" @@ -12650,9 +12691,9 @@ dependencies = [ [[package]] name = "substrate-bip39" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", @@ -12738,7 +12779,7 @@ dependencies = [ "filetime", "parity-wasm", "sp-maybe-compressed-blob", - "strum", + "strum 0.24.1", "tempfile", "toml 0.7.8", "walkdir", @@ -12773,9 +12814,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", @@ -12823,28 +12864,28 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.11" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", - "fastrand 2.0.1", - "redox_syscall 0.3.5", - "rustix 0.38.19", + "fastrand", + "redox_syscall 0.4.1", + "rustix 0.38.25", "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] @@ -12863,27 +12904,27 @@ checksum = "f66edd6b6cd810743c0c71e1d085e92b01ce6a72782032e3f794c8284fe4bcdd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -13029,9 +13070,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", @@ -13041,20 +13082,20 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite 0.2.13", "signal-hook-registry", - "socket2 0.5.4", + "socket2 0.5.5", "tokio-macros", "windows-sys 0.48.0", ] [[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]] @@ -13074,7 +13115,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.7", + "rustls 0.21.9", "tokio", ] @@ -13092,9 +13133,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", @@ -13128,9 +13169,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -13141,7 +13182,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", "serde", "serde_spanned", "toml_datetime", @@ -13191,9 +13232,9 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.39" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2ef2af84856a50c1d430afce2fdded0a4ec7eda868db86409b4543df0797f9" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite 0.2.13", @@ -13209,7 +13250,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -13252,17 +13293,17 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -13339,7 +13380,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2 0.4.9", + "socket2 0.4.10", "thiserror", "tinyvec", "tokio", @@ -13566,11 +13607,11 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.4.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", ] [[package]] @@ -13645,9 +13686,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", @@ -13655,24 +13696,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", @@ -13682,9 +13723,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", @@ -13692,22 +13733,22 @@ 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 = "wasm-instrument" @@ -13726,8 +13767,8 @@ checksum = "87fef6d0d508f08334e0ab0e6877feb4c0ecb3956bcf2cb950699b22fedf3e9c" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", @@ -13827,12 +13868,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.21.4", + "base64 0.21.5", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.16", + "rustix 0.36.17", "serde", "sha2 0.10.8", "toml 0.5.11", @@ -13928,7 +13969,7 @@ checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ "object 0.30.4", "once_cell", - "rustix 0.36.16", + "rustix 0.36.17", ] [[package]] @@ -13959,7 +14000,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.16", + "rustix 0.36.17", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -13980,9 +14021,9 @@ dependencies = [ [[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", @@ -14004,7 +14045,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.4", + "ring 0.17.5", "untrusted 0.9.0", ] @@ -14017,15 +14058,6 @@ dependencies = [ "webpki 0.22.4", ] -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.3", -] - [[package]] name = "webpki-roots" version = "0.25.2" @@ -14159,7 +14191,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2 0.4.9", + "socket2 0.4.10", "thiserror", "tokio", "webrtc-util", @@ -14356,7 +14388,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.19", + "rustix 0.38.25", ] [[package]] @@ -14559,9 +14591,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", ] @@ -14711,7 +14743,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -14737,11 +14769,31 @@ dependencies = [ "time", ] +[[package]] +name = "zerocopy" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -14754,7 +14806,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] diff --git a/crates/kilt-dip-support/Cargo.toml b/crates/kilt-dip-support/Cargo.toml index d9d604884..bbebdfa4f 100644 --- a/crates/kilt-dip-support/Cargo.toml +++ b/crates/kilt-dip-support/Cargo.toml @@ -17,6 +17,7 @@ log.workspace = true # Internal dependencies did.workspace = true +kilt-support = {workspace = true, optional = true} pallet-did-lookup.workspace = true pallet-dip-consumer.workspace = true pallet-dip-provider.workspace = true @@ -57,6 +58,7 @@ std = [ "hash-db/std", "log/std", "did/std", + "kilt-support?/std", "pallet-did-lookup/std", "pallet-dip-consumer/std", "pallet-dip-provider/std", @@ -80,6 +82,8 @@ std = [ "parachain-info/std", ] runtime-benchmarks = [ + "kilt-support/runtime-benchmarks", "pallet-dip-consumer/runtime-benchmarks", + "pallet-dip-provider/runtime-benchmarks", "rococo-runtime/runtime-benchmarks" ] diff --git a/crates/kilt-dip-support/src/did.rs b/crates/kilt-dip-support/src/did.rs index 7b16bcbb8..f59861492 100644 --- a/crates/kilt-dip-support/src/did.rs +++ b/crates/kilt-dip-support/src/did.rs @@ -20,7 +20,6 @@ use did::{ did_details::{DidPublicKey, DidPublicKeyDetails, DidVerificationKey}, DidSignature, DidVerificationKeyRelationship, }; -use frame_support::ensure; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_core::RuntimeDebug; @@ -44,6 +43,20 @@ pub struct TimeBoundDidSignature { pub block_number: BlockNumber, } +#[cfg(feature = "runtime-benchmarks")] +impl kilt_support::traits::GetWorstCase for TimeBoundDidSignature +where + DidSignature: kilt_support::traits::GetWorstCase, + BlockNumber: Default, +{ + fn worst_case(context: Context) -> Self { + Self { + signature: DidSignature::worst_case(context), + block_number: BlockNumber::default(), + } + } +} + pub enum RevealedDidKeysSignatureAndCallVerifierError { SignatureNotFresh, SignatureUnverifiable, @@ -121,6 +134,7 @@ impl< CallVerifier: DipCallOriginFilter, DidVerificationKeyRelationship)>, { + #[cfg(not(feature = "runtime-benchmarks"))] #[allow(clippy::result_unit_err)] pub(crate) fn verify_did_signature_for_call( call: &Call, @@ -131,6 +145,8 @@ impl< (DidVerificationKey, DidVerificationKeyRelationship), RevealedDidKeysSignatureAndCallVerifierError, > { + use frame_support::ensure; + let block_number = ContextProvider::block_number(); let is_signature_fresh = if let Some(blocks_ago_from_now) = block_number.checked_sub(&merkle_revealed_did_signature.did_signature.block_number) @@ -183,4 +199,80 @@ impl< .map_err(|_| RevealedDidKeysSignatureAndCallVerifierError::OriginCheckFailed)?; Ok((key.clone(), *relationship)) } + + #[cfg(feature = "runtime-benchmarks")] + #[allow(clippy::result_unit_err)] + pub(crate) fn verify_did_signature_for_call( + call: &Call, + submitter: &Submitter, + local_details: &mut Option, + merkle_revealed_did_signature: RevealedDidKeysAndSignature, + ) -> Result< + (DidVerificationKey, DidVerificationKeyRelationship), + RevealedDidKeysSignatureAndCallVerifierError, + > { + use sp_core::ed25519; + + let block_number = ContextProvider::block_number(); + // Computed but ignored + if let Some(blocks_ago_from_now) = + block_number.checked_sub(&merkle_revealed_did_signature.did_signature.block_number) + { + // False if the signature is too old. + blocks_ago_from_now <= ContextProvider::SIGNATURE_VALIDITY.into() + } else { + // Signature generated at a future time, not possible to verify. + false + }; + let encoded_payload = ( + call, + &local_details, + submitter, + &merkle_revealed_did_signature.did_signature.block_number, + ContextProvider::genesis_hash(), + ContextProvider::signed_extra(), + ) + .encode(); + // Only consider verification keys from the set of revealed keys. + let proof_verification_keys: Vec<(DidVerificationKey, DidVerificationKeyRelationship)> = + merkle_revealed_did_signature + .merkle_leaves + .borrow() + .iter() + .filter_map( + |RevealedDidKey { + relationship, + details: DidPublicKeyDetails { key, .. }, + .. + }| { + let DidPublicKey::PublicVerificationKey(key) = key else { + return None; + }; + if let Ok(vr) = DidVerificationKeyRelationship::try_from(*relationship) { + Some(Ok((key.clone(), vr))) + } else { + None + } + }, + ) + .collect::>()?; + let valid_signing_key = proof_verification_keys.iter().find(|(verification_key, _)| { + verification_key + .verify_signature(&encoded_payload, &merkle_revealed_did_signature.did_signature.signature) + .is_ok() + }); + let default = ( + DidVerificationKey::Ed25519(ed25519::Public::from_raw([0u8; 32])), + DidVerificationKeyRelationship::Authentication, + ); + let (key, relationship) = valid_signing_key.unwrap_or(&default); + if let Some(details) = local_details { + details.bump(); + } else { + *local_details = Some(DidLocalDetails::default()); + }; + // Ignore the result of this call + let _ = CallVerifier::check_call_origin_info(call, &(key.clone(), *relationship)); + Ok((key.clone(), *relationship)) + } } diff --git a/crates/kilt-dip-support/src/export/child.rs b/crates/kilt-dip-support/src/export/child.rs index 6df44c2e4..6fd215de3 100644 --- a/crates/kilt-dip-support/src/export/child.rs +++ b/crates/kilt-dip-support/src/export/child.rs @@ -27,7 +27,7 @@ use parity_scale_codec::{Codec, Decode, Encode, HasCompact}; use scale_info::TypeInfo; use sp_core::{RuntimeDebug, U256}; use sp_runtime::traits::{AtLeast32BitUnsigned, Get, Hash, MaybeDisplay, Member, SimpleBitOps}; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::marker::PhantomData; use crate::{ did::RevealedDidKeysSignatureAndCallVerifierError, @@ -38,7 +38,7 @@ use crate::{ RelayChainStorageInfo, }, utils::OutputOf, - FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet, + BoundedBlindedValue, FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet, }; #[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo, Clone)] @@ -209,7 +209,7 @@ impl< type Proof = VersionedChildParachainDipStateProof< ::BlockNumber, ::Hasher, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< KeyIdOf, KiltRuntime::AccountId, @@ -376,7 +376,7 @@ impl< type Proof = VersionedChildParachainDipStateProof< ::BlockNumber, ::Hasher, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< ProviderDidKeyId, ProviderAccountId, @@ -592,7 +592,7 @@ mod v0 { type Proof = ChildParachainDipStateProof< ::BlockNumber, ::Hasher, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< ProviderDidKeyId, ProviderAccountId, @@ -629,7 +629,6 @@ mod v0 { // 1.2 If so, extract the state root from the header let state_root_at_height = proof.relay_header.state_root; - // FIXME: Compilation error // 2. Verify relay chain proof let provider_parachain_header = ParachainHeadProofVerifier::::verify_proof_for_parachain_with_root( diff --git a/crates/kilt-dip-support/src/export/common.rs b/crates/kilt-dip-support/src/export/common.rs index d0eff66d6..fa98de6f1 100644 --- a/crates/kilt-dip-support/src/export/common.rs +++ b/crates/kilt-dip-support/src/export/common.rs @@ -24,14 +24,27 @@ pub mod v0 { use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_core::RuntimeDebug; - use sp_std::vec::Vec; - use crate::{did::TimeBoundDidSignature, merkle::DidMerkleProof}; + use crate::{did::TimeBoundDidSignature, merkle::DidMerkleProof, BoundedBlindedValue}; #[derive(Encode, Decode, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, TypeInfo, Clone)] pub struct ParachainRootStateProof { pub(crate) relay_block_height: RelayBlockHeight, - pub(crate) proof: Vec>, + pub(crate) proof: BoundedBlindedValue, + } + + #[cfg(feature = "runtime-benchmarks")] + impl kilt_support::traits::GetWorstCase + for ParachainRootStateProof + where + RelayBlockHeight: Default, + { + fn worst_case(context: Context) -> Self { + Self { + relay_block_height: RelayBlockHeight::default(), + proof: BoundedBlindedValue::worst_case(context), + } + } } #[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo, Clone)] @@ -39,4 +52,21 @@ pub mod v0 { pub(crate) leaves: DidMerkleProof, pub(crate) signature: TimeBoundDidSignature, } + + #[cfg(feature = "runtime-benchmarks")] + impl kilt_support::traits::GetWorstCase + for DipMerkleProofAndDidSignature + where + BlindedValues: kilt_support::traits::GetWorstCase, + Leaf: Default + Clone, + BlockNumber: Default, + Context: Clone, + { + fn worst_case(context: Context) -> Self { + Self { + leaves: DidMerkleProof::worst_case(context.clone()), + signature: TimeBoundDidSignature::worst_case(context), + } + } + } } diff --git a/crates/kilt-dip-support/src/export/sibling.rs b/crates/kilt-dip-support/src/export/sibling.rs index 5f8256010..0fd6ec989 100644 --- a/crates/kilt-dip-support/src/export/sibling.rs +++ b/crates/kilt-dip-support/src/export/sibling.rs @@ -27,7 +27,7 @@ use parity_scale_codec::{Decode, Encode, HasCompact}; use scale_info::TypeInfo; use sp_core::{RuntimeDebug, U256}; use sp_runtime::traits::Get; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::marker::PhantomData; use crate::{ did::RevealedDidKeysSignatureAndCallVerifierError, @@ -35,7 +35,7 @@ use crate::{ state_proofs::{parachain::DipIdentityCommitmentProofVerifierError, relay_chain::ParachainHeadProofVerifierError}, traits::{self, Bump, DidSignatureVerifierContext, DipCallOriginFilter}, utils::OutputOf, - FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet, + BoundedBlindedValue, FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet, }; #[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo, Clone)] @@ -56,6 +56,26 @@ pub enum VersionedSiblingParachainDipStateProof< ), } +#[cfg(feature = "runtime-benchmarks")] +impl + kilt_support::traits::GetWorstCase + for VersionedSiblingParachainDipStateProof< + RelayBlockHeight, + DipMerkleProofBlindedValues, + DipMerkleProofRevealedLeaf, + LocalBlockNumber, + > where + RelayBlockHeight: Default, + DipMerkleProofBlindedValues: kilt_support::traits::GetWorstCase, + DipMerkleProofRevealedLeaf: Default + Clone, + LocalBlockNumber: Default, + Context: Clone, +{ + fn worst_case(context: Context) -> Self { + Self::V0(v0::SiblingParachainDipStateProof::worst_case(context)) + } +} + pub enum DipSiblingProviderStateProofVerifierError< ParachainHeadMerkleProofVerificationError, IdentityCommitmentMerkleProofVerificationError, @@ -183,7 +203,7 @@ impl< >; type Proof = VersionedSiblingParachainDipStateProof< RelayChainStateInfo::BlockNumber, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< KeyIdOf, KiltRuntime::AccountId, @@ -336,7 +356,7 @@ impl< >; type Proof = VersionedSiblingParachainDipStateProof< RelayChainStateInfo::BlockNumber, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< ProviderDidKeyId, ProviderAccountId, @@ -413,9 +433,34 @@ mod v0 { DipMerkleProofRevealedLeaf, LocalBlockNumber, > { - para_state_root: ParachainRootStateProof, - dip_identity_commitment: Vec>, - did: DipMerkleProofAndDidSignature, + pub(crate) para_state_root: ParachainRootStateProof, + pub(crate) dip_identity_commitment: BoundedBlindedValue, + pub(crate) did: + DipMerkleProofAndDidSignature, + } + + #[cfg(feature = "runtime-benchmarks")] + impl + kilt_support::traits::GetWorstCase + for SiblingParachainDipStateProof< + RelayBlockHeight, + DipMerkleProofBlindedValues, + DipMerkleProofRevealedLeaf, + LocalBlockNumber, + > where + DipMerkleProofBlindedValues: kilt_support::traits::GetWorstCase, + DipMerkleProofRevealedLeaf: Default + Clone, + RelayBlockHeight: Default, + LocalBlockNumber: Default, + Context: Clone, + { + fn worst_case(context: Context) -> Self { + Self { + para_state_root: ParachainRootStateProof::worst_case(context.clone()), + dip_identity_commitment: BoundedBlindedValue::worst_case(context.clone()), + did: DipMerkleProofAndDidSignature::worst_case(context), + } + } } #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] @@ -518,7 +563,7 @@ mod v0 { >; type Proof = SiblingParachainDipStateProof< RelayChainStateInfo::BlockNumber, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< ProviderDidKeyId, ProviderAccountId, diff --git a/crates/kilt-dip-support/src/lib.rs b/crates/kilt-dip-support/src/lib.rs index 032280168..9d7a41561 100644 --- a/crates/kilt-dip-support/src/lib.rs +++ b/crates/kilt-dip-support/src/lib.rs @@ -34,3 +34,4 @@ pub use state_proofs::{ relay_chain::{ParachainHeadProofVerifier, ParachainHeadProofVerifierError, RelayStateRootsViaRelayStorePallet}, }; pub use traits::{FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet}; +pub use utils::BoundedBlindedValue; diff --git a/crates/kilt-dip-support/src/merkle.rs b/crates/kilt-dip-support/src/merkle.rs index 2f23c952e..68e30e991 100644 --- a/crates/kilt-dip-support/src/merkle.rs +++ b/crates/kilt-dip-support/src/merkle.rs @@ -16,10 +16,14 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use did::{did_details::DidPublicKeyDetails, DidVerificationKeyRelationship}; +use did::{ + did_details::{DidPublicKeyDetails, DidVerificationKey}, + DidVerificationKeyRelationship, +}; use frame_support::{traits::ConstU32, DefaultNoBound, RuntimeDebug}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +use sp_core::ed25519; use sp_runtime::{BoundedVec, SaturatedConversion}; use sp_std::{fmt::Debug, marker::PhantomData, vec::Vec}; use sp_trie::{verify_trie_proof, LayoutV1}; @@ -31,6 +35,20 @@ pub struct DidMerkleProof { pub revealed: Vec, } +#[cfg(feature = "runtime-benchmarks")] +impl kilt_support::traits::GetWorstCase for DidMerkleProof +where + BlindedValues: kilt_support::traits::GetWorstCase, + Leaf: Default + Clone, +{ + fn worst_case(context: Context) -> Self { + Self { + blinded: BlindedValues::worst_case(context), + revealed: sp_std::vec![Leaf::default(); 64], + } + } +} + #[derive(Clone, Copy, RuntimeDebug, Encode, Decode, PartialEq, Eq, TypeInfo, PartialOrd, Ord, MaxEncodedLen)] pub enum DidKeyRelationship { Encryption, @@ -119,6 +137,25 @@ pub enum RevealedDidMerkleProofLeaf, LinkedAccountMerkleValue), } +#[cfg(feature = "runtime-benchmarks")] +impl Default + for RevealedDidMerkleProofLeaf +where + KeyId: Default, + BlockNumber: Default, +{ + fn default() -> Self { + Self::DidKey( + (KeyId::default(), DidVerificationKeyRelationship::Authentication.into()).into(), + DidPublicKeyDetails { + key: DidVerificationKey::Ed25519(ed25519::Public::from_raw([0u8; 32])).into(), + block_number: BlockNumber::default(), + } + .into(), + ) + } +} + impl RevealedDidMerkleProofLeaf where @@ -259,7 +296,7 @@ impl< LinkedAccountId: Encode + Clone, Web3Name: Encode + Clone, { - #[allow(clippy::result_unit_err)] + #[cfg(not(feature = "runtime-benchmarks"))] #[allow(clippy::type_complexity)] pub(crate) fn verify_dip_merkle_proof( identity_commitment: &Hasher::Out, @@ -338,4 +375,76 @@ impl< linked_accounts, }) } + + #[cfg(feature = "runtime-benchmarks")] + #[allow(clippy::type_complexity)] + pub(crate) fn verify_dip_merkle_proof( + identity_commitment: &Hasher::Out, + proof: DidMerkleProof< + crate::BoundedBlindedValue, + RevealedDidMerkleProofLeaf, + >, + ) -> Result< + RevealedDidMerkleProofLeaves< + KeyId, + AccountId, + BlockNumber, + Web3Name, + LinkedAccountId, + MAX_REVEALED_KEYS_COUNT, + MAX_REVEALED_ACCOUNTS_COUNT, + >, + DidMerkleProofVerifierError, + > { + let proof_leaves = proof + .revealed + .iter() + .map(|leaf| (leaf.encoded_key(), Some(leaf.encoded_value()))) + .collect::, Option>)>>(); + // Ignore result + let _ = verify_trie_proof::, _, _, _>(identity_commitment, &proof.blinded, &proof_leaves); + + #[allow(clippy::type_complexity)] + let (did_keys, web3_name, linked_accounts): ( + BoundedVec, ConstU32>, + Option>, + BoundedVec>, + ) = proof.revealed.iter().try_fold( + ( + BoundedVec::with_bounded_capacity(MAX_REVEALED_KEYS_COUNT.saturated_into()), + None, + BoundedVec::with_bounded_capacity(MAX_REVEALED_ACCOUNTS_COUNT.saturated_into()), + ), + |(mut keys, web3_name, mut linked_accounts), leaf| match leaf { + RevealedDidMerkleProofLeaf::DidKey(key_id, key_value) => { + // Ignore error, just discard anything in excess. + let _ = keys.try_push(RevealedDidKey { + id: key_id.0.clone(), + relationship: key_id.1, + details: key_value.0.clone(), + }); + Ok::<_, DidMerkleProofVerifierError>((keys, web3_name, linked_accounts)) + } + RevealedDidMerkleProofLeaf::Web3Name(revealed_web3_name, details) => Ok(( + keys, + Some(RevealedWeb3Name { + web3_name: revealed_web3_name.0.clone(), + claimed_at: details.0.clone(), + }), + linked_accounts, + )), + RevealedDidMerkleProofLeaf::LinkedAccount(account_id, _) => { + // Ignore error, just discard anything in excess. + let _ = linked_accounts.try_push(account_id.0.clone()); + Ok::<_, DidMerkleProofVerifierError>((keys, web3_name, linked_accounts)) + } + }, + )?; + + Ok(RevealedDidMerkleProofLeaves { + did_keys, + web3_name, + linked_accounts, + }) + } } diff --git a/crates/kilt-dip-support/src/state_proofs.rs b/crates/kilt-dip-support/src/state_proofs.rs index 0156143ce..019161c27 100644 --- a/crates/kilt-dip-support/src/state_proofs.rs +++ b/crates/kilt-dip-support/src/state_proofs.rs @@ -121,6 +121,7 @@ pub(super) mod relay_chain { RelayChainState::BlockNumber: Copy + Into + TryFrom + HasCompact, RelayChainState::Key: AsRef<[u8]>, { + #[cfg(not(feature = "runtime-benchmarks"))] pub fn verify_proof_for_parachain_with_root( para_id: &RelayChainState::ParaId, root: &OutputOf<::Hasher>, @@ -143,6 +144,38 @@ pub(super) mod relay_chain { let mut unwrapped_head = &encoded_head[2..]; Header::decode(&mut unwrapped_head).map_err(|_| ParachainHeadProofVerifierError::HeaderDecode) } + + // Ignores any errors returned by the `read_proof_check` function and returns a + // default Header in case of failure. + #[cfg(feature = "runtime-benchmarks")] + pub fn verify_proof_for_parachain_with_root( + para_id: &RelayChainState::ParaId, + root: &OutputOf<::Hasher>, + proof: impl IntoIterator>, + ) -> Result, ParachainHeadProofVerifierError> { + let parachain_storage_key = RelayChainState::parachain_head_storage_key(para_id); + let storage_proof = StorageProof::new(proof); + let revealed_leaves = + read_proof_check::(*root, storage_proof, [¶chain_storage_key].iter()) + .unwrap_or_default(); + let encoded_head = if let Some(Some(encoded_head)) = revealed_leaves.get(parachain_storage_key.as_ref()) { + encoded_head.clone() + } else { + sp_std::vec![0u8; 3] + }; + let mut unwrapped_head = &encoded_head[2..]; + let header = Header::decode(&mut unwrapped_head).unwrap_or(Header { + number: U256::from(0u64) + .try_into() + .map_err(|_| "Block number should be created from a u64") + .unwrap(), + digest: Default::default(), + extrinsics_root: Default::default(), + parent_hash: Default::default(), + state_root: Default::default(), + }); + Ok(header) + } } // Relies on the `RelayChainState::state_root_for_block` to retrieve the state @@ -154,7 +187,7 @@ pub(super) mod relay_chain { RelayChainState::BlockNumber: Copy + Into + TryFrom + HasCompact, RelayChainState::Key: AsRef<[u8]>, { - #[allow(clippy::result_unit_err)] + #[cfg(not(feature = "runtime-benchmarks"))] pub fn verify_proof_for_parachain( para_id: &RelayChainState::ParaId, relay_height: &RelayChainState::BlockNumber, @@ -164,6 +197,16 @@ pub(super) mod relay_chain { .ok_or(ParachainHeadProofVerifierError::RelaychainStateRootNotFound)?; Self::verify_proof_for_parachain_with_root(para_id, &relay_state_root, proof) } + + #[cfg(feature = "runtime-benchmarks")] + pub fn verify_proof_for_parachain( + para_id: &RelayChainState::ParaId, + relay_height: &RelayChainState::BlockNumber, + proof: impl IntoIterator>, + ) -> Result, ParachainHeadProofVerifierError> { + let relay_state_root = RelayChainState::state_root_for_block(relay_height).unwrap_or_default(); + Self::verify_proof_for_parachain_with_root(para_id, &relay_state_root, proof) + } } pub struct RelayStateRootsViaRelayStorePallet(PhantomData); @@ -296,6 +339,7 @@ pub(super) mod parachain { ParaInfo::Commitment: Decode, ParaInfo::Key: AsRef<[u8]>, { + #[cfg(not(feature = "runtime-benchmarks"))] #[allow(clippy::result_unit_err)] pub fn verify_proof_for_identifier( identifier: &ParaInfo::Identifier, @@ -321,6 +365,33 @@ pub(super) mod parachain { ParaInfo::Commitment::decode(&mut &encoded_commitment[..]) .map_err(|_| DipIdentityCommitmentProofVerifierError::CommitmentDecode) } + + #[cfg(feature = "runtime-benchmarks")] + pub fn verify_proof_for_identifier( + identifier: &ParaInfo::Identifier, + state_root: OutputOf, + proof: impl IntoIterator>, + ) -> Result + where + ParaInfo::Commitment: Default, + { + let dip_commitment_storage_key = ParaInfo::dip_subject_storage_key(identifier, 0); + let storage_proof = StorageProof::new(proof); + let revealed_leaves = read_proof_check::( + state_root, + storage_proof, + [&dip_commitment_storage_key].iter(), + ) + .unwrap_or_default(); + let encoded_commitment = + if let Some(Some(encoded_commitment)) = revealed_leaves.get(dip_commitment_storage_key.as_ref()) { + encoded_commitment.clone() + } else { + Vec::default() + }; + let commitment = ParaInfo::Commitment::decode(&mut &encoded_commitment[..]).unwrap_or_default(); + Ok(commitment) + } } #[cfg(test)] diff --git a/crates/kilt-dip-support/src/utils.rs b/crates/kilt-dip-support/src/utils.rs index e382093b9..825826ce7 100644 --- a/crates/kilt-dip-support/src/utils.rs +++ b/crates/kilt-dip-support/src/utils.rs @@ -16,4 +16,64 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org +use parity_scale_codec::{Decode, Encode}; +use scale_info::TypeInfo; +use sp_core::RuntimeDebug; +use sp_std::vec::Vec; + pub type OutputOf = ::Output; + +#[derive(Encode, Decode, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, TypeInfo, Clone)] +pub struct BoundedBlindedValue(Vec>); + +impl BoundedBlindedValue { + pub fn into_inner(self) -> Vec> { + self.0 + } +} + +impl From for BoundedBlindedValue +where + C: Iterator>, +{ + fn from(value: C) -> Self { + Self(value.into_iter().collect()) + } +} + +impl sp_std::ops::Deref for BoundedBlindedValue { + type Target = Vec>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl IntoIterator for BoundedBlindedValue { + type IntoIter = > as IntoIterator>::IntoIter; + type Item = > as IntoIterator>::Item; + + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() + } +} + +#[cfg(feature = "runtime-benchmarks")] +impl kilt_support::traits::GetWorstCase for BoundedBlindedValue +where + T: Default + Clone, +{ + fn worst_case(_context: Context) -> Self { + Self(sp_std::vec![sp_std::vec![T::default(); 128]; 64]) + } +} + +#[cfg(feature = "runtime-benchmarks")] +impl Default for BoundedBlindedValue +where + T: Default + Clone, +{ + fn default() -> Self { + Self(sp_std::vec![sp_std::vec![T::default(); 128]; 64]) + } +} diff --git a/dip-template/nodes/dip-consumer/Cargo.toml b/dip-template/nodes/dip-consumer/Cargo.toml index b48e55d0d..1f5435f43 100644 --- a/dip-template/nodes/dip-consumer/Cargo.toml +++ b/dip-template/nodes/dip-consumer/Cargo.toml @@ -68,3 +68,9 @@ cumulus-relay-chain-interface.workspace = true [build-dependencies] substrate-build-script-utils.workspace = true + +[features] +runtime-benchmarks = [ + "frame-benchmarking-cli/runtime-benchmarks", + "dip-consumer-runtime-template/runtime-benchmarks", +] diff --git a/dip-template/nodes/dip-consumer/src/cli.rs b/dip-template/nodes/dip-consumer/src/cli.rs index 5e5d10525..da4f53612 100644 --- a/dip-template/nodes/dip-consumer/src/cli.rs +++ b/dip-template/nodes/dip-consumer/src/cli.rs @@ -25,6 +25,7 @@ use sc_service::Configuration; use crate::chain_spec::Extensions; +#[allow(clippy::large_enum_variant)] #[derive(Debug, clap::Subcommand)] pub enum Subcommand { BuildSpec(BuildSpecCmd), @@ -44,6 +45,8 @@ pub enum Subcommand { ExportGenesisState(ExportGenesisStateCommand), ExportGenesisWasm(ExportGenesisWasmCommand), + #[command(subcommand)] + Benchmark(frame_benchmarking_cli::BenchmarkCmd), } #[derive(Debug, clap::Parser)] diff --git a/dip-template/nodes/dip-consumer/src/command.rs b/dip-template/nodes/dip-consumer/src/command.rs index e56083950..36898a019 100644 --- a/dip-template/nodes/dip-consumer/src/command.rs +++ b/dip-template/nodes/dip-consumer/src/command.rs @@ -19,6 +19,8 @@ use std::{fs::create_dir_all, net::SocketAddr}; use cumulus_primitives_core::ParaId; +use dip_consumer_runtime_template::Block; +use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use log::{info, warn}; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, LoggerBuilder, @@ -189,6 +191,45 @@ pub fn run() -> Result<()> { cmd.run(&*spec) }) } + Some(Subcommand::Benchmark(cmd)) => { + let runner = cli.create_runner(cmd)?; + match cmd { + BenchmarkCmd::Pallet(cmd) => { + if cfg!(feature = "runtime-benchmarks") { + runner.sync_run(|config| cmd.run::(config)) + } else { + Err("Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`." + .into()) + } + } + BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { + let partials = new_partial(&config)?; + cmd.run(partials.client) + }), + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => { + return Err(sc_cli::Error::Input( + "Compile with --features=runtime-benchmarks \ + to enable storage benchmarks." + .into(), + ) + .into()) + } + #[cfg(feature = "runtime-benchmarks")] + BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { + let partials = new_partial(&config)?; + let db = partials.backend.expose_db(); + let storage = partials.backend.expose_storage(); + cmd.run(config, partials.client.clone(), db, storage) + }), + BenchmarkCmd::Machine(cmd) => { + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) + } + #[allow(unreachable_patterns)] + _ => Err("Benchmarking sub-command unsupported".into()), + } + } None => { let runner = cli.create_runner(&cli.run.normalize())?; let collator_options = cli.run.collator_options(); diff --git a/dip-template/nodes/dip-provider/Cargo.toml b/dip-template/nodes/dip-provider/Cargo.toml index 0bc866ddd..584bca26e 100644 --- a/dip-template/nodes/dip-provider/Cargo.toml +++ b/dip-template/nodes/dip-provider/Cargo.toml @@ -68,3 +68,9 @@ cumulus-relay-chain-interface.workspace = true [build-dependencies] substrate-build-script-utils.workspace = true + +[features] +runtime-benchmarks = [ + "frame-benchmarking-cli/runtime-benchmarks", + "dip-provider-runtime-template/runtime-benchmarks" +] diff --git a/dip-template/nodes/dip-provider/src/cli.rs b/dip-template/nodes/dip-provider/src/cli.rs index 5e5d10525..da4f53612 100644 --- a/dip-template/nodes/dip-provider/src/cli.rs +++ b/dip-template/nodes/dip-provider/src/cli.rs @@ -25,6 +25,7 @@ use sc_service::Configuration; use crate::chain_spec::Extensions; +#[allow(clippy::large_enum_variant)] #[derive(Debug, clap::Subcommand)] pub enum Subcommand { BuildSpec(BuildSpecCmd), @@ -44,6 +45,8 @@ pub enum Subcommand { ExportGenesisState(ExportGenesisStateCommand), ExportGenesisWasm(ExportGenesisWasmCommand), + #[command(subcommand)] + Benchmark(frame_benchmarking_cli::BenchmarkCmd), } #[derive(Debug, clap::Parser)] diff --git a/dip-template/nodes/dip-provider/src/command.rs b/dip-template/nodes/dip-provider/src/command.rs index 6e508956e..976c31189 100644 --- a/dip-template/nodes/dip-provider/src/command.rs +++ b/dip-template/nodes/dip-provider/src/command.rs @@ -19,6 +19,8 @@ use std::{fs::create_dir_all, net::SocketAddr}; use cumulus_primitives_core::ParaId; +use dip_provider_runtime_template::Block; +use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use log::{info, warn}; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, LoggerBuilder, @@ -189,6 +191,45 @@ pub fn run() -> Result<()> { cmd.run(&*spec) }) } + Some(Subcommand::Benchmark(cmd)) => { + let runner = cli.create_runner(cmd)?; + match cmd { + BenchmarkCmd::Pallet(cmd) => { + if cfg!(feature = "runtime-benchmarks") { + runner.sync_run(|config| cmd.run::(config)) + } else { + Err("Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`." + .into()) + } + } + BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { + let partials = new_partial(&config)?; + cmd.run(partials.client) + }), + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => { + return Err(sc_cli::Error::Input( + "Compile with --features=runtime-benchmarks \ + to enable storage benchmarks." + .into(), + ) + .into()) + } + #[cfg(feature = "runtime-benchmarks")] + BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { + let partials = new_partial(&config)?; + let db = partials.backend.expose_db(); + let storage = partials.backend.expose_storage(); + cmd.run(config, partials.client.clone(), db, storage) + }), + BenchmarkCmd::Machine(cmd) => { + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) + } + #[allow(unreachable_patterns)] + _ => Err("Benchmarking sub-command unsupported".into()), + } + } None => { let runner = cli.create_runner(&cli.run.normalize())?; let collator_options = cli.run.collator_options(); diff --git a/dip-template/runtimes/dip-consumer/Cargo.toml b/dip-template/runtimes/dip-consumer/Cargo.toml index 078f17225..ca55d7dca 100644 --- a/dip-template/runtimes/dip-consumer/Cargo.toml +++ b/dip-template/runtimes/dip-consumer/Cargo.toml @@ -53,6 +53,7 @@ sp-session.workspace = true sp-std.workspace = true sp-transaction-pool.workspace = true sp-version.workspace = true +sp-weights.workspace = true # Cumulus cumulus-pallet-aura-ext.workspace = true @@ -64,6 +65,11 @@ cumulus-primitives-utility.workspace = true pallet-collator-selection.workspace = true parachain-info.workspace = true +# Benchmarks +frame-benchmarking = {workspace = true, optional = true} +frame-system-benchmarking = {workspace = true, optional = true} +hex-literal = {workspace = true, optional = true} + [features] default = [ "std", @@ -104,6 +110,7 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", + "sp-weights/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", @@ -118,8 +125,17 @@ runtime-benchmarks = [ "dip-provider-runtime-template/runtime-benchmarks", "kilt-dip-support/runtime-benchmarks", "pallet-dip-consumer/runtime-benchmarks", + "pallet-relay-store/runtime-benchmarks", "runtime-common/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "hex-literal" ] diff --git a/dip-template/runtimes/dip-consumer/src/dip.rs b/dip-template/runtimes/dip-consumer/src/dip.rs index db25e1933..03ef8efd1 100644 --- a/dip-template/runtimes/dip-consumer/src/dip.rs +++ b/dip-template/runtimes/dip-consumer/src/dip.rs @@ -27,7 +27,7 @@ use pallet_dip_consumer::traits::IdentityProofVerifier; use sp_core::ConstU32; use sp_runtime::traits::BlakeTwo256; -use crate::{AccountId, DidIdentifier, Runtime, RuntimeCall, RuntimeOrigin}; +use crate::{weights, AccountId, DidIdentifier, Runtime, RuntimeCall, RuntimeOrigin}; pub type MerkleProofVerifierOutput = >::VerificationResult; pub type ProofVerifier = KiltVersionedSiblingProviderVerifier< @@ -49,11 +49,13 @@ impl pallet_dip_consumer::Config for Runtime { type ProofVerifier = ProofVerifier; type RuntimeCall = RuntimeCall; type RuntimeOrigin = RuntimeOrigin; + type WeightInfo = weights::pallet_dip_consumer::WeightInfo; } pub struct PreliminaryDipOriginFilter; impl Contains for PreliminaryDipOriginFilter { + #[cfg(not(feature = "runtime-benchmarks"))] fn contains(t: &RuntimeCall) -> bool { matches!( t, @@ -63,6 +65,11 @@ impl Contains for PreliminaryDipOriginFilter { | RuntimeCall::Utility(pallet_utility::Call::force_batch { .. }) ) } + + #[cfg(feature = "runtime-benchmarks")] + fn contains(_t: &RuntimeCall) -> bool { + true + } } fn derive_verification_key_relationship(call: &RuntimeCall) -> Option { @@ -123,4 +130,5 @@ impl DipCallOriginFilter for DipCallFilter { impl pallet_relay_store::Config for Runtime { type MaxRelayBlocksStored = ConstU32<100>; + type WeightInfo = weights::pallet_relay_store::WeightInfo; } diff --git a/dip-template/runtimes/dip-consumer/src/lib.rs b/dip-template/runtimes/dip-consumer/src/lib.rs index 953b179b9..daf21c15f 100644 --- a/dip-template/runtimes/dip-consumer/src/lib.rs +++ b/dip-template/runtimes/dip-consumer/src/lib.rs @@ -65,6 +65,7 @@ use sp_version::RuntimeVersion; mod dip; mod origin_adapter; +mod weights; pub use crate::{dip::*, origin_adapter::*}; #[cfg(any(feature = "std", test))] @@ -234,7 +235,7 @@ impl frame_system::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; type SS58Prefix = ConstU16; - type SystemWeightInfo = (); + type SystemWeightInfo = weights::frame_system::WeightInfo; type Version = Version; } @@ -358,6 +359,15 @@ impl pallet_postit::Config for Runtime { type Username = Web3Name; } +#[cfg(feature = "runtime-benchmarks")] +mod benches { + frame_benchmarking::define_benchmarks!( + [frame_system, SystemBench::] + [pallet_dip_consumer, DipConsumer] + [pallet_relay_store, RelayStore] + ); +} + impl_runtime_apis! { impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> SlotDuration { @@ -501,4 +511,50 @@ impl_runtime_apis! { ParachainSystem::collect_collation_info(header) } } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + + let mut list = Vec::::new(); + list_benchmarks!(list, extra); + + let storage_info = AllPalletsWithSystem::storage_info(); + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig + ) -> Result, sp_runtime::RuntimeString> { + use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch}; + + use frame_system_benchmarking::Pallet as SystemBench; + impl frame_system_benchmarking::Config for Runtime { + fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); + Ok(()) + } + + fn verify_set_code() { + System::assert_last_event(cumulus_pallet_parachain_system::Event::::ValidationFunctionStored.into()); + } + } + + use frame_support::traits::WhitelistedStorageKeys; + let whitelist = AllPalletsWithSystem::whitelisted_storage_keys(); + + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + add_benchmarks!(params, batches); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } } diff --git a/dip-template/runtimes/dip-consumer/src/origin_adapter.rs b/dip-template/runtimes/dip-consumer/src/origin_adapter.rs index d973367b3..ebde676e7 100644 --- a/dip-template/runtimes/dip-consumer/src/origin_adapter.rs +++ b/dip-template/runtimes/dip-consumer/src/origin_adapter.rs @@ -35,8 +35,7 @@ impl EnsureOrigin for EnsureDipOriginAdapter { #[cfg(feature = "runtime-benchmarks")] fn try_successful_origin() -> Result { - // TODO: Replace with actual DIP origin upon benchmarking - Ok(RuntimeOrigin::root()) + EnsureDipOrigin::::try_successful_origin() } } diff --git a/dip-template/runtimes/dip-consumer/src/weights/frame_system.rs b/dip-template/runtimes/dip-consumer/src/weights/frame_system.rs new file mode 100644 index 000000000..3c04d0f21 --- /dev/null +++ b/dip-template/runtimes/dip-consumer/src/weights/frame_system.rs @@ -0,0 +1,193 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `frame_system` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-consumer-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=frame-system +// --extrinsic=* +// --output=./dip-template/runtimes/dip-consumer/src/weights/frame_system.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `frame_system`. +pub struct WeightInfo(PhantomData); +impl frame_system::WeightInfo for WeightInfo { + /// The range of component `b` is `[0, 3932160]`. + fn remark(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_378_000 picoseconds. + Weight::from_parts(90_413_067, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 3 + .saturating_add(Weight::from_parts(196, 0).saturating_mul(b.into())) + } + /// The range of component `b` is `[0, 3932160]`. + fn remark_with_event(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_818_000 picoseconds. + Weight::from_parts(4_882_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 15 + .saturating_add(Weight::from_parts(1_874, 0).saturating_mul(b.into())) + } + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + /// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + fn set_heap_pages() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 5_882_000 picoseconds. + Weight::from_parts(6_631_000, 0) + .saturating_add(Weight::from_parts(0, 1485)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpgradeRestrictionSignal` (r:1 w:0) + /// Proof: `ParachainSystem::UpgradeRestrictionSignal` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingValidationCode` (r:1 w:1) + /// Proof: `ParachainSystem::PendingValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::NewValidationCode` (r:0 w:1) + /// Proof: `ParachainSystem::NewValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::DidSetValidationCode` (r:0 w:1) + /// Proof: `ParachainSystem::DidSetValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn set_code() -> Weight { + // Proof Size summary in bytes: + // Measured: `119` + // Estimated: `1604` + // Minimum execution time: 141_893_625_000 picoseconds. + Weight::from_parts(162_618_687_000, 0) + .saturating_add(Weight::from_parts(0, 1604)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `i` is `[0, 1000]`. + fn set_storage(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_512_000 picoseconds. + Weight::from_parts(2_972_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 7_153 + .saturating_add(Weight::from_parts(1_100_784, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `i` is `[0, 1000]`. + fn kill_storage(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_526_000 picoseconds. + Weight::from_parts(67_203_020, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 8_216 + .saturating_add(Weight::from_parts(391_130, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[0, 1000]`. + fn kill_prefix(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `73 + p * (69 ±0)` + // Estimated: `66 + p * (70 ±0)` + // Minimum execution time: 2_821_000 picoseconds. + Weight::from_parts(9_760_367, 0) + .saturating_add(Weight::from_parts(0, 66)) + // Standard Error: 14_170 + .saturating_add(Weight::from_parts(886_262, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_set_heap_pages() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 1485 + ); + } + #[test] + fn test_set_code() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 1604 + ); + } + #[test] + fn test_kill_prefix() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 66 + ); + } +} diff --git a/dip-template/runtimes/dip-consumer/src/weights/mod.rs b/dip-template/runtimes/dip-consumer/src/weights/mod.rs new file mode 100644 index 000000000..a0fbf6b5f --- /dev/null +++ b/dip-template/runtimes/dip-consumer/src/weights/mod.rs @@ -0,0 +1,21 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +pub mod frame_system; +pub mod pallet_dip_consumer; +pub mod pallet_relay_store; diff --git a/dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs b/dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs new file mode 100644 index 000000000..625c63b1c --- /dev/null +++ b/dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs @@ -0,0 +1,83 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_dip_consumer` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-consumer-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-dip-consumer +// --extrinsic=* +// --output=./dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_dip_consumer`. +pub struct WeightInfo(PhantomData); +impl pallet_dip_consumer::WeightInfo for WeightInfo { + /// Storage: `DipConsumer::IdentityEntries` (r:1 w:1) + /// Proof: `DipConsumer::IdentityEntries` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + /// Storage: `RelayStore::LatestRelayHeads` (r:1 w:0) + /// Proof: `RelayStore::LatestRelayHeads` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `System::BlockHash` (r:1 w:0) + /// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + fn dispatch_as() -> Weight { + // Proof Size summary in bytes: + // Measured: `66` + // Estimated: `3521` + // Minimum execution time: 88_110_000 picoseconds. + Weight::from_parts(89_742_000, 0) + .saturating_add(Weight::from_parts(0, 3521)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_dispatch_as() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3521 + ); + } +} diff --git a/dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs b/dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs new file mode 100644 index 000000000..ae8300999 --- /dev/null +++ b/dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs @@ -0,0 +1,83 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_relay_store` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-consumer-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-relay-store +// --extrinsic=* +// --output=./dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_relay_store`. +pub struct WeightInfo(PhantomData); +impl pallet_relay_store::WeightInfo for WeightInfo { + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `RelayStore::LatestBlockHeights` (r:1 w:1) + /// Proof: `RelayStore::LatestBlockHeights` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `RelayStore::LatestRelayHeads` (r:0 w:2) + /// Proof: `RelayStore::LatestRelayHeads` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + fn on_finalize() -> Weight { + // Proof Size summary in bytes: + // Measured: `540` + // Estimated: `2025` + // Minimum execution time: 9_067_000 picoseconds. + Weight::from_parts(9_467_000, 0) + .saturating_add(Weight::from_parts(0, 2025)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_on_finalize() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 2025 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/Cargo.toml b/dip-template/runtimes/dip-provider/Cargo.toml index 58db10759..d1f7c7bcd 100644 --- a/dip-template/runtimes/dip-provider/Cargo.toml +++ b/dip-template/runtimes/dip-provider/Cargo.toml @@ -55,6 +55,7 @@ sp-session.workspace = true sp-std.workspace = true sp-transaction-pool.workspace = true sp-version.workspace = true +sp-weights.workspace = true # Cumulus cumulus-pallet-aura-ext.workspace = true @@ -66,6 +67,11 @@ cumulus-primitives-utility.workspace = true pallet-collator-selection.workspace = true parachain-info.workspace = true +# Benchmarks +frame-benchmarking = {workspace = true, optional = true} +frame-system-benchmarking = {workspace = true, optional = true} +hex-literal = {workspace = true, optional = true} + [features] default = [ "std", @@ -108,6 +114,7 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", + "sp-weights/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", @@ -115,16 +122,26 @@ std = [ "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", "pallet-collator-selection/std", - "parachain-info/std" + "parachain-info/std", + "frame-benchmarking?/std", ] runtime-benchmarks = [ "did/runtime-benchmarks", "kilt-dip-support/runtime-benchmarks", + "pallet-deposit-storage/runtime-benchmarks", "pallet-did-lookup/runtime-benchmarks", "pallet-dip-provider/runtime-benchmarks", "pallet-web3-names/runtime-benchmarks", "runtime-common/runtime-benchmarks", "frame-system/runtime-benchmarks", "frame-support/runtime-benchmarks", - "pallet-utility/runtime-benchmarks" + "pallet-balances/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "hex-literal" ] diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index 91c52a8c1..66f8ee88e 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -31,9 +31,11 @@ use sp_std::vec::Vec; use crate::{ deposit::{DepositHooks, DepositNamespaces}, - AccountId, Balances, DidIdentifier, Runtime, RuntimeEvent, RuntimeHoldReason, + weights, AccountId, Balances, DidIdentifier, Runtime, RuntimeEvent, RuntimeHoldReason, }; +const MAX_LINKED_ACCOUNTS: u32 = 20; + pub mod runtime_api { use super::*; @@ -60,7 +62,8 @@ pub mod deposit { use frame_support::traits::Get; use pallet_deposit_storage::{ - traits::DepositStorageHooks, DepositEntryOf, DepositKeyOf, FixedDepositCollectorViaDepositsPallet, + traits::{BenchmarkHooks, DepositStorageHooks}, + DepositEntryOf, DepositKeyOf, FixedDepositCollectorViaDepositsPallet, }; use parity_scale_codec::MaxEncodedLen; use sp_core::{ConstU128, RuntimeDebug}; @@ -123,9 +126,52 @@ pub mod deposit { Ok(()) } } + + #[cfg(feature = "runtime-benchmarks")] + pub struct PalletDepositStorageBenchmarkHooks; + + #[cfg(feature = "runtime-benchmarks")] + impl BenchmarkHooks for PalletDepositStorageBenchmarkHooks { + fn pre_reclaim_deposit() -> ( + ::AccountId, + ::Namespace, + sp_runtime::BoundedVec::MaxKeyLength>, + ) { + let submitter = AccountId::from([100u8; 32]); + let namespace = DepositNamespaces::DipProvider; + let did_identifier = DidIdentifier::from([200u8; 32]); + let commitment_version = 0u16; + let key: DepositKeyOf = (did_identifier.clone(), 0) + .encode() + .try_into() + .expect("Should not fail to create a key for a DIP commitment."); + + pallet_dip_provider::IdentityCommitments::::insert( + &did_identifier, + commitment_version, + ::Hash::default(), + ); + + assert!( + pallet_dip_provider::IdentityCommitments::::get(did_identifier, commitment_version).is_some() + ); + + (submitter, namespace, key) + } + + fn post_reclaim_deposit() { + let did_identifier = DidIdentifier::from([200u8; 32]); + let commitment_version = 0u16; + assert!( + pallet_dip_provider::IdentityCommitments::::get(did_identifier, commitment_version).is_none() + ); + } + } } impl pallet_deposit_storage::Config for Runtime { + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks = deposit::PalletDepositStorageBenchmarkHooks; type CheckOrigin = EnsureSigned; type Currency = Balances; type DepositHooks = DepositHooks; @@ -133,6 +179,7 @@ impl pallet_deposit_storage::Config for Runtime { type Namespace = DepositNamespaces; type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; + type WeightInfo = weights::pallet_deposit_storage::WeightInfo; } impl pallet_dip_provider::Config for Runtime { @@ -140,7 +187,8 @@ impl pallet_dip_provider::Config for Runtime { type CommitOrigin = DidRawOrigin; type Identifier = DidIdentifier; type IdentityCommitmentGenerator = DidMerkleRootGenerator; - type IdentityProvider = LinkedDidInfoProvider; + type IdentityProvider = LinkedDidInfoProvider; type ProviderHooks = deposit::DepositCollectorHooks; type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_dip_provider::WeightInfo; } diff --git a/dip-template/runtimes/dip-provider/src/lib.rs b/dip-template/runtimes/dip-provider/src/lib.rs index a0f474b81..90e96c9a9 100644 --- a/dip-template/runtimes/dip-provider/src/lib.rs +++ b/dip-template/runtimes/dip-provider/src/lib.rs @@ -76,6 +76,7 @@ pub use sp_runtime::BuildStorage; use sp_version::NativeVersion; mod dip; +mod weights; pub use crate::dip::*; pub type AccountId = AccountId32; @@ -240,7 +241,7 @@ impl frame_system::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; type SS58Prefix = ConstU16; - type SystemWeightInfo = (); + type SystemWeightInfo = weights::frame_system::WeightInfo; type Version = Version; } @@ -401,7 +402,7 @@ impl did::Config for Runtime { type RuntimeHoldReason = RuntimeHoldReason; type RuntimeOrigin = RuntimeOrigin; type ServiceEndpointDeposit = ConstU128; - type WeightInfo = (); + type WeightInfo = weights::did::WeightInfo; } impl pallet_did_lookup::Config for Runtime { @@ -413,7 +414,7 @@ impl pallet_did_lookup::Config for Runtime { type OriginSuccess = DidRawOrigin; type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; - type WeightInfo = (); + type WeightInfo = weights::pallet_did_lookup::WeightInfo; } pub type Web3Name = AsciiWeb3Name; @@ -431,7 +432,19 @@ impl pallet_web3_names::Config for Runtime { type RuntimeHoldReason = RuntimeHoldReason; type Web3Name = Web3Name; type Web3NameOwner = DidIdentifier; - type WeightInfo = (); + type WeightInfo = weights::pallet_web3_names::WeightInfo; +} + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + frame_benchmarking::define_benchmarks!( + [frame_system, SystemBench::] + [did, Did] + [pallet_did_lookup, DidLookup] + [pallet_web3_names, Web3Names] + [pallet_deposit_storage, DepositStorage] + [pallet_dip_provider, DipProvider] + ); } impl_runtime_apis! { @@ -678,4 +691,50 @@ impl_runtime_apis! { DidMerkleRootGenerator::::generate_proof(&identity_details, request.version, request.keys.iter(), request.should_include_web3_name, request.accounts.iter()).map_err(runtime_api::DipProofError::MerkleProof) } } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + + let mut list = Vec::::new(); + list_benchmarks!(list, extra); + + let storage_info = AllPalletsWithSystem::storage_info(); + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig + ) -> Result, sp_runtime::RuntimeString> { + use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch}; + + use frame_system_benchmarking::Pallet as SystemBench; + impl frame_system_benchmarking::Config for Runtime { + fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); + Ok(()) + } + + fn verify_set_code() { + System::assert_last_event(cumulus_pallet_parachain_system::Event::::ValidationFunctionStored.into()); + } + } + + use frame_support::traits::WhitelistedStorageKeys; + let whitelist = AllPalletsWithSystem::whitelisted_storage_keys(); + + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + add_benchmarks!(params, batches); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } } diff --git a/dip-template/runtimes/dip-provider/src/weights/did.rs b/dip-template/runtimes/dip-provider/src/weights/did.rs new file mode 100644 index 000000000..7557791b9 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/did.rs @@ -0,0 +1,1217 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `did` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=did +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/did.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `did`. +pub struct WeightInfo(PhantomData); +impl did::WeightInfo for WeightInfo { + /// Storage: Did DidBlacklist (r:1 w:0) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:0 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:0 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 10]`. + /// The range of component `c` is `[1, 25]`. + fn create_ed25519_keys(n: u32, c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1131` + // Estimated: `6204` + // Minimum execution time: 179_404_000 picoseconds. + Weight::from_parts(170_230_985, 0) + .saturating_add(Weight::from_parts(0, 6204)) + // Standard Error: 40_649 + .saturating_add(Weight::from_parts(296_994, 0).saturating_mul(n.into())) + // Standard Error: 15_716 + .saturating_add(Weight::from_parts(10_509_026, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + } + /// Storage: Did DidBlacklist (r:1 w:0) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:0 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:0 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 10]`. + /// The range of component `c` is `[1, 25]`. + fn create_sr25519_keys(n: u32, c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1131` + // Estimated: `6204` + // Minimum execution time: 181_049_000 picoseconds. + Weight::from_parts(161_298_980, 0) + .saturating_add(Weight::from_parts(0, 6204)) + // Standard Error: 36_193 + .saturating_add(Weight::from_parts(1_411_802, 0).saturating_mul(n.into())) + // Standard Error: 13_993 + .saturating_add(Weight::from_parts(11_432_937, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + } + /// Storage: Did DidBlacklist (r:1 w:0) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:0 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:0 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 10]`. + /// The range of component `c` is `[1, 25]`. + fn create_ecdsa_keys(n: u32, c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1131` + // Estimated: `6204` + // Minimum execution time: 164_997_000 picoseconds. + Weight::from_parts(143_724_779, 0) + .saturating_add(Weight::from_parts(0, 6204)) + // Standard Error: 46_012 + .saturating_add(Weight::from_parts(1_689_629, 0).saturating_mul(n.into())) + // Standard Error: 17_790 + .saturating_add(Weight::from_parts(9_993_575, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + } + /// Storage: Did DidEndpointsCount (r:1 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:25 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Did DidBlacklist (r:0 w:1) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// The range of component `c` is `[1, 25]`. + fn delete(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `969 + c * (105 ±0)` + // Estimated: `5777 + c * (3090 ±0)` + // Minimum execution time: 53_190_000 picoseconds. + Weight::from_parts(54_199_033, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 4_988 + .saturating_add(Weight::from_parts(1_376_408, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 3090).saturating_mul(c.into())) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:25 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Did DidBlacklist (r:0 w:1) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// The range of component `c` is `[1, 25]`. + fn reclaim_deposit(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `969 + c * (105 ±0)` + // Estimated: `5777 + c * (3090 ±0)` + // Minimum execution time: 55_729_000 picoseconds. + Weight::from_parts(56_557_707, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 4_643 + .saturating_add(Weight::from_parts(1_397_138, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 3090).saturating_mul(c.into())) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + fn submit_did_call_ed25519_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `352` + // Estimated: `5777` + // Minimum execution time: 76_132_000 picoseconds. + Weight::from_parts(76_814_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + fn submit_did_call_sr25519_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `352` + // Estimated: `5777` + // Minimum execution time: 77_295_000 picoseconds. + Weight::from_parts(78_438_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + fn submit_did_call_ecdsa_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `353` + // Estimated: `5777` + // Minimum execution time: 64_288_000 picoseconds. + Weight::from_parts(65_482_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ed25519_authentication_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2170` + // Estimated: `5777` + // Minimum execution time: 67_708_000 picoseconds. + Weight::from_parts(70_147_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_sr25519_authentication_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2170` + // Estimated: `5777` + // Minimum execution time: 68_784_000 picoseconds. + Weight::from_parts(70_860_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ecdsa_authentication_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2107` + // Estimated: `5777` + // Minimum execution time: 68_261_000 picoseconds. + Weight::from_parts(69_565_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ed25519_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2038` + // Estimated: `5777` + // Minimum execution time: 67_556_000 picoseconds. + Weight::from_parts(69_662_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_sr25519_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2165` + // Estimated: `5777` + // Minimum execution time: 67_837_000 picoseconds. + Weight::from_parts(69_180_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ecdsa_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2173` + // Estimated: `5777` + // Minimum execution time: 68_540_000 picoseconds. + Weight::from_parts(69_956_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ed25519_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2104` + // Estimated: `5777` + // Minimum execution time: 65_127_000 picoseconds. + Weight::from_parts(66_929_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_sr25519_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2104` + // Estimated: `5777` + // Minimum execution time: 64_797_000 picoseconds. + Weight::from_parts(65_517_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ecdsa_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2173` + // Estimated: `5777` + // Minimum execution time: 65_807_000 picoseconds. + Weight::from_parts(67_122_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ed25519_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2105` + // Estimated: `5777` + // Minimum execution time: 68_688_000 picoseconds. + Weight::from_parts(69_835_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_sr25519_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2137` + // Estimated: `5777` + // Minimum execution time: 67_241_000 picoseconds. + Weight::from_parts(68_767_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ecdsa_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2177` + // Estimated: `5777` + // Minimum execution time: 66_623_000 picoseconds. + Weight::from_parts(68_381_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ed25519_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2137` + // Estimated: `5777` + // Minimum execution time: 64_750_000 picoseconds. + Weight::from_parts(67_215_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_sr25519_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2132` + // Estimated: `5777` + // Minimum execution time: 65_858_000 picoseconds. + Weight::from_parts(67_393_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ecdsa_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2112` + // Estimated: `5777` + // Minimum execution time: 64_552_000 picoseconds. + Weight::from_parts(66_076_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn add_ed25519_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2026` + // Estimated: `5777` + // Minimum execution time: 67_691_000 picoseconds. + Weight::from_parts(69_179_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn add_sr25519_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `1966` + // Estimated: `5777` + // Minimum execution time: 67_454_000 picoseconds. + Weight::from_parts(69_136_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn add_ecdsa_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2062` + // Estimated: `5777` + // Minimum execution time: 66_065_000 picoseconds. + Weight::from_parts(68_090_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ed25519_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2104` + // Estimated: `5777` + // Minimum execution time: 64_706_000 picoseconds. + Weight::from_parts(67_009_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_sr25519_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2170` + // Estimated: `5777` + // Minimum execution time: 65_290_000 picoseconds. + Weight::from_parts(67_110_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ecdsa_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2107` + // Estimated: `5777` + // Minimum execution time: 65_011_000 picoseconds. + Weight::from_parts(67_020_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:1 w:1) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn add_service_endpoint() -> Weight { + // Proof Size summary in bytes: + // Measured: `1504` + // Estimated: `5777` + // Minimum execution time: 75_496_000 picoseconds. + Weight::from_parts(76_809_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:1 w:1) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_service_endpoint() -> Weight { + // Proof Size summary in bytes: + // Measured: `2154` + // Estimated: `5777` + // Minimum execution time: 74_014_000 picoseconds. + Weight::from_parts(75_355_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Did Did (r:1 w:0) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// The range of component `l` is `[1, 5242880]`. + fn signature_verification_sr25519(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1626` + // Estimated: `5777` + // Minimum execution time: 63_042_000 picoseconds. + Weight::from_parts(41_623_028, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(4_301, 0).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: Did Did (r:1 w:0) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// The range of component `l` is `[1, 5242880]`. + fn signature_verification_ed25519(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1626` + // Estimated: `5777` + // Minimum execution time: 61_831_000 picoseconds. + Weight::from_parts(38_865_643, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(2_522, 0).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: Did Did (r:1 w:0) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// The range of component `l` is `[1, 5242880]`. + fn signature_verification_ecdsa(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1627` + // Estimated: `5777` + // Minimum execution time: 50_295_000 picoseconds. + Weight::from_parts(27_300_442, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1_153, 0).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn change_deposit_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `822` + // Estimated: `5777` + // Minimum execution time: 73_863_000 picoseconds. + Weight::from_parts(76_051_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn update_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `888` + // Estimated: `5777` + // Minimum execution time: 45_375_000 picoseconds. + Weight::from_parts(46_464_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + + /// Storage: Did Did (r:1 w:0) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + fn dispatch_as() -> Weight { + // Proof Size summary in bytes: + // Measured: `353` + // Estimated: `5777` + // Minimum execution time: 186_836_000 picoseconds. + Weight::from_parts(189_377_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: Did DidBlacklist (r:1 w:0) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn create_from_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `999` + // Estimated: `6204` + // Minimum execution time: 1_008_739_000 picoseconds. + Weight::from_parts(1_020_810_000, 0) + .saturating_add(Weight::from_parts(0, 6204)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_create_ed25519_keys() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } + #[test] + fn test_create_sr25519_keys() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } + #[test] + fn test_create_ecdsa_keys() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } + #[test] + fn test_delete() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_reclaim_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_submit_did_call_ed25519_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_submit_did_call_sr25519_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_submit_did_call_ecdsa_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ed25519_authentication_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_sr25519_authentication_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ecdsa_authentication_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ed25519_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_sr25519_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ecdsa_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ed25519_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_sr25519_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ecdsa_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ed25519_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_sr25519_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ecdsa_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ed25519_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_sr25519_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ecdsa_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_add_ed25519_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_add_sr25519_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_add_ecdsa_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ed25519_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_sr25519_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ecdsa_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_add_service_endpoint() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_service_endpoint() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_signature_verification_sr25519() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_signature_verification_ed25519() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_signature_verification_ecdsa() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_change_deposit_owner() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_update_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + + #[test] + fn test_dispatch_as() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_create_from_account() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/frame_system.rs b/dip-template/runtimes/dip-provider/src/weights/frame_system.rs new file mode 100644 index 000000000..3e821789c --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/frame_system.rs @@ -0,0 +1,193 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `frame_system` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=frame-system +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/frame_system.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `frame_system`. +pub struct WeightInfo(PhantomData); +impl frame_system::WeightInfo for WeightInfo { + /// The range of component `b` is `[0, 3932160]`. + fn remark(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_320_000 picoseconds. + Weight::from_parts(1_367_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(223, 0).saturating_mul(b.into())) + } + /// The range of component `b` is `[0, 3932160]`. + fn remark_with_event(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_819_000 picoseconds. + Weight::from_parts(4_960_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 1 + .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(b.into())) + } + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + /// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + fn set_heap_pages() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 2_633_000 picoseconds. + Weight::from_parts(2_766_000, 0) + .saturating_add(Weight::from_parts(0, 1485)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpgradeRestrictionSignal` (r:1 w:0) + /// Proof: `ParachainSystem::UpgradeRestrictionSignal` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingValidationCode` (r:1 w:1) + /// Proof: `ParachainSystem::PendingValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::NewValidationCode` (r:0 w:1) + /// Proof: `ParachainSystem::NewValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::DidSetValidationCode` (r:0 w:1) + /// Proof: `ParachainSystem::DidSetValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn set_code() -> Weight { + // Proof Size summary in bytes: + // Measured: `119` + // Estimated: `1604` + // Minimum execution time: 89_656_515_000 picoseconds. + Weight::from_parts(92_710_625_000, 0) + .saturating_add(Weight::from_parts(0, 1604)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `i` is `[0, 1000]`. + fn set_storage(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_379_000 picoseconds. + Weight::from_parts(1_438_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 1_236 + .saturating_add(Weight::from_parts(591_504, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `i` is `[0, 1000]`. + fn kill_storage(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_377_000 picoseconds. + Weight::from_parts(1_419_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 526 + .saturating_add(Weight::from_parts(413_184, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[0, 1000]`. + fn kill_prefix(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `64 + p * (69 ±0)` + // Estimated: `65 + p * (70 ±0)` + // Minimum execution time: 2_657_000 picoseconds. + Weight::from_parts(2_737_000, 0) + .saturating_add(Weight::from_parts(0, 65)) + // Standard Error: 793 + .saturating_add(Weight::from_parts(806_524, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_set_heap_pages() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 1485 + ); + } + #[test] + fn test_set_code() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 1604 + ); + } + #[test] + fn test_kill_prefix() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 65 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/mod.rs b/dip-template/runtimes/dip-provider/src/weights/mod.rs new file mode 100644 index 000000000..22be9a259 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/mod.rs @@ -0,0 +1,24 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +pub mod did; +pub mod frame_system; +pub mod pallet_deposit_storage; +pub mod pallet_did_lookup; +pub mod pallet_dip_provider; +pub mod pallet_web3_names; diff --git a/dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs b/dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs new file mode 100644 index 000000000..e675d6ec0 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs @@ -0,0 +1,85 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_deposit_storage` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-deposit-storage +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_deposit_storage`. +pub struct WeightInfo(PhantomData); +impl pallet_deposit_storage::WeightInfo for WeightInfo { + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(325), added: 2800, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + fn reclaim_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `443` + // Estimated: `4414` + // Minimum execution time: 39_267_000 picoseconds. + Weight::from_parts(39_811_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_reclaim_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs b/dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs new file mode 100644 index 000000000..4a9366ad6 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs @@ -0,0 +1,321 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_did_lookup` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-did-lookup +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_did_lookup`. +pub struct WeightInfo(PhantomData); +impl pallet_did_lookup::WeightInfo for WeightInfo { + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_account_multisig_sr25519() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 115_816_000 picoseconds. + Weight::from_parts(150_087_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_account_multisig_ed25519() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 119_599_000 picoseconds. + Weight::from_parts(175_393_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_account_multisig_ecdsa() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 119_023_000 picoseconds. + Weight::from_parts(176_847_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_eth_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `377` + // Estimated: `4414` + // Minimum execution time: 115_485_000 picoseconds. + Weight::from_parts(170_435_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_sender() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 70_488_000 picoseconds. + Weight::from_parts(75_207_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:1) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn remove_sender_association() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 37_873_000 picoseconds. + Weight::from_parts(40_493_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:1) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn remove_account_association() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 38_071_000 picoseconds. + Weight::from_parts(39_343_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:2 w:2) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn change_deposit_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `493` + // Estimated: `7838` + // Minimum execution time: 64_007_000 picoseconds. + Weight::from_parts(66_141_000, 0) + .saturating_add(Weight::from_parts(0, 7838)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn update_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 58_458_000 picoseconds. + Weight::from_parts(59_907_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_associate_account_multisig_sr25519() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_associate_account_multisig_ed25519() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_associate_account_multisig_ecdsa() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_associate_eth_account() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_associate_sender() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_remove_sender_association() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_remove_account_association() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_change_deposit_owner() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 7838 + ); + } + #[test] + fn test_update_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs b/dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs new file mode 100644 index 000000000..ad46d99eb --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs @@ -0,0 +1,125 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_dip_provider` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-dip-provider +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_dip_provider`. +pub struct WeightInfo(PhantomData); +impl pallet_dip_provider::WeightInfo for WeightInfo { + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(1447), added: 3922, mode: `MaxEncodedLen`) + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:21 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(325), added: 2800, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn commit_identity() -> Weight { + // Proof Size summary in bytes: + // Measured: `3190` + // Estimated: `55002` + // Minimum execution time: 236_589_000 picoseconds. + Weight::from_parts(266_691_000, 0) + .saturating_add(Weight::from_parts(0, 55002)) + .saturating_add(T::DbWeight::get().reads(29)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(325), added: 2800, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn delete_identity_commitment() -> Weight { + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `4414` + // Minimum execution time: 51_471_000 picoseconds. + Weight::from_parts(56_814_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_commit_identity() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 55002 + ); + } + #[test] + fn test_delete_identity_commitment() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs b/dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs new file mode 100644 index 000000000..e489a91e5 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs @@ -0,0 +1,265 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_web3_names` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-web3-names +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_web3_names`. +pub struct WeightInfo(PhantomData); +impl pallet_web3_names::WeightInfo for WeightInfo { + /// Storage: `Web3Names::Names` (r:1 w:1) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Banned` (r:1 w:0) + /// Proof: `Web3Names::Banned` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// The range of component `n` is `[3, 32]`. + fn claim(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `107` + // Estimated: `4414` + // Minimum execution time: 113_246_000 picoseconds. + Weight::from_parts(132_782_588, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Web3Names::Names` (r:1 w:1) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn release_by_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `428` + // Estimated: `4414` + // Minimum execution time: 101_512_000 picoseconds. + Weight::from_parts(111_009_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:0 w:1) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// The range of component `n` is `[3, 32]`. + fn reclaim_deposit(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `324 + n * (1 ±0)` + // Estimated: `4414` + // Minimum execution time: 36_756_000 picoseconds. + Weight::from_parts(94_263_229, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Web3Names::Banned` (r:1 w:1) + /// Proof: `Web3Names::Banned` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:0 w:1) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// The range of component `n` is `[3, 32]`. + fn ban(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `324 + n * (1 ±0)` + // Estimated: `4414` + // Minimum execution time: 36_341_000 picoseconds. + Weight::from_parts(44_569_163, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `Web3Names::Banned` (r:1 w:1) + /// Proof: `Web3Names::Banned` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// The range of component `n` is `[3, 32]`. + fn unban(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `47 + n * (1 ±0)` + // Estimated: `3514` + // Minimum execution time: 8_620_000 picoseconds. + Weight::from_parts(9_336_817, 0) + .saturating_add(Weight::from_parts(0, 3514)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:2 w:2) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn change_deposit_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `531` + // Estimated: `7838` + // Minimum execution time: 60_074_000 picoseconds. + Weight::from_parts(61_305_000, 0) + .saturating_add(Weight::from_parts(0, 7838)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn update_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `357` + // Estimated: `4414` + // Minimum execution time: 55_049_000 picoseconds. + Weight::from_parts(55_580_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_claim() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_release_by_owner() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_reclaim_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_ban() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_unban() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3514 + ); + } + #[test] + fn test_change_deposit_owner() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 7838 + ); + } + #[test] + fn test_update_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/pallets/ctype/src/lib.rs b/pallets/ctype/src/lib.rs index a4c27d8f6..5936cd558 100644 --- a/pallets/ctype/src/lib.rs +++ b/pallets/ctype/src/lib.rs @@ -94,7 +94,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type EnsureOrigin: EnsureOrigin<::RuntimeOrigin, Success = Self::OriginSuccess>; + type EnsureOrigin: EnsureOrigin; type OverarchingOrigin: EnsureOrigin<::RuntimeOrigin>; type OriginSuccess: CallSources, CtypeCreatorOf>; type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/pallets/did/src/did_details.rs b/pallets/did/src/did_details.rs index f7046b6ae..586f41525 100644 --- a/pallets/did/src/did_details.rs +++ b/pallets/did/src/did_details.rs @@ -191,6 +191,13 @@ impl From for DidSignature { } } +#[cfg(feature = "runtime-benchmarks")] +impl kilt_support::traits::GetWorstCase for DidSignature { + fn worst_case(_context: Context) -> Self { + Self::Sr25519(sp_core::sr25519::Signature::from_raw([0u8; 64])) + } +} + pub trait DidVerifiableIdentifier { /// Allows a verifiable identifier to verify a signature it produces and /// return the public key diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index 914806a69..21f4ca165 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -1,30 +1,38 @@ [package] authors.workspace = true +description = "Stores all deposits under a single pallet, with suport for namespacing different deposit contexts." documentation.workspace = true edition.workspace = true homepage.workspace = true license-file.workspace = true +name = "pallet-deposit-storage" readme.workspace = true repository.workspace = true version.workspace = true -name = "pallet-deposit-storage" -description = "Stores all deposits under a single pallet, with suport for namespacing different deposit contexts." [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[dev-dependencies] +pallet-balances = {workspace = true, features = ["std"]} +sp-io = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} + [dependencies] # Substrate dependencies frame-support.workspace = true frame-system.workspace = true kilt-support.workspace = true +log.workspace = true pallet-dip-provider.workspace = true parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} sp-runtime.workspace = true sp-std.workspace = true -log.workspace = true +# Benchmarking +frame-benchmarking = {workspace = true, optional = true} +pallet-balances = {workspace = true, optional = true} [features] default = ["std"] @@ -32,10 +40,22 @@ std = [ "frame-support/std", "frame-system/std", "kilt-support/std", + "log/std", "pallet-dip-provider/std", "parity-scale-codec/std", "scale-info/std", "sp-runtime/std", "sp-std/std", - "log/std", + "frame-benchmarking?/std", + "pallet-balances?/std", +] + +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "kilt-support/runtime-benchmarks", + "pallet-dip-provider/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", ] diff --git a/pallets/pallet-deposit-storage/src/benchmarking.rs b/pallets/pallet-deposit-storage/src/benchmarking.rs new file mode 100644 index 000000000..eb69d6a6f --- /dev/null +++ b/pallets/pallet-deposit-storage/src/benchmarking.rs @@ -0,0 +1,85 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_benchmarking::v2::*; + +#[benchmarks( + where + T: Config + pallet_balances::Config, +)] +mod benchmarks { + use frame_support::traits::fungible::Mutate; + use frame_system::RawOrigin; + use kilt_support::Deposit; + use sp_runtime::SaturatedConversion; + + use crate::{traits::BenchmarkHooks, Call, Config, DepositEntryOf, Deposits, HoldReason, Pallet}; + + use super::*; + + const KILT: u128 = 10u128.pow(15); + + #[benchmark] + fn reclaim_deposit() { + let (submitter, namespace, key) = T::BenchmarkHooks::pre_reclaim_deposit(); + + assert!(Deposits::::get(&namespace, &key).is_none()); + + let entry = DepositEntryOf:: { + deposit: Deposit { + amount: KILT.saturated_into(), + owner: submitter.clone(), + }, + reason: ::RuntimeHoldReason::from(HoldReason::Deposit), + }; + + let amount = KILT * 100; + + as Mutate<::AccountId>>::set_balance( + &submitter, + amount.saturated_into(), + ); + + Pallet::::add_deposit(namespace.clone(), key.clone(), entry).expect("Creating Deposit should not fail."); + + assert!(Deposits::::get(&namespace, &key).is_some()); + + let origin = RawOrigin::Signed(submitter); + let cloned_namespace = namespace.clone(); + let cloned_key = key.clone(); + + #[extrinsic_call] + Pallet::::reclaim_deposit(origin, cloned_namespace, cloned_key); + + assert!(Deposits::::get(&namespace, &key).is_none()); + + T::BenchmarkHooks::post_reclaim_deposit(); + } + + #[cfg(test)] + mod benchmarks_tests { + use crate::Pallet; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!( + Pallet, + crate::mock::ExtBuilder::default().build_with_keystore(), + crate::mock::TestRuntime, + ); + } +} diff --git a/pallets/pallet-deposit-storage/src/default_weights.rs b/pallets/pallet-deposit-storage/src/default_weights.rs new file mode 100644 index 000000000..6d0618067 --- /dev/null +++ b/pallets/pallet-deposit-storage/src/default_weights.rs @@ -0,0 +1,73 @@ + +//! Autogenerated weights for pallet_deposit_storage +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-11-24 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/debug/kilt-parachain +// benchmark +// pallet +// --pallet +// pallet-deposit-storage +// --extrinsic +// * +// --template +// ./.maintain/weight-template.hbs +// --output +// ./pallets/pallet-deposit-storage/src/defaul_weights.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_deposit_storage. +pub trait WeightInfo { + fn reclaim_deposit() -> Weight; +} + +/// Weights for pallet_deposit_storage using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `StorageDeposit::Deposits` (r:1 w:1) + /// Proof: `StorageDeposit::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn reclaim_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `907` + // Estimated: `4414` + // Minimum execution time: 704_964 nanoseconds. + Weight::from_parts(1_003_107_000, 4414) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `StorageDeposit::Deposits` (r:1 w:1) + /// Proof: `StorageDeposit::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn reclaim_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `907` + // Estimated: `4414` + // Minimum execution time: 704_964 nanoseconds. + Weight::from_parts(1_003_107_000, 4414) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } +} diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index e683b27ea..eeca637f5 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -19,16 +19,25 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] +mod default_weights; mod deposit; pub mod traits; -pub use deposit::FixedDepositCollectorViaDepositsPallet; -pub use pallet::*; -pub use traits::NoopDepositStorageHooks; +#[cfg(test)] +mod mock; -#[frame_support::pallet(dev_mode)] +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + +pub use crate::{ + default_weights::WeightInfo, deposit::FixedDepositCollectorViaDepositsPallet, pallet::*, + traits::NoopDepositStorageHooks, +}; + +#[frame_support::pallet] pub mod pallet { use crate::{ + default_weights::WeightInfo, deposit::{free_deposit, reserve_deposit, DepositEntry}, traits::DepositStorageHooks, }; @@ -61,12 +70,15 @@ pub mod pallet { #[pallet::constant] type MaxKeyLength: Get; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks: crate::traits::BenchmarkHooks; type CheckOrigin: EnsureOrigin; type Currency: Mutate; type DepositHooks: DepositStorageHooks; - type Namespace: Parameter; + type Namespace: Parameter + MaxEncodedLen; type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeHoldReason: From + Clone + PartialEq + Debug + FullCodec + MaxEncodedLen + TypeInfo; + type WeightInfo: WeightInfo; } #[pallet::composite_enum] @@ -110,8 +122,9 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - // TODO: Update weight - #[pallet::weight(0)] + #[pallet::weight({ + ::WeightInfo::reclaim_deposit() + })] pub fn reclaim_deposit(origin: OriginFor, namespace: T::Namespace, key: DepositKeyOf) -> DispatchResult { let dispatcher = T::CheckOrigin::ensure_origin(origin)?; diff --git a/pallets/pallet-deposit-storage/src/mock.rs b/pallets/pallet-deposit-storage/src/mock.rs new file mode 100644 index 000000000..f53c2ae31 --- /dev/null +++ b/pallets/pallet-deposit-storage/src/mock.rs @@ -0,0 +1,129 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + construct_runtime, parameter_types, + sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, IdentityLookup}, + AccountId32, + }, + traits::{ConstU16, ConstU32, ConstU64, Everything}, +}; +use frame_system::{mocking::MockBlock, EnsureSigned}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; +use sp_runtime::RuntimeDebug; + +use crate::{self as storage_deposit_pallet, NoopDepositStorageHooks}; + +pub(crate) type Balance = u128; + +#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Clone, PartialEq, Eq, RuntimeDebug, Default)] +pub enum DepositNamespaces { + #[default] + ExampleNameSpaces, +} + +construct_runtime!( + pub struct TestRuntime { + System: frame_system, + StorageDepositPallet: storage_deposit_pallet, + Balances: pallet_balances, + } +); + +impl frame_system::Config for TestRuntime { + type AccountData = pallet_balances::AccountData; + type AccountId = AccountId32; + type BaseCallFilter = Everything; + type Block = MockBlock; + type BlockHashCount = ConstU64<256>; + type BlockLength = (); + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Lookup = IdentityLookup; + type MaxConsumers = ConstU32<16>; + type Nonce = u64; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = (); + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = ConstU16<1>; + type SystemWeightInfo = (); + type Version = (); +} + +parameter_types! { + pub const ExistentialDeposit: Balance = 500; + pub const MaxLocks: u32 = 50; + pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; +} + +impl pallet_balances::Config for TestRuntime { + type FreezeIdentifier = RuntimeFreezeReason; + type RuntimeHoldReason = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; + type Balance = Balance; + type DustRemoval = (); + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); + type MaxLocks = MaxLocks; + type MaxReserves = MaxReserves; + type ReserveIdentifier = [u8; 8]; +} + +impl crate::Config for TestRuntime { + type CheckOrigin = EnsureSigned; + type Currency = Balances; + type DepositHooks = NoopDepositStorageHooks; + type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = RuntimeHoldReason; + type MaxKeyLength = ConstU32<256>; + type Namespace = DepositNamespaces; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks = (); + type WeightInfo = (); +} + +#[derive(Default)] +pub(crate) struct ExtBuilder; + +impl ExtBuilder { + pub fn _build(self) -> sp_io::TestExternalities { + sp_io::TestExternalities::default() + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn build_with_keystore(self) -> sp_io::TestExternalities { + let mut ext = self._build(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); + ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); + ext + } +} diff --git a/pallets/pallet-deposit-storage/src/traits.rs b/pallets/pallet-deposit-storage/src/traits.rs index f514eee10..b4e179937 100644 --- a/pallets/pallet-deposit-storage/src/traits.rs +++ b/pallets/pallet-deposit-storage/src/traits.rs @@ -47,3 +47,39 @@ where Ok(()) } } + +// Could be expanded to include traits to set up stuff before all benchmarks, +// and before each benchmark case specifically. +#[cfg(feature = "runtime-benchmarks")] +pub trait BenchmarkHooks +where + Runtime: Config, +{ + fn pre_reclaim_deposit() -> ( + Runtime::AccountId, + Runtime::Namespace, + sp_runtime::BoundedVec, + ); + fn post_reclaim_deposit(); +} + +#[cfg(feature = "runtime-benchmarks")] +impl BenchmarkHooks for () +where + Runtime: Config, + Runtime::AccountId: From<[u8; 32]>, + Runtime::Namespace: Default, +{ + fn pre_reclaim_deposit() -> ( + Runtime::AccountId, + Runtime::Namespace, + sp_runtime::BoundedVec, + ) { + ( + Runtime::AccountId::from([100u8; 32]), + Runtime::Namespace::default(), + sp_runtime::BoundedVec::default(), + ) + } + fn post_reclaim_deposit() {} +} diff --git a/pallets/pallet-dip-consumer/Cargo.toml b/pallets/pallet-dip-consumer/Cargo.toml index 5025ad90d..5217db045 100644 --- a/pallets/pallet-dip-consumer/Cargo.toml +++ b/pallets/pallet-dip-consumer/Cargo.toml @@ -13,6 +13,11 @@ version.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[dev-dependencies] +sp-io = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} +sp-runtime = {workspace = true, features = ["std"]} + [dependencies] frame-support.workspace = true frame-system.workspace = true @@ -22,18 +27,28 @@ scale-info = {workspace = true, features = ["derive"]} sp-core.workspace = true sp-std.workspace = true +# Benchmarks +frame-benchmarking = {workspace = true, optional = true} +sp-runtime = {workspace = true, optional = true} + [features] -default = ["std"] -std = [ - "frame-support/std", - "frame-system/std", - "kilt-support/std", - "parity-scale-codec/std", - "scale-info/std", - "sp-core/std", - "sp-std/std", -] +default = [ "std" ] + runtime-benchmarks = [ - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "kilt-support/runtime-benchmarks", + "frame-benchmarking", + "sp-runtime/runtime-benchmarks", +] +std = [ + "frame-support/std", + "frame-system/std", + "kilt-support/std", + "parity-scale-codec/std", + "scale-info/std", + "sp-core/std", + "sp-std/std", + "frame-benchmarking?/std", + "sp-runtime?/std", ] diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs new file mode 100644 index 000000000..78782b4d0 --- /dev/null +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -0,0 +1,85 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{traits::IdentityProofVerifier, Call, Config, IdentityEntries, Pallet}; +use frame_benchmarking::v2::*; +use frame_system::RawOrigin; +use kilt_support::{ + benchmark::IdentityContext, + traits::{GetWorstCase, Instanciate}, +}; + +#[benchmarks( + where + T::AccountId: Instanciate, + T::Identifier: Instanciate, + <::ProofVerifier as IdentityProofVerifier>::Proof: GetWorstCase>, + ::RuntimeCall: From>, +)] +mod benchmarks { + + use super::*; + + type IdentityContextOf = + IdentityContext<::Identifier, ::AccountId>; + + #[benchmark] + fn dispatch_as() { + let submitter = T::AccountId::new(1); + let subject = T::Identifier::new(1); + + let context = IdentityContext:: { + did: subject.clone(), + submitter: submitter.clone(), + }; + + assert!(IdentityEntries::::get(&subject).is_none()); + + let origin = RawOrigin::Signed(submitter); + + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![] }.into(); + + let boxed_call = Box::from(call); + + let proof = <<::ProofVerifier as IdentityProofVerifier>::Proof as GetWorstCase< + IdentityContextOf, + >>::worst_case(context); + + let origin = ::RuntimeOrigin::from(origin); + + #[extrinsic_call] + Pallet::::dispatch_as( + origin as ::RuntimeOrigin, + subject, + proof, + boxed_call, + ); + } + + #[cfg(test)] + mod benchmarks_tests { + use crate::Pallet; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!( + Pallet, + crate::mock::ExtBuilder::default().build_with_keystore(), + crate::mock::TestRuntime, + ); + } +} diff --git a/pallets/pallet-dip-consumer/src/default_weights.rs b/pallets/pallet-dip-consumer/src/default_weights.rs new file mode 100644 index 000000000..f425e7da3 --- /dev/null +++ b/pallets/pallet-dip-consumer/src/default_weights.rs @@ -0,0 +1,65 @@ + +//! Autogenerated weights for pallet_dip_consumer +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-11-23 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/debug/kilt-parachain +// benchmark +// pallet +// --pallet +// pallet-dip-consumer +// --extrinsic +// * +// --template +// ./.maintain/weight-template.hbs +// --output +// ./pallets/pallet-dip-consumer/src/weights.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_dip_consumer. +pub trait WeightInfo { + fn dispatch_as() -> Weight; +} + +/// Weights for pallet_dip_consumer using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `PalletDipConsumer::IdentityEntries` (r:1 w:1) + /// Proof: `PalletDipConsumer::IdentityEntries` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn dispatch_as() -> Weight { + // Proof Size summary in bytes: + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 127_413 nanoseconds. + Weight::from_parts(129_497_000, 3612) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `PalletDipConsumer::IdentityEntries` (r:1 w:1) + /// Proof: `PalletDipConsumer::IdentityEntries` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn dispatch_as() -> Weight { + // Proof Size summary in bytes: + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 127_413 nanoseconds. + Weight::from_parts(129_497_000, 3612) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 0c90942b2..ccdd1e088 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -20,19 +20,26 @@ #![cfg_attr(not(feature = "std"), no_std)] +mod default_weights; pub mod identity; pub mod traits; +#[cfg(test)] +pub mod mock; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; + mod origin; -pub use crate::{origin::*, pallet::*, traits::SuccessfulProofVerifier}; +pub use crate::{default_weights::WeightInfo, origin::*, pallet::*, traits::SuccessfulProofVerifier}; -#[frame_support::pallet(dev_mode)] +#[frame_support::pallet] pub mod pallet { use super::*; use frame_support::{ - dispatch::Dispatchable, + dispatch::{Dispatchable, GetDispatchInfo}, pallet_prelude::*, traits::{Contains, EnsureOriginWithArg}, Twox64Concat, @@ -73,8 +80,9 @@ pub mod pallet { /// The logic of the proof verifier, called upon each execution of the /// `dispatch_as` extrinsic. type ProofVerifier: IdentityProofVerifier; - type RuntimeCall: Parameter + Dispatchable::RuntimeOrigin>; + type RuntimeCall: Parameter + Dispatchable::RuntimeOrigin> + GetDispatchInfo; type RuntimeOrigin: From> + From<::RuntimeOrigin>; + type WeightInfo: WeightInfo; } #[pallet::pallet] @@ -95,12 +103,15 @@ pub mod pallet { pub type Origin = DipOrigin<::Identifier, ::AccountId, VerificationResultOf>; - // TODO: Benchmarking #[pallet::call] impl Pallet { // TODO: Replace with a SignedExtra. #[pallet::call_index(0)] - #[pallet::weight(0)] + #[pallet::weight({ + let extrinsic_weight = ::WeightInfo::dispatch_as(); + let call_weight = call.get_dispatch_info().weight; + extrinsic_weight.saturating_add(call_weight) + })] pub fn dispatch_as( origin: OriginFor, identifier: T::Identifier, @@ -124,7 +135,11 @@ pub mod pallet { account_address: submitter, details: proof_verification_result, }; - // TODO: Use dispatch info for weight calculation + + // TODO: Maybe find a nicer way to exclude the call dispatched from the + // benchmarks while making sure the call is actually dispatched and passes any + // filters the consumer proof verifier has set. + #[cfg(not(feature = "runtime-benchmark"))] let _ = call.dispatch(did_origin.into()).map_err(|e| e.error)?; Ok(()) } diff --git a/pallets/pallet-dip-consumer/src/mock.rs b/pallets/pallet-dip-consumer/src/mock.rs new file mode 100644 index 000000000..07d418625 --- /dev/null +++ b/pallets/pallet-dip-consumer/src/mock.rs @@ -0,0 +1,99 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + construct_runtime, + sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, IdentityLookup}, + AccountId32, + }, + traits::{ConstU16, ConstU32, ConstU64, Contains, Everything}, +}; +use frame_system::{mocking::MockBlock, EnsureSigned}; + +use crate::traits::SuccessfulProofVerifier; + +construct_runtime!( + pub struct TestRuntime { + System: frame_system, + DipConsumer: crate, + } +); + +impl frame_system::Config for TestRuntime { + type AccountData = (); + type AccountId = AccountId32; + type BaseCallFilter = Everything; + type Block = MockBlock; + type BlockHashCount = ConstU64<256>; + type BlockLength = (); + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Lookup = IdentityLookup; + type MaxConsumers = ConstU32<16>; + type Nonce = u64; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = (); + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = ConstU16<1>; + type SystemWeightInfo = (); + type Version = (); +} + +pub struct CallFilter; + +impl Contains for CallFilter { + fn contains(t: &RuntimeCall) -> bool { + matches!(t, RuntimeCall::System { .. }) + } +} + +impl crate::Config for TestRuntime { + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type ProofVerifier = SuccessfulProofVerifier; + type LocalIdentityInfo = u128; + type Identifier = AccountId32; + type DispatchOriginCheck = EnsureSigned; + type DipCallOriginFilter = CallFilter; + type WeightInfo = (); +} + +#[derive(Default)] +pub(crate) struct ExtBuilder; + +impl ExtBuilder { + pub fn _build(self) -> sp_io::TestExternalities { + sp_io::TestExternalities::default() + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn build_with_keystore(self) -> sp_io::TestExternalities { + let mut ext = self._build(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); + ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); + ext + } +} diff --git a/pallets/pallet-dip-provider/Cargo.toml b/pallets/pallet-dip-provider/Cargo.toml index 5e22e357a..6c3c0942d 100644 --- a/pallets/pallet-dip-provider/Cargo.toml +++ b/pallets/pallet-dip-provider/Cargo.toml @@ -13,26 +13,48 @@ version.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[dev-dependencies] +kilt-support = {workspace = true, features = ["std", "mock", "try-runtime"]} +sp-io = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} +sp-runtime = {workspace = true, features = ["std"]} + [dependencies] did.workspace = true frame-support.workspace = true frame-system.workspace = true +kilt-support.workspace = true parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} +sp-core.workspace = true sp-std.workspace = true +# Benchmarks +frame-benchmarking = {workspace = true, optional = true} +sp-runtime = {workspace = true, optional = true} + [features] -default = ["std"] -std = [ - "did/std", - "frame-support/std", - "frame-system/std", - "parity-scale-codec/std", - "scale-info/std", - "sp-std/std", -] +default = [ "std" ] + runtime-benchmarks = [ - "did/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks" + "did/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "kilt-support/runtime-benchmarks", + "frame-benchmarking", + "sp-runtime/runtime-benchmarks", +] +std = [ + "did/std", + "frame-support/std", + "frame-system/std", + "kilt-support/std", + "parity-scale-codec/std", + "scale-info/std", + "sp-core/std", + "sp-std/std", + "frame-benchmarking?/std", + "sp-runtime?/std", ] + +try-runtime = [ "did/try-runtime", "kilt-support/try-runtime" ] diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs new file mode 100644 index 000000000..28a73c5cb --- /dev/null +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -0,0 +1,109 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{traits::IdentityProvider, Call, Config, Pallet}; +use frame_benchmarking::v2::*; +use kilt_support::{ + benchmark::IdentityContext, + traits::{GenerateBenchmarkOrigin, GetWorstCase, Instanciate}, +}; + +#[benchmarks( + where + T::CommitOriginCheck: GenerateBenchmarkOrigin, + T::AccountId: Instanciate, + T::Identifier: Instanciate, + <::IdentityProvider as IdentityProvider>::Success: GetWorstCase> +)] +mod benchmarks { + + type IdentityContextOf = + IdentityContext<::Identifier, ::AccountId>; + + use crate::IdentityOf; + + use super::*; + + #[benchmark] + fn commit_identity() { + let submitter = T::AccountId::new(1); + let subject = T::Identifier::new(1); + let commitment_version = 0; + + let context = IdentityContext:: { + did: subject.clone(), + submitter: submitter.clone(), + }; + + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_none()); + + let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject.clone()); + + as GetWorstCase>>::worst_case(context); + + let cloned_subject = subject.clone(); + + #[extrinsic_call] + Pallet::::commit_identity(origin as T::RuntimeOrigin, cloned_subject, Some(commitment_version)); + + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_some()); + } + + #[benchmark] + fn delete_identity_commitment() { + let submitter = T::AccountId::new(1); + let subject = T::Identifier::new(1); + let commitment_version = 0; + + let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter.clone(), subject.clone()); + + let context = IdentityContext:: { + did: subject.clone(), + submitter, + }; + + as GetWorstCase>>::worst_case(context); + let cloned_subject = subject.clone(); + + Pallet::::commit_identity( + origin.clone() as T::RuntimeOrigin, + subject.clone(), + Some(commitment_version), + ) + .expect("Inserting Identity should not fail."); + + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_some()); + + #[extrinsic_call] + Pallet::::delete_identity_commitment(origin as T::RuntimeOrigin, cloned_subject, Some(commitment_version)); + + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_none()); + } + + #[cfg(test)] + mod benchmarks_tests { + use crate::Pallet; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!( + Pallet, + crate::mock::ExtBuilder::default().build_with_keystore(), + crate::mock::TestRuntime, + ); + } +} diff --git a/pallets/pallet-dip-provider/src/default_weights.rs b/pallets/pallet-dip-provider/src/default_weights.rs new file mode 100644 index 000000000..51c54bbe0 --- /dev/null +++ b/pallets/pallet-dip-provider/src/default_weights.rs @@ -0,0 +1,108 @@ + +//! Autogenerated weights for pallet_dip_provider +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-11-23 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/debug/kilt-parachain +// benchmark +// pallet +// --pallet +// pallet-dip-provider +// --extrinsic +// * +// --template +// ./.maintain/weight-template.hbs +// --output +// ./pallets/pallet-dip-provider/src/weights.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_dip_provider. +pub trait WeightInfo { + fn commit_identity() -> Weight; + fn delete_identity_commitment() -> Weight; +} + +/// Weights for pallet_dip_provider using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:11 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `PalletDipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `PalletDipProvider::IdentityCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn commit_identity() -> Weight { + // Proof Size summary in bytes: + // Measured: `2781` + // Estimated: `29282` + // Minimum execution time: 1_244_624 nanoseconds. + Weight::from_parts(1_401_381_000, 29282) + .saturating_add(T::DbWeight::get().reads(16_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `PalletDipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `PalletDipProvider::IdentityCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn delete_identity_commitment() -> Weight { + // Proof Size summary in bytes: + // Measured: `250` + // Estimated: `3715` + // Minimum execution time: 169_415 nanoseconds. + Weight::from_parts(190_131_000, 3715) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:11 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `PalletDipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `PalletDipProvider::IdentityCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn commit_identity() -> Weight { + // Proof Size summary in bytes: + // Measured: `2781` + // Estimated: `29282` + // Minimum execution time: 1_244_624 nanoseconds. + Weight::from_parts(1_401_381_000, 29282) + .saturating_add(RocksDbWeight::get().reads(16_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `PalletDipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `PalletDipProvider::IdentityCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn delete_identity_commitment() -> Weight { + // Proof Size summary in bytes: + // Measured: `250` + // Estimated: `3715` + // Minimum execution time: 169_415 nanoseconds. + Weight::from_parts(190_131_000, 3715) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index b9819b51b..a3672eded 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -20,17 +20,26 @@ #![cfg_attr(not(feature = "std"), no_std)] +mod default_weights; pub mod traits; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + +#[cfg(test)] +mod mock; + pub use crate::{ + default_weights::WeightInfo, pallet::*, traits::{DefaultIdentityCommitmentGenerator, DefaultIdentityProvider, NoopHooks}, }; -#[frame_support::pallet(dev_mode)] +#[frame_support::pallet] pub mod pallet { use super::*; + use default_weights::WeightInfo; use frame_support::{pallet_prelude::*, traits::EnsureOriginWithArg}; use frame_system::pallet_prelude::*; @@ -54,6 +63,7 @@ pub mod pallet { type IdentityProvider: IdentityProvider; type ProviderHooks: ProviderHooks; type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type WeightInfo: WeightInfo; } #[pallet::storage] @@ -96,8 +106,9 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - // TODO: Update weight - #[pallet::weight(0)] + #[pallet::weight({ + ::WeightInfo::commit_identity() + })] pub fn commit_identity( origin: OriginFor, identifier: T::Identifier, @@ -141,8 +152,9 @@ pub mod pallet { } #[pallet::call_index(1)] - // TODO: Update weight - #[pallet::weight(0)] + #[pallet::weight({ + ::WeightInfo::delete_identity_commitment() + })] pub fn delete_identity_commitment( origin: OriginFor, identifier: T::Identifier, diff --git a/pallets/pallet-dip-provider/src/mock.rs b/pallets/pallet-dip-provider/src/mock.rs new file mode 100644 index 000000000..af57977af --- /dev/null +++ b/pallets/pallet-dip-provider/src/mock.rs @@ -0,0 +1,100 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + construct_runtime, + sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, IdentityLookup}, + AccountId32, + }, + traits::{ConstU16, ConstU32, ConstU64, Everything}, +}; + +use frame_system::mocking::MockBlock; +use kilt_support::mock::mock_origin::{self as mock_origin, DoubleOrigin, EnsureDoubleOrigin}; + +use crate::{DefaultIdentityCommitmentGenerator, DefaultIdentityProvider, NoopHooks}; + +construct_runtime!( + pub struct TestRuntime { + System: frame_system, + DipProvider: crate, + MockOrigin: mock_origin, + } +); + +impl frame_system::Config for TestRuntime { + type AccountData = (); + type AccountId = AccountId32; + type BaseCallFilter = Everything; + type Block = MockBlock; + type BlockHashCount = ConstU64<256>; + type BlockLength = (); + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Lookup = IdentityLookup; + type MaxConsumers = ConstU32<16>; + type Nonce = u64; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = (); + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = ConstU16<1>; + type SystemWeightInfo = (); + type Version = (); +} + +impl crate::Config for TestRuntime { + type CommitOrigin = DoubleOrigin; + type CommitOriginCheck = EnsureDoubleOrigin; + type Identifier = AccountId32; + type IdentityCommitmentGenerator = DefaultIdentityCommitmentGenerator; + type IdentityProvider = DefaultIdentityProvider; + type ProviderHooks = NoopHooks; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); +} + +impl mock_origin::Config for TestRuntime { + type AccountId = ::AccountId; + type RuntimeOrigin = RuntimeOrigin; + type SubjectId = ::Identifier; +} + +#[derive(Default)] +pub(crate) struct ExtBuilder; + +impl ExtBuilder { + pub fn _build(self) -> sp_io::TestExternalities { + sp_io::TestExternalities::default() + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn build_with_keystore(self) -> sp_io::TestExternalities { + let mut ext = self._build(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); + ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); + ext + } +} diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 8cf5c0914..a475c0c9e 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -37,7 +37,7 @@ pub mod identity_provision { fn retrieve(identifier: &Runtime::Identifier) -> Result; } - // Return the `Default` value if `Identity` adn `Details` both implement it. + // Return the `Default` value if `Identity` and `Details` both implement it. pub struct DefaultIdentityProvider(PhantomData); impl IdentityProvider for DefaultIdentityProvider @@ -126,6 +126,17 @@ where } } +#[cfg(any(feature = "runtime-benchmarks", test))] +impl SubmitterInfo for kilt_support::mock::mock_origin::DoubleOrigin +where + AccountId: Clone, +{ + type Submitter = AccountId; + fn submitter(&self) -> Self::Submitter { + self.0.clone() + } +} + pub trait ProviderHooks where Runtime: Config, diff --git a/pallets/pallet-migration/Cargo.toml b/pallets/pallet-migration/Cargo.toml index 378b7baaa..905b0d4a7 100644 --- a/pallets/pallet-migration/Cargo.toml +++ b/pallets/pallet-migration/Cargo.toml @@ -20,12 +20,13 @@ frame-benchmarking = {workspace = true, features = ["std"]} pallet-aura = {workspace = true, features = ["std"]} pallet-timestamp = {workspace = true, features = ["std"]} sp-consensus-aura = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} pallet-session = {workspace = true, features = ["std"]} attestation = {workspace = true, features = ["mock"]} ctype = {workspace = true, features = ["mock"]} -delegation = {workspace = true, features = ["mock"]} -did = {workspace = true, features = ["mock"]} -public-credentials = {workspace = true, features = ["mock"]} +delegation = {workspace = true, features = ["mock"]} +did = {workspace = true, features = ["mock"]} +public-credentials = {workspace = true, features = ["mock"]} [dependencies] # Internal dependencies @@ -36,7 +37,7 @@ pallet-did-lookup.workspace = true pallet-web3-names.workspace = true parachain-staking.workspace = true public-credentials.workspace = true -runtime-common.workspace = true +runtime-common.workspace = true kilt-support.workspace = true ctype = {workspace = true, optional = true} @@ -69,7 +70,7 @@ runtime-benchmarks = [ "pallet-web3-names/runtime-benchmarks", "parachain-staking/runtime-benchmarks", "public-credentials/runtime-benchmarks", - "runtime-common/runtime-benchmarks", + "runtime-common/runtime-benchmarks", "ctype/runtime-benchmarks", "kilt-support/runtime-benchmarks", "pallet-balances/runtime-benchmarks", diff --git a/pallets/pallet-migration/src/benchmarking.rs b/pallets/pallet-migration/src/benchmarking.rs index 68b748cdd..6ced3cd01 100644 --- a/pallets/pallet-migration/src/benchmarking.rs +++ b/pallets/pallet-migration/src/benchmarking.rs @@ -203,7 +203,7 @@ benchmarks! { let sender: AccountIdOf = account("sender", 0, SEED); let attester: ::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); diff --git a/pallets/pallet-migration/src/mock.rs b/pallets/pallet-migration/src/mock.rs index 2567b1bd8..e07fe2e90 100644 --- a/pallets/pallet-migration/src/mock.rs +++ b/pallets/pallet-migration/src/mock.rs @@ -375,9 +375,9 @@ pub mod runtime { } #[cfg(feature = "runtime-benchmarks")] - impl kilt_support::traits::GetWorstCase for TestSubjectId { + impl kilt_support::traits::GetWorstCase for TestSubjectId { // Only used for benchmark testing, not really relevant. - fn worst_case() -> Self { + fn worst_case(_context: Context) -> Self { crate::mock::TestSubjectId::default() } } diff --git a/pallets/pallet-relay-store/Cargo.toml b/pallets/pallet-relay-store/Cargo.toml index c5398f052..96f1051b0 100644 --- a/pallets/pallet-relay-store/Cargo.toml +++ b/pallets/pallet-relay-store/Cargo.toml @@ -13,6 +13,12 @@ version.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[dev-dependencies] +cumulus-primitives-core = { workspace = true, features = ["std"] } +sp-io = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} +sp-runtime = {workspace = true, features = ["std"]} + [dependencies] cumulus-pallet-parachain-system.workspace = true frame-support.workspace = true @@ -21,9 +27,12 @@ log.workspace = true parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} sp-core.workspace = true -sp-runtime.workspace = true sp-std.workspace = true +# Benchmarks +frame-benchmarking = {workspace = true, optional = true} +sp-runtime = {workspace = true, optional = true} + [features] default = ["std"] std = [ @@ -33,10 +42,14 @@ std = [ "parity-scale-codec/std", "scale-info/std", "sp-core/std", - "sp-runtime/std", "sp-std/std", + "frame-benchmarking?/std", + "sp-runtime?/std", ] runtime-benchmarks = [ + "cumulus-pallet-parachain-system/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "frame-benchmarking", + "sp-runtime/runtime-benchmarks", ] diff --git a/pallets/pallet-relay-store/src/benchmarking.rs b/pallets/pallet-relay-store/src/benchmarking.rs new file mode 100644 index 000000000..3520016ba --- /dev/null +++ b/pallets/pallet-relay-store/src/benchmarking.rs @@ -0,0 +1,93 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{Config, Pallet}; +use frame_benchmarking::v2::*; + +#[benchmarks( + where + T: cumulus_pallet_parachain_system::Config +)] +mod benchmarks { + use cumulus_pallet_parachain_system::RelaychainDataProvider; + use sp_core::H256; + use sp_runtime::{ + traits::{BlockNumberProvider, Get}, + BoundedVec, + }; + + use crate::{relay::RelayParentInfo, LatestBlockHeights, LatestRelayHeads}; + + use super::*; + + #[benchmark] + fn on_finalize() { + let max_blocks_stored = T::MaxRelayBlocksStored::get(); + let latest_block_heights: BoundedVec = (1..=max_blocks_stored) + .collect::>() + .try_into() + .expect("Should not fail to build BoundedVec for LatestBlockHeights"); + let latest_block_heads_iter = latest_block_heights.iter().map(|block_height| { + ( + block_height, + RelayParentInfo { + relay_parent_storage_root: H256::default(), + }, + ) + }); + latest_block_heads_iter + .for_each(|(block_height, parent_info)| LatestRelayHeads::::insert(block_height, parent_info)); + LatestBlockHeights::::put(latest_block_heights); + + assert_eq!( + LatestRelayHeads::::iter().count(), + max_blocks_stored as usize, + "The maximum allowed number of blocks should be stored in storage." + ); + + let new_block_number = max_blocks_stored + 1; + frame_system::Pallet::::set_block_number(new_block_number.into()); + RelaychainDataProvider::::set_block_number(new_block_number); + + #[block] + { + Pallet::::on_finalize_internal(new_block_number.into()) + } + + assert!( + LatestBlockHeights::::get().contains(&new_block_number), + "LatestBlockHeights should contain the information about the new block" + ); + assert!( + LatestRelayHeads::::contains_key(new_block_number), + "LatestRelayHeads should contain the information about the new block" + ); + } + + #[cfg(test)] + mod benchmarks_tests { + use crate::Pallet; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!( + Pallet, + crate::mock::ExtBuilder::default().build_with_keystore(), + crate::mock::TestRuntime, + ); + } +} diff --git a/pallets/pallet-relay-store/src/default_weights.rs b/pallets/pallet-relay-store/src/default_weights.rs new file mode 100644 index 000000000..ab5ae9ce4 --- /dev/null +++ b/pallets/pallet-relay-store/src/default_weights.rs @@ -0,0 +1,92 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for pallet_relay_store +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-01 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/kilt-parachain +// benchmark +// pallet +// --template=.maintain/weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --chain=dev +// --pallet=pallet-relay-store +// --extrinsic=* +// --output=./pallets/pallet-relay-store/src/default_weights.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_relay_store. +pub trait WeightInfo { + fn on_finalize() -> Weight; +} + +/// Weights for pallet_relay_store using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `RelayStore::LatestBlockHeights` (r:1 w:1) + /// Proof: `RelayStore::LatestBlockHeights` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `RelayStore::LatestRelayHeads` (r:0 w:2) + /// Proof: `RelayStore::LatestRelayHeads` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + fn on_finalize() -> Weight { + // Proof Size summary in bytes: + // Measured: `577` + // Estimated: `2062` + // Minimum execution time: 132_937 nanoseconds. + Weight::from_parts(146_340_000, 2062) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `RelayStore::LatestBlockHeights` (r:1 w:1) + /// Proof: `RelayStore::LatestBlockHeights` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `RelayStore::LatestRelayHeads` (r:0 w:2) + /// Proof: `RelayStore::LatestRelayHeads` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + fn on_finalize() -> Weight { + // Proof Size summary in bytes: + // Measured: `577` + // Estimated: `2062` + // Minimum execution time: 132_937 nanoseconds. + Weight::from_parts(146_340_000, 2062) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } +} diff --git a/pallets/pallet-relay-store/src/lib.rs b/pallets/pallet-relay-store/src/lib.rs index d5ca7bc1c..bebe071c4 100644 --- a/pallets/pallet-relay-store/src/lib.rs +++ b/pallets/pallet-relay-store/src/lib.rs @@ -20,9 +20,16 @@ #![cfg_attr(not(feature = "std"), no_std)] +mod default_weights; mod relay; -pub use crate::pallet::*; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + +#[cfg(test)] +mod mock; + +pub use crate::{default_weights::WeightInfo, pallet::*}; #[frame_support::pallet] pub mod pallet { @@ -50,6 +57,7 @@ pub mod pallet { pub trait Config: frame_system::Config { #[pallet::constant] type MaxRelayBlocksStored: Get; + type WeightInfo: WeightInfo; } #[pallet::pallet] @@ -62,13 +70,19 @@ pub mod pallet { T: cumulus_pallet_parachain_system::Config, { fn on_initialize(_n: BlockNumberFor) -> Weight { - // Reserve weight to update the last relay state root - // TODO: Replace with benchmarked version of `on_finalize(` - ::DbWeight::get().writes(2) + ::WeightInfo::on_finalize() + } + + fn on_finalize(n: BlockNumberFor) { + Self::on_finalize_internal(n) } + } - // TODO: Benchmarks - fn on_finalize(_n: BlockNumberFor) { + impl Pallet + where + T: cumulus_pallet_parachain_system::Config, + { + pub(crate) fn on_finalize_internal(_n: BlockNumberFor) { // Called before the validation data is cleaned in the // parachain_system::on_finalize hook let Some(new_validation_data) = cumulus_pallet_parachain_system::Pallet::::validation_data() else { diff --git a/pallets/pallet-relay-store/src/mock.rs b/pallets/pallet-relay-store/src/mock.rs new file mode 100644 index 000000000..2aea08ef7 --- /dev/null +++ b/pallets/pallet-relay-store/src/mock.rs @@ -0,0 +1,102 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use cumulus_pallet_parachain_system::{ParachainSetCode, RelayNumberStrictlyIncreases}; +use cumulus_primitives_core::ParaId; +use frame_support::{ + construct_runtime, parameter_types, + sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, IdentityLookup}, + AccountId32, + }, + traits::{ConstU16, ConstU32, ConstU64, Everything}, +}; +use frame_system::mocking::MockBlock; + +construct_runtime!( + pub struct TestRuntime { + System: frame_system, + ParachainSystem: cumulus_pallet_parachain_system, + RelayStore: crate, + } +); + +impl frame_system::Config for TestRuntime { + type AccountData = (); + type AccountId = AccountId32; + type BaseCallFilter = Everything; + type Block = MockBlock; + type BlockHashCount = ConstU64<256>; + type BlockLength = (); + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Lookup = IdentityLookup; + type MaxConsumers = ConstU32<16>; + type Nonce = u64; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = ParachainSetCode; + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = ConstU16<1>; + type SystemWeightInfo = (); + type Version = (); +} + +parameter_types! { + pub const ParachainId: ParaId = ParaId::new(2_000); +} + +impl cumulus_pallet_parachain_system::Config for TestRuntime { + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; + type DmpMessageHandler = (); + type OnSystemEvent = (); + type OutboundXcmpMessageSource = (); + type ReservedDmpWeight = (); + type ReservedXcmpWeight = (); + type RuntimeEvent = RuntimeEvent; + type SelfParaId = ParachainId; + type XcmpMessageHandler = (); +} + +impl crate::Config for TestRuntime { + type MaxRelayBlocksStored = ConstU32<5>; + type WeightInfo = (); +} + +#[derive(Default)] +pub(crate) struct ExtBuilder; + +impl ExtBuilder { + pub fn _build(self) -> sp_io::TestExternalities { + sp_io::TestExternalities::default() + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn build_with_keystore(self) -> sp_io::TestExternalities { + let mut ext = self._build(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); + ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); + ext + } +} diff --git a/pallets/public-credentials/src/benchmarking.rs b/pallets/public-credentials/src/benchmarking.rs index 1153bdf63..087f2bfec 100644 --- a/pallets/public-credentials/src/benchmarking.rs +++ b/pallets/public-credentials/src/benchmarking.rs @@ -71,7 +71,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; c as usize]).expect("Contents should not fail."); let creation_op = Box::new(generate_base_public_credential_creation_op::( @@ -98,7 +98,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); @@ -127,7 +127,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); @@ -156,7 +156,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); @@ -185,7 +185,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); @@ -216,7 +216,7 @@ benchmarks! { let deposit_owner_new: AccountIdOf = account("caller", 1, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(deposit_owner_old.clone(), attester.clone()); @@ -252,7 +252,7 @@ benchmarks! { let deposit_owner: AccountIdOf = account("caller", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let origin = ::EnsureOrigin::generate_origin(deposit_owner.clone(), attester.clone()); reserve_balance::(&deposit_owner); diff --git a/pallets/public-credentials/src/mock.rs b/pallets/public-credentials/src/mock.rs index 07f53d6e3..3afa5c334 100644 --- a/pallets/public-credentials/src/mock.rs +++ b/pallets/public-credentials/src/mock.rs @@ -247,9 +247,9 @@ pub(crate) mod runtime { } #[cfg(feature = "runtime-benchmarks")] - impl kilt_support::traits::GetWorstCase for TestSubjectId { + impl kilt_support::traits::GetWorstCase for TestSubjectId { // Only used for benchmark testing, not really relevant. - fn worst_case() -> Self { + fn worst_case(_context: Context) -> Self { crate::mock::TestSubjectId::default() } } diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 7134a22ed..cfba19e88 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -60,6 +60,9 @@ xcm-builder.workspace = true xcm-executor.workspace = true xcm.workspace = true +#benchmarking +frame-benchmarking = { workspace = true, optional = true } + [features] default = ["std"] fast-gov = [] @@ -71,7 +74,6 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "kilt-dip-support/runtime-benchmarks", "kilt-support/runtime-benchmarks", - "kilt-dip-support/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-membership/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", @@ -82,6 +84,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", ] std = [ "cumulus-pallet-parachain-system/std", @@ -122,6 +125,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "frame-benchmarking?/std", ] try-runtime = [ "cumulus-pallet-parachain-system/try-runtime", diff --git a/runtimes/common/src/assets.rs b/runtimes/common/src/assets.rs index 784bc692d..21368e6ca 100644 --- a/runtimes/common/src/assets.rs +++ b/runtimes/common/src/assets.rs @@ -104,8 +104,8 @@ mod benchmarks { } } - impl kilt_support::traits::GetWorstCase for AssetDid { - fn worst_case() -> Self { + impl kilt_support::traits::GetWorstCase for AssetDid { + fn worst_case(_context: Context) -> Self { // Returns the worst case for an AssetDID, which is represented by the longest // identifier according to the spec. Self::try_from( diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 134c65de9..4b6ca4d0e 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -17,18 +17,25 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use did::did_details::DidDetails; +use frame_support::ensure; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::RevealedWeb3Name; use pallet_did_lookup::linkable_account::LinkableAccountId; use pallet_dip_provider::traits::IdentityProvider; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; +use sp_core::ConstU32; +use sp_runtime::{BoundedVec, SaturatedConversion}; use sp_std::vec::Vec; -#[derive(Encode, Decode, TypeInfo)] +#[cfg(feature = "runtime-benchmarks")] +use kilt_support::{benchmark::IdentityContext, traits::GetWorstCase}; + +#[derive(Encode, Decode, TypeInfo, Debug)] pub enum LinkedDidInfoProviderError { DidNotFound, DidDeleted, + TooManyLinkedAccounts, Internal, } @@ -37,6 +44,7 @@ impl From for u16 { match value { LinkedDidInfoProviderError::DidNotFound => 0, LinkedDidInfoProviderError::DidDeleted => 1, + LinkedDidInfoProviderError::TooManyLinkedAccounts => 2, LinkedDidInfoProviderError::Internal => u16::MAX, } } @@ -45,18 +53,18 @@ impl From for u16 { pub type Web3OwnershipOf = RevealedWeb3Name<::Web3Name, BlockNumberFor>; -pub struct LinkedDidInfoOf +pub struct LinkedDidInfoOf where Runtime: did::Config + pallet_web3_names::Config, { pub did_details: DidDetails, pub web3_name_details: Option>, - pub linked_accounts: Vec, + pub linked_accounts: BoundedVec>, } -pub struct LinkedDidInfoProvider; +pub struct LinkedDidInfoProvider; -impl IdentityProvider for LinkedDidInfoProvider +impl IdentityProvider for LinkedDidInfoProvider where Runtime: did::Config::Identifier> + pallet_web3_names::Config::Identifier> @@ -64,7 +72,7 @@ where + pallet_dip_provider::Config, { type Error = LinkedDidInfoProviderError; - type Success = LinkedDidInfoOf; + type Success = LinkedDidInfoOf; fn retrieve(identifier: &Runtime::Identifier) -> Result { let did_details = match ( @@ -90,7 +98,26 @@ where } else { Ok(None) }?; - let linked_accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier).collect(); + + // Check if the user has too many linked accounts. If they have more than + // [MAX_LINKED_ACCOUNTS], we throw an error. + let are_linked_accounts_within_limit = + pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) + .nth(MAX_LINKED_ACCOUNTS.saturated_into()) + .is_none(); + + ensure!( + are_linked_accounts_within_limit, + LinkedDidInfoProviderError::TooManyLinkedAccounts + ); + + let linked_accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) + .take(MAX_LINKED_ACCOUNTS.saturated_into()) + .collect::>() + .try_into() + // Should never happen since we checked above. + .map_err(|_| LinkedDidInfoProviderError::TooManyLinkedAccounts)?; + Ok(LinkedDidInfoOf { did_details, web3_name_details, @@ -98,3 +125,103 @@ where }) } } + +#[cfg(feature = "runtime-benchmarks")] +impl GetWorstCase> + for LinkedDidInfoOf +where + Runtime: did::Config::Identifier> + + pallet_web3_names::Config::Identifier> + + pallet_did_lookup::Config::Identifier> + + pallet_dip_provider::Config + + pallet_balances::Config, + ::AccountId: Into + From, + ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>, +{ + fn worst_case(context: IdentityContext) -> Self { + use did::{ + did_details::DidVerificationKey, + mock_utils::{generate_base_did_creation_details, get_key_agreement_keys}, + }; + use frame_benchmarking::{vec, Zero}; + use frame_support::traits::fungible::Mutate; + use sp_io::crypto::{ed25519_generate, sr25519_generate}; + use sp_runtime::{traits::Get, KeyTypeId}; + + use crate::constants::KILT; + + // Did Details. + + let submitter = context.submitter; + let did = context.did; + + let amount = KILT * 100; + + // give some money + as Mutate<::AccountId>>::set_balance( + &submitter, + amount.saturated_into(), + ); + + let max_new_keys = ::MaxNewKeyAgreementKeys::get(); + + let new_key_agreement_keys = get_key_agreement_keys::(max_new_keys); + + let mut did_creation_details = generate_base_did_creation_details(did.clone(), submitter.clone()); + + let attestation_key = ed25519_generate(KeyTypeId(*b"0001"), None); + let delegation_key = ed25519_generate(KeyTypeId(*b"0002"), None); + let auth_key = ed25519_generate(KeyTypeId(*b"0003"), None); + did_creation_details.new_attestation_key = Some(DidVerificationKey::from(attestation_key)); + did_creation_details.new_delegation_key = Some(DidVerificationKey::from(delegation_key)); + did_creation_details.new_key_agreement_keys = new_key_agreement_keys; + + let did_details = did::did_details::DidDetails::new_with_creation_details( + did_creation_details, + DidVerificationKey::from(auth_key), + ) + .expect("Creation of DID details should not fail."); + + // add to storage. + did::Pallet::::try_insert_did(did.clone(), did_details.clone(), submitter.clone()) + .expect("Inserting Did should not fail."); + + let max_name_length = ::MaxNameLength::get() + .try_into() + .expect("max name length should not fail."); + + let web3_name_input: BoundedVec::MaxNameLength> = + BoundedVec::try_from(vec![b'1'; max_name_length]).expect("BoundedVec creation should not fail."); + + let web3_name = pallet_web3_names::Web3NameOf::::try_from(web3_name_input.to_vec()) + .expect("Creation of w3n from w3n input should not fail."); + + pallet_web3_names::Pallet::::register_name(web3_name.clone(), did.clone(), submitter.clone()) + .expect("Inserting w3n into storage should not fail."); + + let web3_name_details = Some(RevealedWeb3Name { + web3_name, + claimed_at: BlockNumberFor::::zero(), + }); + + let mut linked_accounts = vec![]; + + (0..MAX_LINKED_ACCOUNTS).for_each(|index| { + let connected_acc = sr25519_generate(KeyTypeId(index.to_be_bytes()), None); + let connected_acc_id: ::AccountId = connected_acc.into(); + let linkable_id: LinkableAccountId = connected_acc_id.into(); + pallet_did_lookup::Pallet::::add_association(submitter.clone(), did.clone(), linkable_id.clone()) + .expect("association should not fail."); + + linked_accounts.push(linkable_id); + }); + + LinkedDidInfoOf { + did_details, + linked_accounts: linked_accounts + .try_into() + .expect("BoundedVec creation of linked accounts should not fail."), + web3_name_details, + } + } +} diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index ec62b3d6a..5eb5829a8 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -83,8 +83,8 @@ pub mod v0 { LinkableAccountId, >; - pub(super) fn calculate_root_with_db( - identity: &LinkedDidInfoOf, + pub(super) fn calculate_root_with_db( + identity: &LinkedDidInfoOf, db: &mut MemoryDB, ) -> Result where @@ -232,8 +232,8 @@ pub mod v0 { Ok(trie_builder.root().to_owned()) } - pub(super) fn generate_proof<'a, Runtime, K, A>( - identity: &LinkedDidInfoOf, + pub(super) fn generate_proof<'a, Runtime, K, A, const MAX_LINKED_ACCOUNT: u32>( + identity: &LinkedDidInfoOf, key_ids: K, should_include_web3_name: bool, account_ids: A, @@ -323,12 +323,12 @@ pub mod v0 { }) } - pub(super) fn generate_commitment( + pub(super) fn generate_commitment( identity: &IdentityOf, ) -> Result where Runtime: did::Config + pallet_did_lookup::Config + pallet_web3_names::Config + pallet_dip_provider::Config, - Runtime::IdentityProvider: IdentityProvider>, + Runtime::IdentityProvider: IdentityProvider>, { let mut db = MemoryDB::default(); calculate_root_with_db(identity, &mut db) @@ -337,10 +337,10 @@ pub mod v0 { pub struct DidMerkleRootGenerator(PhantomData); -impl IdentityCommitmentGenerator for DidMerkleRootGenerator +impl IdentityCommitmentGenerator for DidMerkleRootGenerator where Runtime: did::Config + pallet_did_lookup::Config + pallet_web3_names::Config + pallet_dip_provider::Config, - Runtime::IdentityProvider: IdentityProvider>, + Runtime::IdentityProvider: IdentityProvider>, { type Error = DidMerkleProofError; type Output = Runtime::Hash; @@ -351,7 +351,7 @@ where version: IdentityCommitmentVersion, ) -> Result { match version { - 0 => v0::generate_commitment::(identity), + 0 => v0::generate_commitment::(identity), _ => Err(DidMerkleProofError::UnsupportedVersion), } } @@ -361,8 +361,8 @@ impl DidMerkleRootGenerator where Runtime: did::Config + pallet_did_lookup::Config + pallet_web3_names::Config, { - pub fn generate_proof<'a, K, A>( - identity: &LinkedDidInfoOf, + pub fn generate_proof<'a, K, A, const MAX_LINKED_ACCOUNT: u32>( + identity: &LinkedDidInfoOf, version: IdentityCommitmentVersion, key_ids: K, should_include_web3_name: bool, diff --git a/support/src/benchmark.rs b/support/src/benchmark.rs new file mode 100644 index 000000000..b19496912 --- /dev/null +++ b/support/src/benchmark.rs @@ -0,0 +1,23 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/// Manly used for the DIP benchmarking. The worst case can be created for the +/// did and submitter. +#[derive(Clone)] +pub struct IdentityContext { + pub did: DidIdentifier, + pub submitter: AccountId, +} diff --git a/support/src/lib.rs b/support/src/lib.rs index 758062f92..e156ddc02 100644 --- a/support/src/lib.rs +++ b/support/src/lib.rs @@ -28,3 +28,6 @@ pub mod mock; #[cfg(any(feature = "try-runtime", test))] pub mod test_utils; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmark; diff --git a/support/src/mock.rs b/support/src/mock.rs index df757cfd0..a6b5fdde5 100644 --- a/support/src/mock.rs +++ b/support/src/mock.rs @@ -32,7 +32,10 @@ use sp_runtime::AccountId32; pub mod mock_origin { use sp_std::marker::PhantomData; - use frame_support::{traits::EnsureOrigin, Parameter}; + use frame_support::{ + traits::{EnsureOrigin, EnsureOriginWithArg}, + Parameter, + }; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_runtime::AccountId32; @@ -105,6 +108,35 @@ pub mod mock_origin { } } + impl EnsureOriginWithArg + for EnsureDoubleOrigin + where + OuterOrigin: Into, OuterOrigin>> + + From> + + Clone, + SubjectId: PartialEq + Clone, + AccountId: Clone + Decode, + { + type Success = DoubleOrigin; + + fn try_origin(o: OuterOrigin, a: &SubjectId) -> Result { + let did_origin: DoubleOrigin = o.clone().into()?; + if did_origin.1 == *a { + Ok(did_origin) + } else { + Err(o) + } + } + + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin(a: &SubjectId) -> Result { + let zero_account_id = AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()) + .expect("infinite length input; no invalid inputs for type; qed"); + + Ok(OuterOrigin::from(DoubleOrigin(zero_account_id, a.clone()))) + } + } + #[cfg(feature = "runtime-benchmarks")] impl crate::traits::GenerateBenchmarkOrigin for EnsureDoubleOrigin diff --git a/support/src/traits.rs b/support/src/traits.rs index 2c2fa6a66..b2a9f8f17 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -81,8 +81,36 @@ pub trait GenerateBenchmarkOrigin { /// Trait that allows types to implement a worst case value for a type, /// only when running benchmarks. #[cfg(feature = "runtime-benchmarks")] -pub trait GetWorstCase { - fn worst_case() -> Self; +pub trait GetWorstCase { + fn worst_case(context: Context) -> Self; +} + +#[cfg(feature = "runtime-benchmarks")] +impl GetWorstCase for u32 { + fn worst_case(_context: T) -> Self { + u32::MAX + } +} + +#[cfg(feature = "runtime-benchmarks")] +impl GetWorstCase for () { + fn worst_case(_context: T) -> Self {} +} + +/// Trait that allows instanciating multiple instances of a type. +#[cfg(feature = "runtime-benchmarks")] +pub trait Instanciate { + fn new(instance: u32) -> Self; +} + +#[cfg(feature = "runtime-benchmarks")] +impl Instanciate for sp_runtime::AccountId32 { + fn new(instance: u32) -> Self { + use sp_runtime::traits::Hash; + sp_runtime::AccountId32::from(<[u8; 32]>::from(sp_runtime::traits::BlakeTwo256::hash( + &instance.to_be_bytes(), + ))) + } } /// Generic filter.