diff --git a/Cargo.lock b/Cargo.lock index 2cc4b28..7604dfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,18 +68,7 @@ dependencies = [ "cipher 0.4.4", "ctr", "ghash", - "subtle 2.5.0", -] - -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom 0.2.15", - "once_cell", - "version_check", + "subtle 2.6.1", ] [[package]] @@ -89,7 +78,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom 0.2.15", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -204,20 +193,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "aquamarine" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1da02abba9f9063d786eab1509833ebb2fac0f966862ca59439c76b9c566760" -dependencies = [ - "include_dir", - "itertools 0.10.5", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "aquamarine" version = "0.5.0" @@ -229,7 +204,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -519,12 +494,6 @@ dependencies = [ "sha3", ] -[[package]] -name = "array-bytes" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" - [[package]] name = "array-bytes" version = "6.2.3" @@ -533,9 +502,9 @@ checksum = "5d5dde061bd34119e902bbb2d9b90c5692635cf59fb91d582c2b68043f1b8293" [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" [[package]] name = "arrayvec" @@ -564,8 +533,24 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ - "asn1-rs-derive", - "asn1-rs-impl", + "asn1-rs-derive 0.4.0", + "asn1-rs-impl 0.1.0", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" +dependencies = [ + "asn1-rs-derive 0.5.0", + "asn1-rs-impl 0.2.0", "displaydoc", "nom", "num-traits", @@ -586,6 +571,18 @@ dependencies = [ "synstructure 0.12.6", ] +[[package]] +name = "asn1-rs-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", + "synstructure 0.13.1", +] + [[package]] name = "asn1-rs-impl" version = "0.1.0" @@ -597,6 +594,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "assert_cmd" version = "2.0.14" @@ -612,6 +620,12 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + [[package]] name = "async-channel" version = "1.9.0" @@ -632,14 +646,14 @@ dependencies = [ "concurrent-queue", "event-listener-strategy", "futures-core", - "pin-project-lite 0.2.14", + "pin-project-lite", ] [[package]] name = "async-executor" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8828ec6e544c02b0d6691d21ed9f9218d0384a82542855073c2a3f58304aaf0" +checksum = "d7ebdfa2ebdab6b1760375fa7d6f382b9f486eac35fc994625a00e89280bdbb7" dependencies = [ "async-task", "concurrent-queue", @@ -692,7 +706,7 @@ dependencies = [ "futures-io", "futures-lite 2.3.0", "parking", - "polling 3.7.1", + "polling 3.7.2", "rustix 0.38.34", "slab", "tracing", @@ -716,7 +730,7 @@ checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ "event-listener 5.3.1", "event-listener-strategy", - "pin-project-lite 0.2.14", + "pin-project-lite", ] [[package]] @@ -749,9 +763,9 @@ dependencies = [ [[package]] name = "async-signal" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794f185324c2f00e771cd9f1ae8b5ac68be2ca7abb129a87afd6e86d228bc54d" +checksum = "dfb3634b73397aa844481f814fad23bbf07fdb0eabec10f2eb95e58944b1ec32" dependencies = [ "async-io 2.3.3", "async-lock 3.4.0", @@ -773,13 +787,13 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -792,7 +806,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.14", + "pin-project-lite", ] [[package]] @@ -807,6 +821,17 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "attohttpc" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d9a9bf8b79a749ee0b911b91b671cc2b6c670bdbc7e3dfd537576ddc94bb2a2" +dependencies = [ + "http 0.2.12", + "log", + "url", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -815,16 +840,16 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line 0.22.0", "cc", "cfg-if", "libc", "miniz_oxide", - "object 0.35.0", + "object 0.36.1", "rustc-demangle", ] @@ -896,6 +921,15 @@ dependencies = [ "serde", ] +[[package]] +name = "binary-merkle-tree" +version = "13.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "hash-db", + "log", +] + [[package]] name = "bincode" version = "1.3.3" @@ -923,7 +957,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -965,9 +999,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -1037,9 +1071,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" +checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" dependencies = [ "arrayref", "arrayvec 0.7.4", @@ -1124,7 +1158,7 @@ dependencies = [ [[package]] name = "bp-xcm-bridge-hub-router" version = "0.6.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "scale-info", @@ -1187,9 +1221,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -1199,9 +1233,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "bzip2-sys" @@ -1258,15 +1292,20 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.99" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" dependencies = [ "jobserver", "libc", - "once_cell", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cexpr" version = "0.6.0" @@ -1342,7 +1381,7 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1355,7 +1394,20 @@ dependencies = [ "multibase", "multihash 0.17.0", "serde", - "unsigned-varint", + "unsigned-varint 0.7.2", +] + +[[package]] +name = "cid" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd94671561e36e4e7de75f753f577edafb0e7c05d6e4547229fdf7938fbcd2c3" +dependencies = [ + "core2", + "multibase", + "multihash 0.18.1", + "serde", + "unsigned-varint 0.7.2", ] [[package]] @@ -1378,15 +1430,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ckb-merkle-mountain-range" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ccb671c5921be8a84686e6212ca184cb1d7c51cadcdbfcbd1cc3f042f5dfb8" -dependencies = [ - "cfg-if", -] - [[package]] name = "clang-sys" version = "1.8.1" @@ -1400,9 +1443,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.6" +version = "4.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" +checksum = "8f6b81fb3c84f5563d509c59b5a48d935f689e993afa90fe39047f05adef9142" dependencies = [ "clap_builder", "clap_derive", @@ -1410,9 +1453,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.6" +version = "4.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" +checksum = "5ca6706fd5224857d9ac5eb9355f6683563cc0541c7cd9d014043b57cbec78ac" dependencies = [ "anstream", "anstyle", @@ -1423,14 +1466,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1478,7 +1521,7 @@ dependencies = [ "nom", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1487,13 +1530,23 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "comfy-table" version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ - "strum 0.26.2", + "strum 0.26.3", "strum_macros 0.26.4", "unicode-width", ] @@ -1501,7 +1554,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof#b273d33f9981e2bb3375ab45faeb537f7ee35224" +source = "git+https://github.com/w3f/ring-proof#665f5f51af5734c7b6d90b985dd6861d4c5b4752" dependencies = [ "ark-ec", "ark-ff", @@ -1563,7 +1616,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom 0.2.15", + "getrandom", "once_cell", "tiny-keccak", ] @@ -1743,6 +1796,21 @@ dependencies = [ "wasmtime-types", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.4.2" @@ -1800,7 +1868,7 @@ checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", - "subtle 2.5.0", + "subtle 2.6.1", "zeroize", ] @@ -1832,7 +1900,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.7", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] @@ -1847,7 +1915,7 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "clap", "parity-scale-codec", @@ -1864,7 +1932,7 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", @@ -1887,7 +1955,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-client-collator", @@ -1899,6 +1967,7 @@ dependencies = [ "cumulus-relay-chain-interface", "futures", "parity-scale-codec", + "parking_lot 0.12.3", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-overseer", @@ -1929,7 +1998,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-client-pov-recovery", @@ -1951,6 +2020,7 @@ dependencies = [ "sp-runtime", "sp-timestamp", "sp-trie", + "sp-version", "substrate-prometheus-endpoint", "tracing", ] @@ -1958,7 +2028,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-proposer" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "anyhow", "async-trait", @@ -1973,7 +2043,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-relay-chain" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-client-consensus-common", @@ -1996,7 +2066,7 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -2005,21 +2075,24 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", "polkadot-node-primitives", + "polkadot-node-subsystem", "polkadot-parachain-primitives", "polkadot-primitives", "sc-client-api", + "sp-api", "sp-blockchain", "sp-consensus", "sp-core", "sp-runtime", "sp-state-machine", + "sp-version", "tracing", ] [[package]] name = "cumulus-client-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2034,8 +2107,8 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", "tracing", ] @@ -2043,7 +2116,7 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2058,16 +2131,18 @@ dependencies = [ "rand", "sc-client-api", "sc-consensus", + "sp-api", "sp-consensus", "sp-maybe-compressed-blob", "sp-runtime", + "sp-version", "tracing", ] [[package]] name = "cumulus-client-service" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-client-cli", "cumulus-client-collator", @@ -2104,7 +2179,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-pallet-parachain-system", "frame-support", @@ -2116,13 +2191,13 @@ dependencies = [ "sp-application-crypto", "sp-consensus-aura", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "cumulus-pallet-dmp-queue" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-core", "frame-benchmarking", @@ -2133,14 +2208,14 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", ] [[package]] name = "cumulus-pallet-infra-parachain-core" version = "0.1.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-pallet-xcm", @@ -2155,14 +2230,14 @@ dependencies = [ "softfloat", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", ] [[package]] name = "cumulus-pallet-parachain-system" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bytes", "cumulus-pallet-parachain-system-proc-macro", @@ -2182,33 +2257,34 @@ dependencies = [ "polkadot-runtime-parachains", "scale-info", "sp-core", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-inherents", "sp-io", "sp-runtime", "sp-state-machine", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", "sp-version", "staging-xcm", + "staging-xcm-builder", "trie-db", ] [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.6.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "cumulus-pallet-session-benchmarking" version = "9.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -2216,13 +2292,13 @@ dependencies = [ "pallet-session", "parity-scale-codec", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "cumulus-pallet-xcm" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -2231,14 +2307,14 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", ] [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bounded-collections", "bp-xcm-bridge-hub-router", @@ -2255,15 +2331,16 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", + "staging-xcm-builder", "staging-xcm-executor", ] [[package]] name = "cumulus-primitives-aura" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", @@ -2271,13 +2348,13 @@ dependencies = [ "sp-api", "sp-consensus-aura", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "cumulus-primitives-core" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", @@ -2286,7 +2363,7 @@ dependencies = [ "scale-info", "sp-api", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", "staging-xcm", ] @@ -2294,7 +2371,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2302,37 +2379,39 @@ dependencies = [ "scale-info", "sp-core", "sp-inherents", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-runtime", + "sp-state-machine", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", ] [[package]] name = "cumulus-primitives-proof-size-hostfunction" version = "0.2.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", ] [[package]] name = "cumulus-primitives-timestamp" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-core", "futures", "parity-scale-codec", "sp-inherents", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-timestamp", ] [[package]] name = "cumulus-primitives-utility" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -2343,7 +2422,7 @@ dependencies = [ "polkadot-runtime-parachains", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -2352,7 +2431,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-inprocess-interface" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2376,7 +2455,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-interface" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2388,15 +2467,16 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-state-machine", + "sp-version", "thiserror", ] [[package]] name = "cumulus-relay-chain-minimal-node" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", @@ -2436,7 +2516,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-rpc-interface" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2463,7 +2543,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-state-machine", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-version", "thiserror", "tokio", @@ -2475,14 +2555,14 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", "polkadot-primitives", "sp-runtime", "sp-state-machine", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", ] @@ -2495,37 +2575,23 @@ dependencies = [ "byteorder", "digest 0.8.1", "rand_core 0.5.1", - "subtle 2.5.0", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle 2.5.0", + "subtle 2.6.1", "zeroize", ] [[package]] name = "curve25519-dalek" -version = "4.1.2" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "platforms", "rustc_version", - "subtle 2.5.0", + "subtle 2.6.1", "zeroize", ] @@ -2537,7 +2603,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2555,9 +2621,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8194f089b6da4751d6c1da1ef37c17255df51f9346cdb160f8b096562ae4a85c" +checksum = "273dcfd3acd4e1e276af13ed2a43eea7001318823e7a726a6b3ed39b4acc0b82" dependencies = [ "cc", "cxxbridge-flags", @@ -2567,9 +2633,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8df9a089caae66634d754672d5f909395f30f38af6ff19366980d8a8b57501" +checksum = "d8b2766fbd92be34e9ed143898fce6c572dc009de39506ed6903e5a05b68914e" dependencies = [ "cc", "codespan-reporting", @@ -2577,24 +2643,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "cxxbridge-flags" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25290be4751803672a70b98c68b51c1e7d0a640ab5a4377f240f9d2e70054cd1" +checksum = "839fcd5e43464614ffaa989eaf1c139ef1f0c51672a1ed08023307fa1b909ccd" [[package]] name = "cxxbridge-macro" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cb317cb13604b4752416783bb25070381c36e844743e4146b7f8e55de7d140" +checksum = "4b2c1c1776b986979be68bb2285da855f8d8a35851a769fca8740df7c3d07877" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2652,7 +2718,21 @@ version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ - "asn1-rs", + "asn1-rs 0.5.2", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der-parser" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" +dependencies = [ + "asn1-rs 0.6.1", "displaydoc", "nom", "num-bigint", @@ -2680,17 +2760,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive-syn-parse" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "derive-syn-parse" version = "0.2.0" @@ -2699,51 +2768,20 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "did-core" -version = "0.5.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" -dependencies = [ - "bitflags 1.3.2", - "frame-benchmarking", - "frame-support", - "frame-system", - "hex", - "hex-literal 0.3.4", - "libsecp256k1", - "merlin 2.0.1", - "num-traits", - "parity-scale-codec", - "rand", - "rand_chacha 0.2.2", - "scale-info", - "scale-info-derive 2.3.0", - "schnorrkel 0.9.1", - "serde", - "serde-big-array", - "sha2 0.9.9", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "syn 2.0.72", ] [[package]] @@ -2779,7 +2817,7 @@ dependencies = [ "block-buffer 0.10.4", "const-oid", "crypto-common", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] @@ -2826,13 +2864,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2873,14 +2911,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a081e51fb188742f5a7a1164ad752121abcb22874b21e2c3b0dd040c515fdad" dependencies = [ "common-path", - "derive-syn-parse 0.2.0", + "derive-syn-parse", "once_cell", "proc-macro2", "quote", "regex", - "syn 2.0.66", + "syn 2.0.72", "termcolor", - "toml 0.8.14", + "toml 0.8.15", "walkdir", ] @@ -2960,26 +2998,12 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ - "curve25519-dalek 4.1.2", + "curve25519-dalek 4.1.3", "ed25519", "rand_core 0.6.4", "serde", "sha2 0.10.8", - "subtle 2.5.0", - "zeroize", -] - -[[package]] -name = "ed25519-zebra" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" -dependencies = [ - "curve25519-dalek 3.2.0", - "hashbrown 0.12.3", - "hex", - "rand_core 0.6.4", - "sha2 0.9.9", + "subtle 2.6.1", "zeroize", ] @@ -2989,7 +3013,7 @@ version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ - "curve25519-dalek 4.1.2", + "curve25519-dalek 4.1.3", "ed25519", "hashbrown 0.14.5", "hex", @@ -3000,9 +3024,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -3020,7 +3044,7 @@ dependencies = [ "rand_core 0.6.4", "sec1", "serdect", - "subtle 2.5.0", + "subtle 2.6.1", "zeroize", ] @@ -3042,6 +3066,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "enum-as-inner" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "enumflags2" version = "0.7.10" @@ -3059,7 +3095,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3070,7 +3106,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3122,7 +3158,7 @@ checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" dependencies = [ "concurrent-queue", "parking", - "pin-project-lite 0.2.14", + "pin-project-lite", ] [[package]] @@ -3133,7 +3169,7 @@ checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", - "pin-project-lite 0.2.14", + "pin-project-lite", ] [[package]] @@ -3143,7 +3179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ "event-listener 5.3.1", - "pin-project-lite 0.2.14", + "pin-project-lite", ] [[package]] @@ -3157,28 +3193,17 @@ dependencies = [ [[package]] name = "expander" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a718c0675c555c5f976fff4ea9e2c150fa06cefa201cadef87cfbf9324075881" -dependencies = [ - "blake3", - "fs-err", - "proc-macro2", - "quote", -] - -[[package]] -name = "expander" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e83c02035136f1592a47964ea60c05a50e4ed8b5892cfac197063850898d4d" +checksum = "e2c470c71d91ecbd179935b24170459e926382eaaa86b590b78814e180d8a8e2" dependencies = [ "blake2 0.10.6", + "file-guard", "fs-err", - "prettier-please", + "prettyplease 0.2.20", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3216,9 +3241,9 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fatality" -version = "0.0.6" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad875162843b0d046276327afe0136e9ed3a23d5a754210fb6f1f33610d39ab" +checksum = "ec6f82451ff7f0568c6181287189126d492b5654e30a788add08027b6363d019" dependencies = [ "fatality-proc-macro", "thiserror", @@ -3226,17 +3251,16 @@ dependencies = [ [[package]] name = "fatality-proc-macro" -version = "0.0.6" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5aa1e3ae159e592ad222dc90c5acbad632b527779ba88486abe92782ab268bd" +checksum = "eb42427514b063d97ce21d5199f36c0c307d981434a6be32582bc79fe5bd2303" dependencies = [ - "expander 0.0.4", - "indexmap 1.9.3", - "proc-macro-crate 1.1.3", + "expander", + "indexmap 2.2.6", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 1.0.109", - "thiserror", + "syn 2.0.72", ] [[package]] @@ -3256,7 +3280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] @@ -3278,6 +3302,16 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "file-guard" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21ef72acf95ec3d7dbf61275be556299490a245f017cf084bd23b4f68cf9407c" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "file-per-thread-logger" version = "0.1.6" @@ -3335,35 +3369,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] -name = "flate2" -version = "1.0.30" +name = "float-cmp" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" dependencies = [ - "crc32fast", - "libz-sys", - "miniz_oxide", + "num-traits", ] [[package]] -name = "float-cmp" -version = "0.9.0" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "num-traits", + "foreign-types-shared", ] [[package]] -name = "fnv" -version = "1.0.7" +name = "foreign-types-shared" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "12.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", ] @@ -3377,6 +3415,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "forwarded-header-value" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835f84f38484cc86f110a805655697908257fb9a7af005234060891557198e9" +dependencies = [ + "nonempty", + "thiserror", +] + [[package]] name = "fragile" version = "2.0.0" @@ -3386,7 +3434,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "frame-support-procedural", @@ -3402,19 +3450,19 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "static_assertions", ] [[package]] name = "frame-benchmarking-cli" version = "32.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "Inflector", - "array-bytes 6.2.3", + "array-bytes", "chrono", "clap", "comfy-table", @@ -3423,7 +3471,7 @@ dependencies = [ "frame-system", "gethostname", "handlebars", - "itertools 0.10.5", + "itertools 0.11.0", "lazy_static", "linked-hash-map", "log", @@ -3431,6 +3479,7 @@ dependencies = [ "rand", "rand_pcg", "sc-block-builder", + "sc-chain-spec", "sc-cli", "sc-client-api", "sc-client-db", @@ -3443,15 +3492,16 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-database", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-keystore", "sp-runtime", "sp-state-machine", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", - "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "thiserror", "thousands", ] @@ -3459,18 +3509,18 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "13.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "frame-election-provider-support" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -3481,15 +3531,15 @@ dependencies = [ "sp-core", "sp-npos-elections", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "frame-executive" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "aquamarine 0.3.3", + "aquamarine", "frame-support", "frame-system", "frame-try-runtime", @@ -3499,8 +3549,8 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] @@ -3516,34 +3566,27 @@ dependencies = [ ] [[package]] -name = "frame-remote-externalities" -version = "0.35.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +name = "frame-metadata-hash-extension" +version = "0.1.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "futures", - "indicatif", - "jsonrpsee", + "array-bytes", + "docify", + "frame-support", + "frame-system", "log", "parity-scale-codec", - "serde", - "sp-core", - "sp-crypto-hashing", - "sp-io", + "scale-info", "sp-runtime", - "sp-state-machine", - "spinners", - "substrate-rpc-client", - "tokio", - "tokio-retry", ] [[package]] name = "frame-support" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "aquamarine 0.5.0", - "array-bytes 6.2.3", + "aquamarine", + "array-bytes", "bitflags 1.3.2", "docify", "environmental", @@ -3563,7 +3606,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-crypto-hashing-proc-macro", - "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-genesis-builder", "sp-inherents", "sp-io", @@ -3571,8 +3614,8 @@ dependencies = [ "sp-runtime", "sp-staking", "sp-state-machine", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-weights", "static_assertions", "tt-call", @@ -3581,48 +3624,48 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "23.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "Inflector", "cfg-expr", - "derive-syn-parse 0.2.0", - "expander 2.1.0", + "derive-syn-parse", + "expander", "frame-support-procedural-tools", - "itertools 0.10.5", + "itertools 0.11.0", "macro_magic", - "proc-macro-warning", + "proc-macro-warning 1.0.2", "proc-macro2", "quote", "sp-crypto-hashing", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "frame-support-procedural-tools" version = "10.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "frame-support-procedural-tools-derive" version = "11.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "frame-system" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cfg-if", "docify", @@ -3634,7 +3677,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-version", "sp-weights", ] @@ -3642,7 +3685,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -3651,14 +3694,15 @@ dependencies = [ "scale-info", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "frame-system-rpc-runtime-api" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "docify", "parity-scale-codec", "sp-api", ] @@ -3666,13 +3710,13 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "parity-scale-codec", "sp-api", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] @@ -3725,6 +3769,16 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-bounded" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b07bbbe7d7e78809544c6f718d875627addc73a7c3582447abc052cd3dc67e0" +dependencies = [ + "futures-timer", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.30" @@ -3770,7 +3824,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.14", + "pin-project-lite", "waker-fn", ] @@ -3784,7 +3838,7 @@ dependencies = [ "futures-core", "futures-io", "parking", - "pin-project-lite 0.2.14", + "pin-project-lite", ] [[package]] @@ -3795,18 +3849,17 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "futures-rustls" -version = "0.22.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" +checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" dependencies = [ "futures-io", - "rustls 0.20.9", - "webpki", + "rustls 0.21.12", ] [[package]] @@ -3840,7 +3893,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.14", + "pin-project-lite", "pin-utils", "slab", ] @@ -3884,17 +3937,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.15" @@ -3903,7 +3945,7 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -3987,7 +4029,7 @@ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core 0.6.4", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] @@ -4001,7 +4043,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", "indexmap 2.2.6", "slab", "tokio", @@ -4043,9 +4104,6 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] [[package]] name = "hashbrown" @@ -4053,7 +4111,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.11", + "ahash", ] [[package]] @@ -4062,7 +4120,7 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.11", + "ahash", "allocator-api2", "serde", ] @@ -4094,6 +4152,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -4109,12 +4173,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" -[[package]] -name = "hex-literal" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" - [[package]] name = "hex-literal" version = "0.4.1" @@ -4191,6 +4249,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -4198,21 +4267,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", - "pin-project-lite 0.2.14", + "http 0.2.12", + "pin-project-lite", ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "pin-project-lite", +] [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -4228,21 +4314,21 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.29" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.14", + "pin-project-lite", "socket2 0.5.7", "tokio", "tower-service", @@ -4250,6 +4336,26 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -4257,8 +4363,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.30", "log", "rustls 0.21.12", "rustls-native-certs 0.6.3", @@ -4266,6 +4372,23 @@ dependencies = [ "tokio-rustls 0.24.1", ] +[[package]] +name = "hyper-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.4.1", + "pin-project-lite", + "tokio", + "tower", + "tower-service", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -4300,6 +4423,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "idna" version = "0.5.0" @@ -4339,6 +4472,25 @@ dependencies = [ "windows", ] +[[package]] +name = "igd-next" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "064d90fec10d541084e7b39ead8875a5a80d9114a2b18791565253bae25f49e4" +dependencies = [ + "async-trait", + "attohttpc", + "bytes", + "futures", + "http 0.2.12", + "hyper 0.14.30", + "log", + "rand", + "tokio", + "url", + "xmltree", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -4370,18 +4522,18 @@ dependencies = [ [[package]] name = "include_dir" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" dependencies = [ "include_dir_macros", ] [[package]] name = "include_dir_macros" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" dependencies = [ "proc-macro2", "quote", @@ -4414,23 +4566,10 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" -[[package]] -name = "indicatif" -version = "0.17.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" -dependencies = [ - "console", - "instant", - "number_prefix", - "portable-atomic", - "unicode-width", -] - [[package]] name = "infra-asset-common" version = "0.1.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-utility", "frame-support", @@ -4442,7 +4581,7 @@ dependencies = [ "scale-info", "sp-api", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -4450,8 +4589,8 @@ dependencies = [ ] [[package]] -name = "infra-did-parachain-bin" -version = "1.1.0" +name = "infra-did-yosemite-bin" +version = "1.0.0" dependencies = [ "assert_cmd", "async-trait", @@ -4474,11 +4613,11 @@ dependencies = [ "frame-support", "frame-system-rpc-runtime-api", "futures", - "hex-literal 0.4.1", - "infra-did-parachain-runtime", + "hex-literal", + "infra-did-yosemite-runtime", "jsonrpsee", "log", - "nix 0.26.4", + "nix 0.28.0", "pallet-transaction-payment", "pallet-transaction-payment-rpc", "pallet-transaction-payment-rpc-runtime-api", @@ -4517,7 +4656,7 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-timestamp", "sp-transaction-pool", "sp-version", @@ -4533,8 +4672,8 @@ dependencies = [ ] [[package]] -name = "infra-did-parachain-runtime" -version = "0.1.1" +name = "infra-did-yosemite-runtime" +version = "1.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -4547,7 +4686,6 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", - "did-core", "frame-benchmarking", "frame-executive", "frame-support", @@ -4555,15 +4693,15 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal 0.3.4", + "hex-literal", "infra-asset-common", - "infra-relay-runtime-constants", "log", "pallet-assets", "pallet-aura", "pallet-authorship", "pallet-balances", "pallet-collator-selection", + "pallet-did", "pallet-message-queue", "pallet-preimage", "pallet-scheduler", @@ -4592,8 +4730,8 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-transaction-pool", "sp-version", "sp-weights", @@ -4603,119 +4741,14 @@ dependencies = [ "staging-xcm-executor", "substrate-wasm-builder", "testnet-parachains-constants", + "yosemite-runtime-constants", ] [[package]] -name = "infra-relay-runtime" -version = "1.10.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" -dependencies = [ - "bitvec", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "infra-asset-common", - "infra-relay-runtime-constants", - "log", - "pallet-asset-rate", - "pallet-assets", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-bounties", - "pallet-child-bounties", - "pallet-collective", - "pallet-democracy", - "pallet-elections-phragmen", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-message-queue", - "pallet-multisig", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-preimage", - "pallet-proxy", - "pallet-scheduler", - "pallet-session", - "pallet-session-benchmarking", - "pallet-sudo", - "pallet-system-token-conversion", - "pallet-system-token-tx-payment", - "pallet-timestamp", - "pallet-tips", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-validator-management", - "pallet-vesting", - "pallet-xcm", - "parity-scale-codec", - "polkadot-parachain-primitives", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "softfloat", - "sp-api", - "sp-arithmetic", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-genesis-builder", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-transaction-pool", - "sp-version", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "static_assertions", - "substrate-wasm-builder", -] - -[[package]] -name = "infra-relay-runtime-constants" -version = "1.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", - "staging-xcm", - "staging-xcm-builder", -] - -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ "generic-array 0.14.7", ] @@ -4750,7 +4783,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "windows-sys 0.48.0", ] @@ -4785,7 +4818,7 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "windows-sys 0.52.0", ] @@ -4838,11 +4871,31 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jni" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] @@ -4858,12 +4911,11 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.22.5" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdb12a2381ea5b2e68c3469ec604a007b367778cdb14d09612c8069ebd616ad" +checksum = "62b089779ad7f80768693755a031cc14a7766aba707cbe886674e3f79e9b7e47" dependencies = [ "jsonrpsee-core", - "jsonrpsee-http-client", "jsonrpsee-proc-macros", "jsonrpsee-server", "jsonrpsee-types", @@ -4874,20 +4926,22 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.22.5" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4978087a58c3ab02efc5b07c5e5e2803024536106fd5506f558db172c889b3aa" +checksum = "08163edd8bcc466c33d79e10f695cdc98c00d1e6ddfb95cec41b6b0279dd5432" dependencies = [ + "base64 0.22.1", "futures-util", - "http", + "http 1.1.0", "jsonrpsee-core", "pin-project", - "rustls-native-certs 0.7.0", + "rustls 0.23.12", "rustls-pki-types", - "soketto", + "rustls-platform-verifier", + "soketto 0.8.0", "thiserror", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-util", "tracing", "url", @@ -4895,16 +4949,19 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.22.5" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257e1ec385e07b0255dde0b933f948b5c8b8c28d42afda9587c3a967b896d" +checksum = "79712302e737d23ca0daa178e752c9334846b08321d439fd89af9a384f8c830b" dependencies = [ "anyhow", "async-trait", "beef", + "bytes", "futures-timer", "futures-util", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "jsonrpsee-types", "parking_lot 0.12.3", "pin-project", @@ -4918,55 +4975,39 @@ dependencies = [ "tracing", ] -[[package]] -name = "jsonrpsee-http-client" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ccf93fc4a0bfe05d851d37d7c32b7f370fe94336b52a2f0efc5f1981895c2e5" -dependencies = [ - "async-trait", - "hyper", - "hyper-rustls", - "jsonrpsee-core", - "jsonrpsee-types", - "serde", - "serde_json", - "thiserror", - "tokio", - "tower", - "tracing", - "url", -] - [[package]] name = "jsonrpsee-proc-macros" -version = "0.22.5" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d0bb047e79a143b32ea03974a6bf59b62c2a4c5f5d42a381c907a8bbb3f75c0" +checksum = "7895f186d5921065d96e16bd795e5ca89ac8356ec423fafc6e3d7cf8ec11aee4" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "jsonrpsee-server" -version = "0.22.5" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12d8b6a9674422a8572e0b0abb12feeb3f2aeda86528c80d0350c2bd0923ab41" +checksum = "654afab2e92e5d88ebd8a39d6074483f3f2bfdf91c5ac57fe285e7127cdd4f51" dependencies = [ + "anyhow", "futures-util", - "http", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", + "hyper-util", "jsonrpsee-core", "jsonrpsee-types", "pin-project", "route-recognizer", "serde", "serde_json", - "soketto", + "soketto 0.8.0", "thiserror", "tokio", "tokio-stream", @@ -4977,12 +5018,12 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.22.5" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150d6168405890a7a3231a3c74843f58b8959471f6df76078db2619ddee1d07d" +checksum = "d9c465fbe385238e861fdc4d1c85e04ada6c1fd246161d26385c1b311724d2af" dependencies = [ - "anyhow", "beef", + "http 1.1.0", "serde", "serde_json", "thiserror", @@ -4990,11 +5031,11 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.22.5" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58b9db2dfd5bb1194b0ce921504df9ceae210a345bc2f6c5a61432089bbab070" +checksum = "1c28759775f5cb2f1ea9667672d3fe2b0e701d1f4b7b67954e60afe7fd058b5e" dependencies = [ - "http", + "http 1.1.0", "jsonrpsee-client-transport", "jsonrpsee-core", "jsonrpsee-types", @@ -5076,9 +5117,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lazycell" @@ -5094,12 +5135,12 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -5110,14 +5151,15 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libp2p" -version = "0.51.4" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f35eae38201a993ece6bdc823292d6abd1bffed1c4d0f4a3517d2bd8e1d917fe" +checksum = "e94495eb319a85b70a68b85e2389a95bb3555c71c49025b78c691a854a7e6464" dependencies = [ "bytes", + "either", "futures", "futures-timer", - "getrandom 0.2.15", + "getrandom", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -5134,18 +5176,21 @@ dependencies = [ "libp2p-request-response", "libp2p-swarm", "libp2p-tcp", + "libp2p-upnp", "libp2p-wasm-ext", "libp2p-websocket", "libp2p-yamux", - "multiaddr", + "multiaddr 0.18.1", "pin-project", + "rw-stream-sink", + "thiserror", ] [[package]] name = "libp2p-allow-block-list" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +checksum = "55b46558c5c0bf99d3e2a1a38fd54ff5476ca66dd1737b12466a1824dd219311" dependencies = [ "libp2p-core", "libp2p-identity", @@ -5155,9 +5200,9 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +checksum = "2f5107ad45cb20b2f6c3628c7b6014b996fcb13a88053f4569c872c6e30abf58" dependencies = [ "libp2p-core", "libp2p-identity", @@ -5167,9 +5212,9 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.39.2" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" +checksum = "dd44289ab25e4c9230d9246c475a22241e301b23e8f4061d3bdef304a1a99713" dependencies = [ "either", "fnv", @@ -5178,8 +5223,8 @@ dependencies = [ "instant", "libp2p-identity", "log", - "multiaddr", - "multihash 0.17.0", + "multiaddr 0.18.1", + "multihash 0.19.1", "multistream-select", "once_cell", "parking_lot 0.12.3", @@ -5189,18 +5234,20 @@ dependencies = [ "rw-stream-sink", "smallvec", "thiserror", - "unsigned-varint", + "unsigned-varint 0.7.2", "void", ] [[package]] name = "libp2p-dns" -version = "0.39.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" +checksum = "e6a18db73084b4da2871438f6239fef35190b05023de7656e877c18a00541a3b" dependencies = [ + "async-trait", "futures", "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.3", "smallvec", @@ -5209,19 +5256,20 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.42.2" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" +checksum = "45a96638a0a176bec0a4bcaebc1afa8cf909b114477209d7456ade52c61cd9cd" dependencies = [ "asynchronous-codec", "either", "futures", + "futures-bounded", "futures-timer", "libp2p-core", "libp2p-identity", "libp2p-swarm", "log", - "lru 0.10.1", + "lru 0.12.3", "quick-protobuf", "quick-protobuf-codec", "smallvec", @@ -5231,27 +5279,27 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.3" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" +checksum = "55cca1eb2bc1fd29f099f3daaab7effd01e1a54b7c577d0ed082521034d912e8" dependencies = [ - "bs58 0.4.0", + "bs58 0.5.1", "ed25519-dalek", - "log", - "multiaddr", - "multihash 0.17.0", + "hkdf", + "multihash 0.19.1", "quick-protobuf", "rand", "sha2 0.10.8", "thiserror", + "tracing", "zeroize", ] [[package]] name = "libp2p-kad" -version = "0.43.3" +version = "0.44.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" +checksum = "16ea178dabba6dde6ffc260a8e0452ccdc8f79becf544946692fff9d412fc29d" dependencies = [ "arrayvec 0.7.4", "asynchronous-codec", @@ -5266,20 +5314,21 @@ dependencies = [ "libp2p-swarm", "log", "quick-protobuf", + "quick-protobuf-codec", "rand", "sha2 0.10.8", "smallvec", "thiserror", "uint", - "unsigned-varint", + "unsigned-varint 0.7.2", "void", ] [[package]] name = "libp2p-mdns" -version = "0.43.1" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" +checksum = "42a2567c305232f5ef54185e9604579a894fd0674819402bb0ac0246da82f52a" dependencies = [ "data-encoding", "futures", @@ -5290,38 +5339,43 @@ dependencies = [ "log", "rand", "smallvec", - "socket2 0.4.10", + "socket2 0.5.7", "tokio", - "trust-dns-proto", + "trust-dns-proto 0.22.0", "void", ] [[package]] name = "libp2p-metrics" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" +checksum = "239ba7d28f8d0b5d77760dc6619c05c7e88e74ec8fbbe97f856f20a56745e620" dependencies = [ + "instant", "libp2p-core", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-ping", "libp2p-swarm", + "once_cell", "prometheus-client", ] [[package]] name = "libp2p-noise" -version = "0.42.2" +version = "0.43.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" +checksum = "d2eeec39ad3ad0677551907dd304b2f13f17208ccebe333bef194076cd2e8921" dependencies = [ "bytes", - "curve25519-dalek 3.2.0", + "curve25519-dalek 4.1.3", "futures", "libp2p-core", "libp2p-identity", "log", + "multiaddr 0.18.1", + "multihash 0.19.1", "once_cell", "quick-protobuf", "rand", @@ -5329,21 +5383,22 @@ dependencies = [ "snow", "static_assertions", "thiserror", - "x25519-dalek 1.1.1", + "x25519-dalek", "zeroize", ] [[package]] name = "libp2p-ping" -version = "0.42.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" +checksum = "e702d75cd0827dfa15f8fd92d15b9932abe38d10d21f47c50438c71dd1b5dae3" dependencies = [ "either", "futures", "futures-timer", "instant", "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand", @@ -5352,9 +5407,9 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.7.0-alpha.3" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" +checksum = "130d451d83f21b81eb7b35b360bc7972aeafb15177784adc56528db082e6b927" dependencies = [ "bytes", "futures", @@ -5365,18 +5420,20 @@ dependencies = [ "libp2p-tls", "log", "parking_lot 0.12.3", - "quinn-proto", + "quinn 0.10.2", "rand", - "rustls 0.20.9", + "ring 0.16.20", + "rustls 0.21.12", + "socket2 0.5.7", "thiserror", "tokio", ] [[package]] name = "libp2p-request-response" -version = "0.24.1" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" +checksum = "d8e3b4d67870478db72bac87bfc260ee6641d0734e0e3e275798f089c3fecfd4" dependencies = [ "async-trait", "futures", @@ -5384,15 +5441,17 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-swarm", + "log", "rand", "smallvec", + "void", ] [[package]] name = "libp2p-swarm" -version = "0.42.2" +version = "0.43.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" +checksum = "580189e0074af847df90e75ef54f3f30059aedda37ea5a1659e8b9fca05c0141" dependencies = [ "either", "fnv", @@ -5403,6 +5462,8 @@ dependencies = [ "libp2p-identity", "libp2p-swarm-derive", "log", + "multistream-select", + "once_cell", "rand", "smallvec", "tokio", @@ -5411,36 +5472,39 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +checksum = "c4d5ec2a3df00c7836d7696c136274c9c59705bac69133253696a6c932cd1d74" dependencies = [ "heck 0.4.1", + "proc-macro-warning 0.4.2", + "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] name = "libp2p-tcp" -version = "0.39.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" +checksum = "b558dd40d1bcd1aaaed9de898e9ec6a436019ecc2420dd0016e712fbb61c5508" dependencies = [ "futures", "futures-timer", "if-watch", "libc", "libp2p-core", + "libp2p-identity", "log", - "socket2 0.4.10", + "socket2 0.5.7", "tokio", ] [[package]] name = "libp2p-tls" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" +checksum = "8218d1d5482b122ccae396bbf38abdcb283ecc96fa54760e1dfd251f0546ac61" dependencies = [ "futures", "futures-rustls", @@ -5448,51 +5512,69 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.16.20", - "rustls 0.20.9", + "rustls 0.21.12", + "rustls-webpki 0.101.7", "thiserror", - "webpki", - "x509-parser", + "x509-parser 0.15.1", "yasna", ] +[[package]] +name = "libp2p-upnp" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82775a47b34f10f787ad3e2a22e2c1541e6ebef4fe9f28f3ac553921554c94c1" +dependencies = [ + "futures", + "futures-timer", + "igd-next", + "libp2p-core", + "libp2p-swarm", + "log", + "tokio", + "void", +] + [[package]] name = "libp2p-wasm-ext" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" +checksum = "1e5d8e3a9e07da0ef5b55a9f26c009c8fb3c725d492d8bb4b431715786eea79c" dependencies = [ "futures", "js-sys", "libp2p-core", - "parity-send-wrapper", + "send_wrapper", "wasm-bindgen", "wasm-bindgen-futures", ] [[package]] name = "libp2p-websocket" -version = "0.41.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" +checksum = "004ee9c4a4631435169aee6aad2f62e3984dc031c43b6d29731e8e82a016c538" dependencies = [ "either", "futures", "futures-rustls", "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.3", - "quicksink", + "pin-project-lite", "rw-stream-sink", - "soketto", + "soketto 0.8.0", + "thiserror", "url", - "webpki-roots", + "webpki-roots 0.25.4", ] [[package]] name = "libp2p-yamux" -version = "0.43.1" +version = "0.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" +checksum = "8eedcb62824c4300efb9cfd4e2a6edaf3ca097b9e68b36dabe45a44469fd6a85" dependencies = [ "futures", "libp2p-core", @@ -5507,7 +5589,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -5553,7 +5635,7 @@ checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" dependencies = [ "crunchy", "digest 0.9.0", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] @@ -5649,21 +5731,58 @@ dependencies = [ ] [[package]] -name = "lite-json" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0e787ffe1153141a0f6f6d759fdf1cc34b1226e088444523812fd412a5cca2" -dependencies = [ - "lite-parser", -] - -[[package]] -name = "lite-parser" -version = "0.2.0" +name = "litep2p" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d5f9dc37c52d889a21fd701983d02bb6a84f852c5140a6c80ef4557f7dc29e" +checksum = "0f46c51c205264b834ceed95c8b195026e700494bc3991aaba3b4ea9e20626d9" dependencies = [ - "paste", + "async-trait", + "bs58 0.4.0", + "bytes", + "cid 0.10.1", + "ed25519-dalek", + "futures", + "futures-timer", + "hex-literal", + "indexmap 2.2.6", + "libc", + "mockall 0.12.1", + "multiaddr 0.17.1", + "multihash 0.17.0", + "network-interface", + "nohash-hasher", + "parking_lot 0.12.3", + "pin-project", + "prost 0.12.6", + "prost-build 0.11.9", + "quinn 0.9.4", + "rand", + "rcgen", + "ring 0.16.20", + "rustls 0.20.9", + "serde", + "sha2 0.10.8", + "simple-dns", + "smallvec", + "snow", + "socket2 0.5.7", + "static_assertions", + "str0m", + "thiserror", + "tokio", + "tokio-stream", + "tokio-tungstenite", + "tokio-util", + "tracing", + "trust-dns-resolver", + "uint", + "unsigned-varint 0.8.0", + "url", + "webpki", + "x25519-dalek", + "x509-parser 0.16.0", + "yasna", + "zeroize", ] [[package]] @@ -5678,24 +5797,24 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" -dependencies = [ - "hashbrown 0.13.2", -] +checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" [[package]] name = "lru" -version = "0.11.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +dependencies = [ + "hashbrown 0.14.5", +] [[package]] name = "lru-cache" @@ -5708,9 +5827,9 @@ dependencies = [ [[package]] name = "lz4" -version = "1.24.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1" +checksum = "958b4caa893816eea05507c20cfe47574a43d9a697138a7872990bba8a0ece68" dependencies = [ "libc", "lz4-sys", @@ -5718,9 +5837,9 @@ dependencies = [ [[package]] name = "lz4-sys" -version = "1.9.4" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +checksum = "109de74d5d2353660401699a4174a4ff23fcc649caf553df71933c7fb45ad868" dependencies = [ "cc", "libc", @@ -5737,73 +5856,58 @@ dependencies = [ [[package]] name = "macro_magic" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e03844fc635e92f3a0067e25fa4bf3e3dbf3f2927bf3aa01bb7bc8f1c428949d" +checksum = "cc33f9f0351468d26fbc53d9ce00a096c8522ecb42f19b50f34f2c422f76d21d" dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "macro_magic_core" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "468155613a44cfd825f1fb0ffa532b018253920d404e6fca1e8d43155198a46d" +checksum = "1687dc887e42f352865a393acae7cf79d98fab6351cde1f58e9e057da89bf150" dependencies = [ "const-random", - "derive-syn-parse 0.1.5", + "derive-syn-parse", "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "macro_magic_core_macros" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea73aa640dc01d62a590d48c0c3521ed739d53b27f919b25c3551e233481654" +checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "macro_magic_macros" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef9d79ae96aaba821963320eb2b6e34d17df1e5a83d8a1985c29cc5be59577b3" +checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.66", + "syn 2.0.72", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - [[package]] name = "match_cfg" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" -[[package]] -name = "matchers" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" -dependencies = [ - "regex-automata 0.1.10", -] - [[package]] name = "matchers" version = "0.1.0" @@ -5831,9 +5935,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memfd" @@ -5862,15 +5966,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.8.0" @@ -5932,22 +6027,23 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi 0.3.9", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "wasi", + "windows-sys 0.52.0", ] [[package]] @@ -5961,7 +6057,7 @@ dependencies = [ "bitflags 1.3.2", "blake2 0.10.6", "c2-chacha", - "curve25519-dalek 4.1.2", + "curve25519-dalek 4.1.3", "either", "hashlink", "lioness", @@ -5970,7 +6066,7 @@ dependencies = [ "rand", "rand_chacha 0.3.1", "rand_distr", - "subtle 2.5.0", + "subtle 2.6.1", "thiserror", "zeroize", ] @@ -5978,7 +6074,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "29.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "log", @@ -5997,7 +6093,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -6019,11 +6115,26 @@ dependencies = [ "downcast", "fragile", "lazy_static", - "mockall_derive", + "mockall_derive 0.11.4", "predicates 2.1.5", "predicates-tree", ] +[[package]] +name = "mockall" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43766c2b5203b10de348ffe19f7e54564b64f3d6018ff7648d1e2d6d3a0f0a48" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "lazy_static", + "mockall_derive 0.12.1", + "predicates 3.1.0", + "predicates-tree", +] + [[package]] name = "mockall_derive" version = "0.11.4" @@ -6037,10 +6148,22 @@ dependencies = [ ] [[package]] -name = "multiaddr" -version = "0.17.1" +name = "mockall_derive" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" +checksum = "af7cbce79ec385a1d4f54baa90a76401eb15d9cab93685f62e7e9f942aa00ae2" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "multiaddr" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" dependencies = [ "arrayref", "byteorder", @@ -6051,7 +6174,26 @@ dependencies = [ "percent-encoding", "serde", "static_assertions", - "unsigned-varint", + "unsigned-varint 0.7.2", + "url", +] + +[[package]] +name = "multiaddr" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b852bc02a2da5feed68cd14fa50d0774b92790a5bdbfa932a813926c8472070" +dependencies = [ + "arrayref", + "byteorder", + "data-encoding", + "libp2p-identity", + "multibase", + "multihash 0.19.1", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint 0.7.2", "url", ] @@ -6077,10 +6219,10 @@ dependencies = [ "blake3", "core2", "digest 0.10.7", - "multihash-derive 0.8.1", + "multihash-derive", "sha2 0.10.8", "sha3", - "unsigned-varint", + "unsigned-varint 0.7.2", ] [[package]] @@ -6089,11 +6231,15 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfd8a792c1694c6da4f68db0a9d707c72bd260994da179e6030a5dcee00bb815" dependencies = [ + "blake2b_simd", + "blake2s_simd", + "blake3", "core2", "digest 0.10.7", - "multihash-derive 0.8.1", + "multihash-derive", "sha2 0.10.8", - "unsigned-varint", + "sha3", + "unsigned-varint 0.7.2", ] [[package]] @@ -6103,27 +6249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "076d548d76a0e2a0d4ab471d0b1c36c577786dfc4471242035d97a12a735c492" dependencies = [ "core2", - "unsigned-varint", -] - -[[package]] -name = "multihash-codetable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d815ecb3c8238d00647f8630ede7060a642c9f704761cd6082cb4028af6935" -dependencies = [ - "blake2b_simd", - "blake2s_simd", - "blake3", - "core2", - "digest 0.10.7", - "multihash-derive 0.9.0", - "ripemd", - "serde", - "sha1", - "sha2 0.10.8", - "sha3", - "strobe-rs", + "unsigned-varint 0.7.2", ] [[package]] @@ -6141,55 +6267,36 @@ dependencies = [ ] [[package]] -name = "multihash-derive" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "890e72cb7396cb99ed98c1246a97b243cc16394470d94e0bc8b0c2c11d84290e" -dependencies = [ - "core2", - "multihash 0.19.1", - "multihash-derive-impl", -] - -[[package]] -name = "multihash-derive-impl" -version = "0.1.1" +name = "multimap" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3958713ce794e12f7c6326fac9aa274c68d74c4881dd37b3e2662b8a2046bb19" -dependencies = [ - "proc-macro-crate 2.0.0", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure 0.13.1", -] +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "multimap" -version = "0.8.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "multistream-select" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" dependencies = [ "bytes", "futures", "log", "pin-project", "smallvec", - "unsigned-varint", + "unsigned-varint 0.7.2", ] [[package]] name = "nalgebra" -version = "0.32.5" +version = "0.32.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea4908d4f23254adda3daa60ffef0f1ac7b8c3e9a864cf3cc154b251908a2ef" +checksum = "7b5c17de023a86f59ed79891b2e5d5a94c705dbe904a5b5c9c952ea6221b03e4" dependencies = [ "approx", "matrixmultiply", @@ -6203,13 +6310,13 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" +checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] @@ -6294,37 +6401,37 @@ dependencies = [ ] [[package]] -name = "nix" -version = "0.24.3" +name = "network-interface" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +checksum = "a4a43439bf756eed340bdf8feba761e2d50c7d47175d87545cd5cbe4a137c4d1" dependencies = [ - "bitflags 1.3.2", - "cfg-if", + "cc", "libc", + "thiserror", + "winapi", ] [[package]] name = "nix" -version = "0.26.4" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", - "memoffset 0.7.1", - "pin-utils", ] [[package]] name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cfg-if", + "cfg_aliases", "libc", ] @@ -6362,6 +6469,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nonempty" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7" + [[package]] name = "nonzero_ext" version = "0.3.0" @@ -6386,9 +6499,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -6455,16 +6568,10 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "object" version = "0.30.4" @@ -6488,9 +6595,9 @@ dependencies = [ [[package]] name = "object" -version = "0.35.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" dependencies = [ "memchr", ] @@ -6501,7 +6608,16 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" dependencies = [ - "asn1-rs", + "asn1-rs 0.5.2", +] + +[[package]] +name = "oid-registry" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" +dependencies = [ + "asn1-rs 0.6.1", ] [[package]] @@ -6522,12 +6638,60 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.3.1+3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" +dependencies = [ + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "openssl-src", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -6557,7 +6721,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1344346d5af32c95bbddea91b18a88cc83eac394192d20ef2fc4c40a74332355" dependencies = [ - "expander 2.1.0", + "expander", "indexmap 2.2.6", "itertools 0.11.0", "petgraph", @@ -6585,11 +6749,12 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pallet-asset-conversion" version = "10.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "sp-api", @@ -6597,13 +6762,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-asset-rate" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6612,13 +6777,13 @@ dependencies = [ "scale-info", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-asset-tx-payment" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6630,31 +6795,30 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-assets" -version = "4.0.0-dev" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +version = "29.1.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "impl-trait-for-tuples", "log", - "pallet-system-token-oracle", "parity-scale-codec", "scale-info", - "softfloat", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-aura" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "frame-system", @@ -6665,13 +6829,13 @@ dependencies = [ "sp-application-crypto", "sp-consensus-aura", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-authority-discovery" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "frame-system", @@ -6681,13 +6845,13 @@ dependencies = [ "sp-application-crypto", "sp-authority-discovery", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-authorship" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "frame-system", @@ -6695,13 +6859,13 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-babe" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6719,13 +6883,13 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-balances" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "docify", "frame-benchmarking", @@ -6735,13 +6899,58 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-beefy" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "scale-info", + "serde", + "sp-consensus-beefy", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-beefy-mmr" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "array-bytes", + "binary-merkle-tree", + "frame-support", + "frame-system", + "log", + "pallet-beefy", + "pallet-mmr", + "pallet-session", + "parity-scale-codec", + "scale-info", + "serde", + "sp-api", + "sp-consensus-beefy", + "sp-core", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-bounties" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6753,30 +6962,32 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-broker" version = "0.6.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", + "sp-api", "sp-arithmetic", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-child-bounties" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6789,32 +7000,33 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-collator-selection" version = "9.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "log", "pallet-authorship", + "pallet-balances", "pallet-session", "parity-scale-codec", "rand", "scale-info", "sp-runtime", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-collective" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6826,13 +7038,30 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-conviction-voting" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "assert_matches", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-democracy" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6844,13 +7073,45 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-did" +version = "0.1.0" +dependencies = [ + "bitflags 2.6.0", + "frame-benchmarking", + "frame-support", + "frame-system", + "hex", + "hex-literal", + "libsecp256k1", + "merlin 3.0.0", + "num-traits", + "pallet-balances", + "pallet-timestamp", + "parity-scale-codec", + "rand", + "rand_chacha 0.3.1", + "scale-info", + "scale-info-derive 2.3.0", + "schnorrkel 0.9.1", + "serde", + "serde-big-array", + "sha2 0.10.8", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-election-provider-multi-phase" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6866,14 +7127,14 @@ dependencies = [ "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "strum 0.26.2", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "strum 0.26.3", ] [[package]] name = "pallet-election-provider-support-benchmarking" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6881,13 +7142,13 @@ dependencies = [ "parity-scale-codec", "sp-npos-elections", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-elections-phragmen" version = "29.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6900,13 +7161,13 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-fast-unstake" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "docify", "frame-benchmarking", @@ -6919,13 +7180,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-grandpa" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6942,13 +7203,13 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-identity" -version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +version = "29.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "enumflags2", "frame-benchmarking", @@ -6959,13 +7220,13 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-im-online" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6979,13 +7240,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-indices" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -6996,13 +7257,13 @@ dependencies = [ "sp-io", "sp-keyring", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-membership" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -7013,13 +7274,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-message-queue" version = "31.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "environmental", "frame-benchmarking", @@ -7032,14 +7293,32 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-weights", ] +[[package]] +name = "pallet-mmr" +version = "27.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-mmr-primitives", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + [[package]] name = "pallet-multisig" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -7049,13 +7328,29 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-nis" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-offences" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "frame-system", @@ -7065,70 +7360,132 @@ dependencies = [ "scale-info", "serde", "sp-runtime", - "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-staking", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-parameters" +version = "0.1.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-preimage" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-proxy" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-ranked-collective" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] -name = "pallet-offences-benchmarking" +name = "pallet-recovery" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", - "frame-election-provider-support", "frame-support", "frame-system", - "log", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-im-online", - "pallet-offences", - "pallet-session", - "pallet-staking", "parity-scale-codec", "scale-info", + "sp-io", "sp-runtime", - "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] -name = "pallet-preimage" +name = "pallet-referenda" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "assert_matches", "frame-benchmarking", "frame-support", "frame-system", "log", "parity-scale-codec", "scale-info", - "sp-core", + "serde", + "sp-arithmetic", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] -name = "pallet-proxy" -version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +name = "pallet-root-testing" +version = "4.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", "scale-info", + "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-scheduler" version = "29.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "docify", "frame-benchmarking", @@ -7139,14 +7496,14 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-weights", ] [[package]] name = "pallet-session" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "frame-system", @@ -7161,31 +7518,32 @@ dependencies = [ "sp-session", "sp-staking", "sp-state-machine", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", ] [[package]] -name = "pallet-session-benchmarking" +name = "pallet-society" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "pallet-session", - "pallet-staking", + "log", "parity-scale-codec", - "rand", + "rand_chacha 0.3.1", + "scale-info", + "sp-arithmetic", + "sp-io", "sp-runtime", - "sp-session", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-staking" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -7195,84 +7553,81 @@ dependencies = [ "pallet-authorship", "pallet-session", "parity-scale-codec", - "rand_chacha 0.2.2", + "rand_chacha 0.3.1", "scale-info", "serde", "sp-application-crypto", "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-staking-reward-fn" version = "19.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "log", "sp-arithmetic", ] [[package]] -name = "pallet-sudo" -version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +name = "pallet-state-trie-migration" +version = "29.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "docify", "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", + "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] -name = "pallet-system-token-conversion" -version = "0.4.0-dev" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +name = "pallet-sudo" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "docify", "frame-benchmarking", "frame-support", "frame-system", - "log", "parity-scale-codec", "scale-info", - "serde", - "sp-arithmetic", - "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] -name = "pallet-system-token-oracle" -version = "0.1.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +name = "pallet-system-token-conversion" +version = "0.4.0-dev" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", - "lite-json", "log", - "pallet-session", - "pallet-timestamp", "parity-scale-codec", "scale-info", - "serde_json", + "serde", + "sp-arithmetic", "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-system-token-tx-payment" version = "0.1.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -7288,13 +7643,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-timestamp" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "docify", "frame-benchmarking", @@ -7306,15 +7661,15 @@ dependencies = [ "sp-inherents", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-timestamp", ] [[package]] name = "pallet-tips" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -7327,13 +7682,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-transaction-payment" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "frame-system", @@ -7343,13 +7698,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-transaction-payment-rpc" version = "30.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -7365,7 +7720,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -7377,7 +7732,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "docify", "frame-benchmarking", @@ -7390,13 +7745,13 @@ dependencies = [ "serde", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-utility" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -7406,13 +7761,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-validator-management" version = "0.1.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -7430,13 +7785,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-vesting" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-benchmarking", "frame-support", @@ -7445,13 +7800,28 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", +] + +[[package]] +name = "pallet-whitelist" +version = "27.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "pallet-xcm" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bounded-collections", "frame-benchmarking", @@ -7465,17 +7835,36 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "xcm-runtime-apis", +] + +[[package]] +name = "pallet-xcm-benchmarks" +version = "7.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", - "xcm-fee-payment-runtime-api", ] [[package]] name = "parachains-common" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-core", "cumulus-primitives-utility", @@ -7496,7 +7885,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-parachain-info", "staging-xcm", "staging-xcm-executor", @@ -7564,12 +7953,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - [[package]] name = "parity-wasm" version = "0.45.0" @@ -7625,9 +8008,9 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.3", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -7644,7 +8027,7 @@ checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" dependencies = [ "base64ct", "rand_core 0.6.4", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] @@ -7686,9 +8069,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" +checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" dependencies = [ "memchr", "thiserror", @@ -7697,9 +8080,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" +checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" dependencies = [ "pest", "pest_generator", @@ -7707,22 +8090,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" +checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "pest_meta" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" +checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" dependencies = [ "once_cell", "pest", @@ -7756,15 +8139,9 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] -[[package]] -name = "pin-project-lite" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - [[package]] name = "pin-project-lite" version = "0.2.14" @@ -7804,21 +8181,15 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "platforms" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" - [[package]] name = "polkadot-approval-distribution" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "futures", "futures-timer", - "itertools 0.10.5", + "itertools 0.11.0", "polkadot-node-jaeger", "polkadot-node-metrics", "polkadot-node-network-protocol", @@ -7833,7 +8204,7 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "always-assert", "futures", @@ -7849,7 +8220,7 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "derive_more", "fatality", @@ -7862,6 +8233,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-primitives", "rand", + "sc-network", "schnellru", "sp-core", "sp-keystore", @@ -7872,7 +8244,7 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "fatality", @@ -7892,16 +8264,28 @@ dependencies = [ "tracing-gum", ] +[[package]] +name = "polkadot-ckb-merkle-mountain-range" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b44320e5f7ce2c18227537a3032ae5b2c476a7e8eddba45333e1011fc31b92" +dependencies = [ + "cfg-if", + "itertools 0.10.5", +] + [[package]] name = "polkadot-cli" -version = "1.1.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +version = "7.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "cfg-if", "clap", "frame-benchmarking-cli", "futures", "log", "polkadot-node-metrics", + "polkadot-node-primitives", "polkadot-service", "sc-cli", "sc-executor", @@ -7916,13 +8300,12 @@ dependencies = [ "sp-runtime", "substrate-build-script-utils", "thiserror", - "try-runtime-cli", ] [[package]] name = "polkadot-collator-protocol" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "fatality", @@ -7944,19 +8327,19 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "scale-info", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "polkadot-dispute-distribution" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "derive_more", "fatality", @@ -7981,7 +8364,7 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -7995,7 +8378,7 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "futures-timer", @@ -8017,7 +8400,7 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "always-assert", "async-trait", @@ -8040,7 +8423,7 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "parity-scale-codec", @@ -8058,13 +8441,13 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "derive_more", "futures", "futures-timer", - "itertools 0.10.5", + "itertools 0.11.0", "kvdb", "merlin 3.0.0", "parity-scale-codec", @@ -8091,7 +8474,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "futures", @@ -8113,7 +8496,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "fatality", @@ -8133,7 +8516,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "polkadot-node-subsystem", @@ -8148,7 +8531,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -8169,7 +8552,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "polkadot-node-metrics", @@ -8183,7 +8566,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "futures-timer", @@ -8200,7 +8583,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "fatality", "futures", @@ -8219,7 +8602,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -8236,7 +8619,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-prospective-parachains" version = "6.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "fatality", @@ -8253,7 +8636,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "fatality", @@ -8271,16 +8654,14 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "always-assert", - "array-bytes 6.2.3", + "array-bytes", "blake3", "cfg-if", "futures", "futures-timer", - "is_executable", - "libc", "parity-scale-codec", "pin-project", "polkadot-core-primitives", @@ -8293,8 +8674,6 @@ dependencies = [ "rand", "slotmap", "sp-core", - "sp-maybe-compressed-blob", - "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", "tempfile", "thiserror", "tokio", @@ -8304,7 +8683,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-checker" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "polkadot-node-primitives", @@ -8320,14 +8699,13 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-common" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "cfg-if", "cpu-time", "futures", "landlock", "libc", - "nix 0.27.1", + "nix 0.28.0", "parity-scale-codec", "polkadot-parachain-primitives", "polkadot-primitives", @@ -8337,9 +8715,9 @@ dependencies = [ "seccompiler", "sp-core", "sp-crypto-hashing", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-io", - "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "thiserror", "tracing-gum", ] @@ -8347,7 +8725,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-runtime-api" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "polkadot-node-metrics", @@ -8362,7 +8740,7 @@ dependencies = [ [[package]] name = "polkadot-node-jaeger" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "lazy_static", "log", @@ -8372,6 +8750,7 @@ dependencies = [ "polkadot-node-primitives", "polkadot-primitives", "sc-network", + "sc-network-types", "sp-core", "thiserror", "tokio", @@ -8380,7 +8759,7 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bs58 0.5.1", "futures", @@ -8399,7 +8778,7 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-channel 1.9.0", "async-trait", @@ -8415,7 +8794,9 @@ dependencies = [ "rand", "sc-authority-discovery", "sc-network", - "strum 0.26.2", + "sc-network-types", + "sp-runtime", + "strum 0.26.3", "thiserror", "tracing-gum", ] @@ -8423,7 +8804,7 @@ dependencies = [ [[package]] name = "polkadot-node-primitives" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "bounded-vec", @@ -8446,7 +8827,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -8456,11 +8837,12 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "bitvec", "derive_more", + "fatality", "futures", "orchestra", "polkadot-node-jaeger", @@ -8470,6 +8852,7 @@ dependencies = [ "polkadot-statement-table", "sc-client-api", "sc-network", + "sc-network-types", "sc-transaction-pool-api", "smallvec", "sp-api", @@ -8484,19 +8867,20 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "derive_more", "fatality", "futures", "futures-channel", - "itertools 0.10.5", + "itertools 0.11.0", "kvdb", "parity-db", "parity-scale-codec", "parking_lot 0.12.3", "pin-project", + "polkadot-erasure-coding", "polkadot-node-jaeger", "polkadot-node-metrics", "polkadot-node-network-protocol", @@ -8519,7 +8903,7 @@ dependencies = [ [[package]] name = "polkadot-overseer" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -8541,7 +8925,7 @@ dependencies = [ [[package]] name = "polkadot-parachain-primitives" version = "6.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bounded-collections", "derive_more", @@ -8551,17 +8935,17 @@ dependencies = [ "serde", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-weights", ] [[package]] name = "polkadot-primitives" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", - "hex-literal 0.4.1", + "hex-literal", "log", "parity-scale-codec", "polkadot-core-primitives", @@ -8579,13 +8963,13 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "polkadot-rpc" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "jsonrpsee", "mmr-rpc", @@ -8605,10 +8989,12 @@ dependencies = [ "sc-sync-state-rpc", "sc-transaction-pool-api", "sp-api", + "sp-application-crypto", "sp-block-builder", "sp-blockchain", "sp-consensus", "sp-consensus-babe", + "sp-consensus-beefy", "sp-keystore", "sp-runtime", "substrate-frame-rpc-system", @@ -8618,7 +9004,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitvec", "frame-benchmarking", @@ -8659,7 +9045,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -8669,20 +9055,20 @@ dependencies = [ [[package]] name = "polkadot-runtime-metrics" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bs58 0.5.1", "frame-benchmarking", "parity-scale-codec", "polkadot-primitives", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "polkadot-runtime-parachains" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bitflags 1.3.2", "bitvec", @@ -8709,7 +9095,6 @@ dependencies = [ "polkadot-runtime-metrics", "rand", "rand_chacha 0.3.1", - "rustc-hex", "scale-info", "serde", "softfloat", @@ -8723,7 +9108,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "staging-xcm", "staging-xcm-executor", "static_assertions", @@ -8732,31 +9117,28 @@ dependencies = [ [[package]] name = "polkadot-service" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "bitvec", "frame-benchmarking", "frame-benchmarking-cli", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-rpc-runtime-api", "futures", - "hex-literal 0.4.1", - "infra-relay-runtime", - "infra-relay-runtime-constants", + "hex-literal", "is_executable", "kvdb", "kvdb-rocksdb", "log", "mmr-gadget", "pallet-babe", - "pallet-im-online", "pallet-staking", "pallet-system-token-tx-payment", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-validator-management", "parity-db", "parity-scale-codec", "parking_lot 0.12.3", @@ -8839,7 +9221,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-state-machine", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-timestamp", "sp-transaction-pool", "sp-version", @@ -8848,13 +9230,15 @@ dependencies = [ "substrate-prometheus-endpoint", "thiserror", "tracing-gum", - "xcm-fee-payment-runtime-api", + "xcm-runtime-apis", + "yosemite-runtime", + "yosemite-runtime-constants", ] [[package]] name = "polkadot-statement-distribution" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -8877,7 +9261,7 @@ dependencies = [ [[package]] name = "polkadot-statement-table" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -8934,7 +9318,7 @@ dependencies = [ "polkavm-common", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -8944,7 +9328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" dependencies = [ "polkavm-derive-impl", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -8980,20 +9364,20 @@ dependencies = [ "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.14", + "pin-project-lite", "windows-sys 0.48.0", ] [[package]] name = "polling" -version = "3.7.1" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6a007746f34ed64099e88783b0ae369eaa3da6392868ba262e2af9b8fbaea1" +checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi", - "pin-project-lite 0.2.14", + "hermit-abi 0.4.0", + "pin-project-lite", "rustix 0.38.34", "tracing", "windows-sys 0.52.0", @@ -9024,9 +9408,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" [[package]] name = "powerfmt" @@ -9081,21 +9465,11 @@ dependencies = [ "termtree", ] -[[package]] -name = "prettier-please" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22020dfcf177fcc7bf5deaf7440af371400c67c0de14c399938d8ed4fb4645d3" -dependencies = [ - "proc-macro2", - "syn 2.0.66", -] - [[package]] name = "prettyplease" -version = "0.1.11" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28f53e8b192565862cf99343194579a022eb9c7dd3a8d03134734803c7b3125" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ "proc-macro2", "syn 1.0.109", @@ -9108,7 +9482,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -9150,15 +9524,6 @@ dependencies = [ "toml 0.5.11", ] -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.7", -] - [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -9192,6 +9557,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-warning" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "proc-macro-warning" version = "1.0.2" @@ -9200,14 +9576,14 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -9228,9 +9604,9 @@ dependencies = [ [[package]] name = "prometheus-client" -version = "0.19.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" +checksum = "3c99afa9a01501019ac3a14d71d9f94050346f55ca471ce90c799a15c58f61e2" dependencies = [ "dtoa", "itoa", @@ -9246,7 +9622,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -9280,17 +9656,38 @@ dependencies = [ "itertools 0.10.5", "lazy_static", "log", - "multimap", + "multimap 0.8.3", "petgraph", - "prettyplease 0.1.11", + "prettyplease 0.1.25", "prost 0.11.9", - "prost-types", + "prost-types 0.11.9", "regex", "syn 1.0.109", "tempfile", "which", ] +[[package]] +name = "prost-build" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" +dependencies = [ + "bytes", + "heck 0.5.0", + "itertools 0.12.1", + "log", + "multimap 0.10.0", + "once_cell", + "petgraph", + "prettyplease 0.2.20", + "prost 0.12.6", + "prost-types 0.12.6", + "regex", + "syn 2.0.72", + "tempfile", +] + [[package]] name = "prost-derive" version = "0.11.9" @@ -9314,7 +9711,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -9326,6 +9723,15 @@ dependencies = [ "prost 0.11.9", ] +[[package]] +name = "prost-types" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +dependencies = [ + "prost 0.12.6", +] + [[package]] name = "psm" version = "0.1.21" @@ -9345,7 +9751,7 @@ dependencies = [ "libc", "once_cell", "raw-cpuid", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "web-sys", "winapi", ] @@ -9367,26 +9773,51 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +checksum = "f8ededb1cd78531627244d51dd0c7139fbe736c7d57af0092a76f0ffb2f56e98" dependencies = [ "asynchronous-codec", "bytes", "quick-protobuf", "thiserror", - "unsigned-varint", + "unsigned-varint 0.7.2", ] [[package]] -name = "quicksink" -version = "0.1.2" +name = "quinn" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858" +checksum = "2e8b432585672228923edbbf64b8b12c14e1112f62e88737655b4a083dbcd78e" dependencies = [ - "futures-core", - "futures-sink", - "pin-project-lite 0.1.12", + "bytes", + "pin-project-lite", + "quinn-proto 0.9.6", + "quinn-udp 0.3.2", + "rustc-hash", + "rustls 0.20.9", + "thiserror", + "tokio", + "tracing", + "webpki", +] + +[[package]] +name = "quinn" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cc2c5017e4b43d5995dcea317bc46c1e09404c0a9664d2908f7f02dfe943d75" +dependencies = [ + "bytes", + "futures-io", + "pin-project-lite", + "quinn-proto 0.10.6", + "quinn-udp 0.4.1", + "rustc-hash", + "rustls 0.21.12", + "thiserror", + "tokio", + "tracing", ] [[package]] @@ -9407,6 +9838,49 @@ dependencies = [ "webpki", ] +[[package]] +name = "quinn-proto" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "141bf7dfde2fbc246bfd3fe12f2455aa24b0fbd9af535d8c86c7bd1381ff2b1a" +dependencies = [ + "bytes", + "rand", + "ring 0.16.20", + "rustc-hash", + "rustls 0.21.12", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "641538578b21f5e5c8ea733b736895576d0fe329bb883b937db6f4d163dbaaf4" +dependencies = [ + "libc", + "quinn-proto 0.9.6", + "socket2 0.4.10", + "tracing", + "windows-sys 0.42.0", +] + +[[package]] +name = "quinn-udp" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "055b4e778e8feb9f93c4e439f71dc2156ef13360b432b799e179a8c4cdf0b1d7" +dependencies = [ + "bytes", + "libc", + "socket2 0.5.7", + "tracing", + "windows-sys 0.48.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -9458,9 +9932,6 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] [[package]] name = "rand_core" @@ -9468,7 +9939,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.15", + "getrandom", ] [[package]] @@ -9492,11 +9963,11 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.0.2" +version = "11.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd" +checksum = "cb9ee317cfe3fbd54b36a511efc1edd42e216903c9cd575e686dd68a2ba90d8d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -9557,11 +10028,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -9570,7 +10041,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.15", + "getrandom", "libredox", "thiserror", ] @@ -9604,7 +10075,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -9693,19 +10164,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ "hmac 0.12.1", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] name = "ring" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof#b273d33f9981e2bb3375ab45faeb537f7ee35224" +source = "git+https://github.com/w3f/ring-proof#665f5f51af5734c7b6d90b985dd6861d4c5b4752" dependencies = [ "ark-ec", "ark-ff", "ark-poly", "ark-serialize", "ark-std", + "arrayvec 0.7.4", "blake2 0.10.6", "common", "fflonk", @@ -9735,22 +10207,13 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.15", + "getrandom", "libc", "spin 0.9.8", "untrusted 0.9.0", "windows-sys 0.52.0", ] -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "rocksdb" version = "0.21.0" @@ -9873,7 +10336,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys 0.4.14", @@ -9886,7 +10349,6 @@ version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ - "log", "ring 0.16.20", "sct", "webpki", @@ -9906,15 +10368,16 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.4" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "log", + "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.4", - "subtle 2.5.0", + "rustls-webpki 0.102.6", + "subtle 2.6.1", "zeroize", ] @@ -9932,9 +10395,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", "rustls-pemfile 2.1.2", @@ -9968,6 +10431,33 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +[[package]] +name = "rustls-platform-verifier" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e3beb939bcd33c269f4bf946cc829fcd336370267c4a927ac0399c84a3151a1" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls 0.23.12", + "rustls-native-certs 0.7.1", + "rustls-platform-verifier-android", + "rustls-webpki 0.102.6", + "security-framework", + "security-framework-sys", + "webpki-roots 0.26.3", + "winapi", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -9980,9 +10470,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -10008,9 +10498,9 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" dependencies = [ "futures", "pin-project", @@ -10025,9 +10515,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "safe_arch" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" +checksum = "c3460605018fdc9612bce72735cba0d27efbcd9904780d44c7e3a9948f96148a" dependencies = [ "bytemuck", ] @@ -10044,18 +10534,18 @@ dependencies = [ [[package]] name = "sc-allocator" version = "23.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "log", "sp-core", - "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "thiserror", ] [[package]] name = "sc-authority-discovery" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -10064,14 +10554,14 @@ dependencies = [ "libp2p", "linked_hash_set", "log", - "multihash 0.18.1", - "multihash-codetable", + "multihash 0.19.1", "parity-scale-codec", "prost 0.12.6", - "prost-build", + "prost-build 0.12.6", "rand", "sc-client-api", "sc-network", + "sc-network-types", "sp-api", "sp-authority-discovery", "sp-blockchain", @@ -10085,7 +10575,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "futures-timer", @@ -10107,7 +10597,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "sp-api", @@ -10121,10 +10611,10 @@ dependencies = [ [[package]] name = "sc-chain-spec" -version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +version = "28.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "docify", "log", "memmap2 0.9.4", @@ -10143,30 +10633,31 @@ dependencies = [ "sp-io", "sp-runtime", "sp-state-machine", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "sc-chain-spec-derive" version = "11.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sc-cli" version = "0.36.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "chrono", "clap", "fdlimit", "futures", - "itertools 0.10.5", + "itertools 0.11.0", "libp2p-identity", "log", "names", @@ -10200,7 +10691,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "fnv", "futures", @@ -10215,11 +10706,11 @@ dependencies = [ "sp-consensus", "sp-core", "sp-database", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-runtime", "sp-state-machine", "sp-statement-store", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", "substrate-prometheus-endpoint", ] @@ -10227,7 +10718,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.35.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "hash-db", "kvdb", @@ -10253,16 +10744,15 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", - "futures-timer", - "libp2p-identity", "log", - "mockall", + "mockall 0.11.4", "parking_lot 0.12.3", "sc-client-api", + "sc-network-types", "sc-utils", "serde", "sp-api", @@ -10278,7 +10768,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -10307,7 +10797,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "fork-tree", @@ -10343,7 +10833,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "jsonrpsee", @@ -10365,9 +10855,9 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "13.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "async-channel 1.9.0", "async-trait", "fnv", @@ -10380,6 +10870,7 @@ dependencies = [ "sc-network", "sc-network-gossip", "sc-network-sync", + "sc-network-types", "sc-utils", "sp-api", "sp-application-crypto", @@ -10390,7 +10881,6 @@ dependencies = [ "sp-core", "sp-crypto-hashing", "sp-keystore", - "sp-mmr-primitives", "sp-runtime", "substrate-prometheus-endpoint", "thiserror", @@ -10401,7 +10891,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy-rpc" version = "13.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "jsonrpsee", @@ -10411,6 +10901,7 @@ dependencies = [ "sc-consensus-beefy", "sc-rpc", "serde", + "sp-application-crypto", "sp-consensus-beefy", "sp-core", "sp-runtime", @@ -10420,7 +10911,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "fork-tree", "parity-scale-codec", @@ -10433,10 +10924,10 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.19.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "ahash 0.8.11", - "array-bytes 6.2.3", + "ahash", + "array-bytes", "async-trait", "dyn-clone", "finality-grandpa", @@ -10455,6 +10946,7 @@ dependencies = [ "sc-network-common", "sc-network-gossip", "sc-network-sync", + "sc-network-types", "sc-telemetry", "sc-transaction-pool-api", "sc-utils", @@ -10476,7 +10968,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.19.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "finality-grandpa", "futures", @@ -10496,7 +10988,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -10519,7 +11011,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.32.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -10529,25 +11021,25 @@ dependencies = [ "schnellru", "sp-api", "sp-core", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-io", "sp-panic-handler", - "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", "sp-version", - "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "tracing", ] [[package]] name = "sc-executor-common" version = "0.29.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "polkavm", "sc-allocator", "sp-maybe-compressed-blob", - "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "thiserror", "wasm-instrument", ] @@ -10555,18 +11047,18 @@ dependencies = [ [[package]] name = "sc-executor-polkavm" version = "0.29.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "log", "polkavm", "sc-executor-common", - "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "sc-executor-wasmtime" version = "0.29.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "anyhow", "cfg-if", @@ -10576,15 +11068,15 @@ dependencies = [ "rustix 0.36.17", "sc-allocator", "sc-executor-common", - "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "wasmtime", ] [[package]] name = "sc-informant" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "ansi_term", "futures", @@ -10601,9 +11093,9 @@ dependencies = [ [[package]] name = "sc-keystore" version = "25.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "parking_lot 0.12.3", "serde_json", "sp-application-crypto", @@ -10615,22 +11107,22 @@ dependencies = [ [[package]] name = "sc-mixnet" version = "0.4.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", "arrayvec 0.7.4", "blake2 0.10.6", "bytes", "futures", "futures-timer", - "libp2p-identity", "log", "mixnet", - "multiaddr", + "multiaddr 0.18.1", "parity-scale-codec", "parking_lot 0.12.3", "sc-client-api", "sc-network", + "sc-network-types", "sc-transaction-pool-api", "sp-api", "sp-consensus", @@ -10644,13 +11136,14 @@ dependencies = [ [[package]] name = "sc-network" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "async-channel 1.9.0", "async-trait", "asynchronous-codec", "bytes", + "cid 0.9.0", "either", "fnv", "futures", @@ -10658,16 +11151,22 @@ dependencies = [ "ip_network", "libp2p", "linked_hash_set", + "litep2p", "log", - "mockall", + "mockall 0.11.4", + "once_cell", "parity-scale-codec", "parking_lot 0.12.3", "partial_sort", "pin-project", + "prost 0.12.6", + "prost-build 0.12.6", "rand", "sc-client-api", "sc-network-common", + "sc-network-types", "sc-utils", + "schnellru", "serde", "serde_json", "smallvec", @@ -10679,43 +11178,25 @@ dependencies = [ "thiserror", "tokio", "tokio-stream", - "unsigned-varint", + "unsigned-varint 0.7.2", + "void", "wasm-timer", "zeroize", ] -[[package]] -name = "sc-network-bitswap" -version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" -dependencies = [ - "async-channel 1.9.0", - "cid", - "futures", - "libp2p-identity", - "log", - "prost 0.12.6", - "prost-build", - "sc-client-api", - "sc-network", - "sp-blockchain", - "sp-runtime", - "thiserror", - "unsigned-varint", -] - [[package]] name = "sc-network-common" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "bitflags 1.3.2", "futures", "libp2p-identity", "parity-scale-codec", - "prost-build", + "prost-build 0.12.6", "sc-consensus", + "sc-network-types", "sp-consensus", "sp-consensus-grandpa", "sp-runtime", @@ -10724,16 +11205,16 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "ahash 0.8.11", + "ahash", "futures", "futures-timer", - "libp2p", "log", "sc-network", "sc-network-common", "sc-network-sync", + "sc-network-types", "schnellru", "sp-runtime", "substrate-prometheus-endpoint", @@ -10743,18 +11224,18 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "async-channel 1.9.0", "futures", - "libp2p-identity", "log", "parity-scale-codec", "prost 0.12.6", - "prost-build", + "prost-build 0.12.6", "sc-client-api", "sc-network", + "sc-network-types", "sp-blockchain", "sp-core", "sp-runtime", @@ -10764,9 +11245,9 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "async-channel 1.9.0", "async-trait", "fork-tree", @@ -10774,14 +11255,15 @@ dependencies = [ "futures-timer", "libp2p", "log", - "mockall", + "mockall 0.11.4", "parity-scale-codec", "prost 0.12.6", - "prost-build", + "prost-build 0.12.6", "sc-client-api", "sc-consensus", "sc-network", "sc-network-common", + "sc-network-types", "sc-utils", "schnellru", "smallvec", @@ -10800,35 +11282,51 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "futures", - "libp2p", "log", "parity-scale-codec", "sc-network", "sc-network-common", "sc-network-sync", + "sc-network-types", "sc-utils", "sp-consensus", "sp-runtime", "substrate-prometheus-endpoint", ] +[[package]] +name = "sc-network-types" +version = "0.10.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "bs58 0.5.1", + "ed25519-dalek", + "libp2p-identity", + "litep2p", + "log", + "multiaddr 0.18.1", + "multihash 0.19.1", + "rand", + "thiserror", + "zeroize", +] + [[package]] name = "sc-offchain" version = "29.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "bytes", "fnv", "futures", "futures-timer", - "hyper", + "hyper 0.14.30", "hyper-rustls", - "libp2p", "log", "num_cpus", "once_cell", @@ -10838,11 +11336,12 @@ dependencies = [ "sc-client-api", "sc-network", "sc-network-common", + "sc-network-types", "sc-transaction-pool-api", "sc-utils", "sp-api", "sp-core", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-keystore", "sp-offchain", "sp-runtime", @@ -10853,7 +11352,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.17.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -10862,7 +11361,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "29.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "jsonrpsee", @@ -10894,7 +11393,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10914,14 +11413,18 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "11.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "forwarded-header-value", "futures", "governor", - "http", - "hyper", + "http 1.1.0", + "http-body-util", + "hyper 1.4.1", + "ip_network", "jsonrpsee", "log", + "serde", "serde_json", "substrate-prometheus-endpoint", "tokio", @@ -10932,9 +11435,9 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "futures", "futures-util", "hex", @@ -10948,6 +11451,7 @@ dependencies = [ "sc-rpc", "sc-transaction-pool-api", "sc-utils", + "schnellru", "serde", "sp-api", "sp-blockchain", @@ -10963,7 +11467,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.35.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "directories", @@ -10984,11 +11488,11 @@ dependencies = [ "sc-informant", "sc-keystore", "sc-network", - "sc-network-bitswap", "sc-network-common", "sc-network-light", "sc-network-sync", "sc-network-transactions", + "sc-network-types", "sc-rpc", "sc-rpc-server", "sc-rpc-spec-v2", @@ -11005,12 +11509,12 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-core", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-keystore", "sp-runtime", "sp-session", "sp-state-machine", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-transaction-pool", "sp-transaction-storage-proof", "sp-trie", @@ -11027,7 +11531,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.30.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "log", "parity-scale-codec", @@ -11038,7 +11542,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.16.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "clap", "fs4", @@ -11051,7 +11555,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11070,7 +11574,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "derive_more", "futures", @@ -11085,13 +11589,13 @@ dependencies = [ "sp-core", "sp-crypto-hashing", "sp-io", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "sc-telemetry" version = "15.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "chrono", "futures", @@ -11100,6 +11604,7 @@ dependencies = [ "parking_lot 0.12.3", "pin-project", "rand", + "sc-network", "sc-utils", "serde", "serde_json", @@ -11110,7 +11615,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "ansi_term", "chrono", @@ -11130,28 +11635,28 @@ dependencies = [ "sp-core", "sp-rpc", "sp-runtime", - "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "thiserror", "tracing", - "tracing-log 0.1.4", - "tracing-subscriber 0.2.25", + "tracing-log", + "tracing-subscriber", ] [[package]] name = "sc-tracing-proc-macro" version = "11.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sc-transaction-pool" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -11169,7 +11674,7 @@ dependencies = [ "sp-core", "sp-crypto-hashing", "sp-runtime", - "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-transaction-pool", "substrate-prometheus-endpoint", "thiserror", @@ -11178,7 +11683,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -11194,7 +11699,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "14.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-channel 1.9.0", "futures", @@ -11258,7 +11763,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9a8ef13a93c54d20580de1e5c413e624e53121d42fc7e2c11d10ef7f8b02367" dependencies = [ - "ahash 0.8.11", + "ahash", "cfg-if", "hashbrown 0.13.2", ] @@ -11276,7 +11781,7 @@ dependencies = [ "rand_chacha 0.2.2", "rand_core 0.5.1", "sha2 0.8.2", - "subtle 2.5.0", + "subtle 2.6.1", "zeroize", ] @@ -11305,13 +11810,13 @@ dependencies = [ "aead", "arrayref", "arrayvec 0.7.4", - "curve25519-dalek 4.1.2", + "curve25519-dalek 4.1.3", "getrandom_or_panic", "merlin 3.0.0", "rand_core 0.6.4", "serde_bytes", "sha2 0.10.8", - "subtle 2.5.0", + "subtle 2.6.1", "zeroize", ] @@ -11337,6 +11842,21 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "sctp-proto" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6220f78bb44c15f326b0596113305f6101097a18755d53727a575c97e09fb24" +dependencies = [ + "bytes", + "crc", + "fxhash", + "log", + "rand", + "slab", + "thiserror", +] + [[package]] name = "sec1" version = "0.7.3" @@ -11348,7 +11868,7 @@ dependencies = [ "generic-array 0.14.7", "pkcs8", "serdect", - "subtle 2.5.0", + "subtle 2.6.1", "zeroize", ] @@ -11390,22 +11910,23 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", + "num-bigint", "security-framework-sys", ] [[package]] name = "security-framework-sys" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -11435,11 +11956,17 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -11455,29 +11982,29 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -11516,6 +12043,18 @@ dependencies = [ "opaque-debug 0.3.1", ] +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", + "sha1-asm", +] + [[package]] name = "sha1" version = "0.10.6" @@ -11527,6 +12066,15 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha1-asm" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "286acebaf8b67c1130aedffad26f594eff0c1292389158135327d2e23aed582b" +dependencies = [ + "cc", +] + [[package]] name = "sha2" version = "0.8.2" @@ -11620,6 +12168,15 @@ dependencies = [ "wide", ] +[[package]] +name = "simple-dns" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae9a3fcdadafb6d97f4c0e007e4247b114ee0f119f650c3cbf3a8b3a1479694" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "simple-mermaid" version = "0.1.1" @@ -11650,13 +12207,13 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "slot-range-helper" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "enumn", "parity-scale-codec", "paste", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] @@ -11707,7 +12264,7 @@ dependencies = [ "chacha20", "crossbeam-queue", "derive_more", - "ed25519-zebra 4.0.3", + "ed25519-zebra", "either", "event-listener 2.5.3", "fnv", @@ -11738,10 +12295,10 @@ dependencies = [ "siphasher", "slab", "smallvec", - "soketto", + "soketto 0.7.1", "twox-hash", "wasmi", - "x25519-dalek 2.0.1", + "x25519-dalek", "zeroize", ] @@ -11796,12 +12353,12 @@ dependencies = [ "aes-gcm", "blake2 0.10.6", "chacha20poly1305", - "curve25519-dalek 4.1.2", + "curve25519-dalek 4.1.3", "rand_core 0.6.4", "ring 0.17.8", "rustc_version", "sha2 0.10.8", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] @@ -11827,7 +12384,7 @@ dependencies = [ [[package]] name = "softfloat" version = "1.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "num-traits", "parity-scale-codec", @@ -11843,32 +12400,47 @@ checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ "base64 0.13.1", "bytes", - "flate2", "futures", - "http", "httparse", "log", "rand", - "sha-1", + "sha-1 0.9.8", +] + +[[package]] +name = "soketto" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures", + "http 1.1.0", + "httparse", + "log", + "rand", + "sha1", ] [[package]] name = "sp-api" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "docify", "hash-db", "log", "parity-scale-codec", "scale-info", "sp-api-proc-macro", "sp-core", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-metadata-ir", "sp-runtime", - "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-state-machine", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", "sp-version", "thiserror", @@ -11877,34 +12449,34 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "15.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "Inflector", "blake2 0.10.6", - "expander 2.1.0", + "expander", "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sp-application-crypto" version = "30.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "scale-info", "serde", "sp-core", "sp-io", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "sp-arithmetic" version = "23.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "docify", "integer-sqrt", @@ -11912,7 +12484,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "static_assertions", ] @@ -11937,7 +12509,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "scale-info", @@ -11949,7 +12521,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "sp-api", "sp-inherents", @@ -11959,7 +12531,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "futures", "log", @@ -11977,7 +12549,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.32.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "futures", @@ -11992,7 +12564,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.32.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "parity-scale-codec", @@ -12008,7 +12580,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.32.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "parity-scale-codec", @@ -12026,7 +12598,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "13.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "lazy_static", "parity-scale-codec", @@ -12040,13 +12612,13 @@ dependencies = [ "sp-keystore", "sp-mmr-primitives", "sp-runtime", - "strum 0.26.2", + "strum 0.26.3", ] [[package]] name = "sp-consensus-grandpa" version = "13.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "finality-grandpa", "log", @@ -12063,7 +12635,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.32.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "scale-info", @@ -12074,21 +12646,21 @@ dependencies = [ [[package]] name = "sp-core" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "bandersnatch_vrfs", "bitflags 1.3.2", "blake2 0.10.6", "bounded-collections", "bs58 0.5.1", "dyn-clonable", - "ed25519-zebra 3.1.0", + "ed25519-zebra", "futures", "hash-db", "hash256-std-hasher", "impl-serde", - "itertools 0.10.5", + "itertools 0.11.0", "k256", "libsecp256k1", "log", @@ -12105,11 +12677,11 @@ dependencies = [ "secrecy", "serde", "sp-crypto-hashing", - "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "ss58-registry", "substrate-bip39", "thiserror", @@ -12121,7 +12693,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -12140,8 +12712,8 @@ dependencies = [ [[package]] name = "sp-crypto-hashing" -version = "0.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +version = "0.1.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "blake2b_simd", "byteorder", @@ -12153,18 +12725,18 @@ dependencies = [ [[package]] name = "sp-crypto-hashing-proc-macro" -version = "0.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +version = "0.1.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "quote", "sp-crypto-hashing", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sp-database" version = "10.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "kvdb", "parking_lot 0.12.3", @@ -12173,37 +12745,37 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "environmental", "parity-scale-codec", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" dependencies = [ "environmental", "parity-scale-codec", @@ -12212,9 +12784,11 @@ dependencies = [ [[package]] name = "sp-genesis-builder" -version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +version = "0.8.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "parity-scale-codec", + "scale-info", "serde_json", "sp-api", "sp-runtime", @@ -12223,7 +12797,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -12236,9 +12810,10 @@ dependencies = [ [[package]] name = "sp-io" version = "30.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bytes", + "docify", "ed25519-dalek", "libsecp256k1", "log", @@ -12248,12 +12823,12 @@ dependencies = [ "secp256k1", "sp-core", "sp-crypto-hashing", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-keystore", - "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-state-machine", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-trie", "tracing", "tracing-core", @@ -12262,28 +12837,28 @@ dependencies = [ [[package]] name = "sp-keyring" version = "31.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "sp-core", "sp-runtime", - "strum 0.26.2", + "strum 0.26.3", ] [[package]] name = "sp-keystore" version = "0.34.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", "sp-core", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "sp-maybe-compressed-blob" version = "11.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "thiserror", "zstd 0.12.4", @@ -12292,7 +12867,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.6.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -12302,7 +12877,7 @@ dependencies = [ [[package]] name = "sp-mixnet" version = "0.4.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "scale-info", @@ -12313,16 +12888,16 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "ckb-merkle-mountain-range", "log", "parity-scale-codec", + "polkadot-ckb-merkle-mountain-range", "scale-info", "serde", "sp-api", "sp-core", - "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-runtime", "thiserror", ] @@ -12330,7 +12905,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "scale-info", @@ -12343,7 +12918,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "sp-api", "sp-core", @@ -12353,7 +12928,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "13.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "backtrace", "lazy_static", @@ -12363,7 +12938,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "rustc-hash", "serde", @@ -12373,13 +12948,14 @@ dependencies = [ [[package]] name = "sp-runtime" version = "31.0.1" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "docify", "either", "hash256-std-hasher", "impl-trait-for-tuples", "log", + "num-traits", "parity-scale-codec", "paste", "rand", @@ -12390,33 +12966,33 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-weights", ] [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", "polkavm-derive", "primitive-types", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-runtime-interface-proc-macro 17.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-runtime-interface-proc-macro 17.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-tracing 16.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-wasm-interface 20.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "static_assertions", ] [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -12435,33 +13011,33 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "Inflector", - "expander 2.1.0", + "expander", "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" dependencies = [ "Inflector", - "expander 2.1.0", + "expander", "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sp-session" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "scale-info", @@ -12475,7 +13051,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -12488,7 +13064,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.35.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "hash-db", "log", @@ -12497,7 +13073,7 @@ dependencies = [ "rand", "smallvec", "sp-core", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-panic-handler", "sp-trie", "thiserror", @@ -12508,10 +13084,10 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "10.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "aes-gcm", - "curve25519-dalek 4.1.2", + "curve25519-dalek 4.1.3", "ed25519-dalek", "hkdf", "parity-scale-codec", @@ -12522,39 +13098,39 @@ dependencies = [ "sp-application-crypto", "sp-core", "sp-crypto-hashing", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-runtime", - "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-runtime-interface 24.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "thiserror", - "x25519-dalek 2.0.1", + "x25519-dalek", ] [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "impl-serde", "parity-scale-codec", "ref-cast", "serde", - "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12566,7 +13142,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "parity-scale-codec", @@ -12578,29 +13154,29 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "tracing", "tracing-core", - "tracing-subscriber 0.2.25", + "tracing-subscriber", ] [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" dependencies = [ "parity-scale-codec", "tracing", "tracing-core", - "tracing-subscriber 0.3.18", + "tracing-subscriber", ] [[package]] name = "sp-transaction-pool" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "sp-api", "sp-runtime", @@ -12609,7 +13185,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "26.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "async-trait", "parity-scale-codec", @@ -12623,9 +13199,9 @@ dependencies = [ [[package]] name = "sp-trie" version = "29.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "ahash 0.8.11", + "ahash", "hash-db", "lazy_static", "memory-db", @@ -12636,7 +13212,7 @@ dependencies = [ "scale-info", "schnellru", "sp-core", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "thiserror", "tracing", "trie-db", @@ -12646,7 +13222,7 @@ dependencies = [ [[package]] name = "sp-version" version = "29.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12655,7 +13231,7 @@ dependencies = [ "serde", "sp-crypto-hashing-proc-macro", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-version-proc-macro", "thiserror", ] @@ -12663,18 +13239,18 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "13.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -12686,7 +13262,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#b65313e81465dd730e48d4ce00deb76922618375" +source = "git+https://github.com/paritytech/polkadot-sdk#604f56f03db847a90aa4fdb13be6b80482a4dcd6" dependencies = [ "impl-trait-for-tuples", "log", @@ -12696,7 +13272,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "bounded-collections", "parity-scale-codec", @@ -12704,7 +13280,7 @@ dependencies = [ "serde", "smallvec", "sp-arithmetic", - "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] @@ -12719,17 +13295,6 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "spinners" -version = "4.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0ef947f358b9c238923f764c72a4a9d42f2d637c46e059dbd319d6e7cfb4f82" -dependencies = [ - "lazy_static", - "maplit", - "strum 0.24.1", -] - [[package]] name = "spinning_top" version = "0.3.0" @@ -12773,7 +13338,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staging-parachain-info" version = "0.7.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -12781,15 +13346,15 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", ] [[package]] name = "staging-xcm" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "array-bytes 6.2.3", + "array-bytes", "bounded-collections", "derivative", "environmental", @@ -12806,7 +13371,7 @@ dependencies = [ [[package]] name = "staging-xcm-builder" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "frame-system", @@ -12819,7 +13384,7 @@ dependencies = [ "sp-arithmetic", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-weights", "staging-xcm", "staging-xcm-executor", @@ -12828,7 +13393,7 @@ dependencies = [ [[package]] name = "staging-xcm-executor" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "environmental", "frame-benchmarking", @@ -12841,7 +13406,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-weights", "staging-xcm", ] @@ -12881,16 +13446,23 @@ dependencies = [ ] [[package]] -name = "strobe-rs" -version = "0.8.1" +name = "str0m" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" +checksum = "6706347e49b13373f7ddfafad47df7583ed52083d6fc8a594eb2c80497ef959d" dependencies = [ - "bitflags 1.3.2", - "byteorder", - "keccak", - "subtle 2.5.0", - "zeroize", + "combine", + "crc", + "fastrand 2.1.0", + "hmac 0.12.1", + "once_cell", + "openssl", + "openssl-sys", + "sctp-proto", + "serde", + "sha-1 0.10.1", + "thiserror", + "tracing", ] [[package]] @@ -12904,15 +13476,12 @@ name = "strum" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" -dependencies = [ - "strum_macros 0.24.3", -] [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros 0.26.4", ] @@ -12940,13 +13509,13 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "substrate-bip39" version = "0.4.7" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "hmac 0.12.1", "pbkdf2", @@ -12958,13 +13527,14 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "11.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" [[package]] name = "substrate-frame-rpc-system" version = "28.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ + "docify", "frame-system-rpc-runtime-api", "futures", "jsonrpsee", @@ -12982,32 +13552,19 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.17.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "hyper", + "hyper 0.14.30", "log", "prometheus", "thiserror", "tokio", ] -[[package]] -name = "substrate-rpc-client" -version = "0.33.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" -dependencies = [ - "async-trait", - "jsonrpsee", - "log", - "sc-rpc-api", - "serde", - "sp-runtime", -] - [[package]] name = "substrate-state-trie-migration-rpc" version = "27.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -13024,7 +13581,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "17.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "build-helper", "cargo_metadata", @@ -13033,9 +13590,9 @@ dependencies = [ "parity-wasm", "polkavm-linker", "sp-maybe-compressed-blob", - "strum 0.26.2", + "strum 0.26.3", "tempfile", - "toml 0.8.14", + "toml 0.8.15", "walkdir", "wasm-opt", ] @@ -13048,9 +13605,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "subtle-ng" @@ -13071,9 +13628,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -13100,7 +13657,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -13132,9 +13689,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "tempfile" @@ -13176,22 +13733,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "testnet-parachains-constants" version = "1.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "cumulus-primitives-core", "frame-support", - "infra-relay-runtime-constants", "polkadot-core-primitives", "smallvec", "sp-runtime", "staging-xcm", + "yosemite-runtime-constants", ] [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] @@ -13213,18 +13770,18 @@ checksum = "e4c60d69f36615a077cc7663b9cb8e42275722d23e58a7fa3d2c7f2915d09d04" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -13328,9 +13885,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -13343,43 +13900,31 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot 0.12.3", - "pin-project-lite 0.2.14", + "pin-project-lite", "signal-hook-registry", "socket2 0.5.7", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", -] - -[[package]] -name = "tokio-retry" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" -dependencies = [ - "pin-project", - "rand", - "tokio", + "syn 2.0.72", ] [[package]] @@ -13394,11 +13939,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.22.4", + "rustls 0.23.12", "rustls-pki-types", "tokio", ] @@ -13410,11 +13955,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", - "pin-project-lite 0.2.14", + "pin-project-lite", "tokio", "tokio-util", ] +[[package]] +name = "tokio-tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +dependencies = [ + "futures-util", + "log", + "rustls 0.21.12", + "rustls-native-certs 0.6.3", + "tokio", + "tokio-rustls 0.24.1", + "tungstenite", +] + [[package]] name = "tokio-util" version = "0.7.11" @@ -13425,7 +13985,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.14", + "pin-project-lite", "tokio", ] @@ -13440,14 +14000,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.14", + "toml_edit 0.22.16", ] [[package]] @@ -13459,17 +14019,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" -dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.21.1" @@ -13483,15 +14032,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.14" +version = "0.22.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.13", + "winnow 0.6.15", ] [[package]] @@ -13503,7 +14052,8 @@ dependencies = [ "futures-core", "futures-util", "pin-project", - "pin-project-lite 0.2.14", + "pin-project-lite", + "tokio", "tower-layer", "tower-service", "tracing", @@ -13511,18 +14061,16 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", - "pin-project-lite 0.2.14", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "pin-project-lite", "tower-layer", "tower-service", ] @@ -13546,7 +14094,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", - "pin-project-lite 0.2.14", + "pin-project-lite", "tracing-attributes", "tracing-core", ] @@ -13559,7 +14107,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -13585,7 +14133,7 @@ dependencies = [ [[package]] name = "tracing-gum" version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "coarsetime", "polkadot-primitives", @@ -13596,24 +14144,13 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" version = "5.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ - "expander 2.1.0", + "expander", "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", -] - -[[package]] -name = "tracing-log" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" -dependencies = [ - "log", - "once_cell", - "tracing-core", + "syn 2.0.72", ] [[package]] @@ -13627,65 +14164,32 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-serde" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" -dependencies = [ - "serde", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" -dependencies = [ - "ansi_term", - "chrono", - "lazy_static", - "matchers 0.0.1", - "parking_lot 0.11.2", - "regex", - "serde", - "serde_json", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log 0.1.4", - "tracing-serde", -] - [[package]] name = "tracing-subscriber" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ - "matchers 0.1.0", + "matchers", "nu-ansi-term", "once_cell", + "parking_lot 0.12.3", "regex", "sharded-slab", "smallvec", "thread_local", "tracing", "tracing-core", - "tracing-log 0.2.0", + "tracing-log", ] [[package]] name = "trie-db" -version = "0.28.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff28e0f815c2fea41ebddf148e008b077d2faddb026c9555b29696114d602642" +checksum = "0c992b4f40c234a074d48a757efeabb1a6be88af84c0c23f7ca158950cb0ae7f" dependencies = [ "hash-db", - "hashbrown 0.13.2", "log", "rustc-hex", "smallvec", @@ -13709,7 +14213,7 @@ dependencies = [ "async-trait", "cfg-if", "data-encoding", - "enum-as-inner", + "enum-as-inner 0.5.1", "futures-channel", "futures-io", "futures-util", @@ -13726,24 +14230,50 @@ dependencies = [ "url", ] +[[package]] +name = "trust-dns-proto" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3119112651c157f4488931a01e586aa459736e9d6046d3bd9105ffb69352d374" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner 0.6.0", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.4.0", + "ipnet", + "once_cell", + "rand", + "smallvec", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + [[package]] name = "trust-dns-resolver" -version = "0.22.0" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" +checksum = "10a3e6c3aff1718b3c73e395d1f35202ba2ffa847c6a62eea0db8fb4cfe30be6" dependencies = [ "cfg-if", "futures-util", "ipconfig", - "lazy_static", "lru-cache", + "once_cell", "parking_lot 0.12.3", + "rand", "resolv-conf", "smallvec", "thiserror", "tokio", "tracing", - "trust-dns-proto", + "trust-dns-proto 0.23.2", ] [[package]] @@ -13752,48 +14282,32 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "try-runtime-cli" -version = "0.38.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" -dependencies = [ - "async-trait", - "clap", - "frame-remote-externalities", - "frame-try-runtime", - "hex", - "log", - "parity-scale-codec", - "sc-cli", - "sc-executor", - "serde", - "serde_json", - "sp-api", - "sp-consensus-aura", - "sp-consensus-babe", - "sp-core", - "sp-debug-derive 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-externalities 0.25.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-rpc", - "sp-runtime", - "sp-state-machine", - "sp-timestamp", - "sp-transaction-storage-proof", - "sp-version", - "sp-weights", - "substrate-rpc-client", - "zstd 0.12.4", -] - [[package]] name = "tt-call" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" +[[package]] +name = "tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 0.2.12", + "httparse", + "log", + "rand", + "rustls 0.21.12", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "twox-hash" version = "1.6.3" @@ -13870,7 +14384,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ "crypto-common", - "subtle 2.5.0", + "subtle 2.6.1", ] [[package]] @@ -13885,6 +14399,16 @@ dependencies = [ "futures-util", ] +[[package]] +name = "unsigned-varint" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" +dependencies = [ + "bytes", + "tokio-util", +] + [[package]] name = "untrusted" version = "0.7.1" @@ -13899,15 +14423,21 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna 0.5.0", "percent-encoding", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf8parse" version = "0.2.2" @@ -13996,12 +14526,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -14014,7 +14538,7 @@ version = "0.12.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1fbb4ef9bbca0c1170e0b00dd28abc9e3b68669821600cad1caaed606583c6d" dependencies = [ - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -14038,7 +14562,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -14072,7 +14596,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -14370,7 +14894,7 @@ dependencies = [ "log", "mach", "memfd", - "memoffset 0.8.0", + "memoffset", "paste", "rand", "rustix 0.36.17", @@ -14414,11 +14938,17 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.6" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + +[[package]] +name = "webpki-roots" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ - "webpki", + "rustls-pki-types", ] [[package]] @@ -14435,9 +14965,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.24" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a040b111774ab63a19ef46bbc149398ab372b4ccdcfd719e9814dbd7dfd76c8" +checksum = "901e8597c777fa042e9e245bd56c0dc4418c5db3f845b6ff94fbac732c6a0692" dependencies = [ "bytemuck", "safe_arch", @@ -14505,7 +15035,22 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -14532,7 +15077,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -14567,18 +15112,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -14595,9 +15140,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -14613,9 +15158,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -14631,15 +15176,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -14655,9 +15200,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -14673,9 +15218,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -14691,9 +15236,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -14709,9 +15254,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -14724,9 +15269,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.13" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +checksum = "557404e450152cd6795bb558bca69e43c585055f4606e3bcae5894fc6dac9ba0" dependencies = [ "memchr", ] @@ -14752,81 +15297,102 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "1.1.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.5.1", + "curve25519-dalek 4.1.3", + "rand_core 0.6.4", + "serde", "zeroize", ] [[package]] -name = "x25519-dalek" -version = "2.0.1" +name = "x509-parser" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da" dependencies = [ - "curve25519-dalek 4.1.2", - "rand_core 0.6.4", - "serde", - "zeroize", + "asn1-rs 0.5.2", + "data-encoding", + "der-parser 8.2.0", + "lazy_static", + "nom", + "oid-registry 0.6.1", + "rusticata-macros", + "thiserror", + "time", ] [[package]] name = "x509-parser" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" dependencies = [ - "asn1-rs", - "base64 0.13.1", + "asn1-rs 0.6.1", "data-encoding", - "der-parser", + "der-parser 9.0.0", "lazy_static", "nom", - "oid-registry", + "oid-registry 0.7.0", "rusticata-macros", "thiserror", "time", ] [[package]] -name = "xcm-fee-payment-runtime-api" +name = "xcm-procedural" +version = "7.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "xcm-runtime-apis" version = "0.1.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" dependencies = [ "frame-support", "parity-scale-codec", "scale-info", "sp-api", - "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0)", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", "sp-weights", "staging-xcm", + "staging-xcm-executor", ] [[package]] -name = "xcm-procedural" -version = "7.0.0" -source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.10.0#91b0f322bd6261b1867fb09a452825aaa7dde97f" +name = "xml-rs" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" + +[[package]] +name = "xmltree" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb" dependencies = [ - "Inflector", - "proc-macro2", - "quote", - "syn 2.0.66", + "xml-rs", ] [[package]] name = "yamux" -version = "0.10.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" +checksum = "9ed0164ae619f2dc144909a9f082187ebb5893693d8c0196e8085283ccd4b776" dependencies = [ "futures", "log", "nohash-hasher", "parking_lot 0.12.3", + "pin-project", "rand", "static_assertions", ] @@ -14840,24 +15406,149 @@ dependencies = [ "time", ] +[[package]] +name = "yosemite-runtime" +version = "7.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "binary-merkle-tree", + "bitvec", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-metadata-hash-extension", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal", + "infra-asset-common", + "log", + "pallet-asset-rate", + "pallet-assets", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-beefy", + "pallet-beefy-mmr", + "pallet-bounties", + "pallet-child-bounties", + "pallet-collective", + "pallet-conviction-voting", + "pallet-democracy", + "pallet-elections-phragmen", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-message-queue", + "pallet-mmr", + "pallet-multisig", + "pallet-nis", + "pallet-offences", + "pallet-parameters", + "pallet-preimage", + "pallet-proxy", + "pallet-ranked-collective", + "pallet-recovery", + "pallet-referenda", + "pallet-root-testing", + "pallet-scheduler", + "pallet-session", + "pallet-society", + "pallet-staking", + "pallet-state-trie-migration", + "pallet-sudo", + "pallet-system-token-conversion", + "pallet-system-token-tx-payment", + "pallet-timestamp", + "pallet-tips", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-validator-management", + "pallet-vesting", + "pallet-whitelist", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parity-scale-codec", + "polkadot-parachain-primitives", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "scale-info", + "serde", + "serde_derive", + "serde_json", + "smallvec", + "softfloat", + "sp-api", + "sp-arithmetic", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core", + "sp-genesis-builder", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std 14.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-storage 19.0.0 (git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0)", + "sp-transaction-pool", + "sp-version", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "static_assertions", + "substrate-wasm-builder", + "xcm-runtime-apis", + "yosemite-runtime-constants", +] + +[[package]] +name = "yosemite-runtime-constants" +version = "7.0.0" +source = "git+https://github.com/InfraBlockchain/infrablockchain-substrate?branch=feature/release-1.14.0#1c16a3cb7001f52981cda22d09523bf7353f6109" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", + "staging-xcm", + "staging-xcm-builder", +] + [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -14877,7 +15568,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -14920,9 +15611,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" +version = "2.0.12+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index 4fad3b6..f4fd3c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,186 @@ +[workspace.package] +authors = ["Blockchain Labs"] +edition = "2021" +homepage = "https://www.infrablockchain.net/kr/tech/infrablockchain" +license = "GPL-3.0-only" +repository = "https://github.com/InfraBlockchain/infra-did-parachain" + + [workspace] members = [ - "node", - "runtime", + "node", + "runtime", + "pallets/did", ] resolver = "2" +[workspace.dependencies] + +# External +wait-timeout = { version = "0.2" } +tokio = { version = "1.37.0", default-features = false } +tempfile = { version = "3.8.1" } +assert_cmd = { version = "2.0.10" } +nix = { version = "0.28.0" } +async-trait = { version = "0.1.79" } +bitflags = { version = "2.6.0" } +clap = { version = "4.5.3" } +codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" } +color-print = { version = "0.3.4" } +futures = { version = "0.3.30" } +hex-literal = { version = "0.4.1", default-features = false } +jsonrpsee = { version = "0.23.2" } +libsecp256k1 = { version = "0.7.1", default-features = false } +log = { version = "0.4.21", default-features = false } +merlin = { version = "3.0.0", default-features = false } +num-traits = { version = "0.2.19", default-features = false } +rand = { version = "0.8.5", default-features = false } +rand_chacha = { version = "0.3.1", default-features = false } +scale-info = { version = "2.11.1", default-features = false } +scale-info-derive = { git = "https://github.com/docknetwork/scale-info.git", branch = "master", default-features = false } +schnorrkel = { version = "0.9.1", default-features = false } +serde-big-array = { version = "0.3.0" } +serde-hex = { version = "0.4.3", default-features = false, package = "hex" } +serde_json = { version = "1.0.114", default-features = false } +sha2 = { version = "0.10.8", default-features = false } +smallvec = { version = "1.11.0", default-features = false } +serde = { version = "1.0.197", default-features = false } + +# Core Module +pallet-did = { path = "pallets/did", default-features = false } + +# Runtime +infra-did-yosemite-runtime = { path = "runtime", default-features = false } + +# Substrate Utils +substrate-frame-rpc-system = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +substrate-prometheus-endpoint = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +substrate-state-trie-migration-rpc = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +substrate-wasm-builder = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +substrate-build-script-utils = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# FRAME +frame-benchmarking = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +frame-benchmarking-cli = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +frame-executive = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +frame-support = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +frame-system = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +frame-system-benchmarking = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +frame-system-rpc-runtime-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +frame-try-runtime = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# Pallets +pallet-assets = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-authorship = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-balances = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-message-queue = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-preimage = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-scheduler = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-session = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-sudo = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-system-token-conversion = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-system-token-tx-payment = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-timestamp = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-transaction-payment = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-transaction-payment-rpc = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# FRAME Primitives +sp-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-blockchain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-keystore = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-timestamp = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-application-crypto = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-block-builder = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-consensus-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-genesis-builder = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-inherents = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-io = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-offchain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-runtime = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-session = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-std = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-storage = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-transaction-pool = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-version = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sp-weights = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# FRAME Client +sc-basic-authorship = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-chain-spec = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-client-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-consensus = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-finality-grandpa = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-service = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-cli = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-executor = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-network = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-network-sync = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-offchain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-rpc = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-rpc-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-sysinfo = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-telemetry = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-tracing = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-transaction-pool = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +sc-transaction-pool-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# InfraRelay +polkadot-core-primitives = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +polkadot-parachain-primitives = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +polkadot-runtime-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +polkadot-runtime-parachains = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +polkadot-service = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +polkadot-primitives = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +polkadot-cli = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# Yosemite(Testnet) +yosemite-runtime-constants = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# Xcm +pallet-xcm = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +xcm = { package = "staging-xcm", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# InfraXCM +infra-asset-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +# Cumulus +cumulus-client-cli = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-client-collator = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-client-consensus-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-client-consensus-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-client-consensus-proposer = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-client-consensus-relay-chain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-client-parachain-inherent = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-primitives-parachain-inherent = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-relay-chain-interface = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-client-service = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-pallet-aura-ext = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-pallet-dmp-queue = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-pallet-infra-parachain-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-pallet-parachain-system = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-pallet-session-benchmarking = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-pallet-xcm = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-pallet-xcmp-queue = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-primitives-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-primitives-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-primitives-timestamp = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +cumulus-primitives-utility = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +pallet-collator-selection = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +parachain-info = { package = "staging-parachain-info", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } +parachains-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + +testnet-parachains-constants = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.14.0", default-features = false } + [profile.release] -panic = "unwind" opt-level = 3 +panic = "unwind" [profile.production] +codegen-units = 1 inherits = "release" lto = true -codegen-units = 1 diff --git a/node/Cargo.toml b/node/Cargo.toml index 0be4257..605047c 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,128 +1,125 @@ [package] -name = "infra-did-parachain-bin" -version = "1.1.0" -authors = ["blockchain labs"] +authors.workspace = true +edition.workspace = true build = "build.rs" -edition = "2021" -description = "Runs a infra-relay parachain node which could be a collator." +description = "Run InfraDID-Yosemite node" +name = "infra-did-yosemite-bin" +version = "1.0.0" [[bin]] -name = "infra-did-parachain" +name = "infra-did-yosemite" path = "src/main.rs" [dependencies] -async-trait = "0.1.73" -clap = { version = "4.4.6", features = ["derive"] } -codec = { package = "parity-scale-codec", version = "3.0.0" } -futures = "0.3.28" -hex-literal = "0.4.1" -log = "0.4.20" -serde = { version = "1.0.188", features = ["derive"] } -serde_json = "1.0.107" +async-trait = { workspace = true } +clap = { workspace = true, features = ["derive"] } +codec = { workspace = true } +color-print = { workspace = true } +futures = { workspace = true } +hex-literal = { workspace = true, default-features = true } +jsonrpsee = { workspace = true, features = ["server"] } +log = { workspace = true, default-features = true } +serde = { workspace = true, default-features = true, features = ["derive"] } +serde_json = { workspace = true, default-features = true } -# Local -jsonrpsee = { version = "0.22", features = ["server"] } -parachains-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } - -# parachains's runtimes -infra-did-parachain-runtime = { path = "../runtime" } +# Runtime +infra-did-yosemite-runtime = { workspace = true, default-features = true } # Substrate -frame-support = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -frame-benchmarking = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -frame-benchmarking-cli = { git = "https://github.com /InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-runtime = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0", default-features = false } -sp-io = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-session = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-consensus = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-cli = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-client-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-executor = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-service = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-telemetry = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-transaction-pool = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-transaction-pool = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-network = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-network-sync = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-basic-authorship = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-std = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-inherents = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-version = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-timestamp = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-blockchain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-block-builder = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-keystore = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-offchain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-genesis-builder = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-chain-spec = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-rpc = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-tracing = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-offchain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sp-consensus-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-sysinfo = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -substrate-prometheus-endpoint = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -sc-transaction-pool-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -frame-system-rpc-runtime-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -pallet-transaction-payment = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -pallet-transaction-payment-rpc = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -substrate-state-trie-migration-rpc = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } +frame-benchmarking = { workspace = true, default-features = true } +frame-benchmarking-cli = { workspace = true, default-features = true } +frame-support = { workspace = true, default-features = true } +frame-system-rpc-runtime-api = { workspace = true, default-features = true } +pallet-transaction-payment = { workspace = true, default-features = true } +pallet-transaction-payment-rpc = { workspace = true, default-features = true } +pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = true } +sc-basic-authorship = { workspace = true, default-features = true } +sc-chain-spec = { workspace = true, default-features = true } +sc-cli = { workspace = true, default-features = true } +sc-client-api = { workspace = true, default-features = true } +sc-consensus = { workspace = true, default-features = true } +sc-executor = { workspace = true, default-features = true } +sc-network = { workspace = true, default-features = true } +sc-network-sync = { workspace = true, default-features = true } +sc-offchain = { workspace = true, default-features = true } +sc-rpc = { workspace = true, default-features = true } +sc-service = { workspace = true, default-features = true } +sc-sysinfo = { workspace = true, default-features = true } +sc-telemetry = { workspace = true, default-features = true } +sc-tracing = { workspace = true, default-features = true } +sc-transaction-pool = { workspace = true, default-features = true } +sc-transaction-pool-api = { workspace = true, default-features = true } +sp-api = { workspace = true, default-features = true } +sp-block-builder = { workspace = true, default-features = true } +sp-blockchain = { workspace = true, default-features = true } +sp-consensus-aura = { workspace = true, default-features = true } +sp-core = { workspace = true, default-features = true } +sp-genesis-builder = { workspace = true, default-features = true } +sp-inherents = { workspace = true, default-features = true } +sp-io = { workspace = true, default-features = true } +sp-keystore = { workspace = true, default-features = true } +sp-offchain = { workspace = true, default-features = true } +sp-runtime = { workspace = true, default-features = false } +sp-session = { workspace = true, default-features = true } +sp-std = { workspace = true, default-features = true } +sp-timestamp = { workspace = true, default-features = true } +sp-transaction-pool = { workspace = true, default-features = true } +sp-version = { workspace = true, default-features = true } +substrate-frame-rpc-system = { workspace = true, default-features = true } +substrate-prometheus-endpoint = { workspace = true, default-features = true } +substrate-state-trie-migration-rpc = { workspace = true, default-features = true } -# Infra Relay -polkadot-cli = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0", features = ["infra-relay-native",] } -polkadot-primitives = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -polkadot-service = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -xcm = { package = "staging-xcm", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } +# InfraRelay +polkadot-cli = { workspace = true, default-features = true, features = ["yosemite-native"] } +polkadot-primitives = { workspace = true, default-features = true } +polkadot-service = { workspace = true, default-features = true } +xcm = { workspace = true, default-features = true } # Cumulus -cumulus-client-cli = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-client-collator = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-client-consensus-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-client-consensus-relay-chain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-client-consensus-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-client-consensus-proposer = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-client-service = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-client-parachain-inherent = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-primitives-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-primitives-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } -cumulus-relay-chain-interface = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } - -testnet-parachains-constants = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } +cumulus-client-cli = { workspace = true, default-features = true } +cumulus-client-collator = { workspace = true, default-features = true } +cumulus-client-consensus-aura = { workspace = true, default-features = true } +cumulus-client-consensus-common = { workspace = true, default-features = true } +cumulus-client-consensus-proposer = { workspace = true, default-features = true } +cumulus-client-consensus-relay-chain = { workspace = true, default-features = true } +cumulus-client-parachain-inherent = { workspace = true, default-features = true } +cumulus-client-service = { workspace = true, default-features = true } +cumulus-primitives-aura = { workspace = true, default-features = true } +cumulus-primitives-core = { workspace = true, default-features = true } +cumulus-primitives-parachain-inherent = { workspace = true, default-features = true } +cumulus-relay-chain-interface = { workspace = true, default-features = true } +parachains-common = { workspace = true, default-features = true } -color-print = "0.3.4" +testnet-parachains-constants = { workspace = true, default-features = true } [build-dependencies] -substrate-build-script-utils = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch ="feature/release-1.10.0" } +substrate-build-script-utils = { workspace = true, default-features = true } [dev-dependencies] -assert_cmd = "2.0" -nix = { version = "0.26.1", features = ["signal"] } -tempfile = "3.8.0" -tokio = { version = "1.32.0", features = ["macros", "time", "parking_lot"] } -wait-timeout = "0.2" +assert_cmd = { workspace = true } +nix = { workspace = true, features = ["signal"] } +tempfile = { workspace = true } +tokio = { workspace = true, default-features = true, features = ["macros", "time", "parking_lot"] } +wait-timeout = { workspace = true } [features] default = [] +fast-runtime = [ + "infra-did-yosemite-runtime/fast-runtime", +] runtime-benchmarks = [ - "frame-benchmarking-cli/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", - "parachains-common/runtime-benchmarks", - "polkadot-cli/runtime-benchmarks", - "polkadot-primitives/runtime-benchmarks", - "polkadot-service/runtime-benchmarks", - "sc-service/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame-benchmarking-cli/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "parachains-common/runtime-benchmarks", + "polkadot-cli/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-service/runtime-benchmarks", + "sc-service/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "polkadot-cli/try-runtime", - "polkadot-service/try-runtime", - "sp-runtime/try-runtime", + "polkadot-cli/try-runtime", + "polkadot-service/try-runtime", + "sp-runtime/try-runtime", ] -fast-runtime = [ - "infra-did-parachain-runtime/fast-runtime", -] \ No newline at end of file diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 053c1e7..f33c9a8 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -23,12 +23,11 @@ use serde::{Deserialize, Serialize}; use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public}; use sp_runtime::traits::{IdentifyAccount, Verify}; -/// Specialized `ChainSpec` for the normal parachain runtime. -pub type InfraDIDChainSpec = sc_service::GenericChainSpec<(), Extensions>; +pub type GenericChainSpec = sc_service::GenericChainSpec; -const INFRA_RELAY_ED: InfraDIDBalance = testnet_parachains_constants::infra_relay::currency::EXISTENTIAL_DEPOSIT; +const INFRA_RELAY_ED: InfraDIDBalance = testnet_parachains_constants::yosemite::currency::EXISTENTIAL_DEPOSIT; -const INFRA_DID_PARACHAIN_ID: u32 = 1002; +const PARACHAIN_ID: u32 = 1005; const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; @@ -76,22 +75,22 @@ type AccountPublic = ::Signer; /// Generate the session keys from individual elements. /// /// The input must be a tuple of individual keys (a single arg for now since we have just one key). -pub fn session_keys(keys: AuraId) -> infra_did_parachain_runtime::SessionKeys { - infra_did_parachain_runtime::SessionKeys { aura: keys } +pub fn session_keys(keys: AuraId) -> infra_did_yosemite_runtime::SessionKeys { + infra_did_yosemite_runtime::SessionKeys { aura: keys } } -pub fn development_config() -> InfraDIDChainSpec { +pub fn development_config() -> GenericChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 42.into()); properties.insert("tokenSymbol".into(), "DIDEV".into()); properties.insert("tokenDecimals".into(), 9.into()); - InfraDIDChainSpec::builder( - infra_did_parachain_runtime::WASM_BINARY.expect("WASM binary was not built for `InfraDID`"), - Extensions { relay_chain: "infra-relay".into(), para_id: INFRA_DID_PARACHAIN_ID } + GenericChainSpec::builder( + infra_did_yosemite_runtime::WASM_BINARY.expect("WASM binary was not built for `InfraDID`"), + Extensions { relay_chain: "yosemite-dev".into(), para_id: PARACHAIN_ID } ) - .with_name("InfraBlockchain DID Chain Dev") - .with_id("did-hub-infra-dev") + .with_name("InfraDID Development") + .with_id("infra-did-yosemite-dev") .with_chain_type(ChainType::Development) .with_genesis_config_patch( infra_did_genesis( @@ -108,25 +107,25 @@ pub fn development_config() -> InfraDIDChainSpec { ], // endowed_accounts INFRA_RELAY_ED * 4096, Some(get_account_id_from_seed::("Alice")), // root_key - INFRA_DID_PARACHAIN_ID.into(), // para_id + PARACHAIN_ID.into(), // para_id ) ) .with_properties(properties) .build() } -pub fn testnet_config() -> InfraDIDChainSpec { +pub fn testnet_config() -> GenericChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(),42.into()); properties.insert("tokenSymbol".into(), "DIDTEST".into()); properties.insert("tokenDecimals".into(), 9.into()); - InfraDIDChainSpec::builder( - infra_did_parachain_runtime::WASM_BINARY.expect("WASM binary was not built for `InfraDID`"), - Extensions { relay_chain: "infra-relay".into(), para_id: INFRA_DID_PARACHAIN_ID } + GenericChainSpec::builder( + infra_did_yosemite_runtime::WASM_BINARY.expect("WASM binary was not built for `InfraDID`"), + Extensions { relay_chain: "yosemite-local".into(), para_id: PARACHAIN_ID } ) - .with_name("InfraBlockchain DID Chain Testnet") - .with_id("did-hub-infra-testnet") + .with_name("InfraDID Testnet") + .with_id("infra-did-yosemite-testnet") .with_chain_type(ChainType::Local) .with_genesis_config_patch( infra_did_genesis( @@ -157,7 +156,7 @@ pub fn testnet_config() -> InfraDIDChainSpec { ], // endowed_accounts INFRA_RELAY_ED * 4096, Some(get_account_id_from_seed::("Alice")), // root_key - INFRA_DID_PARACHAIN_ID.into(), // para_id + PARACHAIN_ID.into(), // para_id ) ) .with_properties(properties) @@ -165,18 +164,18 @@ pub fn testnet_config() -> InfraDIDChainSpec { } // Not used for syncing, but just to determine the genesis values set for the upgrade from shell. -pub fn mainnet_config() -> InfraDIDChainSpec { +pub fn mainnet_config() -> GenericChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 42.into()); properties.insert("tokenSymbol".into(), "DIDMAIN".into()); properties.insert("tokenDecimals".into(), 9.into()); - InfraDIDChainSpec::builder( - infra_did_parachain_runtime::WASM_BINARY.expect("WASM binary was not built for `InfraDID`"), - Extensions { relay_chain: "infra-relay".into(), para_id: INFRA_DID_PARACHAIN_ID } + GenericChainSpec::builder( + infra_did_yosemite_runtime::WASM_BINARY.expect("WASM binary was not built for `InfraDID`"), + Extensions { relay_chain: "yosemite".into(), para_id: PARACHAIN_ID } ) - .with_name("InfraBlockchain DID Chain Mainnet") - .with_id("did-hub-infra") + .with_name("InfraDID Mainnet") + .with_id("infra-did-yosemite-mainnet") .with_chain_type(ChainType::Live) .with_genesis_config_patch( infra_did_genesis( @@ -210,7 +209,7 @@ pub fn mainnet_config() -> InfraDIDChainSpec { Default::default(), // endowed_accounts Default::default(), None, // root_key - INFRA_DID_PARACHAIN_ID.into(), // para_id + PARACHAIN_ID.into(), // para_id ) ) .with_properties(properties) @@ -225,38 +224,38 @@ fn infra_did_genesis( id: ParaId, ) -> serde_json::Value { serde_json::json!({ - "balances": infra_did_parachain_runtime::BalancesConfig { + "balances": infra_did_yosemite_runtime::BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, endowment)) .collect(), }, - "parachainInfo": infra_did_parachain_runtime::ParachainInfoConfig { + "parachainInfo": infra_did_yosemite_runtime::ParachainInfoConfig { parachain_id: id, ..Default::default() }, - "collatorSelection": infra_did_parachain_runtime::CollatorSelectionConfig { + "collatorSelection": infra_did_yosemite_runtime::CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: INFRA_RELAY_ED * 16, ..Default::default() }, - "session": infra_did_parachain_runtime::SessionConfig { + "session": infra_did_yosemite_runtime::SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - session_keys(aura), // session keys + acc.clone(), + acc, + session_keys(aura), ) }) .collect(), }, - "infraXcm": infra_did_parachain_runtime::InfraXcmConfig { + "infraXcm": infra_did_yosemite_runtime::InfraXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), ..Default::default() }, - "sudo": infra_did_parachain_runtime::SudoConfig { key: root_key } + "sudo": infra_did_yosemite_runtime::SudoConfig { key: root_key } }) } diff --git a/node/src/command.rs b/node/src/command.rs index 84955db..4168405 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -15,10 +15,10 @@ // along with Cumulus. If not, see . use crate::{ - chain_spec, + chain_spec::{self, GenericChainSpec}, cli::{Cli, RelayChainCli, Subcommand}, fake_runtime_api::{asset_hub_polkadot_aura::RuntimeApi as AssetHubPolkadotRuntimeApi, aura::RuntimeApi}, - service::{new_partial, Block}, + service::{new_partial, Block, Hash}, }; use cumulus_primitives_core::ParaId; use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; @@ -34,11 +34,12 @@ use std::net::SocketAddr; fn load_spec(id: &str) -> std::result::Result, String> { Ok(match id { - "infra-did-dev" | "dev" | "" => Box::new(chain_spec::development_config()), - "infra-did-testnet" => Box::new(chain_spec::testnet_config()), - "infra-did-mainnet" => Box::new(chain_spec::mainnet_config()), + "infra-did-yosemite-dev" | "dev" => Box::new(chain_spec::development_config()), + "infra-did-yosemite-local-testnet" => Box::new(chain_spec::testnet_config()), + "infra-did-yosemite-staging-testnet" => Box::new(chain_spec::testnet_config()), + "infra-did-yosemite-mainnet" => Box::new(chain_spec::mainnet_config()), // -- Loading a specific spec from disk - path => Box::new(chain_spec::InfraDIDChainSpec::from_json_file( + path => Box::new(GenericChainSpec::from_json_file( std::path::PathBuf::from(path), )?), }) @@ -46,7 +47,7 @@ fn load_spec(id: &str) -> std::result::Result, String> { impl SubstrateCli for Cli { fn impl_name() -> String { - "InfraBlockchain DID Parachain".into() + "InfraDID Parachain".into() } fn impl_version() -> String { @@ -55,7 +56,7 @@ impl SubstrateCli for Cli { fn description() -> String { format!( - "InfraBlockchain DID Parachain\n\nThe command-line arguments provided first will be \ + "InfraDID Parachain\n\nThe command-line arguments provided first will be \ passed to the parachain node, while the arguments provided after -- will be passed \ to the relaychain node.\n\n\ {} [parachain-args] -- [relaychain-args]", @@ -82,7 +83,7 @@ impl SubstrateCli for Cli { impl SubstrateCli for RelayChainCli { fn impl_name() -> String { - "InfraBlockchain DID Parachain".into() + "InfraDID Parachain".into() } fn impl_version() -> String { @@ -91,7 +92,7 @@ impl SubstrateCli for RelayChainCli { fn description() -> String { format!( - "InfraBlockchain DID Parachain\n\nThe command-line arguments provided first will be \ + "InfraDID Parachain\n\nThe command-line arguments provided first will be \ passed to the parachain node, while the arguments provided after -- will be passed \ to the relay chain node.\n\n\ {} [parachain-args] -- [relay_chain-args]", @@ -277,7 +278,7 @@ pub fn run() -> Result<()> { AccountIdConversion::::into_account_truncating(&id); let tokio_handle = config.tokio_handle.clone(); - let infra_relay_config = + let polkadot_config = SubstrateCli::create_configuration(&infra_relay_cli, &infra_relay_cli, tokio_handle) .map_err(|err| format!("Relay chain argument error: {}", err))?; @@ -285,18 +286,48 @@ pub fn run() -> Result<()> { info!("Parachain Account: {}", parachain_account); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - crate::service::start_asset_hub_lookahead_node::< - AssetHubPolkadotRuntimeApi, - AuraId, - >(config, infra_relay_config, collator_options, id, hwbench) - .await - .map(|r| r.0) - .map_err(Into::into) + match config.network.network_backend { + sc_network::config::NetworkBackendType::Libp2p => + start_node::>( + config, + polkadot_config, + collator_options, + id, + hwbench, + ) + .await, + sc_network::config::NetworkBackendType::Litep2p => + start_node::( + config, + polkadot_config, + collator_options, + id, + hwbench, + ) + .await + } }) }, } } +async fn start_node>( + config: sc_service::Configuration, + polkadot_config: sc_service::Configuration, + collator_options: cumulus_client_cli::CollatorOptions, + id: ParaId, + hwbench: Option, +) -> Result{ + crate::service::start_lookahead_node::< + AssetHubPolkadotRuntimeApi, + AuraId, + Network + >(config, polkadot_config, collator_options, id, hwbench) + .await + .map(|r| r.0) + .map_err(Into::into) +} + impl DefaultConfigurationValues for RelayChainCli { fn p2p_listen_port() -> u16 { 30334 diff --git a/node/src/common/aura.rs b/node/src/common/aura.rs new file mode 100644 index 0000000..9f72d84 --- /dev/null +++ b/node/src/common/aura.rs @@ -0,0 +1,68 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Aura-related primitives for cumulus parachain collators. + +use codec::Codec; +use cumulus_primitives_aura::AuraUnincludedSegmentApi; +use cumulus_primitives_core::BlockT; +use sp_consensus_aura::AuraApi; +use sp_runtime::app_crypto::{AppCrypto, AppPair, AppSignature, Pair}; + +/// Convenience trait for defining the basic bounds of an `AuraId`. +pub trait AuraIdT: AppCrypto + Codec + Send { + /// Extra bounds for the `Pair`. + type BoundedPair: AppPair + AppCrypto; + + /// Extra bounds for the `Signature`. + type BoundedSignature: AppSignature + + TryFrom> + + std::hash::Hash + + sp_runtime::traits::Member + + Codec; +} + +impl AuraIdT for T +where + T: AppCrypto + Codec + Send + Sync, + <::Pair as AppCrypto>::Signature: + TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, +{ + type BoundedPair = ::Pair; + type BoundedSignature = <::Pair as AppCrypto>::Signature; +} + +/// Convenience trait for defining the basic bounds of a parachain runtime that supports +/// the Aura consensus. +pub trait AuraRuntimeApi: + sp_api::ApiExt + + AuraApi::Public> + + AuraUnincludedSegmentApi + + Sized +{ + /// Check if the runtime has the Aura API. + fn has_aura_api(&self, at: Block::Hash) -> bool { + self.has_api::::Public>>(at) + .unwrap_or(false) + } +} + +impl AuraRuntimeApi for T where + T: sp_api::ApiExt + + AuraApi::Public> + + AuraUnincludedSegmentApi +{ +} diff --git a/node/src/common/mod.rs b/node/src/common/mod.rs new file mode 100644 index 0000000..4ea8705 --- /dev/null +++ b/node/src/common/mod.rs @@ -0,0 +1,48 @@ + +pub mod aura; + +use cumulus_primitives_core::CollectCollationInfo; +use sp_api::{ApiExt, CallApiAt, ConstructRuntimeApi, Metadata}; +use sp_block_builder::BlockBuilder; +use sp_runtime::traits::Block as BlockT; +use sp_session::SessionKeys; +use sp_transaction_pool::runtime_api::TaggedTransactionQueue; + +/// Convenience trait that defines the basic bounds for the `RuntimeApi` of a parachain node. +pub trait NodeRuntimeApi: + ApiExt + + Metadata + + SessionKeys + + BlockBuilder + + TaggedTransactionQueue + + CollectCollationInfo + + Sized +{ +} + +impl NodeRuntimeApi for T where + T: ApiExt + + Metadata + + SessionKeys + + BlockBuilder + + TaggedTransactionQueue + + CollectCollationInfo +{ +} + +// trait that defines the basic bounds for the `ConstructRuntimeApi` of a parachain +/// node. +pub trait ConstructNodeRuntimeApi>: + ConstructRuntimeApi + Send + Sync + 'static +{ + /// Basic bounds for the `RuntimeApi` of a parachain node. + type BoundedRuntimeApi: NodeRuntimeApi; +} + +impl> ConstructNodeRuntimeApi for T +where + T: ConstructRuntimeApi + Send + Sync + 'static, + T::RuntimeApi: NodeRuntimeApi, +{ + type BoundedRuntimeApi = T::RuntimeApi; +} \ No newline at end of file diff --git a/node/src/fake_runtime_api/asset_hub_polkadot_aura.rs b/node/src/fake_runtime_api/asset_hub_polkadot_aura.rs index 880f5d7..6b718e9 100644 --- a/node/src/fake_runtime_api/asset_hub_polkadot_aura.rs +++ b/node/src/fake_runtime_api/asset_hub_polkadot_aura.rs @@ -189,11 +189,15 @@ sp_api::impl_runtime_apis! { } impl sp_genesis_builder::GenesisBuilder for Runtime { - fn create_default_config() -> Vec { + fn build_state(_: Vec) -> sp_genesis_builder::Result { unimplemented!() } - fn build_config(_: Vec) -> sp_genesis_builder::Result { + fn get_preset(_id: &Option) -> Option> { + unimplemented!() + } + + fn preset_names() -> Vec { unimplemented!() } } diff --git a/node/src/fake_runtime_api/aura.rs b/node/src/fake_runtime_api/aura.rs index 880f5d7..6b718e9 100644 --- a/node/src/fake_runtime_api/aura.rs +++ b/node/src/fake_runtime_api/aura.rs @@ -189,11 +189,15 @@ sp_api::impl_runtime_apis! { } impl sp_genesis_builder::GenesisBuilder for Runtime { - fn create_default_config() -> Vec { + fn build_state(_: Vec) -> sp_genesis_builder::Result { unimplemented!() } - fn build_config(_: Vec) -> sp_genesis_builder::Result { + fn get_preset(_id: &Option) -> Option> { + unimplemented!() + } + + fn preset_names() -> Vec { unimplemented!() } } diff --git a/node/src/main.rs b/node/src/main.rs index ef9cccd..08f626c 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -26,6 +26,7 @@ mod service; mod cli; mod command; mod rpc; +mod common; fn main() -> sc_cli::Result<()> { command::run() diff --git a/node/src/rpc.rs b/node/src/rpc.rs index caee14e..4d87687 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -54,14 +54,14 @@ where + Send + Sync + 'static, - C::Api: frame_rpc_system::AccountNonceApi, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, B: sc_client_api::Backend + Send + Sync + 'static, B::State: sc_client_api::backend::StateBackend>, { - use frame_rpc_system::{System, SystemApiServer}; + use substrate_frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; @@ -88,12 +88,12 @@ where + Send + Sync + 'static, - C::Api: frame_rpc_system::AccountNonceApi, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, { - use frame_rpc_system::{System, SystemApiServer}; + use substrate_frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_rpc::dev::{Dev, DevApiServer}; diff --git a/node/src/service.rs b/node/src/service.rs index 2daeae5..225104c 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -17,10 +17,7 @@ use codec::{Codec, Decode}; use cumulus_client_cli::CollatorOptions; use cumulus_client_collator::service::CollatorService; -use cumulus_client_consensus_aura::collators::{ - basic::{self as basic_aura, Params as BasicAuraParams}, - lookahead::{self as aura, Params as AuraParams}, -}; +use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams}; use cumulus_client_consensus_common::{ ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus, }; @@ -41,7 +38,10 @@ use sp_core::Pair; use jsonrpsee::RpcModule; -use crate::{fake_runtime_api::aura::RuntimeApi as FakeRuntimeApi, rpc}; +use crate::{fake_runtime_api::aura::RuntimeApi as FakeRuntimeApi, rpc, common::{ + aura::{AuraIdT, AuraRuntimeApi}, + ConstructNodeRuntimeApi, +}}; pub use parachains_common::{AccountId, AuraId, Balance, Block, Hash, Header, Nonce}; use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; @@ -52,7 +52,7 @@ use sc_consensus::{ BlockImportParams, ImportQueue, }; use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; -use sc_network::{config::FullNetworkConfiguration, NetworkBlock}; +use sc_network::{config::FullNetworkConfiguration, service::traits::NetworkBackend, NetworkBlock}; use sc_network_sync::SyncingService; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; @@ -193,7 +193,7 @@ where /// /// This is the actual implementation that is abstract over the executor and the runtime api. #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -214,7 +214,7 @@ where + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi, + + substrate_frame_rpc_system::AccountNonceApi, RB: Fn( DenyUnsafe, Arc>, @@ -246,6 +246,7 @@ where Arc>) + Send + Sync>, Arc, ) -> Result<(), sc_service::Error>, + Net: NetworkBackend, { let parachain_config = prepare_node_config(parachain_config); @@ -271,7 +272,7 @@ where let prometheus_registry = parachain_config.prometheus_registry().cloned(); let transaction_pool = params.transaction_pool.clone(); let import_queue_service = params.import_queue.service(); - let net_config = FullNetworkConfiguration::new(¶chain_config.network); + let net_config = FullNetworkConfiguration::<_, _, Net>::new(¶chain_config.network); let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { @@ -435,7 +436,7 @@ where RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + sp_block_builder::BlockBuilder + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi, + + substrate_frame_rpc_system::AccountNonceApi, { let deps = rpc::FullDeps { client, pool, deny_unsafe }; @@ -517,7 +518,7 @@ where struct Verifier { client: Arc, - aura_verifier: BuildOnAccess>>, + aura_verifier: Box>, relay_chain_verifier: Box>, _phantom: PhantomData, } @@ -525,21 +526,16 @@ struct Verifier { #[async_trait::async_trait] impl VerifierT for Verifier where - Client: sp_api::ProvideRuntimeApi + Send + Sync, - Client::Api: AuraApi, - AuraId: Send + Sync + Codec, + Client: ProvideRuntimeApi + Send + Sync, + Client::Api: AuraRuntimeApi, + AuraId: AuraIdT + Sync, { async fn verify( - &mut self, + &self, block_import: BlockImportParams, ) -> Result, String> { - if self - .client - .runtime_api() - .has_api::>(*block_import.header.parent_hash()) - .unwrap_or(false) - { - self.aura_verifier.get_mut().verify(block_import).await + if self.client.runtime_api().has_aura_api(*block_import.header.parent_hash()) { + self.aura_verifier.verify(block_import).await } else { self.relay_chain_verifier.verify(block_import).await } @@ -548,7 +544,7 @@ where /// Build the import queue for parachain runtimes that started with relay chain consensus and /// switched to aura. -pub fn build_relay_to_aura_import_queue( +pub fn build_relay_to_aura_import_queue( client: Arc>, block_import: ParachainBlockImport, config: &Configuration, @@ -556,48 +552,37 @@ pub fn build_relay_to_aura_import_queue( task_manager: &TaskManager, ) -> Result, sc_service::Error> where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + sp_consensus_aura::AuraApi::Pair as Pair>::Public>, - <::Pair as Pair>::Signature: - TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, + RuntimeApi: ConstructNodeRuntimeApi>, + RuntimeApi::RuntimeApi: AuraRuntimeApi, + AuraId: AuraIdT + Sync, { let verifier_client = client.clone(); - let aura_verifier = move || { - Box::new(cumulus_client_consensus_aura::build_verifier::< - ::Pair, - _, - _, - _, - >(cumulus_client_consensus_aura::BuildVerifierParams { - client: verifier_client.clone(), - create_inherent_data_providers: move |parent_hash, _| { - let cidp_client = verifier_client.clone(); - async move { - let slot_duration = cumulus_client_consensus_aura::slot_duration_at( - &*cidp_client, - parent_hash, - )?; - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) - } - }, - telemetry: telemetry_handle, - })) as Box<_> - }; + let aura_verifier = cumulus_client_consensus_aura::build_verifier::< + ::Pair, + _, + _, + _, + >(cumulus_client_consensus_aura::BuildVerifierParams { + client: verifier_client.clone(), + create_inherent_data_providers: move |parent_hash, _| { + let cidp_client = verifier_client.clone(); + async move { + let slot_duration = + cumulus_client_consensus_aura::slot_duration_at(&*cidp_client, parent_hash)?; + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + + Ok((slot, timestamp)) + } + }, + telemetry: telemetry_handle, + }); let relay_chain_verifier = Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) })) as Box<_>; @@ -605,7 +590,7 @@ where let verifier = Verifier { client, relay_chain_verifier, - aura_verifier: BuildOnAccess::Uninitialized(Some(Box::new(aura_verifier))), + aura_verifier: Box::new(aura_verifier), _phantom: PhantomData, }; @@ -615,237 +600,13 @@ where Ok(BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry)) } -/// Start an aura powered parachain node. Some system chains use this. -pub async fn start_generic_aura_node( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - para_id: ParaId, - hwbench: Option, -) -> sc_service::error::Result<(TaskManager, Arc>)> { - start_node_impl::( - parachain_config, - polkadot_config, - collator_options, - CollatorSybilResistance::Resistant, // Aura - para_id, - build_parachain_rpc_extensions::, - build_relay_to_aura_import_queue::<_, AuraId>, - |client, - block_import, - prometheus_registry, - telemetry, - task_manager, - relay_chain_interface, - transaction_pool, - sync_oracle, - keystore, - relay_chain_slot_duration, - para_id, - collator_key, - overseer_handle, - announce_block, - _backend| { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; - - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( - task_manager.spawn_handle(), - client.clone(), - transaction_pool, - prometheus_registry, - telemetry.clone(), - ); - let proposer = Proposer::new(proposer_factory); - - let collator_service = CollatorService::new( - client.clone(), - Arc::new(task_manager.spawn_handle()), - announce_block, - client.clone(), - ); - - let params = BasicAuraParams { - create_inherent_data_providers: move |_, ()| async move { Ok(()) }, - block_import, - para_client: client, - relay_client: relay_chain_interface, - sync_oracle, - keystore, - collator_key, - para_id, - overseer_handle, - slot_duration, - relay_chain_slot_duration, - proposer, - collator_service, - // Very limited proposal time. - authoring_duration: Duration::from_millis(500), - collation_request_receiver: None, - }; - - let fut = - basic_aura::run::::Pair, _, _, _, _, _, _, _>(params); - task_manager.spawn_essential_handle().spawn("aura", None, fut); - - Ok(()) - }, - hwbench, - ) - .await -} - -/// Start a shell node which should later transition into an Aura powered parachain node. Asset Hub -/// uses this because at genesis, Asset Hub was on the `shell` runtime which didn't have Aura and -/// needs to sync and upgrade before it can run `AuraApi` functions. -pub async fn start_asset_hub_node( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - para_id: ParaId, - hwbench: Option, -) -> sc_service::error::Result<(TaskManager, Arc>)> -where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_core::CollectCollationInfo - + sp_consensus_aura::AuraApi::Pair as Pair>::Public> - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi, - <::Pair as Pair>::Signature: - TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, -{ - start_node_impl::( - parachain_config, - polkadot_config, - collator_options, - CollatorSybilResistance::Resistant, // Aura - para_id, - build_parachain_rpc_extensions::, - build_relay_to_aura_import_queue::<_, AuraId>, - |client, - block_import, - prometheus_registry, - telemetry, - task_manager, - relay_chain_interface, - transaction_pool, - sync_oracle, - keystore, - relay_chain_slot_duration, - para_id, - collator_key, - overseer_handle, - announce_block, - _backend| { - let relay_chain_interface2 = relay_chain_interface.clone(); - - let collator_service = CollatorService::new( - client.clone(), - Arc::new(task_manager.spawn_handle()), - announce_block, - client.clone(), - ); - - let spawner = task_manager.spawn_handle(); - - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( - spawner, - client.clone(), - transaction_pool, - prometheus_registry, - telemetry.clone(), - ); - - let collation_future = Box::pin(async move { - // Start collating with the `shell` runtime while waiting for an upgrade to an Aura - // compatible runtime. - let mut request_stream = cumulus_client_collator::relay_chain_driven::init( - collator_key.clone(), - para_id, - overseer_handle.clone(), - ) - .await; - while let Some(request) = request_stream.next().await { - let pvd = request.persisted_validation_data().clone(); - let last_head_hash = - match ::Header::decode(&mut &pvd.parent_head.0[..]) { - Ok(header) => header.hash(), - Err(e) => { - log::error!("Could not decode the head data: {e}"); - request.complete(None); - continue; - }, - }; - - // Check if we have upgraded to an Aura compatible runtime and transition if - // necessary. - if client - .runtime_api() - .has_api::>(last_head_hash) - .unwrap_or(false) - { - // Respond to this request before transitioning to Aura. - request.complete(None); - break; - } - } - - // Move to Aura consensus. - let slot_duration = match cumulus_client_consensus_aura::slot_duration(&*client) { - Ok(d) => d, - Err(e) => { - log::error!("Could not get Aura slot duration: {e}"); - return; - }, - }; - - let proposer = Proposer::new(proposer_factory); - - let params = BasicAuraParams { - create_inherent_data_providers: move |_, ()| async move { Ok(()) }, - block_import, - para_client: client, - relay_client: relay_chain_interface2, - sync_oracle, - keystore, - collator_key, - para_id, - overseer_handle, - slot_duration, - relay_chain_slot_duration, - proposer, - collator_service, - // Very limited proposal time. - authoring_duration: Duration::from_millis(500), - collation_request_receiver: Some(request_stream), - }; - - basic_aura::run::::Pair, _, _, _, _, _, _, _>(params) - .await - }); - - let spawner = task_manager.spawn_essential_handle(); - spawner.spawn_essential("cumulus-asset-hub-collator", None, collation_future); - - Ok(()) - }, - hwbench, - ) - .await -} - /// Start a shell node which should later transition into an Aura powered parachain node. Asset Hub /// uses this because at genesis, Asset Hub was on the `shell` runtime which didn't have Aura and /// needs to sync and upgrade before it can run `AuraApi` functions. /// /// Uses the lookahead collator to support async backing. #[sc_tracing::logging::prefix_logs_with("Parachain")] -pub async fn start_asset_hub_lookahead_node( +pub async fn start_lookahead_node( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -863,12 +624,13 @@ where + cumulus_primitives_core::CollectCollationInfo + sp_consensus_aura::AuraApi::Pair as Pair>::Public> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi + + substrate_frame_rpc_system::AccountNonceApi + cumulus_primitives_aura::AuraUnincludedSegmentApi, <::Pair as Pair>::Signature: TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, + Net: NetworkBackend, { - start_node_impl::( + start_node_impl::( parachain_config, polkadot_config, collator_options, @@ -983,162 +745,6 @@ where .await } -/// Start relay-chain consensus that is free for all. Everyone can submit a block, the relay-chain -/// decides what is backed and included. -fn start_relay_chain_consensus( - client: Arc>, - block_import: ParachainBlockImport, - prometheus_registry: Option<&Registry>, - telemetry: Option, - task_manager: &TaskManager, - relay_chain_interface: Arc, - transaction_pool: Arc>>, - _sync_oracle: Arc>, - _keystore: KeystorePtr, - _relay_chain_slot_duration: Duration, - para_id: ParaId, - collator_key: CollatorPair, - overseer_handle: OverseerHandle, - announce_block: Arc>) + Send + Sync>, - _backend: Arc, -) -> Result<(), sc_service::Error> { - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( - task_manager.spawn_handle(), - client.clone(), - transaction_pool, - prometheus_registry, - telemetry, - ); - - let free_for_all = cumulus_client_consensus_relay_chain::build_relay_chain_consensus( - cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams { - para_id, - proposer_factory, - block_import, - relay_chain_interface: relay_chain_interface.clone(), - create_inherent_data_providers: move |_, (relay_parent, validation_data)| { - let relay_chain_interface = relay_chain_interface.clone(); - async move { - let parachain_inherent = - cumulus_client_parachain_inherent::ParachainInherentDataProvider::create_at( - relay_parent, - &relay_chain_interface, - &validation_data, - para_id, - ).await; - let parachain_inherent = parachain_inherent.ok_or_else(|| { - Box::::from( - "Failed to create parachain inherent", - ) - })?; - Ok(parachain_inherent) - } - }, - }, - ); - - let spawner = task_manager.spawn_handle(); - - // Required for free-for-all consensus - #[allow(deprecated)] - old_consensus::start_collator_sync(old_consensus::StartCollatorParams { - para_id, - block_status: client.clone(), - announce_block, - overseer_handle, - spawner, - key: collator_key, - parachain_consensus: free_for_all, - runtime_api: client.clone(), - }); - - Ok(()) -} - -/// Start consensus using the lookahead aura collator. -fn start_lookahead_aura_consensus( - client: Arc>, - block_import: ParachainBlockImport, - prometheus_registry: Option<&Registry>, - telemetry: Option, - task_manager: &TaskManager, - relay_chain_interface: Arc, - transaction_pool: Arc>>, - sync_oracle: Arc>, - keystore: KeystorePtr, - relay_chain_slot_duration: Duration, - para_id: ParaId, - collator_key: CollatorPair, - overseer_handle: OverseerHandle, - announce_block: Arc>) + Send + Sync>, - backend: Arc, -) -> Result<(), sc_service::Error> { - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( - task_manager.spawn_handle(), - client.clone(), - transaction_pool, - prometheus_registry, - telemetry.clone(), - ); - - let collator_service = CollatorService::new( - client.clone(), - Arc::new(task_manager.spawn_handle()), - announce_block, - client.clone(), - ); - - let params = AuraParams { - create_inherent_data_providers: move |_, ()| async move { Ok(()) }, - block_import, - para_client: client.clone(), - para_backend: backend, - relay_client: relay_chain_interface, - code_hash_provider: move |block_hash| { - client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash()) - }, - sync_oracle, - keystore, - collator_key, - para_id, - overseer_handle, - relay_chain_slot_duration, - proposer: Proposer::new(proposer_factory), - collator_service, - authoring_duration: Duration::from_millis(1500), - reinitialize: false, - }; - - let fut = aura::run::::Pair, _, _, _, _, _, _, _, _, _>(params); - task_manager.spawn_essential_handle().spawn("aura", None, fut); - - Ok(()) -} - -/// Start an aura powered parachain node which uses the lookahead collator to support async backing. -/// This node is basic in the sense that its runtime api doesn't include common contents such as -/// transaction payment. Used for aura glutton. -pub async fn start_basic_lookahead_node( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - para_id: ParaId, - hwbench: Option, -) -> sc_service::error::Result<(TaskManager, Arc>)> { - start_node_impl::( - parachain_config, - polkadot_config, - collator_options, - CollatorSybilResistance::Resistant, // Aura - para_id, - |_, _, _, _| Ok(RpcModule::new(())), - build_relay_to_aura_import_queue::<_, AuraId>, - start_lookahead_aura_consensus, - hwbench, - ) - .await -} - /// Checks that the hardware meets the requirements and print a warning otherwise. fn warn_if_slow_hardware(hwbench: &sc_sysinfo::HwBench) { // Polkadot para-chains should generally use these requirements to ensure that the relay-chain diff --git a/pallets/did/Cargo.toml b/pallets/did/Cargo.toml new file mode 100644 index 0000000..9cdcf5e --- /dev/null +++ b/pallets/did/Cargo.toml @@ -0,0 +1,87 @@ +[package] +authors.workspace = true +edition.workspace = true +license.workspace = true +name = "pallet-did" +version = "0.1.0" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +bitflags = { workspace = true } +codec = { workspace = true } +frame-benchmarking = { workspace = true, optional = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +hex-literal = { workspace = true, optional = true } +num-traits = { workspace = true } +scale-info = { workspace = true, features = ["derive", "serde"] } +scale-info-derive = { workspace = true } +serde = { workspace = true, features = ["derive", "alloc"] } +serde-big-array = { workspace = true, optional = true } +serde-hex = { workspace = true, features = ["serde"], optional = true } +sp-api = { workspace = true } +sp-application-crypto = { workspace = true, features = [ + "serde", + "full_crypto", +] } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-io = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } +libsecp256k1 = { workspace = true, features = ["static-context", "hmac"] } +merlin = { workspace = true, optional = true } +rand = { workspace = true, optional = true } +rand_chacha = { workspace = true, optional = true } +schnorrkel = { workspace = true, optional = true } +sha2 = { workspace = true } + +[dev-dependencies] +rand = { workspace = true } +pallet-balances = { workspace = true } +pallet-timestamp = { workspace = true } + +[features] +default = ["std"] +std = [ + "serde-hex/std", + "codec/std", + "frame-support/std", + "frame-benchmarking/std", + "pallet-balances/std", + "sp-application-crypto/std", + "sp-application-crypto/full_crypto", + "serde", + "serde-big-array", + "sp-core/std", + "sp-core/full_crypto", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "frame-system/std", + "sp-api/std", + "num-traits/std", + "libsecp256k1/std", + "scale-info/std", +] + +# Serde support without relying on std features. +serde = [ + "serde-hex/serde", + "scale-info/serde", + "sp-application-crypto/serde", + "sp-core/serde", + "sp-runtime/serde", + "serde-big-array", +] + +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "hex-literal", + "schnorrkel", + "schnorrkel/chacha", + "rand_chacha", + "rand", + "merlin", +] diff --git a/pallets/did/src/common/keys.rs b/pallets/did/src/common/keys.rs new file mode 100644 index 0000000..ea3cc05 --- /dev/null +++ b/pallets/did/src/common/keys.rs @@ -0,0 +1,66 @@ +use crate::util::Bytes32; +use codec::{Decode, Encode, MaxEncodedLen}; +use sp_core::{ed25519, sr25519}; + +/// An abstraction for a public key. Abstracts the type and value of the public key where the value +/// is a byte array +#[derive( + Encode, + Decode, + Debug, + Clone, + PartialEq, + Eq, + PartialOrd, + Ord, + MaxEncodedLen, + scale_info_derive::TypeInfo, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[scale_info(omit_prefix)] +pub enum PublicKey { + /// Public key for Sr25519 is 32 bytes + Sr25519(Bytes32), + /// Public key for Ed25519 is 32 bytes + Ed25519(Bytes32), + /// Compressed X25519 public key, 32 bytes. This key is not used for signing + X25519(Bytes32), +} + +impl From for PublicKey { + fn from(value: ed25519::Public) -> Self { + PublicKey::ed25519(value.into()) + } +} + +impl From for PublicKey { + fn from(value: sr25519::Public) -> Self { + PublicKey::sr25519(value.into()) + } +} + +impl PublicKey { + pub const fn can_sign(&self) -> bool { + !matches!(self, PublicKey::X25519(_)) + } + + pub const fn sr25519(bytes: [u8; 32]) -> Self { + PublicKey::Sr25519(Bytes32(bytes)) + } + + pub const fn ed25519(bytes: [u8; 32]) -> Self { + PublicKey::Ed25519(Bytes32(bytes)) + } + + pub const fn x25519(bytes: [u8; 32]) -> Self { + PublicKey::X25519(Bytes32(bytes)) + } + + pub fn as_slice(&self) -> &[u8] { + match self { + Self::Sr25519(bytes) => &bytes[..], + Self::Ed25519(bytes) => &bytes[..], + Self::X25519(bytes) => &bytes[..], + } + } +} diff --git a/pallets/did/src/common/limits.rs b/pallets/did/src/common/limits.rs new file mode 100644 index 0000000..c5176fd --- /dev/null +++ b/pallets/did/src/common/limits.rs @@ -0,0 +1,87 @@ +use frame_support::traits::{ConstU32, Get}; + +/// All size limits for the `did-core` encodable data structures. +pub trait Limits: Clone + Eq { + /// Maximum size of the label + type MaxAccumulatorLabelSize: Get + Send + Sync + 'static; + /// Maximum byte size of the parameters. This depends only on the chosen elliptic curve. + type MaxAccumulatorParamsSize: Get + Send + Sync + 'static; + /// Maximum byte size of the public key. This depends only on the chosen elliptic curve. + type MaxAccumulatorPublicKeySize: Get + Send + Sync + 'static; + /// Maximum byte size of the accumulated value which is just one group element (not the number + /// of members) + type MaxAccumulatorAccumulatedSize: Get + Send + Sync + 'static; + + /// Maximum byte size of reference to off-chain DID Doc. + type MaxDidDocRefSize: Get + Send + Sync + 'static; + /// Maximum byte size of service endpoint's `id` field + type MaxDidServiceEndpointIdSize: Get + Send + Sync + 'static; + /// Maximum number of service endpoint's `origin` + type MaxDidServiceEndpointOrigins: Get + Send + Sync + 'static; + /// Maximum byte size of service endpoint's `origin` + type MaxDidServiceEndpointOriginSize: Get + Send + Sync + 'static; + + /// `StatusListCredential`s with size larger than this won't be accepted. + type MaxStatusListCredentialSize: Get + Send + Sync + 'static; + /// `StatusListCredential`s with size less than this won't be accepted. + type MinStatusListCredentialSize: Get + Send + Sync + 'static; + + /// Max byte size of the `Iri`. + type MaxIriSize: Get + Send + Sync + 'static; + + /// Max byte size of the `Blob`. + type MaxBlobSize: Get + Send + Sync + 'static; + + /// Max byte size of the offchain params label. + type MaxOffchainParamsLabelSize: Get + Send + Sync + 'static; + /// Max byte size of the offchain params bytes. + type MaxOffchainParamsBytesSize: Get + Send + Sync + 'static; + + /// Maximum byte size of the `BBS` (fixed size) public key. This depends only on the chosen + /// elliptic curve. + type MaxBBSPublicKeySize: Get + Send + Sync + 'static; + /// Maximum byte size of the `BBS+` (fixed size) public key. This depends only on the chosen + /// elliptic curve. + type MaxBBSPlusPublicKeySize: Get + Send + Sync + 'static; + /// Maximum byte size of the `PS` public key. This depends on the chosen elliptic curve and the + /// number of messages that can be signed. + type MaxPSPublicKeySize: Get + Send + Sync + 'static; + + /// Max amount of master members per a single `Membership`. + type MaxMasterMembers: Get + Send + Sync + 'static; + /// Max amount of the controller `DID`s per a single `Policy`. + type MaxPolicyControllers: Get + Send + Sync + 'static; +} + +type NoLimit = ConstU32<{ u32::MAX }>; +type Zero = ConstU32<0>; + +/// `Limits` without any limits. +impl Limits for () { + type MaxAccumulatorLabelSize = NoLimit; + type MaxAccumulatorParamsSize = NoLimit; + type MaxAccumulatorPublicKeySize = NoLimit; + type MaxAccumulatorAccumulatedSize = NoLimit; + + type MaxDidDocRefSize = NoLimit; + type MaxDidServiceEndpointIdSize = NoLimit; + type MaxDidServiceEndpointOrigins = NoLimit; + type MaxDidServiceEndpointOriginSize = NoLimit; + + type MaxStatusListCredentialSize = NoLimit; + type MinStatusListCredentialSize = Zero; + + type MaxIriSize = NoLimit; + + type MaxBlobSize = NoLimit; + + type MaxOffchainParamsLabelSize = NoLimit; + type MaxOffchainParamsBytesSize = NoLimit; + + type MaxBBSPublicKeySize = NoLimit; + type MaxBBSPlusPublicKeySize = NoLimit; + type MaxPSPublicKeySize = NoLimit; + + type MaxMasterMembers = NoLimit; + type MaxPolicyControllers = NoLimit; +} diff --git a/pallets/did/src/common/mod.rs b/pallets/did/src/common/mod.rs new file mode 100644 index 0000000..df1124d --- /dev/null +++ b/pallets/did/src/common/mod.rs @@ -0,0 +1,60 @@ +use core::marker::PhantomData; + +pub mod keys; +pub mod limits; +pub mod policy; +pub mod signatures; +pub mod state_change; +pub mod storage_version; +pub mod types; + +pub use keys::*; +pub use limits::*; +pub use policy::*; +pub use signatures::*; +pub use state_change::*; +pub use storage_version::*; +pub use types::*; + +/// All associated types and size limits for the encodable data structures used by the `did-core`. +pub trait TypesAndLimits: Types + Limits {} +impl TypesAndLimits for T {} + +/// Combines two different types - first implementing `Types` and second implementing `Limits` +/// to form a single type implementing both. +#[derive(Clone, Eq, PartialEq, Default)] +pub struct CombineTypesAndLimits(PhantomData<(T, L)>); + +impl Types for CombineTypesAndLimits { + type BlockNumber = T::BlockNumber; + type AccountId = T::AccountId; +} + +impl Limits for CombineTypesAndLimits { + type MaxAccumulatorLabelSize = L::MaxAccumulatorLabelSize; + type MaxAccumulatorParamsSize = L::MaxAccumulatorParamsSize; + type MaxAccumulatorPublicKeySize = L::MaxAccumulatorPublicKeySize; + type MaxAccumulatorAccumulatedSize = L::MaxAccumulatorAccumulatedSize; + + type MaxDidDocRefSize = L::MaxDidDocRefSize; + type MaxDidServiceEndpointIdSize = L::MaxDidServiceEndpointIdSize; + type MaxDidServiceEndpointOrigins = L::MaxDidServiceEndpointOrigins; + type MaxDidServiceEndpointOriginSize = L::MaxDidServiceEndpointOriginSize; + + type MaxStatusListCredentialSize = L::MaxStatusListCredentialSize; + type MinStatusListCredentialSize = L::MinStatusListCredentialSize; + + type MaxIriSize = L::MaxIriSize; + + type MaxBlobSize = L::MaxBlobSize; + + type MaxOffchainParamsLabelSize = L::MaxOffchainParamsLabelSize; + type MaxOffchainParamsBytesSize = L::MaxOffchainParamsBytesSize; + + type MaxBBSPublicKeySize = L::MaxBBSPublicKeySize; + type MaxBBSPlusPublicKeySize = L::MaxBBSPlusPublicKeySize; + type MaxPSPublicKeySize = L::MaxPSPublicKeySize; + + type MaxMasterMembers = L::MaxMasterMembers; + type MaxPolicyControllers = L::MaxPolicyControllers; +} diff --git a/pallets/did/src/common/policy.rs b/pallets/did/src/common/policy.rs new file mode 100644 index 0000000..990a19b --- /dev/null +++ b/pallets/did/src/common/policy.rs @@ -0,0 +1,255 @@ +use frame_support::{CloneNoBound, DebugNoBound, EqNoBound, PartialEqNoBound}; +use sp_std::{borrow::Borrow, fmt::Debug}; + +use super::{Limits, SigValue, ToStateChange, ED25519_WEIGHT, SR25519_WEIGHT}; +#[cfg(feature = "serde")] +use crate::util::btree_set; +use crate::{ + common::Types, + did, + did::{Did, DidSignature}, + util::{NonceError, WithNonce}, +}; +use alloc::vec::Vec; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{ + ensure, + weights::{RuntimeDbWeight, Weight}, + BoundedBTreeSet, +}; +use sp_runtime::{traits::TryCollect, DispatchError}; + +/// Authorization logic containing rules to modify some data entity. +#[derive( + Encode, + Decode, + CloneNoBound, + PartialEqNoBound, + EqNoBound, + DebugNoBound, + MaxEncodedLen, + scale_info_derive::TypeInfo, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub enum Policy { + /// Set of `DID`s allowed to modify the entity. + OneOf( + #[cfg_attr(feature = "serde", serde(with = "btree_set"))] + BoundedBTreeSet, + ), +} + +impl Policy { + /// Instantiates `Policy::OneOf` from the given iterator of controllers. + pub fn one_of( + controllers: impl IntoIterator< + IntoIter = impl ExactSizeIterator>, + Item = impl Borrow, + >, + ) -> Result { + controllers + .into_iter() + .map(|did| *did.borrow()) + .try_collect() + .map_err(|_| PolicyValidationError::TooManyControllers) + .map(Self::OneOf) + } +} + +/// An error occurred during `Policy`-based action execution. +pub enum PolicyExecutionError { + IncorrectNonce, + NoEntity, + NotAuthorized, +} + +impl From for DispatchError { + fn from(error: PolicyExecutionError) -> Self { + let raw = match error { + PolicyExecutionError::IncorrectNonce => "Incorrect nonce", + PolicyExecutionError::NoEntity => "Entity not found", + PolicyExecutionError::NotAuthorized => "Provided DID is not authorized", + }; + + DispatchError::Other(raw) + } +} + +/// An error occurred during `Policy` validation. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum PolicyValidationError { + Empty, + TooManyControllers, +} + +impl From for DispatchError { + fn from(error: PolicyValidationError) -> Self { + let raw = match error { + PolicyValidationError::Empty => "Policy can't be empty (have zero controllers)", + PolicyValidationError::TooManyControllers => "Policy can't have so many controllers", + }; + + DispatchError::Other(raw) + } +} + +impl Policy { + /// Ensures given `Policy` to be valid against supplied config. + pub fn ensure_valid(&self) -> Result<(), PolicyValidationError> { + if self.is_empty() { + Err(PolicyValidationError::Empty)? + } + + Ok(()) + } + + /// Returns underlying controllers count. + pub fn len(&self) -> u32 { + match self { + Self::OneOf(controllers) => controllers.len() as u32, + } + } + + /// Returns `true` if given `Policy` is empty, i.e. doesn't have a single controller. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Executes action over target data providing a mutable reference if all checks succeed. + /// + /// Unlike `try_exec_action_over_data`, this action may result in a removal of a data, if the + /// value under option will be taken. + /// + /// Checks: + /// 1. Verify that `proof` authorizes `action` according to `policy`. + /// 2. Verify that the action is not a replayed payload by ensuring each provided controller + /// nonce equals the last nonce plus 1. + /// + /// Returns a mutable reference to the underlying data wrapped into an option if the command is + /// authorized, otherwise returns Err. + pub fn try_exec_removable_action( + entity: &mut Option, + f: F, + mut action: S, + proof: Vec>, + ) -> Result + where + T: crate::did::Config, + V: HasPolicy, + F: FnOnce(S, &mut Option) -> Result, + WithNonce: ToStateChange, + E: From + From> + From, + { + let data = entity.take().ok_or(PolicyExecutionError::NoEntity)?; + // check the signer set satisfies policy + match &data.policy() { + Policy::OneOf(controllers) => { + ensure!( + proof.len() == 1 && controllers.contains(&proof[0].sig.did), + PolicyExecutionError::NotAuthorized + ); + }, + } + + let mut new_did_details = Vec::with_capacity(proof.len()); + // check each signature is valid over payload and signed by the claimed signer + for DidSignatureWithNonce { sig, nonce } in proof { + let signer = sig.did; + + // Check if nonce is valid and increase it + let mut did_detail = did::Pallet::::onchain_did_details(&signer)?; + did_detail.try_update(nonce).map_err(|_| PolicyExecutionError::IncorrectNonce)?; + + let action_with_nonce = WithNonce::new_with_nonce(action, nonce); + // Verify signature + let valid = + did::Pallet::::verify_sig_from_auth_or_control_key(&action_with_nonce, &sig)?; + action = action_with_nonce.into_data(); + + ensure!(valid, PolicyExecutionError::NotAuthorized); + new_did_details.push((signer, did_detail)); + } + + let mut owned_data_opt = Some(data); + let res = f(action, &mut owned_data_opt)?; + *entity = owned_data_opt; + + // The nonce of each DID must be updated + for (signer, did_details) in new_did_details { + did::Pallet::::insert_did_details(signer, did_details); + } + + Ok(res) + } +} + +/// Collection of signatures sent by different DIDs. +#[derive(PartialEq, Eq, Encode, Decode, Clone, DebugNoBound, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct DidSignatureWithNonce +where + T: Types, +{ + /// `DID`'s signature + pub sig: DidSignature, + /// Nonce used to make the above signature + pub nonce: T::BlockNumber, +} + +#[derive(PartialEq, Eq, Encode, Decode, Clone, Debug, Default)] +struct SigTypes { + sr: V, + ed: V, +} + +impl DidSignatureWithNonce { + /// Return counts of different signature types in given `DidSignatureWithNonce` as 3-Tuple as + /// (no. of Sr22519 sigs, no. of Ed25519 Sigs). Useful for weight + /// calculation and thus the return type is in `Weight` but realistically, it should fit in a u8 + fn count_sig_types( + auths: impl IntoIterator>>, + ) -> SigTypes { + let mut counts = SigTypes::default(); + + for auth in auths { + let counter = match auth.borrow().sig.sig { + SigValue::Sr25519(_) => &mut counts.sr, + SigValue::Ed25519(_) => &mut counts.ed, + }; + + *counter += 1; + } + + counts + } + + /// Computes weight of the given `DidSignatureWithNonce`. Considers the no. and types of + /// signatures and no. of reads. Disregards message size as messages are hashed giving the same + /// output size and hashing itself is very cheap. The extrinsic using it might decide to + /// consider adding some weight proportional to the message size. + pub fn auth_weight( + auths: impl IntoIterator>>, + db_weights: RuntimeDbWeight, + ) -> Weight { + let SigTypes { sr, ed } = Self::count_sig_types(auths); + + db_weights + .reads(sr + ed) + .saturating_add(SR25519_WEIGHT.saturating_mul(sr)) + .saturating_add(ED25519_WEIGHT.saturating_mul(ed)) + } +} + +/// Denotes an entity which has an associated `Policy`. +pub trait HasPolicy { + /// Returns underlying `Policy`. + fn policy(&self) -> &Policy; +} diff --git a/pallets/did/src/common/signatures.rs b/pallets/did/src/common/signatures.rs new file mode 100644 index 0000000..1ce5151 --- /dev/null +++ b/pallets/did/src/common/signatures.rs @@ -0,0 +1,134 @@ +use super::keys::PublicKey; +use crate::util::Bytes64; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::weights::Weight; +use sp_core::{ed25519, sr25519, Pair}; +use sp_runtime::traits::Verify; + +/// An abstraction for a signature. +#[derive( + Encode, Decode, scale_info_derive::TypeInfo, Debug, Clone, PartialEq, Eq, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[scale_info(omit_prefix)] +pub enum SigValue { + /// Signature for Sr25519 is 64 bytes + Sr25519(Bytes64), + /// Signature for Ed25519 is 64 bytes + Ed25519(Bytes64), +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum VerificationError { + IncompatibleKey(PublicKey, SigValue), +} + +impl SigValue { + /// Get weight for signature verification. + /// Considers the type of signature. Disregards message size as messages are hashed giving the + /// same output size and hashing itself is very cheap. The extrinsic using it might decide to + /// consider adding some weight proportional to the message size. + pub fn weight(&self) -> Weight { + match self { + SigValue::Sr25519(_) => SR25519_WEIGHT, + SigValue::Ed25519(_) => ED25519_WEIGHT, + } + } + + pub fn verify( + &self, + message: &[u8], + public_key: &PublicKey, + ) -> Result { + macro_rules! verify { + ( $message:ident, $sig_bytes:ident, $pk_bytes:ident, $sig_type:expr, $pk_type:expr ) => {{ + let signature = $sig_type(**$sig_bytes); + let pk = $pk_type(**$pk_bytes); + signature.verify($message, &pk) + }}; + } + + let result = match (public_key, self) { + (PublicKey::Sr25519(pk_bytes), SigValue::Sr25519(sig_bytes)) => { + let sig = sr25519::Signature::from(sig_bytes.0); + let pk = sr25519::Public::from(pk_bytes.0); + sig.verify(message, &pk) + }, + (PublicKey::Ed25519(pk_bytes), SigValue::Ed25519(sig_bytes)) => { + let sig = ed25519::Signature::from(sig_bytes.0); + let pk = ed25519::Public::from(pk_bytes.0); + sig.verify(message, &pk) + }, + _ => Err(VerificationError::IncompatibleKey(public_key.clone(), self.clone()))?, + }; + + Ok(result) + } + + pub fn sr25519(msg: &[u8], pair: &sr25519::Pair) -> Self { + SigValue::Sr25519(pair.sign(msg).0.into()) + } + + pub fn ed25519(msg: &[u8], pair: &ed25519::Pair) -> Self { + SigValue::Ed25519(pair.sign(msg).0.into()) + } +} + +impl From for SigValue { + fn from(value: ed25519::Signature) -> Self { + let bytes: [u8; ed25519::SIGNATURE_SERIALIZED_SIZE] = value.into(); + SigValue::Ed25519(Bytes64(bytes)) + } +} + +impl From for SigValue { + fn from(value: sr25519::Signature) -> Self { + let bytes: [u8; sr25519::SIGNATURE_SERIALIZED_SIZE] = value.into(); + SigValue::Sr25519(Bytes64(bytes)) + } +} + +// Weight for Sr25519 sig verification +// TODO: proof size +pub const SR25519_WEIGHT: Weight = Weight::from_parts(140_000_000, 0); +// Weight for Ed25519 sig verification +// TODO: proof size +pub const ED25519_WEIGHT: Weight = Weight::from_parts(152_000_000, 0); + +#[cfg(test)] +mod tests { + use super::*; + + use sp_core::Pair; + + #[test] + fn signature_verification() { + // Check that the signature should be wrapped in correct variant of enum `SigValue`. + // Trying to wrap a Sr25519 signature in a SigValue::Ed25519 should fail. + // Trying to wrap a Ed25519 signature in a SigValue::Sr25519 should fail. + let msg = vec![26u8; 350]; + + // The macro checks that a signature verification only passes when sig wrapped in + // `$correct_sig_type` but fails when wrapped in `$incorrect_sig_type` + macro_rules! check_sig_verification { + ( $module:ident, $pk_type:expr, $correct_sig_type:expr, $incorrect_sig_type:expr ) => {{ + let (pair, _, _) = $module::Pair::generate_with_phrase(None); + let pk_bytes = pair.public().0; + let pk = $pk_type(pk_bytes.into()); + assert!(pk.can_sign()); + let sig_bytes = pair.sign(&msg).0; + let correct_sig = $correct_sig_type(sig_bytes.into()); + + // Valid signature wrapped in a correct type works + assert!(correct_sig.verify(&msg, &pk).unwrap()); + + // Valid signature wrapped in an incorrect type does not work + let incorrect_sig = $incorrect_sig_type(sig_bytes.into()); + assert!(incorrect_sig.verify(&msg, &pk).is_err()) + }}; + } + + check_sig_verification!(sr25519, PublicKey::Sr25519, SigValue::Sr25519, SigValue::Ed25519); + check_sig_verification!(ed25519, PublicKey::Ed25519, SigValue::Ed25519, SigValue::Sr25519); + } +} diff --git a/pallets/did/src/common/state_change.rs b/pallets/did/src/common/state_change.rs new file mode 100644 index 0000000..a03c6e9 --- /dev/null +++ b/pallets/did/src/common/state_change.rs @@ -0,0 +1,49 @@ +#![allow(unused_lifetimes)] +use super::TypesAndLimits; + +crate::def_state_change! { + /// Any state change that needs to be signed is first wrapped in this enum and then its serialized. + /// This is done to make it unambiguous which command was intended as the SCALE codec's + /// not self describing. The enum variants are supposed to take care of replay protection by having a + /// nonce or something else. A better approach would have been to make `StateChange` aware of nonce or nonces. + /// There can be multiple nonces attached with a payload a multiple DIDs may take part in an action and they + /// will have their own nonce. However this change will be a major disruption for now. + /// Never change the order of variants in this enum + StateChange: + did::AddKeys, + did::AddControllers, + did::RemoveKeys, + did::RemoveControllers, + did::AddServiceEndpoint, + did::RemoveServiceEndpoint, + did::DidRemoval, + revoke::Revoke, + revoke::UnRevoke, + revoke::RemoveRegistry, + blob::AddBlob, + attest::SetAttestationClaim, + offchain_signatures::AddOffchainSignatureParams, + offchain_signatures::AddOffchainSignaturePublicKey, + offchain_signatures::RemoveOffchainSignatureParams, + offchain_signatures::RemoveOffchainSignaturePublicKey, + accumulator::AddAccumulatorParams, + accumulator::AddAccumulatorPublicKey, + accumulator::RemoveAccumulatorParams, + accumulator::RemoveAccumulatorPublicKey, + accumulator::AddAccumulator, + accumulator::UpdateAccumulator, + accumulator::RemoveAccumulator, + status_list_credential::UpdateStatusListCredential, + status_list_credential::RemoveStatusListCredential, + trusted_entity::AddIssuer, + trusted_entity::RemoveIssuer, + trusted_entity::AddVerifier, + trusted_entity::RemoveVerifier, + trusted_entity::RemoveAuthorizer +} + +/// Converts the given entity to the state change. +pub trait ToStateChange { + /// Converts the given entity to the state change. + fn to_state_change(&self) -> StateChange<'_, T>; +} diff --git a/pallets/did/src/common/storage_version.rs b/pallets/did/src/common/storage_version.rs new file mode 100644 index 0000000..f48e2a3 --- /dev/null +++ b/pallets/did/src/common/storage_version.rs @@ -0,0 +1,18 @@ +use codec::{Decode, Encode, MaxEncodedLen}; + +/// Defines version of the storage being used. +#[derive( + Encode, Decode, scale_info_derive::TypeInfo, Copy, Clone, Debug, Eq, PartialEq, MaxEncodedLen, +)] +pub enum StorageVersion { + /// The old version which supports only a single key for DID. + SingleKey, + /// Multi-key DID. + MultiKey, +} + +impl Default for StorageVersion { + fn default() -> Self { + Self::SingleKey + } +} diff --git a/pallets/did/src/common/types.rs b/pallets/did/src/common/types.rs new file mode 100644 index 0000000..f3d66e1 --- /dev/null +++ b/pallets/did/src/common/types.rs @@ -0,0 +1,45 @@ +use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; +use core::fmt::Debug; +use frame_support::pallet_prelude::*; +use frame_system::pallet_prelude::BlockNumberFor; +use scale_info::TypeInfo; +use sp_runtime::traits::*; + +#[derive( + Encode, Decode, Copy, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, Debug, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[scale_info(omit_prefix)] +pub enum CurveType { + /// BLS12-381 + Bls12381, +} + +/// Defines associated types used by `did-core`. +pub trait Types: Clone + Eq { + type BlockNumber: Member + + MaybeSerializeDeserialize + + MaybeFromStr + + Debug + + sp_std::hash::Hash + + Copy + + MaybeDisplay + + AtLeast32BitUnsigned + + Default + + TypeInfo + + MaxEncodedLen + + FullCodec; + + type AccountId: Parameter + + Member + + MaybeSerializeDeserialize + + Debug + + MaybeDisplay + + Ord + + MaxEncodedLen; +} + +impl Types for T { + type BlockNumber = BlockNumberFor; + type AccountId = T::AccountId; +} diff --git a/pallets/did/src/lib.rs b/pallets/did/src/lib.rs new file mode 100644 index 0000000..9ae96f1 --- /dev/null +++ b/pallets/did/src/lib.rs @@ -0,0 +1,16 @@ +#![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::unused_unit)] + +extern crate alloc; + +pub mod common; +pub mod modules; +pub mod util; + +pub use modules::{ + accumulator, anchor, attest, blob, did, offchain_signatures, revoke, status_list_credential, + trusted_entity, +}; + +#[cfg(test)] +mod tests; diff --git a/pallets/did/src/modules/accumulator/actions.rs b/pallets/did/src/modules/accumulator/actions.rs new file mode 100644 index 0000000..770de58 --- /dev/null +++ b/pallets/did/src/modules/accumulator/actions.rs @@ -0,0 +1,102 @@ +use super::*; +use crate::{common::TypesAndLimits, util::Bytes}; +use frame_support::DebugNoBound; + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddAccumulatorPublicKey { + pub public_key: AccumulatorPublicKey, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddAccumulatorParams { + pub params: AccumulatorParameters, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveAccumulatorParams { + pub params_ref: AccumParametersStorageKey, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveAccumulatorPublicKey { + pub key_ref: AccumPublicKeyStorageKey, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddAccumulator { + pub id: AccumulatorId, + pub accumulator: Accumulator, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveAccumulator { + pub id: AccumulatorId, + /// Next valid nonce, i.e. 1 greater than currently stored + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct UpdateAccumulator { + pub id: AccumulatorId, + pub new_accumulated: Bytes, + pub additions: Option>, + pub removals: Option>, + pub witness_update_info: Option, + /// Next valid nonce, i.e. 1 greater than currently stored + pub nonce: T::BlockNumber, +} + +crate::impl_action_with_nonce! { + for AccumulatorId: + UpdateAccumulator with 1 as len, id as target, + RemoveAccumulator with 1 as len, id as target +} + +crate::impl_action_with_nonce! { + for (): + AddAccumulator with 1 as len, () as target, + AddAccumulatorParams with 1 as len, () as target, + AddAccumulatorPublicKey with 1 as len, () as target, + RemoveAccumulatorPublicKey with 1 as len, () as target, + RemoveAccumulatorParams with 1 as len, () as target +} diff --git a/pallets/did/src/modules/accumulator/benchmarks.rs b/pallets/did/src/modules/accumulator/benchmarks.rs new file mode 100644 index 0000000..45cd661 --- /dev/null +++ b/pallets/did/src/modules/accumulator/benchmarks.rs @@ -0,0 +1,393 @@ +use super::*; +use crate::{common::state_change::ToStateChange, did::UncheckedDidKey, util::IncId}; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MAX_PARAMS: u32 = 512; +const MAX_LABEL: u32 = 128; +const MAX_ACC: u32 = 128; +const MAX_KEY: u32 = 256; + +crate::bench_with_all_pairs! { + with_pairs: + add_params_sr25519 for sr25519, add_params_ed25519 for ed25519, add_params_secp256k1 for secp256k1 { + { + let b in 0 .. MAX_PARAMS => (); + let l in 1 .. MAX_LABEL => (); + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let params = AccumulatorParameters { + curve_type: CurveType::Bls12381, + bytes: vec![3; b as usize].try_into().unwrap(), + label: Some(vec![0; l as usize].try_into().unwrap()) + }; + + let new_params = AddAccumulatorParams { + params: params.clone(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&new_params.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: add_params(RawOrigin::Signed(caller), new_params, signature) + verify { + assert_eq!(AccumulatorParams::get(AccumulatorOwner(did), IncId::from(1u8)).unwrap(), params); + } + + remove_params_sr25519 for sr25519, remove_params_ed25519 for ed25519, remove_params_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + Pallet::::add_params_( + AddAccumulatorParams { + params: AccumulatorParameters { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_PARAMS as usize].try_into().unwrap(), + label: Some(vec![1; MAX_LABEL as usize].try_into().unwrap()), + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + let rem_params = RemoveAccumulatorParams { + params_ref: (AccumulatorOwner(did), 1u8.try_into().unwrap()), + nonce: 1u8.into() + }; + + let sig = pair.sign(&rem_params.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + + }: remove_params(RawOrigin::Signed(caller), rem_params, signature) + verify { + assert!(AccumulatorParams::::get(AccumulatorOwner(did), IncId::from(1u8)).is_none()); + } + + add_public_sr25519 for sr25519, add_public_ed25519 for ed25519, add_public_secp256k1 for secp256k1 { + { + let b in 0 .. MAX_KEY; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + Pallet::::add_params_( + AddAccumulatorParams { + params: AccumulatorParameters { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_PARAMS as usize].try_into().unwrap(), + label: Some(vec![1; MAX_LABEL as usize].try_into().unwrap()), + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + let public_key = AccumulatorPublicKey { + curve_type: CurveType::Bls12381, + bytes: vec![3; b as usize].try_into().unwrap(), + /// The params used to generate the public key (`P_tilde` comes from params) + params_ref: Some((AccumulatorOwner(did), IncId::from(1u8))) + }; + + let add_key = AddAccumulatorPublicKey { + public_key: public_key.clone(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&add_key.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: add_public_key(RawOrigin::Signed(caller), add_key, signature) + verify { + assert_eq!(AccumulatorKeys::get(AccumulatorOwner(did), IncId::from(1u8)).unwrap(), public_key); + } + + remove_public_sr25519 for sr25519, remove_public_ed25519 for ed25519, remove_public_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + Pallet::::add_params_( + AddAccumulatorParams { + params: AccumulatorParameters { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_PARAMS as usize].try_into().unwrap(), + label: Some(vec![1; MAX_LABEL as usize].try_into().unwrap()), + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + Pallet::::add_public_key_( + AddAccumulatorPublicKey { + public_key: AccumulatorPublicKey { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_KEY as usize].try_into().unwrap(), + /// The params used to generate the public key (`P_tilde` comes from params) + params_ref: Some((AccumulatorOwner(did), IncId::from(1u8))) + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + let rem_key = RemoveAccumulatorPublicKey { + key_ref: (AccumulatorOwner(did), 1u8.try_into().unwrap()), + nonce: 1u8.into() + }; + + let sig = pair.sign(&rem_key.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + + }: remove_public_key(RawOrigin::Signed(caller), rem_key, signature) + verify { + assert!(AccumulatorKeys::::get(AccumulatorOwner(did), IncId::from(1u8)).is_none()); + } + + add_accumulator_sr25519 for sr25519, add_accumulator_ed25519 for ed25519, add_accumulator_secp256k1 for secp256k1 { + { + let b in 0 .. MAX_ACC; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + + let public = pair.public(); + let accumulator = Accumulator::Positive(AccumulatorCommon { + accumulated: vec![3; b as usize].try_into().unwrap(), + key_ref: (AccumulatorOwner(did), 1u8.into()), + }); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let acc_id: AccumulatorId = AccumulatorId([1; 32]); + + Pallet::::add_params_( + AddAccumulatorParams { + params: AccumulatorParameters { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_PARAMS as usize].try_into().unwrap(), + label: Some(vec![1; MAX_LABEL as usize].try_into().unwrap()), + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + + Pallet::::add_public_key_( + AddAccumulatorPublicKey { + public_key: AccumulatorPublicKey { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_KEY as usize].try_into().unwrap(), + /// The params used to generate the public key (`P_tilde` comes from params) + params_ref: Some((AccumulatorOwner(did), IncId::from(1u8))) + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + let add_acc = AddAccumulator { + id: acc_id, + accumulator: accumulator.clone(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&add_acc.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: add_accumulator(RawOrigin::Signed(caller), add_acc.clone(), signature) + verify { + assert_eq!(Accumulators::::get(acc_id).unwrap().accumulator, accumulator); + } + + update_accumulator_sr25519 for sr25519, update_accumulator_ed25519 for ed25519, update_accumulator_secp256k1 for secp256k1 { + { + let a in 0 .. MAX_ACC; + let b in 0 .. 30; + let c in 0 .. 100; + let d in 0 .. 30; + let e in 0 .. 100; + let f in 0 .. 100; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + + let public = pair.public(); + let accumulator = Accumulator::Positive(AccumulatorCommon { + accumulated: vec![3; MAX_ACC as usize].try_into().unwrap(), + key_ref: (AccumulatorOwner(did), 1u8.try_into().unwrap()), + }); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let acc_id: AccumulatorId = AccumulatorId([1; 32]); + + Pallet::::add_params_( + AddAccumulatorParams { + params: AccumulatorParameters { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_PARAMS as usize].try_into().unwrap(), + label: Some(vec![1; MAX_LABEL as usize].try_into().unwrap()), + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + + Pallet::::add_public_key_( + AddAccumulatorPublicKey { + public_key: AccumulatorPublicKey { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_KEY as usize].try_into().unwrap(), + /// The params used to generate the public key (`P_tilde` comes from params) + params_ref: Some((AccumulatorOwner(did), IncId::from(1u8))) + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + Pallet::::add_accumulator_( + AddAccumulator { + id: acc_id, + accumulator, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + + let new_accumulated = vec![3; a as usize]; + let up_acc = UpdateAccumulator { + id: acc_id, + new_accumulated: new_accumulated.clone().into(), + additions: Some((0..b).map(|i| vec![i as u8; c as usize].into()).collect()), + removals: Some((0..d).map(|i| vec![i as u8; e as usize].into()).collect()), + witness_update_info: Some(vec![5; f as usize].try_into().unwrap()), + nonce: 1u32.into(), + }; + + let sig = pair.sign(&up_acc.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: update_accumulator(RawOrigin::Signed(caller), up_acc, signature) + verify { + assert_eq!(Accumulators::::get(acc_id).unwrap().accumulator.accumulated(), new_accumulated); + } + + remove_accumulator_sr25519 for sr25519, remove_accumulator_ed25519 for ed25519, remove_accumulator_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + let accumulator = Accumulator::Positive(AccumulatorCommon { + accumulated: vec![3; MAX_ACC as usize].try_into().unwrap(), + key_ref: (AccumulatorOwner(did), 1u8.try_into().unwrap()), + }); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let acc_id: AccumulatorId = AccumulatorId([2; 32]); + + Pallet::::add_params_( + AddAccumulatorParams { + params: AccumulatorParameters { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_PARAMS as usize].try_into().unwrap(), + label: Some(vec![1; MAX_LABEL as usize].try_into().unwrap()), + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + + Pallet::::add_public_key_( + AddAccumulatorPublicKey { + public_key: AccumulatorPublicKey { + curve_type: CurveType::Bls12381, + bytes: vec![3; MAX_KEY as usize].try_into().unwrap(), + /// The params used to generate the public key (`P_tilde` comes from params) + params_ref: Some((AccumulatorOwner(did), IncId::from(1u8))) + }, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + Pallet::::add_accumulator_( + AddAccumulator { + id: acc_id, + accumulator, + nonce: 1u8.into() + }, + AccumulatorOwner(did) + ).unwrap(); + + let remove_acc = RemoveAccumulator { + id: acc_id, + nonce: 1u8.into() + }; + + let sig = pair.sign(&remove_acc.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: remove_accumulator(RawOrigin::Signed(caller), remove_acc, signature) + verify { + assert!(Accumulators::::get(acc_id).is_none()); + } +} diff --git a/pallets/did/src/modules/accumulator/impl.rs b/pallets/did/src/modules/accumulator/impl.rs new file mode 100644 index 0000000..001af78 --- /dev/null +++ b/pallets/did/src/modules/accumulator/impl.rs @@ -0,0 +1,146 @@ +use super::*; +use crate::deposit_indexed_event; + +impl Pallet { + pub(super) fn add_params_( + AddAccumulatorParams { params, .. }: AddAccumulatorParams, + owner: AccumulatorOwner, + ) -> DispatchResult { + let params_counter = + AccumulatorOwnerCounters::::mutate(owner, |counters| *counters.params_counter.inc()); + AccumulatorParams::::insert(owner, params_counter, params); + + Self::deposit_event(Event::ParamsAdded(owner, params_counter)); + Ok(()) + } + + pub(super) fn add_public_key_( + AddAccumulatorPublicKey { public_key, .. }: AddAccumulatorPublicKey, + owner: AccumulatorOwner, + ) -> DispatchResult { + if let Some((acc_owner, params_id)) = public_key.params_ref { + ensure!( + AccumulatorParams::::contains_key(acc_owner, params_id), + Error::::ParamsDontExist + ); + } + + let keys_counter = + AccumulatorOwnerCounters::::mutate(owner, |counters| *counters.key_counter.inc()); + AccumulatorKeys::insert(owner, keys_counter, public_key); + + Self::deposit_event(Event::KeyAdded(owner, keys_counter)); + Ok(()) + } + + pub(super) fn remove_params_( + RemoveAccumulatorParams { params_ref: (did, counter), .. }: RemoveAccumulatorParams, + owner: AccumulatorOwner, + ) -> DispatchResult { + // Only the DID that added the param can remove it + ensure!(did == owner, Error::::NotAccumulatorOwner); + ensure!(AccumulatorParams::::contains_key(did, counter), Error::::ParamsDontExist); + + AccumulatorParams::::remove(did, counter); + + Self::deposit_event(Event::ParamsRemoved(did, counter)); + Ok(()) + } + + pub(super) fn remove_public_key_( + RemoveAccumulatorPublicKey { key_ref: (did, counter), .. }: RemoveAccumulatorPublicKey, + owner: AccumulatorOwner, + ) -> DispatchResult { + ensure!(did == owner, Error::::NotAccumulatorOwner); + ensure!(AccumulatorKeys::::contains_key(did, counter), Error::::PublicKeyDoesntExist); + + AccumulatorKeys::::remove(did, counter); + + Self::deposit_event(Event::KeyRemoved(did, counter)); + Ok(()) + } + + pub(super) fn add_accumulator_( + AddAccumulator { id, accumulator, .. }: AddAccumulator, + owner: AccumulatorOwner, + ) -> DispatchResult { + ensure!(!Accumulators::::contains_key(id), Error::::AccumulatorAlreadyExists); + + let (acc_owner, key_id) = accumulator.key_ref(); + ensure!( + AccumulatorKeys::::contains_key(acc_owner, key_id), + Error::::PublicKeyDoesntExist + ); + ensure!(acc_owner == owner, Error::::NotPublicKeyOwner); + + let accumulated = accumulator.accumulated().to_vec().into(); + + let current_block = >::block_number(); + Accumulators::::insert(id, AccumulatorWithUpdateInfo::new(accumulator, current_block)); + + deposit_indexed_event!(AccumulatorAdded(id, accumulated) over id); + Ok(()) + } + + pub(super) fn update_accumulator_( + UpdateAccumulator { id, new_accumulated, .. }: UpdateAccumulator, + owner: AccumulatorOwner, + ) -> DispatchResult { + Accumulators::::try_mutate(id, |accumulator| -> DispatchResult { + let accumulator = accumulator.as_mut().ok_or(Error::::AccumulatorDoesntExist)?; + + // Only the DID that added the accumulator can update it + ensure!(*accumulator.accumulator.owner_did() == owner, Error::::NotAccumulatorOwner); + + accumulator + .accumulator + .set_new_accumulated(new_accumulated.clone().0) + .map_err(|_| Error::::AccumulatedTooBig)?; + accumulator.last_updated_at = >::block_number(); + + Ok(()) + })?; + + // The event stores only the accumulated value which can be used by the verifier. + // For witness update, that information is retrieved by looking at the block and parsing the + // extrinsic. + deposit_indexed_event!(AccumulatorUpdated(id, new_accumulated) over id); + Ok(()) + } + + pub(super) fn remove_accumulator_( + RemoveAccumulator { id, .. }: RemoveAccumulator, + signer: AccumulatorOwner, + ) -> DispatchResult { + let accumulator = Accumulators::::get(id).ok_or(Error::::AccumulatorDoesntExist)?; + + // Only the DID that added the accumulator can remove it + ensure!(*accumulator.accumulator.owner_did() == signer, Error::::NotAccumulatorOwner); + Accumulators::::remove(id); + + deposit_indexed_event!(AccumulatorRemoved(id)); + Ok(()) + } + + pub fn public_key_with_params( + (key_did, key_id): &AccumPublicKeyStorageKey, + ) -> Option> { + let pk = AccumulatorKeys::get(key_did, key_id)?; + let params = match &pk.params_ref { + Some((params_did, params_id)) => AccumulatorParams::::get(params_did, params_id), + _ => None, + }; + + Some((pk, params)) + } + + /// Get accumulated value with public key and params. + pub fn get_accumulator_with_public_key_and_params( + id: &AccumulatorId, + ) -> Option<(Vec, Option>)> { + let stored_acc = Accumulators::::get(id)?; + let pk_p = Self::public_key_with_params(&stored_acc.accumulator.key_ref()); + + Some((stored_acc.accumulator.accumulated().to_vec(), pk_p)) + } +} diff --git a/pallets/did/src/modules/accumulator/mod.rs b/pallets/did/src/modules/accumulator/mod.rs new file mode 100644 index 0000000..9a27ef9 --- /dev/null +++ b/pallets/did/src/modules/accumulator/mod.rs @@ -0,0 +1,362 @@ +use crate::{ + common::{self, CurveType, SigValue}, + did, + did::{Did, DidSignature}, + util::{Bytes, CheckedDivCeil, IncId}, +}; +pub use actions::*; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{dispatch::DispatchResult, ensure, weights::Weight}; +use sp_std::{fmt::Debug, prelude::*}; + +pub use pallet::*; +pub use types::*; +use weights::*; + +mod actions; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +mod r#impl; +#[cfg(test)] +mod tests; +mod types; +mod weights; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + // The module's configuration trait. + #[pallet::config] + pub trait Config: frame_system::Config + did::Config { + /// The overarching event type. + type RuntimeEvent: From + + IsType<::RuntimeEvent> + + Into<::RuntimeEvent>; + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + ParamsAdded(AccumulatorOwner, IncId), + ParamsRemoved(AccumulatorOwner, IncId), + KeyAdded(AccumulatorOwner, IncId), + KeyRemoved(AccumulatorOwner, IncId), + AccumulatorAdded(AccumulatorId, Bytes), + AccumulatorUpdated(AccumulatorId, Bytes), + AccumulatorRemoved(AccumulatorId), + } + + #[pallet::error] + pub enum Error { + ParamsDontExist, + PublicKeyDoesntExist, + AccumulatedTooBig, + AccumulatorDoesntExist, + AccumulatorAlreadyExists, + NotPublicKeyOwner, + NotAccumulatorOwner, + IncorrectNonce, + } + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::storage] + #[pallet::getter(fn did_counters)] + pub type AccumulatorOwnerCounters = StorageMap< + _, + Blake2_128Concat, + AccumulatorOwner, + StoredAccumulatorOwnerCounters, + ValueQuery, + >; + + #[pallet::storage] + #[pallet::getter(fn accumulator_params)] + pub type AccumulatorParams = StorageDoubleMap< + _, + Blake2_128Concat, + AccumulatorOwner, + Identity, + IncId, + AccumulatorParameters, + >; + + /// Public key storage is kept separate from accumulator storage and a single key can be used to + /// manage several accumulators. It is assumed that whoever (DID) owns the public key, owns the + /// accumulator as well and only that DID can update accumulator. + #[pallet::storage] + #[pallet::getter(fn accumulator_key)] + pub type AccumulatorKeys = StorageDoubleMap< + _, + Blake2_128Concat, + AccumulatorOwner, + Identity, + IncId, + AccumulatorPublicKey, + >; + + /// Stores latest accumulator as key value: accumulator id -> (created_at, last_updated_at, + /// Accumulator) `created_at` is the block number when the accumulator was created and is + /// intended to serve as a starting point for anyone looking for all updates to the accumulator. + /// `last_updated_at` is the block number when the last update was sent. `created_at` and + /// `last_updated_at` together indicate which blocks should be considered for finding + /// accumulator updates. Historical values and updates are persisted as events indexed with the + /// accumulator id. The reason for not storing past values is to save storage in chain state. + /// Another option could have been to store block numbers for the updates so that each block + /// from `created_at` doesn't need to be scanned but even that requires large storage as we + /// expect millions of updates. Just keeping the latest accumulated value allows for any + /// potential on chain verification as well. + #[pallet::storage] + #[pallet::getter(fn accumulator)] + pub type Accumulators = + StorageMap<_, Blake2_128Concat, AccumulatorId, AccumulatorWithUpdateInfo, OptionQuery>; + + #[pallet::storage] + #[pallet::getter(fn version)] + pub type Version = StorageValue<_, common::StorageVersion, ValueQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub _marker: PhantomData, + } + + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + GenesisConfig { _marker: PhantomData } + } + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) { + Version::::put(common::StorageVersion::MultiKey); + } + } + + #[pallet::call] + impl Pallet { + #[pallet::weight(SubstrateWeight::::add_params(params, signature))] + #[pallet::call_index(0)] + pub fn add_params( + origin: OriginFor, + params: AddAccumulatorParams, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::add_params_, + params, + signature, + ) + } + + #[pallet::weight(SubstrateWeight::::add_public(public_key, signature))] + #[pallet::call_index(1)] + pub fn add_public_key( + origin: OriginFor, + public_key: AddAccumulatorPublicKey, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::add_public_key_, + public_key, + signature, + ) + } + + #[pallet::weight(SubstrateWeight::::remove_params(remove, signature))] + #[pallet::call_index(2)] + pub fn remove_params( + origin: OriginFor, + remove: RemoveAccumulatorParams, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::remove_params_, + remove, + signature, + ) + } + + #[pallet::weight(SubstrateWeight::::remove_public(remove, signature))] + #[pallet::call_index(3)] + pub fn remove_public_key( + origin: OriginFor, + remove: RemoveAccumulatorPublicKey, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::remove_public_key_, + remove, + signature, + ) + } + + /// Add a new accumulator with the initial accumulated value. Each accumulator has a unique + /// id and it refers to a public key. It is assumed that the accumulator is owned by the DID + /// that owns the public key. It logs an event with the accumulator id and accumulated + /// value. For each new accumulator, its creation block is recorded in state to indicate + /// from which block, the chain should be scanned for the accumulator's updates. + /// Note: Weight is same for both kinds of accumulator even when universal takes a bit more + /// space + #[pallet::weight(SubstrateWeight::::add_accumulator(add_accumulator, signature))] + #[pallet::call_index(4)] + pub fn add_accumulator( + origin: OriginFor, + add_accumulator: AddAccumulator, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::add_accumulator_, + add_accumulator, + signature, + ) + } + + /// Update an existing accumulator. The update contains the new accumulated value, the + /// updates themselves and the witness updated info. The updates and witness update info are + /// optional as the owner might be privately communicating the updated witnesses. It logs an + /// event with the accumulator id and the new accumulated value which is sufficient for a + /// verifier. But the prover (who has a witness to update) needs the updates and the witness + /// update info and is expected to look into the corresponding extrinsic arguments. + #[pallet::weight(SubstrateWeight::::update_accumulator(update, signature))] + #[pallet::call_index(5)] + pub fn update_accumulator( + origin: OriginFor, + update: UpdateAccumulator, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::update_accumulator_, + update, + signature, + ) + } + + #[pallet::weight(SubstrateWeight::::remove_accumulator(remove, signature))] + #[pallet::call_index(6)] + pub fn remove_accumulator( + origin: OriginFor, + remove: RemoveAccumulator, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::remove_accumulator_, + remove, + signature, + ) + } + } +} + +impl SubstrateWeight { + fn add_params( + add_params: &AddAccumulatorParams, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::add_params_sr25519, + SigValue::Ed25519(_) => Self::add_params_ed25519, + }( + add_params.params.bytes.len() as u32, + add_params.params.label.as_ref().map_or(0, |v| v.len()) as u32, + )) + } + + fn add_public( + public_key: &AddAccumulatorPublicKey, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::add_public_sr25519, + SigValue::Ed25519(_) => Self::add_public_ed25519, + }(public_key.public_key.bytes.len() as u32)) + } + + fn remove_params( + _: &RemoveAccumulatorParams, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_params_sr25519, + SigValue::Ed25519(_) => Self::remove_params_ed25519, + }()) + } + + fn remove_public( + _: &RemoveAccumulatorPublicKey, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_public_sr25519, + SigValue::Ed25519(_) => Self::remove_public_ed25519, + }()) + } + + fn add_accumulator( + acc: &AddAccumulator, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::add_accumulator_sr25519, + SigValue::Ed25519(_) => Self::add_accumulator_ed25519, + }(acc.accumulator.accumulated().len() as u32)) + } + + fn remove_accumulator( + _: &RemoveAccumulator, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_accumulator_sr25519, + SigValue::Ed25519(_) => Self::remove_accumulator_ed25519, + }()) + } + + fn update_accumulator( + acc: &UpdateAccumulator, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::update_accumulator_sr25519, + SigValue::Ed25519(_) => Self::update_accumulator_ed25519, + })( + acc.new_accumulated.len() as u32, + acc.additions.as_ref().map_or(0, |v| v.len()) as u32, + acc.additions + .iter() + .flatten() + .map(|v| v.len() as u32) + .sum::() + .checked_div_ceil(acc.additions.as_ref().map_or(0, |v| v.len()) as u32) + .unwrap_or(0), + acc.removals.as_ref().map_or(0, |v| v.len()) as u32, + acc.removals + .iter() + .flatten() + .map(|v| v.len() as u32) + .sum::() + .checked_div_ceil(acc.removals.as_ref().map_or(0, |v| v.len()) as u32) + .unwrap_or(0), + acc.witness_update_info.as_ref().map_or(0, |v| v.len()) as u32, + ) + } +} diff --git a/pallets/did/src/modules/accumulator/tests.rs b/pallets/did/src/modules/accumulator/tests.rs new file mode 100644 index 0000000..58fe6a3 --- /dev/null +++ b/pallets/did/src/modules/accumulator/tests.rs @@ -0,0 +1,498 @@ +use super::*; +use crate::tests::common::*; +use frame_support::assert_err; +use frame_system::Origin; +use sp_core::{sr25519, Hasher, H256}; + +fn sign_add_params( + keypair: &sr25519::Pair, + params: &AddAccumulatorParams, + signer: AccumulatorOwner, + key_id: u32, +) -> DidSignature { + did_sig::(params, keypair, signer, key_id) +} + +fn sign_remove_params( + keypair: &sr25519::Pair, + remove: &RemoveAccumulatorParams, + signer: AccumulatorOwner, + key_id: u32, +) -> DidSignature { + did_sig::(remove, keypair, signer, key_id) +} + +fn sign_add_key( + keypair: &sr25519::Pair, + public_key: &AddAccumulatorPublicKey, + signer: AccumulatorOwner, + key_id: u32, +) -> DidSignature { + did_sig::(public_key, keypair, signer, key_id) +} + +fn sign_remove_key( + keypair: &sr25519::Pair, + remove: &RemoveAccumulatorPublicKey, + signer: AccumulatorOwner, + key_id: u32, +) -> DidSignature { + did_sig::(remove, keypair, signer, key_id) +} + +fn sign_add_accum( + keypair: &sr25519::Pair, + accum: &AddAccumulator, + signer: AccumulatorOwner, + key_id: u32, +) -> DidSignature { + did_sig::(accum, keypair, signer, key_id) +} + +fn sign_remove_accum( + keypair: &sr25519::Pair, + remove: &RemoveAccumulator, + signer: AccumulatorOwner, + key_id: u32, +) -> DidSignature { + did_sig::(remove, keypair, signer, key_id) +} + +fn sign_update_accum( + keypair: &sr25519::Pair, + update: &UpdateAccumulator, + signer: AccumulatorOwner, + key_id: u32, +) -> DidSignature { + did_sig::(update, keypair, signer, key_id) +} + +fn accumulator_events() -> Vec<(super::Event, Vec)> { + System::events() + .iter() + .filter_map(|event_record| { + let frame_system::EventRecord:: { phase: _p, event, topics } = + event_record; + match event { + TestEvent::Accum(e) => Some((e.clone(), topics.clone())), + _ => None, + } + }) + .collect() +} + +#[test] +fn accumulator_errors() { + ext().execute_with(|| { + run_to_block(10); + + let (author, author_kp) = newdid(); + let author = AccumulatorOwner(author); + let mut next_nonce = 10 + 1; + check_nonce(&author, next_nonce - 1); + + run_to_block(11); + + let (author_1, author_1_kp) = newdid(); + let author_1 = AccumulatorOwner(author_1); + let next_nonce_1 = 11 + 1; + check_nonce(&author_1, next_nonce_1 - 1); + + run_to_block(30); + + assert!(vec![3; 300] + .try_into() + .map(|accumulated| Accumulator::::Positive(AccumulatorCommon { + accumulated, + key_ref: (author, 1u8.into()), + })) + .is_err()); + + let id = AccumulatorId(rand::random()); + + let accumulator = Accumulator::Positive(AccumulatorCommon { + key_ref: (author, 1u8.into()), + accumulated: vec![3; 100].try_into().unwrap(), + }); + + let add_accum = AddAccumulator { id, accumulator, nonce: next_nonce }; + let sig = sign_add_accum(&author_kp, &add_accum, author, 1); + assert_err!( + AccumMod::add_accumulator(RuntimeOrigin::signed(1), add_accum, sig), + Error::::PublicKeyDoesntExist + ); + check_nonce(&author, next_nonce - 1); + + run_to_block(40); + + let params = AccumulatorParameters { + label: Some(vec![0, 1, 2, 3].try_into().unwrap()), + curve_type: CurveType::Bls12381, + bytes: vec![1; 100].try_into().unwrap(), + }; + let ap = AddAccumulatorParams { params, nonce: next_nonce }; + let sig = sign_add_params::(&author_kp, &ap, author, 1); + AccumMod::add_params(RuntimeOrigin::signed(1), ap, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + run_to_block(50); + + let key = AccumulatorPublicKey { + params_ref: None, + curve_type: CurveType::Bls12381, + bytes: vec![2; 100].try_into().unwrap(), + }; + let ak = AddAccumulatorPublicKey { public_key: key, nonce: next_nonce }; + let sig = sign_add_key::(&author_kp, &ak, author, 1); + AccumMod::add_public_key(RuntimeOrigin::signed(1), ak, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + run_to_block(60); + + let id = AccumulatorId(rand::random()); + let accumulator = Accumulator::Positive(AccumulatorCommon { + accumulated: vec![3; 32].try_into().unwrap(), + key_ref: (author, 1u8.into()), + }); + let add_accum = AddAccumulator { id, accumulator: accumulator.clone(), nonce: next_nonce }; + let sig = sign_add_accum(&author_kp, &add_accum, author, 1); + AccumMod::add_accumulator(RuntimeOrigin::signed(1), add_accum, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + // Cannot add with same id again + let add_accum = AddAccumulator { id, accumulator, nonce: next_nonce }; + let sig = sign_add_accum(&author_kp, &add_accum, author, 1); + assert_err!( + AccumMod::add_accumulator(RuntimeOrigin::signed(1), add_accum, sig), + Error::::AccumulatorAlreadyExists + ); + check_nonce(&author, next_nonce - 1); + + run_to_block(70); + + let mut update_accum = UpdateAccumulator { + id: AccumulatorId(rand::random()), + new_accumulated: vec![4; 32].try_into().unwrap(), + additions: Some(vec![vec![0, 1, 2].into(), vec![3, 5, 4].into()]), + removals: Some(vec![vec![9, 4].into()]), + witness_update_info: Some(vec![1, 1, 2, 3].into()), + nonce: next_nonce, + }; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + assert_err!( + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig), + Error::::AccumulatorDoesntExist + ); + + update_accum.id = id; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + run_to_block(80); + + let mut update_accum = UpdateAccumulator { + id, + new_accumulated: vec![5; 300].try_into().unwrap(), + additions: Some(vec![vec![0, 1, 2].into(), vec![3, 5, 4].into()]), + removals: Some(vec![vec![9, 4].into()]), + witness_update_info: Some(vec![1, 1, 2, 3].into()), + nonce: next_nonce, + }; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + assert_err!( + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig), + Error::::AccumulatedTooBig + ); + check_nonce(&author, next_nonce - 1); + + update_accum.new_accumulated = vec![5; 100].into(); + update_accum.additions = Some(vec![ + vec![89; 2].into(), + vec![45; 6].into(), + vec![55; 8].into(), + vec![56; 4].into(), + vec![57; 5].into(), + vec![10; 5].into(), + vec![5; 8].into(), + vec![35; 2].into(), + vec![11; 4].into(), + vec![15; 4].into(), + vec![25; 5].into(), + ]); + update_accum.removals = None; + update_accum.witness_update_info = Some(vec![11, 12, 21, 23, 35, 50].into()); + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + run_to_block(90); + + update_accum.nonce = next_nonce - 1; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + assert_err!( + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig), + sp_runtime::DispatchError::Other("Incorrect nonce") + ); + check_nonce(&author, next_nonce - 1); + + update_accum.nonce = next_nonce; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + run_to_block(100); + + update_accum.nonce = next_nonce; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + // Only accumulator owner can update it + update_accum.nonce = next_nonce_1; + let sig = sign_update_accum(&author_1_kp, &update_accum, author_1, 1); + assert_err!( + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig), + Error::::NotAccumulatorOwner + ); + check_nonce(&author_1, next_nonce_1 - 1); + update_accum.nonce = next_nonce; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + // Only accumulator owner can remove it + let rem_accum = RemoveAccumulator { id, nonce: next_nonce_1 }; + let sig = sign_remove_accum(&author_1_kp, &rem_accum, author_1, 1); + assert_err!( + AccumMod::remove_accumulator(RuntimeOrigin::signed(1), rem_accum, sig), + Error::::NotAccumulatorOwner + ); + check_nonce(&author_1, next_nonce_1 - 1); + let rem_accum = RemoveAccumulator { id, nonce: next_nonce }; + let sig = sign_remove_accum(&author_kp, &rem_accum, author, 1); + AccumMod::remove_accumulator(RuntimeOrigin::signed(1), rem_accum, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + // Only key owner can remove it + let rem = RemoveAccumulatorPublicKey { key_ref: (author, 1u8.into()), nonce: next_nonce_1 }; + let sig = sign_remove_key(&author_1_kp, &rem, author_1, 1); + assert_err!( + AccumMod::remove_public_key(RuntimeOrigin::signed(1), rem, sig), + Error::::NotAccumulatorOwner + ); + check_nonce(&author_1, next_nonce_1 - 1); + let rem = RemoveAccumulatorPublicKey { key_ref: (author, 1u8.into()), nonce: next_nonce }; + let sig = sign_remove_key(&author_kp, &rem, author, 1); + AccumMod::remove_public_key(RuntimeOrigin::signed(1), rem, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + // Only params owner can remove it + let rem = RemoveAccumulatorParams { params_ref: (author, 1u8.into()), nonce: next_nonce_1 }; + let sig = sign_remove_params(&author_1_kp, &rem, author_1, 1); + assert_err!( + AccumMod::remove_params(RuntimeOrigin::signed(1), rem, sig), + Error::::NotAccumulatorOwner + ); + check_nonce(&author_1, next_nonce_1 - 1); + + let rem = RemoveAccumulatorParams { params_ref: (author, 1u8.into()), nonce: next_nonce }; + let sig = sign_remove_params(&author_kp, &rem, author, 1); + AccumMod::remove_params(RuntimeOrigin::signed(1), rem, sig).unwrap(); + check_nonce(&author, next_nonce); + }); +} + +#[test] +fn add_remove_accumulator() { + ext().execute_with(|| { + run_to_block(10); + + let (author, author_kp) = newdid(); + let author = AccumulatorOwner(author); + let mut next_nonce = 10 + 1; + + run_to_block(20); + + let params = AccumulatorParameters { + label: Some(vec![0, 1, 2, 3].try_into().unwrap()), + curve_type: CurveType::Bls12381, + bytes: vec![1; 100].try_into().unwrap(), + }; + let ap = AddAccumulatorParams { params: params.clone(), nonce: next_nonce }; + let sig = sign_add_params::(&author_kp, &ap, author, 1); + AccumMod::add_params( + RuntimeOrigin::signed(1), + AddAccumulatorParams { params: params.clone(), nonce: next_nonce }, + sig, + ) + .unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!(AccumulatorParams::get(author, IncId::from(1u8)), Some(params)); + assert!( + accumulator_events().contains(&(super::Event::ParamsAdded(author, 1u8.into()), vec![])) + ); + + run_to_block(30); + + let key = AccumulatorPublicKey { + params_ref: None, + curve_type: CurveType::Bls12381, + bytes: vec![2; 100].try_into().unwrap(), + }; + let ak = AddAccumulatorPublicKey { public_key: key.clone(), nonce: next_nonce }; + let sig = sign_add_key::(&author_kp, &ak, author, 1); + AccumMod::add_public_key( + RuntimeOrigin::signed(1), + AddAccumulatorPublicKey { public_key: key.clone(), nonce: next_nonce }, + sig, + ) + .unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!(AccumulatorKeys::get(author, IncId::from(1u8)), Some(key)); + assert!( + accumulator_events().contains(&(super::Event::KeyAdded(author, 1u8.into()), vec![])) + ); + + run_to_block(40); + + let id = AccumulatorId(rand::random()); + let accumulator = Accumulator::Positive(AccumulatorCommon { + accumulated: vec![3; 32].try_into().unwrap(), + key_ref: (author, 1u8.into()), + }); + let add_accum = AddAccumulator { id, accumulator: accumulator.clone(), nonce: next_nonce }; + let sig = sign_add_accum(&author_kp, &add_accum, author, 1); + AccumMod::add_accumulator(RuntimeOrigin::signed(1), add_accum, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!( + Accumulators::::get(id), + Some(AccumulatorWithUpdateInfo::new(accumulator.clone(), 40)) + ); + assert!(accumulator_events().contains(&( + super::Event::AccumulatorAdded(id, accumulator.accumulated().to_vec().into()), + vec![::Hashing::hash(&id[..])] + ))); + + run_to_block(50); + + let mut update_accum = UpdateAccumulator { + id, + new_accumulated: vec![4; 32].try_into().unwrap(), + additions: Some(vec![vec![0, 1, 2].into(), vec![3, 5, 4].into()]), + removals: Some(vec![vec![9, 4].into()]), + witness_update_info: Some(vec![1, 2, 3, 4].into()), + nonce: next_nonce + 1, + }; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + assert_err!( + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig), + sp_runtime::DispatchError::Other("Incorrect nonce") + ); + check_nonce(&author, next_nonce - 1); + + update_accum.nonce = next_nonce - 1; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + assert_err!( + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum.clone(), sig), + sp_runtime::DispatchError::Other("Incorrect nonce") + ); + check_nonce(&author, next_nonce - 1); + + update_accum.nonce = next_nonce; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + let accumulator = Accumulator::Positive(AccumulatorCommon { + accumulated: vec![4; 32].try_into().unwrap(), + key_ref: (author, 1u8.into()), + }); + assert_eq!( + Accumulators::::get(id), + Some(AccumulatorWithUpdateInfo { + created_at: 40, + last_updated_at: 50, + accumulator: accumulator.clone() + }) + ); + assert!(accumulator_events().contains(&( + super::Event::AccumulatorUpdated(id, accumulator.accumulated().to_vec().into()), + vec![::Hashing::hash(&id[..])] + ))); + + run_to_block(60); + + let update_accum = UpdateAccumulator { + id, + new_accumulated: vec![5; 32].try_into().unwrap(), + additions: Some(vec![vec![0, 1, 2].into(), vec![3, 5, 4].into()]), + removals: None, + witness_update_info: Some(vec![1, 1, 0, 11, 8, 19].into()), + nonce: next_nonce, + }; + let sig = sign_update_accum(&author_kp, &update_accum, author, 1); + AccumMod::update_accumulator(RuntimeOrigin::signed(1), update_accum, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + let accumulator = Accumulator::Positive(AccumulatorCommon { + accumulated: vec![5; 32].try_into().unwrap(), + key_ref: (author, 1u8.into()), + }); + assert_eq!( + Accumulators::::get(id), + Some(AccumulatorWithUpdateInfo { + created_at: 40, + last_updated_at: 60, + accumulator: accumulator.clone() + }) + ); + assert!(accumulator_events().contains(&( + super::Event::AccumulatorUpdated(id, accumulator.accumulated().to_vec().into()), + vec![::Hashing::hash(&id[..])] + ))); + + run_to_block(70); + + let mut rem_accum = RemoveAccumulator { id, nonce: next_nonce - 1 }; + let sig = sign_remove_accum(&author_kp, &rem_accum, author, 1); + assert_err!( + AccumMod::remove_accumulator(RuntimeOrigin::signed(1), rem_accum.clone(), sig), + sp_runtime::DispatchError::Other("Incorrect nonce") + ); + check_nonce(&author, next_nonce - 1); + + rem_accum.nonce = next_nonce + 1; + let sig = sign_remove_accum(&author_kp, &rem_accum, author, 1); + assert_err!( + AccumMod::remove_accumulator(RuntimeOrigin::signed(1), rem_accum.clone(), sig), + sp_runtime::DispatchError::Other("Incorrect nonce") + ); + check_nonce(&author, next_nonce - 1); + + rem_accum.nonce = next_nonce; + let sig = sign_remove_accum(&author_kp, &rem_accum, author, 1); + AccumMod::remove_accumulator(RuntimeOrigin::signed(1), rem_accum, sig).unwrap(); + check_nonce(&author, next_nonce); + assert_eq!(Accumulators::::get(id), None); + assert!(accumulator_events().contains(&( + super::Event::AccumulatorRemoved(id), + vec![::Hashing::hash(&id[..])] + ))); + }); +} diff --git a/pallets/did/src/modules/accumulator/types.rs b/pallets/did/src/modules/accumulator/types.rs new file mode 100644 index 0000000..ea9aead --- /dev/null +++ b/pallets/did/src/modules/accumulator/types.rs @@ -0,0 +1,201 @@ +use frame_support::{CloneNoBound, DebugNoBound, EqNoBound, PartialEqNoBound}; + +use super::*; +use crate::{ + common::{Limits, TypesAndLimits}, + util::BoundedBytes, +}; + +pub type AccumParametersStorageKey = (AccumulatorOwner, IncId); +pub type AccumPublicKeyStorageKey = (AccumulatorOwner, IncId); +pub type AccumPublicKeyWithParams = (AccumulatorPublicKey, Option>); + +/// Accumulator identifier. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct AccumulatorId( + #[cfg_attr(feature = "serde", serde(with = "crate::util::hex"))] pub [u8; 32], +); + +crate::impl_wrapper!(AccumulatorId([u8; 32]), with tests as acc_tests); + +/// Accumulator owner - DID with the ability to control given accumulator keys, params, etc. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct AccumulatorOwner(pub Did); + +crate::impl_wrapper!(AccumulatorOwner(Did), for rand use Did(rand::random()), with tests as acc_owner_tests); + +#[derive( + scale_info_derive::TypeInfo, + Encode, + Decode, + CloneNoBound, + PartialEqNoBound, + EqNoBound, + DebugNoBound, + MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AccumulatorParameters { + /// The label (generating string) used to generate the params + pub label: Option>, + pub curve_type: CurveType, + pub bytes: BoundedBytes, +} + +#[derive( + scale_info_derive::TypeInfo, + Encode, + Decode, + CloneNoBound, + PartialEqNoBound, + EqNoBound, + DebugNoBound, + MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AccumulatorPublicKey { + pub curve_type: CurveType, + pub bytes: BoundedBytes, + /// The params used to generate the public key (`P_tilde` comes from params) + pub params_ref: Option, +} + +#[derive( + Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub enum Accumulator { + Positive(AccumulatorCommon), + Universal(UniversalAccumulator), +} + +#[derive( + Encode, + Decode, + scale_info_derive::TypeInfo, + CloneNoBound, + PartialEqNoBound, + EqNoBound, + DebugNoBound, + MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AccumulatorCommon { + pub accumulated: BoundedBytes, + pub key_ref: AccumPublicKeyStorageKey, +} + +#[derive( + Encode, + Decode, + scale_info_derive::TypeInfo, + CloneNoBound, + PartialEqNoBound, + EqNoBound, + DebugNoBound, + MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct UniversalAccumulator { + pub common: AccumulatorCommon, + /// This is not enforced on chain and serves as metadata only + pub max_size: u64, +} + +impl Accumulator { + /// Get reference to the public key of the accumulator + pub fn key_ref(&self) -> AccumPublicKeyStorageKey { + match self { + Accumulator::Positive(a) => a.key_ref, + Accumulator::Universal(a) => a.common.key_ref, + } + } + + /// DID of the owner of the accumulator + pub fn owner_did(&self) -> &AccumulatorOwner { + match self { + Accumulator::Positive(a) => &a.key_ref.0, + Accumulator::Universal(a) => &a.common.key_ref.0, + } + } + + pub fn accumulated(&self) -> &[u8] { + match self { + Accumulator::Positive(a) => &a.accumulated, + Accumulator::Universal(a) => &a.common.accumulated, + } + } + + pub fn set_new_accumulated(&mut self, new_accumulated: A) -> Result<&mut Self, A::Error> + where + A: TryInto>, + { + match self { + Accumulator::Positive(a) => a.accumulated = new_accumulated.try_into()?, + Accumulator::Universal(a) => a.common.accumulated = new_accumulated.try_into()?, + } + + Ok(self) + } +} + +#[derive( + scale_info_derive::TypeInfo, Encode, Decode, Clone, PartialEq, Eq, Debug, Default, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(omit_prefix)] +pub struct StoredAccumulatorOwnerCounters { + pub params_counter: IncId, + pub key_counter: IncId, +} + +#[derive( + scale_info_derive::TypeInfo, Encode, Decode, Clone, PartialEq, Eq, Debug, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AccumulatorWithUpdateInfo +where + T: TypesAndLimits, +{ + pub created_at: T::BlockNumber, + pub last_updated_at: T::BlockNumber, + pub accumulator: Accumulator, +} + +impl AccumulatorWithUpdateInfo { + pub fn new(accumulator: Accumulator, created_at: T::BlockNumber) -> Self { + Self { accumulator, created_at, last_updated_at: created_at } + } +} diff --git a/pallets/did/src/modules/accumulator/weights.rs b/pallets/did/src/modules/accumulator/weights.rs new file mode 100644 index 0000000..0f76f98 --- /dev/null +++ b/pallets/did/src/modules/accumulator/weights.rs @@ -0,0 +1,371 @@ +//! Autogenerated weights for accumulator +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2022-08-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Native), WASM-EXECUTION: Interpreted, CHAIN: Some("mainnet"), DB CACHE: 128 + +// Executed Command: +// ./target/production/dock-node +// benchmark +// --execution=native +// --chain=mainnet +// --pallet=accumulator +// --extra +// --extrinsic=* +// --repeat=20 +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/accumulator/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for accumulator. +pub trait WeightInfo { + fn add_params_sr25519(b: u32, l: u32) -> Weight; + fn add_params_ed25519(b: u32, l: u32) -> Weight; + fn add_params_secp256k1(b: u32, l: u32) -> Weight; + fn remove_params_sr25519() -> Weight; + fn remove_params_ed25519() -> Weight; + fn remove_params_secp256k1() -> Weight; + fn add_public_sr25519(b: u32) -> Weight; + fn add_public_ed25519(b: u32) -> Weight; + fn add_public_secp256k1(b: u32) -> Weight; + fn remove_public_sr25519() -> Weight; + fn remove_public_ed25519() -> Weight; + fn remove_public_secp256k1() -> Weight; + fn add_accumulator_sr25519(b: u32) -> Weight; + fn add_accumulator_ed25519(b: u32) -> Weight; + fn add_accumulator_secp256k1(b: u32) -> Weight; + fn update_accumulator_sr25519(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) -> Weight; + fn update_accumulator_ed25519(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) -> Weight; + fn update_accumulator_secp256k1(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) -> Weight; + fn remove_accumulator_sr25519() -> Weight; + fn remove_accumulator_ed25519() -> Weight; + fn remove_accumulator_secp256k1() -> Weight; +} + +/// Weights for accumulator using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn add_params_sr25519(b: u32, l: u32) -> Weight { + Weight::from_parts(54_891_000_u64, 0) + // Standard Error: 0 + .saturating_add(Weight::from_all(8_000_u64).saturating_mul(b as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(8_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_params_ed25519(b: u32, _l: u32) -> Weight { + Weight::from_parts(55_802_000_u64, 0) + // Standard Error: 0 + .saturating_add(Weight::from_all(4_000_u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_params_secp256k1(b: u32, l: u32) -> Weight { + Weight::from_all(159_890_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(4_000_u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_params_sr25519() -> Weight { + Weight::from_all(58_306_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_params_ed25519() -> Weight { + Weight::from_all(55_655_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_params_secp256k1() -> Weight { + Weight::from_all(162_917_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn add_public_sr25519(b: u32) -> Weight { + Weight::from_all(61_674_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(5_000_u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_public_ed25519(b: u32) -> Weight { + Weight::from_all(60_164_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(4_000_u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_public_secp256k1(_b: u32) -> Weight { + Weight::from_all(167_138_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_public_sr25519() -> Weight { + Weight::from_all(56_413_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_public_ed25519() -> Weight { + Weight::from_all(55_915_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_public_secp256k1() -> Weight { + Weight::from_all(164_392_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn add_accumulator_sr25519(b: u32) -> Weight { + Weight::from_all(63_558_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(9_000_u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_accumulator_ed25519(b: u32) -> Weight { + Weight::from_all(61_650_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_accumulator_secp256k1(_b: u32) -> Weight { + Weight::from_all(167_711_000_u64) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn update_accumulator_sr25519(a: u32, b: u32, c: u32, d: u32, e: u32, _f: u32) -> Weight { + Weight::from_all(46_170_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(7_000_u64).saturating_mul(a as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(326_000_u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(85_000_u64).saturating_mul(c as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(291_000_u64).saturating_mul(d as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(84_000_u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn update_accumulator_ed25519(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) -> Weight { + Weight::from_all(37_112_000_u64) + // Standard Error: 3_000 + .saturating_add(Weight::from_all(13_000_u64).saturating_mul(a as u64)) + // Standard Error: 19_000 + .saturating_add(Weight::from_all(247_000_u64).saturating_mul(b as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(90_000_u64).saturating_mul(c as u64)) + // Standard Error: 19_000 + .saturating_add(Weight::from_all(326_000_u64).saturating_mul(d as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(98_000_u64).saturating_mul(e as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(30_000_u64).saturating_mul(f as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn update_accumulator_secp256k1(a: u32, b: u32, c: u32, d: u32, e: u32, _f: u32) -> Weight { + Weight::from_all(161_276_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(a as u64)) + // Standard Error: 7_000 + .saturating_add(Weight::from_all(110_000_u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(22_000_u64).saturating_mul(c as u64)) + // Standard Error: 7_000 + .saturating_add(Weight::from_all(93_000_u64).saturating_mul(d as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(18_000_u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_accumulator_sr25519() -> Weight { + Weight::from_all(60_493_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_accumulator_ed25519() -> Weight { + Weight::from_all(57_062_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_accumulator_secp256k1() -> Weight { + Weight::from_all(167_644_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn add_params_sr25519(b: u32, l: u32) -> Weight { + Weight::from_all(54_891_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(8_000_u64).saturating_mul(b as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(8_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_params_ed25519(b: u32, _l: u32) -> Weight { + Weight::from_all(55_802_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(4_000_u64).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_params_secp256k1(b: u32, l: u32) -> Weight { + Weight::from_all(159_890_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(4_000_u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_params_sr25519() -> Weight { + Weight::from_all(58_306_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_params_ed25519() -> Weight { + Weight::from_all(55_655_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_params_secp256k1() -> Weight { + Weight::from_all(162_917_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn add_public_sr25519(b: u32) -> Weight { + Weight::from_all(61_674_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(5_000_u64).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_public_ed25519(b: u32) -> Weight { + Weight::from_all(60_164_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(4_000_u64).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_public_secp256k1(_b: u32) -> Weight { + Weight::from_all(167_138_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_public_sr25519() -> Weight { + Weight::from_all(56_413_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_public_ed25519() -> Weight { + Weight::from_all(55_915_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_public_secp256k1() -> Weight { + Weight::from_all(164_392_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn add_accumulator_sr25519(b: u32) -> Weight { + Weight::from_all(63_558_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(9_000_u64).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_accumulator_ed25519(b: u32) -> Weight { + Weight::from_all(61_650_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_accumulator_secp256k1(_b: u32) -> Weight { + Weight::from_all(167_711_000_u64) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn update_accumulator_sr25519(a: u32, b: u32, c: u32, d: u32, e: u32, _f: u32) -> Weight { + Weight::from_all(46_170_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(7_000_u64).saturating_mul(a as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(326_000_u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(85_000_u64).saturating_mul(c as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(291_000_u64).saturating_mul(d as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(84_000_u64).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn update_accumulator_ed25519(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) -> Weight { + Weight::from_all(37_112_000_u64) + // Standard Error: 3_000 + .saturating_add(Weight::from_all(13_000_u64).saturating_mul(a as u64)) + // Standard Error: 19_000 + .saturating_add(Weight::from_all(247_000_u64).saturating_mul(b as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(90_000_u64).saturating_mul(c as u64)) + // Standard Error: 19_000 + .saturating_add(Weight::from_all(326_000_u64).saturating_mul(d as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(98_000_u64).saturating_mul(e as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(30_000_u64).saturating_mul(f as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn update_accumulator_secp256k1(a: u32, b: u32, c: u32, d: u32, e: u32, _f: u32) -> Weight { + Weight::from_all(161_276_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(a as u64)) + // Standard Error: 7_000 + .saturating_add(Weight::from_all(110_000_u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(22_000_u64).saturating_mul(c as u64)) + // Standard Error: 7_000 + .saturating_add(Weight::from_all(93_000_u64).saturating_mul(d as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(18_000_u64).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_accumulator_sr25519() -> Weight { + Weight::from_all(60_493_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_accumulator_ed25519() -> Weight { + Weight::from_all(57_062_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_accumulator_secp256k1() -> Weight { + Weight::from_all(167_644_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } +} diff --git a/pallets/did/src/modules/anchor/benchmarks.rs b/pallets/did/src/modules/anchor/benchmarks.rs new file mode 100644 index 0000000..20bc2c0 --- /dev/null +++ b/pallets/did/src/modules/anchor/benchmarks.rs @@ -0,0 +1,24 @@ +use super::*; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +use sp_runtime::traits::Hash; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MAX_LEN: u32 = 10_000; + +benchmarks! { + where_clause { where T: sp_std::fmt::Debug } + + deploy { + let l in 0 .. MAX_LEN => (); + + let caller = whitelisted_caller(); + let data = vec![0; l as usize]; + + }: deploy(RawOrigin::Signed(caller), data.clone()) + verify { + let hash = <::Hashing as Hash>::hash(&data); + assert_eq!(Anchors::::get(&hash).unwrap(), >::block_number()); + } +} diff --git a/pallets/did/src/modules/anchor/mod.rs b/pallets/did/src/modules/anchor/mod.rs new file mode 100644 index 0000000..4586779 --- /dev/null +++ b/pallets/did/src/modules/anchor/mod.rs @@ -0,0 +1,77 @@ +//! Minimal proof of existence registry. +//! +//! Anchors are hashed once before being added to storage. To check whether an anchor exists +//! query the "Anchors" map for the hash of the anchor. If a corresponding value exists, then the +//! anchor exists and the value represents the block number when it was first published. + +use alloc::vec::Vec; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +#[cfg(test)] +mod tests; +mod weights; +use weights::*; + +pub use pallet::*; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + use sp_core::Hasher; + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + + IsType<::RuntimeEvent> + + Into<::RuntimeEvent>; + } + + #[pallet::error] + pub enum Error { + /// The anchor being posted was already created in a previous block. + AnchorExists, + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + /// A new permanent anchor was posted. + AnchorDeployed(T::Hash, T::AccountId), + } + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::storage] + pub type Anchors = StorageMap<_, Identity, T::Hash, BlockNumberFor>; + + #[pallet::call] + impl Pallet { + /// Drop a permanent anchor. + #[pallet::weight(SubstrateWeight::::deploy(data.len() as u32))] + #[pallet::call_index(0)] + pub fn deploy(origin: OriginFor, data: Vec) -> DispatchResult { + let account = ensure_signed(origin)?; + + Pallet::::deploy_(data, account) + } + } + + impl Pallet { + fn deploy_(data: Vec, account: T::AccountId) -> DispatchResult { + // check + let hash = ::Hashing::hash(&data); + ensure!(Anchors::::get(hash).is_none(), Error::::AnchorExists); + + // execute + let last_block = >::block_number(); + Anchors::::insert(hash, last_block); + Self::deposit_event(Event::::AnchorDeployed(hash, account)); + + Ok(()) + } + } +} diff --git a/pallets/did/src/modules/anchor/tests.rs b/pallets/did/src/modules/anchor/tests.rs new file mode 100644 index 0000000..a47a77b --- /dev/null +++ b/pallets/did/src/modules/anchor/tests.rs @@ -0,0 +1,52 @@ +use super::{Anchors, Error, Event}; +use crate::tests::common::*; +use frame_system::Origin; +use sp_core::H256; +use sp_runtime::traits::Hash; + +#[test] +fn deploy_and_check() { + ext().execute_with(|| { + let bs = random_bytes(32); + let h = ::Hashing::hash(&bs); + assert!(Anchors::::get(h).is_none()); + AnchorMod::deploy(RuntimeOrigin::signed(ABBA), bs).unwrap(); + assert!(Anchors::::get(h).is_some()); + }); +} + +#[test] +fn deploy_twice_error() { + ext().execute_with(|| { + let bs = random_bytes(32); + AnchorMod::deploy(RuntimeOrigin::signed(ABBA), bs.clone()).unwrap(); + let err = AnchorMod::deploy(RuntimeOrigin::signed(ABBA), bs).unwrap_err(); + assert_eq!(err, Error::::AnchorExists.into()); + }); +} + +#[test] +fn deploy_and_observe_event() { + ext().execute_with(|| { + let bs = random_bytes(32); + let h = ::Hashing::hash(&bs); + AnchorMod::deploy(RuntimeOrigin::signed(ABBA), bs).unwrap(); + assert_eq!(&anchor_events(), &[Event::::AnchorDeployed(h, ABBA)]); + }); +} + +fn anchor_events() -> Vec> { + System::events() + .iter() + .filter_map(|event_record| { + let frame_system::EventRecord:: { phase, event, topics } = + event_record; + assert_eq!(phase, &frame_system::Phase::Initialization); + assert_eq!(topics, &vec![]); + match event { + TestEvent::Anchor(e) => Some(e.clone()), + _ => None, + } + }) + .collect() +} diff --git a/pallets/did/src/modules/anchor/weights.rs b/pallets/did/src/modules/anchor/weights.rs new file mode 100644 index 0000000..c4b2157 --- /dev/null +++ b/pallets/did/src/modules/anchor/weights.rs @@ -0,0 +1,55 @@ +//! Autogenerated weights for anchor +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2022-08-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Native), WASM-EXECUTION: Interpreted, CHAIN: Some("mainnet"), DB CACHE: 128 + +// Executed Command: +// ./target/production/dock-node +// benchmark +// --execution=native +// --chain=mainnet +// --pallet=anchor +// --extra +// --extrinsic=* +// --repeat=20 +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/anchor/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for anchor. +pub trait WeightInfo { + fn deploy(l: u32) -> Weight; +} + +/// Weights for anchor using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn deploy(l: u32) -> Weight { + Weight::from_all(5_881_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn deploy(l: u32) -> Weight { + Weight::from_all(5_881_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/pallets/did/src/modules/attest/benchmarks.rs b/pallets/did/src/modules/attest/benchmarks.rs new file mode 100644 index 0000000..ded1077 --- /dev/null +++ b/pallets/did/src/modules/attest/benchmarks.rs @@ -0,0 +1,47 @@ +use super::*; +use crate::{ + common::state_change::ToStateChange, + did::{Did, DidSignature, UncheckedDidKey}, +}; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MAX_LEN: u32 = 10_000; + +crate::bench_with_all_pairs! { + with_pairs: + set_claim_sr25519 for sr25519, set_claim_ed25519 for ed25519, set_claim_secp256k1 for secp256k1 { + { + let l in 0 .. MAX_LEN => (); + } + let pair as Pair; + let caller = whitelisted_caller(); + let data = vec![0; l as usize]; + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + let attest = Attestation { + priority: 1, + iri: Some(vec![12; l as usize].try_into().unwrap()) + }; + + let set_attest = SetAttestationClaim { + attest, + nonce: 1u8.into() + }; + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let sig = pair.sign(&set_attest.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: set_claim(RawOrigin::Signed(caller), set_attest.clone(), signature) + verify { + assert_eq!(Attestations::get(Attester(did)), set_attest.attest); + } +} diff --git a/pallets/did/src/modules/attest/mod.rs b/pallets/did/src/modules/attest/mod.rs new file mode 100644 index 0000000..9def320 --- /dev/null +++ b/pallets/did/src/modules/attest/mod.rs @@ -0,0 +1,171 @@ +//! This module allows DIDs to publically attests to arbirary (and arbitrarily large) RDF +//! claimgraphs. These attestations are not stored on-chain; rather, the attester chooses a storage +//! method by specifying an Iri. + +use crate::{ + common::{Limits, SigValue, TypesAndLimits}, + did::{self, Did, DidSignature}, + util::BoundedBytes, +}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{ + dispatch::DispatchResult, ensure, weights::Weight, CloneNoBound, DebugNoBound, DefaultNoBound, + EqNoBound, PartialEqNoBound, +}; +use frame_system::ensure_signed; +use sp_std::{fmt::Debug, prelude::*}; +use weights::*; + +pub use pallet::*; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +#[cfg(test)] +mod tests; +mod weights; + +pub type Iri = BoundedBytes<::MaxIriSize>; + +/// Attester is a DID giving an attestation to arbitrary (and arbitrarily large) RDF claimgraphs. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct Attester(pub Did); + +crate::impl_wrapper!(Attester(Did), for rand use Did(rand::random()), with tests as attester_tests); + +#[derive( + Encode, + Decode, + CloneNoBound, + PartialEqNoBound, + DebugNoBound, + DefaultNoBound, + EqNoBound, + MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct Attestation { + #[codec(compact)] + pub priority: u64, + pub iri: Option>, +} + +#[derive( + Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound, Default, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct SetAttestationClaim { + pub attest: Attestation, + pub nonce: T::BlockNumber, +} + +crate::impl_action_with_nonce! { for (): SetAttestationClaim with 1 as len, () as target } + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config + did::Config {} + + #[pallet::error] + /// Error for the attest module. + pub enum Error { + /// The Attestation was not posted because its priority was less than or equal to that of + /// an attestation previously posted by the same entity. + /// + /// Note, the default value for an attestation is the null claim (claiming nothing), with + /// a priority of 0. To override this initial value, a priority of 1 or greater is + /// required. Check to see that the provided priority is not zero as that could be the + /// cause of this error. + PriorityTooLow, + } + + /// The priority value provides replay protection and also gives attestations a partial + /// ordering. Signatures with lesser or equal priority to those previously posted by the same + /// entity are not accepted by the chain. + /// + /// Notice that priority is not a block-number. This is intentional as it yields some desired + /// properties and allows some potential use-cases: + /// - When publishing consecutive attestations, the attester need not care at which block a a + /// previous attestation was included. This means attestations can be made over a + /// mono-directional channel. + /// - Timestamps may be used as priority when available. + /// - A timeline of future attestations may be constructed by encrypting multiple signatures, + /// each with the output of a verifiable delay function. A "final" attestation may be + /// selected by assigning it the highest priority in the batch. The "final" attestation will + /// be acceptable by the runtime regardless of whether its predecessors were submitted. + /// + /// An attestation on chain with iri set to None is semantically meaningless. Setting the + /// iri to None is equivalent to attesting to the empty claimgraph. + /// + /// When Attestations::get(did).iri == Some(dat) and dat is a valid utf-8 Iri: + /// `[did dock:attestsDocumentContents dat]`. + #[pallet::storage] + #[pallet::getter(fn attestation)] + pub type Attestations = + StorageMap<_, Blake2_128Concat, Attester, Attestation, ValueQuery>; + + #[pallet::call] + impl Pallet { + #[pallet::weight(SubstrateWeight::::set_claim(attests, signature))] + #[pallet::call_index(0)] + pub fn set_claim( + origin: OriginFor, + attests: SetAttestationClaim, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::set_claim_, + attests, + signature, + ) + } + } + + impl Pallet { + fn set_claim_( + SetAttestationClaim { attest, .. }: SetAttestationClaim, + attester: Attester, + ) -> DispatchResult { + let prev = Attestations::::get(attester); + ensure!(prev.priority < attest.priority, Error::::PriorityTooLow); + + // execute + Attestations::insert(attester, &attest); + + Ok(()) + } + } +} + +impl SubstrateWeight { + fn set_claim( + SetAttestationClaim { attest, .. }: &SetAttestationClaim, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::set_claim_sr25519, + SigValue::Ed25519(_) => Self::set_claim_ed25519, + }(attest.iri.as_ref().map_or(0, |v| v.len()) as u32)) + } +} diff --git a/pallets/did/src/modules/attest/tests.rs b/pallets/did/src/modules/attest/tests.rs new file mode 100644 index 0000000..3fd21ab --- /dev/null +++ b/pallets/did/src/modules/attest/tests.rs @@ -0,0 +1,242 @@ +use super::*; +use crate::tests::common::*; +use frame_system::Origin; +use sp_core::sr25519; + +type Er = crate::attest::Error; + +/// Trigger the PriorityTooLow error by submitting a priority 0 attestation. +#[test] +fn priority_too_low() { + ext().execute_with(|| { + run_to_block(10); + + let (did, kp) = newdid(); + let did = Attester(did); + let att = Attestation { priority: 0, iri: None }; + let err = AttestMod::set_claim( + RuntimeOrigin::signed(0), + SetAttestationClaim { attest: att.clone(), nonce: 10 + 1 }, + did_sig::(&SetAttestationClaim { attest: att, nonce: 10 + 1 }, &kp, did, 1), + ) + .unwrap_err(); + assert_eq!(err, Er::PriorityTooLow.into()); + }); +} + +/// assert sizes of encoded Attestation +#[test] +fn encoded_attestation_size() { + ext().execute_with(|| { + for (priority, iri, expected_size) in [ + (0, None, 1 + 1), + (63, None, 1 + 1), + (64, None, 2 + 1), + (256, None, 2 + 1), + (0, Some(vec![].try_into().unwrap()), 1 + 2), + (0, Some(vec![0].try_into().unwrap()), 1 + 3), + (0, Some(vec![0; 63].try_into().unwrap()), 1 + 63 + 2), + (0, Some(vec![0; 64].try_into().unwrap()), 1 + 64 + 3), + (0, Some(vec![0; 256].try_into().unwrap()), 1 + 256 + 3), + (63, Some(vec![0; 256].try_into().unwrap()), 1 + 256 + 3), + (64, Some(vec![0; 256].try_into().unwrap()), 2 + 256 + 3), + ] + .iter() + .cloned() + { + assert_eq!(Attestation:: { priority, iri }.encode().len(), expected_size); + } + }); +} + +/// Trigger the InvalidSignature error by tweaking a value in the plaintext after signing +#[test] +fn invalid_sig_a() { + ext().execute_with(|| { + run_to_block(10); + + let (dida, kpa) = newdid(); + let mut att = Attestation { priority: 1, iri: None }; + let sig = did_sig::( + &SetAttestationClaim { attest: att.clone(), nonce: 10 + 1 }, + &kpa, + Attester(dida), + 1, + ); + // Modify payload so sig doesn't match + att.priority += 1; + let err = AttestMod::set_claim( + RuntimeOrigin::signed(0), + SetAttestationClaim { attest: att, nonce: 10 + 2 }, + sig, + ) + .unwrap_err(); + assert_eq!(err, did::Error::::InvalidSignature.into()); + }); +} + +/// Trigger the InvalidSignature error using a different did for signing +#[test] +fn invalid_sig_b() { + ext().execute_with(|| { + run_to_block(10); + + let (dida, _kpa) = newdid(); + let (_didb, kpb) = newdid(); + let att = Attestation { priority: 1, iri: None }; + let err = AttestMod::set_claim( + RuntimeOrigin::signed(0), + SetAttestationClaim { attest: att.clone(), nonce: 10 + 1 }, + did_sig::( + &SetAttestationClaim { attest: att, nonce: 10 + 1 }, + &kpb, + Attester(dida), + 1, + ), + ) + .unwrap_err(); + assert_eq!(err, did::Error::::InvalidSignature.into()); + }); +} + +/// Attestations with equal priority are mutually exlusive +#[test] +fn priority_face_off() { + ext().execute_with(|| { + run_to_block(10); + + let (did, kp) = newdid(); + let did = Attester(did); + check_nonce(&did, 10); + + // same iri + set_claim(&did, &Attestation { priority: 1, iri: None }, &kp, 10 + 1).unwrap(); + check_nonce(&did, 10 + 1); + assert_eq!( + set_claim(&did, &Attestation { priority: 1, iri: None }, &kp, 11 + 1).unwrap_err(), + Er::PriorityTooLow.into() + ); + + // different iris + set_claim( + &did, + &Attestation { priority: 2, iri: Some(vec![0].try_into().unwrap()) }, + &kp, + 11 + 1, + ) + .unwrap(); + check_nonce(&did, 11 + 1); + + assert_eq!( + set_claim( + &did, + &Attestation { priority: 2, iri: Some(vec![0, 2, 3].try_into().unwrap()) }, + &kp, + 12 + 1 + ) + .unwrap_err(), + Er::PriorityTooLow.into() + ); + }); +} + +/// After attempting a set of attestations the one with highest priority is the one that ends up +/// in chain state. +#[test] +fn priority_battle_royale() { + ext().execute_with(|| { + run_to_block(10); + + let (did, kp) = newdid(); + let did = Attester(did); + let prios: Vec = (0..200).map(|_| rand::random::()).collect(); + let mut nonce = 10 + 1; + for priority in &prios { + check_nonce(&did, nonce - 1); + + let _ = set_claim(&did, &Attestation { priority: *priority, iri: None }, &kp, nonce) + .map(|_| { + check_nonce(&did, nonce); + nonce += 1; + }); + } + assert_eq!(Attestations::::get(did).priority, prios.iter().max().unwrap().clone()); + }); +} + +/// An attestation with priority set to the highest value is final. +/// It does not trigger a panic by integer overflow. +#[test] +fn max_priority_is_final() { + ext().execute_with(|| { + run_to_block(10); + + let (did, kp) = newdid(); + let did = Attester(did); + check_nonce(&did, 10); + + set_claim(&did, &Attestation { priority: u64::max_value(), iri: None }, &kp, 10 + 1) + .unwrap(); + check_nonce(&did, 10 + 1); + let err = + set_claim(&did, &Attestation { priority: u64::max_value(), iri: None }, &kp, 11 + 1) + .unwrap_err(); + assert_eq!(err, Er::PriorityTooLow.into()); + }); +} + +/// Set an attestation that is not None +#[test] +fn set_some_attestation() { + ext().execute_with(|| { + run_to_block(10); + + let (did, kp) = newdid(); + let did = Attester(did); + assert_eq!(Attestations::::get(did), Attestation { priority: 0, iri: None }); + check_nonce(&did, 10); + set_claim( + &did, + &Attestation { priority: 1, iri: Some(vec![0, 1, 2].try_into().unwrap()) }, + &kp, + 10 + 1, + ) + .unwrap(); + check_nonce(&did, 10 + 1); + assert_eq!( + Attestations::::get(did), + Attestation { priority: 1, iri: Some(vec![0, 1, 2].try_into().unwrap()) } + ); + }); +} + +/// Skip a priority value. +#[test] +fn skip_prio() { + ext().execute_with(|| { + run_to_block(10); + + let (did, kp) = newdid(); + let did = Attester(did); + for (i, priority) in [1, 2, 4].iter().enumerate() { + let nonce = 10 + 1 + i as u64; + check_nonce(&did, nonce - 1); + set_claim(&did, &Attestation { priority: *priority, iri: None }, &kp, nonce).unwrap(); + check_nonce(&did, nonce); + } + }); +} + +/// helper +fn set_claim( + claimer: &Attester, + att: &Attestation, + kp: &sr25519::Pair, + nonce: u64, +) -> DispatchResult { + AttestMod::set_claim( + RuntimeOrigin::signed(0), + SetAttestationClaim { attest: att.clone(), nonce }, + did_sig::(&SetAttestationClaim { attest: att.clone(), nonce }, kp, *claimer, 1), + ) +} diff --git a/pallets/did/src/modules/attest/weights.rs b/pallets/did/src/modules/attest/weights.rs new file mode 100644 index 0000000..1299879 --- /dev/null +++ b/pallets/did/src/modules/attest/weights.rs @@ -0,0 +1,85 @@ +//! Autogenerated weights for attest +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2022-08-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Native), WASM-EXECUTION: Interpreted, CHAIN: Some("mainnet"), DB CACHE: 128 + +// Executed Command: +// ./target/production/dock-node +// benchmark +// --execution=native +// --chain=mainnet +// --pallet=attest +// --extra +// --extrinsic=* +// --repeat=20 +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/attest/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for attest. +pub trait WeightInfo { + fn set_claim_sr25519(l: u32) -> Weight; + fn set_claim_ed25519(l: u32) -> Weight; + fn set_claim_secp256k1(l: u32) -> Weight; +} + +/// Weights for attest using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn set_claim_sr25519(l: u32) -> Weight { + Weight::from_all(49_216_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn set_claim_ed25519(l: u32) -> Weight { + Weight::from_all(49_142_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn set_claim_secp256k1(l: u32) -> Weight { + Weight::from_all(152_813_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn set_claim_sr25519(l: u32) -> Weight { + Weight::from_all(49_216_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn set_claim_ed25519(l: u32) -> Weight { + Weight::from_all(49_142_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn set_claim_secp256k1(l: u32) -> Weight { + Weight::from_all(152_813_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } +} diff --git a/pallets/did/src/modules/blob/benchmarks.rs b/pallets/did/src/modules/blob/benchmarks.rs new file mode 100644 index 0000000..9e4ba0f --- /dev/null +++ b/pallets/did/src/modules/blob/benchmarks.rs @@ -0,0 +1,41 @@ +use super::*; +use crate::{common::state_change::ToStateChange, did::UncheckedDidKey}; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +use sp_runtime::traits::TryCollect; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MAX_BLOB: u32 = 100; + +crate::bench_with_all_pairs! { + with_pairs: + new_sr25519 for sr25519, new_ed25519 for ed25519, new_secp256k1 for secp256k1 { + { + let s in 0 .. MAX_BLOB; + } + let pair as Pair; + let caller = whitelisted_caller(); + let n = 0; + let public = pair.public(); + let did = Did([1; Did::BYTE_SIZE]); + + did::Pallet::::new_onchain_(did, vec![UncheckedDidKey::new_with_all_relationships(public)], Default::default()).unwrap(); + let id = Default::default(); + + let blob = Blob { + id, + blob: BoundedBytes((0..s).map(|i| i as u8).try_collect().unwrap()), + }; + let add_blob = AddBlob { + blob, + nonce: 1u8.into() + }; + let sig = pair.sign(&add_blob.to_state_change().encode()); + let signature = DidSignature::new(did.clone(), 1u32, sig); + }: new(RawOrigin::Signed(caller), add_blob, signature) + verify { + let value = Blobs::::get(id); + assert!(value.is_some()); + } +} diff --git a/pallets/did/src/modules/blob/mod.rs b/pallets/did/src/modules/blob/mod.rs new file mode 100644 index 0000000..3f0509e --- /dev/null +++ b/pallets/did/src/modules/blob/mod.rs @@ -0,0 +1,137 @@ +//! Generic immutable single-owner storage. + +use crate::{ + common::{Limits, SigValue, TypesAndLimits}, + did, + did::{Did, DidSignature}, + util::BoundedBytes, +}; +use codec::{Decode, Encode, MaxEncodedLen}; +use sp_std::fmt::Debug; + +use frame_support::{ + dispatch::DispatchResult, ensure, weights::Weight, CloneNoBound, DebugNoBound, EqNoBound, + PartialEqNoBound, +}; +use sp_std::prelude::*; +use weights::*; + +pub use pallet::*; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +#[cfg(test)] +mod tests; +mod weights; + +/// Owner of a Blob. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct BlobOwner(pub Did); + +crate::impl_wrapper!(BlobOwner(Did), for rand use Did(rand::random()), with tests as blob_owner_tests); + +/// Size of the blob id in bytes +pub const ID_BYTE_SIZE: usize = 32; + +/// The unique name for a blob. +pub type BlobId = [u8; ID_BYTE_SIZE]; + +/// When a new blob is being registered, the following object is sent. +#[derive(Encode, Decode, CloneNoBound, PartialEqNoBound, DebugNoBound, EqNoBound)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct Blob { + pub id: BlobId, + pub blob: BoundedBytes, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, DebugNoBound, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddBlob { + pub blob: Blob, + pub nonce: T::BlockNumber, +} + +crate::impl_action_with_nonce! { + AddBlob for (): with 1 as len, () as target +} + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config + did::Config {} + + /// Error for the blob module. + #[pallet::error] + pub enum Error { + /// There is already a blob with same id + BlobAlreadyExists, + /// There is no such DID registered + DidDoesNotExist, + } + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::storage] + #[pallet::getter(fn blob)] + pub type Blobs = + StorageMap<_, Blake2_128Concat, BlobId, (BlobOwner, BoundedBytes)>; + + #[pallet::call] + impl Pallet { + /// Create a new immutable blob. + #[pallet::weight(SubstrateWeight::::new(blob, signature))] + #[pallet::call_index(0)] + pub fn new( + origin: OriginFor, + blob: AddBlob, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did(Self::new_, blob, signature) + } + } + + impl Pallet { + fn new_(AddBlob { blob, .. }: AddBlob, signer: BlobOwner) -> DispatchResult { + // check + ensure!(!Blobs::::contains_key(blob.id), Error::::BlobAlreadyExists); + + // execute + Blobs::::insert(blob.id, (signer, blob.blob)); + + Ok(()) + } + } +} + +impl SubstrateWeight { + #[allow(clippy::new_ret_no_self)] + fn new( + AddBlob { blob, .. }: &AddBlob, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::new_sr25519, + SigValue::Ed25519(_) => Self::new_ed25519, + }(blob.blob.len() as u32)) + } +} diff --git a/pallets/did/src/modules/blob/tests.rs b/pallets/did/src/modules/blob/tests.rs new file mode 100644 index 0000000..00eb73d --- /dev/null +++ b/pallets/did/src/modules/blob/tests.rs @@ -0,0 +1,161 @@ +use super::{did, Blob, BlobId, BlobOwner, Blobs, DispatchResult, Error}; +use crate::{blob::AddBlob, common::Limits, did::Did, tests::common::*}; +use frame_system::Origin; +use sp_core::{sr25519, Pair}; + +fn create_blob( + id: BlobId, + content: Vec, + author: BlobOwner, + author_kp: sr25519::Pair, + nonce: u64, +) -> Option { + let bl = Blob { id, blob: content.clone().try_into().ok()? }; + println!("did: {:?}", author); + println!("pk: {:?}", author_kp.public().0); + println!("id: {:?}", id); + println!("content: {:?}", content); + + BlobMod::new( + RuntimeOrigin::signed(ABBA), + AddBlob { blob: bl.clone(), nonce }, + did_sig::(&AddBlob { blob: bl, nonce }, &author_kp, author, 1), + ) + .into() +} + +fn get_max_blob_size() -> usize { + ::MaxBlobSize::get() as usize +} + +#[test] +fn add_blob() { + fn add(size: usize, block_no: u64) { + run_to_block(block_no); + + let id: BlobId = rand::random(); + let noise = random_bytes(size); + let (author, author_kp) = newdid(); + assert_eq!(Blobs::::get(id), None); + create_blob(id, noise.clone(), BlobOwner(author), author_kp, block_no + 1) + .unwrap() + .unwrap(); + // Can retrieve a valid blob and the blob contents and author match the given ones. + assert_eq!(Blobs::::get(id), Some((BlobOwner(author), noise.try_into().unwrap()))); + check_nonce(&author, block_no + 1); + } + + ext().execute_with(|| { + // Can add a blob with unique id, blob data of < MaxBlobSize bytes and a valid signature. + add(get_max_blob_size() - 1, 10); + add(get_max_blob_size() - 2, 20); + add(0, 30); + // Can add a blob with unique id, blob data of MaxBlobSize bytes and a valid signature. + add(get_max_blob_size(), 40); + }); +} + +#[test] +fn err_blob_too_big() { + fn add_too_big(size: usize, block_no: u64) { + run_to_block(block_no); + + let (author, author_kp) = newdid(); + let noise = random_bytes(size); + let id = rand::random(); + assert_eq!(Blobs::::get(id), None); + check_nonce(&author, block_no); + assert!(create_blob(id, noise, BlobOwner(author), author_kp, block_no + 1).is_none()); + check_nonce(&author, block_no); + } + + ext().execute_with(|| { + add_too_big(get_max_blob_size() + 1, 10); + add_too_big(get_max_blob_size() + 2, 20); + }); +} + +#[test] +fn err_blob_already_exists() { + ext().execute_with(|| { + run_to_block(10); + + // Adding a blob with already used id fails with error BlobAlreadyExists. + let id = rand::random(); + let (author, author_kp) = newdid(); + assert_eq!(Blobs::::get(id), None); + check_nonce(&author, 10); + create_blob(id, random_bytes(10), BlobOwner(author), author_kp.clone(), 10 + 1) + .unwrap() + .unwrap(); + check_nonce(&author, 10 + 1); + let err = create_blob(id, random_bytes(10), BlobOwner(author), author_kp, 11 + 1) + .unwrap() + .unwrap_err(); + assert_eq!(err, Error::::BlobAlreadyExists.into()); + check_nonce(&author, 10 + 1); + }); +} + +#[test] +fn err_did_does_not_exist() { + ext().execute_with(|| { + run_to_block(10); + + // Adding a blob with an unregistered DID fails with error DidDoesNotExist. + let author = BlobOwner(Did(rand::random())); + let author_kp = gen_kp(); + let err = create_blob(rand::random(), random_bytes(10), author, author_kp, 10 + 1) + .unwrap() + .unwrap_err(); + assert_eq!(err, did::Error::::NoKeyForDid.into()); + }); +} + +#[test] +fn err_invalid_sig() { + ext().execute_with(|| { + { + run_to_block(10); + // An invalid signature while adding a blob should fail with error InvalidSignature. + let (author, author_kp) = newdid(); + let bl = Blob { id: rand::random(), blob: random_bytes(10).try_into().unwrap() }; + let att = crate::attest::SetAttestationClaim:: { + attest: crate::attest::Attestation { priority: 1, iri: None }, + nonce: 10 + 1, + }; + check_nonce(&author, 10); + let err = BlobMod::new( + RuntimeOrigin::signed(ABBA), + AddBlob { blob: bl, nonce: 10 + 1 }, + did_sig(&att, &author_kp, BlobOwner(author), 1), + ) + .unwrap_err(); + assert_eq!(err, did::Error::::InvalidSignature.into()); + check_nonce(&author, 10); + } + + { + run_to_block(20); + + // signature by other party + let (author, _) = newdid(); + let (_, author_kp) = newdid(); + let bl = Blob { id: rand::random(), blob: random_bytes(10).try_into().unwrap() }; + check_nonce(&author, 20); + let err = BlobMod::new( + RuntimeOrigin::signed(ABBA), + AddBlob { blob: bl.clone(), nonce: 20 + 1 }, + did_sig::( + &AddBlob { blob: bl, nonce: 20 + 1 }, + &author_kp, + BlobOwner(author), + 1, + ), + ) + .unwrap_err(); + assert_eq!(err, did::Error::::InvalidSignature.into()); + check_nonce(&author, 20); + } + }) +} diff --git a/pallets/did/src/modules/blob/weights.rs b/pallets/did/src/modules/blob/weights.rs new file mode 100644 index 0000000..fdd4f94 --- /dev/null +++ b/pallets/did/src/modules/blob/weights.rs @@ -0,0 +1,85 @@ +//! Autogenerated weights for blob +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2022-08-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Native), WASM-EXECUTION: Interpreted, CHAIN: Some("mainnet"), DB CACHE: 128 + +// Executed Command: +// ./target/production/dock-node +// benchmark +// --execution=native +// --chain=mainnet +// --pallet=blob +// --extra +// --extrinsic=* +// --repeat=20 +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/blob/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for blob. +pub trait WeightInfo { + fn new_sr25519(s: u32) -> Weight; + fn new_ed25519(s: u32) -> Weight; + fn new_secp256k1(s: u32) -> Weight; +} + +/// Weights for blob using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn new_sr25519(s: u32) -> Weight { + Weight::from_all(48_757_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(31_000_u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn new_ed25519(s: u32) -> Weight { + Weight::from_all(48_672_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(9_000_u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn new_secp256k1(s: u32) -> Weight { + Weight::from_all(152_477_000_u64) + // Standard Error: 2_000 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn new_sr25519(s: u32) -> Weight { + Weight::from_all(48_757_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(31_000_u64).saturating_mul(s as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn new_ed25519(s: u32) -> Weight { + Weight::from_all(48_672_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(9_000_u64).saturating_mul(s as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn new_secp256k1(s: u32) -> Weight { + Weight::from_all(152_477_000_u64) + // Standard Error: 2_000 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(s as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } +} diff --git a/pallets/did/src/modules/did/actions.rs b/pallets/did/src/modules/did/actions.rs new file mode 100644 index 0000000..1448f17 --- /dev/null +++ b/pallets/did/src/modules/did/actions.rs @@ -0,0 +1,109 @@ +use super::*; +use crate::{ + common::{Types, TypesAndLimits}, + impl_action_with_nonce, +}; + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddKeys { + pub did: Did, + pub keys: Vec, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveKeys { + pub did: Did, + /// Key ids to remove + pub keys: BTreeSet, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddControllers { + pub did: Did, + pub controllers: BTreeSet, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveControllers { + pub did: Did, + /// Controller ids to remove + pub controllers: BTreeSet, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddServiceEndpoint { + pub did: Did, + /// Endpoint id + pub id: ServiceEndpointId, + /// Endpoint data + pub endpoint: ServiceEndpoint, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveServiceEndpoint { + pub did: Did, + /// Endpoint id to remove + pub id: ServiceEndpointId, + pub nonce: T::BlockNumber, +} + +/// This struct is passed as an argument while removing the DID +/// `did` is the DID which is being removed. +#[derive( + Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct DidRemoval { + pub did: Did, + pub nonce: T::BlockNumber, +} + +impl_action_with_nonce!( + for Did: + AddKeys with keys.len() as len, did as target, + RemoveKeys with keys.len() as len, did as target, + AddControllers with controllers.len() as len, did as target, + RemoveControllers with controllers.len() as len, did as target, + AddServiceEndpoint with 1 as len, did as target, + RemoveServiceEndpoint with 1 as len, did as target, + DidRemoval with 1 as len, did as target +); diff --git a/pallets/did/src/modules/did/base/mod.rs b/pallets/did/src/modules/did/base/mod.rs new file mode 100644 index 0000000..de17957 --- /dev/null +++ b/pallets/did/src/modules/did/base/mod.rs @@ -0,0 +1,111 @@ +use crate::{common::TypesAndLimits, impl_wrapper}; +use codec::{Decode, Encode, MaxEncodedLen}; +use sp_std::{ + fmt::Debug, + ops::{Index, RangeFull}, +}; + +use super::*; + +pub mod offchain; +pub mod onchain; +pub mod signature; + +pub use offchain::*; +pub use onchain::*; +pub use signature::DidSignature; + +/// The type of the Dock `DID`. +#[derive( + Encode, + Decode, + Clone, + Debug, + PartialEq, + Eq, + Copy, + Ord, + PartialOrd, + MaxEncodedLen, + scale_info_derive::TypeInfo, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[scale_info(omit_prefix)] +pub struct Did(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub RawDid); + +impl Did { + /// Size of the Dock DID in bytes + pub const BYTE_SIZE: usize = 32; +} + +impl_wrapper! { Did(RawDid), with tests as did_tests } + +/// Raw DID representation. +pub type RawDid = [u8; Did::BYTE_SIZE]; + +impl Index for Did { + type Output = RawDid; + + fn index(&self, _: RangeFull) -> &Self::Output { + &self.0 + } +} + +/// Contains underlying DID describing its storage type. +#[derive(Encode, Decode, DebugNoBound, Clone, PartialEq, Eq, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub enum StoredDidDetails { + /// For off-chain DID, most data is stored off-chain. + OffChain(OffChainDidDetails), + /// For on-chain DID, all data is stored on the chain. + OnChain(StoredOnChainDidDetails), +} + +impl StoredDidDetails { + pub fn is_onchain(&self) -> bool { + matches!(self, StoredDidDetails::OnChain(_)) + } + + pub fn is_offchain(&self) -> bool { + matches!(self, StoredDidDetails::OffChain(_)) + } + + pub fn into_offchain(self) -> Option> { + match self { + StoredDidDetails::OffChain(details) => Some(details), + _ => None, + } + } + + pub fn into_onchain(self) -> Option> { + match self { + StoredDidDetails::OnChain(details) => Some(details), + _ => None, + } + } + + pub fn to_offchain_mut(&mut self) -> Option<&mut OffChainDidDetails> { + match self { + StoredDidDetails::OffChain(details) => Some(details), + _ => None, + } + } + + pub fn to_onchain_mut(&mut self) -> Option<&mut StoredOnChainDidDetails> { + match self { + StoredDidDetails::OnChain(details) => Some(details), + _ => None, + } + } +} + +impl Pallet { + /// Inserts details for the given `DID`. + pub(crate) fn insert_did_details>>(did: Did, did_details: D) { + Dids::::insert(did, did_details.into()) + } +} diff --git a/pallets/did/src/modules/did/base/offchain.rs b/pallets/did/src/modules/did/base/offchain.rs new file mode 100644 index 0000000..72cd438 --- /dev/null +++ b/pallets/did/src/modules/did/base/offchain.rs @@ -0,0 +1,131 @@ +use super::super::*; +use crate::{common::TypesAndLimits, deposit_indexed_event}; + +/// Stores details of an off-chain DID. +/// Off-chain DID has no need of nonce as the signature is made on the whole transaction by +/// the caller account and Substrate takes care of replay protection. Thus it stores the data +/// about off-chain DID Doc (hash, URI or any other reference) and the account that owns it. +#[derive(Encode, Decode, DebugNoBound, Clone, PartialEq, Eq, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct OffChainDidDetails { + pub account_id: T::AccountId, + pub doc_ref: OffChainDidDocRef, +} + +impl From> for StoredDidDetails { + fn from(details: OffChainDidDetails) -> Self { + Self::OffChain(details) + } +} + +impl TryFrom> for OffChainDidDetails { + type Error = Error; + + fn try_from(details: StoredDidDetails) -> Result { + details.into_offchain().ok_or(Error::::CannotGetDetailForOffChainDid) + } +} + +impl OffChainDidDetails { + /// Constructs new off-chain DID details using supplied params. + pub fn new(account_id: T::AccountId, doc_ref: OffChainDidDocRef) -> Self { + Self { account_id, doc_ref } + } + + /// Ensures that caller is able to update given off-chain DID. + pub fn ensure_can_update(&self, caller: &T::AccountId) -> Result<(), Error> { + ensure!(&self.account_id == caller, Error::::DidNotOwnedByAccount); + + Ok(()) + } +} + +/// To describe the off chain DID Doc's reference. This is just to inform the client, this module +/// does not check if the bytes are indeed valid as per the enum variant +#[derive( + Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub enum OffChainDidDocRef { + /// Content IDentifier as per https://github.com/multiformats/cid. + CID(BoundedBytes), + /// A URL + URL(BoundedBytes), + /// A custom encoding of the reference + Custom(BoundedBytes), +} + +impl OffChainDidDocRef { + pub fn len(&self) -> u32 { + match self { + OffChainDidDocRef::CID(v) => v.len() as u32, + OffChainDidDocRef::URL(v) => v.len() as u32, + OffChainDidDocRef::Custom(v) => v.len() as u32, + } + } + + pub fn is_empty(&self) -> bool { + self.len() == 0 + } +} + +impl Pallet { + pub(crate) fn new_offchain_( + caller: T::AccountId, + did: Did, + did_doc_ref: OffChainDidDocRef, + ) -> DispatchResult { + // DID is not registered already + ensure!(!Dids::::contains_key(did), Error::::DidAlreadyExists); + + let details = OffChainDidDetails::new(caller, did_doc_ref.clone()); + Self::insert_did_details(did, details); + + deposit_indexed_event!(OffChainDidAdded(did, did_doc_ref) over did); + Ok(()) + } + + pub(crate) fn set_offchain_did_doc_ref_( + caller: T::AccountId, + did: Did, + did_doc_ref: OffChainDidDocRef, + ) -> DispatchResult { + Self::offchain_did_details(&did)?.ensure_can_update(&caller)?; + + let details: StoredDidDetails = + OffChainDidDetails::new(caller, did_doc_ref.clone()).into(); + Dids::::insert(did, details); + + deposit_indexed_event!(OffChainDidUpdated(did, did_doc_ref) over did); + Ok(()) + } + + pub(crate) fn remove_offchain_did_(caller: T::AccountId, did: Did) -> DispatchResult { + Self::offchain_did_details(&did)?.ensure_can_update(&caller)?; + + Dids::::remove(did); + + deposit_indexed_event!(OffChainDidRemoved(did)); + Ok(()) + } + + pub fn is_offchain_did(did: &Did) -> Result> { + Self::did(did) + .as_ref() + .map(StoredDidDetails::is_offchain) + .ok_or(Error::::DidDoesNotExist) + } + + /// Get DID detail of an off-chain DID. Throws error if DID does not exist or is on-chain. + pub fn offchain_did_details(did: &Did) -> Result, Error> { + Self::did(did).ok_or(Error::::DidDoesNotExist)?.try_into() + } +} diff --git a/pallets/did/src/modules/did/base/onchain.rs b/pallets/did/src/modules/did/base/onchain.rs new file mode 100644 index 0000000..1386aac --- /dev/null +++ b/pallets/did/src/modules/did/base/onchain.rs @@ -0,0 +1,262 @@ +use super::super::*; +use crate::{ + common::{ToStateChange, TypesAndLimits}, + deposit_indexed_event, + util::WrappedActionWithNonce, +}; + +/// Each on-chain DID is associated with a nonce that is incremented each time the DID does a +/// write (through an extrinsic). The nonce starts from the block number when the DID was created to +/// avoid replay attacks where an action of a DID that is removed and recreated by the same owner +/// and same key is replayed by someone else. +pub type StoredOnChainDidDetails = WithNonce; + +/// Stores details of an on-chain DID. +#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, Default, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct OnChainDidDetails { + /// Number of keys added for this DID so far. + pub last_key_id: IncId, + /// Number of currently active controller keys. + pub active_controller_keys: u32, + /// Number of currently active controllers. + pub active_controllers: u32, +} + +impl From> for StoredDidDetails { + fn from(details: StoredOnChainDidDetails) -> Self { + Self::OnChain(details) + } +} + +impl TryFrom> for StoredOnChainDidDetails { + type Error = Error; + + fn try_from(details: StoredDidDetails) -> Result { + details.into_onchain().ok_or(Error::::CannotGetDetailForOnChainDid) + } +} + +impl OnChainDidDetails { + /// Constructs new on-chain DID details using supplied params. + /// + /// - `last_key_id` - last incremental identifier of the key being used for the given DID. + /// - `active_controller_keys` - amount of currently active controller keys for the given DID. + /// - `active_controllers` - amount of currently active controllers for the given DID. + pub fn new(last_key_id: IncId, active_controller_keys: u32, active_controllers: u32) -> Self { + Self { last_key_id, active_controller_keys, active_controllers } + } +} + +impl Pallet { + pub(crate) fn new_onchain_( + did: Did, + keys: Vec, + mut controllers: BTreeSet, + ) -> DispatchResult { + // DID is not registered already + ensure!(!Dids::::contains_key(did), Error::::DidAlreadyExists); + + let keys: Vec<_> = keys + .into_iter() + .map(DidKey::try_from) + .collect::>() + .map_err(Error::::from)?; + + let controller_keys_count = keys.iter().filter(|key| key.can_control()).count() as u32; + // Make self controlled if needed + if controller_keys_count > 0 { + controllers.insert(Controller(did)); + } + ensure!(!controllers.is_empty(), Error::::NoControllerProvided); + + let mut last_key_id = IncId::new(); + for (key, key_id) in keys.into_iter().zip(&mut last_key_id) { + DidKeys::::insert(did, key_id, key); + } + + for ctrl in &controllers { + DidControllers::::insert(did, ctrl, ()); + } + + let did_details = WithNonce::new(OnChainDidDetails::new( + last_key_id, + controller_keys_count, + controllers.len() as u32, + )); + + Self::insert_did_details(did, did_details); + + deposit_indexed_event!(OnChainDidAdded(did)); + Ok(()) + } + + pub(crate) fn remove_onchain_did_( + DidRemoval { did, .. }: DidRemoval, + details: &mut Option, + ) -> DispatchResult { + // This will result in the removal of DID from storage map `Dids` + details.take(); + + // TODO: limit and cursor + let _ = DidKeys::::clear_prefix(did, u32::MAX, None); + // TODO: limit and cursor + let _ = DidControllers::::clear_prefix(did, u32::MAX, None); + // TODO: limit and cursor + let _ = DidServiceEndpoints::::clear_prefix(did, u32::MAX, None); + // TODO: dynamic weight + let _ = T::OnDidRemoval::on_remove_did(did); + + deposit_indexed_event!(OnChainDidRemoved(did)); + Ok(()) + } + + /// Try executing an action by a DID. Each action of a DID is supposed to have a nonce which + /// should be one more than the current one. This function will check that payload has correct + /// nonce and will then execute the given function `f` on the action and if `f` executes + /// successfully, it will increment the DID's nonce by 1. + pub(crate) fn try_exec_signed_action_from_onchain_did( + f: F, + action: A, + signature: DidSignature, + ) -> Result + where + F: FnOnce(A, S) -> Result, + A: ActionWithNonce + ToStateChange, + S: Into + Copy, + E: From> + From, + { + ensure!( + Self::verify_sig_from_auth_or_control_key(&action, &signature)?, + Error::::InvalidSignature + ); + + Self::try_exec_action_over_onchain_did( + |WrappedActionWithNonce { action, target, .. }, _| f(action, target), + WrappedActionWithNonce::new(action.nonce(), signature.did, action), + ) + } + + /// Attempts to execute an action signed by a DID that controls (possibly) another DID. + /// This means nonce of signing DID must be checked and increased if the action is successful. + /// The DID details of the controlled DID can be changed. + pub(crate) fn try_exec_signed_action_from_controller( + f: F, + action: A, + signature: DidSignature, + ) -> Result + where + F: FnOnce(A, &mut OnChainDidDetails) -> Result, + A: ActionWithNonce + ToStateChange, + A::Target: Into, + E: From> + From, + { + Self::try_exec_signed_removable_action_from_controller( + |action, details_opt| f(action, details_opt.as_mut().unwrap()), + action, + signature, + ) + } + + /// Attempts to execute an action signed by a DID that controls (possibly) another DID. + /// This means nonce of signing DID must be checked and increased if the action is successful. + /// The DID details of the controlled DID can be changed. + /// Unlike `try_exec_action_over_onchain_did`, this action may result in a removal of a DID, + /// if the value under option will be taken. + pub(crate) fn try_exec_signed_removable_action_from_controller( + f: F, + action: A, + signature: DidSignature, + ) -> Result + where + F: FnOnce(A, &mut Option) -> Result, + A: ActionWithNonce + ToStateChange, + E: From> + From, + { + ensure!( + Self::verify_sig_from_controller(&action, &signature)?, + Error::::InvalidSignature + ); + + if action.target() != *signature.did { + let wrapped_action = WrappedActionWithNonce::new(action.nonce(), signature.did, action); + + // Target DID and acting (signer) DID are different and thus both DID's details must be + // modified + Self::try_exec_removable_action_over_onchain_did( + |WrappedActionWithNonce { action, .. }, _| { + Dids::::try_mutate_exists(action.target(), |details_opt| { + WithNonce::try_update_opt_without_increasing_nonce_with( + details_opt, + |data_opt| f(action, data_opt), + ) + .ok_or(Error::::DidDoesNotExist)? + }) + }, + wrapped_action, + ) + } else { + // Target DID and acting (signer) DID are the same + Self::try_exec_removable_action_over_onchain_did(f, action) + } + } + + crate::pub_for_test! { + /// Executes action over target on-chain DID providing a mutable reference if the given + /// nonce is correct, i.e. 1 more than the current nonce. + fn try_exec_action_over_onchain_did(f: F, action: A) -> Result + where + F: FnOnce(A, &mut OnChainDidDetails) -> Result, + A: ActionWithNonce, + A::Target: Into, + E: From> + From, + + { + Self::try_exec_removable_action_over_onchain_did(|action, details_opt| { + f(action, details_opt.as_mut().unwrap()) + }, action) + } + } + + crate::pub_for_test! { + /// Executes action over target on-chain DID providing a mutable reference if the given + /// nonce is correct, i.e. 1 more than the current nonce. + /// Unlike `try_exec_action_over_onchain_did`, this action may result in a removal of a DID, + /// if the value under option will be taken. + fn try_exec_removable_action_over_onchain_did( + f: F, + action: A, + ) -> Result + where + F: FnOnce(A, &mut Option) -> Result, + A: ActionWithNonce, + A::Target: Into, + E: From> + From, + + { + ensure!(!action.is_empty(), Error::::EmptyPayload); + + Dids::::try_mutate_exists(action.target().into(), |cnt_details_opt| { + WithNonce::try_update_opt_with(cnt_details_opt, action.nonce(), |data_opt| { + f(action, data_opt) + }) + .ok_or(Error::::DidDoesNotExist)? + }) + } + } + + pub fn is_onchain_did(did: &Did) -> Result> { + Self::did(did) + .as_ref() + .map(StoredDidDetails::is_onchain) + .ok_or(Error::::DidDoesNotExist) + } + + /// Get DID detail of an on-chain DID. Throws error if DID does not exist or is off-chain. + pub fn onchain_did_details(did: &Did) -> Result, Error> { + Self::did(did).ok_or(Error::::DidDoesNotExist)?.try_into() + } +} diff --git a/pallets/did/src/modules/did/base/signature.rs b/pallets/did/src/modules/did/base/signature.rs new file mode 100644 index 0000000..84d0e53 --- /dev/null +++ b/pallets/did/src/modules/did/base/signature.rs @@ -0,0 +1,76 @@ +use super::super::*; +use crate::common::{SigValue, ToStateChange, VerificationError}; + +/// `DID`'s signature along with the used `DID`s key reference. +#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[derive(scale_info_derive::TypeInfo)] +#[codec(encode_bound(D: Encode + MaxEncodedLen + Into))] +#[scale_info(omit_prefix)] +pub struct DidSignature> { + /// The DID that created this signature + pub did: D, + /// The key-id of above DID used to verify the signature + pub key_id: IncId, + /// The actual signature + pub sig: SigValue, +} + +impl> DidSignature { + pub fn new(did: impl Into, key_id: impl Into, sig: impl Into) -> Self { + Self { did: did.into(), key_id: key_id.into(), sig: sig.into() } + } + + pub fn verify( + &self, + message: &[u8], + public_key: &PublicKey, + ) -> Result { + self.sig.verify(message, public_key) + } + + /// This is just the weight to verify the signature. It does not include weight to read the DID + /// or the key. + pub fn weight(&self) -> Weight { + self.sig.weight() + } +} + +impl Pallet { + /// Verifies a `DidSignature` created by `signer` only if `signer` is a controller of `did` and + /// has an appropriate key. To update a DID (add/remove keys, add/remove controllers), the + /// updater must be a controller of the DID and must have a key with `CAPABILITY_INVOCATION` + /// verification relationship + pub fn verify_sig_from_controller( + action: &A, + sig: &DidSignature, + ) -> Result> + where + A: Action + ToStateChange, + A::Target: Into, + { + Self::ensure_controller(&action.target().into(), &sig.did)?; + let signer_pubkey = Self::control_key(&sig.did, sig.key_id)?; + let encoded_state_change = action.to_state_change().encode(); + + sig.verify(&encoded_state_change, &signer_pubkey).map_err(Into::into) + } + + /// Verifies that `did`'s key with id `key_id` can either authenticate or control otherwise + /// returns an error. Then provided signature will be verified against the supplied public key + /// and `true` returned for a valid signature. + pub fn verify_sig_from_auth_or_control_key( + state_change: &Sc, + sig: &DidSignature, + ) -> Result> + where + D: Into + Copy, + Sc: ToStateChange, + { + let signer_pubkey = Self::auth_or_control_key(&sig.did.into(), sig.key_id)?; + let encoded_state_change = state_change.to_state_change().encode(); + + sig.verify(&encoded_state_change, &signer_pubkey).map_err(Into::into) + } +} diff --git a/pallets/did/src/modules/did/benchmarks.rs b/pallets/did/src/modules/did/benchmarks.rs new file mode 100644 index 0000000..82df968 --- /dev/null +++ b/pallets/did/src/modules/did/benchmarks.rs @@ -0,0 +1,374 @@ +use super::*; +use crate::{common::state_change::ToStateChange, did::service_endpoints::*}; +use alloc::collections::BTreeSet; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +use sp_application_crypto::Pair; +use sp_core::{ed25519, U256}; +use sp_runtime::traits::TryCollect; +use sp_std::iter::once; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MAX_ENTITY_AMOUNT: u32 = 10; +const MAX_DID_DOC_REF_SIZE: u32 = 100; +const MAX_ORIGINS: u32 = 10; +const MAX_ORIGIN_LENGTH: u32 = 10; +const MAX_SERVICE_ENDPOINT_ID_LENGTH: u32 = 100; + +crate::bench_with_all_pairs! { + with_pairs: + add_keys_sr25519 for sr25519, add_keys_ed25519 for ed25519, add_keys_secp256k1 for secp256k1 { + { + let k in 1 .. MAX_ENTITY_AMOUNT; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let did_key = UncheckedDidKey::new_with_all_relationships(pair.public()); + + crate::did::Pallet::::new_onchain_( + did, + vec![did_key.clone()], + Default::default(), + ).unwrap(); + + let keys: Vec<_> = + (0..k) + .map(|idx| crate::def_test_pair!(secp256k1, &[10 + idx as u8; 32]).public()) + .map(UncheckedDidKey::new_with_all_relationships) + .collect(); + + let key_update = AddKeys { + did, + keys: keys.clone(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&key_update.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: add_keys(RawOrigin::Signed(caller), key_update, signature) + verify { + let mut stored_keys = DidKeys::::iter_prefix_values(did).collect::>(); + stored_keys.sort_by_key(|key| key.public_key().as_slice().to_vec()); + + let mut keys = keys.clone(); + keys.push(did_key); + keys.sort_by_key(|key| key.public_key.as_slice().to_vec()); + + assert_eq!(stored_keys, keys.into_iter().map(DidKey::try_from).map(Result::unwrap).collect::>()); + } + + remove_keys_sr25519 for sr25519, remove_keys_ed25519 for ed25519, remove_keys_secp256k1 for secp256k1 { + { + let k in 1 .. MAX_ENTITY_AMOUNT; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + let keys: Vec<_> = + once(UncheckedDidKey::new_with_all_relationships(public)) + .chain( + (0..k) + .map(|i| ed25519::Pair::from_seed(&U256::from(i).into())) + .map(|pair| UncheckedDidKey::new_with_all_relationships(pair.public())) + ) + .map(Into::into) + .collect(); + + crate::did::Pallet::::new_onchain_( + did, + keys.clone(), + Default::default(), + ).unwrap(); + + let key_update = RemoveKeys { + did, + keys: (1..=k + 1).map(IncId::from).collect(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&key_update.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: remove_keys(RawOrigin::Signed(caller), key_update, signature) + verify { + assert_eq!(DidKeys::::iter_prefix(did).count(), 0); + } + + add_controllers_sr25519 for sr25519, add_controllers_ed25519 for ed25519, add_controllers_secp256k1 for secp256k1 { + { + let k in 1 .. MAX_ENTITY_AMOUNT; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([2; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let controllers: BTreeSet<_> = (0..k) + .map(|i| U256::from(i).into()) + .map(Did) + .map(Controller) + .collect(); + + let new_controllers = AddControllers { + did, + controllers: controllers.clone(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&new_controllers.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: add_controllers(RawOrigin::Signed(caller), new_controllers, signature) + verify { + let mut stored_controllers = DidControllers::::iter_prefix(did).map(|(cnt, _)| cnt).collect::>(); + stored_controllers.sort(); + + let mut controllers = controllers.into_iter().collect::>(); + controllers.push(Controller(did)); + controllers.sort(); + + assert_eq!(stored_controllers, controllers); + } + + remove_controllers_sr25519 for sr25519, remove_controllers_ed25519 for ed25519, remove_controllers_secp256k1 for secp256k1 { + { + let k in 1 .. MAX_ENTITY_AMOUNT; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([3; Did::BYTE_SIZE]); + let public = pair.public(); + let controllers: BTreeSet<_> = (0..k) + .map(|i| U256::from(i).into()) + .map(Did) + .map(Controller) + .collect(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + controllers.clone(), + ).unwrap(); + + let rem_controllers = RemoveControllers { + did, + controllers: controllers.clone().into_iter().chain(once(Controller(did))).collect(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&rem_controllers.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: remove_controllers(RawOrigin::Signed(caller), rem_controllers, signature) + verify { + assert_eq!(DidControllers::::iter_prefix(did).count(), 0); + } + + add_service_endpoint_sr25519 for sr25519, add_service_endpoint_ed25519 for ed25519, add_service_endpoint_secp256k1 for secp256k1 { + { + let o in 1 .. MAX_ORIGINS; + let l in 1 .. MAX_ORIGIN_LENGTH; + let i in 1 .. MAX_SERVICE_ENDPOINT_ID_LENGTH; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([3; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let add_endpoint = AddServiceEndpoint { + did, + id: ServiceEndpointId(vec![1; i as usize].try_into().unwrap()), + endpoint: ServiceEndpoint { + origins: (0..o).map(|i| vec![i as u8; l as usize].try_into().unwrap()).map(ServiceEndpointOrigin).try_collect().unwrap(), + types: crate::did::service_endpoints::ServiceEndpointType::LINKED_DOMAINS + }, + nonce: 1u8.into() + }; + + let sig = pair.sign(&add_endpoint.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: add_service_endpoint(RawOrigin::Signed(caller), add_endpoint.clone(), signature) + verify { + assert_eq!(DidServiceEndpoints::::get(did, ServiceEndpointId(vec![1; i as usize].try_into().unwrap())), Some(add_endpoint.endpoint)); + } + + remove_service_endpoint_sr25519 for sr25519, remove_service_endpoint_ed25519 for ed25519, remove_service_endpoint_secp256k1 for secp256k1 { + { + let i in 1 .. MAX_SERVICE_ENDPOINT_ID_LENGTH; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([3; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + crate::did::Pallet::::add_service_endpoint_( + AddServiceEndpoint { + did, + id: ServiceEndpointId(vec![1; i as usize].try_into().unwrap()), + endpoint: ServiceEndpoint { + origins: (0..MAX_ORIGINS as usize).map(|i| vec![i as u8; MAX_ORIGIN_LENGTH as usize].try_into().unwrap()).map(ServiceEndpointOrigin).try_collect().unwrap(), + types: crate::did::service_endpoints::ServiceEndpointType::LINKED_DOMAINS + }, + nonce: 1u8.into() + }, + &mut Default::default() + ).unwrap(); + + let remove_endpoint = RemoveServiceEndpoint { + id: ServiceEndpointId(vec![1; i as usize].try_into().unwrap()), + did, + nonce: 1u8.into() + }; + + let sig = pair.sign(&remove_endpoint.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: remove_service_endpoint(RawOrigin::Signed(caller), remove_endpoint.clone(), signature) + verify { + assert!(DidServiceEndpoints::::get(did, ServiceEndpointId(vec![1; i as usize].try_into().unwrap())).is_none()); + } + remove_onchain_did_sr25519 for sr25519, remove_onchain_did_ed25519 for ed25519, remove_onchain_did_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([3; Did::BYTE_SIZE]); + let public = pair.public(); + + let keys: Vec<_> = once(UncheckedDidKey::new_with_all_relationships(public)).chain((0..MAX_ENTITY_AMOUNT) + .map(|i| ed25519::Pair::from_seed(&U256::from(i).into())) + .map(|pair| UncheckedDidKey::new_with_all_relationships(pair.public()))) + .collect(); + let controllers: BTreeSet<_> = (0..MAX_ENTITY_AMOUNT) + .map(|i| U256::from(i).into()) + .map(Did) + .map(Controller) + .collect(); + + crate::did::Pallet::::new_onchain_( + did, + keys, + controllers, + ).unwrap(); + + let remove_did = DidRemoval { + did, + nonce: 1u8.into() + }; + + for i in 0..MAX_ENTITY_AMOUNT { + crate::did::Pallet::::add_service_endpoint_( + AddServiceEndpoint { + did, + id: ServiceEndpointId(vec![1; (i + 1) as usize].try_into().unwrap()), + endpoint: ServiceEndpoint { + origins: (0..MAX_ORIGINS as usize).map(|i| vec![i as u8; MAX_ORIGIN_LENGTH as usize].try_into().unwrap()).map(ServiceEndpointOrigin).try_collect().unwrap(), + types: crate::did::service_endpoints::ServiceEndpointType::LINKED_DOMAINS + }, + nonce: 1u8.into() + }, + &mut Default::default() + ).unwrap(); + } + + let sig = pair.sign(&remove_did.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: remove_onchain_did(RawOrigin::Signed(caller), remove_did.clone(), signature) + verify { + assert!(Dids::::get(did).is_none()); + }; + + standard: + new_onchain { + let k in 1 .. MAX_ENTITY_AMOUNT => (); + let c in 1 .. MAX_ENTITY_AMOUNT => (); + + let caller = whitelisted_caller(); + let did = Did([4; Did::BYTE_SIZE]); + + let keys: Vec<_> = (0..k) + .map(|i| ed25519::Pair::from_seed(&U256::from(i).into())) + .map(|pair| UncheckedDidKey::new_with_all_relationships(pair.public())) + .collect(); + let controllers: BTreeSet<_> = (0..c) + .map(|i| U256::from(i).into()) + .map(Did) + .map(Controller) + .collect(); + + }: new_onchain(RawOrigin::Signed(caller), did, keys.clone().into_iter().map(Into::into).collect(), controllers.clone()) + verify { + let keys: Vec<_> = keys.into_iter().map(DidKey::try_from).map(Result::unwrap).collect(); + assert_eq!(Dids::::get(did).unwrap().into_onchain().unwrap(), WithNonce::new(OnChainDidDetails::new((keys.len() as u32).into(), keys.iter().filter(|key| key.can_control() || key.ver_rels().is_empty()).count() as u32, controllers.len() as u32 + 1))); + + let mut stored_keys = DidKeys::::iter_prefix_values(did).collect::>(); + stored_keys.sort_by_key(|key| key.public_key().as_slice().to_vec()); + + let mut keys = keys.into_iter().collect::>(); + keys.sort_by_key(|key| key.public_key().as_slice().to_vec()); + + assert_eq!(stored_keys, keys); + + let mut stored_controllers = DidControllers::::iter_prefix(did).map(|(cnt, _)| cnt).collect::>(); + stored_controllers.sort(); + + let mut controllers = controllers.into_iter().collect::>(); + controllers.push(Controller(did)); + controllers.sort(); + + assert_eq!(stored_controllers, controllers); + } + + new_offchain { + let k in 1 .. MAX_DID_DOC_REF_SIZE => (); + + let caller: T::AccountId = whitelisted_caller(); + let did = Did([4; Did::BYTE_SIZE]); + + let did_doc_ref = OffChainDidDocRef::::CID(BoundedBytes((0..k).map(|k| k as u8).try_collect().unwrap())); + + }: new_offchain(RawOrigin::Signed(caller.clone()), did, did_doc_ref.clone()) + verify { + assert_eq!(Pallet::::offchain_did_details(&did).unwrap(), OffChainDidDetails::new(caller, did_doc_ref)); + } + set_offchain_did_doc_ref { + let k in 1 .. MAX_DID_DOC_REF_SIZE => (); + + let caller: T::AccountId = whitelisted_caller(); + let did = Did([4; Did::BYTE_SIZE]); + + let did_doc_ref = OffChainDidDocRef::::CID(BoundedBytes((0..k).map(|k| k as u8).try_collect().unwrap())); + super::Pallet::::new_offchain_(caller.clone(), did, OffChainDidDocRef::::URL(Default::default())).unwrap(); + + }: set_offchain_did_doc_ref(RawOrigin::Signed(caller.clone()), did, did_doc_ref.clone()) + verify { + assert_eq!(Pallet::::offchain_did_details(&did).unwrap(), OffChainDidDetails::new(caller, did_doc_ref)); + } + remove_offchain_did { + let caller: T::AccountId = whitelisted_caller(); + let did = Did([4; Did::BYTE_SIZE]); + + let did_doc_ref = OffChainDidDocRef::::CID(BoundedBytes((1..MAX_DID_DOC_REF_SIZE).map(|k| k as u8).try_collect().unwrap())); + super::Pallet::::new_offchain_(caller.clone(), did, OffChainDidDocRef::::URL(Default::default())).unwrap(); + + }: remove_offchain_did(RawOrigin::Signed(caller.clone()), did) + verify { + assert!(Pallet::::offchain_did_details(&did).is_err()); + } +} diff --git a/pallets/did/src/modules/did/controllers.rs b/pallets/did/src/modules/did/controllers.rs new file mode 100644 index 0000000..03d496d --- /dev/null +++ b/pallets/did/src/modules/did/controllers.rs @@ -0,0 +1,65 @@ +use super::*; +use crate::{deposit_indexed_event, impl_wrapper}; + +/// `DID`'s controller. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct Controller(pub Did); + +impl_wrapper!(Controller(Did), for rand use Did(rand::random()), with tests as controller_tests); + +impl Pallet { + pub(crate) fn add_controllers_( + AddControllers { did, controllers, .. }: AddControllers, + OnChainDidDetails { active_controllers, .. }: &mut OnChainDidDetails, + ) -> DispatchResult { + for ctrl in &controllers { + ensure!(!Self::is_controller(&did, ctrl), Error::::ControllerIsAlreadyAdded) + } + + for ctrl in &controllers { + DidControllers::::insert(did, ctrl, ()); + *active_controllers += 1; + } + + deposit_indexed_event!(DidControllersAdded(did)); + Ok(()) + } + + pub(crate) fn remove_controllers_( + RemoveControllers { did, controllers, .. }: RemoveControllers, + OnChainDidDetails { active_controllers, .. }: &mut OnChainDidDetails, + ) -> DispatchResult { + for controller_did in &controllers { + ensure!(Self::is_controller(&did, controller_did), Error::::NoControllerForDid) + } + + for controller_did in &controllers { + DidControllers::::remove(did, controller_did); + *active_controllers -= 1; + } + + deposit_indexed_event!(DidControllersRemoved(did)); + Ok(()) + } + + /// Throws an error if `controller` is not the controller of `controlled` + pub fn ensure_controller(controlled: &Did, controller: &Controller) -> Result<(), Error> { + ensure!(Self::is_controller(controlled, controller), Error::::OnlyControllerCanUpdate); + + Ok(()) + } + + /// Returns true if given `controlled` DID is controlled by the `controller` DID. + pub fn is_controller(controlled: &Did, controller: &Controller) -> bool { + Self::bound_controller(controlled, controller).is_some() + } + + /// Returns true if DID controls itself, else false. + pub fn is_self_controlled(did: &Did) -> bool { + Self::is_controller(did, &Controller(*did)) + } +} diff --git a/pallets/did/src/modules/did/details_aggregator.rs b/pallets/did/src/modules/did/details_aggregator.rs new file mode 100644 index 0000000..9f5855a --- /dev/null +++ b/pallets/did/src/modules/did/details_aggregator.rs @@ -0,0 +1,136 @@ +use super::{service_endpoints::ServiceEndpointId, *}; +use crate::{ + attest::{self, Attestation, Attester}, + common::TypesAndLimits, + impl_bits_conversion, impl_wrapper_type_info, +}; + +/// Aggregated details for the given DID. +#[derive(Encode, Decode, DebugNoBound, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AggregatedDidDetailsResponse { + did: Did, + details: StoredDidDetails, + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] + keys: Option>, + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] + controllers: Option>, + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] + service_endpoints: Option>>, + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] + attestation: Option>, +} + +/// `DidKey` with its identifier. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(omit_prefix)] +pub struct DidKeyWithId { + id: IncId, + key: DidKey, +} + +/// `ServiceEndpoint` with its identifier. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, DebugNoBound, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct ServiceEndpointWithId { + id: ServiceEndpointId, + endpoint: ServiceEndpoint, +} + +impl AggregatedDidDetailsResponse { + /// Constructs new `DID` response using supplied arguments. + pub fn new( + did: Did, + details: StoredDidDetails, + keys: Option, + controllers: Option, + service_endpoints: Option, + attestation: Option>, + ) -> Self + where + KI: IntoIterator, + CI: IntoIterator, + SI: IntoIterator, ServiceEndpoint)>, + { + Self { + did, + details, + controllers: controllers.map(|controllers| controllers.into_iter().collect()), + keys: keys + .map(|keys| keys.into_iter().map(|(id, key)| DidKeyWithId { id, key }).collect()), + service_endpoints: service_endpoints.map(|endpoints| { + endpoints + .into_iter() + .map(|(id, endpoint)| ServiceEndpointWithId { id, endpoint }) + .collect() + }), + attestation, + } + } +} + +bitflags::bitflags! { + /// Information requested for DID. The default option includes only basic DID details. + #[derive(Default, Clone, Debug, PartialEq)] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(try_from = "u8", into = "u8"))] + pub struct AggregatedDidDetailsRequestParams: u8 { + /// Just basic DID details. + const BASIC = 0; + /// Include keys for the DID. + const KEYS = 0b0001; + /// Include controllers for the DID. + const CONTROLLERS = 0b0010; + /// Include service endpoints for the DID. + const SERVICE_ENDPOINTS = 0b0100; + /// Include attestation for the DID. + const ATTESTATION = 0b1000; + /// Include full DID information (keys, controllers, service endpoints and attestation). + const FULL = 0b1111; + } +} + +impl_bits_conversion! { AggregatedDidDetailsRequestParams from u8 } +impl_wrapper_type_info! { AggregatedDidDetailsRequestParams(u8) } + +impl Pallet { + /// Request aggregated DID details containing specified information. + pub fn aggregate_did_details( + did: &Did, + params: AggregatedDidDetailsRequestParams, + ) -> Option> { + let details = Self::did(did)?; + let keys = params + .intersects(AggregatedDidDetailsRequestParams::KEYS) + .then(|| DidKeys::::iter_prefix(did)); + let controllers = params + .intersects(AggregatedDidDetailsRequestParams::CONTROLLERS) + .then(|| DidControllers::::iter_prefix(did).map(|(did, ())| did)); + let service_endpoints = params + .intersects(AggregatedDidDetailsRequestParams::SERVICE_ENDPOINTS) + .then(|| DidServiceEndpoints::::iter_prefix(did)); + let attestation = params + .intersects(AggregatedDidDetailsRequestParams::ATTESTATION) + .then(|| >::attestation(Attester(*did))); + + Some(AggregatedDidDetailsResponse::new( + *did, + details, + keys, + controllers, + service_endpoints, + attestation, + )) + } +} diff --git a/pallets/did/src/modules/did/keys.rs b/pallets/did/src/modules/did/keys.rs new file mode 100644 index 0000000..4271027 --- /dev/null +++ b/pallets/did/src/modules/did/keys.rs @@ -0,0 +1,322 @@ +use super::*; +use crate::{deposit_indexed_event, impl_bits_conversion, impl_wrapper_type_info}; + +/// Valid did key with correct verification relationships. +#[derive( + Encode, Clone, Debug, PartialEq, Eq, PartialOrd, MaxEncodedLen, scale_info_derive::TypeInfo, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[scale_info(omit_prefix)] +pub struct DidKey { + /// The public key + public_key: PublicKey, + /// The different verification relationships the above key has with the DID. + ver_rels: VerRelType, +} + +/// `DidKey` without validity constraint requirement. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, PartialOrd)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct UncheckedDidKey { + /// The public key + pub public_key: PublicKey, + /// The different verification relationships the above key has with the DID. + pub ver_rels: VerRelType, +} + +impl Decode for DidKey { + fn decode(input: &mut I) -> Result { + let decoded = UncheckedDidKey::decode(input)?; + + Self::try_from(decoded) + .map_err(|err| -> &'static str { err.into() }) + .map_err(Into::into) + } +} + +bitflags::bitflags! { + /// Different verification relation types specified in the DID spec here https://www.w3.org/TR/did-core/#verification-relationships. + // #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[derive(Clone, Debug, PartialEq, Eq, PartialOrd)] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(try_from = "u16", into = "u16"))] + pub struct VerRelType: u16 { + /// No verification relation set. + const NONE = 0; + /// https://www.w3.org/TR/did-core/#authentication + const AUTHENTICATION = 0b0001; + /// https://www.w3.org/TR/did-core/#assertion + const ASSERTION = 0b0010; + /// A key must have this to control a DID + /// https://www.w3.org/TR/did-core/#capability-invocation + const CAPABILITY_INVOCATION = 0b0100; + /// https://www.w3.org/TR/did-core/#key-agreement + const KEY_AGREEMENT = 0b1000; + /// Includes `AUTHENTICATION`, `ASSERTION`, `CAPABILITY_INVOCATION`. + /// We might add more relationships in future but these 3 are all we care about now. + const ALL_FOR_SIGNING = 0b0111; + } +} + +impl_bits_conversion! { VerRelType from u16 } +impl_wrapper_type_info! { VerRelType(u16) } + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum DidKeyError { + KeyAgreementCantBeUsedForSigning, + SigningKeyCantBeUsedForKeyAgreement, +} + +impl From for &'static str { + fn from(err: DidKeyError) -> &'static str { + match err { + DidKeyError::KeyAgreementCantBeUsedForSigning => + "Key Agreement can't be used for signing", + DidKeyError::SigningKeyCantBeUsedForKeyAgreement => + "Signing key can't be used for Key Agreement", + } + } +} + +impl From for Error { + fn from(err: DidKeyError) -> Error { + match err { + DidKeyError::KeyAgreementCantBeUsedForSigning => + Error::::KeyAgreementCantBeUsedForSigning, + DidKeyError::SigningKeyCantBeUsedForKeyAgreement => + Error::::SigningKeyCantBeUsedForKeyAgreement, + } + } +} + +impl DidKey { + /// Constructs new `DidKey` using given public key and verification relationships. + pub fn new( + public_key: impl Into, + ver_rels: VerRelType, + ) -> Result { + if ver_rels.is_empty() { + Ok(Self::new_with_all_relationships(public_key)) + } else { + let public_key = public_key.into(); + if public_key.can_sign() { + if ver_rels.intersects(VerRelType::KEY_AGREEMENT) { + return Err(DidKeyError::SigningKeyCantBeUsedForKeyAgreement) + } + } else if ver_rels != VerRelType::KEY_AGREEMENT { + return Err(DidKeyError::KeyAgreementCantBeUsedForSigning) + } + + Ok(Self { public_key, ver_rels }) + } + } + + /// Constructs new `DidKey` using given public key and all available verification relationships + /// for this key. + pub fn new_with_all_relationships(public_key: impl Into) -> Self { + let public_key = public_key.into(); + let ver_rels = if public_key.can_sign() { + // If the key can be used for signing, mark it with all related relationships. + VerRelType::ALL_FOR_SIGNING + } else { + // The non-signing public key can be used only for key agreement currently. + VerRelType::KEY_AGREEMENT + }; + + Self { public_key, ver_rels } + } + + /// Returns underlying public key. + pub fn public_key(&self) -> &PublicKey { + &self.public_key + } + + /// Returns underlying verification relationships. + pub fn ver_rels(&self) -> VerRelType { + self.clone().ver_rels + } + + /// Checks if this key is capable of signing. + pub fn can_sign(&self) -> bool { + self.public_key.can_sign() + } + + /// Checks if this key can has `CAPABILITY_INVOCATION` relation set. + pub fn can_control(&self) -> bool { + self.ver_rels.intersects(VerRelType::CAPABILITY_INVOCATION) + } + + /// Checks if this key can has `AUTHENTICATION` relation set. + pub fn can_authenticate(&self) -> bool { + self.ver_rels.intersects(VerRelType::AUTHENTICATION) + } + + /// Checks if this key can has `KEY_AGREEMENT` relation set. + pub fn for_key_agreement(&self) -> bool { + self.ver_rels.intersects(VerRelType::KEY_AGREEMENT) + } + + /// Checks if this key can has either `AUTHENTICATION` or `CAPABILITY_INVOCATION` relation set. + pub fn can_authenticate_or_control(&self) -> bool { + self.ver_rels + .intersects(VerRelType::AUTHENTICATION | VerRelType::CAPABILITY_INVOCATION) + } +} + +impl UncheckedDidKey { + /// Constructs new `UncheckedDidKey` using given public key and verification relationships. + /// This function doesn't require key to have valid verification relationships. + pub fn new(public_key: impl Into, ver_rels: VerRelType) -> Self { + UncheckedDidKey { public_key: public_key.into(), ver_rels } + } + + /// Constructs new `UncheckedDidKey` using given public key and all available verification + /// relationships for this key. + pub fn new_with_all_relationships(public_key: impl Into) -> Self { + DidKey::new_with_all_relationships(public_key).into() + } +} + +impl TryFrom for DidKey { + type Error = DidKeyError; + + fn try_from( + UncheckedDidKey { public_key, ver_rels }: UncheckedDidKey, + ) -> Result { + DidKey::new(public_key, ver_rels) + } +} + +impl From for UncheckedDidKey { + fn from(DidKey { public_key, ver_rels }: DidKey) -> Self { + UncheckedDidKey::new(public_key, ver_rels) + } +} + +impl Pallet { + pub(crate) fn add_keys_( + AddKeys { did, keys, .. }: AddKeys, + OnChainDidDetails { + active_controllers, + active_controller_keys, + last_key_id, + .. + }: &mut OnChainDidDetails, + ) -> DispatchResult { + let keys: Vec<_> = keys + .into_iter() + .map(DidKey::try_from) + .collect::>() + .map_err(Error::::from)?; + + // If DID was not self controlled first, check if it can become by looking over new keys + let controller_keys_count = keys.iter().filter(|key| key.can_control()).count() as u32; + *active_controller_keys += controller_keys_count; + + // Make self controlled if needed + let add_self_controlled = controller_keys_count > 0 && !Self::is_self_controlled(&did); + if add_self_controlled { + DidControllers::::insert(did, Controller(did), ()); + *active_controllers += 1; + } + + for (key, key_id) in keys.into_iter().zip(last_key_id) { + DidKeys::::insert(did, key_id, key); + } + + deposit_indexed_event!(DidKeysAdded(did)); + Ok(()) + } + + pub(crate) fn remove_keys_( + RemoveKeys { did, keys, .. }: RemoveKeys, + OnChainDidDetails { + active_controllers, + active_controller_keys, + .. + }: &mut OnChainDidDetails, + ) -> DispatchResult { + for key_id in &keys { + let key = DidKeys::::get(did, key_id).ok_or(Error::::NoKeyForDid)?; + + if key.can_control() { + *active_controller_keys -= 1; + } + } + + for key in &keys { + DidKeys::::remove(did, key); + } + + // If no self-control keys exist for the given DID, remove self-control + let remove_self_controlled = *active_controller_keys == 0 && Self::is_self_controlled(&did); + if remove_self_controlled { + DidControllers::::remove(did, Controller(did)); + *active_controllers -= 1; + } + + deposit_indexed_event!(DidKeysRemoved(did)); + Ok(()) + } + + /// Return `did`'s key with id `key_id` only if has control capability, otherwise returns an + /// error. + pub fn control_key(&did: &Controller, key_id: IncId) -> Result> { + let did_key = DidKeys::::get(*did, key_id).ok_or(Error::::NoKeyForDid)?; + + if did_key.can_control() { + Ok(did_key.public_key) + } else { + Err(Error::::InsufficientVerificationRelationship) + } + } + + /// Return `did`'s key with id `key_id` only if it can authenticate or control otherwise returns + /// an error + pub fn auth_or_control_key(did: &Did, key_id: IncId) -> Result> { + let did_key = DidKeys::::get(did, key_id).ok_or(Error::::NoKeyForDid)?; + + if did_key.can_authenticate_or_control() { + Ok(did_key.public_key) + } else { + Err(Error::::InsufficientVerificationRelationship) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use codec::{Decode, Encode}; + use sp_core::Pair; + + #[test] + fn encode() { + assert_eq!(2u16.encode(), VerRelType::ASSERTION.encode()); + assert_eq!(VerRelType::decode(&mut &2u16.encode()[..]).unwrap(), VerRelType::ASSERTION); + let (pair_sr, _, _) = sp_application_crypto::sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + + assert_eq!( + DidKey::new(PublicKey::sr25519(pk_sr), VerRelType::CAPABILITY_INVOCATION) + .unwrap() + .encode(), + UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::CAPABILITY_INVOCATION) + .encode() + ); + assert_eq!( + DidKey::decode( + &mut &UncheckedDidKey::new( + PublicKey::sr25519(pk_sr), + VerRelType::CAPABILITY_INVOCATION + ) + .encode()[..] + ) + .unwrap(), + DidKey::new(PublicKey::sr25519(pk_sr), VerRelType::CAPABILITY_INVOCATION).unwrap() + ); + } +} diff --git a/pallets/did/src/modules/did/mod.rs b/pallets/did/src/modules/did/mod.rs new file mode 100644 index 0000000..19db791 --- /dev/null +++ b/pallets/did/src/modules/did/mod.rs @@ -0,0 +1,476 @@ +use crate::{ + common::{self, PublicKey, SigValue, VerificationError}, + util::*, +}; + +use crate::{common::Limits, util::CheckedDivCeil}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{ + dispatch::DispatchResult, ensure, weights::Weight, CloneNoBound, DebugNoBound, EqNoBound, + PartialEqNoBound, +}; +use frame_system::ensure_signed; +use sp_std::{ + collections::btree_set::BTreeSet, + convert::{TryFrom, TryInto}, + fmt::Debug, + prelude::*, + vec::Vec, +}; + +pub use actions::*; +pub use base::{offchain, onchain, signature}; +pub use details_aggregator::*; +pub use pallet::*; +use weights::*; + +pub use base::*; +pub use controllers::Controller; +pub use keys::{DidKey, UncheckedDidKey, VerRelType}; +pub use service_endpoints::{ServiceEndpoint, ServiceEndpointId, ServiceEndpointOrigin}; + +pub(crate) mod actions; +pub(crate) mod base; +pub(crate) mod controllers; +pub(crate) mod details_aggregator; +pub(crate) mod keys; +pub(crate) mod service_endpoints; +pub(crate) mod weights; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +#[cfg(test)] +pub mod tests; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use alloc::collections::BTreeMap; + use frame_support::{pallet_prelude::*, Blake2_128Concat, Identity}; + use frame_system::pallet_prelude::*; + + /// The module's configuration trait. + #[pallet::config] + pub trait Config: frame_system::Config + Limits { + /// The handler of a `DID` removal. + type OnDidRemoval: OnDidRemoval; + + /// The overarching event type. + type RuntimeEvent: From> + + IsType<::RuntimeEvent> + + Into<::RuntimeEvent>; + } + + #[pallet::event] + pub enum Event { + OffChainDidAdded(Did, OffChainDidDocRef), + OffChainDidUpdated(Did, OffChainDidDocRef), + OffChainDidRemoved(Did), + OnChainDidAdded(Did), + DidKeysAdded(Did), + DidKeysRemoved(Did), + DidControllersAdded(Did), + DidControllersRemoved(Did), + DidServiceEndpointAdded(Did), + DidServiceEndpointRemoved(Did), + OnChainDidRemoved(Did), + } + + /// Error for the DID module. + #[pallet::error] + #[derive(PartialEq, Eq, Clone)] + pub enum Error { + /// Given public key is not of the correct size + PublicKeySizeIncorrect, + /// There is already a DID with same value + DidAlreadyExists, + /// There is no such DID registered + DidDoesNotExist, + /// Signature type does not match public key type + IncompatSigPubkey, + /// Signature by DID failed verification + InvalidSignature, + NotAnOffChainDid, + DidNotOwnedByAccount, + NoControllerProvided, + /// The provided key type is not comptaible with the provided verification relationship + IncompatibleVerificationRelation, + CannotGetDetailForOffChainDid, + CannotGetDetailForOnChainDid, + EmptyPayload, + IncorrectNonce, + /// Only controller of a DID can update the DID Doc + OnlyControllerCanUpdate, + NoKeyForDid, + NoControllerForDid, + /// The key does not have the required verification relationship + InsufficientVerificationRelationship, + ControllerIsAlreadyAdded, + InvalidServiceEndpoint, + ServiceEndpointAlreadyExists, + ServiceEndpointDoesNotExist, + KeyAgreementCantBeUsedForSigning, + SigningKeyCantBeUsedForKeyAgreement, + } + + impl From for Error { + fn from(NonceError::IncorrectNonce: NonceError) -> Self { + Self::IncorrectNonce + } + } + + impl From for Error { + fn from(VerificationError::IncompatibleKey(_, _): VerificationError) -> Self { + Self::IncompatSigPubkey + } + } + + #[pallet::pallet] + pub struct Pallet(_); + + /// Stores details of off-chain and on-chain DIDs + #[pallet::storage] + #[pallet::getter(fn did)] + pub type Dids = StorageMap<_, Blake2_128Concat, Did, StoredDidDetails>; + + /// Stores keys of a DID as (DID, IncId) -> DidKey. Does not check if the same key is being + /// added multiple times to the same DID. + #[pallet::storage] + #[pallet::getter(fn did_key)] + pub type DidKeys = StorageDoubleMap<_, Blake2_128Concat, Did, Identity, IncId, DidKey>; + + /// Stores controlled - controller pairs of a DID as (DID, DID) -> zero-sized record. If a + /// record exists, then the controller is bound. + #[pallet::storage] + #[pallet::getter(fn bound_controller)] + pub type DidControllers = + StorageDoubleMap<_, Blake2_128Concat, Did, Blake2_128Concat, Controller, ()>; + + /// Stores service endpoints of a DID as (DID, endpoint id) -> ServiceEndpoint. + #[pallet::storage] + #[pallet::getter(fn did_service_endpoints)] + pub type DidServiceEndpoints = StorageDoubleMap< + _, + Blake2_128Concat, + Did, + Blake2_128Concat, + ServiceEndpointId, + ServiceEndpoint, + >; + + #[pallet::storage] + #[pallet::getter(fn storage_version)] + pub type Version = StorageValue<_, common::StorageVersion, ValueQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub dids: BTreeMap, + pub _marker: PhantomData, + } + + impl Default for GenesisConfig { + fn default() -> Self { + GenesisConfig { dids: Default::default(), _marker: PhantomData } + } + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) { + debug_assert!({ + let dedup: BTreeSet<&Did> = self.dids.keys().collect(); + self.dids.len() == dedup.len() + }); + debug_assert!({ self.dids.iter().all(|(_, key)| key.can_control()) }); + + for (did, key) in &self.dids { + let mut key_id = IncId::new(); + key_id.inc(); + let did_details = + StoredOnChainDidDetails::new(OnChainDidDetails::new(key_id, 1u32, 1u32)); + + >::insert_did_details(*did, did_details); + DidKeys::::insert(did, key_id, key); + DidControllers::::insert(did, Controller(*did), ()); + } + + Version::::put(common::StorageVersion::MultiKey); + } + } + + #[pallet::call] + impl Pallet { + #[pallet::weight(SubstrateWeight::::new_offchain(did_doc_ref.len()))] + #[pallet::call_index(0)] + pub fn new_offchain( + origin: OriginFor, + did: Did, + did_doc_ref: OffChainDidDocRef, + ) -> DispatchResult { + // Only `did_owner` can update or remove this DID + let did_owner = ensure_signed(origin)?; + + Self::new_offchain_(did_owner, did, did_doc_ref) + } + + #[pallet::weight(SubstrateWeight::::set_offchain_did_doc_ref(did_doc_ref.len()))] + #[pallet::call_index(1)] + pub fn set_offchain_did_doc_ref( + origin: OriginFor, + did: Did, + did_doc_ref: OffChainDidDocRef, + ) -> DispatchResult { + let caller = ensure_signed(origin)?; + + Self::set_offchain_did_doc_ref_(caller, did, did_doc_ref) + } + + #[pallet::weight(SubstrateWeight::::remove_offchain_did())] + #[pallet::call_index(2)] + pub fn remove_offchain_did(origin: OriginFor, did: Did) -> DispatchResult { + let caller = ensure_signed(origin)?; + + Self::remove_offchain_did_(caller, did) + } + + /// Create new DID. + /// At least 1 control key or 1 controller must be provided. + /// If any supplied key has an empty `ver_rel`, then it will use all verification + /// relationships available for its key type. + #[pallet::weight(SubstrateWeight::::new_onchain(keys.len() as u32, controllers.len() as u32))] + #[pallet::call_index(3)] + pub fn new_onchain( + origin: OriginFor, + did: Did, + keys: Vec, + controllers: BTreeSet, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::new_onchain_(did, keys, controllers) + } + + /// Add more keys from DID doc. + /// **Does not** check if the key was already added. + #[pallet::weight(SubstrateWeight::::add_keys(keys, sig))] + #[pallet::call_index(4)] + pub fn add_keys( + origin: OriginFor, + keys: AddKeys, + sig: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_signed_action_from_controller(Self::add_keys_, keys, sig) + } + + /// Remove keys from DID doc. This is an atomic operation meaning that it will either remove + /// all keys or do nothing. **Note that removing all keys might make DID unusable**. + #[pallet::weight(SubstrateWeight::::remove_keys(keys, sig))] + #[pallet::call_index(5)] + pub fn remove_keys( + origin: OriginFor, + keys: RemoveKeys, + sig: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_signed_action_from_controller(Self::remove_keys_, keys, sig) + } + + /// Add new controllers to the signer DID. + /// **Does not** require provided controllers to + /// - have any key + /// - exist on- or off-chain + #[pallet::weight(SubstrateWeight::::add_controllers(controllers, sig))] + #[pallet::call_index(6)] + pub fn add_controllers( + origin: OriginFor, + controllers: AddControllers, + sig: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_signed_action_from_controller(Self::add_controllers_, controllers, sig) + } + + /// Remove controllers from the signer DID. + /// This is an atomic operation meaning that it will either remove all keys or do nothing. + /// **Note that removing all controllers might make DID unusable**. + #[pallet::weight(SubstrateWeight::::remove_controllers(controllers, sig))] + #[pallet::call_index(7)] + pub fn remove_controllers( + origin: OriginFor, + controllers: RemoveControllers, + sig: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_signed_action_from_controller( + Self::remove_controllers_, + controllers, + sig, + ) + } + + /// Add a single service endpoint to the signer DID. + #[pallet::weight(SubstrateWeight::::add_service_endpoint(service_endpoint, sig))] + #[pallet::call_index(8)] + pub fn add_service_endpoint( + origin: OriginFor, + service_endpoint: AddServiceEndpoint, + sig: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_signed_action_from_controller( + Self::add_service_endpoint_, + service_endpoint, + sig, + ) + } + + /// Remove a single service endpoint. + #[pallet::weight(SubstrateWeight::::remove_service_endpoint(service_endpoint, sig))] + #[pallet::call_index(9)] + pub fn remove_service_endpoint( + origin: OriginFor, + service_endpoint: RemoveServiceEndpoint, + sig: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_signed_action_from_controller( + Self::remove_service_endpoint_, + service_endpoint, + sig, + ) + } + + /// Remove the on-chain DID along with its keys, controllers, service endpoints and BBS+ + /// keys. Other DID-controlled entities won't be removed. + /// However, the authorization logic ensures that once a DID is removed, it loses its + /// ability to control any DID. + #[pallet::weight(SubstrateWeight::::remove_onchain_did(removal, sig))] + #[pallet::call_index(10)] + pub fn remove_onchain_did( + origin: OriginFor, + removal: DidRemoval, + sig: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_signed_removable_action_from_controller( + Self::remove_onchain_did_, + removal, + sig, + ) + } + + /// Adds `StateChange` and `AggregatedDidDetailsResponse` to the metadata. + #[doc(hidden)] + #[pallet::weight(::DbWeight::get().writes(10))] + #[pallet::call_index(11)] + pub fn noop( + _o: OriginFor, + _s: common::StateChange<'static, T>, + _d: AggregatedDidDetailsResponse, + ) -> DispatchResult { + Err(DispatchError::BadOrigin) + } + } +} + +pub trait OnDidRemoval { + fn on_remove_did(did: Did) -> Weight; +} + +impl OnDidRemoval for () { + fn on_remove_did(_: Did) -> Weight { + Default::default() + } +} + +crate::impl_tuple!(OnDidRemoval::on_remove_did(did: Did) -> Weight => using saturating_add for A B); +crate::impl_tuple!(OnDidRemoval::on_remove_did(did: Did) -> Weight => using saturating_add for A B C); +crate::impl_tuple!(OnDidRemoval::on_remove_did(did: Did) -> Weight => using saturating_add for A B C D); +crate::impl_tuple!(OnDidRemoval::on_remove_did(did: Did) -> Weight => using saturating_add for A B C D E); + +impl SubstrateWeight { + fn add_keys(keys: &AddKeys, DidSignature { sig, .. }: &DidSignature) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::add_keys_sr25519, + SigValue::Ed25519(_) => Self::add_keys_ed25519, + }(keys.len())) + } + + fn remove_keys( + keys: &RemoveKeys, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_keys_sr25519, + SigValue::Ed25519(_) => Self::remove_keys_ed25519, + }(keys.len())) + } + + fn add_controllers( + controllers: &AddControllers, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::add_controllers_sr25519, + SigValue::Ed25519(_) => Self::add_controllers_ed25519, + }(controllers.len())) + } + + fn remove_controllers( + controllers: &RemoveControllers, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_controllers_sr25519, + SigValue::Ed25519(_) => Self::remove_controllers_ed25519, + }(controllers.len())) + } + + fn add_service_endpoint( + AddServiceEndpoint { id, endpoint, .. }: &AddServiceEndpoint, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::add_service_endpoint_sr25519, + SigValue::Ed25519(_) => Self::add_service_endpoint_ed25519, + })( + endpoint.origins.len() as u32, + endpoint + .origins + .iter() + .map(|v| v.len() as u32) + .sum::() + .checked_div_ceil(endpoint.origins.len() as u32) + .unwrap_or(0), + id.len() as u32, + ) + } + + fn remove_service_endpoint( + RemoveServiceEndpoint { id, .. }: &RemoveServiceEndpoint, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_service_endpoint_sr25519, + SigValue::Ed25519(_) => Self::remove_service_endpoint_ed25519, + }(id.len() as u32)) + } + + fn remove_onchain_did( + _: &DidRemoval, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_onchain_did_sr25519, + SigValue::Ed25519(_) => Self::remove_onchain_did_ed25519, + }()) + } +} diff --git a/pallets/did/src/modules/did/service_endpoints.rs b/pallets/did/src/modules/did/service_endpoints.rs new file mode 100644 index 0000000..3b492a1 --- /dev/null +++ b/pallets/did/src/modules/did/service_endpoints.rs @@ -0,0 +1,108 @@ +use super::*; +use crate::{ + common::Limits, deposit_indexed_event, impl_bits_conversion, impl_wrapper, + impl_wrapper_type_info, +}; +use codec::{Decode, Encode, MaxEncodedLen}; +use sp_runtime::BoundedVec; + +/// `DID`'s service endpoint. +#[derive( + Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct ServiceEndpoint { + pub types: ServiceEndpointType, + pub origins: BoundedVec, T::MaxDidServiceEndpointOrigins>, +} + +/// `DID`'s service endpoint id. +#[derive( + Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct ServiceEndpointId(pub BoundedBytes); + +impl_wrapper!(ServiceEndpointId(BoundedBytes)); + +/// `DID`'s service endpoint origin. +#[derive( + Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct ServiceEndpointOrigin(pub BoundedBytes); + +impl_wrapper!(ServiceEndpointOrigin(BoundedBytes)); + +bitflags::bitflags! { + /// Different service endpoint types specified in the DID spec here https://www.w3.org/TR/did-core/#services + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(try_from = "u16", into = "u16"))] + pub struct ServiceEndpointType: u16 { + /// No service endpoint set. + const NONE = 0; + const LINKED_DOMAINS = 0b0001; + } +} + +impl_bits_conversion! { ServiceEndpointType from u16 } +impl_wrapper_type_info! { ServiceEndpointType(u16) } + +impl ServiceEndpoint { + pub fn is_valid(&self) -> bool { + !self.types.is_empty() && + !self.origins.is_empty() && + !self.origins.iter().any(|origin| origin.is_empty()) + } +} + +impl Pallet { + pub(crate) fn add_service_endpoint_( + AddServiceEndpoint { did, id, endpoint, .. }: AddServiceEndpoint, + _: &mut OnChainDidDetails, + ) -> DispatchResult { + ensure!(!id.is_empty(), Error::::InvalidServiceEndpoint); + ensure!(endpoint.is_valid(), Error::::InvalidServiceEndpoint); + ensure!( + Self::did_service_endpoints(did, &id).is_none(), + Error::::ServiceEndpointAlreadyExists + ); + + DidServiceEndpoints::::insert(did, id, endpoint); + + deposit_indexed_event!(DidServiceEndpointAdded(did)); + Ok(()) + } + + pub(crate) fn remove_service_endpoint_( + RemoveServiceEndpoint { did, id, .. }: RemoveServiceEndpoint, + _: &mut OnChainDidDetails, + ) -> DispatchResult { + ensure!(!id.is_empty(), Error::::InvalidServiceEndpoint); + ensure!( + Self::did_service_endpoints(did, &id).is_some(), + Error::::ServiceEndpointDoesNotExist + ); + + DidServiceEndpoints::::remove(did, id); + + deposit_indexed_event!(DidServiceEndpointRemoved(did)); + Ok(()) + } +} diff --git a/pallets/did/src/modules/did/tests.rs b/pallets/did/src/modules/did/tests.rs new file mode 100644 index 0000000..bfaf370 --- /dev/null +++ b/pallets/did/src/modules/did/tests.rs @@ -0,0 +1,1982 @@ +use super::*; +use crate::common::ToStateChange; + +use crate::{ + common::SigValue, + did::{ + keys::{DidKeyError, UncheckedDidKey}, + service_endpoints::{ServiceEndpointOrigin, ServiceEndpointType}, + }, + tests::common::*, +}; +use frame_support::{assert_err, assert_noop, assert_ok}; +use frame_system::Origin; +use sp_core::{ed25519, sr25519, Pair}; + +fn not_key_agreement(key: &DidKey) { + assert!(key.can_sign()); + assert!(key.can_authenticate()); + assert!(key.can_control()); + assert!(key.can_authenticate_or_control()); + assert!(!key.for_key_agreement()); +} + +fn only_key_agreement(key: &DidKey) { + assert!(!key.can_sign()); + assert!(!key.can_authenticate()); + assert!(!key.can_control()); + assert!(!key.can_authenticate_or_control()); + assert!(key.for_key_agreement()); +} + +pub fn check_did_detail( + did: &Did, + last_key_id: u32, + active_controller_keys: u32, + active_controllers: u32, + nonce: ::Nonce, +) { + let did_detail = DIDModule::onchain_did_details(did).unwrap(); + assert_eq!(did_detail.data().last_key_id, last_key_id.into()); + assert_eq!(did_detail.data().active_controller_keys, active_controller_keys); + assert_eq!(did_detail.data().active_controllers, active_controllers); + assert_eq!(did_detail.nonce, nonce); +} + +/// Ensure that all keys in storage corresponding to the DID are deleted. This check should be +/// performed when a DID is removed. +fn ensure_onchain_did_gone(did: &Did) { + assert!(DIDModule::did(did).is_none()); + let mut i = 0; + for (_, _) in DidKeys::::iter_prefix(did) { + i += 1; + } + assert_eq!(i, 0); + for (_, _) in DidControllers::::iter_prefix(did) { + i += 1; + } + assert_eq!(i, 0); + for (_, _) in DidServiceEndpoints::::iter_prefix(did) { + i += 1; + } + assert_eq!(i, 0); +} + +#[test] +fn offchain_did() { + // Creating an off-chain DID + ext().execute_with(|| { + let alice = 1u64; + let did: Did = [5; Did::BYTE_SIZE].into(); + let doc_ref = OffChainDidDocRef::Custom(vec![129; 60].try_into().unwrap()); + + assert!(vec![129; 300].try_into().map(OffChainDidDocRef::::Custom).is_err()); + + // Add a DID + assert_ok!(DIDModule::new_offchain(RuntimeOrigin::signed(alice), did, doc_ref.clone())); + + // Try to add the same DID and same uri again and fail + assert_noop!( + DIDModule::new_offchain(RuntimeOrigin::signed(alice), did, doc_ref.clone()), + Error::::DidAlreadyExists + ); + + // Try to add the same DID and different uri and fail + let doc_ref_1 = OffChainDidDocRef::URL(vec![205; 99].try_into().unwrap()); + assert_noop!( + DIDModule::new_offchain(RuntimeOrigin::signed(alice), did, doc_ref_1), + Error::::DidAlreadyExists + ); + + assert!(DIDModule::is_offchain_did(&did).unwrap()); + assert!(!DIDModule::is_onchain_did(&did).unwrap()); + + assert_noop!( + DIDModule::onchain_did_details(&did), + Error::::CannotGetDetailForOnChainDid + ); + + let did_detail_storage = Dids::::get(did).unwrap(); + let OffChainDidDetails { account_id: owner, doc_ref: fetched_ref } = + did_detail_storage.into_offchain().unwrap(); + assert_eq!(owner, alice); + assert_eq!(fetched_ref, doc_ref); + + let bob = 2u64; + let new_ref = OffChainDidDocRef::CID(vec![235; 99].try_into().unwrap()); + assert_noop!( + DIDModule::set_offchain_did_doc_ref(RuntimeOrigin::signed(bob), did, new_ref.clone()), + Error::::DidNotOwnedByAccount + ); + + assert_ok!(DIDModule::set_offchain_did_doc_ref( + RuntimeOrigin::signed(alice), + did, + new_ref.clone() + )); + let did_detail_storage = Dids::::get(did).unwrap(); + let fetched_ref = did_detail_storage.into_offchain().unwrap().doc_ref; + assert_eq!(fetched_ref, new_ref); + + assert_noop!( + DIDModule::remove_offchain_did(RuntimeOrigin::signed(bob), did), + Error::::DidNotOwnedByAccount + ); + + assert_ok!(DIDModule::remove_offchain_did(RuntimeOrigin::signed(alice), did)); + assert!(Dids::::get(did).is_none()); + }); +} + +#[test] +fn onchain_keyless_did_creation() { + // Creating an on-chain DID with no keys but only controllers, i.e. DID is controlled by other + // DIDs + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [5; Did::BYTE_SIZE].into(); + let did_2: Did = [3; Did::BYTE_SIZE].into(); + let controller_1 = Controller([7; Did::BYTE_SIZE].into()); + let controller_2 = Controller([20; Did::BYTE_SIZE].into()); + + assert_noop!( + DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![], + vec![].into_iter().collect() + ), + Error::::NoControllerProvided + ); + + run_to_block(20); + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![].into_iter().collect(), + vec![controller_1].into_iter().collect() + )); + + assert!(!DIDModule::is_offchain_did(&did_1).unwrap()); + assert!(DIDModule::is_onchain_did(&did_1).unwrap()); + + assert!(!DIDModule::is_self_controlled(&did_1)); + assert!(!DIDModule::is_controller(&did_1, &controller_2)); + assert!(DIDModule::is_controller(&did_1, &controller_1)); + + check_did_detail(&did_1, 0, 0, 1, 20); + + assert_noop!( + DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![].into_iter().collect(), + vec![controller_1].into_iter().collect() + ), + Error::::DidAlreadyExists + ); + + run_to_block(55); + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![].into_iter().collect(), + vec![Controller(did_1), controller_1, controller_2].into_iter().collect() + )); + + assert!(!DIDModule::is_offchain_did(&did_2).unwrap()); + assert!(DIDModule::is_onchain_did(&did_2).unwrap()); + + assert!(!DIDModule::is_self_controlled(&did_2)); + assert!(DIDModule::is_controller(&did_2, &Controller(did_1))); + assert!(DIDModule::is_controller(&did_2, &controller_1)); + assert!(DIDModule::is_controller(&did_2, &controller_2)); + + check_did_detail(&did_2, 0, 0, 3, 55); + }); +} + +#[test] +fn onchain_keyed_did_creation_with_self_control() { + // Creating an on-chain DID with keys but no other controllers + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [5; Did::BYTE_SIZE].into(); + let did_2: Did = [4; Did::BYTE_SIZE].into(); + let did_3: Did = [3; Did::BYTE_SIZE].into(); + let did_4: Did = [2; Did::BYTE_SIZE].into(); + let did_5: Did = [11; Did::BYTE_SIZE].into(); + let did_6: Did = [111; Did::BYTE_SIZE].into(); + let did_8: Did = [82; Did::BYTE_SIZE].into(); + let did_9: Did = [83; Did::BYTE_SIZE].into(); + let did_10: Did = [84; Did::BYTE_SIZE].into(); + let did_11: Did = [85; Did::BYTE_SIZE].into(); + + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + run_to_block(5); + + // DID controls itself when adding keys capable of signing without specifying any + // verificatiion relationship + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::NONE)], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_1)); + check_did_detail(&did_1, 1, 1, 1, 5); + + let key_1 = DidKeys::::get(did_1, IncId::from(1u32)).unwrap(); + not_key_agreement(&key_1); + + run_to_block(6); + + // DID controls itself and specifies another controller as well + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::NONE)], + vec![did_1].into_iter().map(Controller).collect() + )); + assert!(DIDModule::is_self_controlled(&did_2)); + check_did_detail(&did_2, 1, 1, 2, 6); + + let key_2 = DidKeys::::get(did_2, IncId::from(1u32)).unwrap(); + not_key_agreement(&key_2); + + run_to_block(7); + + // Adding x25519 key does not make the DID self controlled + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_4, + vec![UncheckedDidKey::new(PublicKey::x25519(pk_ed), VerRelType::NONE)], + vec![Controller(did_3)].into_iter().collect() + )); + assert!(!DIDModule::is_self_controlled(&did_4)); + check_did_detail(&did_4, 1, 0, 1, 8); + + // x25519 key cannot be added for incompatible relationship types + for add in [VerRelType::NONE, VerRelType::KEY_AGREEMENT] { + for vr in vec![ + VerRelType::AUTHENTICATION, + VerRelType::ASSERTION, + VerRelType::CAPABILITY_INVOCATION, + VerRelType::ALL_FOR_SIGNING, + ] + .into_iter() + .map(|val| val | add) + { + let key = UncheckedDidKey::new(PublicKey::x25519(pk_ed), vr); + + assert_noop!( + DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_10, + vec![key], + vec![Controller(did_3)].into_iter().collect() + ), + Error::::KeyAgreementCantBeUsedForSigning + ); + } + } + + for pk in vec![PublicKey::sr25519(pk_sr), PublicKey::ed25519(pk_ed)] { + for vr in vec![ + VerRelType::AUTHENTICATION, + VerRelType::ASSERTION, + VerRelType::CAPABILITY_INVOCATION, + VerRelType::NONE, + VerRelType::ALL_FOR_SIGNING, + ] + .into_iter() + { + let key = UncheckedDidKey::new(pk.clone(), VerRelType::KEY_AGREEMENT | vr); + + assert_noop!( + DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_10, + vec![key], + vec![Controller(did_3)].into_iter().collect() + ), + Error::::SigningKeyCantBeUsedForKeyAgreement + ); + } + } + + let key_4 = DidKeys::::get(did_4, IncId::from(1u32)).unwrap(); + only_key_agreement(&key_4); + + run_to_block(10); + + // Add single key and specify relationship as `capabilityInvocation` + for (did, pk) in + vec![(did_5, PublicKey::sr25519(pk_sr)), (did_6, PublicKey::ed25519(pk_ed))] + { + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did, + vec![UncheckedDidKey::new(pk, VerRelType::CAPABILITY_INVOCATION)], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did)); + let key = DidKeys::::get(did, IncId::from(1u32)).unwrap(); + assert!(key.can_sign()); + assert!(!key.can_authenticate()); + assert!(key.can_control()); + assert!(key.can_authenticate_or_control()); + assert!(!key.for_key_agreement()); + check_did_detail(&did, 1, 1, 1, 10); + } + + run_to_block(13); + + // Add single key with single relationship and but do not specify relationship as + // `capabilityInvocation` + for (did, pk, vr) in vec![ + ([72; Did::BYTE_SIZE], PublicKey::sr25519(pk_sr), VerRelType::ASSERTION), + ([73; Did::BYTE_SIZE], PublicKey::ed25519(pk_ed), VerRelType::ASSERTION), + ([75; Did::BYTE_SIZE], PublicKey::sr25519(pk_sr), VerRelType::AUTHENTICATION), + ([76; Did::BYTE_SIZE], PublicKey::ed25519(pk_ed), VerRelType::AUTHENTICATION), + ] { + let did: Did = did.into(); + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did, + vec![UncheckedDidKey::new(pk, vr)], + vec![Controller(did_1)].into_iter().collect() + )); + assert!(!DIDModule::is_self_controlled(&did)); + let key = DidKeys::::get(did, IncId::from(1u32)).unwrap(); + assert!(key.can_sign()); + assert!(!key.can_control()); + if vr == VerRelType::AUTHENTICATION { + assert!(key.can_authenticate()); + assert!(key.can_authenticate_or_control()); + } + assert!(!key.for_key_agreement()); + check_did_detail(&did, 1, 0, 1, 13); + } + + run_to_block(19); + + // Add single key, specify multiple relationships and but do not specify relationship as + // `capabilityInvocation` + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_8, + vec![UncheckedDidKey::new( + PublicKey::ed25519(pk_ed), + VerRelType::AUTHENTICATION | VerRelType::ASSERTION + )], + vec![Controller(did_9)].into_iter().collect() + )); + assert!(!DIDModule::is_self_controlled(&did_8)); + let key_8 = DidKeys::::get(did_8, IncId::from(1u32)).unwrap(); + assert!(key_8.can_sign()); + assert!(key_8.can_authenticate()); + assert!(!key_8.can_control()); + check_did_detail(&did_8, 1, 0, 1, 19); + + run_to_block(20); + + // Add multiple keys and specify multiple relationships + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_9, + vec![ + UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::AUTHENTICATION), + UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::ASSERTION), + ], + vec![Controller(did_8)].into_iter().collect() + )); + assert!(!DIDModule::is_self_controlled(&did_9)); + let key_9_1 = DidKeys::::get(did_9, IncId::from(1u32)).unwrap(); + assert!(key_9_1.can_sign()); + assert!(key_9_1.can_authenticate()); + assert!(!key_9_1.can_control()); + let key_9_2 = DidKeys::::get(did_9, IncId::from(2u32)).unwrap(); + assert!(key_9_2.can_sign()); + assert!(!key_9_2.can_authenticate()); + assert!(!key_9_2.can_control()); + let key_9_3 = DidKeys::::get(did_9, IncId::from(3u32)).unwrap(); + assert!(key_9_3.can_sign()); + assert!(key_9_3.can_authenticate()); + assert!(!key_9_3.can_control()); + check_did_detail(&did_9, 3, 0, 1, 20); + + run_to_block(22); + + // Add multiple keys and specify multiple relationships + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_10, + vec![ + UncheckedDidKey::new( + PublicKey::ed25519(pk_ed), + VerRelType::AUTHENTICATION | VerRelType::ASSERTION + ), + UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::ASSERTION), + ], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_10)); + let key_10_1 = DidKeys::::get(did_10, IncId::from(1u32)).unwrap(); + assert!(key_10_1.can_sign()); + assert!(key_10_1.can_authenticate()); + assert!(!key_10_1.can_control()); + let key_10_2 = DidKeys::::get(did_10, IncId::from(2u32)).unwrap(); + assert!(key_10_2.can_sign()); + assert!(!key_10_2.can_authenticate()); + assert!(!key_10_2.can_control()); + let key_10_3 = DidKeys::::get(did_10, IncId::from(3u32)).unwrap(); + assert!(key_10_3.can_sign()); + assert!(!key_10_3.can_authenticate()); + assert!(key_10_3.can_control()); + check_did_detail(&did_10, 3, 1, 1, 22); + + run_to_block(23); + + // Add multiple keys, specify multiple relationships and other controllers as well + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_11, + vec![ + UncheckedDidKey::new( + PublicKey::ed25519(pk_ed), + VerRelType::AUTHENTICATION | VerRelType::ASSERTION + ), + UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::CAPABILITY_INVOCATION), + ], + vec![did_1, did_2].into_iter().map(Controller).collect() + )); + assert!(DIDModule::is_self_controlled(&did_11)); + let key_11_1 = DidKeys::::get(did_11, IncId::from(1u32)).unwrap(); + assert!(key_11_1.can_sign()); + assert!(key_11_1.can_authenticate()); + assert!(!key_11_1.can_control()); + let key_11_2 = DidKeys::::get(did_11, IncId::from(2u32)).unwrap(); + assert!(key_11_2.can_sign()); + assert!(!key_11_2.can_authenticate()); + assert!(key_11_2.can_control()); + check_did_detail(&did_11, 2, 1, 3, 23); + }); +} + +#[test] +fn onchain_keyed_did_creation_with_and_without_self_control() { + // Creating an on-chain DID with keys and other controllers + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + let did_3: Did = [54; Did::BYTE_SIZE].into(); + let did_4: Did = [55; Did::BYTE_SIZE].into(); + let did_5: Did = [56; Did::BYTE_SIZE].into(); + let did_6: Did = [57; Did::BYTE_SIZE].into(); + + let controller_1 = Controller([61; Did::BYTE_SIZE].into()); + let controller_2 = Controller([62; Did::BYTE_SIZE].into()); + let controller_3 = Controller([63; Did::BYTE_SIZE].into()); + let controller_4 = Controller([64; Did::BYTE_SIZE].into()); + + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + run_to_block(10); + + // DID does not control itself, some other DID does + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::AUTHENTICATION)], + vec![controller_1].into_iter().collect() + )); + assert!(!DIDModule::is_self_controlled(&did_1)); + assert!(DIDModule::is_controller(&did_1, &controller_1)); + check_did_detail(&did_1, 1, 0, 1, 10); + + run_to_block(11); + + // DID does not control itself, some other DID does + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::ASSERTION)], + vec![controller_2].into_iter().collect() + )); + assert!(!DIDModule::is_self_controlled(&did_2)); + assert!(DIDModule::is_controller(&did_2, &controller_2)); + check_did_detail(&did_2, 1, 0, 1, 11); + + run_to_block(12); + + // DID does not control itself, some other DID does + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_3, + vec![UncheckedDidKey::new(PublicKey::x25519(pk_ed), VerRelType::KEY_AGREEMENT)], + vec![controller_3].into_iter().collect() + )); + assert!(!DIDModule::is_self_controlled(&did_3)); + assert!(DIDModule::is_controller(&did_3, &controller_3)); + check_did_detail(&did_3, 1, 0, 1, 12); + + run_to_block(13); + + // DID does not control itself, some other DID does + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_4, + vec![ + UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::AUTHENTICATION), + UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::ASSERTION) + ], + vec![controller_4].into_iter().collect() + )); + assert!(!DIDModule::is_self_controlled(&did_4)); + assert!(DIDModule::is_controller(&did_4, &controller_4)); + check_did_detail(&did_4, 2, 0, 1, 13); + + run_to_block(14); + + // DID is controlled by itself and another DID as well + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_5, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::ASSERTION)], + vec![controller_1].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_5)); + assert!(DIDModule::is_controller(&did_5, &controller_1)); + check_did_detail(&did_5, 2, 1, 2, 14); + + run_to_block(15); + + // DID has 2 keys to control itself and another DID + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_6, + vec![UncheckedDidKey::new( + PublicKey::ed25519(pk_ed), + VerRelType::ASSERTION | VerRelType::CAPABILITY_INVOCATION + )], + vec![controller_1].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_6)); + assert!(DIDModule::is_controller(&did_6, &controller_1)); + check_did_detail(&did_6, 2, 2, 2, 15); + }); +} + +#[test] +fn add_keys_to_did() { + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + + let (pair_sr_1, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr_1 = pair_sr_1.public().0; + let (pair_sr_2, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr_2 = pair_sr_2.public().0; + let (pair_ed_1, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed_1 = pair_ed_1.public().0; + let (pair_ed_2, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed_2 = pair_ed_2.public().0; + + run_to_block(3); + + // Add keys to a DID that has not been registered yet should fail + let add_keys = AddKeys { + did: did_1, + keys: vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr_1), VerRelType::NONE)], + nonce: 4, + }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr_1); + assert_noop!( + DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + + run_to_block(5); + + // At least one key must be provided + let add_keys = AddKeys { did: did_1, keys: vec![], nonce: 5 }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr_1); + assert_noop!( + DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + let add_keys = AddKeys { + did: did_1, + keys: vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr_1), VerRelType::NONE)], + nonce: 5, + }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr_1); + assert_noop!( + DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![ + UncheckedDidKey::new(PublicKey::sr25519(pk_sr_1), VerRelType::NONE), + UncheckedDidKey::new(PublicKey::sr25519(pk_sr_2), VerRelType::NONE), + UncheckedDidKey::new(PublicKey::ed25519(pk_ed_2), VerRelType::AUTHENTICATION), + ], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_1)); + check_did_detail(&did_1, 3, 2, 1, 5); + + run_to_block(7); + + // This DID does not control itself + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed_1), VerRelType::AUTHENTICATION)], + vec![did_1].into_iter().map(Controller).collect() + )); + assert!(!DIDModule::is_self_controlled(&did_2)); + check_did_detail(&did_2, 1, 0, 1, 7); + + run_to_block(10); + + // x25519 key cannot be added for incompatible relationship types + for add in [VerRelType::NONE, VerRelType::KEY_AGREEMENT] { + for vr in vec![ + VerRelType::AUTHENTICATION, + VerRelType::ASSERTION, + VerRelType::CAPABILITY_INVOCATION, + VerRelType::ALL_FOR_SIGNING, + ] + .into_iter() + .map(|val| val | add) + { + let key = UncheckedDidKey::new(PublicKey::x25519(pk_ed), vr); + + let add_keys = AddKeys { did: did_2, keys: vec![key], nonce: 5 + 1 }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr_1); + assert_noop!( + DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + Error::::KeyAgreementCantBeUsedForSigning + ); + } + } + + for pk in vec![PublicKey::sr25519(pk_sr), PublicKey::ed25519(pk_ed)] { + for vr in vec![ + VerRelType::AUTHENTICATION, + VerRelType::ASSERTION, + VerRelType::CAPABILITY_INVOCATION, + VerRelType::NONE, + VerRelType::ALL_FOR_SIGNING, + ] + .into_iter() + { + let key = UncheckedDidKey::new(pk.clone(), VerRelType::KEY_AGREEMENT | vr); + + let add_keys = AddKeys { did: did_2, keys: vec![key], nonce: 5 + 1 }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr_1); + assert_noop!( + DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + Error::::SigningKeyCantBeUsedForKeyAgreement + ); + } + } + + // Add x25519 key + let add_keys = AddKeys { + did: did_2, + keys: vec![UncheckedDidKey::new(PublicKey::x25519(pk_ed_1), VerRelType::KEY_AGREEMENT)], + nonce: 5 + 1, + }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr_1); + assert_ok!(DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + assert!(!DIDModule::is_self_controlled(&did_2)); + check_did_detail(&did_2, 2, 0, 1, 7); + check_did_detail(&did_1, 3, 2, 1, 6); + + only_key_agreement(&DidKeys::::get(did_2, IncId::from(2u32)).unwrap()); + + // Add many keys + let add_keys = AddKeys { + did: did_2, + keys: vec![ + UncheckedDidKey::new(PublicKey::x25519(pk_sr_2), VerRelType::KEY_AGREEMENT), + UncheckedDidKey::new(PublicKey::ed25519(pk_ed_1), VerRelType::ASSERTION), + ], + nonce: 6 + 1, + }; + + // Controller uses a key without the capability to update DID + let sig = SigValue::ed25519(&add_keys.to_state_change().encode(), &pair_ed_2); + assert_noop!( + DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys.clone(), + DidSignature { did: Controller(did_1), key_id: 3u32.into(), sig } + ), + Error::::InsufficientVerificationRelationship + ); + + // Controller uses the correct key + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr_2); + assert_ok!(DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 2u32.into(), sig } + )); + assert!(!DIDModule::is_self_controlled(&did_2)); + check_did_detail(&did_2, 5, 0, 1, 7); + check_did_detail(&did_1, 3, 2, 1, 7); + DidKeys::::get(did_2, IncId::from(3u32)).unwrap(); + DidKeys::::get(did_2, IncId::from(4u32)).unwrap(); + DidKeys::::get(did_2, IncId::from(5u32)).unwrap(); + + let add_keys = AddKeys { + did: did_1, + keys: vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed_1), VerRelType::NONE)], + nonce: 7 + 1, + }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr_1); + assert_ok!(DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + + check_did_detail(&did_1, 4, 3, 1, 8); + DidKeys::::get(did_1, IncId::from(4u32)).unwrap() + }); +} + +#[test] +fn remove_keys_from_did() { + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + + let (pair_sr_1, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr_1 = pair_sr_1.public().0; + let (pair_sr_2, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr_2 = pair_sr_2.public().0; + let (pair_ed_1, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed_1 = pair_ed_1.public().0; + let (pair_ed_2, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed_2 = pair_ed_2.public().0; + + run_to_block(2); + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![ + UncheckedDidKey::new_with_all_relationships(PublicKey::sr25519(pk_sr_1)), + UncheckedDidKey::new_with_all_relationships(PublicKey::ed25519(pk_ed_1)), + UncheckedDidKey::new(PublicKey::ed25519(pk_ed_2), VerRelType::ASSERTION), + UncheckedDidKey::new(PublicKey::sr25519(pk_sr_2), VerRelType::AUTHENTICATION), + ], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_1)); + check_did_detail(&did_1, 4, 2, 1, 2); + + run_to_block(5); + + // This DID does not control itself + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed_1), VerRelType::AUTHENTICATION)], + vec![did_1].into_iter().map(Controller).collect() + )); + check_did_detail(&did_2, 1, 0, 1, 5); + + run_to_block(10); + + // Nonce should be 1 greater than existing 2, i.e. 3 + for nonce in [1, 2, 4, 5, 6, 7, 8, 10, 10000] { + let remove_keys = + RemoveKeys { did: did_2, keys: vec![1u32.into()].into_iter().collect(), nonce }; + let sig = SigValue::sr25519(&remove_keys.to_state_change().encode(), &pair_sr_1); + assert_noop!( + DIDModule::remove_keys( + RuntimeOrigin::signed(alice), + remove_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + NonceError::IncorrectNonce + ); + } + + // Since did_2 does not control itself, it cannot remove keys from itself + let remove_keys = + RemoveKeys { did: did_2, keys: vec![1u32.into()].into_iter().collect(), nonce: 5 + 1 }; + let sig = SigValue::ed25519(&remove_keys.to_state_change().encode(), &pair_ed_1); + assert_noop!( + DIDModule::remove_keys( + RuntimeOrigin::signed(alice), + remove_keys, + DidSignature { did: Controller(did_2), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + + let remove_keys = + RemoveKeys { did: did_1, keys: vec![1u32.into()].into_iter().collect(), nonce: 2 + 1 }; + let sig = SigValue::ed25519(&remove_keys.to_state_change().encode(), &pair_ed_1); + assert_ok!(DIDModule::remove_keys( + RuntimeOrigin::signed(alice), + remove_keys, + DidSignature { did: Controller(did_1), key_id: 2u32.into(), sig } + )); + check_did_detail(&did_1, 4, 1, 1, 3); + + let remove_keys = + RemoveKeys { did: did_1, keys: vec![3u32.into()].into_iter().collect(), nonce: 3 + 1 }; + let sig = SigValue::ed25519(&remove_keys.to_state_change().encode(), &pair_ed_1); + assert_ok!(DIDModule::remove_keys( + RuntimeOrigin::signed(alice), + remove_keys, + DidSignature { did: Controller(did_1), key_id: 2u32.into(), sig } + )); + check_did_detail(&did_1, 4, 1, 1, 4); + + let remove_keys = + RemoveKeys { did: did_2, keys: vec![1u32.into()].into_iter().collect(), nonce: 4 + 1 }; + let sig = SigValue::ed25519(&remove_keys.to_state_change().encode(), &pair_ed_1); + assert_ok!(DIDModule::remove_keys( + RuntimeOrigin::signed(alice), + remove_keys, + DidSignature { did: Controller(did_1), key_id: 2u32.into(), sig } + )); + check_did_detail(&did_1, 4, 1, 1, 5); + check_did_detail(&did_2, 1, 0, 1, 5); + + run_to_block(30); + + // This DID is controlled by itself and another DID + let did_5: Did = [54; Did::BYTE_SIZE].into(); + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_5, + vec![UncheckedDidKey::new_with_all_relationships(PublicKey::sr25519(pk_sr_1))] + .into_iter() + .collect(), + vec![did_1].into_iter().map(Controller).collect() + )); + check_did_detail(&did_5, 1, 1, 2, 30); + + let remove_keys = + RemoveKeys { did: did_5, keys: vec![1u32.into()].into_iter().collect(), nonce: 5 + 1 }; + let sig = SigValue::ed25519(&remove_keys.to_state_change().encode(), &pair_ed_1); + assert_ok!(DIDModule::remove_keys( + RuntimeOrigin::signed(alice), + remove_keys, + DidSignature { did: Controller(did_1), key_id: 2u32.into(), sig } + )); + check_did_detail(&did_5, 1, 0, 1, 30); + check_did_detail(&did_1, 4, 1, 1, 6); + + let remove_controllers = RemoveControllers { + did: did_5, + controllers: vec![did_1].into_iter().map(Controller).collect(), + nonce: 6 + 1, + }; + let sig = SigValue::ed25519(&remove_controllers.to_state_change().encode(), &pair_ed_1); + assert_ok!(DIDModule::remove_controllers( + RuntimeOrigin::signed(alice), + remove_controllers, + DidSignature { did: Controller(did_1), key_id: 2u32.into(), sig } + )); + check_did_detail(&did_5, 1, 0, 0, 30); + check_did_detail(&did_1, 4, 1, 1, 7); + }); +} + +#[test] +fn remove_controllers_from_did() { + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + let did_3: Did = [53; Did::BYTE_SIZE].into(); + + let (pair_sr_1, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr_1 = pair_sr_1.public().0; + let (pair_sr_2, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr_2 = pair_sr_2.public().0; + let (pair_ed_1, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed_1 = pair_ed_1.public().0; + let (pair_ed_2, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed_2 = pair_ed_2.public().0; + + run_to_block(2); + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![ + UncheckedDidKey::new_with_all_relationships(PublicKey::sr25519(pk_sr_1)), + UncheckedDidKey::new_with_all_relationships(PublicKey::ed25519(pk_ed_1)), + UncheckedDidKey::new(PublicKey::ed25519(pk_ed_2), VerRelType::ASSERTION), + UncheckedDidKey::new(PublicKey::sr25519(pk_sr_2), VerRelType::AUTHENTICATION), + ], + vec![].into_iter().map(Controller).collect() + )); + assert!(DIDModule::is_self_controlled(&did_1)); + check_did_detail(&did_1, 4, 2, 1, 2); + + run_to_block(5); + + // This DID does not control itself + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed_1), VerRelType::AUTHENTICATION)], + vec![did_1].into_iter().map(Controller).collect() + )); + check_did_detail(&did_2, 1, 0, 1, 5); + + // This DID has no keys but controlled by other DIDs + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_3, + vec![].into_iter().collect(), + vec![did_1, did_2].into_iter().map(Controller).collect() + )); + check_did_detail(&did_3, 0, 0, 2, 5); + + run_to_block(10); + + // Nonce should be 1 greater than existing 2, i.e. 3 + for nonce in [1, 2, 4, 5, 10, 10000] { + let remove_controllers = RemoveControllers { + did: did_2, + controllers: vec![did_1].into_iter().map(Controller).collect(), + nonce, + }; + let sig = SigValue::sr25519(&remove_controllers.to_state_change().encode(), &pair_sr_1); + assert_noop!( + DIDModule::remove_controllers( + RuntimeOrigin::signed(alice), + remove_controllers, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + NonceError::IncorrectNonce + ); + } + + // Trying to remove a non-existent controller should fail + let remove_controllers = RemoveControllers { + did: did_1, + controllers: vec![did_1, did_2].into_iter().map(Controller).collect(), + nonce: 3, + }; + let sig = SigValue::ed25519(&remove_controllers.to_state_change().encode(), &pair_ed_1); + assert_noop!( + DIDModule::remove_controllers( + RuntimeOrigin::signed(alice), + remove_controllers, + DidSignature { did: Controller(did_1), key_id: 2u32.into(), sig } + ), + Error::::NoControllerForDid + ); + + // Since did_2 does not control itself, it cannot remove controllers from itself + let remove_controllers = RemoveControllers { + did: did_1, + controllers: vec![did_1].into_iter().map(Controller).collect(), + nonce: 5 + 1, + }; + let sig = SigValue::ed25519(&remove_controllers.to_state_change().encode(), &pair_ed_1); + assert_noop!( + DIDModule::remove_controllers( + RuntimeOrigin::signed(alice), + remove_controllers, + DidSignature { did: Controller(did_2), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + + let remove_controllers = RemoveControllers { + did: did_1, + controllers: vec![did_1].into_iter().map(Controller).collect(), + nonce: 3, + }; + let sig = SigValue::ed25519(&remove_controllers.to_state_change().encode(), &pair_ed_1); + assert_ok!(DIDModule::remove_controllers( + RuntimeOrigin::signed(alice), + remove_controllers, + DidSignature { did: Controller(did_1), key_id: 2u32.into(), sig } + )); + assert!(!DIDModule::is_self_controlled(&did_1)); + check_did_detail(&did_1, 4, 2, 0, 3); + + assert!(DIDModule::is_controller(&did_3, &Controller(did_2))); + let remove_controllers = RemoveControllers { + did: did_3, + controllers: vec![did_2].into_iter().map(Controller).collect(), + nonce: 3 + 1, + }; + let sig = SigValue::sr25519(&remove_controllers.to_state_change().encode(), &pair_sr_1); + assert_ok!(DIDModule::remove_controllers( + RuntimeOrigin::signed(alice), + remove_controllers, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + assert!(!DIDModule::is_controller(&did_3, &Controller(did_2))); + check_did_detail(&did_1, 4, 2, 0, 4); + check_did_detail(&did_3, 0, 0, 1, 5); + }); +} + +#[test] +fn add_controllers_to_did() { + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + let did_3: Did = [53; Did::BYTE_SIZE].into(); + + // Add keys to a DID that has not been registered yet should fail + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + run_to_block(5); + + // At least one controller must be provided + let add_controllers = + AddControllers { did: did_1, controllers: vec![].into_iter().collect(), nonce: 5 }; + let sig = SigValue::sr25519(&add_controllers.to_state_change().encode(), &pair_sr); + assert_noop!( + DIDModule::add_controllers( + RuntimeOrigin::signed(alice), + add_controllers, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + + let add_controllers = AddControllers { + did: did_1, + controllers: vec![did_2].into_iter().map(Controller).collect(), + nonce: 5, + }; + let sig = SigValue::sr25519(&add_controllers.to_state_change().encode(), &pair_sr); + assert_noop!( + DIDModule::add_controllers( + RuntimeOrigin::signed(alice), + add_controllers, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + + // This DID controls itself + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::AUTHENTICATION),], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_1)); + check_did_detail(&did_1, 2, 1, 1, 5); + + run_to_block(10); + // This DID does not control itself + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::AUTHENTICATION)], + vec![did_1].into_iter().map(Controller).collect() + )); + assert!(!DIDModule::is_self_controlled(&did_2)); + assert!(DIDModule::is_controller(&did_2, &Controller(did_1))); + check_did_detail(&did_2, 1, 0, 1, 10); + + run_to_block(15); + + // Since did_2 does not control itself, it cannot controller to itself + let add_controllers = AddControllers { + did: did_2, + controllers: vec![did_3].into_iter().map(Controller).collect(), + nonce: 10 + 1, + }; + let sig = SigValue::sr25519(&add_controllers.to_state_change().encode(), &pair_sr); + assert_noop!( + DIDModule::add_controllers( + RuntimeOrigin::signed(alice), + add_controllers, + DidSignature { did: Controller(did_2), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + }); +} + +#[test] +fn becoming_controller() { + // A DID that was not a controller of its DID during creation can become one + // when either a key is added with `capabilityInvocation` + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + run_to_block(5); + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::NONE)], + vec![].into_iter().collect() + )); + check_did_detail(&did_1, 1, 1, 1, 5); + + run_to_block(10); + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::x25519(pk_ed), VerRelType::KEY_AGREEMENT)], + vec![did_1].into_iter().map(Controller).collect() + )); + assert!(!DIDModule::is_self_controlled(&did_2)); + check_did_detail(&did_2, 1, 0, 1, 10); + + run_to_block(15); + + let add_keys = AddKeys { + did: did_2, + keys: vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::ASSERTION)], + nonce: 5 + 1, + }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr); + assert_ok!(DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + assert!(!DIDModule::is_self_controlled(&did_2)); + check_did_detail(&did_2, 2, 0, 1, 10); + check_did_detail(&did_1, 1, 1, 1, 6); + }); +} + +#[test] +fn any_controller_can_update() { + // For a DID with many controllers, any controller can update it by adding keys, controllers. + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + let did_4: Did = [54; Did::BYTE_SIZE].into(); + + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + run_to_block(3); + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::NONE)], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_1)); + check_did_detail(&did_1, 1, 1, 1, 3); + + run_to_block(5); + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::NONE)], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_2)); + check_did_detail(&did_2, 1, 1, 1, 5); + + run_to_block(14); + + let add_controllers = AddControllers { + did: did_4, + controllers: vec![did_1].into_iter().map(Controller).collect(), + nonce: 5 + 1, + }; + let sig = SigValue::sr25519(&add_controllers.to_state_change().encode(), &pair_sr); + assert_ok!(DIDModule::add_controllers( + RuntimeOrigin::signed(alice), + add_controllers, + DidSignature { did: Controller(did_2), key_id: 1u32.into(), sig } + )); + check_did_detail(&did_4, 1, 1, 3, 7); + check_did_detail(&did_2, 1, 1, 1, 6); + + run_to_block(15); + + let add_keys = AddKeys { + did: did_4, + keys: vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::NONE)], + nonce: 3 + 1, + }; + let sig = SigValue::ed25519(&add_keys.to_state_change().encode(), &pair_ed); + assert_ok!(DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + check_did_detail(&did_4, 2, 2, 3, 7); + check_did_detail(&did_1, 1, 1, 1, 4); + }); +} + +#[test] +fn service_endpoints() { + // Adding and removing service endpoints to a DID + ext().execute_with(|| { + let alice = 1u64; + let did: Did = [51; Did::BYTE_SIZE].into(); + + let endpoint_1_id: ServiceEndpointId = + ServiceEndpointId(vec![102; 50].try_into().unwrap()); + let origins_1: Vec> = + vec![ServiceEndpointOrigin(vec![112; 100].try_into().unwrap())]; + let endpoint_2_id: ServiceEndpointId = + ServiceEndpointId(vec![202; 90].try_into().unwrap()); + let origins_2: Vec> = vec![ + ServiceEndpointOrigin(vec![212; 150].try_into().unwrap()), + ServiceEndpointOrigin(vec![225; 30].try_into().unwrap()), + ]; + + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + run_to_block(5); + + let add_service_endpoint = AddServiceEndpoint { + did, + id: endpoint_1_id.clone(), + endpoint: ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_1.clone().try_into().unwrap(), + }, + nonce: 5 + 1, + }; + let sig = SigValue::sr25519(&add_service_endpoint.to_state_change().encode(), &pair_sr); + + // DID does not exist yet, thus no controller + assert_noop!( + DIDModule::add_service_endpoint( + RuntimeOrigin::signed(alice), + add_service_endpoint, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did, + vec![ + UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::NONE), + UncheckedDidKey::new( + PublicKey::ed25519(pk_ed), + VerRelType::AUTHENTICATION | VerRelType::ASSERTION + ) + ], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did)); + check_did_detail(&did, 2, 1, 1, 5); + + run_to_block(10); + + // Non-control key cannot add endpoint + let add_service_endpoint = AddServiceEndpoint { + did, + id: endpoint_1_id.clone(), + endpoint: ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_1.clone().try_into().unwrap(), + }, + nonce: 5 + 1, + }; + let sig = SigValue::ed25519(&add_service_endpoint.to_state_change().encode(), &pair_ed); + + assert_noop!( + DIDModule::add_service_endpoint( + RuntimeOrigin::signed(alice), + add_service_endpoint, + DidSignature { did: Controller(did), key_id: 2u32.into(), sig } + ), + Error::::InsufficientVerificationRelationship + ); + + assert!(vec![20; 512].try_into().map(ServiceEndpointId::).is_err()); // too big id not allowed + assert!(vec![30; 561].try_into().map(ServiceEndpointOrigin::).is_err()); // too big origin not allowed + assert!(vec![ServiceEndpointOrigin::(vec![30; 20].try_into().unwrap()); 300] + .try_into() + .map(|origins| ServiceEndpoint { types: ServiceEndpointType::LINKED_DOMAINS, origins }) + .is_err()); // too many origins not allowed + + // Trying to add invalid endpoint fails + for (id, ep) in vec![ + ( + ServiceEndpointId(vec![].try_into().unwrap()), // Empty id not allowed + ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_1.clone().try_into().unwrap(), + }, + ), + ( + endpoint_1_id.clone(), + ServiceEndpoint { + types: ServiceEndpointType::NONE, // Empty type not allowed + origins: origins_1.clone().try_into().unwrap(), + }, + ), + ( + endpoint_1_id.clone(), + ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: vec![].try_into().unwrap(), // Empty origin not allowed + }, + ), + ( + endpoint_1_id.clone(), + ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: vec![ServiceEndpointOrigin(vec![].try_into().unwrap())] + .try_into() + .unwrap(), // Empty origin not allowed + }, + ), + ( + endpoint_1_id.clone(), + ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: vec![ + ServiceEndpointOrigin(vec![45; 55].try_into().unwrap()), + ServiceEndpointOrigin(vec![].try_into().unwrap()), + ] + .try_into() + .unwrap(), // All provided origins mut be non-empty + }, + ), + ] { + let add_service_endpoint = AddServiceEndpoint { did, id, endpoint: ep, nonce: 5 + 1 }; + let sig = SigValue::sr25519(&add_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_noop!( + DIDModule::add_service_endpoint( + RuntimeOrigin::signed(alice), + add_service_endpoint.clone(), + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + ), + Error::::InvalidServiceEndpoint + ); + } + + assert!(DIDModule::did_service_endpoints(did, &endpoint_1_id).is_none()); + + let add_service_endpoint = AddServiceEndpoint { + did, + id: endpoint_1_id.clone(), + endpoint: ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_1.clone().try_into().unwrap(), + }, + nonce: 5 + 1, + }; + let sig = SigValue::sr25519(&add_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_ok!(DIDModule::add_service_endpoint( + RuntimeOrigin::signed(alice), + add_service_endpoint, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + )); + + assert_eq!( + DIDModule::did_service_endpoints(did, &endpoint_1_id).unwrap(), + ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_1.try_into().unwrap(), + } + ); + check_did_detail(&did, 2, 1, 1, 6); + + run_to_block(15); + + // Adding new endpoint with existing id fails + let add_service_endpoint = AddServiceEndpoint { + did, + id: endpoint_1_id.clone(), + endpoint: ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_2.clone().try_into().unwrap(), + }, + nonce: 6 + 1, + }; + let sig = SigValue::sr25519(&add_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_noop!( + DIDModule::add_service_endpoint( + RuntimeOrigin::signed(alice), + add_service_endpoint, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + ), + Error::::ServiceEndpointAlreadyExists + ); + + let add_service_endpoint = AddServiceEndpoint { + did, + id: endpoint_2_id.clone(), + endpoint: ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_2.clone().try_into().unwrap(), + }, + nonce: 6 + 1, + }; + let sig = SigValue::sr25519(&add_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_ok!(DIDModule::add_service_endpoint( + RuntimeOrigin::signed(alice), + add_service_endpoint, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + )); + + assert_eq!( + DIDModule::did_service_endpoints(did, &endpoint_2_id).unwrap(), + ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_2.try_into().unwrap(), + } + ); + check_did_detail(&did, 2, 1, 1, 7); + + run_to_block(16); + + // Non-control key cannot remove endpoint + let rem_service_endpoint = + RemoveServiceEndpoint { did, id: endpoint_1_id.clone(), nonce: 7 + 1 }; + let sig = SigValue::ed25519(&rem_service_endpoint.to_state_change().encode(), &pair_ed); + + assert_noop!( + DIDModule::remove_service_endpoint( + RuntimeOrigin::signed(alice), + rem_service_endpoint, + DidSignature { did: Controller(did), key_id: 2u32.into(), sig } + ), + Error::::InsufficientVerificationRelationship + ); + + // Invalid endpoint id fails + let rem_service_endpoint = RemoveServiceEndpoint { + did, + id: ServiceEndpointId(vec![].try_into().unwrap()), + nonce: 7 + 1, + }; + let sig = SigValue::sr25519(&rem_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_noop!( + DIDModule::remove_service_endpoint( + RuntimeOrigin::signed(alice), + rem_service_endpoint, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + ), + Error::::InvalidServiceEndpoint + ); + + let rem_service_endpoint = + RemoveServiceEndpoint { did, id: endpoint_1_id.clone(), nonce: 7 + 1 }; + let sig = SigValue::sr25519(&rem_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_ok!(DIDModule::remove_service_endpoint( + RuntimeOrigin::signed(alice), + rem_service_endpoint, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + )); + assert!(DIDModule::did_service_endpoints(did, &endpoint_1_id).is_none()); + check_did_detail(&did, 2, 1, 1, 8); + + // id already removed, removing again fails + let rem_service_endpoint = RemoveServiceEndpoint { did, id: endpoint_1_id, nonce: 8 + 1 }; + let sig = SigValue::sr25519(&rem_service_endpoint.to_state_change().encode(), &pair_sr); + assert_noop!( + DIDModule::remove_service_endpoint( + RuntimeOrigin::signed(alice), + rem_service_endpoint, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + ), + Error::::ServiceEndpointDoesNotExist + ); + + let rem_service_endpoint = + RemoveServiceEndpoint { did, id: endpoint_2_id.clone(), nonce: 8 + 1 }; + let sig = SigValue::sr25519(&rem_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_ok!(DIDModule::remove_service_endpoint( + RuntimeOrigin::signed(alice), + rem_service_endpoint, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + )); + assert!(DIDModule::did_service_endpoints(did, &endpoint_2_id).is_none()); + check_did_detail(&did, 2, 1, 1, 9); + + let rem_did = DidRemoval { did, nonce: 9 + 1 }; + let sig = SigValue::ed25519(&rem_did.to_state_change().encode(), &pair_ed); + + assert_noop!( + DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did), key_id: 2u32.into(), sig } + ), + Error::::InsufficientVerificationRelationship + ); + + check_did_detail(&did, 2, 1, 1, 9); + + let rem_did = DidRemoval { did, nonce: 9 + 1 }; + let sig = SigValue::sr25519(&rem_did.to_state_change().encode(), &pair_sr); + + assert_ok!(DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did), key_id: 1u32.into(), sig } + )); + ensure_onchain_did_gone(&did); + }); +} + +#[test] +fn did_removal() { + // Removing a DID + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + let did_3: Did = [53; Did::BYTE_SIZE].into(); + let did_4: Did = [54; Did::BYTE_SIZE].into(); + + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + run_to_block(5); + + // did_1 controls itself + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::NONE)], + vec![].into_iter().collect() + )); + assert!(DIDModule::is_self_controlled(&did_1)); + check_did_detail(&did_1, 1, 1, 1, 5); + + run_to_block(10); + + // did_2 does not control itself but controlled by did_1 + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::AUTHENTICATION)], + vec![did_1].into_iter().map(Controller).collect() + )); + assert!(!DIDModule::is_self_controlled(&did_2)); + check_did_detail(&did_2, 1, 0, 1, 10); + + run_to_block(15); + + // did_3 controls itself and also controlled by did_1 + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_3, + vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::NONE)], + vec![did_1].into_iter().map(Controller).collect() + )); + assert!(DIDModule::is_self_controlled(&did_3)); + check_did_detail(&did_3, 1, 1, 2, 15); + + run_to_block(20); + + // did_4 controls itself and also controlled by did_3 + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_4, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::NONE)], + vec![did_3].into_iter().map(Controller).collect() + )); + assert!(DIDModule::is_self_controlled(&did_4)); + check_did_detail(&did_4, 1, 1, 2, 20); + + // did_2 does not control itself so it cannot remove itself + let rem_did = DidRemoval { did: did_2, nonce: 10 + 1 }; + let sig = SigValue::ed25519(&rem_did.to_state_change().encode(), &pair_ed); + assert_noop!( + DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did_2), key_id: 1u32.into(), sig } + ), + Error::::OnlyControllerCanUpdate + ); + check_did_detail(&did_2, 1, 0, 1, 10); + + // did_2 is controlled by did_1 so it can be removed by did_1 + let rem_did = DidRemoval { did: did_2, nonce: 5 + 1 }; + let sig = SigValue::sr25519(&rem_did.to_state_change().encode(), &pair_sr); + assert_ok!(DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + ensure_onchain_did_gone(&did_2); + check_did_detail(&did_1, 1, 1, 1, 6); + + // Nonce should be correct when its deleted + let rem_did = DidRemoval { did: did_3, nonce: 5 }; + let sig = SigValue::sr25519(&rem_did.to_state_change().encode(), &pair_sr); + assert_noop!( + DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + ), + NonceError::IncorrectNonce + ); + check_did_detail(&did_1, 1, 1, 1, 6); + check_did_detail(&did_3, 1, 1, 2, 15); + + // did_3 is controlled by itself and did_1 and thus did_1 can remove it + let rem_did = DidRemoval { did: did_3, nonce: 6 + 1 }; + let sig = SigValue::sr25519(&rem_did.to_state_change().encode(), &pair_sr); + assert_ok!(DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + ensure_onchain_did_gone(&did_3); + check_did_detail(&did_1, 1, 1, 1, 7); + + // did_4 is controlled by itself and did_3 but did_3 has been removed so it can no + // longer remove did_4 + let rem_did = DidRemoval { did: did_4, nonce: 15 + 1 }; + let sig = SigValue::ed25519(&rem_did.to_state_change().encode(), &pair_ed); + assert_noop!( + DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did_3), key_id: 1u32.into(), sig } + ), + Error::::NoKeyForDid + ); + check_did_detail(&did_4, 1, 1, 2, 20); + + // did_4 removes itself + let rem_did = DidRemoval { did: did_4, nonce: 20 + 1 }; + let sig = SigValue::sr25519(&rem_did.to_state_change().encode(), &pair_sr); + assert_ok!(DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did_4), key_id: 1u32.into(), sig } + )); + ensure_onchain_did_gone(&did_4); + + // did_1 removes itself + let rem_did = DidRemoval { did: did_1, nonce: 7 + 1 }; + let sig = SigValue::sr25519(&rem_did.to_state_change().encode(), &pair_sr); + assert_ok!(DIDModule::remove_onchain_did( + RuntimeOrigin::signed(alice), + rem_did, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + ensure_onchain_did_gone(&did_1); + }); +} + +#[test] +fn batched_did_changes() { + // Making multiple changes to a DID in a single block + ext().execute_with(|| { + let alice = 1u64; + let did_1: Did = [51; Did::BYTE_SIZE].into(); + let did_2: Did = [52; Did::BYTE_SIZE].into(); + + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + run_to_block(10); + + let endpoint_1_id: ServiceEndpointId = + ServiceEndpointId(vec![102; 50].try_into().unwrap()); + let origins_1 = vec![ServiceEndpointOrigin(vec![112; 100].try_into().unwrap())]; + let endpoint_2_id: ServiceEndpointId = + ServiceEndpointId(vec![202; 90].try_into().unwrap()); + let origins_2 = vec![ + ServiceEndpointOrigin(vec![212; 150].try_into().unwrap()), + ServiceEndpointOrigin(vec![225; 30].try_into().unwrap()), + ]; + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_1, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::NONE)], + vec![].into_iter().collect() + )); + check_did_detail(&did_1, 1, 1, 1, 10); + + run_to_block(11); + + // did_1 adds a key and service endpoint to itself in the same block. Checks that nonce is + // correct. + let add_keys = AddKeys { + did: did_1, + keys: vec![UncheckedDidKey::new(PublicKey::x25519(pk_ed), VerRelType::KEY_AGREEMENT)], + nonce: 10 + 1, + }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr); + + let add_service_endpoint = AddServiceEndpoint { + did: did_1, + id: endpoint_1_id.clone(), + endpoint: ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_1.clone().try_into().unwrap(), + }, + nonce: 10 + 2, + }; + let sig_1 = SigValue::sr25519(&add_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_ok!(DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + assert_ok!(DIDModule::add_service_endpoint( + RuntimeOrigin::signed(alice), + add_service_endpoint, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig: sig_1 } + )); + + check_did_detail(&did_1, 2, 1, 1, 12); + assert_eq!( + DIDModule::did_service_endpoints(did_1, &endpoint_1_id).unwrap(), + ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_1.try_into().unwrap(), + } + ); + only_key_agreement(&DidKeys::::get(did_1, IncId::from(2u32)).unwrap()); + + run_to_block(13); + + // did_1 adds 2 keys and 1 service endpoint to did_1 in the same block. Checks that nonce of + // both DIDs is correct. + let add_keys = AddKeys { + did: did_2, + keys: vec![UncheckedDidKey::new(PublicKey::x25519(pk_ed), VerRelType::KEY_AGREEMENT)], + nonce: 12 + 1, + }; + let sig = SigValue::sr25519(&add_keys.to_state_change().encode(), &pair_sr); + + let add_keys_2 = AddKeys { + did: did_2, + keys: vec![UncheckedDidKey::new(PublicKey::ed25519(pk_ed), VerRelType::ASSERTION)], + nonce: 12 + 2, + }; + let sig_2 = SigValue::sr25519(&add_keys_2.to_state_change().encode(), &pair_sr); + + let add_service_endpoint = AddServiceEndpoint { + did: did_2, + id: endpoint_2_id.clone(), + endpoint: ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_2.clone().try_into().unwrap(), + }, + nonce: 12 + 3, + }; + let sig_3 = SigValue::sr25519(&add_service_endpoint.to_state_change().encode(), &pair_sr); + + assert_ok!(DIDModule::new_onchain( + RuntimeOrigin::signed(alice), + did_2, + vec![UncheckedDidKey::new(PublicKey::sr25519(pk_sr), VerRelType::AUTHENTICATION)], + vec![did_1].into_iter().map(Controller).collect() + )); + assert_ok!(DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig } + )); + assert_ok!(DIDModule::add_keys( + RuntimeOrigin::signed(alice), + add_keys_2, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig: sig_2 } + )); + assert_ok!(DIDModule::add_service_endpoint( + RuntimeOrigin::signed(alice), + add_service_endpoint, + DidSignature { did: Controller(did_1), key_id: 1u32.into(), sig: sig_3 } + )); + + check_did_detail(&did_2, 3, 0, 1, 13); + check_did_detail(&did_1, 2, 1, 1, 15); + assert_eq!( + DIDModule::did_service_endpoints(did_2, &endpoint_2_id).unwrap(), + ServiceEndpoint { + types: ServiceEndpointType::LINKED_DOMAINS, + origins: origins_2.try_into().unwrap(), + } + ); + only_key_agreement(&DidKeys::::get(did_2, IncId::from(2u32)).unwrap()); + assert_eq!( + DidKeys::::get(did_2, IncId::from(3u32)).unwrap(), + DidKey::new(PublicKey::ed25519(pk_ed), VerRelType::ASSERTION).unwrap() + ); + }); +} +// TODO: Add test for events DidAdded, KeyUpdated, DIDRemoval + +#[test] +fn valid_key() { + let (pair_sr, _, _) = sr25519::Pair::generate_with_phrase(None); + let pk_sr = pair_sr.public().0; + let (pair_ed, _, _) = ed25519::Pair::generate_with_phrase(None); + let pk_ed = pair_ed.public().0; + + // x25519 key cannot be added for incompatible relationship types + for add in [VerRelType::NONE, VerRelType::KEY_AGREEMENT] { + for vr in vec![ + VerRelType::AUTHENTICATION, + VerRelType::ASSERTION, + VerRelType::CAPABILITY_INVOCATION, + VerRelType::ALL_FOR_SIGNING, + ] + .into_iter() + .map(|val| val | add) + { + let key = UncheckedDidKey::new(PublicKey::x25519(pk_ed), vr); + assert_err!( + DidKey::decode(&mut &key.encode()[..]), + codec::Error::from("Key Agreement can't be used for signing") + ); + assert_err!( + DidKey::new(PublicKey::x25519(pk_ed), vr), + DidKeyError::KeyAgreementCantBeUsedForSigning + ); + } + } + + // signing keys can't be used for key agreement + for pk in vec![PublicKey::sr25519(pk_sr), PublicKey::ed25519(pk_ed)] { + for vr in vec![ + VerRelType::AUTHENTICATION, + VerRelType::ASSERTION, + VerRelType::CAPABILITY_INVOCATION, + VerRelType::NONE, + VerRelType::ALL_FOR_SIGNING, + ] + .into_iter() + { + let key = UncheckedDidKey::new(pk.clone(), VerRelType::KEY_AGREEMENT | vr); + assert_err!( + DidKey::decode(&mut &key.encode()[..]), + codec::Error::from("Signing key can't be used for Key Agreement") + ); + assert_err!( + DidKey::new(pk.clone(), VerRelType::KEY_AGREEMENT | vr), + DidKeyError::SigningKeyCantBeUsedForKeyAgreement + ); + } + } +} + +#[test] +fn valid_ver_rels_encoding_decoding() { + assert_err!(VerRelType::decode(&mut &999u32.encode()[..]), codec::Error::from("Invalid value")); + assert_ok!(VerRelType::decode(&mut &7u32.encode()[..]), VerRelType::ALL_FOR_SIGNING); +} + +#[test] +fn aggregated_did_details_request_params_encoding_decoding() { + assert_err!( + AggregatedDidDetailsRequestParams::decode(&mut &999u32.encode()[..]), + codec::Error::from("Invalid value") + ); + assert_ok!( + AggregatedDidDetailsRequestParams::decode(&mut &15u32.encode()[..]), + AggregatedDidDetailsRequestParams::FULL + ); +} + +#[test] +fn service_endpoints_type_encoding_decoding() { + assert_err!( + ServiceEndpointType::decode(&mut &999u32.encode()[..]), + codec::Error::from("Invalid value") + ); + assert_ok!( + ServiceEndpointType::decode(&mut &1u32.encode()[..]), + ServiceEndpointType::LINKED_DOMAINS + ); +} diff --git a/pallets/did/src/modules/did/weights.rs b/pallets/did/src/modules/did/weights.rs new file mode 100644 index 0000000..60da5be --- /dev/null +++ b/pallets/did/src/modules/did/weights.rs @@ -0,0 +1,473 @@ +//! Autogenerated weights for did +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2022-08-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Native), WASM-EXECUTION: Interpreted, CHAIN: Some("mainnet"), DB CACHE: 128 + +// Executed Command: +// ./target/production/dock-node +// benchmark +// --execution=native +// --chain=mainnet +// --pallet=did +// --extra +// --extrinsic=* +// --repeat=20 +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/did/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for did. +pub trait WeightInfo { + fn add_keys_sr25519(k: u32) -> Weight; + fn add_keys_ed25519(k: u32) -> Weight; + fn add_keys_secp256k1(k: u32) -> Weight; + fn remove_keys_sr25519(k: u32) -> Weight; + fn remove_keys_ed25519(k: u32) -> Weight; + fn remove_keys_secp256k1(k: u32) -> Weight; + fn add_controllers_sr25519(k: u32) -> Weight; + fn add_controllers_ed25519(k: u32) -> Weight; + fn add_controllers_secp256k1(k: u32) -> Weight; + fn remove_controllers_sr25519(k: u32) -> Weight; + fn remove_controllers_ed25519(k: u32) -> Weight; + fn remove_controllers_secp256k1(k: u32) -> Weight; + fn add_service_endpoint_sr25519(o: u32, l: u32, i: u32) -> Weight; + fn add_service_endpoint_ed25519(o: u32, l: u32, i: u32) -> Weight; + fn add_service_endpoint_secp256k1(o: u32, l: u32, i: u32) -> Weight; + fn remove_service_endpoint_sr25519(i: u32) -> Weight; + fn remove_service_endpoint_ed25519(i: u32) -> Weight; + fn remove_service_endpoint_secp256k1(i: u32) -> Weight; + fn remove_onchain_did_sr25519() -> Weight; + fn remove_onchain_did_ed25519() -> Weight; + fn remove_onchain_did_secp256k1() -> Weight; + fn new_onchain(k: u32, c: u32) -> Weight; + fn new_offchain(k: u32) -> Weight; + fn set_offchain_did_doc_ref(k: u32) -> Weight; + fn remove_offchain_did() -> Weight; +} + +/// Weights for did using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn add_keys_sr25519(k: u32) -> Weight { + Weight::from_all(56_930_000_u64) + // Standard Error: 34_000 + .saturating_add(Weight::from_all(1_072_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_keys_ed25519(k: u32) -> Weight { + Weight::from_all(57_701_000_u64) + // Standard Error: 29_000 + .saturating_add(Weight::from_all(712_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_keys_secp256k1(k: u32) -> Weight { + Weight::from_all(162_329_000_u64) + // Standard Error: 575_000 + .saturating_add(Weight::from_all(1_296_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_keys_sr25519(k: u32) -> Weight { + Weight::from_all(62_781_000_u64) + // Standard Error: 26_000 + .saturating_add(Weight::from_all(2_804_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_keys_ed25519(k: u32) -> Weight { + Weight::from_all(60_847_000_u64) + // Standard Error: 30_000 + .saturating_add(Weight::from_all(2_717_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_keys_secp256k1(k: u32) -> Weight { + Weight::from_all(165_718_000_u64) + // Standard Error: 72_000 + .saturating_add(Weight::from_all(2_734_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_controllers_sr25519(k: u32) -> Weight { + Weight::from_all(60_892_000_u64) + // Standard Error: 34_000 + .saturating_add(Weight::from_all(3_351_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_controllers_ed25519(k: u32) -> Weight { + Weight::from_all(60_140_000_u64) + // Standard Error: 59_000 + .saturating_add(Weight::from_all(3_061_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_controllers_secp256k1(k: u32) -> Weight { + Weight::from_all(168_684_000_u64) + // Standard Error: 69_000 + .saturating_add(Weight::from_all(2_770_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_controllers_sr25519(k: u32) -> Weight { + Weight::from_all(60_478_000_u64) + // Standard Error: 119_000 + .saturating_add(Weight::from_all(3_625_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_controllers_ed25519(k: u32) -> Weight { + Weight::from_all(60_970_000_u64) + // Standard Error: 43_000 + .saturating_add(Weight::from_all(3_273_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_controllers_secp256k1(k: u32) -> Weight { + Weight::from_all(165_267_000_u64) + // Standard Error: 57_000 + .saturating_add(Weight::from_all(3_198_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_service_endpoint_sr25519(o: u32, l: u32, i: u32) -> Weight { + Weight::from_all(62_630_000_u64) + // Standard Error: 15_000 + .saturating_add(Weight::from_all(146_000_u64).saturating_mul(o as u64)) + // Standard Error: 15_000 + .saturating_add(Weight::from_all(82_000_u64).saturating_mul(l as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_service_endpoint_ed25519(o: u32, l: u32, i: u32) -> Weight { + Weight::from_all(61_631_000_u64) + // Standard Error: 16_000 + .saturating_add(Weight::from_all(60_000_u64).saturating_mul(o as u64)) + // Standard Error: 16_000 + .saturating_add(Weight::from_all(58_000_u64).saturating_mul(l as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(4_000_u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_service_endpoint_secp256k1(o: u32, l: u32, i: u32) -> Weight { + Weight::from_all(152_391_000_u64) + // Standard Error: 236_000 + .saturating_add(Weight::from_all(719_000_u64).saturating_mul(o as u64)) + // Standard Error: 236_000 + .saturating_add(Weight::from_all(810_000_u64).saturating_mul(l as u64)) + // Standard Error: 11_000 + .saturating_add(Weight::from_all(80_000_u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_service_endpoint_sr25519(i: u32) -> Weight { + Weight::from_all(62_886_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(28_000_u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_service_endpoint_ed25519(i: u32) -> Weight { + Weight::from_all(62_262_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(9_000_u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_service_endpoint_secp256k1(i: u32) -> Weight { + Weight::from_all(166_356_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(12_000_u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_onchain_did_sr25519() -> Weight { + Weight::from_all(85_904_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(34_u64)) + } + fn remove_onchain_did_ed25519() -> Weight { + Weight::from_all(86_475_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(34_u64)) + } + fn remove_onchain_did_secp256k1() -> Weight { + Weight::from_all(193_139_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(34_u64)) + } + fn new_onchain(k: u32, c: u32) -> Weight { + Weight::from_all(10_672_000_u64) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(549_000_u64).saturating_mul(k as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(606_000_u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(c as u64))) + } + fn new_offchain(k: u32) -> Weight { + Weight::from_all(9_652_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn set_offchain_did_doc_ref(k: u32) -> Weight { + Weight::from_all(10_356_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_offchain_did() -> Weight { + Weight::from_all(10_057_000_u64) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn add_keys_sr25519(k: u32) -> Weight { + Weight::from_all(56_930_000_u64) + // Standard Error: 34_000 + .saturating_add(Weight::from_all(1_072_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_keys_ed25519(k: u32) -> Weight { + Weight::from_all(57_701_000_u64) + // Standard Error: 29_000 + .saturating_add(Weight::from_all(712_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_keys_secp256k1(k: u32) -> Weight { + Weight::from_all(162_329_000_u64) + // Standard Error: 575_000 + .saturating_add(Weight::from_all(1_296_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_keys_sr25519(k: u32) -> Weight { + Weight::from_all(62_781_000_u64) + // Standard Error: 26_000 + .saturating_add(Weight::from_all(2_804_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_keys_ed25519(k: u32) -> Weight { + Weight::from_all(60_847_000_u64) + // Standard Error: 30_000 + .saturating_add(Weight::from_all(2_717_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_keys_secp256k1(k: u32) -> Weight { + Weight::from_all(165_718_000_u64) + // Standard Error: 72_000 + .saturating_add(Weight::from_all(2_734_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_controllers_sr25519(k: u32) -> Weight { + Weight::from_all(60_892_000_u64) + // Standard Error: 34_000 + .saturating_add(Weight::from_all(3_351_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_controllers_ed25519(k: u32) -> Weight { + Weight::from_all(60_140_000_u64) + // Standard Error: 59_000 + .saturating_add(Weight::from_all(3_061_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_controllers_secp256k1(k: u32) -> Weight { + Weight::from_all(168_684_000_u64) + // Standard Error: 69_000 + .saturating_add(Weight::from_all(2_770_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_controllers_sr25519(k: u32) -> Weight { + Weight::from_all(60_478_000_u64) + // Standard Error: 119_000 + .saturating_add(Weight::from_all(3_625_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_controllers_ed25519(k: u32) -> Weight { + Weight::from_all(60_970_000_u64) + // Standard Error: 43_000 + .saturating_add(Weight::from_all(3_273_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn remove_controllers_secp256k1(k: u32) -> Weight { + Weight::from_all(165_267_000_u64) + // Standard Error: 57_000 + .saturating_add(Weight::from_all(3_198_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + } + fn add_service_endpoint_sr25519(o: u32, l: u32, i: u32) -> Weight { + Weight::from_all(62_630_000_u64) + // Standard Error: 15_000 + .saturating_add(Weight::from_all(146_000_u64).saturating_mul(o as u64)) + // Standard Error: 15_000 + .saturating_add(Weight::from_all(82_000_u64).saturating_mul(l as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(i as u64)) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_service_endpoint_ed25519(o: u32, l: u32, i: u32) -> Weight { + Weight::from_all(61_631_000_u64) + // Standard Error: 16_000 + .saturating_add(Weight::from_all(60_000_u64).saturating_mul(o as u64)) + // Standard Error: 16_000 + .saturating_add(Weight::from_all(58_000_u64).saturating_mul(l as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(4_000_u64).saturating_mul(i as u64)) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_service_endpoint_secp256k1(o: u32, l: u32, i: u32) -> Weight { + Weight::from_all(152_391_000_u64) + // Standard Error: 236_000 + .saturating_add(Weight::from_all(719_000_u64).saturating_mul(o as u64)) + // Standard Error: 236_000 + .saturating_add(Weight::from_all(810_000_u64).saturating_mul(l as u64)) + // Standard Error: 11_000 + .saturating_add(Weight::from_all(80_000_u64).saturating_mul(i as u64)) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_service_endpoint_sr25519(i: u32) -> Weight { + Weight::from_all(62_886_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(28_000_u64).saturating_mul(i as u64)) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_service_endpoint_ed25519(i: u32) -> Weight { + Weight::from_all(62_262_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(9_000_u64).saturating_mul(i as u64)) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_service_endpoint_secp256k1(i: u32) -> Weight { + Weight::from_all(166_356_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(12_000_u64).saturating_mul(i as u64)) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_onchain_did_sr25519() -> Weight { + Weight::from_all(85_904_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(34_u64)) + } + fn remove_onchain_did_ed25519() -> Weight { + Weight::from_all(86_475_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(34_u64)) + } + fn remove_onchain_did_secp256k1() -> Weight { + Weight::from_all(193_139_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(34_u64)) + } + fn new_onchain(k: u32, c: u32) -> Weight { + Weight::from_all(10_672_000_u64) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(549_000_u64).saturating_mul(k as u64)) + // Standard Error: 4_000 + .saturating_add(Weight::from_all(606_000_u64).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(k as u64))) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(c as u64))) + } + fn new_offchain(k: u32) -> Weight { + Weight::from_all(9_652_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn set_offchain_did_doc_ref(k: u32) -> Weight { + Weight::from_all(10_356_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(k as u64)) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_offchain_did() -> Weight { + Weight::from_all(10_057_000_u64) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } +} diff --git a/pallets/did/src/modules/mod.rs b/pallets/did/src/modules/mod.rs new file mode 100644 index 0000000..eb99e4b --- /dev/null +++ b/pallets/did/src/modules/mod.rs @@ -0,0 +1,9 @@ +pub mod accumulator; +pub mod anchor; +pub mod attest; +pub mod blob; +pub mod did; +pub mod offchain_signatures; +pub mod revoke; +pub mod status_list_credential; +pub mod trusted_entity; diff --git a/pallets/did/src/modules/offchain_signatures/actions.rs b/pallets/did/src/modules/offchain_signatures/actions.rs new file mode 100644 index 0000000..1684347 --- /dev/null +++ b/pallets/did/src/modules/offchain_signatures/actions.rs @@ -0,0 +1,62 @@ +use crate::common::{Types, TypesAndLimits}; +use frame_support::DebugNoBound; + +use super::*; + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddOffchainSignatureParams { + pub params: OffchainSignatureParams, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddOffchainSignaturePublicKey { + pub key: OffchainPublicKey, + pub did: Did, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveOffchainSignatureParams { + pub params_ref: SignatureParamsStorageKey, + pub nonce: T::BlockNumber, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveOffchainSignaturePublicKey { + pub key_ref: SignaturePublicKeyStorageKey, + pub did: Did, + pub nonce: T::BlockNumber, +} + +crate::impl_action_with_nonce! { + for Did: + AddOffchainSignaturePublicKey with 1 as len, did as target, + RemoveOffchainSignaturePublicKey with 1 as len, did as target +} + +crate::impl_action_with_nonce! { + for (): + AddOffchainSignatureParams with 1 as len, () as target, + RemoveOffchainSignatureParams with 1 as len, () as target +} diff --git a/pallets/did/src/modules/offchain_signatures/benchmarks.rs b/pallets/did/src/modules/offchain_signatures/benchmarks.rs new file mode 100644 index 0000000..50fdc0b --- /dev/null +++ b/pallets/did/src/modules/offchain_signatures/benchmarks.rs @@ -0,0 +1,183 @@ +use super::*; +use crate::{ + common::{CurveType, ToStateChange}, + did::{Did, DidSignature, UncheckedDidKey}, + util::{BoundedBytes, IncId}, +}; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MAX_PARAMS: u32 = 512; +const MAX_LABEL: u32 = 128; +const MAX_KEY: u32 = 256; + +crate::bench_with_all_pairs! { + with_pairs: + add_params_sr25519 for sr25519, add_params_ed25519 for ed25519, add_params_secp256k1 for secp256k1 { + { + let b in 0 .. MAX_PARAMS => (); + let l in 1 .. MAX_LABEL => (); + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let params = BBSPlusParameters::new( + BoundedBytes::try_from(vec![0; l as usize]).unwrap(), + BoundedBytes::try_from(vec![0; b as usize]).unwrap(), + CurveType::Bls12381, + ); + let new_params = AddOffchainSignatureParams { + params: params.clone().into(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&new_params.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: add_params(RawOrigin::Signed(caller), new_params, signature) + verify { + assert_eq!(SignatureParams::::get(SignatureParamsOwner(did), IncId::from(1u8)).unwrap(), params.clone().into()); + } + + remove_params_sr25519 for sr25519, remove_params_ed25519 for ed25519, remove_params_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + Pallet::::add_params_( + AddOffchainSignatureParams { + params: BBSPlusParameters::new( + BoundedBytes::try_from(vec![1; MAX_LABEL as usize]).unwrap(), + BoundedBytes::try_from(vec![0; MAX_PARAMS as usize]).unwrap(), + CurveType::Bls12381, + ).into(), + nonce: 1u8.into() + }, + SignatureParamsOwner(did) + ).unwrap(); + + let rem_params = RemoveOffchainSignatureParams { + params_ref: (SignatureParamsOwner(did), 1u8.into()), + nonce: 1u8.into() + }; + + let sig = pair.sign(&rem_params.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: remove_params(RawOrigin::Signed(caller), rem_params, signature) + verify { + assert!(SignatureParams::::get(SignatureParamsOwner(did), IncId::from(1u8)).is_none()); + } + + add_public_sr25519 for sr25519, add_public_ed25519 for ed25519, add_public_secp256k1 for secp256k1 { + { + let b in 0 .. MAX_KEY; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + Pallet::::add_params_( + AddOffchainSignatureParams { + params: BBSPlusParameters::new( + BoundedBytes::try_from(vec![1; MAX_LABEL as usize]).unwrap(), + BoundedBytes::try_from(vec![0; MAX_PARAMS as usize]).unwrap(), + CurveType::Bls12381, + ).into(), + nonce: 1u8.into() + }, + SignatureParamsOwner(did) + ).unwrap(); + + let key: OffchainPublicKey = BBSPlusPublicKey::new( + BoundedBytes::try_from(vec![0; b as usize]).unwrap(), + (SignatureParamsOwner(did), IncId::from(1u8)), + CurveType::Bls12381, + ).into(); + let add_key = AddOffchainSignaturePublicKey { + did: did, + key: key.clone(), + nonce: 1u8.into() + }; + + let sig = pair.sign(&add_key.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: add_public_key(RawOrigin::Signed(caller), add_key, signature) + verify { + assert_eq!(PublicKeys::get(did, IncId::from(2u8)).unwrap(), key); + } + + remove_public_sr25519 for sr25519, remove_public_ed25519 for ed25519, remove_public_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + Pallet::::add_params_( + AddOffchainSignatureParams { + params: BBSPlusParameters::new( + BoundedBytes::try_from(vec![1; MAX_LABEL as usize]).unwrap(), + BoundedBytes::try_from(vec![0; MAX_PARAMS as usize]).unwrap(), + CurveType::Bls12381, + ).into(), + nonce: 1u8.into() + }, + SignatureParamsOwner(did) + ).unwrap(); + + Pallet::::add_public_key_( + AddOffchainSignaturePublicKey { + did: did, + key: BBSPlusPublicKey::new( + BoundedBytes::try_from(vec![0; MAX_KEY as usize]).unwrap(), + (SignatureParamsOwner(did), IncId::from(1u8)), + CurveType::Bls12381, + ).into(), + nonce: 2u8.into() + }, + &mut Default::default() + ).unwrap(); + + let rem_key = RemoveOffchainSignaturePublicKey { + did: did, + key_ref: (did, 1u8.into()), + nonce: 1u8.into() + }; + + let sig = pair.sign(&rem_key.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: remove_public_key(RawOrigin::Signed(caller), rem_key, signature) + verify { + assert!(PublicKeys::::get(did, IncId::from(2u8)).is_none()); + } +} diff --git a/pallets/did/src/modules/offchain_signatures/mod.rs b/pallets/did/src/modules/offchain_signatures/mod.rs new file mode 100644 index 0000000..624e9a1 --- /dev/null +++ b/pallets/did/src/modules/offchain_signatures/mod.rs @@ -0,0 +1,247 @@ +//! Module to store offchain signature keys and parameters for different signature schemes. +//! Currently can be either `BBS`, `BBS+` or `Pointcheval-Sanders`. + +use crate::{ + common::{self, SigValue}, + did, + did::{Controller, Did, DidSignature, OnDidRemoval}, + util::IncId, +}; +use codec::{Decode, Encode}; +use sp_std::prelude::*; + +use frame_support::{dispatch::DispatchResult, traits::Get, weights::Weight}; +use frame_system::ensure_signed; +use weights::*; + +pub use actions::*; +pub use pallet::*; +pub use params::*; +pub use public_key::*; +pub use schemes::*; + +mod actions; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +mod params; +mod public_key; +mod schemes; +#[cfg(test)] +mod tests; +mod weights; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::{pallet_prelude::*, Blake2_128Concat}; + use frame_system::pallet_prelude::*; + + #[pallet::config] + /// The module's configuration trait. + pub trait Config: frame_system::Config + did::Config { + /// The overarching event type. + type RuntimeEvent: From + + IsType<::RuntimeEvent> + + Into<::RuntimeEvent>; + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + ParamsAdded(SignatureParamsOwner, IncId), + ParamsRemoved(SignatureParamsOwner, IncId), + KeyAdded(Did, IncId), + KeyRemoved(Did, IncId), + } + + #[pallet::error] + pub enum Error { + ParamsDontExist, + IncorrectParamsScheme, + PublicKeyDoesntExist, + NotOwner, + IncorrectNonce, + } + + #[pallet::pallet] + pub struct Pallet(_); + + /// Pair of counters where each is used to assign unique id to parameters and public keys + /// respectively. On adding new params or keys, corresponding counter is increased by 1 but + /// the counters don't decrease on removal + #[pallet::storage] + #[pallet::getter(fn did_params_counter)] + pub type ParamsCounter = + StorageMap<_, Blake2_128Concat, SignatureParamsOwner, IncId, ValueQuery>; + + /// Signature parameters are stored as key value (did, counter) -> signature parameters + #[pallet::storage] + #[pallet::getter(fn did_public_key_params)] + pub type SignatureParams = StorageDoubleMap< + _, + Blake2_128Concat, + SignatureParamsOwner, + Identity, + IncId, + OffchainSignatureParams, + >; + + /// Public keys are stored as key value (did, counter) -> public key + #[pallet::storage] + #[pallet::getter(fn did_public_key)] + pub type PublicKeys = + StorageDoubleMap<_, Blake2_128Concat, Did, Identity, IncId, OffchainPublicKey>; + + #[pallet::storage] + #[pallet::getter(fn version)] + pub type Version = StorageValue<_, common::StorageVersion, ValueQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub _marker: PhantomData, + } + + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + GenesisConfig { _marker: PhantomData } + } + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) { + Version::::put(common::StorageVersion::MultiKey); + } + } + + #[pallet::call] + impl Pallet { + #[pallet::weight(SubstrateWeight::::add_params(params, signature))] + #[pallet::call_index(0)] + pub fn add_params( + origin: OriginFor, + params: AddOffchainSignatureParams, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::add_params_, + params, + signature, + ) + } + + /// Add new offchain signature public key. Only the DID controller can add key and it should + /// use the nonce from the DID module. This kind of key cannot be removed by calling + /// `remove_keys` from the DID module but only by calling `remove_public_key` of this + /// module. + #[pallet::weight(SubstrateWeight::::add_public(public_key, signature))] + #[pallet::call_index(1)] + pub fn add_public_key( + origin: OriginFor, + public_key: AddOffchainSignaturePublicKey, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_controller( + Self::add_public_key_, + public_key, + signature, + ) + } + + #[pallet::weight(SubstrateWeight::::remove_params(remove, signature))] + #[pallet::call_index(2)] + pub fn remove_params( + origin: OriginFor, + remove: RemoveOffchainSignatureParams, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_onchain_did( + Self::remove_params_, + remove, + signature, + ) + } + + /// Remove existing offchain signature public key. Only the DID controller can remove key + /// and it should use the nonce from the DID module. This kind of key cannot be removed by + /// calling `remove_keys` from the DID module. + #[pallet::weight(SubstrateWeight::::remove_public(remove, signature))] + #[pallet::call_index(3)] + pub fn remove_public_key( + origin: OriginFor, + remove: RemoveOffchainSignaturePublicKey, + signature: DidSignature, + ) -> DispatchResult { + ensure_signed(origin)?; + + did::Pallet::::try_exec_signed_action_from_controller( + Self::remove_public_key_, + remove, + signature, + ) + } + } +} + +impl OnDidRemoval for Pallet { + fn on_remove_did(did: Did) -> Weight { + use sp_io::MultiRemovalResults; + // TODO: limit and cursor + let MultiRemovalResults { backend, .. } = + PublicKeys::::clear_prefix(did, u32::MAX, None); + + T::DbWeight::get().writes(backend as u64) + } +} + +impl SubstrateWeight { + fn add_params( + add_params: &AddOffchainSignatureParams, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::add_params_sr25519, + SigValue::Ed25519(_) => Self::add_params_ed25519, + }( + add_params.params.bytes().len() as u32, + add_params.params.label().map_or(0, |v| v.len()) as u32, + )) + } + + fn add_public( + public_key: &AddOffchainSignaturePublicKey, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::add_public_sr25519, + SigValue::Ed25519(_) => Self::add_public_ed25519, + }(public_key.key.bytes().len() as u32)) + } + + fn remove_params( + _: &RemoveOffchainSignatureParams, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_params_sr25519, + SigValue::Ed25519(_) => Self::remove_params_ed25519, + }()) + } + + fn remove_public( + _: &RemoveOffchainSignaturePublicKey, + DidSignature { sig, .. }: &DidSignature, + ) -> Weight { + (match sig { + SigValue::Sr25519(_) => Self::remove_public_sr25519, + SigValue::Ed25519(_) => Self::remove_public_ed25519, + }()) + } +} diff --git a/pallets/did/src/modules/offchain_signatures/params.rs b/pallets/did/src/modules/offchain_signatures/params.rs new file mode 100644 index 0000000..585a52e --- /dev/null +++ b/pallets/did/src/modules/offchain_signatures/params.rs @@ -0,0 +1,115 @@ +use crate::{common::Limits, did::Did, offchain_signatures::schemes::*, util::IncId}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{ensure, DebugNoBound}; +use sp_runtime::DispatchResult; +use sp_std::fmt::Debug; + +use super::{ + AddOffchainSignatureParams, BBSPlusPublicKey, Config, Error, Event, PSPublicKey, Pallet, + ParamsCounter, RemoveOffchainSignatureParams, SignatureParams, +}; + +/// DID owner of the signature parameters. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct SignatureParamsOwner(pub Did); + +crate::impl_wrapper!(SignatureParamsOwner(Did), for rand use Did(rand::random()), with tests as bbs_plus_params_owner_tests); + +pub type SignatureParamsStorageKey = (SignatureParamsOwner, IncId); +pub type BBSPublicKeyWithParams = (BBSPublicKey, Option>); +pub type BBSPlusPublicKeyWithParams = (BBSPlusPublicKey, Option>); +pub type PSPublicKeyWithParams = (PSPublicKey, Option>); + +/// Signature parameters. Currently can be either `BBS`, `BBS+` or `Pointcheval-Sanders`. +#[derive( + scale_info_derive::TypeInfo, Encode, Decode, Clone, PartialEq, Eq, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub enum OffchainSignatureParams { + /// Signature parameters for the BBS signature scheme. + BBS(BBSParameters), + /// Signature parameters for the BBS+ signature scheme. + BBSPlus(BBSPlusParameters), + /// Signature parameters for the Pointcheval-Sanders signature scheme. + PS(PSParameters), +} + +impl OffchainSignatureParams { + /// Returns underlying parameters if it corresponds to the BBS scheme. + pub fn into_bbs(self) -> Option> { + self.try_into().ok() + } + + /// Returns underlying parameters if it corresponds to the BBS+ scheme. + pub fn into_bbs_plus(self) -> Option> { + self.try_into().ok() + } + + /// Returns underlying parameters if it corresponds to the Pointcheval-Sanders scheme. + pub fn into_ps(self) -> Option> { + self.try_into().ok() + } + + /// Returns underlying **unchecked** bytes representation for parameters corresponding to either + /// signature scheme. + pub fn bytes(&self) -> &[u8] { + match self { + Self::BBS(params) => ¶ms.bytes[..], + Self::BBSPlus(params) => ¶ms.bytes[..], + Self::PS(params) => ¶ms.bytes[..], + } + } + + /// Returns underlying label for a key corresponding to either signature scheme. + pub fn label(&self) -> Option<&[u8]> { + match self { + Self::BBS(params) => params.label.as_ref().map(|slice| &slice[..]), + Self::BBSPlus(params) => params.label.as_ref().map(|slice| &slice[..]), + Self::PS(params) => params.label.as_ref().map(|slice| &slice[..]), + } + } +} + +impl Pallet { + pub(super) fn add_params_( + AddOffchainSignatureParams { params, .. }: AddOffchainSignatureParams, + signer: SignatureParamsOwner, + ) -> DispatchResult { + let params_count = ParamsCounter::::mutate(signer, |counter| *counter.inc()); + SignatureParams::::insert(signer, params_count, params); + + Self::deposit_event(Event::ParamsAdded(signer, params_count)); + Ok(()) + } + + pub(super) fn remove_params_( + RemoveOffchainSignatureParams { + params_ref: (did, counter), + .. + }: RemoveOffchainSignatureParams, + owner: SignatureParamsOwner, + ) -> DispatchResult { + // Only the DID that added the param can it + ensure!(did == owner, Error::::NotOwner); + + ensure!(SignatureParams::::contains_key(did, counter), Error::::ParamsDontExist); + + SignatureParams::::remove(did, counter); + + Self::deposit_event(Event::ParamsRemoved(did, counter)); + Ok(()) + } + + pub fn did_params( + did: &SignatureParamsOwner, + ) -> impl Iterator)> { + SignatureParams::::iter_prefix(did) + } +} diff --git a/pallets/did/src/modules/offchain_signatures/public_key.rs b/pallets/did/src/modules/offchain_signatures/public_key.rs new file mode 100644 index 0000000..b4a840f --- /dev/null +++ b/pallets/did/src/modules/offchain_signatures/public_key.rs @@ -0,0 +1,134 @@ +use crate::{ + common::Limits, + did::{Did, OnChainDidDetails}, + offchain_signatures::{schemes::*, SignatureParams}, + util::IncId, +}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{ensure, DebugNoBound}; +use sp_runtime::DispatchResult; + +use super::{ + AddOffchainSignaturePublicKey, Config, Error, Event, OffchainSignatureParams, Pallet, + PublicKeys, RemoveOffchainSignaturePublicKey, SignatureParamsStorageKey, +}; + +pub type SignaturePublicKeyStorageKey = (Did, IncId); + +/// Public key for different signature schemes. Currently can be either `BBS`, `BBS+` or +/// `Pointcheval-Sanders`. +#[derive( + scale_info_derive::TypeInfo, Encode, Decode, Clone, PartialEq, Eq, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub enum OffchainPublicKey { + /// Public key for the BBS signature scheme. + BBS(BBSPublicKey), + /// Public key for the BBS+ signature scheme. + BBSPlus(BBSPlusPublicKey), + /// Public key for the Pointcheval-Sanders signature scheme. + PS(PSPublicKey), +} + +impl OffchainPublicKey { + /// Returns underlying public key if it corresponds to the BBS scheme. + pub fn into_bbs(self) -> Option> { + self.try_into().ok() + } + + /// Returns underlying public key if it corresponds to the BBS+ scheme. + pub fn into_bbs_plus(self) -> Option> { + self.try_into().ok() + } + + /// Returns underlying public key if it corresponds to the Pointcheval-Sanders scheme. + pub fn into_ps(self) -> Option> { + self.try_into().ok() + } + + /// Returns underlying **unchecked** bytes representation for a key corresponding to either + /// signature scheme. + pub fn bytes(&self) -> &[u8] { + match self { + Self::BBS(key) => &key.bytes[..], + Self::BBSPlus(key) => &key.bytes[..], + Self::PS(key) => &key.bytes[..], + } + } + + /// Returns underlying parameters reference for a key corresponding to either signature scheme. + pub fn params_ref(&self) -> Option<&SignatureParamsStorageKey> { + let opt = match self { + Self::BBS(bbs_key) => &bbs_key.params_ref, + Self::BBSPlus(bbs_plus_key) => &bbs_plus_key.params_ref, + Self::PS(ps_key) => &ps_key.params_ref, + }; + + opt.as_ref() + } + + /// Returns `true` if supplied params have same scheme as the given key. + pub fn params_match_scheme(&self, params: &OffchainSignatureParams) -> bool { + match self { + Self::BBS(_) => matches!(params, OffchainSignatureParams::BBS(_)), + Self::BBSPlus(_) => matches!(params, OffchainSignatureParams::BBSPlus(_)), + Self::PS(_) => matches!(params, OffchainSignatureParams::PS(_)), + } + } + + /// Ensures that supplied key has a valid size and has constrained parameters. + pub fn ensure_valid(&self) -> Result<(), Error> + where + T: Config, + { + if let Some((did, params_id)) = self.params_ref() { + let params = + SignatureParams::::get(did, params_id).ok_or(Error::::ParamsDontExist)?; + + ensure!(self.params_match_scheme(¶ms), Error::::IncorrectParamsScheme); + // Note: Once we have more than 1 curve type, it should check that params and key + // both have same curve type + }; + + Ok(()) + } +} + +impl Pallet { + pub(super) fn add_public_key_( + AddOffchainSignaturePublicKey { did: owner, key, .. }: AddOffchainSignaturePublicKey, + OnChainDidDetails { last_key_id, .. }: &mut OnChainDidDetails, + ) -> DispatchResult { + key.ensure_valid()?; + + PublicKeys::::insert(owner, last_key_id.inc(), key); + + Self::deposit_event(Event::KeyAdded(owner, *last_key_id)); + Ok(()) + } + + pub(super) fn remove_public_key_( + RemoveOffchainSignaturePublicKey { + key_ref: (did, counter), + did: owner, + .. + }: RemoveOffchainSignaturePublicKey, + _: &mut OnChainDidDetails, + ) -> DispatchResult { + ensure!(PublicKeys::::contains_key(did, counter), Error::::PublicKeyDoesntExist); + + ensure!(did == owner, Error::::NotOwner); + + PublicKeys::::remove(did, counter); + + Self::deposit_event(Event::KeyRemoved(owner, counter)); + Ok(()) + } + + pub fn did_public_keys(did: &Did) -> impl Iterator)> { + PublicKeys::::iter_prefix(did) + } +} diff --git a/pallets/did/src/modules/offchain_signatures/schemes.rs b/pallets/did/src/modules/offchain_signatures/schemes.rs new file mode 100644 index 0000000..e36a8f4 --- /dev/null +++ b/pallets/did/src/modules/offchain_signatures/schemes.rs @@ -0,0 +1,191 @@ +use crate::{ + common::{CurveType, Limits}, + offchain_signatures::SignatureParams, + util::BoundedBytes, +}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{CloneNoBound, DebugNoBound, EqNoBound, PartialEqNoBound}; +use sp_runtime::traits::CheckedConversion; + +use super::{Config, OffchainSignatureParams, SignatureParamsStorageKey}; +use crate::offchain_signatures::OffchainPublicKey; + +/// Identifier of the participant used in the threshold issuance. +pub type ParticipantId = u16; + +/// Defines public key and signature params for the given signature scheme. +macro_rules! def_signature_scheme_key_and_params { + (for $scheme: ident: $(#[$key_meta:meta])* $key: ident<$key_byte_size: ident>, $(#[$params_meta:meta])* $params: ident<$params_byte_size: ident>) => { + $(#[$key_meta])* + #[derive(scale_info_derive::TypeInfo, Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen)] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] + #[cfg_attr( + feature = "serde", + serde(bound(serialize = "T: Sized", deserialize = "T: Sized")) + )] + #[scale_info(skip_type_params(T))] + #[scale_info(omit_prefix)] + pub struct $key { + /// The public key should be for the same curve as the parameters but a public key might not have + /// parameters on chain + pub(crate) curve_type: CurveType, + pub(crate) bytes: BoundedBytes, + /// The params used to generate the public key + pub(crate) params_ref: Option, + /// Optional participant id used in threshold issuance. + pub(crate) participant_id: Option, + } + + impl $key { + /// Instantiates new public key for the signature scheme. + /// This function doesn't validate supplied bytes. + pub fn new( + bytes: BoundedBytes, + params_ref: impl Into>, + curve_type: CurveType, + ) -> Self { + Self { + bytes, + params_ref: params_ref.into(), + curve_type, + participant_id: None, + } + } + + /// Instantiates new public key with participant id for the signature scheme. + /// This function doesn't validate supplied bytes. + /// Participant id implies the usage of this key in threshold issuance. + pub fn new_with_participant_id( + bytes: BoundedBytes, + params_ref: impl Into>, + curve_type: CurveType, + participant_id: ParticipantId, + ) -> Self { + let mut this = Self::new(bytes, params_ref, curve_type); + this.participant_id = Some(participant_id); + + this + } + + /// Combines key with signature params (if exist and have same scheme). + pub fn with_params(self) -> ($key, Option<$params>) where T: Config { + let params = self + .params_ref + .as_ref() + .and_then(|(did, params_id)| SignatureParams::::get(did, params_id)) + .and_then(OffchainSignatureParams::checked_into); + + (self, params) + } + } + + impl From<$key> for ($key, Option<$params>) { + fn from(key: $key) -> ($key, Option<$params>) { + key.with_params() + } + } + + impl From<$key> for OffchainPublicKey { + fn from(key: $key) -> Self { + Self::$scheme(key) + } + } + + impl TryFrom> for $key { + type Error = OffchainPublicKey; + + fn try_from(key: OffchainPublicKey) -> Result<$key, OffchainPublicKey> { + match key { + OffchainPublicKey::$scheme(key) => Ok(key), + other => Err(other), + } + } + } + + impl TryFrom> for ($key, Option<$params>) { + type Error = OffchainPublicKey; + + fn try_from(key: OffchainPublicKey) -> Result<($key, Option<$params>), OffchainPublicKey> { + match key { + OffchainPublicKey::$scheme(key) => Ok(key.with_params()), + other => Err(other), + } + } + } + + $(#[$params_meta])* + #[derive(scale_info_derive::TypeInfo, Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen)] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] + #[cfg_attr( + feature = "serde", + serde(bound(serialize = "T: Sized", deserialize = "T: Sized")) + )] + #[scale_info(skip_type_params(T))] + #[scale_info(omit_prefix)] + pub struct $params { + /// The label (generating string) used to generate the params + pub(crate) label: Option>, + pub(crate) curve_type: CurveType, + pub(crate) bytes: BoundedBytes, + } + + impl $params { + /// Instantiates new parameters for the signature scheme. + /// This function doesn't validate supplied bytes. + pub fn new( + label: impl Into>>, + bytes: BoundedBytes, + curve_type: CurveType, + ) -> Self { + Self { + label: label.into(), + curve_type, + bytes, + } + } + } + + impl From<$params> for OffchainSignatureParams { + fn from(params: $params) -> Self { + Self::$scheme(params) + } + } + + impl TryFrom> for $params { + type Error = OffchainSignatureParams; + + fn try_from(key: OffchainSignatureParams) -> Result<$params, OffchainSignatureParams> { + match key { + OffchainSignatureParams::$scheme(params) => Ok(params), + other => Err(other), + } + } + } + } +} + +def_signature_scheme_key_and_params! { + for BBS: + /// Public key for the BBS signature scheme. + BBSPublicKey, + /// Signature parameters for the BBS signature scheme. + BBSParameters +} + +def_signature_scheme_key_and_params! { + for BBSPlus: + /// Public key for the BBS+ signature scheme. + BBSPlusPublicKey, + /// Signature parameters for the BBS+ signature scheme. + BBSPlusParameters +} + +def_signature_scheme_key_and_params! { + for PS: + /// Public key for the PS signature scheme. + PSPublicKey, + /// Signature parameters for the PS signature scheme. + PSParameters +} diff --git a/pallets/did/src/modules/offchain_signatures/tests.rs b/pallets/did/src/modules/offchain_signatures/tests.rs new file mode 100644 index 0000000..0940871 --- /dev/null +++ b/pallets/did/src/modules/offchain_signatures/tests.rs @@ -0,0 +1,1396 @@ +use super::*; +use crate::{ + common::CurveType, + did::{tests::check_did_detail, AddControllers}, + offchain_signatures, + tests::common::*, + util::BoundedBytes, +}; +use alloc::collections::BTreeMap; +use frame_support::assert_err; +use frame_system::Origin; +use sp_core::{sr25519, H256}; +use sp_runtime::traits::CheckedConversion; + +fn sign_add_params( + keypair: &sr25519::Pair, + ap: &AddOffchainSignatureParams, + signer: Did, + key_id: u32, +) -> DidSignature { + did_sig::(ap, keypair, SignatureParamsOwner(signer), key_id) +} + +fn sign_remove_params( + keypair: &sr25519::Pair, + rp: &RemoveOffchainSignatureParams, + signer: Did, + key_id: u32, +) -> DidSignature { + did_sig::(rp, keypair, SignatureParamsOwner(signer), key_id) +} + +fn sign_add_key( + keypair: &sr25519::Pair, + ak: &AddOffchainSignaturePublicKey, + signer: Did, + key_id: u32, +) -> DidSignature { + did_sig::(ak, keypair, Controller(signer), key_id) +} + +fn sign_remove_key( + keypair: &sr25519::Pair, + rk: &RemoveOffchainSignaturePublicKey, + signer: Did, + key_id: u32, +) -> DidSignature { + did_sig::(rk, keypair, Controller(signer), key_id) +} + +macro_rules! with_each_scheme { + ($key: ident, $params: ident $($tt: tt)+) => { + mod bbs { + use super::*; + use BBSPublicKey as $key; + use BBSParameters as $params; + + $($tt)+ + } + + mod bbs_plus { + use super::*; + use BBSPlusPublicKey as $key; + use BBSPlusParameters as $params; + + $($tt)+ + } + + mod ps { + use super::*; + use PSPublicKey as $key; + use PSParameters as $params; + + $($tt)+ + } + } +} + +fn sig_events() -> Vec { + System::events() + .iter() + .filter_map(|event_record| { + let frame_system::EventRecord:: { phase: _p, event, topics: _t } = + event_record; + match event { + TestEvent::OffchainSignature(e) => Some(e.clone()), + _ => None, + } + }) + .collect() +} + +with_each_scheme! { + SchemeKey, + SchemeParams + + #[test] + fn add_remove_params() { + ext().execute_with(|| { + run_to_block(5); + + let (author, author_kp) = newdid(); + let mut next_nonce = 5 + 1; + check_nonce(&author, next_nonce - 1); + + run_to_block(6); + + let (author_1, author_1_kp) = newdid(); + let mut next_nonce_1 = 6 + 1; + check_nonce(&author_1, next_nonce_1 - 1); + + run_to_block(10); + + assert!(vec![1u8; 600].try_into().map(|params_bytes| SchemeParams::::new(BoundedBytes::try_from(vec![0, 1, 2, 3]).unwrap(), params_bytes, CurveType::Bls12381)).is_err()); + + check_nonce(&author, next_nonce - 1); + + run_to_block(15); + + let params = SchemeParams::::new(BoundedBytes::try_from(vec![0, 1, 2, 3]).unwrap(), vec![1u8; 500].try_into().unwrap(), CurveType::Bls12381); + + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + None + ); + assert!( + !sig_events().contains(&offchain_signatures::Event::ParamsAdded( + SignatureParamsOwner(author), + 1u8.into() + )) + ); + check_nonce(&author, next_nonce - 1); + + run_to_block(20); + + let ap = AddOffchainSignatureParams { + params: params.clone().into(), + nonce: next_nonce, + }; + let sig = sign_add_params::(&author_kp, &ap, author, 1); + SignatureMod::add_params( + RuntimeOrigin::signed(1), + AddOffchainSignatureParams { + params: params.clone().into(), + nonce: next_nonce, + }, + sig, + ) + .unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(1u8) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + Some(params.clone().into()) + ); + + assert!( + sig_events().contains(&offchain_signatures::Event::ParamsAdded( + SignatureParamsOwner(author), + 1u8.into() + )) + ); + + run_to_block(21); + + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(2u8)), + None + ); + let params_1 = SchemeParams::::new(None, vec![1u8; 100].try_into().unwrap(), CurveType::Bls12381); + let ap = AddOffchainSignatureParams { + params: params_1.clone().into(), + nonce: next_nonce, + }; + let sig = sign_add_params::(&author_kp, &ap, author, 1); + SignatureMod::add_params( + RuntimeOrigin::signed(1), + AddOffchainSignatureParams { + params: params_1.clone().into(), + nonce: next_nonce, + }, + sig, + ) + .unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(2u8) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(2u8)), + Some(params_1.into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::ParamsAdded( + SignatureParamsOwner(author), + 2u8.into() + )) + ); + + run_to_block(25); + + let params_2 = + SchemeParams::::new(BoundedBytes::try_from(vec![0, 9, 1]).unwrap(), vec![9u8; 100].try_into().unwrap(), CurveType::Bls12381); + let ap = AddOffchainSignatureParams { + params: params_2.clone().into(), + nonce: next_nonce_1, + }; + let sig = sign_add_params::(&author_1_kp, &ap, author_1, 1); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(0u8) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author_1), IncId::from(1u8)), + None + ); + SignatureMod::add_params( + RuntimeOrigin::signed(1), + AddOffchainSignatureParams { + params: params_2.clone().into(), + nonce: next_nonce_1, + }, + sig, + ) + .unwrap(); + check_nonce(&author_1, next_nonce_1); + next_nonce_1 += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(1u8) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author_1), IncId::from(1u8)), + Some(params_2.clone().into()) + ); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(2u8) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::ParamsAdded( + SignatureParamsOwner(author_1), + 1u8.into() + )) + ); + + run_to_block(30); + + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(3u8)), + None + ); + let params_3 = SchemeParams::::new(None, vec![8u8; 100].try_into().unwrap(), CurveType::Bls12381); + let ap = AddOffchainSignatureParams { + params: params_3.clone().into(), + nonce: next_nonce, + }; + let sig = sign_add_params::(&author_kp, &ap, author, 1); + SignatureMod::add_params( + RuntimeOrigin::signed(1), + AddOffchainSignatureParams { + params: params_3.clone().into(), + nonce: next_nonce, + }, + sig, + ) + .unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(3u8) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(3u8)), + Some(params_3.clone().into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::ParamsAdded( + SignatureParamsOwner(author), + 3u8.into() + )) + ); + + let rf = (SignatureParamsOwner(author), 5u8.into()); + let rp = RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce, + }; + let sig = sign_remove_params::(&author_kp, &rp, author, 1); + assert_err!( + SignatureMod::remove_params(RuntimeOrigin::signed(1), rp, sig), + Error::::ParamsDontExist + ); + check_nonce(&author, next_nonce - 1); + + let rf = (SignatureParamsOwner(author), 2u8.into()); + let mut rp = RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce_1, + }; + + let sig = sign_remove_params::(&author_1_kp, &rp, author_1, 1); + assert_err!( + SignatureMod::remove_params(RuntimeOrigin::signed(1), rp.clone(), sig), + Error::::NotOwner + ); + check_nonce(&author_1, next_nonce_1 - 1); + + rp.nonce = next_nonce; + let sig = sign_remove_params::(&author_kp, &rp, author, 1); + SignatureMod::remove_params(RuntimeOrigin::signed(1), rp, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + // Counter doesn't go back + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(3u8) + ); + // Entry gone from storage + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(2u8)), + None + ); + // Other entries remain as it is + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(3u8)), + Some(params_3.clone().into()) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + Some(params.clone().into()) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author_1), IncId::from(1u8)), + Some(params_2.into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::ParamsRemoved( + SignatureParamsOwner(author), + 2u8.into() + )) + ); + + let rp = RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce, + }; + let sig = sign_remove_params::(&author_kp, &rp, author, 1); + // Cannot remove as already removed + assert_err!( + SignatureMod::remove_params( + RuntimeOrigin::signed(1), + RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce + }, + sig + ), + Error::::ParamsDontExist + ); + check_nonce(&author, next_nonce - 1); + + let rf = (SignatureParamsOwner(author_1), 1u8.into()); + let rp = RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce_1, + }; + let sig = sign_remove_params::(&author_1_kp, &rp, author_1, 1); + SignatureMod::remove_params(RuntimeOrigin::signed(1), rp, sig).unwrap(); + check_nonce(&author_1, next_nonce_1); + next_nonce_1 += 1; + // Counter doesn't go back + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(1u8) + ); + // Entry gone from storage + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author_1), IncId::from(1u8)), + None + ); + // Other entries remain as it is + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(3u8)), + Some(params_3.into()) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + Some(params.clone().into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::ParamsRemoved( + SignatureParamsOwner(author_1), + 1u8.into() + )) + ); + + let rp = RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce_1, + }; + let sig = sign_remove_params::(&author_1_kp, &rp, author_1, 1); + // Cannot remove as already removed + assert_err!( + SignatureMod::remove_params( + RuntimeOrigin::signed(1), + RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce_1 + }, + sig + ), + Error::::ParamsDontExist + ); + check_nonce(&author_1, next_nonce_1 - 1); + + let rf = (SignatureParamsOwner(author), 3u8.into()); + let rp = RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce, + }; + let sig = sign_remove_params::(&author_kp, &rp, author, 1); + SignatureMod::remove_params(RuntimeOrigin::signed(1), rp, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + // Counter doesn't go back + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(3u8) + ); + // Entry gone from storage + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(3u8)), + None + ); + // Other entries remain as it is + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + Some(params.into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::ParamsRemoved( + SignatureParamsOwner(author), + 3u8.into() + )) + ); + + let rf = (SignatureParamsOwner(author), 1u8.into()); + let rp = RemoveOffchainSignatureParams { + params_ref: rf, + nonce: next_nonce, + }; + let sig = sign_remove_params::(&author_kp, &rp, author, 1); + SignatureMod::remove_params(RuntimeOrigin::signed(1), rp, sig).unwrap(); + check_nonce(&author, next_nonce); + // Counter doesn't go back + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(3u8) + ); + // Entry gone from storage + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + None + ); + assert!( + sig_events().contains(&offchain_signatures::Event::ParamsRemoved( + SignatureParamsOwner(author), + 1u8.into() + )) + ); + }); + } + + #[test] + fn add_remove_public_key() { + ext().execute_with(|| { + run_to_block(10); + + let (author, author_kp) = newdid(); + let mut next_nonce = 10 + 1; + check_nonce(&author, next_nonce - 1); + + run_to_block(15); + + assert!(vec![1u8; 200].try_into().map(|bytes| SchemeKey::::new(bytes, None, CurveType::Bls12381)).is_err()); + + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert!( + !sig_events().contains(&offchain_signatures::Event::KeyAdded(author, 2u8.into())) + ); + check_nonce(&author, next_nonce - 1); + + run_to_block(30); + + let key = SchemeKey::new(vec![1u8; 100].try_into().unwrap(), None, CurveType::Bls12381); + let ak = AddOffchainSignaturePublicKey { + key: key.clone().into(), + did: author, + nonce: next_nonce, + }; + + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert_eq!(PublicKeys::::get(author, IncId::from(1u8)), None); + assert_eq!(PublicKeys::::get(author, IncId::from(2u8)), None); + assert!( + !sig_events().contains(&offchain_signatures::Event::KeyAdded(author, 2u8.into())) + ); + check_nonce(&author, next_nonce - 1); + + run_to_block(35); + + let sig = sign_add_key(&author_kp, &ak, author, 1); + SignatureMod::add_public_key(RuntimeOrigin::signed(1), ak, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert_eq!(PublicKeys::::get(author, IncId::from(1u8)), None); + assert_eq!( + PublicKeys::::get(author, IncId::from(2u8)), + Some(key.clone().into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyAdded(author, 2u8.into())) + ); + + assert_eq!(PublicKeys::::get(author, IncId::from(3u8)), None); + let key_1 = SchemeKey::new(vec![1u8; 100].try_into().unwrap(), None, CurveType::Bls12381); + let ak = AddOffchainSignaturePublicKey { + key: key.clone().into(), + did: author, + nonce: next_nonce, + }; + let sig = sign_add_key(&author_kp, &ak, author, 1); + SignatureMod::add_public_key(RuntimeOrigin::signed(1), ak, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(3u8)), + Some(key_1.into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyAdded(author, 3u8.into())) + ); + + run_to_block(45); + + let (author_1, author_kp_1) = newdid(); + let mut next_nonce_1 = 45 + 1; + + run_to_block(50); + + let key_2 = SchemeKey::new(vec![9u8; 100].try_into().unwrap(), None, CurveType::Bls12381); + let ak = AddOffchainSignaturePublicKey { + key: key_2.clone().into(), + did: author_1, + nonce: next_nonce_1, + }; + let sig = sign_add_key(&author_kp_1, &ak, author_1, 1); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(0u8) + ); + assert_eq!(PublicKeys::::get(author_1, IncId::from(1u8)), None); + assert_eq!(PublicKeys::::get(author_1, IncId::from(2u8)), None); + SignatureMod::add_public_key(RuntimeOrigin::signed(1), ak, sig).unwrap(); + check_nonce(&author_1, next_nonce_1); + next_nonce_1 += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(0u8) + ); + assert_eq!( + PublicKeys::::get(author_1, IncId::from(2u8)), + Some(key_2.clone().into()) + ); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyAdded(author_1, 2u8.into())) + ); + + run_to_block(55); + + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(3u8)), + None + ); + let key_3 = SchemeKey::new(vec![8u8; 100].try_into().unwrap(), None, CurveType::Bls12381); + let ak = AddOffchainSignaturePublicKey { + key: key_3.clone().into(), + did: author, + nonce: next_nonce, + }; + let sig = sign_add_key(&author_kp, &ak, author, 1); + SignatureMod::add_public_key(RuntimeOrigin::signed(1), ak, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(4u8)), + Some(key_3.clone().into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyAdded(author, 3u8.into())) + ); + + run_to_block(60); + + let rf = (author, 5u8.into()); + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: author, + nonce: next_nonce, + }; + let sig = sign_remove_key(&author_kp, &rk, author, 1); + assert_err!( + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig), + Error::::PublicKeyDoesntExist + ); + check_nonce(&author, next_nonce - 1); + + let rf = (author, 3u8.into()); + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: author_1, + nonce: next_nonce_1, + }; + let sig = sign_remove_key(&author_kp_1, &rk, author_1, 1); + assert_err!( + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig), + Error::::NotOwner + ); + + let rf = (author, 3u8.into()); + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: author, + nonce: next_nonce, + }; + let sig = sign_remove_key(&author_kp, &rk, author, 1); + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + + // Counter doesn't go back + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + // Entry gone from storage + assert_eq!(PublicKeys::::get(author, IncId::from(3u8)), None); + // Other entries remain as it is + assert_eq!( + PublicKeys::::get(author, IncId::from(4u8)), + Some(key_3.clone().into()) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(2u8)), + Some(key.clone().into()) + ); + assert_eq!( + PublicKeys::::get(author_1, IncId::from(2u8)), + Some(key_2.into()) + ); + + let rf = (author, 3u8.into()); + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: author, + nonce: next_nonce, + }; + let sig = sign_remove_key(&author_kp, &rk, author, 1); + // Cannot remove as already removed + assert_err!( + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig), + Error::::PublicKeyDoesntExist + ); + check_nonce(&author, next_nonce - 1); + + run_to_block(70); + + let rf = (author_1, 2u8.into()); + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: author_1, + nonce: next_nonce_1, + }; + let sig = sign_remove_key(&author_kp_1, &rk, author_1, 1); + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig).unwrap(); + check_nonce(&author_1, next_nonce_1); + next_nonce_1 += 1; + // Counter doesn't go back + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(0u8) + ); + // Entry gone from storage + assert_eq!(PublicKeys::::get(author_1, IncId::from(2u8)), None); + // Other entries remain as it is + assert_eq!( + PublicKeys::::get(author, IncId::from(4u8)), + Some(key_3.into()) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(2u8)), + Some(key.clone().into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyRemoved( + author_1, + 2u8.into() + )) + ); + + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: author_1, + nonce: next_nonce_1, + }; + let sig = sign_remove_key(&author_kp_1, &rk, author_1, 1); + // Cannot remove as already removed + assert_err!( + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig), + Error::::PublicKeyDoesntExist + ); + check_nonce(&author_1, next_nonce_1 - 1); + + let rf = (author, 4u8.into()); + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: author, + nonce: next_nonce, + }; + let sig = sign_remove_key(&author_kp, &rk, author, 1); + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + // Counter doesn't go back + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + // Entry gone from storage + assert_eq!(PublicKeys::::get(author, IncId::from(4u8)), None); + // Other entries remain as it is + assert_eq!(PublicKeys::::get(author, IncId::from(2u8)), Some(key.into())); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyRemoved(author, 4u8.into())) + ); + + let rf = (author, 2u8.into()); + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: author, + nonce: next_nonce, + }; + let sig = sign_remove_key(&author_kp, &rk, author, 1); + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig).unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + // Counter doesn't go back + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + // Entry gone from storage + assert_eq!(PublicKeys::::get(author, IncId::from(2u8)), None); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyRemoved(author, 2u8.into())) + ); + + run_to_block(80); + + let params = + SchemeParams::::new(BoundedBytes::try_from(vec![0, 1, 2, 3]).unwrap(), vec![19; 100].try_into().unwrap(), CurveType::Bls12381); + let ap = AddOffchainSignatureParams { + params: params.clone().into(), + nonce: next_nonce, + }; + let sig = sign_add_params::(&author_kp, &ap, author, 1); + SignatureMod::add_params( + RuntimeOrigin::signed(1), + AddOffchainSignatureParams { + params: params.clone().into(), + nonce: next_nonce, + }, + sig, + ) + .unwrap(); + check_nonce(&author, next_nonce); + next_nonce += 1; + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(1u8) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + Some(params.into()) + ); + + // Add key with reference to non-existent params + let key_4 = SchemeKey::new( + vec![92u8; 100].try_into().unwrap(), + Some((SignatureParamsOwner(author), 4u8.into())), + CurveType::Bls12381, + ); + let ak = AddOffchainSignaturePublicKey { + key: key_4.into(), + did: author_1, + nonce: next_nonce_1, + }; + let sig = sign_add_key(&author_kp_1, &ak, author_1, 1); + assert_err!( + SignatureMod::add_public_key(RuntimeOrigin::signed(1), ak, sig), + Error::::ParamsDontExist + ); + check_nonce(&author_1, next_nonce_1 - 1); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(0u8) + ); + + // Add key with reference to existent params + let key_4 = SchemeKey::new( + vec![92u8; 100].try_into().unwrap(), + Some((SignatureParamsOwner(author), 1u8.into())), + CurveType::Bls12381, + ); + let ak = AddOffchainSignaturePublicKey { + key: key_4.clone().into(), + did: author_1, + nonce: next_nonce_1, + }; + let sig = sign_add_key(&author_kp_1, &ak, author_1, 1); + SignatureMod::add_public_key(RuntimeOrigin::signed(1), ak, sig).unwrap(); + check_nonce(&author_1, next_nonce_1); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(0u8) + ); + assert_eq!( + PublicKeys::::get(author_1, IncId::from(3u8)), + Some(key_4.clone().into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyAdded(author_1, 3u8.into())) + ); + + let ak = AddOffchainSignaturePublicKey { + key: key_4.clone().into(), + did: author, + nonce: next_nonce, + }; + let sig = sign_add_key(&author_kp, &ak, author, 1); + SignatureMod::add_public_key(RuntimeOrigin::signed(1), ak, sig).unwrap(); + check_nonce(&author, next_nonce); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(1u8) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(5u8)), + Some(key_4.into()) + ); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyAdded(author, 5u8.into())) + ); + }); + } + + #[test] + fn add_remove_public_key_by_controller() { + ext().execute_with(|| { + run_to_block(10); + + let (did, did_kp) = newdid(); + let mut next_nonce = 10 + 1; + check_did_detail(&did, 1, 1, 1, next_nonce - 1); + + run_to_block(20); + + let (did_1, did_1_kp) = newdid(); + let mut next_nonce_1 = 20 + 1; + check_nonce(&did_1, next_nonce_1 - 1); + check_did_detail(&did_1, 1, 1, 1, next_nonce_1 - 1); + + // Make `did` controller of `did` + let add_controllers = AddControllers { + did: did_1, + controllers: vec![did].into_iter().map(Controller).collect(), + nonce: next_nonce_1, + }; + let sig = did_sig::<_, _, _>(&add_controllers, &did_1_kp, Controller(did_1), 1); + DIDModule::add_controllers(RuntimeOrigin::signed(1), add_controllers, sig).unwrap(); + assert!(DIDModule::is_controller(&did_1, &Controller(did))); + check_did_detail(&did_1, 1, 1, 2, next_nonce_1); + check_did_detail(&did, 1, 1, 1, next_nonce - 1); + next_nonce_1 += 1; + + let key = SchemeKey::new(vec![8u8; 100].try_into().unwrap(), None, CurveType::Bls12381); + let ak = AddOffchainSignaturePublicKey { + key: key.clone().into(), + did: did_1, + nonce: next_nonce, + }; + let sig = sign_add_key(&did_kp, &ak, did, 1); + SignatureMod::add_public_key(RuntimeOrigin::signed(1), ak, sig).unwrap(); + + check_did_detail(&did_1, 2, 1, 2, next_nonce_1 - 1); + check_did_detail(&did, 1, 1, 1, next_nonce); + + next_nonce += 1; + + assert_eq!( + PublicKeys::::get(did_1, IncId::from(2u8)), + Some(key.into()) + ); + assert_eq!(PublicKeys::::get(did, IncId::from(2u8)), None); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyAdded(did_1, 2u8.into())) + ); + + let rf = (did_1, 2u8.into()); + let rk = RemoveOffchainSignaturePublicKey { + key_ref: rf, + did: did_1, + nonce: next_nonce, + }; + let sig = sign_remove_key(&did_kp, &rk, did, 1); + SignatureMod::remove_public_key(RuntimeOrigin::signed(1), rk, sig).unwrap(); + + check_did_detail(&did_1, 2, 1, 2, next_nonce_1 - 1); + check_did_detail(&did, 1, 1, 1, next_nonce); + + assert_eq!(PublicKeys::::get(did_1, IncId::from(2u8)), None); + assert!( + sig_events().contains(&offchain_signatures::Event::KeyRemoved(did_1, 2u8.into())) + ); + }) + } + + #[test] + fn add_params_keys() { + ext().execute_with(|| { + run_to_block(10); + let (author, _) = newdid(); + let next_nonce = 10 + 1; + + run_to_block(20); + let (author_1, _) = newdid(); + + run_to_block(30); + let (author_2, _) = newdid(); + + let params = SchemeParams::::new(None, vec![5; 100].try_into().unwrap(), CurveType::Bls12381); + let params_1 = SchemeParams::::new(None, vec![6; 100].try_into().unwrap(), CurveType::Bls12381); + + let key = SchemeKey::new(vec![1; 80].try_into().unwrap(), None, CurveType::Bls12381); + let key_1 = SchemeKey::new(vec![2; 80].try_into().unwrap(), None, CurveType::Bls12381); + let key_2 = SchemeKey::new(vec![3; 80].try_into().unwrap(), None, CurveType::Bls12381); + + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(0u8) + ); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(0u8) + ); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_2)), + IncId::from(0u8) + ); + + run_to_block(35); + + assert!(SignatureMod::add_params_( + AddOffchainSignatureParams { + params: params.clone().into(), + nonce: next_nonce + }, + SignatureParamsOwner(author) + ) + .is_ok()); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(1u8) + ); + assert_eq!(PublicKeys::::get(author, IncId::from(1u8)), None); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + Some(params.clone().into()) + ); + + run_to_block(40); + + let did_detail = DIDModule::onchain_did_details(&author).unwrap(); + let ak = AddOffchainSignaturePublicKey { + key: key.clone().into(), + did: author, + nonce: did_detail.next_nonce().unwrap(), + }; + assert_eq!(did_detail.nonce + 1, ak.nonce); + assert!(>::try_exec_action_over_onchain_did( + SignatureMod::add_public_key_, + ak, + ) + .is_ok()); + assert_eq!( + PublicKeys::::get(author, IncId::from(2u8)), + Some(key.clone().into()) + ); + assert_eq!(PublicKeys::::get(author, IncId::from(3u8)), None); + + run_to_block(50); + + let did_detail = DIDModule::onchain_did_details(&author).unwrap(); + let ak = AddOffchainSignaturePublicKey { + key: key_1.clone().into(), + did: author, + nonce: did_detail.next_nonce().unwrap(), + }; + assert_eq!(did_detail.nonce + 1, ak.nonce); + assert!(>::try_exec_action_over_onchain_did( + SignatureMod::add_public_key_, + ak, + ) + .is_ok()); + assert_eq!( + PublicKeys::::get(author, IncId::from(2u8)), + Some(key.clone().into()) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(3u8)), + Some(key_1.clone().into()) + ); + + run_to_block(60); + + let did_detail = DIDModule::onchain_did_details(&author).unwrap(); + let ak = AddOffchainSignaturePublicKey { + key: key_2.clone().into(), + did: author, + nonce: did_detail.next_nonce().unwrap(), + }; + assert_eq!(did_detail.nonce + 1, ak.nonce); + assert!(>::try_exec_action_over_onchain_did( + SignatureMod::add_public_key_, + ak, + ) + .is_ok()); + assert_eq!( + PublicKeys::::get(author, IncId::from(2u8)), + Some(key.clone().into()) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(3u8)), + Some(key_1.clone().into()) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(4u8)), + Some(key_2.clone().into()) + ); + + run_to_block(70); + + let did_detail = DIDModule::onchain_did_details(&author).unwrap(); + assert!(SignatureMod::add_params_( + AddOffchainSignatureParams { + params: params_1.clone().into(), + nonce: did_detail.next_nonce().unwrap() + }, + SignatureParamsOwner(author) + ) + .is_ok()); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author)), + IncId::from(2u8) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(2u8)), + Some(key.clone().into()) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(3u8)), + Some(key_1.clone().into()) + ); + assert_eq!( + PublicKeys::::get(author, IncId::from(4u8)), + Some(key_2.into()) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(1u8)), + Some(params.clone().into()) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author), IncId::from(2u8)), + Some(params_1.into()) + ); + + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(0u8) + ); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_2)), + IncId::from(0u8) + ); + + run_to_block(80); + + let did_detail_1 = DIDModule::onchain_did_details(&author_1).unwrap(); + let ak = AddOffchainSignaturePublicKey { + key: key.clone().into(), + did: author_1, + nonce: did_detail_1.next_nonce().unwrap(), + }; + assert_eq!(did_detail_1.nonce + 1, ak.nonce); + assert!(>::try_exec_action_over_onchain_did( + SignatureMod::add_public_key_, + ak, + ) + .is_ok()); + assert_eq!( + PublicKeys::::get(author_1, IncId::from(2u8)), + Some(key.clone().into()) + ); + + run_to_block(90); + + let did_detail_1 = DIDModule::onchain_did_details(&author_1).unwrap(); + assert!(SignatureMod::add_params_( + AddOffchainSignatureParams { + params: params.clone().into(), + nonce: did_detail_1.next_nonce().unwrap() + }, + SignatureParamsOwner(author_1) + ) + .is_ok()); + assert_eq!( + ParamsCounter::::get(SignatureParamsOwner(author_1)), + IncId::from(1u8) + ); + assert_eq!( + PublicKeys::::get(author_1, IncId::from(2u8)), + Some(key.clone().into()) + ); + assert_eq!( + SignatureParams::::get(SignatureParamsOwner(author_1), IncId::from(1u8)), + Some(params.into()) + ); + + run_to_block(100); + + let did_detail_1 = DIDModule::onchain_did_details(&author_1).unwrap(); + let ak = AddOffchainSignaturePublicKey { + key: key_1.clone().into(), + did: author_1, + nonce: did_detail_1.next_nonce().unwrap(), + }; + assert_eq!(did_detail_1.nonce + 1, ak.nonce); + assert!(>::try_exec_action_over_onchain_did( + SignatureMod::add_public_key_, + ak, + ) + .is_ok()); + assert_eq!( + PublicKeys::::get(author_1, IncId::from(2u8)), + Some(key.into()) + ); + assert_eq!( + PublicKeys::::get(author_1, IncId::from(3u8)), + Some(key_1.into()) + ); + }); + } + + #[test] + fn get_params_and_keys() { + ext().execute_with(|| { + let (author, _) = newdid(); + + let (author_1, _) = newdid(); + + let params = SchemeParams::::new(None, vec![5; 100].try_into().unwrap(), CurveType::Bls12381); + let params_1 = SchemeParams::::new(None, vec![6; 100].try_into().unwrap(), CurveType::Bls12381); + let params_2 = SchemeParams::::new(None, vec![7; 100].try_into().unwrap(), CurveType::Bls12381); + + let key = SchemeKey::new(vec![1; 80].try_into().unwrap(), None, CurveType::Bls12381); + let key_1 = SchemeKey::new( + vec![2; 80].try_into().unwrap(), + Some((SignatureParamsOwner(author), 1u8.into())), + CurveType::Bls12381, + ); + let key_2 = SchemeKey::new( + vec![3; 80].try_into().unwrap(), + Some((SignatureParamsOwner(author_1), 1u8.into())), + CurveType::Bls12381, + ); + + assert_eq!( + SignatureMod::did_params(&SignatureParamsOwner(author)).count(), + 0 + ); + assert_eq!( + SignatureMod::did_params(&SignatureParamsOwner(author_1)).count(), + 0 + ); + assert_eq!( + SignatureMod::did_public_key(author, IncId::from(0u8)) + .and_then(|key| -> Option> { key.try_into().ok() }) + .map(SchemeKey::with_params), + None + ); + assert_eq!( + SignatureMod::did_public_key(author_1, IncId::from(0u8)) + .and_then(|key| -> Option> { key.try_into().ok() }) + .map(SchemeKey::with_params), + None + ); + + SignatureMod::add_params_( + AddOffchainSignatureParams { + params: params.clone().into(), + nonce: 0, // Doesn't matter + }, + SignatureParamsOwner(author), + ) + .unwrap(); + SignatureMod::add_params_( + AddOffchainSignatureParams { + params: params_1.clone().into(), + nonce: 0, // Doesn't matter + }, + SignatureParamsOwner(author_1), + ) + .unwrap(); + SignatureMod::add_params_( + AddOffchainSignatureParams { + params: params_2.clone().into(), + nonce: 0, // Doesn't matter + }, + SignatureParamsOwner(author_1), + ) + .unwrap(); + + assert_eq!( + SignatureMod::did_params(&SignatureParamsOwner(author)).collect::>(), + { + let mut m = BTreeMap::new(); + m.insert(1u8.into(), params.clone().into()); + m + } + ); + + assert_eq!( + SignatureMod::did_params(&SignatureParamsOwner(author_1)).collect::>(), + { + let mut m = BTreeMap::new(); + m.insert(1u8.into(), params_1.clone().into()); + m.insert(2u8.into(), params_2.into()); + m + } + ); + + let did_detail = DIDModule::onchain_did_details(&author).unwrap(); + let ak = AddOffchainSignaturePublicKey { + key: key.clone().into(), + did: author, + nonce: did_detail.next_nonce().unwrap(), + }; + assert!(>::try_exec_action_over_onchain_did( + SignatureMod::add_public_key_, + ak, + ) + .is_ok()); + assert_eq!( + SignatureMod::did_public_key(author, IncId::from(2u8)) + .and_then(|key| -> Option> { key.try_into().ok() }) + .map(SchemeKey::with_params), + Some((key.clone(), None)) + ); + + let did_detail_1 = DIDModule::onchain_did_details(&author_1).unwrap(); + let ak = AddOffchainSignaturePublicKey { + key: key_1.clone().into(), + did: author_1, + nonce: did_detail_1.next_nonce().unwrap(), + }; + assert!(>::try_exec_action_over_onchain_did( + SignatureMod::add_public_key_, + ak, + ) + .is_ok()); + assert_eq!( + SignatureMod::did_public_key(author_1, IncId::from(2u8)) + .and_then(|key| -> Option> { key.try_into().ok() }) + .map(SchemeKey::with_params), + Some((key_1.clone(), Some(params.clone()))) + ); + + let did_detail = DIDModule::onchain_did_details(&author).unwrap(); + let ak = AddOffchainSignaturePublicKey { + key: key_2.clone().into(), + did: author, + nonce: did_detail.next_nonce().unwrap(), + }; + assert!(>::try_exec_action_over_onchain_did( + SignatureMod::add_public_key_, + ak, + ) + .is_ok()); + assert_eq!( + SignatureMod::did_public_key(author, IncId::from(3u8)) + .and_then(|key| -> Option> { key.try_into().ok() }) + .map(SchemeKey::with_params), + Some((key_2.clone(), Some(params_1.clone()))) + ); + + assert_eq!( + SignatureMod::did_public_keys(&Controller(author_1)) + .map(|(idx, key)| (idx, key.checked_into::>().unwrap().with_params())) + .collect::>(), + { + let mut m = BTreeMap::new(); + m.insert(2u8.into(), (key_1.clone(), Some(params))); + m + } + ); + + assert_eq!( + SignatureMod::did_public_keys(&Controller(author)) + .map(|(idx, key)| (idx, key.checked_into::>().unwrap().with_params())) + .collect::>(), + { + let mut m = BTreeMap::new(); + m.insert(2u8.into(), (key, None)); + m.insert(3u8.into(), (key_2, Some(params_1))); + m + } + ); + + SignatureParams::::remove(SignatureParamsOwner(author), IncId::from(1u8)); + + assert_eq!( + SignatureMod::did_params(&SignatureParamsOwner(author)).count(), + 0 + ); + + assert_eq!( + SignatureMod::did_public_keys(&Controller(author_1)) + .map(|(idx, key)| (idx, key.checked_into::>().unwrap().with_params())) + .collect::>(), + { + let mut m = BTreeMap::new(); + m.insert(2u8.into(), (key_1, None)); + m + } + ); + }); + } +} diff --git a/pallets/did/src/modules/offchain_signatures/weights.rs b/pallets/did/src/modules/offchain_signatures/weights.rs new file mode 100644 index 0000000..9b3ec29 --- /dev/null +++ b/pallets/did/src/modules/offchain_signatures/weights.rs @@ -0,0 +1,204 @@ +//! Autogenerated weights for bbs_plus +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2022-08-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Native), WASM-EXECUTION: Interpreted, CHAIN: Some("mainnet"), DB CACHE: 128 + +// Executed Command: +// ./target/production/dock-node +// benchmark +// --execution=native +// --chain=mainnet +// --pallet=bbs_plus +// --extra +// --extrinsic=* +// --repeat=20 +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/bbs_plus/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for bbs_plus. +pub trait WeightInfo { + fn add_params_sr25519(b: u32, l: u32) -> Weight; + fn add_params_ed25519(b: u32, l: u32) -> Weight; + fn add_params_secp256k1(b: u32, l: u32) -> Weight; + fn remove_params_sr25519() -> Weight; + fn remove_params_ed25519() -> Weight; + fn remove_params_secp256k1() -> Weight; + fn add_public_sr25519(b: u32) -> Weight; + fn add_public_ed25519(b: u32) -> Weight; + fn add_public_secp256k1(b: u32) -> Weight; + fn remove_public_sr25519() -> Weight; + fn remove_public_ed25519() -> Weight; + fn remove_public_secp256k1() -> Weight; +} + +/// Weights for bbs_plus using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn add_params_sr25519(b: u32, l: u32) -> Weight { + Weight::from_all(52_181_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(7_000_u64).saturating_mul(b as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(9_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_params_ed25519(b: u32, l: u32) -> Weight { + Weight::from_all(52_658_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(b as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn add_params_secp256k1(b: u32, l: u32) -> Weight { + Weight::from_all(154_268_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn remove_params_sr25519() -> Weight { + Weight::from_all(56_041_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_params_ed25519() -> Weight { + Weight::from_all(52_544_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_params_secp256k1() -> Weight { + Weight::from_all(155_224_000_u64) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn add_public_sr25519(b: u32) -> Weight { + Weight::from_all(59_312_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(12_000_u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn add_public_ed25519(b: u32) -> Weight { + Weight::from_all(58_693_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn add_public_secp256k1(_b: u32) -> Weight { + Weight::from_all(162_846_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_public_sr25519() -> Weight { + Weight::from_all(59_284_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_public_ed25519() -> Weight { + Weight::from_all(57_625_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + fn remove_public_secp256k1() -> Weight { + Weight::from_all(161_804_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn add_params_sr25519(b: u32, l: u32) -> Weight { + Weight::from_all(52_181_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(7_000_u64).saturating_mul(b as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(9_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_params_ed25519(b: u32, l: u32) -> Weight { + Weight::from_all(52_658_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(b as u64)) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn add_params_secp256k1(b: u32, l: u32) -> Weight { + Weight::from_all(154_268_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(1_000_u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(2_000_u64).saturating_mul(l as u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + fn remove_params_sr25519() -> Weight { + Weight::from_all(56_041_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_params_ed25519() -> Weight { + Weight::from_all(52_544_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_params_secp256k1() -> Weight { + Weight::from_all(155_224_000_u64) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn add_public_sr25519(b: u32) -> Weight { + Weight::from_all(59_312_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(12_000_u64).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn add_public_ed25519(b: u32) -> Weight { + Weight::from_all(58_693_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(3_000_u64).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn add_public_secp256k1(_b: u32) -> Weight { + Weight::from_all(162_846_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_public_sr25519() -> Weight { + Weight::from_all(59_284_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_public_ed25519() -> Weight { + Weight::from_all(57_625_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + fn remove_public_secp256k1() -> Weight { + Weight::from_all(161_804_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } +} diff --git a/pallets/did/src/modules/revoke/actions.rs b/pallets/did/src/modules/revoke/actions.rs new file mode 100644 index 0000000..ef2355c --- /dev/null +++ b/pallets/did/src/modules/revoke/actions.rs @@ -0,0 +1,93 @@ +use super::*; +use frame_support::DebugNoBound; + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddRegistry { + pub id: RegistryId, + pub new_registry: Registry, +} + +/// Command to create a set of revocations withing a registry. +/// Creation of revocations is idempotent; creating a revocation that already exists is allowed, +/// but has no effect. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RevokeRaw { + /// The registry on which to operate + pub registry_id: RegistryId, + /// Credential ids which will be revoked + pub revoke_ids: BTreeSet, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +/// Command to remove a set of revocations within a registry. +/// Removal of revocations is idempotent; removing a revocation that doesn't exists is allowed, +/// but has no effect. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct UnRevokeRaw { + /// The registry on which to operate + pub registry_id: RegistryId, + /// Credential ids which will be revoked + pub revoke_ids: BTreeSet, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +/// Command to remove an entire registry. Removes all revocations in the registry as well as +/// registry metadata. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveRegistryRaw { + /// The registry on which to operate + pub registry_id: RegistryId, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +crate::impl_action! { + for RegistryId: + RevokeRaw with revoke_ids.len() as len, registry_id as target no_state_change, + UnRevokeRaw with revoke_ids.len() as len, registry_id as target no_state_change, + RemoveRegistryRaw with 1 as len, registry_id as target no_state_change +} + +/// Command to create a set of revocations withing a registry. +/// Creation of revocations is idempotent; creating a revocation that already exists is allowed, +/// but has no effect. +pub type Revoke = WithNonce>; +/// Command to remove a set of revocations within a registry. +/// Removal of revocations is idempotent; removing a revocation that doesn't exists is allowed, +/// but has no effect. +pub type UnRevoke = WithNonce>; +/// Command to remove an entire registry. Removes all revocations in the registry as well as +/// registry metadata. +pub type RemoveRegistry = WithNonce>; + +crate::impl_action_with_nonce! { + for RegistryId: + UnRevoke with data().len() as len, data().registry_id as target, + Revoke with data().len() as len, data().registry_id as target, + RemoveRegistry with data().len() as len, data().registry_id as target +} diff --git a/pallets/did/src/modules/revoke/benchmarks.rs b/pallets/did/src/modules/revoke/benchmarks.rs new file mode 100644 index 0000000..d5eb28e --- /dev/null +++ b/pallets/did/src/modules/revoke/benchmarks.rs @@ -0,0 +1,175 @@ +use super::*; +use crate::{ + common::state_change::ToStateChange, + did::{Did, DidSignature, UncheckedDidKey}, +}; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +use sp_core::U256; +use sp_std::iter::once; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MAX_REVOCATIONS: u32 = 1000; +const MAX_CONTROLLERS: u32 = 15; + +fn dummy_registry() -> Registry { + Registry { policy: Policy::one_of(once(Did([3; 32]))).unwrap(), add_only: false } +} + +crate::bench_with_all_pairs! { + with_pairs: + revoke_sr25519 for sr25519, revoke_ed25519 for ed25519, revoke_secp256k1 for secp256k1 { + { + let r in 1 .. MAX_REVOCATIONS as u32; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let reg_id = RegistryId([1u8; 32]); + let revoke_ids: BTreeSet<_> = (0..r).map(|i| U256::from(i).into()).map(RevokeId).collect(); + let revoke_raw = RevokeRaw { + /// The registry on which to operate + registry_id: reg_id, + /// Credential ids which will be revoked + revoke_ids: revoke_ids.clone(), + _marker: PhantomData + }; + + let revoke = Revoke::new_with_nonce(revoke_raw.clone(), 1u32.into()); + let sig = pair.sign(&revoke.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + super::Pallet::::new_registry_(AddRegistry { id: reg_id, new_registry: Registry { policy: Policy::one_of(&[did]).unwrap(), add_only: false } }).unwrap(); + }: revoke(RawOrigin::Signed(caller), revoke_raw, vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert!(revoke_ids + .iter() + .all(|id| Revocations::::contains_key(reg_id, id))); + } + + unrevoke_sr25519 for sr25519, unrevoke_ed25519 for ed25519, unrevoke_secp256k1 for secp256k1 { + { + let r in 1 .. MAX_REVOCATIONS as u32; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let reg_id = RegistryId([2u8; 32]); + let revoke_ids: BTreeSet<_> = (0..r).map(|i| U256::from(i).into()).map(RevokeId).collect(); + + super::Pallet::::new_registry_(AddRegistry { id: reg_id, new_registry: Registry { policy: Policy::one_of(&[did]).unwrap(), add_only: false } }).unwrap(); + + crate::revoke::Pallet::::revoke_( + RevokeRaw { + /// The registry on which to operate + registry_id: reg_id, + /// Credential ids which will be revoked + revoke_ids: revoke_ids.clone(), + _marker: PhantomData + }, + &mut dummy_registry() + ).unwrap(); + + let unrevoke_raw = UnRevokeRaw { + /// The registry on which to operate + registry_id: reg_id, + /// Credential ids which will be revoked + revoke_ids: revoke_ids.clone(), + _marker: PhantomData + }; + + let unrevoke = UnRevoke::new_with_nonce(unrevoke_raw.clone(), 1u32.into()); + let sig = pair.sign(&unrevoke.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: unrevoke(RawOrigin::Signed(caller), unrevoke_raw, vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert!(revoke_ids + .iter() + .all(|id| !Revocations::::contains_key(reg_id, id))); + } + + remove_registry_sr25519 for sr25519, remove_registry_ed25519 for ed25519, remove_registry_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let public = pair.public(); + let did = Did([3 as u8; Did::BYTE_SIZE]); + let reg_id = RegistryId([4 as u8; 32]); + let reg = Registry { + policy: Policy::one_of(once(did).chain((1..MAX_CONTROLLERS).map(U256::from).map(Into::into).map(Did)).collect::>()).unwrap(), + add_only: false, + }; + let add_reg = AddRegistry { + new_registry: reg.clone(), + id: reg_id + }; + let revoke_ids: BTreeSet<_> = (0..100).map(|i| U256::from(i).into()).map(RevokeId).collect(); + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + super::Pallet::::new_registry_(add_reg).unwrap(); + + crate::revoke::Pallet::::revoke_( + RevokeRaw { + /// The registry on which to operate + registry_id: reg_id, + /// Credential ids which will be revoked + revoke_ids: revoke_ids.clone(), + _marker: PhantomData + }, + &mut dummy_registry() + ).unwrap(); + + let rem_reg_raw = RemoveRegistryRaw { + registry_id: reg_id, + _marker: PhantomData + }; + let rem_reg = RemoveRegistry::new_with_nonce(rem_reg_raw.clone(), 1u32.into()); + let sig = pair.sign(&rem_reg.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: remove_registry(RawOrigin::Signed(caller), rem_reg_raw, vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert!(Registries::::get(reg_id).is_none()); + }; + + standard: + new_registry { + let c in 1 .. MAX_CONTROLLERS; + + let caller = whitelisted_caller(); + let did = Did([3 as u8; Did::BYTE_SIZE]); + let reg_id = RegistryId([4 as u8; 32]); + let reg = Registry { + policy: Policy::one_of(once(did).chain((1..c).map(U256::from).map(Into::into).map(Did)).collect::>()).unwrap(), + add_only: false, + }; + let add_reg = AddRegistry { + new_registry: reg.clone(), + id: reg_id + }; + + }: new_registry(RawOrigin::Signed(caller), add_reg) + verify { + assert_eq!(Registries::::get(reg_id).unwrap(), reg); + } +} diff --git a/pallets/did/src/modules/revoke/impl.rs b/pallets/did/src/modules/revoke/impl.rs new file mode 100644 index 0000000..55d260d --- /dev/null +++ b/pallets/did/src/modules/revoke/impl.rs @@ -0,0 +1,123 @@ +use super::*; +use crate::{ + common::{DidSignatureWithNonce, PolicyExecutionError}, + deposit_indexed_event, +}; + +impl Pallet { + pub(super) fn new_registry_( + AddRegistry { new_registry, id }: AddRegistry, + ) -> DispatchResult { + // check + new_registry.policy.ensure_valid()?; + ensure!(!Registries::::contains_key(id), Error::::RegExists); + + // execute + Registries::::insert(id, new_registry); + + deposit_indexed_event!(RegistryAdded(id)); + Ok(()) + } + + pub(super) fn revoke_( + RevokeRaw { registry_id, revoke_ids, .. }: RevokeRaw, + _: &mut Registry, + ) -> DispatchResult { + // execute + for cred_id in &revoke_ids { + Revocations::::insert(registry_id, cred_id, ()); + } + + deposit_indexed_event!(RevokedInRegistry(registry_id)); + Ok(()) + } + + pub(super) fn unrevoke_( + UnRevokeRaw { revoke_ids, registry_id, .. }: UnRevokeRaw, + registry: &mut Registry, + ) -> DispatchResult { + ensure!(!registry.add_only, Error::::AddOnly); + + // execute + for cred_id in &revoke_ids { + Revocations::::remove(registry_id, cred_id); + } + + deposit_indexed_event!(UnrevokedInRegistry(registry_id)); + Ok(()) + } + + pub(super) fn remove_registry_( + RemoveRegistryRaw { registry_id, .. }: RemoveRegistryRaw, + registry: &mut Option>, + ) -> DispatchResult { + let registry = registry.take().unwrap(); + ensure!(!registry.add_only, Error::::AddOnly); + + // execute + // TODO: limit and cursor + let _ = Revocations::::clear_prefix(registry_id, u32::MAX, None); + + deposit_indexed_event!(RegistryRemoved(registry_id)); + Ok(()) + } + + /// Executes action over target registry providing a mutable reference if all checks succeed. + /// + /// Checks: + /// 1. Ensure that the `StatusListCredential` exists. + /// 2. Verify that `proof` authorizes `action` according to `policy`. + /// 3. Verify that the action is not a replayed payload by ensuring each provided controller + /// nonce equals the last nonce plus 1. + /// + /// Returns a mutable reference to the underlying registry if the command is authorized, + /// otherwise returns Err. + pub(crate) fn try_exec_action_over_registry( + f: F, + action: A, + proof: Vec>, + ) -> Result + where + F: FnOnce(A, &mut Registry) -> Result, + A: Action, + WithNonce: ToStateChange, + E: From> + From + From> + From, + { + Self::try_exec_removable_action_over_registry( + |action, reg| f(action, reg.as_mut().unwrap()), + action, + proof, + ) + } + + /// Executes action over target registry providing a mutable reference if all checks succeed. + /// + /// Unlike `try_exec_action_over_registry`, this action may result in a removal of a Registry, + /// if the value under option will be taken. + /// + /// Checks: + /// 1. Ensure that the `Registry` exists. + /// 2. Verify that `proof` authorizes `action` according to `policy`. + /// 3. Verify that the action is not a replayed payload by ensuring each provided controller + /// nonce equals the last nonce plus 1. + /// + /// Returns a mutable reference to the underlying registry wrapped into an option if the command + /// is authorized, otherwise returns Err. + pub(crate) fn try_exec_removable_action_over_registry( + f: F, + action: A, + proof: Vec>, + ) -> Result + where + F: FnOnce(A, &mut Option>) -> Result, + A: Action, + WithNonce: ToStateChange, + E: From> + From + From> + From, + { + ensure!(!action.is_empty(), Error::EmptyPayload); + + Registries::try_mutate_exists(action.target(), |registry| { + Policy::try_exec_removable_action(registry, f, action, proof) + }) + } +} diff --git a/pallets/did/src/modules/revoke/mod.rs b/pallets/did/src/modules/revoke/mod.rs new file mode 100644 index 0000000..e95647f --- /dev/null +++ b/pallets/did/src/modules/revoke/mod.rs @@ -0,0 +1,286 @@ +#[cfg(feature = "serde")] +use crate::util::hex; +use crate::{ + common::{self, DidSignatureWithNonce, HasPolicy, Limits, Policy, SigValue, ToStateChange}, + did::{self}, + util::{Action, NonceError, WithNonce}, +}; +use alloc::collections::BTreeSet; +use codec::{Decode, Encode, MaxEncodedLen}; +use core::ops::{Index, RangeFull}; +use sp_std::{fmt::Debug, marker::PhantomData, vec::Vec}; + +use frame_support::{dispatch::DispatchResult, ensure, weights::Weight, DebugNoBound}; +use frame_system::ensure_signed; +use sp_std::prelude::*; +use weights::*; + +pub use actions::*; +pub use pallet::*; + +mod actions; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +mod r#impl; +#[cfg(test)] +pub mod tests; +mod weights; + +/// Points to an on-chain revocation registry. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct RegistryId(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub [u8; 32]); + +impl Index for RegistryId { + type Output = [u8; 32]; + + fn index(&self, _: RangeFull) -> &Self::Output { + &self.0 + } +} + +crate::impl_wrapper!(RegistryId([u8; 32])); + +/// Points to a revocation which may or may not exist in a registry. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct RevokeId(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub [u8; 32]); + +impl Index for RevokeId { + type Output = [u8; 32]; + + fn index(&self, _: RangeFull) -> &Self::Output { + &self.0 + } +} + +crate::impl_wrapper!(RevokeId([u8; 32])); + +/// Metadata about a revocation scope. +#[derive( + PartialEq, Eq, Encode, Decode, Clone, DebugNoBound, MaxEncodedLen, scale_info_derive::TypeInfo, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct Registry { + /// Who is allowed to update this registry. + pub policy: Policy, + /// true: credentials can be revoked, but not un-revoked and the registry can't be removed + /// either false: credentials can be revoked and un-revoked + pub add_only: bool, +} + +impl HasPolicy for Registry { + fn policy(&self) -> &Policy { + &self.policy + } +} + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config + did::Config { + /// The overarching event type. + type RuntimeEvent: From + + IsType<::RuntimeEvent> + + Into<::RuntimeEvent>; + } + + #[pallet::event] + pub enum Event { + /// Registry with given id created + RegistryAdded(RegistryId), + /// Some items were revoked from given registry id + RevokedInRegistry(RegistryId), + /// Some items were un-revoked from given registry id + UnrevokedInRegistry(RegistryId), + /// Registry with given id removed + RegistryRemoved(RegistryId), + } + + /// Revocation Error + #[pallet::error] + pub enum Error { + /// A revocation registry with that name already exists. + RegExists, + /// nonce is incorrect. This is related to replay protection. + IncorrectNonce, + /// Too many controllers specified. + TooManyControllers, + /// This registry is marked as add_only. Deletion of revocations is not allowed. Deletion + /// of the registry is not allowed. + AddOnly, + /// Action is empty. + EmptyPayload, + } + + impl From for Error { + fn from(NonceError::IncorrectNonce: NonceError) -> Self { + Self::IncorrectNonce + } + } + + /// Registry metadata + #[pallet::storage] + #[pallet::getter(fn get_revocation_registry)] + pub type Registries = StorageMap<_, Blake2_128Concat, RegistryId, Registry>; + + /// The single global revocation set + // double_map requires and explicit hasher specification for the second key. blake2_256 is + // the default. + #[pallet::storage] + #[pallet::getter(fn get_revocation_status)] + pub type Revocations = + StorageDoubleMap<_, Blake2_128Concat, RegistryId, Blake2_256, RevokeId, ()>; + + #[pallet::storage] + #[pallet::getter(fn version)] + pub type Version = StorageValue<_, common::StorageVersion, ValueQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub _marker: PhantomData, + } + + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + GenesisConfig { _marker: PhantomData } + } + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) { + Version::::put(common::StorageVersion::MultiKey); + } + } + + #[pallet::call] + impl Pallet { + /// Create a new revocation registry named `id` with `registry` metadata. + /// + /// # Errors + /// + /// Returns an error if `id` is already in use as a registry id. + /// + /// Returns an error if `registry.policy` is invalid. + #[pallet::weight(SubstrateWeight::::new_registry(add_registry.new_registry.policy.len()))] + #[pallet::call_index(0)] + pub fn new_registry(origin: OriginFor, add_registry: AddRegistry) -> DispatchResult { + ensure_signed(origin)?; + + Self::new_registry_(add_registry)?; + Ok(()) + } + + /// Create some revocations according to the `revoke` command. + /// + /// # Errors + /// + /// Returns an error if `revoke.last_modified` does not match the block number when the + /// registry referenced by `revoke.registry_id` was last modified. + /// + /// Returns an error if `proof` does not satisfy the policy requirements of the registry + /// referenced by `revoke.registry_id`. + #[pallet::weight(SubstrateWeight::::revoke(&proof[0])(revoke.len()))] + #[pallet::call_index(1)] + pub fn revoke( + origin: OriginFor, + revoke: RevokeRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_action_over_registry(Self::revoke_, revoke, proof)?; + Ok(()) + } + + /// Delete some revocations according to the `unrevoke` command. + /// + /// # Errors + /// + /// Returns an error if the registry referenced by `revoke.registry_id` is `add_only`. + /// + /// Returns an error if `unrevoke.last_modified` does not match the block number when the + /// registry referenced by `revoke.registry_id` was last modified. + /// + /// Returns an error if `proof` does not satisfy the policy requirements of the registry + /// referenced by `unrevoke.registry_id`. + #[pallet::weight(SubstrateWeight::::unrevoke(&proof[0])(unrevoke.len()))] + #[pallet::call_index(2)] + pub fn unrevoke( + origin: OriginFor, + unrevoke: UnRevokeRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_action_over_registry(Self::unrevoke_, unrevoke, proof)?; + Ok(()) + } + + /// Delete an entire registry. Deletes all revocations within the registry, as well as + /// registry metadata. Once the registry is deleted, it can be reclaimed by any party using + /// a call to `new_registry`. + /// + /// # Errors + /// + /// Returns an error if the registry referenced by `revoke.registry_id` is `add_only`. + /// + /// Returns an error if `removal.last_modified` does not match the block number when the + /// registry referenced by `removal.registry_id` was last modified. + /// + /// Returns an error if `proof` does not satisfy the policy requirements of the registry + /// referenced by `removal.registry_id`. + #[pallet::weight(SubstrateWeight::::remove_registry(&proof[0]))] + #[pallet::call_index(3)] + pub fn remove_registry( + origin: OriginFor, + removal: RemoveRegistryRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_removable_action_over_registry(Self::remove_registry_, removal, proof)?; + Ok(()) + } + } +} + +impl SubstrateWeight { + fn revoke(DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce) -> fn(u32) -> Weight { + match sig.sig { + SigValue::Sr25519(_) => Self::revoke_sr25519, + SigValue::Ed25519(_) => Self::revoke_ed25519, + } + } + + fn unrevoke(DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce) -> fn(u32) -> Weight { + match sig.sig { + SigValue::Sr25519(_) => Self::unrevoke_sr25519, + SigValue::Ed25519(_) => Self::unrevoke_ed25519, + } + } + + fn remove_registry(DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce) -> Weight { + (match sig.sig { + SigValue::Sr25519(_) => Self::remove_registry_sr25519, + SigValue::Ed25519(_) => Self::remove_registry_ed25519, + }()) + } +} diff --git a/pallets/did/src/modules/revoke/tests.rs b/pallets/did/src/modules/revoke/tests.rs new file mode 100644 index 0000000..ffdf2c5 --- /dev/null +++ b/pallets/did/src/modules/revoke/tests.rs @@ -0,0 +1,674 @@ +#![allow(clippy::type_complexity)] + +use super::*; +use crate::{ + common::{Policy, ToStateChange}, + did::Did, + tests::common::*, + util::{Action, WithNonce}, +}; +use alloc::collections::BTreeMap; +use frame_support::assert_noop; +use frame_system::Origin; +use sp_core::{sr25519, U256}; +use sp_std::{iter::once, marker::PhantomData}; + +pub fn get_pauth( + action: &A, + signers: &[(Did, &sr25519::Pair)], +) -> Vec> +where + WithNonce: ToStateChange, +{ + signers + .iter() + .map(|(did, kp)| { + let did_detail = DIDModule::onchain_did_details(did).unwrap(); + let next_nonce = did_detail.next_nonce().unwrap(); + let sp = WithNonce::::new_with_nonce(action.clone(), next_nonce); + let sig = did_sig_on_bytes(&sp.to_state_change().encode(), kp, *did, 1); + DidSignatureWithNonce { sig, nonce: next_nonce } + }) + .collect() +} + +pub fn get_nonces(signers: &[(Did, &sr25519::Pair)]) -> BTreeMap { + let mut nonces = BTreeMap::new(); + for (d, _) in signers { + let did_detail = DIDModule::onchain_did_details(d).unwrap(); + nonces.insert(*d, did_detail.nonce); + } + nonces +} + +pub fn check_nonce_increase(old_nonces: BTreeMap, signers: &[(Did, &sr25519::Pair)]) { + let new_nonces = get_nonces(signers); + assert_eq!(new_nonces.len(), old_nonces.len()); + for (d, new_nonce) in new_nonces { + assert_eq!(old_nonces.get(&d).unwrap() + 1, new_nonce); + } +} + +/// Tests every failure case in the module. +/// If a failure case is not covered, thats a bug. +/// If an error variant from Error is not covered, thats a bug. +/// +/// Tests in this module are named after the errors they check. +/// For example, `#[test] fn invalidpolicy` exercises the Error::InvalidPolicy. +mod errors { + use crate::common::{PolicyExecutionError, PolicyValidationError}; + + // Cannot do `use super::*` as that would import `Call` as `Call` which conflicts with `Call` in + // `tests::common` + use super::*; + use alloc::collections::BTreeSet; + use sp_runtime::DispatchError; + + #[test] + fn invalidpolicy() { + if !in_ext() { + return ext().execute_with(invalidpolicy) + } + + let ar = AddRegistry { + id: RGA, + new_registry: Registry { + policy: Policy::one_of(None::).unwrap(), + add_only: false, + }, + }; + + let err = RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap_err(); + assert_eq!(err, PolicyValidationError::Empty.into()); + } + + // this test has caught at least one bug + #[test] + fn notauthorized() { + if !in_ext() { + return ext().execute_with(notauthorized) + } + + fn assert_revoke_err( + policy: Policy, + signers: &[(Did, &sr25519::Pair)], + ) -> DispatchError { + let regid: RegistryId = RegistryId(random()); + let ar = AddRegistry { id: regid, new_registry: Registry { policy, add_only: false } }; + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let rev = RevokeRaw { + _marker: PhantomData, + registry_id: regid, + revoke_ids: random::<[[u8; 32]; 32]>().iter().cloned().map(Into::into).collect(), + }; + let pauth = get_pauth(&rev, signers); + dbg!(&rev); + dbg!(&pauth); + RevoMod::revoke(RuntimeOrigin::signed(ABBA), rev, pauth).unwrap_err() + } + + run_to_block(10); + + let (a, b, c) = (DIDA, DIDB, DIDC); + let (kpa, kpb, kpc) = (create_did(a), create_did(b), create_did(c)); + + let cases: &[(Policy, &[(Did, &sr25519::Pair)], &str)] = &[ + (Policy::one_of([a]).unwrap(), &[], "provide no signatures"), + (Policy::one_of([a]).unwrap(), &[(b, &kpb)], "wrong account; wrong key"), + (Policy::one_of([a]).unwrap(), &[(a, &kpb)], "correct account; wrong key"), + (Policy::one_of([a]).unwrap(), &[(a, &kpb)], "wrong account; correct key"), + (Policy::one_of([a, b]).unwrap(), &[(c, &kpc)], "account not a controller"), + (Policy::one_of([a, b]).unwrap(), &[(a, &kpa), (b, &kpb)], "two signers"), + (Policy::one_of([a]).unwrap(), &[], "one controller; no sigs"), + (Policy::one_of([a, b]).unwrap(), &[], "two controllers; no sigs"), + ]; + + for (pol, set, description) in cases { + dbg!(description); + assert_eq!( + assert_revoke_err(pol.clone(), set), + PolicyExecutionError::NotAuthorized.into(), + "{}", + description + ); + } + } + + #[test] + /// sign unrelated commands and ensure they fail + fn notauthorized_wrong_command() { + if !in_ext() { + return ext().execute_with(notauthorized_wrong_command) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let registry_id = RGA; + let add_only = false; + + run_to_block(10); + + let kpa = create_did(DIDA); + let reg = Registry { policy, add_only }; + + let ar = AddRegistry { id: registry_id, new_registry: reg }; + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let unrevoke = UnRevokeRaw { + _marker: PhantomData, + registry_id, + revoke_ids: once(RevokeId(Default::default())).collect(), + }; + let ur_proof = get_pauth(&unrevoke, &[(DIDA, &kpa)]); + RevoMod::unrevoke(RuntimeOrigin::signed(ABBA), unrevoke.clone(), ur_proof).unwrap(); + + let rev = RevokeRaw { + _marker: PhantomData, + registry_id, + revoke_ids: once(RevokeId(Default::default())).collect(), + }; + let ur_proof = get_pauth(&unrevoke, &[(DIDA, &kpa)]); + assert_eq!( + RevoMod::revoke(RuntimeOrigin::signed(ABBA), rev, ur_proof).unwrap_err(), + PolicyExecutionError::NotAuthorized.into() + ); + + let ur_proof = get_pauth(&unrevoke, &[(DIDA, &kpa)]); + RevoMod::unrevoke(RuntimeOrigin::signed(ABBA), unrevoke, ur_proof).unwrap(); + } + + #[test] + fn regexists() { + if !in_ext() { + return ext().execute_with(regexists) + } + + let reg = Registry { policy: Policy::one_of([DIDA]).unwrap(), add_only: false }; + let ar = AddRegistry { id: RGA, new_registry: reg }; + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar.clone()).unwrap(); + let err = RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap_err(); + assert_eq!(err, Error::::RegExists.into()); + } + + #[test] + fn noreg() { + if !in_ext() { + return ext().execute_with(noreg) + } + + let registry_id = RGA; + + let noreg: Result<(), DispatchError> = Err(PolicyExecutionError::NoEntity.into()); + + assert_eq!( + RevoMod::revoke( + RuntimeOrigin::signed(ABBA), + RevokeRaw { + _marker: PhantomData, + registry_id, + revoke_ids: once(RevokeId(Default::default())).collect(), + }, + vec![] + ), + noreg + ); + assert_eq!( + RevoMod::unrevoke( + RuntimeOrigin::signed(ABBA), + UnRevokeRaw { + _marker: PhantomData, + registry_id, + revoke_ids: once(RevokeId(Default::default())).collect(), + }, + vec![], + ), + noreg + ); + assert_eq!( + RevoMod::remove_registry( + RuntimeOrigin::signed(ABBA), + RemoveRegistryRaw { _marker: PhantomData, registry_id }, + vec![], + ), + noreg + ); + } + + #[test] + fn too_many_controllers() { + if !in_ext() { + return ext().execute_with(incorrect_nonce) + } + + let registry_id = RGA; + let err = Error::::TooManyControllers; + + let ar = AddRegistry { + id: registry_id, + new_registry: Registry { + policy: Policy::one_of((0u8..16).map(U256::from).map(Into::into).map(Did)).unwrap(), + add_only: false, + }, + }; + + assert_noop!(RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar), err); + } + + #[test] + fn emtpy_payload() { + if !in_ext() { + return ext().execute_with(incorrect_nonce) + } + let err = Error::::EmptyPayload; + + let kpa = create_did(DIDA); + let registry_id = RGA; + let reg = Registry { policy: Policy::one_of([DIDA]).unwrap(), add_only: false }; + let ar = AddRegistry { id: RGA, new_registry: reg }; + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + let revoke_raw = + RevokeRaw { _marker: PhantomData, registry_id, revoke_ids: Default::default() }; + let proof = get_pauth(&revoke_raw, &[(DIDA, &kpa)]); + + assert_noop!(RevoMod::revoke(RuntimeOrigin::signed(ABBA), revoke_raw, proof), err); + } + + #[test] + fn incorrect_nonce() { + if !in_ext() { + return ext().execute_with(incorrect_nonce) + } + + run_to_block(1); + + let kpa = create_did(DIDA); + + let registry_id = RGA; + let err: Result<(), DispatchError> = Err(PolicyExecutionError::IncorrectNonce.into()); + + let ar = AddRegistry { + id: registry_id, + new_registry: Registry { policy: Policy::one_of([DIDA]).unwrap(), add_only: false }, + }; + + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let rev = RevokeRaw { + _marker: PhantomData, + registry_id, + revoke_ids: once(RevokeId(Default::default())).collect(), + }; + let proof = get_pauth(&rev, &[(DIDA, &kpa)]); + + // Increase nonce to make the auth chekc fail + inc_nonce(&DIDA); + assert_eq!(RevoMod::revoke(RuntimeOrigin::signed(ABBA), rev, proof), err); + + let unrevoke = UnRevokeRaw { + _marker: PhantomData, + registry_id, + revoke_ids: once(RevokeId(Default::default())).collect(), + }; + let proof = get_pauth(&unrevoke, &[(DIDA, &kpa)]); + + // Increase nonce to make the auth check fail + inc_nonce(&DIDA); + assert_eq!(RevoMod::unrevoke(RuntimeOrigin::signed(ABBA), unrevoke, proof,), err); + + let remove = RemoveRegistryRaw { _marker: PhantomData, registry_id }; + let proof = get_pauth(&remove, &[(DIDA, &kpa)]); + + // Increase nonce to make the auth check fail + inc_nonce(&DIDA); + assert_eq!(RevoMod::remove_registry(RuntimeOrigin::signed(ABBA), remove, proof,), err); + } + + #[test] + fn addonly() { + if !in_ext() { + return ext().execute_with(addonly) + } + + let registry_id = RGA; + let err: Result<(), DispatchError> = Err(Error::::AddOnly.into()); + let revoke_ids: BTreeSet<_> = [RA, RB, RC].iter().cloned().collect(); + + run_to_block(1); + + let kpa = create_did(DIDA); + + let ar = AddRegistry { + id: registry_id, + new_registry: Registry { policy: Policy::one_of([DIDA]).unwrap(), add_only: true }, + }; + + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let unrevoke = UnRevokeRaw { _marker: PhantomData, registry_id, revoke_ids }; + let proof = get_pauth(&unrevoke, &[(DIDA, &kpa)]); + assert_eq!(RevoMod::unrevoke(RuntimeOrigin::signed(ABBA), unrevoke, proof), err); + + let remove = RemoveRegistryRaw { _marker: PhantomData, registry_id }; + let proof = get_pauth(&remove, &[(DIDA, &kpa)]); + assert_eq!(RevoMod::remove_registry(RuntimeOrigin::signed(ABBA), remove, proof), err); + } + + // Untested variants will be a match error. + // To fix the match error, write a test for the variant then update the test. + fn _all_included(dummy: Error) { + match dummy { + Error::__Ignore(_, _) | + Error::RegExists | + Error::EmptyPayload | + Error::IncorrectNonce | + Error::AddOnly | + Error::TooManyControllers => {}, + } + } +} + +/// Tests every happy path for every public extrinsic call in the module. +/// If a happy path is not covered, thats a bug. +/// If a call is not covered, thats a bug. +/// +/// Tests in this module are named after the calls they check. +/// For example, `#[test] fn new_registry` tests the happy path for Module::new_registry. +mod calls { + use super::*; + // Cannot do `use super::super::*` as that would import `Call` as `Call` which conflicts with + // `Call` in `tests::common` + use super::super::{Call as RevCall, Registries, Revocations}; + use alloc::collections::BTreeSet; + + #[test] + fn new_registry() { + if !in_ext() { + return ext().execute_with(new_registry) + } + + let cases: &[(Policy, bool)] = &[ + (Policy::one_of([DIDA]).unwrap(), false), + (Policy::one_of([DIDA, DIDB]).unwrap(), false), + (Policy::one_of([DIDA]).unwrap(), true), + (Policy::one_of([DIDA, DIDB]).unwrap(), true), + ]; + for (policy, add_only) in cases.iter().cloned() { + let reg_id = RegistryId(random()); + let reg = Registry { policy, add_only }; + let ar = AddRegistry { id: reg_id, new_registry: reg.clone() }; + assert!(!Registries::::contains_key(reg_id)); + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + assert!(Registries::::contains_key(reg_id)); + assert_eq!(Registries::::get(reg_id).unwrap(), reg); + } + } + + #[test] + fn revoke() { + if !in_ext() { + return ext().execute_with(revoke) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let registry_id = RGA; + let add_only = true; + + run_to_block(1); + + let kpa = create_did(DIDA); + + let ar = AddRegistry { id: registry_id, new_registry: Registry { policy, add_only } }; + + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let cases: &[&[RevokeId]] = &[ + // &[], + &[RevokeId(random())], + &[RevokeId(random()), RevokeId(random())], + &[RevokeId(random()), RevokeId(random()), RevokeId(random())], + &[RA], // Test idempotence, step 1 + &[RA], // Test idempotence, step 2 + ]; + for (i, ids) in cases.iter().enumerate() { + println!("Revoke ids: {:?}", ids); + let revoke = RevokeRaw { + _marker: PhantomData, + registry_id, + revoke_ids: ids.iter().cloned().collect(), + }; + let proof = get_pauth(&revoke, &[(DIDA, &kpa)]); + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + RevoMod::revoke(RuntimeOrigin::signed(ABBA), revoke, proof).unwrap(); + assert!(ids.iter().all(|id| Revocations::::contains_key(registry_id, id))); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + run_to_block(1 + 1 + i as u64); + } + } + + #[test] + fn unrevoke() { + if !in_ext() { + return ext().execute_with(unrevoke) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let registry_id = RGA; + let add_only = false; + + run_to_block(10); + + let kpa = create_did(DIDA); + + enum Action { + Revoke, + UnRevo, + AsrtRv, // assert revoked + AsrtNR, // assert not revoked + } + + let ar = AddRegistry { id: registry_id, new_registry: Registry { policy, add_only } }; + + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let cases: &[(Action, &[RevokeId], u32)] = &[ + //(Action::UnRevo, &[], line!()), + (Action::UnRevo, &[RevokeId(random())], line!()), + (Action::UnRevo, &[RevokeId(random()), RevokeId(random())], line!()), + ( + Action::UnRevo, + &[RevokeId(random()), RevokeId(random()), RevokeId(random())], + line!(), + ), + (Action::Revoke, &[RA, RB], line!()), + (Action::AsrtRv, &[RA, RB], line!()), + (Action::UnRevo, &[RA], line!()), + (Action::AsrtNR, &[RA], line!()), + (Action::AsrtRv, &[RB], line!()), + (Action::UnRevo, &[RA, RB], line!()), + (Action::AsrtNR, &[RA, RB], line!()), + (Action::Revoke, &[RA, RB], line!()), + (Action::AsrtRv, &[RA, RB], line!()), + (Action::UnRevo, &[RA, RB], line!()), + (Action::AsrtNR, &[RA, RB], line!()), + ]; + for (i, (action, ids, line_no)) in cases.iter().enumerate() { + eprintln!("running action from line {}", line_no); + let revoke_ids: BTreeSet = ids.iter().cloned().collect(); + match action { + Action::Revoke => { + let revoke = RevokeRaw { _marker: PhantomData, registry_id, revoke_ids }; + let proof = get_pauth(&revoke, &[(DIDA, &kpa)]); + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + RevoMod::revoke(RuntimeOrigin::signed(ABBA), revoke, proof).unwrap(); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + }, + Action::UnRevo => { + let unrevoke = UnRevokeRaw { + _marker: PhantomData, + registry_id, + revoke_ids: revoke_ids.clone(), + }; + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + let proof = get_pauth(&unrevoke, &[(DIDA, &kpa)]); + RevoMod::unrevoke(RuntimeOrigin::signed(ABBA), unrevoke, proof).unwrap(); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + }, + Action::AsrtRv => { + assert!(revoke_ids + .iter() + .all(|id| Revocations::::contains_key(registry_id, id))); + }, + Action::AsrtNR => { + assert!(!revoke_ids + .iter() + .any(|id| Revocations::::contains_key(registry_id, id))); + }, + } + run_to_block(10 + 1 + i as u64) + } + } + + #[test] + fn remove_registry() { + if !in_ext() { + return ext().execute_with(remove_registry) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let registry_id = RGA; + let add_only = false; + let kpa = create_did(DIDA); + + let reg = Registry { policy, add_only }; + let ar = AddRegistry { id: registry_id, new_registry: reg }; + + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + assert!(Registries::::contains_key(registry_id)); + + // destroy reg + let rem = RemoveRegistryRaw { _marker: PhantomData, registry_id }; + let proof = get_pauth(&rem, &[(DIDA, &kpa)]); + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + RevoMod::remove_registry(RuntimeOrigin::signed(ABBA), rem, proof).unwrap(); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + + // assert not exists + assert!(!Registries::::contains_key(registry_id)); + } + + // Untested variants will be a match error. + // To fix the match error, write a test for the variant then update the test. + fn _all_included(dummy: RevCall) { + match dummy { + RevCall::new_registry { .. } | + RevCall::revoke { .. } | + RevCall::unrevoke { .. } | + RevCall::remove_registry { .. } | + RevCall::__Ignore { .. } => {}, + } + } +} + +mod test { + use sp_runtime::DispatchError; + // Cannot do `use super::*` as that would import `Call` as `Call` which conflicts with `Call` in + // `tests::common` + use super::*; + use crate::revoke::Registries; + + #[test] + /// Exercises Module::ensure_auth, both success and failure cases. + fn ensure_auth() { + if !in_ext() { + return ext().execute_with(ensure_auth) + } + + run_to_block(10); + + let (a, b, c): (Did, Did, Did) = (Did(random()), Did(random()), Did(random())); + let (kpa, kpb, kpc) = (create_did(a), create_did(b), create_did(c)); + let rev = RevokeRaw { + _marker: PhantomData, + registry_id: RGA, + revoke_ids: once(RevokeId(Default::default())).collect(), + }; + + let cases: &[(u32, Policy, &[(Did, &sr25519::Pair)], bool)] = &[ + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpa)], true), + (line!(), Policy::one_of([a, b]).unwrap(), &[(a, &kpa)], true), + (line!(), Policy::one_of([a, b]).unwrap(), &[(b, &kpb)], true), + (line!(), Policy::one_of([a]).unwrap(), &[], false), // provide no signatures + (line!(), Policy::one_of([a]).unwrap(), &[(b, &kpb)], false), // wrong account; wrong key + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpb)], false), // correct account; wrong key + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpb)], false), // wrong account; correct key + (line!(), Policy::one_of([a, b]).unwrap(), &[(c, &kpc)], false), // account not a controller + (line!(), Policy::one_of([a, b]).unwrap(), &[(a, &kpa), (b, &kpb)], false), // two signers + (line!(), Policy::one_of([a]).unwrap(), &[], false), // one controller; no sigs + (line!(), Policy::one_of([a, b]).unwrap(), &[], false), // two controllers; no sigs + ]; + for (i, (line_no, policy, signers, expect_success)) in cases.iter().enumerate() { + eprintln!("running case from line {}", line_no); + Registries::::insert(RGA, Registry { policy: policy.clone(), add_only: false }); + + let old_nonces = get_nonces(signers); + let command = &rev; + let proof = get_pauth(command, signers); + let res = RevoMod::try_exec_action_over_registry( + |_, _| Ok::<_, DispatchError>(()), + command.clone(), + proof, + ); + assert_eq!(res.is_ok(), *expect_success); + + if *expect_success { + check_nonce_increase(old_nonces, signers); + } + run_to_block(10 + 1 + i as u64); + } + } + + #[test] + /// Exercises the revocation registry convenience getter, get_revocation_registry. + fn get_revocation_registry() { + if !in_ext() { + return ext().execute_with(get_revocation_registry) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let registry_id = RGA; + let add_only = false; + let reg = Registry { policy, add_only }; + + let ar = AddRegistry { id: registry_id, new_registry: reg.clone() }; + + assert_eq!(RevoMod::get_revocation_registry(registry_id), None); + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + assert_eq!(RevoMod::get_revocation_registry(registry_id), Some(reg)); + } + + #[test] + /// Exercises the revocation status convenience getter, get_revocation_status. + fn get_revocation_status() { + if !in_ext() { + return ext().execute_with(get_revocation_status) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let registry_id = RGA; + let add_only = false; + let reg = Registry { policy, add_only }; + let kpa = create_did(DIDA); + let revid: RevokeId = RevokeId(random()); + + let ar = AddRegistry { id: registry_id, new_registry: reg }; + + RevoMod::new_registry(RuntimeOrigin::signed(ABBA), ar).unwrap(); + let revoke = + RevokeRaw { _marker: PhantomData, registry_id, revoke_ids: once(revid).collect() }; + let proof = get_pauth(&revoke, &[(DIDA, &kpa)]); + + assert_eq!(RevoMod::get_revocation_status(registry_id, revid), None); + RevoMod::revoke(RuntimeOrigin::signed(ABBA), revoke, proof).unwrap(); + assert_eq!(RevoMod::get_revocation_status(registry_id, revid), Some(())); + } +} diff --git a/pallets/did/src/modules/revoke/weights.rs b/pallets/did/src/modules/revoke/weights.rs new file mode 100644 index 0000000..6c1be5d --- /dev/null +++ b/pallets/did/src/modules/revoke/weights.rs @@ -0,0 +1,190 @@ +//! Autogenerated weights for revoke +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2022-08-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Native), WASM-EXECUTION: Interpreted, CHAIN: Some("mainnet"), DB CACHE: 128 + +// Executed Command: +// ./target/production/dock-node +// benchmark +// --execution=native +// --chain=mainnet +// --pallet=revoke +// --extra +// --extrinsic=* +// --repeat=20 +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/revoke/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for revoke. +pub trait WeightInfo { + fn revoke_sr25519(r: u32) -> Weight; + fn revoke_ed25519(r: u32) -> Weight; + fn revoke_secp256k1(r: u32) -> Weight; + fn unrevoke_sr25519(r: u32) -> Weight; + fn unrevoke_ed25519(r: u32) -> Weight; + fn unrevoke_secp256k1(r: u32) -> Weight; + fn remove_registry_sr25519() -> Weight; + fn remove_registry_ed25519() -> Weight; + fn remove_registry_secp256k1() -> Weight; + fn new_registry(c: u32) -> Weight; +} + +/// Weights for revoke using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn revoke_sr25519(r: u32) -> Weight { + Weight::from_all(51_886_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(744_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn revoke_ed25519(r: u32) -> Weight { + Weight::from_all(55_942_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(718_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn revoke_secp256k1(r: u32) -> Weight { + Weight::from_all(148_000_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(707_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn unrevoke_sr25519(r: u32) -> Weight { + Weight::from_all(67_695_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(741_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn unrevoke_ed25519(r: u32) -> Weight { + Weight::from_all(65_882_000_u64) + // Standard Error: 3_000 + .saturating_add(Weight::from_all(747_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn unrevoke_secp256k1(r: u32) -> Weight { + Weight::from_all(166_568_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(704_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_registry_sr25519() -> Weight { + Weight::from_all(128_526_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(103_u64)) + } + fn remove_registry_ed25519() -> Weight { + Weight::from_all(122_116_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(103_u64)) + } + fn remove_registry_secp256k1() -> Weight { + Weight::from_all(230_576_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(103_u64)) + } + fn new_registry(c: u32) -> Weight { + Weight::from_all(9_069_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(35_000_u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn revoke_sr25519(r: u32) -> Weight { + Weight::from_all(51_886_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(744_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn revoke_ed25519(r: u32) -> Weight { + Weight::from_all(55_942_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(718_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn revoke_secp256k1(r: u32) -> Weight { + Weight::from_all(148_000_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(707_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn unrevoke_sr25519(r: u32) -> Weight { + Weight::from_all(67_695_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(741_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn unrevoke_ed25519(r: u32) -> Weight { + Weight::from_all(65_882_000_u64) + // Standard Error: 3_000 + .saturating_add(Weight::from_all(747_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn unrevoke_secp256k1(r: u32) -> Weight { + Weight::from_all(166_568_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(704_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_registry_sr25519() -> Weight { + Weight::from_all(128_526_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(103_u64)) + } + fn remove_registry_ed25519() -> Weight { + Weight::from_all(122_116_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(103_u64)) + } + fn remove_registry_secp256k1() -> Weight { + Weight::from_all(230_576_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(103_u64)) + } + fn new_registry(c: u32) -> Weight { + Weight::from_all(9_069_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(35_000_u64).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } +} diff --git a/pallets/did/src/modules/status_list_credential/actions.rs b/pallets/did/src/modules/status_list_credential/actions.rs new file mode 100644 index 0000000..4fe0da1 --- /dev/null +++ b/pallets/did/src/modules/status_list_credential/actions.rs @@ -0,0 +1,49 @@ +use frame_support::DebugNoBound; +use sp_std::marker::PhantomData; + +use crate::{common::Limits, util::WithNonce}; +use codec::{Decode, Encode}; + +use super::{StatusListCredential, StatusListCredentialId}; + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, DebugNoBound, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct UpdateStatusListCredentialRaw { + pub id: StatusListCredentialId, + pub credential: StatusListCredential, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, DebugNoBound, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveStatusListCredentialRaw { + pub id: StatusListCredentialId, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +crate::impl_action! { + for StatusListCredentialId: + UpdateStatusListCredentialRaw with 1 as len, id as target no_state_change, + RemoveStatusListCredentialRaw with 1 as len, id as target no_state_change +} + +pub type UpdateStatusListCredential = WithNonce>; +pub type RemoveStatusListCredential = WithNonce>; + +crate::impl_action_with_nonce! { + for StatusListCredentialId: + UpdateStatusListCredential with data().len() as len, data().id as target, + RemoveStatusListCredential with data().len() as len, data().id as target +} diff --git a/pallets/did/src/modules/status_list_credential/benchmarks.rs b/pallets/did/src/modules/status_list_credential/benchmarks.rs new file mode 100644 index 0000000..bc83844 --- /dev/null +++ b/pallets/did/src/modules/status_list_credential/benchmarks.rs @@ -0,0 +1,117 @@ +use super::*; +use crate::{ + common::state_change::ToStateChange, + did::{Did, DidSignature, UncheckedDidKey}, + util::BoundedBytes, +}; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +use sp_core::U256; +use sp_runtime::traits::TryCollect; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MIN_CREDENTIAL_SIZE: u32 = 100; +const MAX_CREDENTIAL_SIZE: u32 = 10_000; +const MAX_POLICY_CONTROLLERS: u32 = 15; + +crate::bench_with_all_pairs! { + with_pairs: + update_sr25519 for sr25519, update_ed25519 for ed25519, update_secp256k1 for secp256k1 { + { + let r in MIN_CREDENTIAL_SIZE .. MAX_CREDENTIAL_SIZE as u32; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([0; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let id = [1u8; 32].into(); + let credential = StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::::RevocationList2020Credential(BoundedBytes((0..r).map(|v| v as u8).try_collect().unwrap())), + policy: Policy::one_of((0..MAX_POLICY_CONTROLLERS).map(|i| U256::from(i).into()).map(Did)).unwrap() + }; + super::Pallet::::create_(id, credential).unwrap(); + + let credential = StatusListCredential::::StatusList2021Credential(BoundedBytes((0..r).map(|v| v as u8).try_collect().unwrap())); + let update_credential_raw = UpdateStatusListCredentialRaw { + /// Unique identifier of the underlying `StatusListCredential` + id, + /// The `StatusListCredential` itself + credential, + _marker: PhantomData + }; + let update = WithNonce::new_with_nonce(update_credential_raw, 1u32.into()); + + let sig = pair.sign(&update.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: update(RawOrigin::Signed(caller), update.into_data(), vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert_eq!(StatusListCredentials::get(id).unwrap(), StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::::StatusList2021Credential(BoundedBytes((0..r).map(|v| v as u8).try_collect().unwrap())), + policy: Policy::one_of((0..MAX_POLICY_CONTROLLERS).map(|i| U256::from(i).into()).map(Did)).unwrap() + }); + } + + remove_sr25519 for sr25519, remove_ed25519 for ed25519, remove_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([0; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let id = [1u8; 32].into(); + let credential = StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::::RevocationList2020Credential(BoundedBytes((0..MAX_CREDENTIAL_SIZE).map(|v| v as u8).try_collect().unwrap())), + policy: Policy::one_of((0..MAX_POLICY_CONTROLLERS).map(|i| U256::from(i).into()).map(Did)).unwrap() + }; + super::Pallet::::create_(id, credential).unwrap(); + + let remove_credential_raw = RemoveStatusListCredentialRaw { + /// Unique identifier of the underlying `StatusListCredential` + id, + _marker: PhantomData + }; + let remove = WithNonce::new_with_nonce(remove_credential_raw, 1u32.into()); + + let sig = pair.sign(&remove.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: remove(RawOrigin::Signed(caller), remove.into_data(), vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert_eq!(StatusListCredentials::::get(id), None); + }; + + standard: + create { + let r in MIN_CREDENTIAL_SIZE .. MAX_CREDENTIAL_SIZE as u32; + let c in 1 .. MAX_POLICY_CONTROLLERS as u32; + + let caller = whitelisted_caller(); + + let id = [1u8; 32].into(); + let credential = StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::::RevocationList2020Credential(BoundedBytes((0..r).map(|v| v as u8).try_collect().unwrap())), + policy: Policy::one_of((0..c).map(|i| U256::from(i).into()).map(Did)).unwrap() + }; + + }: create(RawOrigin::Signed(caller), id, credential) + verify { + assert_eq!(StatusListCredentials::::get(id).unwrap(), StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::::RevocationList2020Credential(BoundedBytes((0..r).map(|v| v as u8).try_collect().unwrap())), + policy: Policy::one_of((0..c).map(|i| U256::from(i).into()).map(Did)).unwrap() + }); + } +} diff --git a/pallets/did/src/modules/status_list_credential/impl.rs b/pallets/did/src/modules/status_list_credential/impl.rs new file mode 100644 index 0000000..04934e9 --- /dev/null +++ b/pallets/did/src/modules/status_list_credential/impl.rs @@ -0,0 +1,102 @@ +use super::*; + +impl Pallet { + pub(super) fn create_( + id: StatusListCredentialId, + credential: StatusListCredentialWithPolicy, + ) -> DispatchResult { + ensure!( + !StatusListCredentials::::contains_key(id), + Error::::StatusListCredentialAlreadyExists + ); + credential.ensure_valid()?; + + StatusListCredentials::insert(id, credential); + + deposit_indexed_event!(StatusListCredentialCreated(id)); + Ok(()) + } + + pub(super) fn update_( + UpdateStatusListCredentialRaw { id, credential, .. }: UpdateStatusListCredentialRaw, + status_list_credential: &mut StatusListCredentialWithPolicy, + ) -> DispatchResult { + credential.ensure_valid()?; + + status_list_credential.status_list_credential = credential; + + deposit_indexed_event!(StatusListCredentialUpdated(id)); + Ok(()) + } + + pub(super) fn remove_( + RemoveStatusListCredentialRaw { id, .. }: RemoveStatusListCredentialRaw, + status_list_credential: &mut Option>, + ) -> DispatchResult { + status_list_credential.take(); + + deposit_indexed_event!(StatusListCredentialRemoved(id)); + Ok(()) + } + + /// Executes action over target `StatusListCredential` providing a mutable reference if all + /// checks succeed. + /// + /// Checks: + /// 1. Ensure that the `StatusListCredential` exists. + /// 2. Verify that `proof` authorizes `action` according to `policy`. + /// 3. Verify that the action is not a replayed payload by ensuring each provided controller + /// nonce equals the last nonce plus 1. + /// + /// Returns a mutable reference to the underlying StatusListCredential if the command is + /// authorized, otherwise returns Err. + pub(crate) fn try_exec_action_over_status_list_credential( + f: F, + action: A, + proof: Vec>, + ) -> Result + where + F: FnOnce(A, &mut StatusListCredentialWithPolicy) -> Result, + A: Action, + WithNonce: ToStateChange, + E: From> + From + From> + From, + { + Self::try_exec_removable_action_over_status_list_credential( + |action, reg| f(action, reg.as_mut().unwrap()), + action, + proof, + ) + } + + /// Executes action over target `StatusListCredential` providing a mutable reference if all + /// checks succeed. + /// + /// Unlike `try_exec_action_over_status_list_credential`, this action may result in a removal of + /// a `StatusListCredential`, if the value under option will be taken. + /// + /// Checks: + /// 1. Ensure that the `StatusListCredential` exists. + /// 2. Verify that `proof` authorizes `action` according to `policy`. + /// 3. Verify that the action is not a replayed payload by ensuring each provided controller + /// nonce equals the last nonce plus 1. + /// + /// Returns a mutable reference to the underlying `StatusListCredential` wrapped into an option + /// if the command is authorized, otherwise returns Err. + pub(crate) fn try_exec_removable_action_over_status_list_credential( + f: F, + action: A, + proof: Vec>, + ) -> Result + where + F: FnOnce(A, &mut Option>) -> Result, + A: Action, + WithNonce: ToStateChange, + E: From> + From + From> + From, + { + ensure!(!action.is_empty(), Error::EmptyPayload); + + StatusListCredentials::try_mutate_exists(action.target(), |credential| { + Policy::try_exec_removable_action(credential, f, action, proof) + }) + } +} diff --git a/pallets/did/src/modules/status_list_credential/mod.rs b/pallets/did/src/modules/status_list_credential/mod.rs new file mode 100644 index 0000000..871266b --- /dev/null +++ b/pallets/did/src/modules/status_list_credential/mod.rs @@ -0,0 +1,155 @@ +//! Storage for status list-related verifiable credentials: +//! - [`RevocationList2020Credential`](https://w3c-ccg.github.io/vc-status-rl-2020/#revocationlist2020credential) +//! - [`StatusList2021Credential`](https://www.w3.org/TR/vc-status-list/#statuslist2021credential). +use crate::{ + common::{DidSignatureWithNonce, Policy, PolicyExecutionError, SigValue, ToStateChange}, + deposit_indexed_event, did, + util::{Action, NonceError, WithNonce}, +}; +use alloc::vec::*; +use frame_support::pallet_prelude::*; + +use frame_system::ensure_signed; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarks; +mod r#impl; +#[cfg(test)] +mod tests; +mod weights; + +pub mod actions; +pub mod types; + +pub use actions::*; +pub use pallet::*; +pub use types::*; +use weights::*; + +#[frame_support::pallet] + +pub mod pallet { + use super::*; + + use frame_system::pallet_prelude::*; + + /// Error for the StatusListCredential module. + #[pallet::error] + pub enum Error { + /// There is already a `StatusListCredential` with the same id + StatusListCredentialAlreadyExists, + /// The `StatusListCredential` byte length is less than `MinStatusListCredentialSize` + StatusListCredentialTooSmall, + /// Action can't have an empty payload. + EmptyPayload, + } + + #[pallet::event] + pub enum Event { + /// `StatusListCredential` with the given id was created. + StatusListCredentialCreated(StatusListCredentialId), + /// `StatusListCredential` with the given id was updated. + StatusListCredentialUpdated(StatusListCredentialId), + /// `StatusListCredential` with the given id was removed. + StatusListCredentialRemoved(StatusListCredentialId), + } + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config + did::Config { + type RuntimeEvent: From + + IsType<::RuntimeEvent> + + Into<::RuntimeEvent>; + } + + /// Stores `StatusListCredential`s along with their modification policies. + /// The credential itself is represented as a raw byte sequence and can be either + /// - [`RevocationList2020Credential`](https://w3c-ccg.github.io/vc-status-rl-2020/#revocationlist2020credential) + /// - [`StatusList2021Credential`](https://www.w3.org/TR/vc-status-list/#statuslist2021credential) + #[pallet::storage] + #[pallet::getter(fn status_list_credential)] + pub type StatusListCredentials = + StorageMap<_, Blake2_128Concat, StatusListCredentialId, StatusListCredentialWithPolicy>; + + #[pallet::call] + impl Pallet { + /// Associates a new `StatusListCredentialWithPolicy` with the supplied identifier. + /// This method doesn't ensure `StatusListCredential` is a valid `JSON-LD` object. + #[pallet::weight(SubstrateWeight::::create(credential))] + #[pallet::call_index(0)] + pub fn create( + origin: OriginFor, + id: StatusListCredentialId, + credential: StatusListCredentialWithPolicy, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::create_(id, credential) + } + + /// Updates `StatusListCredential` associated with the supplied identifier. + /// This method doesn't ensure `StatusListCredential` is a valid `JSON-LD` object. + #[pallet::weight(SubstrateWeight::::update(&proof[0], update_credential))] + #[pallet::call_index(1)] + pub fn update( + origin: OriginFor, + update_credential: UpdateStatusListCredentialRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_action_over_status_list_credential( + Self::update_, + update_credential, + proof, + ) + } + + /// Removes `StatusListCredential` associated with the supplied identifier. + #[pallet::weight(SubstrateWeight::::remove(&proof[0]))] + #[pallet::call_index(2)] + pub fn remove( + origin: OriginFor, + remove_credential: RemoveStatusListCredentialRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_removable_action_over_status_list_credential( + Self::remove_, + remove_credential, + proof, + ) + } + } +} + +impl SubstrateWeight { + fn create( + StatusListCredentialWithPolicy { + status_list_credential, + policy, + }: &StatusListCredentialWithPolicy, + ) -> Weight { + ::create(status_list_credential.len(), policy.len()) + } + + fn update( + DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce, + UpdateStatusListCredentialRaw { credential, .. }: &UpdateStatusListCredentialRaw, + ) -> Weight { + match sig.sig { + SigValue::Sr25519(_) => Self::update_sr25519(credential.len()), + SigValue::Ed25519(_) => Self::update_ed25519(credential.len()), + } + } + + fn remove(DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce) -> Weight { + match sig.sig { + SigValue::Sr25519(_) => Self::remove_sr25519(), + SigValue::Ed25519(_) => Self::remove_ed25519(), + } + } +} diff --git a/pallets/did/src/modules/status_list_credential/tests.rs b/pallets/did/src/modules/status_list_credential/tests.rs new file mode 100644 index 0000000..76e7a45 --- /dev/null +++ b/pallets/did/src/modules/status_list_credential/tests.rs @@ -0,0 +1,321 @@ +#![allow(clippy::type_complexity)] + +use super::*; +use crate::{ + common::{Policy, PolicyValidationError, ToStateChange}, + did::Did, + tests::common::*, + util::{Action, BoundedBytes, WithNonce}, +}; +use alloc::collections::BTreeMap; +use frame_support::{assert_noop, assert_ok}; +use frame_system::Origin; +use sp_core::sr25519; +use sp_runtime::{traits::TryCollect, DispatchError}; +use sp_std::{iter::empty, marker::PhantomData}; + +type Mod = super::Pallet; + +pub fn get_pauth( + action: &A, + signers: &[(Did, &sr25519::Pair)], +) -> Vec> +where + WithNonce: ToStateChange, +{ + signers + .iter() + .map(|(did, kp)| { + let did_detail = DIDModule::onchain_did_details(did).unwrap(); + let next_nonce = did_detail.next_nonce().unwrap(); + let action_with_nonce = + WithNonce::::new_with_nonce(action.clone(), next_nonce); + let state_change = action_with_nonce.to_state_change().encode(); + let sig = did_sig_on_bytes(&state_change, kp, *did, 1); + + DidSignatureWithNonce { sig, nonce: next_nonce } + }) + .collect() +} + +pub fn get_nonces(signers: &[(Did, &sr25519::Pair)]) -> BTreeMap { + let mut nonces = BTreeMap::new(); + for (d, _) in signers { + let did_detail = DIDModule::onchain_did_details(d).unwrap(); + nonces.insert(*d, did_detail.nonce); + } + nonces +} + +pub fn check_nonce_increase(old_nonces: BTreeMap, signers: &[(Did, &sr25519::Pair)]) { + let new_nonces = get_nonces(signers); + assert_eq!(new_nonces.len(), old_nonces.len()); + for (d, new_nonce) in new_nonces { + assert_eq!(old_nonces.get(&d).unwrap() + 1, new_nonce); + } +} + +/// Checks auth mechanics for the `StatusListCredential` module. +#[test] +fn ensure_auth() { + ext().execute_with(|| { + run_to_block(10); + + let (a, b, c): (Did, Did, Did) = (Did(random()), Did(random()), Did(random())); + let (kpa, kpb, kpc) = (create_did(a), create_did(b), create_did(c)); + + let cases: [(u32, Policy, &[(Did, &sr25519::Pair)], bool); 11] = [ + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpa)], true), + (line!(), Policy::one_of([a, b]).unwrap(), &[(a, &kpa)], true), + (line!(), Policy::one_of([a, b]).unwrap(), &[(b, &kpb)], true), + (line!(), Policy::one_of([a]).unwrap(), &[], false), // provide no signatures + (line!(), Policy::one_of([a]).unwrap(), &[(b, &kpb)], false), // wrong account; wrong key + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpb)], false), // correct account; wrong key + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpb)], false), // wrong account; correct key + (line!(), Policy::one_of([a, b]).unwrap(), &[(c, &kpc)], false), // account not a controller + (line!(), Policy::one_of([a, b]).unwrap(), &[(a, &kpa), (b, &kpb)], false), // two signers + (line!(), Policy::one_of([a]).unwrap(), &[], false), // one controller; no sigs + (line!(), Policy::one_of([a, b]).unwrap(), &[], false), // two controllers; no sigs + ]; + for (i, (line_no, policy, signers, expect_success)) in cases.into_iter().enumerate() { + eprintln!("running case from line {}", line_no); + let id = StatusListCredentialId(rand::random()); + + Mod::create_( + id, + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::RevocationList2020Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy: policy.clone(), + }, + ) + .unwrap(); + + let command = UpdateStatusListCredentialRaw { + /// Unique identifier of the StatusListCredential + id, + /// StatusListCredential itself + credential: StatusListCredential::StatusList2021Credential(BoundedBytes( + (0..10).map(|v| v as u8).try_collect().unwrap(), + )), + _marker: PhantomData, + }; + let old_nonces = get_nonces(signers); + let proof = get_pauth(&command, signers); + let res = Mod::try_exec_action_over_status_list_credential( + |_, _| Ok::<_, DispatchError>(()), + command.clone(), + proof, + ); + assert_eq!(res.is_ok(), expect_success); + if expect_success { + check_nonce_increase(old_nonces, signers); + } + + let command = RemoveStatusListCredentialRaw { id, _marker: PhantomData }; + + let old_nonces = get_nonces(signers); + let proof = get_pauth(&command, signers); + let res = Mod::try_exec_action_over_status_list_credential( + |_, _| Ok::<_, DispatchError>(()), + command.clone(), + proof, + ); + assert_eq!(res.is_ok(), expect_success); + + if expect_success { + check_nonce_increase(old_nonces, signers); + } + run_to_block(10 + 1 + i as u64); + } + }) +} + +/// Checks creation mechanism of the `StatusListCredential`. +#[test] +fn create_status_list_credential() { + ext().execute_with(|| { + let did = Did(random()); + let policy = Policy::one_of([did]).unwrap(); + let id = StatusListCredentialId(rand::random()); + + assert!((0..10_000) + .map(|v| v as u8) + .try_collect() + .map(BoundedBytes) + .map(StatusListCredential::::RevocationList2020Credential) + .is_err()); + + assert_noop!( + Mod::create( + RuntimeOrigin::signed(ABBA), + id, + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::RevocationList2020Credential( + BoundedBytes((0..5).map(|v| v as u8).try_collect().unwrap()), + ), + policy: policy.clone(), + } + ), + Error::::StatusListCredentialTooSmall + ); + assert_noop!( + Mod::create( + RuntimeOrigin::signed(ABBA), + id, + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy: Policy::one_of(empty::()).unwrap(), + } + ), + PolicyValidationError::Empty + ); + Policy::::one_of((0..16).map(|_| Did(random()))).unwrap_err(); + Mod::create_( + id, + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy: policy.clone(), + }, + ) + .unwrap(); + assert_eq!( + Mod::status_list_credential(id).unwrap(), + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy: policy.clone(), + } + ); + + Policy::::one_of(vec![Did(random()); 16]).unwrap_err(); + + assert_noop!( + Mod::create( + RuntimeOrigin::signed(ABBA), + id, + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy, + } + ), + Error::::StatusListCredentialAlreadyExists + ); + }); +} + +/// Checks update mechanism of the `StatusListCredential`. +#[test] +fn update_status_list_credential() { + ext().execute_with(|| { + let did = Did(random()); + let keypair = create_did(did); + let policy = Policy::one_of([did]).unwrap(); + let id = StatusListCredentialId(rand::random()); + + Mod::create_( + id, + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy: policy.clone(), + }, + ) + .unwrap(); + assert_eq!( + Mod::status_list_credential(id).unwrap(), + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy: policy.clone() + } + ); + + let update = UpdateStatusListCredentialRaw { + id, + credential: StatusListCredential::StatusList2021Credential(BoundedBytes( + (0..10).map(|v| v as u8).try_collect().unwrap(), + )), + _marker: PhantomData, + }; + let auth = get_pauth(&update, &[(did, &keypair)][..]); + + assert_ok!(Mod::update(RuntimeOrigin::signed(ABBA), update, auth)); + assert_eq!( + Mod::status_list_credential(id).unwrap(), + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy + } + ); + + let update = UpdateStatusListCredentialRaw { + id, + credential: StatusListCredential::StatusList2021Credential(BoundedBytes( + (0..5).map(|v| v as u8).try_collect().unwrap(), + )), + _marker: PhantomData, + }; + let auth = get_pauth(&update, &[(did, &keypair)][..]); + assert_noop!( + Mod::update(RuntimeOrigin::signed(ABBA), update, auth), + Error::::StatusListCredentialTooSmall + ); + }); +} + +/// Checks removal mechanism of the `StatusListCredential`. +#[test] +fn remove_status_list_credential() { + ext().execute_with(|| { + let did = Did(random()); + let keypair = create_did(did); + let policy = Policy::one_of([did]).unwrap(); + let id = StatusListCredentialId(rand::random()); + + Mod::create_( + id, + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy: policy.clone(), + }, + ) + .unwrap(); + assert_eq!( + Mod::status_list_credential(id).unwrap(), + StatusListCredentialWithPolicy { + status_list_credential: StatusListCredential::StatusList2021Credential( + BoundedBytes((0..10).map(|v| v as u8).try_collect().unwrap()), + ), + policy + } + ); + + let remove = RemoveStatusListCredentialRaw { id, _marker: PhantomData }; + let auth = get_pauth(&remove, &[(did, &keypair)][..]); + + assert_ok!(Mod::remove(RuntimeOrigin::signed(ABBA), remove, auth)); + assert_eq!(Mod::status_list_credential(id), None); + + let remove = RemoveStatusListCredentialRaw { id, _marker: PhantomData }; + let auth = get_pauth(&remove, &[(did, &keypair)][..]); + assert_noop!( + Mod::remove(RuntimeOrigin::signed(ABBA), remove, auth), + PolicyExecutionError::NoEntity + ); + }); +} diff --git a/pallets/did/src/modules/status_list_credential/types.rs b/pallets/did/src/modules/status_list_credential/types.rs new file mode 100644 index 0000000..802358e --- /dev/null +++ b/pallets/did/src/modules/status_list_credential/types.rs @@ -0,0 +1,128 @@ +#[cfg(feature = "serde")] +use crate::util::hex; +use crate::{ + common::{HasPolicy, Limits, Policy}, + util::BoundedBytes, +}; +use codec::{Decode, Encode, MaxEncodedLen}; +use core::fmt::Debug; +use frame_support::{traits::Get, DebugNoBound, *}; +use sp_runtime::DispatchResult; + +use super::{Config, Error}; + +/// Either [`RevocationList2020Credential`](https://w3c-ccg.github.io/vc-status-rl-2020/#revocationlist2020credential) +/// or [`StatusList2021Credential`](https://www.w3.org/TR/vc-status-list/#statuslist2021credential). +/// The underlying verifiable credential is represented as a raw byte sequence. +#[derive( + Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub enum StatusListCredential { + /// A verifiable credential that encapsulates a revocation list as per https://w3c-ccg.github.io/vc-status-rl-2020/#revocationlist2020credential. + RevocationList2020Credential(BoundedBytes), + /// A verifiable credential that contains a status list as per https://www.w3.org/TR/vc-status-list/#statuslist2021credential. + StatusList2021Credential(BoundedBytes), +} + +impl StatusListCredential { + /// Returns underlying raw bytes. + pub fn bytes(&self) -> &[u8] { + match self { + Self::RevocationList2020Credential(bytes) => bytes, + Self::StatusList2021Credential(bytes) => bytes, + } + } + + /// Returns underlying raw bytes length. + pub fn len(&self) -> u32 { + self.bytes().len() as u32 + } + + /// Returns `true` if underlying raw bytes length is equal to zero. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Ensures that byte length is valid. + pub fn ensure_valid(&self) -> Result<(), Error> + where + T: Config, + { + ensure!( + self.len() >= T::MinStatusListCredentialSize::get(), + Error::StatusListCredentialTooSmall + ); + + Ok(()) + } +} + +/// `StatusListCredential` combined with `Policy`. +#[derive( + scale_info_derive::TypeInfo, Encode, Decode, Clone, PartialEq, Eq, DebugNoBound, MaxEncodedLen, +)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct StatusListCredentialWithPolicy { + pub status_list_credential: StatusListCredential, + pub policy: Policy, +} + +impl HasPolicy for StatusListCredentialWithPolicy { + fn policy(&self) -> &Policy { + &self.policy + } +} + +impl StatusListCredentialWithPolicy { + /// Returns underlying raw bytes. + pub fn bytes(&self) -> &[u8] { + self.status_list_credential.bytes() + } + + /// Returns underlying raw bytes length. + pub fn len(&self) -> u32 { + self.status_list_credential.len() + } + + /// Returns `true` if underlying raw bytes length is equal to zero. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Ensures that underlying `Policy` and `StatusListCredential` are valid. + pub fn ensure_valid(&self) -> DispatchResult + where + T: Config, + { + self.policy.ensure_valid()?; + self.status_list_credential.ensure_valid()?; + + Ok(()) + } +} + +impl From> for StatusListCredential { + fn from( + StatusListCredentialWithPolicy { + status_list_credential, + .. + }: StatusListCredentialWithPolicy, + ) -> StatusListCredential { + status_list_credential + } +} + +/// Unique identifier for the `StatusListCredential`. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct StatusListCredentialId(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub [u8; 32]); + +crate::impl_wrapper!(StatusListCredentialId([u8; 32])); diff --git a/pallets/did/src/modules/status_list_credential/weights.rs b/pallets/did/src/modules/status_list_credential/weights.rs new file mode 100644 index 0000000..12e3651 --- /dev/null +++ b/pallets/did/src/modules/status_list_credential/weights.rs @@ -0,0 +1,125 @@ +//! Autogenerated weights for status_list_credential +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-08-03, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dock-node +// benchmark +// pallet +// --wasm-execution=compiled +// --pallet=status_list_credential +// --extra +// --repeat=20 +// --extrinsic=* +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/revoke/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for status_list_credential. +pub trait WeightInfo { + fn update_sr25519(r: u32) -> Weight; + fn update_ed25519(r: u32) -> Weight; + fn update_secp256k1(r: u32) -> Weight; + fn remove_sr25519() -> Weight; + fn remove_ed25519() -> Weight; + fn remove_secp256k1() -> Weight; + fn create(r: u32, c: u32) -> Weight; +} + +/// Weights for status_list_credential using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn update_sr25519(r: u32) -> Weight { + Weight::from_all(69_710_000) // Standard Error: 0 + .saturating_add(Weight::from_all(4_000).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + fn update_ed25519(r: u32) -> Weight { + Weight::from_all(68_958_000) // Standard Error: 0 + .saturating_add(Weight::from_all(2_000).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + fn update_secp256k1(r: u32) -> Weight { + Weight::from_all(164_889_000) // Standard Error: 0 + .saturating_add(Weight::from_all(4_000).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + fn remove_sr25519() -> Weight { + Weight::from_all(70_000_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + fn remove_ed25519() -> Weight { + Weight::from_all(72_000_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + fn remove_secp256k1() -> Weight { + Weight::from_all(159_000_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + fn create(_r: u32, c: u32) -> Weight { + Weight::from_all(15_669_000) // Standard Error: 4_000 + .saturating_add(Weight::from_all(74_000).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn update_sr25519(r: u32) -> Weight { + Weight::from_all(69_710_000) // Standard Error: 0 + .saturating_add(Weight::from_all(4_000).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + fn update_ed25519(r: u32) -> Weight { + Weight::from_all(68_958_000) // Standard Error: 0 + .saturating_add(Weight::from_all(2_000).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + fn update_secp256k1(r: u32) -> Weight { + Weight::from_all(164_889_000) // Standard Error: 0 + .saturating_add(Weight::from_all(4_000).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + fn remove_sr25519() -> Weight { + Weight::from_all(70_000_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + fn remove_ed25519() -> Weight { + Weight::from_all(72_000_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + fn remove_secp256k1() -> Weight { + Weight::from_all(159_000_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + fn create(_r: u32, c: u32) -> Weight { + Weight::from_all(15_669_000) // Standard Error: 4_000 + .saturating_add(Weight::from_all(74_000).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) + } +} diff --git a/pallets/did/src/modules/trusted_entity/actions.rs b/pallets/did/src/modules/trusted_entity/actions.rs new file mode 100644 index 0000000..5d1120d --- /dev/null +++ b/pallets/did/src/modules/trusted_entity/actions.rs @@ -0,0 +1,143 @@ +use super::*; +use frame_support::DebugNoBound; + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddAuthorizer { + pub id: AuthorizerId, + pub new_authorizer: Authorizer, +} + +/// Command to create a set of issuers withing a authorizer. +/// Creation of issuers is idempotent; creating a issuers that already exists is allowed, +/// but has no effect. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddIssuerRaw { + /// The authorizer on which to operate + pub authorizer_id: AuthorizerId, + /// entity ids which will be registered as trusted entities + pub entity_ids: BTreeSet, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +/// Command to remove a set of issuers within a authorizer. +/// Removal of issuers is idempotent; removing a issuers that doesn't exists is allowed, +/// but has no effect. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveIssuerRaw { + /// The authorizer on which to operate + pub authorizer_id: AuthorizerId, + /// entity ids which will be removed as trusted entities + pub entity_ids: BTreeSet, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +/// Command to create a set of verifiers withing a authorizer. +/// Creation of verifiers is idempotent; creating a verifiers that already exists is allowed, +/// but has no effect. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct AddVerifierRaw { + /// The authorizer on which to operate + pub authorizer_id: AuthorizerId, + /// entity ids which will be registered as trusted entities + pub entity_ids: BTreeSet, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +/// Command to remove a set of verifiers within a authorizer. +/// Removal of verifiers is idempotent; removing a verifiers that doesn't exists is allowed, +/// but has no effect. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveVerifierRaw { + /// The authorizer on which to operate + pub authorizer_id: AuthorizerId, + /// entity ids which will be removed as trusted entities + pub entity_ids: BTreeSet, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +/// Command to remove an entire authorizer storage. Removes all issuers and verifiers in the +/// authorizer storage as well as authorizer metadata. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, DebugNoBound, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct RemoveAuthorizerRaw { + /// The authorizer on which to operate + pub authorizer_id: AuthorizerId, + #[codec(skip)] + #[cfg_attr(feature = "serde", serde(skip))] + pub _marker: PhantomData, +} + +crate::impl_action! { + for AuthorizerId: + AddIssuerRaw with entity_ids.len() as len, authorizer_id as target no_state_change, + RemoveIssuerRaw with entity_ids.len() as len, authorizer_id as target no_state_change, + AddVerifierRaw with entity_ids.len() as len, authorizer_id as target no_state_change, + RemoveVerifierRaw with entity_ids.len() as len, authorizer_id as target no_state_change, + RemoveAuthorizerRaw with 1 as len, authorizer_id as target no_state_change +} + +/// Command to create a set of issuers withing a authorizer. +/// Creation of issuers is idempotent; creating a issuers that already exists is allowed, +/// but has no effect. +pub type AddIssuer = WithNonce>; +/// Command to remove a set of issuers within a authorizer. +/// Removal of issuers is idempotent; removing a issuers that doesn't exists is allowed, +/// but has no effect. +pub type RemoveIssuer = WithNonce>; +/// Command to create a set of verifiers withing a authorizer. +/// Creation of verifiers is idempotent; creating a verifiers that already exists is allowed, +/// but has no effect. +pub type AddVerifier = WithNonce>; +/// Command to remove a set of verifiers within a authorizer. +/// Removal of verifiers is idempotent; removing a verifiers that doesn't exists is allowed, +/// but has no effect. +pub type RemoveVerifier = WithNonce>; +/// Command to remove an entire authorizer storage. Removes all issuers and verifiers in the +/// authorizer storage as well as authorizer metadata. +pub type RemoveAuthorizer = WithNonce>; + +crate::impl_action_with_nonce! { + for AuthorizerId: + AddIssuer with data().len() as len, data().authorizer_id as target, + RemoveIssuer with data().len() as len, data().authorizer_id as target, + AddVerifier with data().len() as len, data().authorizer_id as target, + RemoveVerifier with data().len() as len, data().authorizer_id as target, + RemoveAuthorizer with data().len() as len, data().authorizer_id as target +} diff --git a/pallets/did/src/modules/trusted_entity/benchmarks.rs b/pallets/did/src/modules/trusted_entity/benchmarks.rs new file mode 100644 index 0000000..49fed0a --- /dev/null +++ b/pallets/did/src/modules/trusted_entity/benchmarks.rs @@ -0,0 +1,262 @@ +use super::*; +use crate::{ + common::state_change::ToStateChange, + did::{Did, DidSignature, UncheckedDidKey}, +}; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +use sp_core::U256; +use sp_std::iter::once; +#[cfg(not(feature = "std"))] +use sp_std::prelude::*; + +const MAX_TRUSTED_ENTITY: u32 = 1000; +const MAX_CONTROLLERS: u32 = 15; + +fn dummy_authorizer() -> Authorizer { + Authorizer { policy: Policy::one_of(once(Did([3; 32]))).unwrap(), add_only: false } +} + +crate::bench_with_all_pairs! { + with_pairs: + add_issuer_sr25519 for sr25519, add_issuer_ed25519 for ed25519, add_issuer_secp256k1 for secp256k1 { + { + let r in 1 .. MAX_TRUSTED_ENTITY as u32; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let authorizer_id = AuthorizerId([1u8; 32]); + let entity_ids: BTreeSet<_> = (0..r).map(|i| U256::from(i).into()).map(AuthorizerId).collect(); + let add_issuer_raw = AddIssuerRaw { + /// The authorizer on which to operate + authorizer_id: authorizer_id, + /// entity ids which will be added + entity_ids: entity_ids.clone(), + _marker: PhantomData + }; + + let add_issuer = AddIssuer::new_with_nonce(add_issuer_raw.clone(), 1u32.into()); + let sig = pair.sign(&add_issuer.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + super::Pallet::::new_authorizer_(AddAuthorizer { id: authorizer_id, new_authorizer: Authorizer { policy: Policy::one_of(&[did]).unwrap(), add_only: false } }).unwrap(); + }: add_issuer(RawOrigin::Signed(caller), add_issuer_raw, vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert!(entity_ids + .iter() + .all(|id| Issuers::::contains_key(authorizer_id, id))); + } + + remove_issuer_sr25519 for sr25519, remove_issuer_ed25519 for ed25519, remove_issuer_secp256k1 for secp256k1 { + { + let r in 1 .. MAX_TRUSTED_ENTITY as u32; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let authorizer_id = AuthorizerId([1u8; 32]); + let entity_ids: BTreeSet<_> = (0..r).map(|i| U256::from(i).into()).map(AuthorizerId).collect(); + + super::Pallet::::new_authorizer_(AddAuthorizer { id: authorizer_id, new_authorizer: Authorizer { policy: Policy::one_of(&[did]).unwrap(), add_only: false } }).unwrap(); + + crate::trusted_entity::Pallet::::add_issuer_( + AddIssuerRaw { + /// The authorizer on which to operate + authorizer_id: authorizer_id, + /// entity ids which will be added + entity_ids: entity_ids.clone(), + _marker: PhantomData + }, + &mut dummy_authorizer() + ).unwrap(); + + let remove_issuer_raw = RemoveIssuerRaw { + /// The authorizer on which to operate + authorizer_id: authorizer_id, + /// entity ids which will be added + entity_ids: entity_ids.clone(), + _marker: PhantomData + }; + + let remove_issuer = RemoveIssuer::new_with_nonce(remove_issuer_raw.clone(), 1u32.into()); + let sig = pair.sign(&remove_issuer.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: remove_issuer(RawOrigin::Signed(caller), remove_issuer_raw, vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert!(entity_ids + .iter() + .all(|id| !Issuers::::contains_key(authorizer_id, id))); + } + + add_verifier_sr25519 for sr25519, add_verifier_ed25519 for ed25519, add_verifier_secp256k1 for secp256k1 { + { + let r in 1 .. MAX_TRUSTED_ENTITY as u32; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let authorizer_id = AuthorizerId([1u8; 32]); + let entity_ids: BTreeSet<_> = (0..r).map(|i| U256::from(i).into()).map(AuthorizerId).collect(); + let add_verifier_raw = AddVerifierRaw { + /// The authorizer on which to operate + authorizer_id: authorizer_id, + /// entity ids which will be added + entity_ids: entity_ids.clone(), + _marker: PhantomData + }; + + let add_verifier = AddVerifier::new_with_nonce(add_verifier_raw.clone(), 1u32.into()); + let sig = pair.sign(&add_verifier.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + super::Pallet::::new_authorizer_(AddAuthorizer { id: authorizer_id, new_authorizer: Authorizer { policy: Policy::one_of(&[did]).unwrap(), add_only: false } }).unwrap(); + }: add_verifier(RawOrigin::Signed(caller), add_verifier_raw, vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert!(entity_ids + .iter() + .all(|id| Verifiers::::contains_key(authorizer_id, id))); + } + + remove_verifier_sr25519 for sr25519, remove_verifier_ed25519 for ed25519, remove_verifier_secp256k1 for secp256k1 { + { + let r in 1 .. MAX_TRUSTED_ENTITY as u32; + } + let pair as Pair; + let caller = whitelisted_caller(); + let did = Did([1; Did::BYTE_SIZE]); + let public = pair.public(); + + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + let authorizer_id = AuthorizerId([1u8; 32]); + let entity_ids: BTreeSet<_> = (0..r).map(|i| U256::from(i).into()).map(AuthorizerId).collect(); + + super::Pallet::::new_authorizer_(AddAuthorizer { id: authorizer_id, new_authorizer: Authorizer { policy: Policy::one_of(&[did]).unwrap(), add_only: false } }).unwrap(); + + crate::trusted_entity::Pallet::::add_verifier_( + AddVerifierRaw { + /// The authorizer on which to operate + authorizer_id: authorizer_id, + /// entity ids which will be added + entity_ids: entity_ids.clone(), + _marker: PhantomData + }, + &mut dummy_authorizer() + ).unwrap(); + + let remove_verifier_raw = RemoveVerifierRaw { + /// The authorizer on which to operate + authorizer_id: authorizer_id, + /// entity ids which will be added + entity_ids: entity_ids.clone(), + _marker: PhantomData + }; + + let remove_verifier = RemoveVerifier::new_with_nonce(remove_verifier_raw.clone(), 1u32.into()); + let sig = pair.sign(&remove_verifier.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + + }: remove_verifier(RawOrigin::Signed(caller), remove_verifier_raw, vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert!(entity_ids + .iter() + .all(|id| !Verifiers::::contains_key(authorizer_id, id))); + } + + remove_authorizer_sr25519 for sr25519, remove_authorizer_ed25519 for ed25519, remove_authorizer_secp256k1 for secp256k1 { + let pair as Pair; + let caller = whitelisted_caller(); + let public = pair.public(); + let did = Did([3 as u8; Did::BYTE_SIZE]); + let authorizer_id = AuthorizerId([4 as u8; 32]); + let authorizer = Authorizer { + policy: Policy::one_of(once(did).chain((1..MAX_CONTROLLERS).map(U256::from).map(Into::into).map(Did)).collect::>()).unwrap(), + add_only: false, + }; + let add_authorizer = AddAuthorizer { + id: authorizer_id + new_authorizer: authorizer.clone(), + }; + let entity_ids: BTreeSet<_> = (0..100).map(|i| U256::from(i).into()).map(TrustedEntityId).collect(); + crate::did::Pallet::::new_onchain_( + did, + vec![UncheckedDidKey::new_with_all_relationships(public)], + Default::default(), + ).unwrap(); + + super::Pallet::::new_authorizer_(add_authorizer).unwrap(); + + crate::trusted_entity::Pallet::::add_issuer_( + AddIssuerRaw { + /// The authorizer on which to operate + authorizer_id: authorizer_id, + /// entity ids which will be added + entity_ids: entity_ids.clone(), + _marker: PhantomData + }, + &mut dummy_authorizer() + ).unwrap(); + + let rem_authorizer_raw = RemoveAuthorizerRaw { + authorizer_id: authorizer_id, + _marker: PhantomData + }; + let remove_authorizer = RemoveAuthorizer::new_with_nonce(rem_authorizer_raw.clone(), 1u32.into()); + let sig = pair.sign(&remove_authorizer.to_state_change().encode()); + let signature = DidSignature::new(did, 1u32, sig); + }: remove_authorizer(RawOrigin::Signed(caller), remove_authorizer_raw, vec![DidSignatureWithNonce { sig: signature, nonce: 1u32.into() }]) + verify { + assert!(Authorizers::::get(authorizer_id).is_none()); + }; + + standard: + new_authorizer { + let c in 1 .. MAX_CONTROLLERS; + + let caller = whitelisted_caller(); + let did = Did([3 as u8; Did::BYTE_SIZE]); + let authorizer_id = AuthorizerId([4 as u8; 32]); + let authorizer = Authorizer { + policy: Policy::one_of(once(did).chain((1..c).map(U256::from).map(Into::into).map(Did)).collect::>()).unwrap(), + add_only: false, + }; + let add_authorizer = AddAuthorizer { + id: authorizer_id + new_authorizer: authorizer.clone(), + }; + + }: new_authorizer(RawOrigin::Signed(caller), add_authorizer) + verify { + assert_eq!(Authorizers::::get(authorizer_id).unwrap(), authorizer); + } +} diff --git a/pallets/did/src/modules/trusted_entity/impl.rs b/pallets/did/src/modules/trusted_entity/impl.rs new file mode 100644 index 0000000..7fd0d69 --- /dev/null +++ b/pallets/did/src/modules/trusted_entity/impl.rs @@ -0,0 +1,153 @@ +use super::*; +use crate::{ + common::{DidSignatureWithNonce, PolicyExecutionError}, + deposit_indexed_event, +}; + +impl Pallet { + pub(super) fn new_authorizer_( + AddAuthorizer { new_authorizer, id }: AddAuthorizer, + ) -> DispatchResult { + // check + new_authorizer.policy.ensure_valid()?; + ensure!(!Authorizers::::contains_key(id), Error::::AuthzExists); + + // execute + Authorizers::::insert(id, new_authorizer); + + deposit_indexed_event!(AuthorizerAdded(id)); + Ok(()) + } + + pub(super) fn add_issuer_( + AddIssuerRaw { authorizer_id, entity_ids, .. }: AddIssuerRaw, + _: &mut Authorizer, + ) -> DispatchResult { + // execute + for cred_id in &entity_ids { + Issuers::::insert(authorizer_id, cred_id, ()); + } + + deposit_indexed_event!(IssuerAdded(authorizer_id)); + Ok(()) + } + + pub(super) fn remove_issuer_( + RemoveIssuerRaw { entity_ids, authorizer_id, .. }: RemoveIssuerRaw, + authorizer: &mut Authorizer, + ) -> DispatchResult { + ensure!(!authorizer.add_only, Error::::AddOnly); + + // execute + for cred_id in &entity_ids { + Issuers::::remove(authorizer_id, cred_id); + } + + deposit_indexed_event!(IssuerRemoved(authorizer_id)); + Ok(()) + } + + pub(super) fn add_verifier_( + AddVerifierRaw { authorizer_id, entity_ids, .. }: AddVerifierRaw, + _: &mut Authorizer, + ) -> DispatchResult { + // execute + for cred_id in &entity_ids { + Verifiers::::insert(authorizer_id, cred_id, ()); + } + + deposit_indexed_event!(VerifierAdded(authorizer_id)); + Ok(()) + } + + pub(super) fn remove_verifier_( + RemoveVerifierRaw { entity_ids, authorizer_id, .. }: RemoveVerifierRaw, + authorizer: &mut Authorizer, + ) -> DispatchResult { + ensure!(!authorizer.add_only, Error::::AddOnly); + + // execute + for cred_id in &entity_ids { + Verifiers::::remove(authorizer_id, cred_id); + } + + deposit_indexed_event!(VerifierRemoved(authorizer_id)); + Ok(()) + } + + pub(super) fn remove_authorizer_( + RemoveAuthorizerRaw { authorizer_id, .. }: RemoveAuthorizerRaw, + authorizer: &mut Option>, + ) -> DispatchResult { + let authorizer = authorizer.take().unwrap(); + ensure!(!authorizer.add_only, Error::::AddOnly); + + // execute + // TODO: limit and cursor + let _ = Issuers::::clear_prefix(authorizer_id, u32::MAX, None); + let _ = Verifiers::::clear_prefix(authorizer_id, u32::MAX, None); + Authorizers::::remove(authorizer_id); + + deposit_indexed_event!(AuthorizerRemoved(authorizer_id)); + Ok(()) + } + + /// Executes action over target authorizer providing a mutable reference if all checks succeed. + /// + /// Checks: + /// 1. Ensure that the `Authorizer` exists. + /// 2. Verify that `proof` authorizes `action` according to `policy`. + /// 3. Verify that the action is not a replayed payload by ensuring each provided controller + /// nonce equals the last nonce plus 1. + /// + /// Returns a mutable reference to the underlying authorizer if the command is authorized, + /// otherwise returns Err. + pub(crate) fn try_exec_action_over_authorizer( + f: F, + action: A, + proof: Vec>, + ) -> Result + where + F: FnOnce(A, &mut Authorizer) -> Result, + A: Action, + WithNonce: ToStateChange, + E: From> + From + From> + From, + { + Self::try_exec_removable_action_over_authorizer( + |action, reg| f(action, reg.as_mut().unwrap()), + action, + proof, + ) + } + + /// Executes action over target authorizer providing a mutable reference if all checks succeed. + /// + /// Unlike `try_exec_action_over_authorizer`, this action may result in a removal of a + /// Authorizer, if the value under option will be taken. + /// + /// Checks: + /// 1. Ensure that the `Authorizer` exists. + /// 2. Verify that `proof` authorizes `action` according to `policy`. + /// 3. Verify that the action is not a replayed payload by ensuring each provided controller + /// nonce equals the last nonce plus 1. + /// + /// Returns a mutable reference to the underlying authorizer wrapped into an option if the + /// command is authorized, otherwise returns Err. + pub(crate) fn try_exec_removable_action_over_authorizer( + f: F, + action: A, + proof: Vec>, + ) -> Result + where + F: FnOnce(A, &mut Option>) -> Result, + A: Action, + WithNonce: ToStateChange, + E: From> + From + From> + From, + { + ensure!(!action.is_empty(), Error::EmptyPayload); + + Authorizers::try_mutate_exists(action.target(), |authorizer| { + Policy::try_exec_removable_action(authorizer, f, action, proof) + }) + } +} diff --git a/pallets/did/src/modules/trusted_entity/mod.rs b/pallets/did/src/modules/trusted_entity/mod.rs new file mode 100644 index 0000000..ac7e416 --- /dev/null +++ b/pallets/did/src/modules/trusted_entity/mod.rs @@ -0,0 +1,376 @@ +#[cfg(feature = "serde")] +use crate::util::hex; +use crate::{ + common::{self, DidSignatureWithNonce, HasPolicy, Limits, Policy, SigValue, ToStateChange}, + did::{self}, + util::{Action, NonceError, WithNonce}, +}; +use alloc::collections::BTreeSet; +use codec::{Decode, Encode, MaxEncodedLen}; +use core::ops::{Index, RangeFull}; +use sp_std::{fmt::Debug, marker::PhantomData, vec::Vec}; + +use frame_support::{dispatch::DispatchResult, ensure, weights::Weight, DebugNoBound}; +use frame_system::ensure_signed; +use sp_std::prelude::*; +use weights::*; + +pub use actions::*; +pub use pallet::*; + +mod actions; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +mod r#impl; +#[cfg(test)] +pub mod tests; +mod weights; + +/// Points to an on-chain authorizer. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct AuthorizerId(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub [u8; 32]); + +impl Index for AuthorizerId { + type Output = [u8; 32]; + + fn index(&self, _: RangeFull) -> &Self::Output { + &self.0 + } +} + +crate::impl_wrapper!(AuthorizerId([u8; 32])); + +/// Points to a issuer or verifier which may or may not exist in a authorizer. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct TrustedEntityId(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub [u8; 32]); + +impl Index for TrustedEntityId { + type Output = [u8; 32]; + + fn index(&self, _: RangeFull) -> &Self::Output { + &self.0 + } +} + +crate::impl_wrapper!(TrustedEntityId([u8; 32])); + +/// Metadata about a authorizer scope. +#[derive( + PartialEq, Eq, Encode, Decode, Clone, DebugNoBound, MaxEncodedLen, scale_info_derive::TypeInfo, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(serialize = "T: Sized", deserialize = "T: Sized")))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +pub struct Authorizer { + /// Who is allowed to update this authorizer. + pub policy: Policy, + /// true: credentials can be add entities, but not remove entities and the authorizer can't be + /// removed either false: credentials can be add entities and remove entities + pub add_only: bool, +} + +impl HasPolicy for Authorizer { + fn policy(&self) -> &Policy { + &self.policy + } +} + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config + did::Config { + /// The overarching event type. + type RuntimeEvent: From + + IsType<::RuntimeEvent> + + Into<::RuntimeEvent>; + } + + #[pallet::event] + pub enum Event { + /// Authorizer with given id created + AuthorizerAdded(AuthorizerId), + /// Issuer were added from given authorizer id + IssuerAdded(AuthorizerId), + /// Issuer were removed from given authorizer id + IssuerRemoved(AuthorizerId), + /// Verifier were added from given authorizer id + VerifierAdded(AuthorizerId), + /// Verifier were removed from given authorizer id + VerifierRemoved(AuthorizerId), + /// Authorizer with given id removed + AuthorizerRemoved(AuthorizerId), + } + + /// Revocation Error + #[pallet::error] + pub enum Error { + /// A authorizer with that name already exists. + AuthzExists, + /// nonce is incorrect. This is related to replay protection. + IncorrectNonce, + /// Too many controllers specified. + TooManyControllers, + /// This authorizer is marked as add_only. Deletion of revocations is not allowed. Deletion + /// of the authorizer is not allowed. + AddOnly, + /// Action is empty. + EmptyPayload, + } + + impl From for Error { + fn from(NonceError::IncorrectNonce: NonceError) -> Self { + Self::IncorrectNonce + } + } + + /// Authorizer metadata + #[pallet::storage] + #[pallet::getter(fn get_authorizer)] + pub type Authorizers = StorageMap<_, Blake2_128Concat, AuthorizerId, Authorizer>; + + /// The single global issuer set + // double_map requires and explicit hasher specification for the second key. blake2_256 is + // the default. + #[pallet::storage] + #[pallet::getter(fn get_issuer)] + pub type Issuers = + StorageDoubleMap<_, Blake2_128Concat, AuthorizerId, Blake2_256, TrustedEntityId, ()>; + + /// The single global verifier set + // double_map requires and explicit hasher specification for the second key. blake2_256 is + // the default. + #[pallet::storage] + #[pallet::getter(fn get_verifier)] + pub type Verifiers = + StorageDoubleMap<_, Blake2_128Concat, AuthorizerId, Blake2_256, TrustedEntityId, ()>; + + #[pallet::storage] + #[pallet::getter(fn version)] + pub type Version = StorageValue<_, common::StorageVersion, ValueQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub _marker: PhantomData, + } + + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + GenesisConfig { _marker: PhantomData } + } + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) { + Version::::put(common::StorageVersion::MultiKey); + } + } + + #[pallet::call] + impl Pallet { + /// Create a new authorizer named `id` with `authorizer` metadata. + /// + /// # Errors + /// + /// Returns an error if `id` is already in use as a authorizer id. + /// + /// Returns an error if `authorizer.policy` is invalid. + #[pallet::weight(SubstrateWeight::::new_authorizer(add_authorizer.new_authorizer.policy.len()))] + #[pallet::call_index(0)] + pub fn new_authorizer( + origin: OriginFor, + add_authorizer: AddAuthorizer, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::new_authorizer_(add_authorizer)?; + Ok(()) + } + + /// Create some issuer according to the `add_issuer` command. + /// + /// # Errors + /// + /// Returns an error if `add_issuer.last_modified` does not match the block number when the + /// authorizer referenced by `add_issuer.authorizer_id` was last modified. + /// + /// Returns an error if `proof` does not satisfy the policy requirements of the authorizer + /// referenced by `add_issuer.authorizer_id`. + #[pallet::weight(SubstrateWeight::::add_issuer(&proof[0])(add_issuer.len()))] + #[pallet::call_index(1)] + pub fn add_issuer( + origin: OriginFor, + add_issuer: AddIssuerRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_action_over_authorizer(Self::add_issuer_, add_issuer, proof)?; + Ok(()) + } + + /// Delete some issuer according to the `remove_issuer` command. + /// + /// # Errors + /// + /// Returns an error if the authorizer referenced by `add_issuer.authorizer_id` is + /// `add_only`. + /// + /// Returns an error if `remove_issuer.last_modified` does not match the block number when + /// the authorizer referenced by `add_issuer.authorizer_id` was last modified. + /// + /// Returns an error if `proof` does not satisfy the policy requirements of the authorizer + /// referenced by `remove_issuer.authorizer_id`. + #[pallet::weight(SubstrateWeight::::remove_issuer(&proof[0])(remove_issuer.len()))] + #[pallet::call_index(2)] + pub fn remove_issuer( + origin: OriginFor, + remove_issuer: RemoveIssuerRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_action_over_authorizer(Self::remove_issuer_, remove_issuer, proof)?; + Ok(()) + } + + /// Create some verifier according to the `add_verifier` command. + /// + /// # Errors + /// + /// Returns an error if `add_verifier.last_modified` does not match the block number when + /// the authorizer referenced by `add_verifier.authorizer_id` was last modified. + /// + /// Returns an error if `proof` does not satisfy the policy requirements of the authorizer + /// referenced by `add_verifier.authorizer_id`. + #[pallet::weight(SubstrateWeight::::add_verifier(&proof[0])(add_verifier.len()))] + #[pallet::call_index(3)] + pub fn add_verifier( + origin: OriginFor, + add_verifier: AddVerifierRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_action_over_authorizer(Self::add_verifier_, add_verifier, proof)?; + Ok(()) + } + + /// Delete some verifier according to the `remove_verifier` command. + /// + /// # Errors + /// + /// Returns an error if the authorizer referenced by `add_issuer.authorizer_id` is + /// `add_only`. + /// + /// Returns an error if `remove_verifier.last_modified` does not match the block number when + /// the authorizer referenced by `add_verifier.authorizer_id` was last modified. + /// + /// Returns an error if `proof` does not satisfy the policy requirements of the authorizer + /// referenced by `remove_verifier.authorizer_id`. + #[pallet::weight(SubstrateWeight::::remove_verifier(&proof[0])(remove_verifier.len()))] + #[pallet::call_index(4)] + pub fn remove_verifier( + origin: OriginFor, + remove_verifier: RemoveVerifierRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_action_over_authorizer(Self::remove_verifier_, remove_verifier, proof)?; + Ok(()) + } + + /// Delete an entire authorizer. Deletes all issuer, verifier within the authorizer, as well + /// as authorizer metadata. Once the authorizer is deleted, it can be reclaimed by any party + /// using a call to `new_authorizer`. + /// + /// # Errors + /// + /// Returns an error if the authorizer referenced by `add_issuer.authorizer_id` is + /// `add_only`. + /// + /// Returns an error if `removal.last_modified` does not match the block number when the + /// authorizer referenced by `removal.authorizer_id` was last modified. + /// + /// Returns an error if `proof` does not satisfy the policy requirements of the authorizer + /// referenced by `removal.authorizer_id`. + #[pallet::weight(SubstrateWeight::::remove_authorizer(&proof[0]))] + #[pallet::call_index(5)] + pub fn remove_authorizer( + origin: OriginFor, + removal: RemoveAuthorizerRaw, + proof: Vec>, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::try_exec_removable_action_over_authorizer( + Self::remove_authorizer_, + removal, + proof, + )?; + Ok(()) + } + } +} + +impl SubstrateWeight { + fn add_issuer( + DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce, + ) -> fn(u32) -> Weight { + match sig.sig { + SigValue::Sr25519(_) => Self::add_issuer_sr25519, + SigValue::Ed25519(_) => Self::add_issuer_ed25519, + } + } + + fn remove_issuer( + DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce, + ) -> fn(u32) -> Weight { + match sig.sig { + SigValue::Sr25519(_) => Self::remove_issuer_sr25519, + SigValue::Ed25519(_) => Self::remove_issuer_ed25519, + } + } + + fn add_verifier( + DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce, + ) -> fn(u32) -> Weight { + match sig.sig { + SigValue::Sr25519(_) => Self::add_verifier_sr25519, + SigValue::Ed25519(_) => Self::add_verifier_ed25519, + } + } + + fn remove_verifier( + DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce, + ) -> fn(u32) -> Weight { + match sig.sig { + SigValue::Sr25519(_) => Self::remove_verifier_sr25519, + SigValue::Ed25519(_) => Self::remove_verifier_ed25519, + } + } + + fn remove_authorizer(DidSignatureWithNonce { sig, .. }: &DidSignatureWithNonce) -> Weight { + (match sig.sig { + SigValue::Sr25519(_) => Self::remove_authorizer_sr25519, + SigValue::Ed25519(_) => Self::remove_authorizer_ed25519, + }()) + } +} diff --git a/pallets/did/src/modules/trusted_entity/tests.rs b/pallets/did/src/modules/trusted_entity/tests.rs new file mode 100644 index 0000000..f969b77 --- /dev/null +++ b/pallets/did/src/modules/trusted_entity/tests.rs @@ -0,0 +1,898 @@ +#![allow(clippy::type_complexity)] + +use super::*; +use crate::{ + common::{Policy, ToStateChange}, + did::Did, + tests::common::*, + util::{Action, WithNonce}, +}; +use alloc::collections::BTreeMap; +use frame_support::assert_noop; +use frame_system::Origin; +use sp_core::{sr25519, U256}; +use sp_runtime::DispatchError; +use sp_std::{iter::once, marker::PhantomData}; + +pub fn get_pauth( + action: &A, + signers: &[(Did, &sr25519::Pair)], +) -> Vec> +where + WithNonce: ToStateChange, +{ + signers + .iter() + .map(|(did, kp)| { + let did_detail = DIDModule::onchain_did_details(did).unwrap(); + let next_nonce = did_detail.next_nonce().unwrap(); + let sp = WithNonce::::new_with_nonce(action.clone(), next_nonce); + let sig = did_sig_on_bytes(&sp.to_state_change().encode(), kp, *did, 1); + DidSignatureWithNonce { sig, nonce: next_nonce } + }) + .collect() +} + +pub fn get_nonces(signers: &[(Did, &sr25519::Pair)]) -> BTreeMap { + let mut nonces = BTreeMap::new(); + for (d, _) in signers { + let did_detail = DIDModule::onchain_did_details(d).unwrap(); + nonces.insert(*d, did_detail.nonce); + } + nonces +} + +pub fn check_nonce_increase(old_nonces: BTreeMap, signers: &[(Did, &sr25519::Pair)]) { + let new_nonces = get_nonces(signers); + assert_eq!(new_nonces.len(), old_nonces.len()); + for (d, new_nonce) in new_nonces { + assert_eq!(old_nonces.get(&d).unwrap() + 1, new_nonce); + } +} + +/// Tests every failure case in the module. +/// If a failure case is not covered, thats a bug. +/// If an error variant from Error is not covered, thats a bug. +/// +/// Tests in this module are named after the errors they check. +/// For example, `#[test] fn invalidpolicy` exercises the Error::InvalidPolicy. +mod errors { + use crate::common::{PolicyExecutionError, PolicyValidationError}; + + // Cannot do `use super::*` as that would import `Call` as `Call` which conflicts with `Call` in + // `tests::common` + use super::*; + use alloc::collections::BTreeSet; + + #[test] + fn invalidpolicy() { + if !in_ext() { + return ext().execute_with(invalidpolicy) + } + + let ar = AddAuthorizer { + id: AUA, + new_authorizer: Authorizer { + policy: Policy::one_of(None::).unwrap(), + add_only: false, + }, + }; + + let err = TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap_err(); + assert_eq!(err, PolicyValidationError::Empty.into()); + } + + // this test has caught at least one bug + #[test] + fn notauthorized() { + if !in_ext() { + return ext().execute_with(notauthorized) + } + + fn assert_add_issuer_err( + policy: Policy, + signers: &[(Did, &sr25519::Pair)], + ) -> DispatchError { + let authorizer_id: AuthorizerId = AuthorizerId(random()); + let ar = AddAuthorizer { + id: authorizer_id, + new_authorizer: Authorizer { policy, add_only: false }, + }; + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let add_issuer_raw = AddIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: random::<[[u8; 32]; 32]>().iter().cloned().map(Into::into).collect(), + }; + let pauth = get_pauth(&add_issuer_raw, signers); + dbg!(&add_issuer_raw); + dbg!(&pauth); + TrustedEntityMod::add_issuer(RuntimeOrigin::signed(ABBA), add_issuer_raw, pauth) + .unwrap_err() + } + + run_to_block(10); + + let (a, b, c) = (DIDA, DIDB, DIDC); + let (kpa, kpb, kpc) = (create_did(a), create_did(b), create_did(c)); + + let cases: &[(Policy, &[(Did, &sr25519::Pair)], &str)] = &[ + (Policy::one_of([a]).unwrap(), &[], "provide no signatures"), + (Policy::one_of([a]).unwrap(), &[(b, &kpb)], "wrong account; wrong key"), + (Policy::one_of([a]).unwrap(), &[(a, &kpb)], "correct account; wrong key"), + (Policy::one_of([a]).unwrap(), &[(a, &kpb)], "wrong account; correct key"), + (Policy::one_of([a, b]).unwrap(), &[(c, &kpc)], "account not a controller"), + (Policy::one_of([a, b]).unwrap(), &[(a, &kpa), (b, &kpb)], "two signers"), + (Policy::one_of([a]).unwrap(), &[], "one controller; no sigs"), + (Policy::one_of([a, b]).unwrap(), &[], "two controllers; no sigs"), + ]; + + for (pol, set, description) in cases { + dbg!(description); + assert_eq!( + assert_add_issuer_err(pol.clone(), set), + PolicyExecutionError::NotAuthorized.into(), + "{}", + description + ); + } + } + + #[test] + /// sign unrelated commands and ensure they fail + fn notauthorized_wrong_command() { + if !in_ext() { + return ext().execute_with(notauthorized_wrong_command) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = false; + + run_to_block(10); + + let kpa = create_did(DIDA); + let _kpb = create_did(DIDB); + let authorizer = Authorizer { policy, add_only }; + + let ar = AddAuthorizer { id: authorizer_id, new_authorizer: authorizer }; + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let remove_issuer_raw = RemoveIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: once(TrustedEntityId(Default::default())).collect(), + }; + let ur_proof = get_pauth(&remove_issuer_raw, &[(DIDA, &kpa)]); + TrustedEntityMod::remove_issuer( + RuntimeOrigin::signed(ABBA), + remove_issuer_raw.clone(), + ur_proof, + ) + .unwrap(); + + let add_issuer_raw = AddIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: once(TrustedEntityId(Default::default())).collect(), + }; + let ur_proof = get_pauth(&add_issuer_raw, &[(DIDB, &kpa)]); + assert_eq!( + TrustedEntityMod::add_issuer(RuntimeOrigin::signed(ABBA), add_issuer_raw, ur_proof) + .unwrap_err(), + PolicyExecutionError::NotAuthorized.into() + ); + + let ur_proof = get_pauth(&remove_issuer_raw, &[(DIDA, &kpa)]); + TrustedEntityMod::remove_issuer(RuntimeOrigin::signed(ABBA), remove_issuer_raw, ur_proof) + .unwrap(); + } + + #[test] + fn authzexists() { + if !in_ext() { + return ext().execute_with(authzexists) + } + + let authorizer = Authorizer { policy: Policy::one_of([DIDA]).unwrap(), add_only: false }; + let ar = AddAuthorizer { id: AUA, new_authorizer: authorizer }; + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar.clone()).unwrap(); + let err = TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap_err(); + assert_eq!(err, Error::::AuthzExists.into()); + } + + #[test] + fn noreg() { + if !in_ext() { + return ext().execute_with(noreg) + } + + let authorizer_id = AUA; + + let noreg: Result<(), DispatchError> = Err(PolicyExecutionError::NoEntity.into()); + + assert_eq!( + TrustedEntityMod::add_issuer( + RuntimeOrigin::signed(ABBA), + AddIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: once(TrustedEntityId(Default::default())).collect(), + }, + vec![] + ), + noreg + ); + assert_eq!( + TrustedEntityMod::remove_issuer( + RuntimeOrigin::signed(ABBA), + RemoveIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: once(TrustedEntityId(Default::default())).collect(), + }, + vec![], + ), + noreg + ); + assert_eq!( + TrustedEntityMod::remove_authorizer( + RuntimeOrigin::signed(ABBA), + RemoveAuthorizerRaw { _marker: PhantomData, authorizer_id }, + vec![], + ), + noreg + ); + } + + #[test] + fn too_many_controllers() { + if !in_ext() { + return ext().execute_with(incorrect_nonce) + } + + let authorizer_id = AUA; + let err = Error::::TooManyControllers; + + let ar = AddAuthorizer { + id: authorizer_id, + new_authorizer: Authorizer { + policy: Policy::one_of((0u8..16).map(U256::from).map(Into::into).map(Did)).unwrap(), + add_only: false, + }, + }; + + assert_noop!(TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar), err); + } + + #[test] + fn emtpy_payload() { + if !in_ext() { + return ext().execute_with(incorrect_nonce) + } + let err = Error::::EmptyPayload; + + let kpa = create_did(DIDA); + let authorizer_id = AUA; + let authorizer = Authorizer { policy: Policy::one_of([DIDA]).unwrap(), add_only: false }; + let ar = AddAuthorizer { id: AUA, new_authorizer: authorizer }; + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + let add_issuer_raw = + AddIssuerRaw { _marker: PhantomData, authorizer_id, entity_ids: Default::default() }; + let proof = get_pauth(&add_issuer_raw, &[(DIDA, &kpa)]); + + assert_noop!( + TrustedEntityMod::add_issuer(RuntimeOrigin::signed(ABBA), add_issuer_raw, proof), + err + ); + } + + #[test] + fn incorrect_nonce() { + if !in_ext() { + return ext().execute_with(incorrect_nonce) + } + + run_to_block(1); + + let kpa = create_did(DIDA); + + let authorizer_id = AUA; + let err: Result<(), DispatchError> = Err(PolicyExecutionError::IncorrectNonce.into()); + + let ar = AddAuthorizer { + id: authorizer_id, + new_authorizer: Authorizer { policy: Policy::one_of([DIDA]).unwrap(), add_only: false }, + }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let add_issuer_raw = AddIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: once(TrustedEntityId(Default::default())).collect(), + }; + let proof = get_pauth(&add_issuer_raw, &[(DIDA, &kpa)]); + + // Increase nonce to make the auth chekc fail + inc_nonce(&DIDA); + assert_eq!( + TrustedEntityMod::add_issuer(RuntimeOrigin::signed(ABBA), add_issuer_raw, proof), + err + ); + + let remove_issuer = RemoveIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: once(TrustedEntityId(Default::default())).collect(), + }; + let proof = get_pauth(&remove_issuer, &[(DIDA, &kpa)]); + + // Increase nonce to make the auth check fail + inc_nonce(&DIDA); + assert_eq!( + TrustedEntityMod::remove_issuer(RuntimeOrigin::signed(ABBA), remove_issuer, proof,), + err + ); + + let remove = RemoveAuthorizerRaw { _marker: PhantomData, authorizer_id }; + let proof = get_pauth(&remove, &[(DIDA, &kpa)]); + + // Increase nonce to make the auth check fail + inc_nonce(&DIDA); + assert_eq!( + TrustedEntityMod::remove_authorizer(RuntimeOrigin::signed(ABBA), remove, proof,), + err + ); + } + + #[test] + fn addonly() { + if !in_ext() { + return ext().execute_with(addonly) + } + + let authorizer_id = AUA; + let err: Result<(), DispatchError> = Err(Error::::AddOnly.into()); + let entity_ids: BTreeSet<_> = [TEA, TEB, TEC].iter().cloned().collect(); + + run_to_block(1); + + let kpa = create_did(DIDA); + + let ar = AddAuthorizer { + id: authorizer_id, + new_authorizer: Authorizer { policy: Policy::one_of([DIDA]).unwrap(), add_only: true }, + }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let remove_issuer = RemoveIssuerRaw { _marker: PhantomData, authorizer_id, entity_ids }; + let proof = get_pauth(&remove_issuer, &[(DIDA, &kpa)]); + assert_eq!( + TrustedEntityMod::remove_issuer(RuntimeOrigin::signed(ABBA), remove_issuer, proof), + err + ); + + let remove = RemoveAuthorizerRaw { _marker: PhantomData, authorizer_id }; + let proof = get_pauth(&remove, &[(DIDA, &kpa)]); + assert_eq!( + TrustedEntityMod::remove_authorizer(RuntimeOrigin::signed(ABBA), remove, proof), + err + ); + } + + // Untested variants will be a match error. + // To fix the match error, write a test for the variant then update the test. + fn _all_included(dummy: Error) { + match dummy { + Error::__Ignore(_, _) | + Error::AuthzExists | + Error::EmptyPayload | + Error::IncorrectNonce | + Error::AddOnly | + Error::TooManyControllers => {}, + } + } +} + +/// Tests every happy path for every public extrinsic call in the module. +/// If a happy path is not covered, thats a bug. +/// If a call is not covered, thats a bug. +/// +/// Tests in this module are named after the calls they check. +/// For example, `#[test] fn new_authorizer` tests the happy path for Module::new_authorizer. +mod calls { + use super::*; + // Cannot do `use super::super::*` as that would import `Call` as `Call` which conflicts with + // `Call` in `tests::common` + use super::super::{Authorizers, Call as RevCall, Issuers, Verifiers}; + use alloc::collections::BTreeSet; + + #[test] + fn new_authorizer() { + if !in_ext() { + return ext().execute_with(new_authorizer) + } + + let cases: &[(Policy, bool)] = &[ + (Policy::one_of([DIDA]).unwrap(), false), + (Policy::one_of([DIDA, DIDB]).unwrap(), false), + (Policy::one_of([DIDA]).unwrap(), true), + (Policy::one_of([DIDA, DIDB]).unwrap(), true), + ]; + for (policy, add_only) in cases.iter().cloned() { + let authorizer_id = AuthorizerId(random()); + let authorizer = Authorizer { policy, add_only }; + let ar = AddAuthorizer { id: authorizer_id, new_authorizer: authorizer.clone() }; + assert!(!Authorizers::::contains_key(authorizer_id)); + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + assert!(Authorizers::::contains_key(authorizer_id)); + assert_eq!(Authorizers::::get(authorizer_id).unwrap(), authorizer); + } + } + + #[test] + fn add_issuer() { + if !in_ext() { + return ext().execute_with(add_issuer) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = true; + + run_to_block(1); + + let kpa = create_did(DIDA); + + let ar = + AddAuthorizer { id: authorizer_id, new_authorizer: Authorizer { policy, add_only } }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let cases: &[&[TrustedEntityId]] = &[ + // &[], + &[TrustedEntityId(random())], + &[TrustedEntityId(random()), TrustedEntityId(random())], + &[TrustedEntityId(random()), TrustedEntityId(random()), TrustedEntityId(random())], + &[TEA], // Test idempotence, step 1 + &[TEA], // Test idempotence, step 2 + ]; + for (i, ids) in cases.iter().enumerate() { + println!("AddIssuer ids: {:?}", ids); + let add_issuer = AddIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: ids.iter().cloned().collect(), + }; + let proof = get_pauth(&add_issuer, &[(DIDA, &kpa)]); + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + TrustedEntityMod::add_issuer(RuntimeOrigin::signed(ABBA), add_issuer, proof).unwrap(); + assert!(ids.iter().all(|id| Issuers::::contains_key(authorizer_id, id))); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + run_to_block(1 + 1 + i as u64); + } + } + + #[test] + fn remove_issuer() { + if !in_ext() { + return ext().execute_with(remove_issuer) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = false; + + run_to_block(10); + + let kpa = create_did(DIDA); + + enum Action { + AddIssuer, + RemoveIssuer, + AsrtIssuer, // assert issuer + AsrtNotIssuer, // assert not issuer + } + + let ar = + AddAuthorizer { id: authorizer_id, new_authorizer: Authorizer { policy, add_only } }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let cases: &[(Action, &[TrustedEntityId], u32)] = &[ + //(Action::RemoveIssuer, &[], line!()), + (Action::RemoveIssuer, &[TrustedEntityId(random())], line!()), + ( + Action::RemoveIssuer, + &[TrustedEntityId(random()), TrustedEntityId(random())], + line!(), + ), + ( + Action::RemoveIssuer, + &[TrustedEntityId(random()), TrustedEntityId(random()), TrustedEntityId(random())], + line!(), + ), + (Action::AddIssuer, &[TEA, TEB], line!()), + (Action::AsrtIssuer, &[TEA, TEB], line!()), + (Action::RemoveIssuer, &[TEA], line!()), + (Action::AsrtNotIssuer, &[TEA], line!()), + (Action::AsrtIssuer, &[TEB], line!()), + (Action::RemoveIssuer, &[TEA, TEB], line!()), + (Action::AsrtNotIssuer, &[TEA, TEB], line!()), + (Action::AddIssuer, &[TEA, TEB], line!()), + (Action::AsrtIssuer, &[TEA, TEB], line!()), + (Action::RemoveIssuer, &[TEA, TEB], line!()), + (Action::AsrtNotIssuer, &[TEA, TEB], line!()), + ]; + for (i, (action, ids, line_no)) in cases.iter().enumerate() { + eprintln!("running action from line {}", line_no); + let entity_ids: BTreeSet = ids.iter().cloned().collect(); + match action { + Action::AddIssuer => { + let add_issuer = + AddIssuerRaw { _marker: PhantomData, authorizer_id, entity_ids }; + let proof = get_pauth(&add_issuer, &[(DIDA, &kpa)]); + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + TrustedEntityMod::add_issuer(RuntimeOrigin::signed(ABBA), add_issuer, proof) + .unwrap(); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + }, + Action::RemoveIssuer => { + let remove_issuer = RemoveIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: entity_ids.clone(), + }; + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + let proof = get_pauth(&remove_issuer, &[(DIDA, &kpa)]); + TrustedEntityMod::remove_issuer( + RuntimeOrigin::signed(ABBA), + remove_issuer, + proof, + ) + .unwrap(); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + }, + Action::AsrtIssuer => { + assert!(entity_ids + .iter() + .all(|id| Issuers::::contains_key(authorizer_id, id))); + }, + Action::AsrtNotIssuer => { + assert!(!entity_ids + .iter() + .any(|id| Issuers::::contains_key(authorizer_id, id))); + }, + } + run_to_block(10 + 1 + i as u64) + } + } + + #[test] + fn add_verifier() { + if !in_ext() { + return ext().execute_with(add_verifier) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = true; + + run_to_block(1); + + let kpa = create_did(DIDA); + + let ar = + AddAuthorizer { id: authorizer_id, new_authorizer: Authorizer { policy, add_only } }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let cases: &[&[TrustedEntityId]] = &[ + // &[], + &[TrustedEntityId(random())], + &[TrustedEntityId(random()), TrustedEntityId(random())], + &[TrustedEntityId(random()), TrustedEntityId(random()), TrustedEntityId(random())], + &[TEA], // Test idempotence, step 1 + &[TEA], // Test idempotence, step 2 + ]; + for (i, ids) in cases.iter().enumerate() { + println!("AddVerifier ids: {:?}", ids); + let add_verifier_raw = AddVerifierRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: ids.iter().cloned().collect(), + }; + let proof = get_pauth(&add_verifier_raw, &[(DIDA, &kpa)]); + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + TrustedEntityMod::add_verifier(RuntimeOrigin::signed(ABBA), add_verifier_raw, proof) + .unwrap(); + assert!(ids.iter().all(|id| Verifiers::::contains_key(authorizer_id, id))); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + run_to_block(1 + 1 + i as u64); + } + } + + #[test] + fn remove_verifier() { + if !in_ext() { + return ext().execute_with(remove_verifier) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = false; + + run_to_block(10); + + let kpa = create_did(DIDA); + + enum Action { + AddVerifier, + RemoveVerifier, + AsrtVerifier, // assert verifier + AsrtNotVerifier, // assert not verifier + } + + let ar = + AddAuthorizer { id: authorizer_id, new_authorizer: Authorizer { policy, add_only } }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + + let cases: &[(Action, &[TrustedEntityId], u32)] = &[ + //(Action::RemoveVerifier, &[], line!()), + (Action::RemoveVerifier, &[TrustedEntityId(random())], line!()), + ( + Action::RemoveVerifier, + &[TrustedEntityId(random()), TrustedEntityId(random())], + line!(), + ), + ( + Action::RemoveVerifier, + &[TrustedEntityId(random()), TrustedEntityId(random()), TrustedEntityId(random())], + line!(), + ), + (Action::AddVerifier, &[TEA, TEB], line!()), + (Action::AsrtVerifier, &[TEA, TEB], line!()), + (Action::RemoveVerifier, &[TEA], line!()), + (Action::AsrtNotVerifier, &[TEA], line!()), + (Action::AsrtVerifier, &[TEB], line!()), + (Action::RemoveVerifier, &[TEA, TEB], line!()), + (Action::AsrtNotVerifier, &[TEA, TEB], line!()), + (Action::AddVerifier, &[TEA, TEB], line!()), + (Action::AsrtVerifier, &[TEA, TEB], line!()), + (Action::RemoveVerifier, &[TEA, TEB], line!()), + (Action::AsrtNotVerifier, &[TEA, TEB], line!()), + ]; + for (i, (action, ids, line_no)) in cases.iter().enumerate() { + eprintln!("running action from line {}", line_no); + let entity_ids: BTreeSet = ids.iter().cloned().collect(); + match action { + Action::AddVerifier => { + let add_verifier_raw = + AddVerifierRaw { _marker: PhantomData, authorizer_id, entity_ids }; + let proof = get_pauth(&add_verifier_raw, &[(DIDA, &kpa)]); + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + TrustedEntityMod::add_verifier( + RuntimeOrigin::signed(ABBA), + add_verifier_raw, + proof, + ) + .unwrap(); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + }, + Action::RemoveVerifier => { + let remove_verifier_raw = RemoveVerifierRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: entity_ids.clone(), + }; + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + let proof = get_pauth(&remove_verifier_raw, &[(DIDA, &kpa)]); + TrustedEntityMod::remove_verifier( + RuntimeOrigin::signed(ABBA), + remove_verifier_raw, + proof, + ) + .unwrap(); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + }, + Action::AsrtVerifier => { + assert!(entity_ids + .iter() + .all(|id| Verifiers::::contains_key(authorizer_id, id))); + }, + Action::AsrtNotVerifier => { + assert!(!entity_ids + .iter() + .any(|id| Verifiers::::contains_key(authorizer_id, id))); + }, + } + run_to_block(10 + 1 + i as u64) + } + } + + #[test] + fn remove_authorizer() { + if !in_ext() { + return ext().execute_with(remove_authorizer) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = false; + let kpa = create_did(DIDA); + + let authorizer = Authorizer { policy, add_only }; + let ar = AddAuthorizer { id: authorizer_id, new_authorizer: authorizer }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + assert!(Authorizers::::contains_key(authorizer_id)); + + // destroy authorizer + let rem = RemoveAuthorizerRaw { _marker: PhantomData, authorizer_id }; + let proof = get_pauth(&rem, &[(DIDA, &kpa)]); + let old_nonces = get_nonces(&[(DIDA, &kpa)]); + TrustedEntityMod::remove_authorizer(RuntimeOrigin::signed(ABBA), rem, proof).unwrap(); + check_nonce_increase(old_nonces, &[(DIDA, &kpa)]); + + // assert not exists + assert!(!Authorizers::::contains_key(authorizer_id)); + } + + // Untested variants will be a match error. + // To fix the match error, write a test for the variant then update the test. + fn _all_included(dummy: RevCall) { + match dummy { + RevCall::new_authorizer { .. } | + RevCall::add_issuer { .. } | + RevCall::remove_issuer { .. } | + RevCall::add_verifier { .. } | + RevCall::remove_verifier { .. } | + RevCall::remove_authorizer { .. } | + RevCall::__Ignore { .. } => {}, + } + } +} + +mod test { + use sp_runtime::DispatchError; + // Cannot do `use super::*` as that would import `Call` as `Call` which conflicts with `Call` in + // `tests::common` + use super::*; + use crate::trusted_entity::Authorizers; + + #[test] + /// Exercises Module::ensure_auth, both success and failure cases. + fn ensure_auth() { + if !in_ext() { + return ext().execute_with(ensure_auth) + } + + run_to_block(10); + + let (a, b, c): (Did, Did, Did) = (Did(random()), Did(random()), Did(random())); + let (kpa, kpb, kpc) = (create_did(a), create_did(b), create_did(c)); + let add_issuer_raw = AddIssuerRaw { + _marker: PhantomData, + authorizer_id: AUA, + entity_ids: once(TrustedEntityId(Default::default())).collect(), + }; + + let cases: &[(u32, Policy, &[(Did, &sr25519::Pair)], bool)] = &[ + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpa)], true), + (line!(), Policy::one_of([a, b]).unwrap(), &[(a, &kpa)], true), + (line!(), Policy::one_of([a, b]).unwrap(), &[(b, &kpb)], true), + (line!(), Policy::one_of([a]).unwrap(), &[], false), // provide no signatures + (line!(), Policy::one_of([a]).unwrap(), &[(b, &kpb)], false), // wrong account; wrong key + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpb)], false), // correct account; wrong key + (line!(), Policy::one_of([a]).unwrap(), &[(a, &kpb)], false), // wrong account; correct key + (line!(), Policy::one_of([a, b]).unwrap(), &[(c, &kpc)], false), // account not a controller + (line!(), Policy::one_of([a, b]).unwrap(), &[(a, &kpa), (b, &kpb)], false), // two signers + (line!(), Policy::one_of([a]).unwrap(), &[], false), // one controller; no sigs + (line!(), Policy::one_of([a, b]).unwrap(), &[], false), // two controllers; no sigs + ]; + for (i, (line_no, policy, signers, expect_success)) in cases.iter().enumerate() { + eprintln!("running case from line {}", line_no); + Authorizers::::insert( + AUA, + Authorizer { policy: policy.clone(), add_only: false }, + ); + + let old_nonces = get_nonces(signers); + let command = &add_issuer_raw; + let proof = get_pauth(command, signers); + let res = TrustedEntityMod::try_exec_action_over_authorizer( + |_, _| Ok::<_, DispatchError>(()), + command.clone(), + proof, + ); + assert_eq!(res.is_ok(), *expect_success); + + if *expect_success { + check_nonce_increase(old_nonces, signers); + } + run_to_block(10 + 1 + i as u64); + } + } + + #[test] + /// Exercises the revocation authorizer convenience getter, get_authorizer. + fn get_authorizer() { + if !in_ext() { + return ext().execute_with(get_authorizer) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = false; + let authorizer = Authorizer { policy, add_only }; + + let ar = AddAuthorizer { id: authorizer_id, new_authorizer: authorizer.clone() }; + + assert_eq!(TrustedEntityMod::get_authorizer(authorizer_id), None); + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + assert_eq!(TrustedEntityMod::get_authorizer(authorizer_id), Some(authorizer)); + } + + #[test] + /// Exercises the revocation status convenience getter, get_issuer. + fn get_issuer() { + if !in_ext() { + return ext().execute_with(get_issuer) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = false; + let authorizer = Authorizer { policy, add_only }; + let kpa = create_did(DIDA); + let entity_id: TrustedEntityId = TrustedEntityId(random()); + + let ar = AddAuthorizer { id: authorizer_id, new_authorizer: authorizer }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + let add_issuer = AddIssuerRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: once(entity_id).collect(), + }; + let proof = get_pauth(&add_issuer, &[(DIDA, &kpa)]); + + assert_eq!(TrustedEntityMod::get_issuer(authorizer_id, entity_id), None); + TrustedEntityMod::add_issuer(RuntimeOrigin::signed(ABBA), add_issuer, proof).unwrap(); + assert_eq!(TrustedEntityMod::get_issuer(authorizer_id, entity_id), Some(())); + } + + #[test] + /// Exercises the revocation status convenience getter, get_verifier. + fn get_verifier() { + if !in_ext() { + return ext().execute_with(get_verifier) + } + + let policy = Policy::one_of([DIDA]).unwrap(); + let authorizer_id = AUA; + let add_only = false; + let authorizer = Authorizer { policy, add_only }; + let kpa = create_did(DIDA); + let entity_id: TrustedEntityId = TrustedEntityId(random()); + + let ar = AddAuthorizer { id: authorizer_id, new_authorizer: authorizer }; + + TrustedEntityMod::new_authorizer(RuntimeOrigin::signed(ABBA), ar).unwrap(); + let add_verifier_raw = AddVerifierRaw { + _marker: PhantomData, + authorizer_id, + entity_ids: once(entity_id).collect(), + }; + let proof = get_pauth(&add_verifier_raw, &[(DIDA, &kpa)]); + + assert_eq!(TrustedEntityMod::get_verifier(authorizer_id, entity_id), None); + TrustedEntityMod::add_verifier(RuntimeOrigin::signed(ABBA), add_verifier_raw, proof) + .unwrap(); + assert_eq!(TrustedEntityMod::get_verifier(authorizer_id, entity_id), Some(())); + } +} diff --git a/pallets/did/src/modules/trusted_entity/weights.rs b/pallets/did/src/modules/trusted_entity/weights.rs new file mode 100644 index 0000000..862626f --- /dev/null +++ b/pallets/did/src/modules/trusted_entity/weights.rs @@ -0,0 +1,292 @@ +//! Autogenerated weights for add_issuer +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2022-08-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Native), WASM-EXECUTION: Interpreted, CHAIN: Some("mainnet"), DB CACHE: 128 + +// Executed Command: +// ./target/production/dock-node +// benchmark +// --execution=native +// --chain=mainnet +// --pallet=add_issuer +// --extra +// --extrinsic=* +// --repeat=20 +// --steps=50 +// --template=node/module-weight-template.hbs +// --output=./pallets/core/src/modules/add_issuer/weights.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for add_issuer. +pub trait WeightInfo { + fn add_issuer_sr25519(r: u32) -> Weight; + fn add_issuer_ed25519(r: u32) -> Weight; + fn add_issuer_secp256k1(r: u32) -> Weight; + fn remove_issuer_sr25519(r: u32) -> Weight; + fn remove_issuer_ed25519(r: u32) -> Weight; + fn remove_issuer_secp256k1(r: u32) -> Weight; + fn add_verifier_sr25519(r: u32) -> Weight; + fn add_verifier_ed25519(r: u32) -> Weight; + fn add_verifier_secp256k1(r: u32) -> Weight; + fn remove_verifier_sr25519(r: u32) -> Weight; + fn remove_verifier_ed25519(r: u32) -> Weight; + fn remove_verifier_secp256k1(r: u32) -> Weight; + fn remove_authorizer_sr25519() -> Weight; + fn remove_authorizer_ed25519() -> Weight; + fn remove_authorizer_secp256k1() -> Weight; + fn new_authorizer(c: u32) -> Weight; +} + +/// Weights for add_issuer using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn add_issuer_sr25519(r: u32) -> Weight { + Weight::from_all(51_886_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(744_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_issuer_ed25519(r: u32) -> Weight { + Weight::from_all(55_942_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(718_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_issuer_secp256k1(r: u32) -> Weight { + Weight::from_all(148_000_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(707_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_issuer_sr25519(r: u32) -> Weight { + Weight::from_all(67_695_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(741_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_issuer_ed25519(r: u32) -> Weight { + Weight::from_all(65_882_000_u64) + // Standard Error: 3_000 + .saturating_add(Weight::from_all(747_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_issuer_secp256k1(r: u32) -> Weight { + Weight::from_all(166_568_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(704_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_verifier_sr25519(r: u32) -> Weight { + Weight::from_all(51_886_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(744_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_verifier_ed25519(r: u32) -> Weight { + Weight::from_all(55_942_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(718_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_verifier_secp256k1(r: u32) -> Weight { + Weight::from_all(148_000_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(707_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_verifier_sr25519(r: u32) -> Weight { + Weight::from_all(67_695_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(741_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_verifier_ed25519(r: u32) -> Weight { + Weight::from_all(65_882_000_u64) + // Standard Error: 3_000 + .saturating_add(Weight::from_all(747_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_verifier_secp256k1(r: u32) -> Weight { + Weight::from_all(166_568_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(704_000_u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_authorizer_sr25519() -> Weight { + Weight::from_all(128_526_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(103_u64)) + } + fn remove_authorizer_ed25519() -> Weight { + Weight::from_all(122_116_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(103_u64)) + } + fn remove_authorizer_secp256k1() -> Weight { + Weight::from_all(230_576_000_u64) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(103_u64)) + } + fn new_authorizer(c: u32) -> Weight { + Weight::from_all(9_069_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(35_000_u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn add_issuer_sr25519(r: u32) -> Weight { + Weight::from_all(51_886_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(744_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_issuer_ed25519(r: u32) -> Weight { + Weight::from_all(55_942_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(718_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_issuer_secp256k1(r: u32) -> Weight { + Weight::from_all(148_000_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(707_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_issuer_sr25519(r: u32) -> Weight { + Weight::from_all(67_695_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(741_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_issuer_ed25519(r: u32) -> Weight { + Weight::from_all(65_882_000_u64) + // Standard Error: 3_000 + .saturating_add(Weight::from_all(747_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_issuer_secp256k1(r: u32) -> Weight { + Weight::from_all(166_568_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(704_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_verifier_sr25519(r: u32) -> Weight { + Weight::from_all(51_886_000_u64) + // Standard Error: 0 + .saturating_add(Weight::from_all(744_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_verifier_ed25519(r: u32) -> Weight { + Weight::from_all(55_942_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(718_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn add_verifier_secp256k1(r: u32) -> Weight { + Weight::from_all(148_000_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(707_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_verifier_sr25519(r: u32) -> Weight { + Weight::from_all(67_695_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(741_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_verifier_ed25519(r: u32) -> Weight { + Weight::from_all(65_882_000_u64) + // Standard Error: 3_000 + .saturating_add(Weight::from_all(747_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_verifier_secp256k1(r: u32) -> Weight { + Weight::from_all(166_568_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(704_000_u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(r as u64))) + } + fn remove_authorizer_sr25519() -> Weight { + Weight::from_all(128_526_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(103_u64)) + } + fn remove_authorizer_ed25519() -> Weight { + Weight::from_all(122_116_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(103_u64)) + } + fn remove_authorizer_secp256k1() -> Weight { + Weight::from_all(230_576_000_u64) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(103_u64)) + } + fn new_authorizer(c: u32) -> Weight { + Weight::from_all(9_069_000_u64) + // Standard Error: 1_000 + .saturating_add(Weight::from_all(35_000_u64).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } +} diff --git a/pallets/did/src/tests/common.rs b/pallets/did/src/tests/common.rs new file mode 100644 index 0000000..bf3014b --- /dev/null +++ b/pallets/did/src/tests/common.rs @@ -0,0 +1,365 @@ +//! Boilerplate for runtime module unit tests + +use crate::{ + accumulator, anchor, attest, blob, + common::{self, StateChange, ToStateChange}, + did::{self, Did, DidKey, DidSignature}, + offchain_signatures, revoke, status_list_credential, trusted_entity, +}; + +use crate::{ + common::SigValue, + revoke::{RegistryId, RevokeId}, + trusted_entity::{AuthorizerId, TrustedEntityId}, +}; +use codec::{Decode, Encode}; +use frame_support::{ + construct_runtime, parameter_types, derive_impl, + traits::{Contains, OnFinalize, OnInitialize, IsType}, + weights::Weight, +}; + +use frame_system::{Origin, RawOrigin}; +pub use rand::random; +use sp_core::{sr25519, Pair, H160, H256}; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, ConstU32, ConstU64, IdentityLookup}, + BuildStorage, +}; +pub use std::iter::once; + +// Configure a mock runtime to test the pallet. +type Block = frame_system::mocking::MockBlock; + +construct_runtime!( + pub enum Test + { + System: frame_system, + Balances: pallet_balances, + Timestamp: pallet_timestamp, + DIDModule: did, + RevoMod: revoke, + TrustedEntityMod: trusted_entity, + BlobMod: blob, + AnchorMod: anchor, + AttestMod: attest, + SignatureMod: offchain_signatures, + AccumMod: accumulator, + StatusListCredentialMod: status_list_credential, + } +); + +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Debug, Eq)] +pub enum TestEvent { + Did(crate::did::Event), + Revoke(crate::revoke::Event), + Anchor(crate::anchor::Event), + Unknown, + OffchainSignature(offchain_signatures::Event), + Accum(accumulator::Event), + StatusListCredential(status_list_credential::Event), + TrustedEntity(trusted_entity::Event), +} + +impl From> for TestEvent { + fn from(_: frame_system::Event) -> Self { + unimplemented!() + } +} + +impl From> for TestEvent { + fn from(_: pallet_balances::Event) -> Self { + unimplemented!() + } +} + +impl From<()> for TestEvent { + fn from((): ()) -> Self { + Self::Unknown + } +} + +impl From> for TestEvent { + fn from(other: crate::did::Event) -> Self { + Self::Did(other) + } +} + +impl From for TestEvent { + fn from(other: crate::revoke::Event) -> Self { + Self::Revoke(other) + } +} + +impl From> for TestEvent { + fn from(other: crate::anchor::Event) -> Self { + Self::Anchor(other) + } +} + +impl From for TestEvent { + fn from(other: crate::status_list_credential::Event) -> Self { + Self::StatusListCredential(other) + } +} + +impl From for TestEvent { + fn from(other: offchain_signatures::Event) -> Self { + Self::OffchainSignature(other) + } +} + +impl From for TestEvent { + fn from(other: accumulator::Event) -> Self { + Self::Accum(other) + } +} + +impl From for TestEvent { + fn from(other: trusted_entity::Event) -> Self { + Self::TrustedEntity(other) + } +} + +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const MaxPolicyControllers: u32 = 15; + pub const MaxStatusListCredentialSize: u32 = 1_000; + pub const MinStatusListCredentialSize: u32 = 10; +} + +pub struct BaseFilter; +impl Contains for BaseFilter { + fn contains(_call: &RuntimeCall) -> bool { + true + } +} + +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] +impl frame_system::Config for Test { + type Block = Block; + type AccountData = pallet_balances::AccountData; + type MaxConsumers = ConstU32<3>; +} + +impl pallet_timestamp::Config for Test { + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = (); + type WeightInfo = (); +} + +parameter_types! { + pub const ExistentialDeposit: u64 = 5; + pub const MaxReserves: u32 = 50; +} + +impl pallet_balances::Config for Test { + type MaxLocks = ConstU32<50>; + /// The type for recording an account's balance. + type Balance = u64; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); + type MaxReserves = ConstU32<50>; + type ReserveIdentifier = [u8; 8]; + type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; + type FreezeIdentifier = (); + type MaxFreezes = ConstU32<0>; +} + +parameter_types! { + pub const MaxMasterMembers: u32 = 100; +} + +impl crate::common::Limits for Test { + type MaxDidDocRefSize = MaxDidDocRefSize; + type MaxDidServiceEndpointIdSize = MaxDidServiceEndpointIdSize; + type MaxDidServiceEndpointOrigins = MaxDidServiceEndpointOrigins; + type MaxDidServiceEndpointOriginSize = MaxDidServiceEndpointOriginSize; + + type MaxAccumulatorLabelSize = MaxAccumulatorLabelSize; + type MaxAccumulatorParamsSize = MaxAccumulatorParamsSize; + type MaxAccumulatorPublicKeySize = MaxBBSPublicKeySize; + type MaxAccumulatorAccumulatedSize = MaxAccumulatorAccumulatedSize; + + type MaxStatusListCredentialSize = MaxStatusListCredentialSize; + type MinStatusListCredentialSize = MinStatusListCredentialSize; + + type MaxIriSize = MaxIriSize; + type MaxBlobSize = MaxBlobSize; + + type MaxOffchainParamsLabelSize = MaxAccumulatorParamsSize; + type MaxOffchainParamsBytesSize = MaxAccumulatorParamsSize; + type MaxBBSPublicKeySize = MaxBBSPublicKeySize; + type MaxBBSPlusPublicKeySize = MaxBBSPublicKeySize; + type MaxPSPublicKeySize = MaxPSPublicKeySize; + + type MaxMasterMembers = MaxMasterMembers; + type MaxPolicyControllers = MaxPolicyControllers; +} + +impl crate::did::Config for Test { + type RuntimeEvent = TestEvent; + type OnDidRemoval = SignatureMod; +} + +impl crate::revoke::Config for Test { + type RuntimeEvent = TestEvent; +} +impl crate::trusted_entity::Config for Test { + type RuntimeEvent = TestEvent; +} +impl crate::status_list_credential::Config for Test { + type RuntimeEvent = TestEvent; +} +impl crate::blob::Config for Test {} +impl crate::attest::Config for Test {} + +parameter_types! { + pub const MaxBlobSize: u32 = 1024; + pub const MaxIriSize: u32 = 1024; + pub const MaxAccumulatorLabelSize: u32 = 512; + pub const MaxAccumulatorParamsSize: u32 = 512; + pub const MaxBBSPublicKeySize: u32 = 128; + pub const MaxPSPublicKeySize: u32 = 128; + pub const MaxAccumulatorAccumulatedSize: u32 = 256; + pub const MaxDidDocRefSize: u16 = 128; + pub const MaxDidServiceEndpointIdSize: u16 = 256; + pub const MaxDidServiceEndpointOrigins: u16 = 20; + pub const MaxDidServiceEndpointOriginSize: u16 = 256; +} + +impl crate::anchor::Config for Test { + type RuntimeEvent = TestEvent; +} + +impl offchain_signatures::Config for Test { + type RuntimeEvent = TestEvent; +} + +impl accumulator::Config for Test { + type RuntimeEvent = TestEvent; +} + +pub const ABBA: u64 = 0; +pub const DIDA: Did = Did([0u8; 32]); +pub const DIDB: Did = Did([1u8; 32]); +pub const DIDC: Did = Did([2u8; 32]); +pub const RGA: RegistryId = RegistryId([0u8; 32]); +pub const RA: RevokeId = RevokeId([0u8; 32]); +pub const RB: RevokeId = RevokeId([1u8; 32]); +pub const RC: RevokeId = RevokeId([2u8; 32]); +pub const AUA: AuthorizerId = AuthorizerId([0u8; 32]); +pub const TEA: TrustedEntityId = TrustedEntityId([0u8; 32]); +pub const TEB: TrustedEntityId = TrustedEntityId([1u8; 32]); +pub const TEC: TrustedEntityId = TrustedEntityId([2u8; 32]); + +/// check whether test externalities are available +pub fn in_ext() -> bool { + std::panic::catch_unwind(|| sp_io::storage::exists(&[])).is_ok() +} + +#[test] +pub fn meta_in_ext() { + assert!(!in_ext()); + ext().execute_with(|| assert!(in_ext())); +} + +pub fn ext() -> sp_io::TestExternalities { + let mut ret: sp_io::TestExternalities = + frame_system::GenesisConfig::::default().build_storage().unwrap().into(); + ret.execute_with(|| { + frame_system::Pallet::::initialize( + &1, // system module will not store events if block_number == 0 + &[0u8; 32].into(), + &Default::default(), + ); + }); + ret +} + +/// generate a random keypair +pub fn gen_kp() -> sr25519::Pair { + sr25519::Pair::generate_with_phrase(None).0 +} + +// Create did for `did`. Return the randomly generated signing key. +// The did public key is controlled by some non-existent account (normally a security +// concern), but that doesn't matter for our purposes. +pub fn create_did(did: did::Did) -> sr25519::Pair { + let kp = gen_kp(); + println!("did pk: {:?}", kp.public().0); + did::Pallet::::new_onchain( + RuntimeOrigin::signed(ABBA), + did, + vec![DidKey::new_with_all_relationships(common::PublicKey::Sr25519(kp.public().0.into())) + .into()], + vec![].into_iter().collect(), + ) + .unwrap(); + kp +} + +/// create a did with a random id and random signing key +pub fn newdid() -> (Did, sr25519::Pair) { + let d: Did = Did(rand::random()); + (d, create_did(d)) +} + +pub fn sign(payload: &StateChange, keypair: &sr25519::Pair) -> SigValue { + SigValue::Sr25519(keypair.sign(&payload.encode()).0.into()) +} + +pub fn did_sig, D: Into>( + change: &A, + keypair: &sr25519::Pair, + did: D, + key_id: u32, +) -> DidSignature { + let sig = sign(&change.to_state_change(), keypair); + DidSignature { did, key_id: key_id.into(), sig } +} + +pub fn did_sig_on_bytes>( + msg_bytes: &[u8], + keypair: &sr25519::Pair, + did: D, + key_id: u32, +) -> DidSignature { + let sig = SigValue::Sr25519(keypair.sign(msg_bytes).0.into()); + + DidSignature { did, key_id: key_id.into(), sig } +} + +/// create a random byte array with set len +pub fn random_bytes(len: usize) -> Vec { + (0..len).map(|_| rand::random()).collect() +} + +/// Changes the block number. Calls `on_finalize` and `on_initialize` +pub fn run_to_block(n: u64) { + while System::block_number() < n { + if System::block_number() > 1 { + System::on_finalize(System::block_number()); + } + System::set_block_number(System::block_number() + 1); + System::on_initialize(System::block_number()); + } +} + +pub fn check_nonce(d: &Did, nonce: u64) { + let did_detail = DIDModule::onchain_did_details(d).unwrap(); + assert_eq!(did_detail.nonce, nonce); +} + +pub fn inc_nonce(d: &Did) { + let mut did_detail = DIDModule::onchain_did_details(d).unwrap(); + did_detail.nonce = did_detail.next_nonce().unwrap(); + DIDModule::insert_did_details(*d, did_detail); +} diff --git a/pallets/did/src/tests/mod.rs b/pallets/did/src/tests/mod.rs new file mode 100644 index 0000000..34994bf --- /dev/null +++ b/pallets/did/src/tests/mod.rs @@ -0,0 +1 @@ +pub mod common; diff --git a/pallets/did/src/util/action.rs b/pallets/did/src/util/action.rs new file mode 100644 index 0000000..887bda8 --- /dev/null +++ b/pallets/did/src/util/action.rs @@ -0,0 +1,24 @@ +use crate::common::Types; + +/// Describes an action which can be performed on some `Target`. +pub trait Action { + /// Action target. + type Target; + + /// Returns underlying action target. + fn target(&self) -> Self::Target; + + /// Returns action unit length. + fn len(&self) -> u32; + + /// Returns `true` if the action unit count is equal to zero. + fn is_empty(&self) -> bool { + self.len() == 0 + } +} + +/// Describes an action with nonce which can be performed on some `Target` +pub trait ActionWithNonce: Action { + /// Returns action's nonce. + fn nonce(&self) -> T::BlockNumber; +} diff --git a/pallets/did/src/util/btree.rs b/pallets/did/src/util/btree.rs new file mode 100644 index 0000000..086c797 --- /dev/null +++ b/pallets/did/src/util/btree.rs @@ -0,0 +1,49 @@ +use alloc::collections::{BTreeMap, BTreeSet}; + +use serde::{self, Deserialize, Serialize}; + +pub mod btree_set { + use super::*; + + pub fn serialize(value: &T, serializer: S) -> Result + where + S: serde::Serializer, + T: AsRef>, + BTreeSet: serde::Serialize, + { + BTreeSet::serialize(value.as_ref(), serializer) + } + + pub fn deserialize<'de, D, I, O>(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + BTreeSet: serde::Deserialize<'de> + TryInto, + { + BTreeSet::deserialize(deserializer)? + .try_into() + .map_err(|_| serde::de::Error::custom("`BTreeSet` size limit exceeded")) + } +} + +pub mod btree_map { + use super::*; + + pub fn serialize(value: &T, serializer: S) -> Result + where + S: serde::Serializer, + T: AsRef>, + BTreeMap: serde::Serialize, + { + BTreeMap::serialize(value.as_ref(), serializer) + } + + pub fn deserialize<'de, D, K, V, O>(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + BTreeMap: serde::Deserialize<'de> + TryInto, + { + BTreeMap::deserialize(deserializer)? + .try_into() + .map_err(|_| serde::de::Error::custom("`BTreeMap` size limit exceeded")) + } +} diff --git a/pallets/did/src/util/bytes.rs b/pallets/did/src/util/bytes.rs new file mode 100644 index 0000000..4b6459c --- /dev/null +++ b/pallets/did/src/util/bytes.rs @@ -0,0 +1,157 @@ +use crate::impl_wrapper; +#[cfg(feature = "serde")] +use crate::util::hex; +use codec::{Decode, Encode, MaxEncodedLen}; +use core::ops::{Index, RangeFull}; +use frame_support::*; +use sp_runtime::traits::Get; +use sp_std::{fmt, vec::Vec}; + +/// Wrapper around the bounded vector. providing the ability to encode/decode in `hex` format. +#[derive( + Encode, + Decode, + DebugNoBound, + CloneNoBound, + PartialEqNoBound, + EqNoBound, + DefaultNoBound, + PartialOrd, + Ord, + MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr( + feature = "serde", + serde(bound(serialize = "MaxSize: Sized", deserialize = "MaxSize: Sized")) +)] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(skip_type_params(MaxSize))] +#[scale_info(omit_prefix)] +pub struct BoundedBytes>( + #[cfg_attr(feature = "serde", serde(with = "hex"))] pub BoundedVec, +); + +crate::impl_wrapper!(BoundedBytes>(BoundedVec)); + +impl> TryFrom> for BoundedBytes { + type Error = Vec; + + fn try_from(bytes: Vec) -> Result> { + TryFrom::try_from(bytes).map(Self) + } +} + +/// Wrapper around raw bytes vector providing the ability to encode/decode in `hex` format. +#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct Bytes(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub Vec); + +impl FromIterator for Bytes { + fn from_iter>(iter: I) -> Bytes { + Bytes(Vec::from_iter(iter)) + } +} + +#[cfg(test)] +use rand::distributions::Distribution; +impl_wrapper! { Bytes(Vec), for rand use rand::distributions::Standard.sample_iter(&mut rand::thread_rng()).take(32).collect(), with tests as wrapped_bytes_tests } + +// XXX: This could have been a tuple struct. Keeping it a normal struct for Substrate UI +/// A wrapper over 32-byte array +#[derive( + Encode, + Decode, + Debug, + Clone, + PartialEq, + Eq, + Ord, + Copy, + PartialOrd, + MaxEncodedLen, + scale_info_derive::TypeInfo, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[scale_info(omit_prefix)] +pub struct Bytes32(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub [u8; 32]); + +crate::impl_wrapper! { Bytes32([u8; 32]) } + +impl Index for Bytes32 { + type Output = [u8; 32]; + + fn index(&self, _: RangeFull) -> &Self::Output { + &self.0 + } +} + +#[cfg(feature = "serde")] +serde_big_array::big_array! { + BigArray; + 33, 64, 65 +} + +// XXX: These could have been a tuple structs. Keeping them normal struct for Substrate UI +/// Creates a struct named `$name` which contains only 1 element which is a bytearray, useful when +/// wrapping arrays of size > 32. `$size` is the size of the underlying bytearray. Implements the +/// `Default`, `sp_std::fmt::Debug`, `PartialEq` and `Eq` trait as they will not be automatically +/// implemented for arrays of size > 32. +macro_rules! struct_over_byte_array { + ( $name:ident, $size:tt ) => { + /// A wrapper over a byte array + #[derive( + Encode, Decode, Clone, Copy, PartialOrd, Ord, scale_info_derive::TypeInfo, MaxEncodedLen, + )] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[scale_info(omit_prefix)] + pub struct $name( + #[cfg_attr(feature = "serde", serde(with = "hex::big_array"))] pub [u8; $size], + ); + + $crate::impl_wrapper! { $name([u8; $size]) } + + /// Implementing Default as it cannot be automatically derived for arrays of size > 32 + impl Default for $name { + fn default() -> Self { + Self([0; $size]) + } + } + + impl Index for $name { + type Output = [u8; $size]; + + fn index(&self, _: RangeFull) -> &Self::Output { + &self.0 + } + } + + /// Implementing Debug as it cannot be automatically derived for arrays of size > 32 + impl fmt::Debug for $name { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0[..].fmt(f) + } + } + + /// Implementing PartialEq as it cannot be automatically derived for arrays of size > 32 + impl PartialEq for $name { + fn eq(&self, other: &Self) -> bool { + self.0[..] == other.0[..] + } + } + + impl Eq for $name {} + + impl $name { + /// Return a slice to the underlying bytearray + pub fn as_bytes(&self) -> &[u8] { + &self.0 + } + } + }; +} + +struct_over_byte_array!(Bytes64, 64); +struct_over_byte_array!(Bytes65, 65); diff --git a/pallets/did/src/util/div_ceil.rs b/pallets/did/src/util/div_ceil.rs new file mode 100644 index 0000000..efa91a5 --- /dev/null +++ b/pallets/did/src/util/div_ceil.rs @@ -0,0 +1,124 @@ +//! Arithmetic utilities. + +use core::ops::{Add, Div, Rem}; + +use num_traits::{CheckedAdd, CheckedDiv, CheckedRem, One, Zero}; + +/// Provides ability to perform ceiling division operations on integers. +pub trait DivCeil: Sized { + /// Performs ceiling division usign supplied operands. + fn div_ceil(self, other: Self) -> Self; +} + +/// Provides ability to perform checked ceiling division operations on integers. +pub trait CheckedDivCeil: Sized { + /// Performs checked ceiling division usign supplied operands. + /// + /// Returns `None` in case either divider is zero or the calculation overflowed. + fn checked_div_ceil(self, other: Self) -> Option; +} + +/// Implements `DivCeil` for any type which implements `Div`/`Rem`/`Add`/`Ord`/`Zero`/`One`/`Copy`. +impl DivCeil for T +where + T: Div + Rem + Add + Ord + Zero + One + Copy, +{ + fn div_ceil(self, other: Self) -> Self { + let quot = self / other; + let rem = self % other; + let zero = Self::zero(); + + if (rem > zero && other > zero) || (rem < zero && other < zero) { + quot + One::one() + } else { + quot + } + } +} + +/// Implements `CheckedDivCeil` for any type which implements +/// `CheckedDiv`/`CheckedRem`/`CheckedAdd`/`Ord`/`Zero`/`One`/`Copy`. +impl CheckedDivCeil for T +where + T: CheckedDiv + CheckedRem + CheckedAdd + Ord + Zero + One + Copy, +{ + fn checked_div_ceil(self, other: Self) -> Option { + let quot = self.checked_div(&other)?; + let rem = self.checked_rem(&other)?; + let zero = Self::zero(); + + if (rem > zero && other > zero) || (rem < zero && other < zero) { + quot.checked_add(&One::one()) + } else { + Some(quot) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn div_ceil() { + assert_eq!(9.div_ceil(2), 5); + assert_eq!(10.div_ceil(2), 5); + assert_eq!(11.div_ceil(2), 6); + assert_eq!(12.div_ceil(2), 6); + assert_eq!(0.div_ceil(1), 0); + assert_eq!(1.div_ceil(1), 1); + } + + #[test] + fn checked_div_ceil() { + assert_eq!(9.checked_div_ceil(2), Some(5)); + assert_eq!(10.checked_div_ceil(2), Some(5)); + assert_eq!(11.checked_div_ceil(2), Some(6)); + assert_eq!(12.checked_div_ceil(2), Some(6)); + assert_eq!(0.checked_div_ceil(1), Some(0)); + assert_eq!(1.checked_div_ceil(1), Some(1)); + assert_eq!(1.checked_div_ceil(0), None); + } + + #[test] + fn div_ceil_negative() { + assert_eq!((0).div_ceil(-1), 0); + assert_eq!((-1).div_ceil(2), 0); + assert_eq!((-9).div_ceil(2), -4); + assert_eq!((-10).div_ceil(2), -5); + assert_eq!((-11).div_ceil(2), -5); + assert_eq!((-12).div_ceil(2), -6); + assert_eq!(0.div_ceil(1), 0); + assert_eq!((-1).div_ceil(1), -1); + + assert_eq!((-1).div_ceil(-2), 1); + assert_eq!((-9).div_ceil(-2), 5); + assert_eq!((-10).div_ceil(-2), 5); + assert_eq!((-11).div_ceil(-2), 6); + assert_eq!((-12).div_ceil(-2), 6); + assert_eq!(0.div_ceil(-1), 0); + assert_eq!((-1).div_ceil(-1), 1); + } + + #[test] + fn checked_div_ceil_negative() { + assert_eq!((0).checked_div_ceil(-1), Some(0)); + assert_eq!((-1).checked_div_ceil(2), Some(0)); + assert_eq!((-9).checked_div_ceil(2), Some(-4)); + assert_eq!((-10).checked_div_ceil(2), Some(-5)); + assert_eq!((-11).checked_div_ceil(2), Some(-5)); + assert_eq!((-12).checked_div_ceil(2), Some(-6)); + assert_eq!(0.checked_div_ceil(1), Some(0)); + assert_eq!(1.checked_div_ceil(0), None); + assert_eq!((-1).checked_div_ceil(1), Some(-1)); + + assert_eq!((-1).checked_div_ceil(-2), Some(1)); + assert_eq!((-9).checked_div_ceil(-2), Some(5)); + assert_eq!((-10).checked_div_ceil(-2), Some(5)); + assert_eq!((-11).checked_div_ceil(-2), Some(6)); + assert_eq!((-12).checked_div_ceil(-2), Some(6)); + assert_eq!(0.checked_div_ceil(-1), Some(0)); + assert_eq!((-1).checked_div_ceil(-0), None); + assert_eq!((-1).checked_div_ceil(-1), Some(1)); + } +} diff --git a/pallets/did/src/util/hex.rs b/pallets/did/src/util/hex.rs new file mode 100644 index 0000000..e6917e2 --- /dev/null +++ b/pallets/did/src/util/hex.rs @@ -0,0 +1,108 @@ +use alloc::{format, string::String}; +use serde::{ + self, + de::{Error, Visitor}, +}; +use serde_hex::FromHex; +use sp_std::{fmt, marker::PhantomData, vec::Vec}; + +struct HexStrVisitor(PhantomData); + +impl<'de, T> Visitor<'de> for HexStrVisitor +where + T: FromHex, + ::Error: fmt::Display, +{ + type Value = T; + + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "a hex encoded string") + } + + fn visit_str(self, data: &str) -> Result + where + E: Error, + { + parse_hex(data).map_err(Error::custom) + } + + fn visit_borrowed_str(self, data: &'de str) -> Result + where + E: Error, + { + parse_hex(data).map_err(Error::custom) + } +} + +fn parse_hex(data: &str) -> Result::Error> +where + T: serde_hex::FromHex, +{ + FromHex::from_hex(data.strip_prefix("0x").unwrap_or(data)) +} + +pub mod big_array { + use crate::util::{self, BigArray}; + + use super::*; + pub fn serialize<'a, T, S>(value: &'a T, serializer: S) -> Result + where + S: serde::Serializer, + T: util::BigArray<'a> + serde_hex::ToHex, + { + if serializer.is_human_readable() { + let str: String = value.encode_hex(); + serializer.serialize_str(&format!("0x{}", str)) + } else { + BigArray::serialize(value, serializer) + } + } + + pub fn deserialize<'de, D, T>(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + T: util::BigArray<'de> + serde_hex::FromHex, + ::Error: sp_std::fmt::Display, + { + if deserializer.is_human_readable() { + deserializer.deserialize_str(HexStrVisitor(PhantomData)) + } else { + BigArray::deserialize(deserializer) + } + } +} + +mod basic { + use super::*; + + pub fn serialize(value: &T, serializer: S) -> Result + where + S: serde::Serializer, + T: serde::Serialize + AsRef<[u8]>, + { + if serializer.is_human_readable() { + let str = serde_hex::encode(value.as_ref()); + serializer.serialize_str(&format!("0x{}", str)) + } else { + T::serialize(value, serializer) + } + } + + pub fn deserialize<'de, D, T>(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + T: serde::Deserialize<'de> + TryFrom>, + { + if deserializer.is_human_readable() { + let deserialized_bytes = + deserializer.deserialize_str(HexStrVisitor::>(PhantomData))?; + + T::try_from(deserialized_bytes) + .map_err(|_| serde::de::Error::custom("Failed to construct a value from hex")) + } else { + T::deserialize(deserializer) + } + } +} + +pub use basic::*; diff --git a/pallets/did/src/util/inc_id.rs b/pallets/did/src/util/inc_id.rs new file mode 100644 index 0000000..93d2486 --- /dev/null +++ b/pallets/did/src/util/inc_id.rs @@ -0,0 +1,36 @@ +use crate::impl_wrapper_from_type_conversion; +use codec::{Decode, Encode, MaxEncodedLen}; + +/// An incremental identifier. +#[derive( + Encode, Decode, Debug, Clone, PartialEq, Eq, Copy, Default, Ord, PartialOrd, Hash, MaxEncodedLen, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct IncId(u32); + +impl IncId { + /// Creates new `IncId` equal to zero. + pub fn new() -> Self { + Self::default() + } + + /// Increases `IncId` value returning next sequential identifier. + pub fn inc(&mut self) -> &mut Self { + self.0 += 1; + self + } +} + +impl Iterator for &'_ mut IncId { + type Item = IncId; + + fn next(&mut self) -> Option { + Some(*self.inc()) + } +} + +impl_wrapper_from_type_conversion! { from u8 => IncId } +impl_wrapper_from_type_conversion! { from u16 => IncId } +impl_wrapper_from_type_conversion! { from u32 => IncId } diff --git a/pallets/did/src/util/macros.rs b/pallets/did/src/util/macros.rs new file mode 100644 index 0000000..ff622ea --- /dev/null +++ b/pallets/did/src/util/macros.rs @@ -0,0 +1,456 @@ +/// Implements bits conversion from/to the given type for the supplied bitflags identifier. +#[macro_export] +macro_rules! impl_bits_conversion { + ($ident: ident from $type: ty) => { + impl From<$ident> for $type { + fn from(value: $ident) -> Self { + value.bits() + } + } + + impl TryFrom<$type> for $ident { + type Error = $type; + + fn try_from(value: $type) -> Result { + Self::from_bits(value).ok_or(value) + } + } + + impl Encode for $ident { + fn encode(&self) -> Vec { + <$type>::encode(&self.clone().into()) + } + } + + impl Decode for $ident { + fn decode(input: &mut I) -> Result { + let decoded = <$type>::decode(input)?; + + Self::from_bits(decoded).ok_or("Invalid value".into()) + } + } + + impl MaxEncodedLen for $ident { + fn max_encoded_len() -> usize { + <$type>::max_encoded_len() + } + } + }; +} + +/// Makes given ident `pub` only for test and uses supplied visibility if compiled otherwise. +#[macro_export] +macro_rules! pub_for_test { + ($(#[$meta:meta])* $vis: vis $ident: ident $($val: tt)*) => { + #[cfg(test)] + $(#[$meta])* + pub $ident $($val)* + + #[cfg(not(test))] + $(#[$meta])* + $vis $ident $($val)* + } +} + +/// Implements field accessor based on input using supplied `self`. +#[macro_export] +macro_rules! field_accessor { + ($self: ident, () with $($rest: tt)*) => { + () $($rest)* + }; + ($self: ident, $lit: literal with $($rest: tt)*) => { + $lit $($rest)* + }; + ($self: ident, { $expr: expr } with $($rest: tt)*) => { + $expr($self) $($rest)* + }; + ($self: ident, $($ident: tt $(($($call: tt),*))?).+ with $($rest: tt)*) => { + $self.$($ident $(($($call)*))*).+ $($rest)* + }; +} + +/// Implements `ToStateChange` trait with supplied params for the given ident(s). +#[macro_export] +macro_rules! impl_to_state_change { + ($type: ident) => { + impl $crate::common::ToStateChange for $type { + fn to_state_change(&self) -> $crate::common::StateChange<'_, T> { + $crate::common::StateChange::$type(sp_std::borrow::Cow::Borrowed(self)) + } + } + }; +} + +/// Implements `Action` trait with supplied params for the given ident(s). +#[macro_export] +macro_rules! impl_action { + ( + $type: ident for $target: ty: with + $($len_field: tt $(($($len_call: tt),*))?).+ as len, + $($target_field: tt $(($($target_call: tt),*))?).+ as target + ) => { + $crate::impl_to_state_change! { $type } + + impl $crate::util::Action for $type { + type Target = $target; + + fn target(&self) -> $target { + $crate::field_accessor!(self, $($target_field $(($($target_call)*))*).+ with) + } + + fn len(&self) -> u32 { + $crate::field_accessor!(self, $($len_field $(($($len_call)*))*).+ with as u32) + } + } + }; + ( + $type: ident for $target: ty: with + $($len_field: tt $(($($len_call: tt),*))?).+ as len, + $($target_field: tt $(($($target_call: tt),*))?).+ as target + no_state_change + ) => { + impl $crate::util::Action for $type { + type Target = $target; + + fn target(&self) -> $target { + $crate::field_accessor!(self, $($target_field $(($($target_call)*))*).+ with) + } + + fn len(&self) -> u32 { + $crate::field_accessor!(self, $($len_field $(($($len_call)*))*).+ with as u32) + } + } + }; + ( + for $target: ty: + $( + $type: ident with + $($len_field: tt $(($($len_call: tt),*))?).+ as len, + $($target_field: tt $(($($target_call: tt),*))?).+ as target + $($rest: tt)? + ),+ + ) => { + $( + $crate::impl_action! { + $type for $target: + with $($len_field $(($($len_call),*))*).+ as len, + $($target_field $(($($target_call)*))*).+ as target + $($rest)? + } + )+ + }; +} + +/// Implements `Action` and `ActionWithNonce` traits with supplied params for the given ident(s). +#[macro_export] +macro_rules! impl_action_with_nonce { + ($type: ident for $($token: tt)*) => { + $crate::impl_action! { $type for $($token)* } + + impl $crate::util::ActionWithNonce for $type { + fn nonce(&self) -> T::BlockNumber { + self.nonce + } + } + }; + (for $target: ty: + $( + $type: ident with $($len: tt $(($($len_call: tt),*))?).+ as len, + $($target_field: tt $(($($target_call: tt),*))?).+ as target + ),+ + ) => { + $( + $crate::impl_action_with_nonce! { + $type for $target: + with $($len $(($($len_call),*))*).+ as len, + $($target_field $(($($target_call)*))*).+ as target + } + )+ + }; +} + +/// Implements given trait for the tuple type. +#[macro_export] +macro_rules! impl_tuple { + (@ $method: ident($($arg: ident: $arg_ty: ty),*) => using $combine: ident for $main: ident) => { $main::$method($($arg),*) }; + (@ $method: ident($($arg: ident: $arg_ty: ty),*) => using $combine: ident for $main: ident $($ty: ident)+) => { + $main::$method($($arg),*).$combine($crate::impl_tuple!(@ $method($($arg: $arg_ty),*) => using $combine for $($ty)*)) + }; + ($trait: ident::$method: ident($($arg: ident: $arg_ty: ty),*) -> $ret_ty: ty => using $combine: ident for $($ty: ident)*) => { + impl<$($ty),+> $trait for ($($ty),+) + where $($ty: $trait),+ + { + fn $method($($arg: $arg_ty)*) -> $ret_ty { + $crate::impl_tuple!(@ $method($($arg: $arg_ty),*) => using $combine for $($ty)*) + } + } + } +} + +/// Deposits an event indexed over the supplied fields. +#[macro_export] +macro_rules! deposit_indexed_event { + ($event: ident($($value: expr),+) over $($index: expr),+) => {{ + >::deposit_event_indexed( + &[$(<::Hashing as sp_core::Hasher>::hash(&$index[..])),+], + ::RuntimeEvent::from(Event::$event($($value),+)).into() + ); + }}; + ($event: ident($($value: expr),+)) => { + $crate::deposit_indexed_event!($event($($value),+) over $($value),+) + } +} + +/// Implements two-direction `From`/`Into` and one-direction `Deref`/`DeferMut` traits for the +/// supplied wrapper and type. +#[macro_export] +macro_rules! impl_wrapper { + (no_wrapper_from_type $wrapper: ident$(<$($gen: ident: $($bound: path),+),*>)?($type: ty) $(,$($rest: tt)*)?) => { + $($crate::impl_encode_decode_wrapper_tests! { $wrapper($type), $($rest)* })? + + impl$(<$($gen: $($bound)++),+>)* From<$wrapper$(<$($gen),+>)*> for $type { + fn from(wrapper: $wrapper$(<$($gen),+>)*) -> $type { + wrapper.0 + } + } + + impl$(<$($gen: $($bound)++),+>)* sp_std::ops::Deref for $wrapper$(<$($gen),+>)* { + type Target = $type; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl$(<$($gen: $($bound)++),+>)* sp_std::ops::DerefMut for $wrapper$(<$($gen),+>)* { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + }; + ($wrapper: ident$(<$($gen: ident: $($bound: path),+),*>)?($type: ty) $(,$($rest: tt)*)?) => { + $crate::impl_wrapper! { no_wrapper_from_type $wrapper$(<$($gen: $($bound),+),+>)*($type) $(,$($rest)*)? } + + $crate::impl_wrapper_from_type_conversion! { from $type => $wrapper$(<$($gen: $($bound),+),+>)* } + }; +} + +/// Implements `From` for the wrapper. +#[macro_export] +macro_rules! impl_wrapper_from_type_conversion { + (from $type: ty => $wrapper: ident$(<$($gen: ident: $($bound: path),+),*>)?) => { + impl$(<$($gen: $($bound)++),+>)* From<$type> for $wrapper$(<$($gen),+>)* { + fn from(value: $type) -> $wrapper$(<$($gen),+>)* { + $wrapper(value.into()) + } + } + } +} + +/// Implements type's type info for the wrapper. +#[macro_export] +macro_rules! impl_wrapper_type_info { + ($wrapper: ident($type: ty)) => { + impl scale_info::TypeInfo for $wrapper { + type Identity = Self; + + fn type_info() -> scale_info::Type { + scale_info::Type::builder() + .path(scale_info::Path::new( + core::stringify!($wrapper), + core::stringify!($wrapper), + )) + .composite(scale_info::build::Fields::unnamed().field(|f| f.ty::<$type>())) + } + } + }; +} + +/// Defines `StateChange` using supplied actions. +#[macro_export] +macro_rules! def_state_change { + ($(#[$meta:meta])* $name: ident: $($mod: ident::$type: ident),+) => { + $(#[$meta])* + #[ + derive( + scale_info_derive::TypeInfo, + codec::Encode, + codec::Decode, + frame_support::DebugNoBound, + frame_support::CloneNoBound, + frame_support::PartialEqNoBound + ) + ] + #[scale_info(skip_type_params(T))] + #[scale_info(omit_prefix)] + pub enum $name<'a, T: $crate::common::TypesAndLimits> { + $($type(sp_std::borrow::Cow<'a, $crate::modules::$mod::$type>)),+ + } + } +} + +/// Implements `Encode`/`Decode` wrapper tests for the supplied wrapper and type. +#[macro_export] +macro_rules! impl_encode_decode_wrapper_tests { + ($wrapper: ident($type: ty)) => {}; + ($wrapper: ident($type: ty), with tests as $mod: ident) => { + $crate::impl_encode_decode_wrapper_tests!( + $wrapper($type), for rand use rand::random(), with tests as $mod + ); + }; + ($wrapper: ident($type: ty), for rand use $rand: expr, with tests as $mod: ident) => { + #[cfg(test)] + pub mod $mod { + use super::*; + use codec::{Decode, Encode}; + + #[test] + fn encode_decode() { + let type_value: $type = $rand; + let wrapper_value = $wrapper(type_value.clone()); + + let encoded_wrapper = Encode::encode(&wrapper_value); + let encoded_type = Encode::encode(&type_value); + + assert_eq!(encoded_type, encoded_wrapper); + + let decoded_wrapper: $wrapper = Decode::decode(&mut &encoded_wrapper[..]).unwrap(); + assert_eq!(decoded_wrapper, wrapper_value); + let decoded_wrapper: $wrapper = Decode::decode(&mut &encoded_type[..]).unwrap(); + assert_eq!(decoded_wrapper, wrapper_value); + + let decoded_type: $type = Decode::decode(&mut &encoded_type[..]).unwrap(); + assert_eq!(decoded_type, type_value); + let decoded_type: $type = Decode::decode(&mut &encoded_wrapper[..]).unwrap(); + assert_eq!(decoded_type, type_value); + } + + #[test] + fn deref() { + let type_value: $type = $rand; + let wrapper_value = $wrapper(type_value.clone()); + + assert_eq!(*wrapper_value, type_value); + } + + #[test] + fn deref_mut() { + let type_value: $type = $rand; + let mut wrapper_value = $wrapper($rand); + + *wrapper_value = type_value.clone(); + assert_eq!(wrapper_value.0, type_value); + } + + #[test] + fn from_into() { + let type_value: $type = $rand; + let wrapper_value = $wrapper(type_value.clone()); + + assert_eq!(<$wrapper>::from(type_value.clone()), wrapper_value); + assert_eq!(<$type>::from(wrapper_value), type_value); + } + } + }; +} + +/// Creates pair of given type using supplied seed. +#[cfg(feature = "runtime-benchmarks")] +#[macro_export] +macro_rules! def_test_pair { + (sr25519, $seed: expr) => {{ + use sp_core::Pair; + + let pair = sp_core::sr25519::Pair::from_seed($seed); + struct TestSr25519Pair { + pair: sp_core::sr25519::Pair, + } + + impl TestSr25519Pair { + fn sign(&self, msg: &[u8]) -> sp_core::sr25519::Signature { + use rand_chacha::rand_core::SeedableRng; + use schnorrkel::{context::attach_rng, *}; + + let mut transcript = merlin::Transcript::new(b"SigningContext"); + transcript.append_message(b"", b"substrate"); + transcript.append_message(b"sign-bytes", msg); + let context = attach_rng(transcript, rand_chacha::ChaChaRng::from_seed([10u8; 32])); + + let sk = SecretKey::from_bytes(&self.pair.to_raw_vec()[..]).unwrap(); + + sk.sign(context, &PublicKey::from_bytes(&self.pair.public()[..]).unwrap()) + .into() + } + + fn public(&self) -> sp_core::sr25519::Public { + self.pair.public() + } + } + + TestSr25519Pair { pair } + }}; + (ed25519, $seed: expr) => {{ + use sp_core::Pair; + + sp_core::ed25519::Pair::from_seed($seed) + }}; + (secp256k1, $seed: expr) => { + $crate::common::get_secp256k1_keypair_struct($seed) + }; +} + +/// Repeats the benchmark for every pair. +#[cfg(feature = "runtime-benchmarks")] +#[macro_export] +macro_rules! bench_with_all_pairs { + ( + with_pairs: + $( + $bench_name_sr25519: ident for sr25519, + $bench_name_ed25519: ident for ed25519, + $bench_name_secp256k1: ident for secp256k1 + { + $({ $($init: tt)* })? + let $pair: ident as Pair; + $($body: tt)+ + }: $call_tt: tt($($call_e: expr),+) + verify { $($verification: tt)* } + )+ + $(; + standard: + $($other: tt)* + )? + ) => { + benchmarks! { + where_clause { where T: core::fmt::Debug } + + $( + $bench_name_sr25519 { + $($($init)*)* + #[allow(unused_imports)] + use sp_core::Pair; + let $pair = $crate::def_test_pair!(sr25519, &[4; 32]); + $($body)+ + }: $call_tt($($call_e),+) verify { $($verification)* } + + $bench_name_ed25519 { + $($($init)*)* + #[allow(unused_imports)] + use sp_core::Pair; + let $pair = $crate::def_test_pair!(ed25519, &[3; 32]); + $($body)+ + }: $call_tt($($call_e),+) verify { $($verification)* } + + $bench_name_secp256k1 { + $($($init)*)* + #[allow(unused_imports)] + use sp_core::Pair; + let $pair = $crate::def_test_pair!(secp256k1, &[2; 32]); + $($body)+ + }: $call_tt($($call_e),+) verify { $($verification)* } + )+ + + $($($other)*)? + } + }; +} diff --git a/pallets/did/src/util/mod.rs b/pallets/did/src/util/mod.rs new file mode 100644 index 0000000..91420eb --- /dev/null +++ b/pallets/did/src/util/mod.rs @@ -0,0 +1,23 @@ +pub mod action; +#[cfg(feature = "serde")] +pub mod btree; +pub mod bytes; +pub mod div_ceil; +#[cfg(feature = "serde")] +pub mod hex; +pub mod inc_id; +pub mod macros; +pub mod with_nonce; +pub mod wrapped_action_with_nonce; + +pub use action::*; +#[cfg(feature = "serde")] +pub use btree::*; +pub use bytes::*; +pub use div_ceil::*; +#[cfg(feature = "serde")] +pub use hex::*; +pub use inc_id::*; +pub use macros::*; +pub use with_nonce::*; +pub use wrapped_action_with_nonce::*; diff --git a/pallets/did/src/util/with_nonce.rs b/pallets/did/src/util/with_nonce.rs new file mode 100644 index 0000000..b8b55c7 --- /dev/null +++ b/pallets/did/src/util/with_nonce.rs @@ -0,0 +1,166 @@ +use codec::{Decode, Encode, MaxEncodedLen}; +use sp_runtime::{ + traits::{Block as BlockT, CheckedAdd, Header as HeaderT}, + DispatchError, +}; +use sp_std::{convert::TryInto, fmt::Debug}; +use frame_system::pallet_prelude::BlockNumberFor; +use crate::common::Types; + +/// Wrapper for any kind of entity with a nonce. +/// Nonces are mostly used for replay protection. +/// Initial nonce will be equal to the current block number provided by the system. +#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr( + feature = "serde", + serde(bound( + serialize = "T: Sized, D: serde::Serialize", + deserialize = "T: Sized, D: serde::Deserialize<'de>" + )) +)] +#[scale_info(skip_type_params(T))] +#[scale_info(omit_prefix)] +#[codec(encode_bound(D: Encode))] +pub struct WithNonce { + pub nonce: T::BlockNumber, + #[cfg(test)] + pub data: D, + #[cfg(not(test))] + data: D, +} + +impl core::fmt::Debug for WithNonce { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("WithNonce") + .field("nonce", &self.nonce) + .field("data", &self.data) + .finish() + } +} + +impl MaxEncodedLen for WithNonce { + fn max_encoded_len() -> usize { + T::BlockNumber::max_encoded_len().saturating_add(D::max_encoded_len()) + } +} + +/// A nonce handling-related error. +#[derive(Clone, Copy, Debug)] +pub enum NonceError { + /// Provided nonce is incorrect, i.e. doesn't equal to the current plus 1. + IncorrectNonce, +} + +impl From for DispatchError { + fn from(NonceError::IncorrectNonce: NonceError) -> Self { + DispatchError::Other("Incorrect nonce") + } +} + +impl WithNonce { + /// Adds a nonce to the given `data`. + /// Nonce will be equal to the current block number provided by the system. + pub fn new(data: D) -> Self + where + T: frame_system::Config, + T::BlockNumber: + From>, + { + let bn = >::block_number(); + Self::new_with_nonce(data, T::BlockNumber::from(bn)) + } + + /// Adds supplied nonce to the given `data`. + pub fn new_with_nonce(data: D, nonce: T::BlockNumber) -> Self { + Self { nonce, data } + } + + /// Returns read-only reference to the underlying data. + pub fn data(&self) -> &D { + &self.data + } + + /// Takes underlying data. If you would like to update an entity, use `try_update` instead. + pub fn into_data(self) -> D { + self.data + } + + /// Returns next nonce for the given entity. + pub fn next_nonce(&self) -> Option { + self.nonce.checked_add(&1u8.into()) + } + + /// Returns `true` if given nonce is the next nonce for the given entity, i.e. is equal to + /// current nonce plus 1. + pub fn is_next_nonce(&self, nonce: T::BlockNumber) -> bool { + Some(nonce) == self.next_nonce() + } + + /// Returns mutable reference to the underlying data if provided nonce is equal to current nonce + /// plus 1, otherwise returns an error. + pub fn try_update(&mut self, nonce: T::BlockNumber) -> Result<&mut D, NonceError> { + if self.is_next_nonce(nonce) { + self.nonce = nonce; + + Ok(&mut self.data) + } else { + Err(NonceError::IncorrectNonce) + } + } + + /// If supplied value is `Some(_)`, attempts to increase current nonce - succeeds if provided + /// nonce is equal to current nonce plus 1, otherwise returns an error. If value is `None`, + /// `None` will be returned. + pub fn try_update_opt_with( + this_opt: &mut Option, + nonce: T::BlockNumber, + f: F, + ) -> Option> + where + F: FnOnce(&mut Option) -> Result, + E: From + From, + S: TryInto, + Self: Into, + { + let this = + match this_opt.take()?.try_into().map_err(E::from).and_then(|mut this| { + this.try_update(nonce).map(drop).map(|()| this).map_err(E::from) + }) { + err @ Err(_) => return Some(err.map(|_| unreachable!())), + Ok(this) => this, + }; + + let Self { data, nonce } = this; + let mut data_opt = Some(data); + let res = (f)(&mut data_opt).map_err(Into::into); + *this_opt = data_opt.map(|data| Self { data, nonce }.into()); + + Some(res) + } + + /// If supplied value is `Some(_)`, will update given entity without increasing nonce. + pub fn try_update_opt_without_increasing_nonce_with( + this_opt: &mut Option, + f: F, + ) -> Option> + where + F: FnOnce(&mut Option) -> Result, + E: From + From, + S: TryInto, + Self: Into, + { + let this = match this_opt.take()?.try_into().map_err(E::from) { + err @ Err(_) => return Some(err.map(|_| unreachable!())), + Ok(this) => this, + }; + + let Self { data, nonce } = this; + let mut data_opt = Some(data); + let res = (f)(&mut data_opt).map_err(Into::into); + *this_opt = data_opt.map(|data| Self { data, nonce }.into()); + + Some(res) + } +} diff --git a/pallets/did/src/util/wrapped_action_with_nonce.rs b/pallets/did/src/util/wrapped_action_with_nonce.rs new file mode 100644 index 0000000..e4e215d --- /dev/null +++ b/pallets/did/src/util/wrapped_action_with_nonce.rs @@ -0,0 +1,38 @@ +use crate::common::Types; + +use super::{Action, ActionWithNonce}; +use codec::{Decode, Encode}; + +/// Wraps any value in an action with the supplied nonce and given target. +#[derive(Clone, Debug, PartialEq, Eq, Encode, Decode, scale_info_derive::TypeInfo)] +#[scale_info(omit_prefix)] +pub struct WrappedActionWithNonce { + pub nonce: T::BlockNumber, + pub target: Ta, + pub action: A, +} + +impl WrappedActionWithNonce { + /// Wraps any value in an action with the supplied nonce and given target. + pub fn new(nonce: T::BlockNumber, target: Ta, action: A) -> Self { + Self { nonce, target, action } + } +} + +impl Action for WrappedActionWithNonce { + type Target = Ta; + + fn target(&self) -> Self::Target { + self.target.clone() + } + + fn len(&self) -> u32 { + self.action.len() + } +} + +impl ActionWithNonce for WrappedActionWithNonce { + fn nonce(&self) -> T::BlockNumber { + self.nonce + } +} diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index c01857d..5a0b20a 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,104 +1,100 @@ [package] -authors = ["blockchain labs"] -edition = "2021" -homepage = "https://infrablockchain.net/en" -license = "GPL-3.0-only" -name = "infra-did-parachain-runtime" -repository = "https://github.com/InfraBlockchain/infra-newnal-parachain" -version = "0.1.1" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +name = "infra-did-yosemite-runtime" +publish = false +repository.workspace = true +version = "1.0.0" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ - "derive", -] } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } -smallvec = "1.10.0" +codec = { workspace = true } +log = { workspace = true } +scale-info = { workspace = true } +smallvec = { workspace = true, default-features = true } -did-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false, features = [ - "serde", -] } +# Core +pallet-did = { workspace = true, features = ["serde"] } # System -frame-benchmarking = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false, optional = true } -frame-executive = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -frame-support = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -frame-system = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -frame-system-benchmarking = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false, optional = true } -frame-system-rpc-runtime-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -frame-try-runtime = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false, optional = true } +frame-benchmarking = { workspace = true, optional = true } +frame-executive = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +frame-system-benchmarking = { workspace = true, optional = true } +frame-system-rpc-runtime-api = { workspace = true } +frame-try-runtime = { workspace = true, optional = true } # Frames -pallet-assets = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-authorship = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-balances = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-message-queue = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-preimage = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-scheduler = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-session = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-sudo = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-system-token-conversion = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-system-token-tx-payment = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-timestamp = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-transaction-payment = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } +pallet-assets = { workspace = true } +pallet-aura = { workspace = true } +pallet-authorship = { workspace = true } +pallet-balances = { workspace = true } +pallet-message-queue = { workspace = true } +pallet-preimage = { workspace = true } +pallet-scheduler = { workspace = true } +pallet-session = { workspace = true } +pallet-sudo = { workspace = true } +pallet-system-token-conversion = { workspace = true } +pallet-system-token-tx-payment = { workspace = true } +pallet-timestamp = { workspace = true } +pallet-transaction-payment = { workspace = true } +pallet-transaction-payment-rpc-runtime-api = { workspace = true } # Primitives -sp-api = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-block-builder = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-consensus-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-genesis-builder = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-inherents = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-offchain = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-runtime = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-session = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-std = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-storage = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-transaction-pool = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-version = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -sp-weights = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } +sp-api = { workspace = true } +sp-block-builder = { workspace = true } +sp-consensus-aura = { workspace = true } +sp-core = { workspace = true } +sp-genesis-builder = { workspace = true } +sp-inherents = { workspace = true } +sp-offchain = { workspace = true } +sp-runtime = { workspace = true } +sp-session = { workspace = true } +sp-std = { workspace = true } +sp-storage = { workspace = true } +sp-transaction-pool = { workspace = true } +sp-version = { workspace = true } +sp-weights = { workspace = true } -# Infra Relay -infra-relay-runtime-constants = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -polkadot-core-primitives = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -polkadot-parachain-primitives = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -polkadot-runtime-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -polkadot-runtime-parachains = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } +# Yosemite +polkadot-core-primitives = { workspace = true } +polkadot-parachain-primitives = { workspace = true } +polkadot-runtime-common = { workspace = true } +polkadot-runtime-parachains = { workspace = true } +yosemite-runtime-constants = { workspace = true } # Xcm -pallet-xcm = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -xcm = { package = "staging-xcm", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } +pallet-xcm = { workspace = true } +xcm = { package = "staging-xcm", workspace = true } +xcm-builder = { workspace = true } +xcm-executor = { workspace = true } # Cumulus -cumulus-pallet-aura-ext = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-pallet-infra-parachain-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false, features = [ - "parameterized-consensus-hook", -] } -cumulus-pallet-session-benchmarking = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-pallet-xcm = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-primitives-aura = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-primitives-core = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-primitives-timestamp = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -cumulus-primitives-utility = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -infra-asset-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -pallet-collator-selection = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -parachain-info = { package = "staging-parachain-info", git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } -parachains-common = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false } +cumulus-pallet-aura-ext = { workspace = true } +cumulus-pallet-dmp-queue = { workspace = true } +cumulus-pallet-infra-parachain-core = { workspace = true } +cumulus-pallet-parachain-system = { workspace = true } +cumulus-pallet-session-benchmarking = { workspace = true } +cumulus-pallet-xcm = { workspace = true } +cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-primitives-aura = { workspace = true } +cumulus-primitives-core = { workspace = true } +cumulus-primitives-timestamp = { workspace = true } +cumulus-primitives-utility = { workspace = true } +infra-asset-common = { workspace = true } +pallet-collator-selection = { workspace = true } +parachain-info = { workspace = true } +parachains-common = { workspace = true } -testnet-parachains-constants = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0", default-features = false, features=["infra-relay"] } +testnet-parachains-constants = { workspace = true, features = ["yosemite"] } [dev-dependencies] -hex-literal = "0.3.4" +hex-literal = { workspace = true } [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/InfraBlockchain/infrablockchain-substrate", branch = "feature/release-1.10.0" } +substrate-wasm-builder = { workspace = true, default-features = true } [features] default = ["std"] @@ -125,7 +121,7 @@ std = [ "pallet-scheduler/std", "pallet-preimage/std", "pallet-assets/std", - "frame-benchmarking/std", + "frame-benchmarking?/std", "frame-try-runtime/std", "pallet-system-token-tx-payment/std", "pallet-system-token-conversion/std", @@ -140,10 +136,10 @@ std = [ "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-xcm/std", - "did-core/std", + "pallet-did/std", "parachain-info/std", "polkadot-core-primitives/std", - "infra-relay-runtime-constants/std", + "yosemite-runtime-constants/std", "polkadot-parachain-primitives/std", "polkadot-runtime-common/std", "polkadot-runtime-parachains/std", @@ -168,8 +164,8 @@ std = [ ] runtime-benchmarks = [ - "did-core/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", + "pallet-did/runtime-benchmarks", + "frame-benchmarking?/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", @@ -183,7 +179,6 @@ runtime-benchmarks = [ "cumulus-pallet-xcmp-queue/runtime-benchmarks", ] -fast-runtime = [] try-runtime = [ "cumulus-pallet-aura-ext/try-runtime", "cumulus-pallet-dmp-queue/try-runtime", @@ -204,3 +199,5 @@ try-runtime = [ "pallet-xcm/try-runtime", "parachain-info/try-runtime", ] + +fast-runtime = [] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9c1de7a..b3ffad1 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -35,7 +35,7 @@ use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, derive_impl, dispatch::DispatchClass, - genesis_builder_helper::{build_config, create_default_config}, + genesis_builder_helper::{build_state, get_preset}, parameter_types, traits::{ tokens::fungibles::{Balanced, Credit, UnionOf}, @@ -63,7 +63,7 @@ use infra_asset_common::{ pub use sp_runtime::BuildStorage; // TODO: These constants are para-agnostic, but we need to configure for DID-chain specific constants -use testnet_parachains_constants::infra_relay::{ +use testnet_parachains_constants::yosemite::{ consensus::*, currency::*, fee::WeightToFee, time::*, }; @@ -71,7 +71,7 @@ use testnet_parachains_constants::infra_relay::{ use polkadot_runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; -pub use did_core::{ +pub use pallet_did::{ accumulator, anchor, attest, blob, common, did, offchain_signatures::{self, BBSPlusPublicKey, OffchainPublicKey, PSPublicKey}, revoke, status_list_credential, trusted_entity, @@ -147,14 +147,14 @@ mod wasm_handlers { #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("InfraBlockchain DID Parachain"), - impl_name: create_runtime_str!("InfraBlockchain DID Parachain"), + spec_name: create_runtime_str!("infra-did-yosemite"), + impl_name: create_runtime_str!("bcl-infra-did-yosemite"), authoring_version: 1, spec_version: 10_000, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 13, - state_version: 10, + transaction_version: 1, + state_version: 1, }; /// The version information used to identify this runtime when compiled natively. @@ -424,7 +424,7 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = - pallet_transaction_payment::CurrencyAdapter>; + pallet_transaction_payment::FungibleAdapter>; type WeightToFee = WeightToFee; type LengthToFee = ConstantMultiplier; type FeeMultiplierUpdate = (); @@ -507,9 +507,8 @@ impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} -pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery< - cumulus_primitives_core::ParaId ->; +pub type PriceForSiblingParachainDelivery = + polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; impl cumulus_pallet_xcmp_queue::Config for Runtime { type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; @@ -517,7 +516,11 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = InfraXcm; type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = sp_core::ConstU32<1_000>; + type MaxInboundSuspended = ConstU32<1_000>; + type MaxActiveOutboundChannels = ConstU32<128>; + // Most on-chain HRMP channels are configured to use 102400 bytes of max message size, so we + // need to set the page size larger than that until we reduce the channel size on-chain. + type MaxPageSize = ConstU32<{ 103 * 1024 }>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; @@ -1108,13 +1111,16 @@ impl_runtime_apis! { } impl sp_genesis_builder::GenesisBuilder for Runtime { + fn build_state(config: Vec) -> sp_genesis_builder::Result { + build_state::(config) + } - fn create_default_config() -> Vec { - create_default_config::() + fn get_preset(id: &Option) -> Option> { + get_preset::(id, |_| None) } - fn build_config(config: Vec) -> sp_genesis_builder::Result { - build_config::(config) + fn preset_names() -> Vec { + vec![] } } } diff --git a/runtime/src/weights/pallet_balances.rs b/runtime/src/weights/pallet_balances.rs index 299a801..35d7e19 100644 --- a/runtime/src/weights/pallet_balances.rs +++ b/runtime/src/weights/pallet_balances.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-01-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-05-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-8idpd4bs-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-unxyhko3-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024 // Executed Command: @@ -54,8 +54,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 42_706_000 picoseconds. - Weight::from_parts(43_378_000, 0) + // Minimum execution time: 43_472_000 picoseconds. + Weight::from_parts(44_389_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -66,8 +66,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 33_090_000 picoseconds. - Weight::from_parts(33_703_000, 0) + // Minimum execution time: 34_211_000 picoseconds. + Weight::from_parts(35_075_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -78,8 +78,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 12_678_000 picoseconds. - Weight::from_parts(13_068_000, 0) + // Minimum execution time: 12_751_000 picoseconds. + Weight::from_parts(13_221_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -90,8 +90,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 17_336_000 picoseconds. - Weight::from_parts(17_824_000, 0) + // Minimum execution time: 17_530_000 picoseconds. + Weight::from_parts(17_979_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -102,8 +102,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 44_817_000 picoseconds. - Weight::from_parts(45_453_000, 0) + // Minimum execution time: 45_913_000 picoseconds. + Weight::from_parts(47_447_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -114,8 +114,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 41_468_000 picoseconds. - Weight::from_parts(42_093_000, 0) + // Minimum execution time: 42_435_000 picoseconds. + Weight::from_parts(44_712_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -126,8 +126,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 15_344_000 picoseconds. - Weight::from_parts(15_878_000, 0) + // Minimum execution time: 15_407_000 picoseconds. + Weight::from_parts(16_104_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -139,11 +139,11 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0 + u * (136 ±0)` // Estimated: `990 + u * (2603 ±0)` - // Minimum execution time: 15_067_000 picoseconds. - Weight::from_parts(15_281_000, 0) + // Minimum execution time: 15_494_000 picoseconds. + Weight::from_parts(15_793_000, 0) .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 11_009 - .saturating_add(Weight::from_parts(13_050_024, 0).saturating_mul(u.into())) + // Standard Error: 11_778 + .saturating_add(Weight::from_parts(13_198_951, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) @@ -154,9 +154,25 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1501` - // Minimum execution time: 5_139_000 picoseconds. - Weight::from_parts(5_511_000, 0) + // Minimum execution time: 5_368_000 picoseconds. + Weight::from_parts(5_674_000, 0) .saturating_add(Weight::from_parts(0, 1501)) .saturating_add(T::DbWeight::get().reads(1)) } + fn burn_allow_death() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 27_491_000 picoseconds. + Weight::from_parts(28_444_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + fn burn_keep_alive() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 18_290_000 picoseconds. + Weight::from_parts(19_227_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } } diff --git a/runtime/src/weights/pallet_xcm.rs b/runtime/src/weights/pallet_xcm.rs index e0e231d..51b6543 100644 --- a/runtime/src/weights/pallet_xcm.rs +++ b/runtime/src/weights/pallet_xcm.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-03-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-h2rr8wx7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024 // Executed Command: @@ -64,30 +64,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 21_224_000 picoseconds. - Weight::from_parts(21_821_000, 0) - .saturating_add(Weight::from_parts(0, 3610)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`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::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn send_blob() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 21_474_000 picoseconds. - Weight::from_parts(22_072_000, 0) + // Minimum execution time: 22_136_000 picoseconds. + Weight::from_parts(22_518_000, 0) .saturating_add(Weight::from_parts(0, 3610)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) @@ -112,8 +90,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 90_677_000 picoseconds. - Weight::from_parts(93_658_000, 0) + // Minimum execution time: 92_277_000 picoseconds. + Weight::from_parts(94_843_000, 0) .saturating_add(Weight::from_parts(0, 3610)) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(3)) @@ -140,8 +118,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `400` // Estimated: `6196` - // Minimum execution time: 116_767_000 picoseconds. - Weight::from_parts(118_843_000, 0) + // Minimum execution time: 120_110_000 picoseconds. + Weight::from_parts(122_968_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(5)) @@ -170,8 +148,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `496` // Estimated: `6208` - // Minimum execution time: 137_983_000 picoseconds. - Weight::from_parts(141_396_000, 0) + // Minimum execution time: 143_116_000 picoseconds. + Weight::from_parts(147_355_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(7)) @@ -186,24 +164,14 @@ impl pallet_xcm::WeightInfo for WeightInfo { Weight::from_parts(18_446_744_073_709_551_000, 0) .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `Benchmark::Override` (r:0 w:0) - /// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn execute_blob() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 18_446_744_073_709_551_000 picoseconds. - Weight::from_parts(18_446_744_073_709_551_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - } /// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_xcm_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_232_000 picoseconds. - Weight::from_parts(6_507_000, 0) + // Minimum execution time: 6_517_000 picoseconds. + Weight::from_parts(6_756_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -213,8 +181,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_884_000 picoseconds. - Weight::from_parts(2_016_000, 0) + // Minimum execution time: 1_894_000 picoseconds. + Weight::from_parts(2_024_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -240,8 +208,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 26_637_000 picoseconds. - Weight::from_parts(27_616_000, 0) + // Minimum execution time: 27_314_000 picoseconds. + Weight::from_parts(28_787_000, 0) .saturating_add(Weight::from_parts(0, 3610)) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(5)) @@ -266,8 +234,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `363` // Estimated: `3828` - // Minimum execution time: 28_668_000 picoseconds. - Weight::from_parts(29_413_000, 0) + // Minimum execution time: 29_840_000 picoseconds. + Weight::from_parts(30_589_000, 0) .saturating_add(Weight::from_parts(0, 3828)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) @@ -278,8 +246,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_990_000 picoseconds. - Weight::from_parts(2_114_000, 0) + // Minimum execution time: 1_893_000 picoseconds. + Weight::from_parts(2_017_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -289,8 +257,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `159` // Estimated: `13524` - // Minimum execution time: 18_856_000 picoseconds. - Weight::from_parts(19_430_000, 0) + // Minimum execution time: 19_211_000 picoseconds. + Weight::from_parts(19_552_000, 0) .saturating_add(Weight::from_parts(0, 13524)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) @@ -301,8 +269,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `163` // Estimated: `13528` - // Minimum execution time: 19_068_000 picoseconds. - Weight::from_parts(19_434_000, 0) + // Minimum execution time: 19_177_000 picoseconds. + Weight::from_parts(19_704_000, 0) .saturating_add(Weight::from_parts(0, 13528)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) @@ -313,8 +281,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `173` // Estimated: `16013` - // Minimum execution time: 21_055_000 picoseconds. - Weight::from_parts(21_379_000, 0) + // Minimum execution time: 20_449_000 picoseconds. + Weight::from_parts(21_075_000, 0) .saturating_add(Weight::from_parts(0, 16013)) .saturating_add(T::DbWeight::get().reads(6)) } @@ -336,8 +304,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `212` // Estimated: `6152` - // Minimum execution time: 25_736_000 picoseconds. - Weight::from_parts(26_423_000, 0) + // Minimum execution time: 26_578_000 picoseconds. + Weight::from_parts(27_545_000, 0) .saturating_add(Weight::from_parts(0, 6152)) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(3)) @@ -348,8 +316,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `206` // Estimated: `11096` - // Minimum execution time: 11_853_000 picoseconds. - Weight::from_parts(12_215_000, 0) + // Minimum execution time: 11_646_000 picoseconds. + Weight::from_parts(11_944_000, 0) .saturating_add(Weight::from_parts(0, 11096)) .saturating_add(T::DbWeight::get().reads(4)) } @@ -359,8 +327,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `170` // Estimated: `13535` - // Minimum execution time: 19_418_000 picoseconds. - Weight::from_parts(19_794_000, 0) + // Minimum execution time: 19_301_000 picoseconds. + Weight::from_parts(19_664_000, 0) .saturating_add(Weight::from_parts(0, 13535)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) @@ -383,8 +351,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `212` // Estimated: `13577` - // Minimum execution time: 34_719_000 picoseconds. - Weight::from_parts(35_260_000, 0) + // Minimum execution time: 35_715_000 picoseconds. + Weight::from_parts(36_915_000, 0) .saturating_add(Weight::from_parts(0, 13577)) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(4)) @@ -397,8 +365,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `1588` - // Minimum execution time: 4_937_000 picoseconds. - Weight::from_parts(5_203_000, 0) + // Minimum execution time: 4_871_000 picoseconds. + Weight::from_parts(5_066_000, 0) .saturating_add(Weight::from_parts(0, 1588)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -409,8 +377,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `7740` // Estimated: `11205` - // Minimum execution time: 26_064_000 picoseconds. - Weight::from_parts(26_497_000, 0) + // Minimum execution time: 25_150_000 picoseconds. + Weight::from_parts(26_119_000, 0) .saturating_add(Weight::from_parts(0, 11205)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -421,8 +389,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `160` // Estimated: `3625` - // Minimum execution time: 37_132_000 picoseconds. - Weight::from_parts(37_868_000, 0) + // Minimum execution time: 38_248_000 picoseconds. + Weight::from_parts(39_122_000, 0) .saturating_add(Weight::from_parts(0, 3625)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) diff --git a/runtime/src/xcm_config.rs b/runtime/src/xcm_config.rs index 129888c..d73df78 100644 --- a/runtime/src/xcm_config.rs +++ b/runtime/src/xcm_config.rs @@ -99,6 +99,7 @@ pub type ForeignAssetsConvertedConcreteId = infra_asset_common::ForeignAssetsCon // be accepted here StartsWithExplicitGlobalConsensus, ), + Location, Balance, >; @@ -206,7 +207,6 @@ impl Contains for SafeCallFilter { ForeignAssetsCall::transfer { .. } | ForeignAssetsCall::transfer_keep_alive { .. } | ForeignAssetsCall::force_transfer { .. } | - ForeignAssetsCall::force_transfer2 { .. } | ForeignAssetsCall::freeze { .. } | ForeignAssetsCall::thaw { .. } | ForeignAssetsCall::freeze_asset { .. } | @@ -316,6 +316,7 @@ impl xcm_executor::Config for XcmConfig { type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); type HrmpChannelClosingHandler = (); + type XcmRecorder = InfraXcm; } /// Converts a local signed origin into an XCM multilocation.