diff --git a/Cargo.lock b/Cargo.lock index 40d3934d02..7bfa4a48d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -431,6 +431,17 @@ dependencies = [ "event-listener", ] +[[package]] +name = "async-recursion" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.17", +] + [[package]] name = "async-trait" version = "0.1.68" @@ -439,7 +450,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -526,6 +537,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base58" version = "0.2.0" @@ -540,9 +557,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f1e31e207a6b8fb791a38ea3105e6cb541f55e4d029902d3039a4ad07cc4105" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64ct" @@ -562,7 +579,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "hash-db", "log", @@ -1024,7 +1041,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -1346,6 +1363,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "crypto-bigint" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1417,7 +1446,7 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "clap", "parity-scale-codec", @@ -1432,7 +1461,7 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", @@ -1455,7 +1484,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "async-trait", "cumulus-client-consensus-common", @@ -1484,7 +1513,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "async-trait", "cumulus-client-pov-recovery", @@ -1508,7 +1537,7 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -1531,7 +1560,7 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1555,7 +1584,7 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-client-cli", "cumulus-client-collator", @@ -1590,7 +1619,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "frame-support", "frame-system", @@ -1606,7 +1635,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-dmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1623,7 +1652,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "bytes", "cumulus-pallet-parachain-system-proc-macro", @@ -1652,18 +1681,18 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "cumulus-pallet-session-benchmarking" version = "3.0.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "frame-benchmarking", "frame-support", @@ -1677,7 +1706,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcm" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1693,7 +1722,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-primitives-core", "frame-benchmarking", @@ -1714,12 +1743,13 @@ dependencies = [ [[package]] name = "cumulus-primitives-core" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", "polkadot-parachain", "polkadot-primitives", + "scale-info", "sp-api", "sp-runtime", "sp-std", @@ -1730,7 +1760,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1753,7 +1783,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-primitives-core", "futures", @@ -1766,7 +1796,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-utility" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1784,7 +1814,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-inprocess-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1809,7 +1839,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1827,7 +1857,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-minimal-node" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "array-bytes 6.1.0", "async-trait", @@ -1836,13 +1866,16 @@ dependencies = [ "cumulus-relay-chain-rpc-interface", "futures", "lru 0.9.0", + "polkadot-availability-recovery", + "polkadot-collator-protocol", "polkadot-core-primitives", "polkadot-network-bridge", + "polkadot-node-collation-generation", + "polkadot-node-core-runtime-api", "polkadot-node-network-protocol", "polkadot-node-subsystem-util", "polkadot-overseer", "polkadot-primitives", - "polkadot-service", "sc-authority-discovery", "sc-client-api", "sc-network", @@ -1862,7 +1895,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-rpc-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1892,7 +1925,7 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -1944,9 +1977,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" +checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" dependencies = [ "cc", "cxxbridge-flags", @@ -1956,9 +1989,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" +checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" dependencies = [ "cc", "codespan-reporting", @@ -1966,24 +1999,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] name = "cxxbridge-flags" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" +checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" +checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -2081,6 +2114,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "der" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "der-parser" version = "7.0.0" @@ -2227,6 +2270,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -2280,7 +2324,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -2334,10 +2378,24 @@ version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", + "signature 1.6.4", +] + +[[package]] +name = "ecdsa" +version = "0.16.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +dependencies = [ + "der 0.7.6", + "digest 0.10.7", + "elliptic-curve 0.13.5", + "rfc6979 0.4.0", + "signature 2.1.0", + "spki 0.7.2", ] [[package]] @@ -2346,7 +2404,7 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", ] [[package]] @@ -2389,18 +2447,37 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ - "base16ct", - "crypto-bigint", - "der", + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", "digest 0.10.7", - "ff", + "ff 0.12.1", "generic-array 0.14.7", - "group", + "group 0.12.1", "hkdf", "pem-rfc7468", - "pkcs8", + "pkcs8 0.9.0", + "rand_core 0.6.4", + "sec1 0.3.0", + "subtle", + "zeroize", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +dependencies = [ + "base16ct 0.2.0", + "crypto-bigint 0.5.2", + "digest 0.10.7", + "ff 0.13.0", + "generic-array 0.14.7", + "group 0.13.0", + "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1", + "sec1 0.7.2", "subtle", "zeroize", ] @@ -2434,7 +2511,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -2445,7 +2522,7 @@ checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -2538,7 +2615,6 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 1.0.109", ] [[package]] @@ -2554,6 +2630,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "expander" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", + "syn 2.0.17", +] + [[package]] name = "fake-simd" version = "0.1.2" @@ -2619,6 +2708,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "fiat-crypto" version = "0.1.20" @@ -2710,7 +2809,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", ] @@ -2733,7 +2832,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-support-procedural", @@ -2758,7 +2857,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "Inflector", "array-bytes 4.2.0", @@ -2805,18 +2904,18 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2833,7 +2932,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -2862,9 +2961,11 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ + "async-recursion", "futures", + "jsonrpsee", "log", "parity-scale-codec", "serde", @@ -2878,7 +2979,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "bitflags", "environmental", @@ -2911,44 +3012,45 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "Inflector", "cfg-expr", "derive-syn-parse", "frame-support-procedural-tools", "itertools", + "proc-macro-warning", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "log", @@ -2966,7 +3068,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -2981,7 +3083,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "sp-api", @@ -2990,7 +3092,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "parity-scale-codec", @@ -3103,7 +3205,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -3179,6 +3281,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -3275,7 +3378,18 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "ff", + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", "rand_core 0.6.4", "subtle", ] @@ -3388,6 +3502,12 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hkdf" version = "0.12.3" @@ -3531,6 +3651,7 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls", + "webpki-roots", ] [[package]] @@ -3706,9 +3827,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.1", "libc", @@ -3791,6 +3912,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" dependencies = [ "jsonrpsee-core", + "jsonrpsee-http-client", "jsonrpsee-proc-macros", "jsonrpsee-server", "jsonrpsee-types", @@ -3847,6 +3969,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "jsonrpsee-http-client" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc345b0a43c6bc49b947ebeb936e886a419ee3d894421790c969cc56040542ad" +dependencies = [ + "async-trait", + "hyper", + "hyper-rustls", + "jsonrpsee-core", + "jsonrpsee-types", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "jsonrpsee-proc-macros" version = "0.16.2" @@ -3910,13 +4051,14 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa", - "elliptic-curve", + "ecdsa 0.16.7", + "elliptic-curve 0.13.5", + "once_cell", "sha2 0.10.6", ] @@ -3936,7 +4078,7 @@ dependencies = [ "base58", "frame-support", "hex", - "hex-literal", + "hex-literal 0.3.4", "log", "parity-scale-codec", "scale-info", @@ -3961,7 +4103,7 @@ dependencies = [ "cumulus-relay-chain-minimal-node", "frame-benchmarking", "frame-benchmarking-cli", - "hex-literal", + "hex-literal 0.3.4", "jsonrpsee", "log", "pallet-transaction-payment-rpc", @@ -4057,8 +4199,8 @@ dependencies = [ [[package]] name = "kusama-runtime" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", "frame-benchmarking", @@ -4069,7 +4211,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.4.1", "kusama-runtime-constants", "log", "pallet-authority-discovery", @@ -4155,8 +4297,8 @@ dependencies = [ [[package]] name = "kusama-runtime-constants" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "frame-support", "polkadot-primitives", @@ -4188,9 +4330,9 @@ dependencies = [ [[package]] name = "kvdb-rocksdb" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2182b8219fee6bd83aacaab7344e840179ae079d5216aa4e249b4d704646a844" +checksum = "fe7a749456510c45f795e8b04a6a3e0976d0139213ecbf465843830ad55e2217" dependencies = [ "kvdb", "num_cpus", @@ -4299,7 +4441,7 @@ dependencies = [ "prost-build", "rand 0.8.5", "rw-stream-sink", - "sec1", + "sec1 0.3.0", "sha2 0.10.6", "smallvec", "thiserror", @@ -4695,9 +4837,9 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "0.8.3+7.4.4" +version = "0.10.0+7.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "557b255ff04123fcc176162f56ed0c9cd42d8f357cf55b3fabeb60f7413741b3" +checksum = "0fe4d5874f5ff2bc616e55e8c6086d478fcda13faf9495768a4aa1c22042d30b" dependencies = [ "bindgen", "bzip2-sys", @@ -4896,7 +5038,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-system", "futures", - "hex-literal", + "hex-literal 0.3.4", "jsonrpsee", "mashnet-node-runtime", "pallet-transaction-payment", @@ -4946,7 +5088,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "kilt-runtime-api-did", "kilt-runtime-api-public-credentials", "kilt-support", @@ -5143,7 +5285,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "futures", "log", @@ -5162,7 +5304,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "anyhow", "jsonrpsee", @@ -5635,8 +5777,8 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ - "ecdsa", - "elliptic-curve", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", "sha2 0.10.6", ] @@ -5646,8 +5788,8 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ - "ecdsa", - "elliptic-curve", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", "sha2 0.10.6", ] @@ -5664,7 +5806,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -5680,7 +5822,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -5696,7 +5838,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -5710,7 +5852,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -5723,7 +5865,7 @@ dependencies = [ "scale-info", "sp-application-crypto", "sp-consensus-babe", - "sp-consensus-vrf", + "sp-core", "sp-io", "sp-runtime", "sp-session", @@ -5734,7 +5876,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5754,7 +5896,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -5769,7 +5911,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -5788,7 +5930,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "binary-merkle-tree", @@ -5812,7 +5954,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -5830,7 +5972,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -5849,7 +5991,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -5885,7 +6027,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5902,7 +6044,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -5933,6 +6075,7 @@ dependencies = [ "log", "pallet-balances", "parity-scale-codec", + "runtime-common", "scale-info", "serde", "sha3", @@ -5947,7 +6090,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5970,7 +6113,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5983,7 +6126,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6001,7 +6144,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6019,7 +6162,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6042,7 +6185,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "enumflags2", "frame-benchmarking", @@ -6058,7 +6201,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6078,7 +6221,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6111,7 +6254,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6128,7 +6271,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6145,7 +6288,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6161,7 +6304,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6177,7 +6320,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -6194,7 +6337,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6214,7 +6357,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -6225,7 +6368,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -6242,7 +6385,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6266,7 +6409,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6283,7 +6426,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6298,7 +6441,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6316,7 +6459,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6331,7 +6474,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6350,7 +6493,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6367,7 +6510,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -6388,7 +6531,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6404,7 +6547,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -6418,7 +6561,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6441,18 +6584,18 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "log", "sp-arithmetic", @@ -6461,7 +6604,7 @@ dependencies = [ [[package]] name = "pallet-staking-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "sp-api", @@ -6470,7 +6613,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6487,7 +6630,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -6501,7 +6644,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6519,7 +6662,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6538,7 +6681,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-support", "frame-system", @@ -6554,7 +6697,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -6570,7 +6713,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6582,7 +6725,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6599,7 +6742,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6615,7 +6758,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6635,6 +6778,7 @@ dependencies = [ "frame-support", "frame-system", "kilt-support", + "log", "pallet-balances", "parity-scale-codec", "scale-info", @@ -6648,7 +6792,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-benchmarking", "frame-support", @@ -6662,8 +6806,8 @@ dependencies = [ [[package]] name = "pallet-xcm" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bounded-collections", "frame-benchmarking", @@ -6683,8 +6827,8 @@ dependencies = [ [[package]] name = "pallet-xcm-benchmarks" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "frame-benchmarking", "frame-support", @@ -6703,7 +6847,7 @@ dependencies = [ [[package]] name = "parachain-info" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.41#ae4e75b077c220bdf29b299b36a63b87ccb46b4c" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.42#f603a61ff370fc33740c9373833c3c6ba1486846" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -6929,7 +7073,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "kilt-runtime-api-did", "kilt-runtime-api-public-credentials", "kilt-runtime-api-staking", @@ -7015,7 +7159,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -7056,7 +7200,7 @@ checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -7083,8 +7227,18 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der", - "spki", + "der 0.6.1", + "spki 0.6.0", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.6", + "spki 0.7.2", ] [[package]] @@ -7107,10 +7261,11 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "polkadot-approval-distribution" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", + "polkadot-node-jaeger", "polkadot-node-metrics", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -7122,8 +7277,8 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", "polkadot-node-network-protocol", @@ -7136,8 +7291,8 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "derive_more", "fatality", @@ -7159,8 +7314,8 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "fatality", "futures", @@ -7180,15 +7335,15 @@ dependencies = [ [[package]] name = "polkadot-cli" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "clap", "frame-benchmarking-cli", "futures", "log", "polkadot-client", - "polkadot-node-core-pvf", + "polkadot-node-core-pvf-worker", "polkadot-node-metrics", "polkadot-performance-test", "polkadot-service", @@ -7201,6 +7356,7 @@ dependencies = [ "sp-core", "sp-io", "sp-keyring", + "sp-maybe-compressed-blob", "substrate-build-script-utils", "thiserror", "try-runtime-cli", @@ -7208,8 +7364,8 @@ dependencies = [ [[package]] name = "polkadot-client" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "async-trait", "frame-benchmarking", @@ -7250,8 +7406,8 @@ dependencies = [ [[package]] name = "polkadot-collator-protocol" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "always-assert", "bitvec", @@ -7272,8 +7428,8 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "parity-scale-codec", "scale-info", @@ -7284,8 +7440,8 @@ dependencies = [ [[package]] name = "polkadot-dispute-distribution" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "derive_more", "fatality", @@ -7309,8 +7465,8 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -7323,8 +7479,8 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", "futures-timer", @@ -7343,8 +7499,8 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "always-assert", "async-trait", @@ -7366,8 +7522,8 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", "parity-scale-codec", @@ -7384,8 +7540,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", "derive_more", @@ -7413,8 +7569,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", "futures", @@ -7434,8 +7590,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", "fatality", @@ -7453,8 +7609,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", "polkadot-node-subsystem", @@ -7468,8 +7624,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "async-trait", "futures", @@ -7488,8 +7644,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", "polkadot-node-metrics", @@ -7503,8 +7659,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", "futures-timer", @@ -7520,8 +7676,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "fatality", "futures", @@ -7539,8 +7695,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "async-trait", "futures", @@ -7556,8 +7712,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", "fatality", @@ -7574,12 +7730,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "always-assert", - "assert_matches", - "cpu-time", "futures", "futures-timer", "libc", @@ -7591,28 +7745,20 @@ dependencies = [ "polkadot-parachain", "polkadot-primitives", "rand 0.8.5", - "rayon", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", "slotmap", "sp-core", - "sp-externalities", - "sp-io", "sp-maybe-compressed-blob", "sp-tracing", "sp-wasm-interface", "substrate-build-script-utils", - "tempfile", - "tikv-jemalloc-ctl", "tokio", "tracing-gum", ] [[package]] name = "polkadot-node-core-pvf-checker" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", "polkadot-node-primitives", @@ -7625,10 +7771,39 @@ dependencies = [ "tracing-gum", ] +[[package]] +name = "polkadot-node-core-pvf-worker" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" +dependencies = [ + "assert_matches", + "cpu-time", + "futures", + "libc", + "parity-scale-codec", + "polkadot-node-core-pvf", + "polkadot-parachain", + "polkadot-primitives", + "rayon", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sp-core", + "sp-externalities", + "sp-io", + "sp-maybe-compressed-blob", + "sp-tracing", + "substrate-build-script-utils", + "tempfile", + "tikv-jemalloc-ctl", + "tokio", + "tracing-gum", +] + [[package]] name = "polkadot-node-core-runtime-api" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "futures", "lru 0.9.0", @@ -7642,8 +7817,8 @@ dependencies = [ [[package]] name = "polkadot-node-jaeger" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "lazy_static", "log", @@ -7660,8 +7835,8 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bs58", "futures", @@ -7679,8 +7854,8 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "async-trait", "derive_more", @@ -7701,8 +7876,8 @@ dependencies = [ [[package]] name = "polkadot-node-primitives" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bounded-vec", "futures", @@ -7713,19 +7888,18 @@ dependencies = [ "serde", "sp-application-crypto", "sp-consensus-babe", - "sp-consensus-vrf", "sp-core", "sp-keystore", "sp-maybe-compressed-blob", "sp-runtime", "thiserror", - "zstd", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] name = "polkadot-node-subsystem" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -7734,8 +7908,8 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "async-trait", "derive_more", @@ -7757,8 +7931,8 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "async-trait", "derive_more", @@ -7790,8 +7964,8 @@ dependencies = [ [[package]] name = "polkadot-overseer" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "async-trait", "futures", @@ -7813,8 +7987,8 @@ dependencies = [ [[package]] name = "polkadot-parachain" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bounded-collections", "derive_more", @@ -7830,27 +8004,29 @@ dependencies = [ [[package]] name = "polkadot-performance-test" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "env_logger 0.9.3", "kusama-runtime", "log", "polkadot-erasure-coding", - "polkadot-node-core-pvf", + "polkadot-node-core-pvf-worker", "polkadot-node-primitives", "polkadot-primitives", "quote", + "sc-executor-common", + "sp-maybe-compressed-blob", "thiserror", ] [[package]] name = "polkadot-primitives" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", - "hex-literal", + "hex-literal 0.4.1", "parity-scale-codec", "polkadot-core-primitives", "polkadot-parachain", @@ -7872,8 +8048,8 @@ dependencies = [ [[package]] name = "polkadot-rpc" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "jsonrpsee", "mmr-rpc", @@ -7904,8 +8080,8 @@ dependencies = [ [[package]] name = "polkadot-runtime" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", "frame-benchmarking", @@ -7916,7 +8092,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.4.1", "log", "pallet-authority-discovery", "pallet-authorship", @@ -7926,6 +8102,7 @@ dependencies = [ "pallet-bounties", "pallet-child-bounties", "pallet-collective", + "pallet-conviction-voting", "pallet-democracy", "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", @@ -7944,6 +8121,7 @@ dependencies = [ "pallet-offences-benchmarking", "pallet-preimage", "pallet-proxy", + "pallet-referenda", "pallet-scheduler", "pallet-session", "pallet-session-benchmarking", @@ -7957,6 +8135,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-vesting", + "pallet-whitelist", "pallet-xcm", "parity-scale-codec", "polkadot-primitives", @@ -7969,6 +8148,7 @@ dependencies = [ "serde_derive", "smallvec", "sp-api", + "sp-arithmetic", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", @@ -7994,8 +8174,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", "frame-benchmarking", @@ -8040,8 +8220,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-constants" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "frame-support", "polkadot-primitives", @@ -8054,8 +8234,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-metrics" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bs58", "parity-scale-codec", @@ -8066,8 +8246,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitflags", "bitvec", @@ -8110,15 +8290,15 @@ dependencies = [ [[package]] name = "polkadot-service" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "async-trait", "frame-benchmarking-cli", "frame-support", "frame-system-rpc-runtime-api", "futures", - "hex-literal", + "hex-literal 0.4.1", "kusama-runtime", "kvdb", "kvdb-rocksdb", @@ -8219,8 +8399,8 @@ dependencies = [ [[package]] name = "polkadot-statement-distribution" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "arrayvec 0.5.2", "fatality", @@ -8240,8 +8420,8 @@ dependencies = [ [[package]] name = "polkadot-statement-table" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -8408,11 +8588,22 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-warning" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.17", +] + [[package]] name = "proc-macro2" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" +checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" dependencies = [ "unicode-ident", ] @@ -8539,6 +8730,7 @@ dependencies = [ "frame-support", "frame-system", "kilt-support", + "log", "pallet-balances", "parity-scale-codec", "scale-info", @@ -8595,9 +8787,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -8800,7 +8992,7 @@ checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -8817,9 +9009,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.2" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1a59b5d8e97dee33696bf13c5ba8ab85341c002922fba050069326b9c498974" +checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" dependencies = [ "aho-corasick 1.0.1", "memchr", @@ -8875,11 +9067,21 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ - "crypto-bigint", + "crypto-bigint 0.4.9", "hmac 0.12.1", "zeroize", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + [[package]] name = "ring" version = "0.16.20" @@ -8897,9 +9099,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9562ea1d70c0cc63a34a22d977753b50cca91cc6b6527750463bd5dd8697bc" +checksum = "015439787fce1e75d55f279078d33ff14b4af5d93d995e8838ee4631301c8a99" dependencies = [ "libc", "librocksdb-sys", @@ -8907,8 +9109,8 @@ dependencies = [ [[package]] name = "rococo-runtime" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "binary-merkle-tree", "frame-benchmarking", @@ -8918,7 +9120,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.4.1", "log", "pallet-authority-discovery", "pallet-authorship", @@ -8993,8 +9195,8 @@ dependencies = [ [[package]] name = "rococo-runtime-constants" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "frame-support", "polkadot-primitives", @@ -9071,10 +9273,7 @@ name = "runtime-common" version = "1.11.0-dev" dependencies = [ "attestation", - "ctype", "cumulus-primitives-core", - "delegation", - "did", "frame-support", "frame-system", "kilt-asset-dids", @@ -9082,11 +9281,9 @@ dependencies = [ "log", "pallet-authorship", "pallet-balances", - "pallet-did-lookup", - "pallet-inflation", "pallet-membership", "pallet-transaction-payment", - "pallet-web3-names", + "pallet-treasury", "parachain-staking", "parity-scale-codec", "polkadot-parachain", @@ -9210,7 +9407,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64 0.21.1", + "base64 0.21.2", ] [[package]] @@ -9257,7 +9454,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "log", "sp-core", @@ -9268,7 +9465,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "futures", @@ -9296,7 +9493,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "futures", "futures-timer", @@ -9319,7 +9516,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -9334,7 +9531,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -9353,18 +9550,18 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "chrono", @@ -9404,7 +9601,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "fnv", "futures", @@ -9430,7 +9627,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "hash-db", "kvdb", @@ -9456,7 +9653,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "futures", @@ -9481,7 +9678,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "futures", @@ -9510,13 +9707,12 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "fork-tree", "futures", "log", - "merlin", "num-bigint", "num-rational", "num-traits", @@ -9529,7 +9725,6 @@ dependencies = [ "sc-keystore", "sc-telemetry", "scale-info", - "schnorrkel", "sp-api", "sp-application-crypto", "sp-block-builder", @@ -9537,7 +9732,6 @@ dependencies = [ "sp-consensus", "sp-consensus-babe", "sp-consensus-slots", - "sp-consensus-vrf", "sp-core", "sp-inherents", "sp-keystore", @@ -9549,7 +9743,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "futures", "jsonrpsee", @@ -9571,7 +9765,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -9606,7 +9800,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "futures", "jsonrpsee", @@ -9625,7 +9819,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "fork-tree", "parity-scale-codec", @@ -9638,7 +9832,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "ahash 0.8.3", "array-bytes 4.2.0", @@ -9678,7 +9872,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "finality-grandpa", "futures", @@ -9698,7 +9892,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "futures", @@ -9721,7 +9915,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "lru 0.8.1", "parity-scale-codec", @@ -9745,7 +9939,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -9758,7 +9952,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "log", "sc-allocator", @@ -9771,7 +9965,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "anyhow", "cfg-if", @@ -9789,7 +9983,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "ansi_term", "futures", @@ -9805,7 +9999,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -9820,7 +10014,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "async-channel", @@ -9850,6 +10044,7 @@ dependencies = [ "serde", "serde_json", "smallvec", + "snow", "sp-arithmetic", "sp-blockchain", "sp-consensus", @@ -9864,7 +10059,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "cid", "futures", @@ -9884,7 +10079,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -9912,7 +10107,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "ahash 0.8.3", "futures", @@ -9931,7 +10126,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "futures", @@ -9953,7 +10148,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -9987,7 +10182,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "futures", @@ -10007,7 +10202,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "bytes", @@ -10038,7 +10233,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "futures", "libp2p", @@ -10051,7 +10246,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -10060,7 +10255,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "futures", "jsonrpsee", @@ -10090,7 +10285,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10109,7 +10304,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "http", "jsonrpsee", @@ -10124,7 +10319,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", "futures", @@ -10150,7 +10345,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "directories", @@ -10216,7 +10411,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "log", "parity-scale-codec", @@ -10227,7 +10422,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "clap", "fs4", @@ -10243,7 +10438,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10262,7 +10457,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "futures", "libc", @@ -10281,7 +10476,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "chrono", "futures", @@ -10300,7 +10495,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "ansi_term", "atty", @@ -10331,18 +10526,18 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "futures", @@ -10369,7 +10564,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "futures", @@ -10383,7 +10578,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-channel", "futures", @@ -10509,10 +10704,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ - "base16ct", - "der", + "base16ct 0.1.1", + "der 0.6.1", "generic-array 0.14.7", - "pkcs8", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[package]] +name = "sec1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" +dependencies = [ + "base16ct 0.2.0", + "der 0.7.6", + "generic-array 0.14.7", + "pkcs8 0.10.2", "subtle", "zeroize", ] @@ -10608,7 +10817,7 @@ checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -10622,6 +10831,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" +dependencies = [ + "serde", +] + [[package]] name = "sha-1" version = "0.9.8" @@ -10726,6 +10944,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + [[package]] name = "simba" version = "0.8.1" @@ -10762,8 +10990,8 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "slot-range-helper" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "enumn", "parity-scale-codec", @@ -10840,13 +11068,15 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "hash-db", "log", "parity-scale-codec", + "scale-info", "sp-api-proc-macro", "sp-core", + "sp-metadata-ir", "sp-runtime", "sp-state-machine", "sp-std", @@ -10858,7 +11088,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "Inflector", "blake2", @@ -10866,13 +11096,13 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "scale-info", @@ -10885,7 +11115,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "integer-sqrt", "num-traits", @@ -10899,7 +11129,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "scale-info", @@ -10912,7 +11142,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "sp-api", @@ -10924,7 +11154,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "futures", "log", @@ -10942,7 +11172,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "futures", @@ -10957,7 +11187,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "parity-scale-codec", @@ -10975,10 +11205,9 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", - "merlin", "parity-scale-codec", "scale-info", "serde", @@ -10986,7 +11215,6 @@ dependencies = [ "sp-application-crypto", "sp-consensus", "sp-consensus-slots", - "sp-consensus-vrf", "sp-core", "sp-inherents", "sp-keystore", @@ -10998,7 +11226,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "lazy_static", "parity-scale-codec", @@ -11017,7 +11245,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "finality-grandpa", "log", @@ -11035,7 +11263,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "scale-info", @@ -11044,29 +11272,16 @@ dependencies = [ "sp-timestamp", ] -[[package]] -name = "sp-consensus-vrf" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" -dependencies = [ - "parity-scale-codec", - "scale-info", - "schnorrkel", - "sp-core", - "sp-runtime", - "sp-std", -] - [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "array-bytes 4.2.0", - "base58", "bitflags", "blake2", "bounded-collections", + "bs58", "dyn-clonable", "ed25519-zebra", "futures", @@ -11079,6 +11294,7 @@ dependencies = [ "merlin", "parity-scale-codec", "parking_lot 0.12.1", + "paste", "primitive-types", "rand 0.8.5", "regex", @@ -11103,7 +11319,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "blake2b_simd", "byteorder", @@ -11117,18 +11333,18 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -11137,17 +11353,17 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "environmental", "parity-scale-codec", @@ -11158,7 +11374,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -11173,7 +11389,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "bytes", "ed25519", @@ -11182,6 +11398,7 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", + "rustversion", "secp256k1", "sp-core", "sp-externalities", @@ -11198,7 +11415,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "lazy_static", "sp-core", @@ -11209,14 +11426,11 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ - "async-trait", "futures", - "merlin", "parity-scale-codec", "parking_lot 0.12.1", - "schnorrkel", "serde", "sp-core", "sp-externalities", @@ -11226,16 +11440,27 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "thiserror", - "zstd", + "zstd 0.12.3+zstd.1.5.2", +] + +[[package]] +name = "sp-metadata-ir" +version = "0.1.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" +dependencies = [ + "frame-metadata", + "parity-scale-codec", + "scale-info", + "sp-std", ] [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -11253,7 +11478,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "scale-info", @@ -11267,7 +11492,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "sp-api", "sp-core", @@ -11277,7 +11502,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "backtrace", "lazy_static", @@ -11287,7 +11512,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "rustc-hash", "serde", @@ -11297,7 +11522,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "either", "hash256-std-hasher", @@ -11319,7 +11544,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -11337,19 +11562,19 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "Inflector", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "scale-info", @@ -11363,10 +11588,11 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "scale-info", + "serde", "sp-core", "sp-runtime", "sp-std", @@ -11375,7 +11601,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "hash-db", "log", @@ -11395,12 +11621,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "impl-serde", "parity-scale-codec", @@ -11413,7 +11639,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "futures-timer", @@ -11428,7 +11654,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "sp-std", @@ -11440,7 +11666,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "sp-api", "sp-runtime", @@ -11449,7 +11675,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "log", @@ -11465,11 +11691,11 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "ahash 0.8.3", "hash-db", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "lazy_static", "memory-db", "nohash-hasher", @@ -11488,7 +11714,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "impl-serde", "parity-scale-codec", @@ -11505,18 +11731,18 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -11530,7 +11756,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "parity-scale-codec", "scale-info", @@ -11572,7 +11798,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "kilt-runtime-api-did", "kilt-runtime-api-public-credentials", "kilt-runtime-api-staking", @@ -11633,7 +11859,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" dependencies = [ "base64ct", - "der", + "der 0.6.1", +] + +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der 0.7.6", ] [[package]] @@ -11779,7 +12015,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "platforms 2.0.0", ] @@ -11787,7 +12023,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -11806,7 +12042,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "hyper", "log", @@ -11818,7 +12054,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "jsonrpsee", @@ -11831,7 +12067,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "jsonrpsee", "log", @@ -11850,7 +12086,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "ansi_term", "build-helper", @@ -11859,7 +12095,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml", + "toml 0.7.4", "walkdir", "wasm-opt", ] @@ -11892,9 +12128,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "45b6ddbb36c5b969c182aec3c4a0bce7df3fbad4b77114706a49aacc80567388" dependencies = [ "proc-macro2", "quote", @@ -12002,7 +12238,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -12173,7 +12409,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -12223,19 +12459,36 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + [[package]] name = "toml_datetime" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" -version = "0.19.9" +version = "0.19.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d964908cec0d030b812013af25a0e57fddfadb1e066ecc6681d86253129d4f" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" dependencies = [ "indexmap", + "serde", + "serde_spanned", "toml_datetime", "winnow", ] @@ -12302,7 +12555,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -12327,8 +12580,8 @@ dependencies = [ [[package]] name = "tracing-gum" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "polkadot-node-jaeger", "polkadot-primitives", @@ -12338,14 +12591,14 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ - "expander 0.0.6", + "expander 2.0.0", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] @@ -12469,7 +12722,7 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd" dependencies = [ "async-trait", "clap", @@ -12500,7 +12753,7 @@ dependencies = [ "sp-version", "sp-weights", "substrate-rpc-client", - "zstd", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -12572,9 +12825,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-normalization" @@ -12759,7 +13012,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", "wasm-bindgen-shared", ] @@ -12793,7 +13046,7 @@ checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -12965,9 +13218,9 @@ dependencies = [ "rustix 0.36.14", "serde", "sha2 0.10.6", - "toml", + "toml 0.5.11", "windows-sys 0.42.0", - "zstd", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] @@ -13202,7 +13455,7 @@ dependencies = [ "ccm", "curve25519-dalek 3.2.0", "der-parser 8.2.0", - "elliptic-curve", + "elliptic-curve 0.12.3", "hkdf", "hmac 0.12.1", "log", @@ -13214,11 +13467,11 @@ dependencies = [ "rcgen 0.9.3", "ring", "rustls 0.19.1", - "sec1", + "sec1 0.3.0", "serde", "sha1", "sha2 0.10.6", - "signature", + "signature 1.6.4", "subtle", "thiserror", "tokio", @@ -13342,8 +13595,8 @@ dependencies = [ [[package]] name = "westend-runtime" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bitvec", "frame-benchmarking", @@ -13354,7 +13607,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.4.1", "log", "pallet-authority-discovery", "pallet-authorship", @@ -13434,8 +13687,8 @@ dependencies = [ [[package]] name = "westend-runtime-constants" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "frame-support", "polkadot-primitives", @@ -13791,8 +14044,8 @@ dependencies = [ [[package]] name = "xcm" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "bounded-collections", "derivative", @@ -13807,8 +14060,8 @@ dependencies = [ [[package]] name = "xcm-builder" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "frame-support", "frame-system", @@ -13828,8 +14081,8 @@ dependencies = [ [[package]] name = "xcm-executor" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "environmental", "frame-benchmarking", @@ -13848,13 +14101,13 @@ dependencies = [ [[package]] name = "xcm-procedural" -version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.41#e203bfb396ed949f102720debf32fb98166787af" +version = "0.9.42" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.42#9b1fc27cec47f01a2c229532ee7ab79cc5bb28ef" dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.17", ] [[package]] @@ -13897,7 +14150,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.17", ] [[package]] @@ -13906,7 +14159,16 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.3+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" +dependencies = [ + "zstd-safe 6.0.5+zstd.1.5.4", ] [[package]] @@ -13919,6 +14181,16 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "6.0.5+zstd.1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" +dependencies = [ + "libc", + "zstd-sys", +] + [[package]] name = "zstd-sys" version = "2.0.8+zstd.1.5.5" diff --git a/Cargo.toml b/Cargo.toml index c612f5aa4e..d0ec0361fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ panic = "unwind" [workspace.dependencies] # Build deps -substrate-wasm-builder = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} +substrate-wasm-builder = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} # External (without extra features and with default disabled if necessary) base58 = {version = "0.2.0", default-features = false} @@ -72,112 +72,112 @@ peregrine-runtime = {path = "runtimes/peregrine", default-features = false} spiritnet-runtime = {path = "runtimes/spiritnet", default-features = false} # Benchmarking (with default disabled) -cumulus-pallet-session-benchmarking = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} +cumulus-pallet-session-benchmarking = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} # Cumulus (with default disabled) -cumulus-pallet-aura-ext = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -cumulus-pallet-dmp-queue = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -cumulus-pallet-parachain-system = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -cumulus-pallet-xcm = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -cumulus-pallet-xcmp-queue = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -cumulus-primitives-core = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -cumulus-primitives-timestamp = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -cumulus-primitives-utility = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -pallet-collator-selection = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} -parachain-info = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.41"} +cumulus-pallet-aura-ext = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +cumulus-pallet-dmp-queue = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +cumulus-pallet-parachain-system = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +cumulus-pallet-xcm = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +cumulus-pallet-xcmp-queue = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +cumulus-primitives-core = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +cumulus-primitives-timestamp = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +cumulus-primitives-utility = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +pallet-collator-selection = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} +parachain-info = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.42"} # Substrate (with default disabled) -frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -frame-benchmarking-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -frame-executive = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-democracy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-grandpa = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-indices = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-preimage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-proxy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-sudo = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-tips = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-vesting = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -pallet-multisig = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-offchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-staking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -sp-weights = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} -try-runtime-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.41"} +frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +frame-benchmarking-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +frame-executive = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-democracy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-grandpa = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-indices = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-preimage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-proxy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-sudo = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-tips = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-vesting = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +pallet-multisig = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-offchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-staking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +sp-weights = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +try-runtime-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} # Polkadot (with default disabled) -pallet-xcm = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.41"} -polkadot-parachain = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.41"} -xcm = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.41"} -xcm-builder = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.41"} -xcm-executor = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.41"} +pallet-xcm = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.42"} +polkadot-parachain = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.42"} +xcm = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.42"} +xcm-builder = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.42"} +xcm-executor = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.42"} # Client-only (with default enabled) -cumulus-client-cli = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-client-consensus-aura = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-client-consensus-common = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-client-network = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-client-service = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-primitives-parachain-inherent = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-relay-chain-inprocess-interface = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-relay-chain-interface = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-relay-chain-minimal-node = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -cumulus-relay-chain-rpc-interface = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.41"} -pallet-transaction-payment-rpc = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -polkadot-cli = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.41"} -polkadot-primitives = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.41"} -polkadot-service = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.41"} -sc-basic-authorship = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-chain-spec = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-cli = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-client-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-consensus-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-network = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-network-sync = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-rpc-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-service = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-sysinfo = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-telemetry = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-tracing = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sp-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sp-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -sp-timestamp = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -substrate-frame-rpc-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} -substrate-prometheus-endpoint = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41"} +cumulus-client-cli = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-client-consensus-aura = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-client-consensus-common = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-client-network = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-client-service = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-primitives-parachain-inherent = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-relay-chain-inprocess-interface = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-relay-chain-interface = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-relay-chain-minimal-node = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +cumulus-relay-chain-rpc-interface = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.42"} +pallet-transaction-payment-rpc = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +polkadot-cli = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42"} +polkadot-primitives = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42"} +polkadot-service = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42"} +sc-basic-authorship = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-chain-spec = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-cli = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-client-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-consensus-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-network = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-network-sync = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-rpc-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-service = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-sysinfo = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-telemetry = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-tracing = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sp-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sp-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +sp-timestamp = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +substrate-frame-rpc-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +substrate-prometheus-endpoint = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} diff --git a/nodes/parachain/src/chain_spec.rs b/nodes/parachain/src/chain_spec.rs index 42725d5dfa..a89a1ef51e 100644 --- a/nodes/parachain/src/chain_spec.rs +++ b/nodes/parachain/src/chain_spec.rs @@ -22,7 +22,7 @@ #![allow(clippy::derive_partial_eq_without_eq)] use cumulus_primitives_core::ParaId; -use polkadot_primitives::v2::LOWEST_PUBLIC_ID; +use polkadot_primitives::v4::LOWEST_PUBLIC_ID; use runtime_common::{AccountId, AccountPublic}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::Properties; diff --git a/nodes/parachain/src/service.rs b/nodes/parachain/src/service.rs index a57aa9e993..8d047042df 100644 --- a/nodes/parachain/src/service.rs +++ b/nodes/parachain/src/service.rs @@ -37,7 +37,7 @@ use sc_network_sync::SyncingService; use sc_service::{Configuration, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sp_api::ConstructRuntimeApi; -use sp_keystore::SyncCryptoStorePtr; +use sp_keystore::KeystorePtr; use sp_runtime::traits::BlakeTwo256; use std::{sync::Arc, time::Duration}; use substrate_prometheus_endpoint::Registry; @@ -146,12 +146,7 @@ where }) .transpose()?; - let executor = sc_executor::NativeElseWasmExecutor::::new( - config.wasm_method, - config.default_heap_pages, - config.max_runtime_instances, - config.runtime_cache_size, - ); + let executor = sc_service::new_native_or_wasm_executor(config); let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( config, @@ -278,7 +273,7 @@ where Arc, Arc>>, Arc>, - SyncCryptoStorePtr, + KeystorePtr, bool, ParaId, ) -> Result>, sc_service::Error>, @@ -342,7 +337,7 @@ where transaction_pool: transaction_pool.clone(), task_manager: &mut task_manager, config: parachain_config, - keystore: params.keystore_container.sync_keystore(), + keystore: params.keystore_container.keystore(), backend: backend.clone(), network: network.clone(), system_rpc_tx, @@ -383,8 +378,8 @@ where &task_manager, relay_chain_interface.clone(), transaction_pool, - sync_service, - params.keystore_container.sync_keystore(), + sync_service.clone(), + params.keystore_container.keystore(), force_authoring, id, )?; @@ -397,6 +392,7 @@ where client: client.clone(), task_manager: &mut task_manager, relay_chain_interface, + sync_service: sync_service.clone(), spawner, parachain_consensus, import_queue: import_queue_service, @@ -413,6 +409,7 @@ where task_manager: &mut task_manager, para_id: id, relay_chain_interface, + sync_service, relay_chain_slot_duration, import_queue: import_queue_service, recovery_handle: Box::new(overseer_handle), @@ -523,7 +520,7 @@ fn build_consensus( relay_chain_interface: Arc, transaction_pool: Arc>>, sync_oracle: Arc>, - keystore: SyncCryptoStorePtr, + keystore: KeystorePtr, force_authoring: bool, id: ParaId, ) -> Result>, sc_service::Error> diff --git a/nodes/standalone/src/service.rs b/nodes/standalone/src/service.rs index eaa3efb1b5..64c4bab891 100644 --- a/nodes/standalone/src/service.rs +++ b/nodes/standalone/src/service.rs @@ -23,7 +23,6 @@ use sc_client_api::BlockBackend; use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_consensus_grandpa::SharedVoterState; pub use sc_executor::NativeElseWasmExecutor; -use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams}; use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_consensus_aura::ed25519::AuthorityPair as AuraPair; @@ -65,10 +64,6 @@ type PartialComponents = sc_service::PartialComponents< >; pub fn new_partial(config: &Configuration) -> Result { - if config.keystore_remote.is_some() { - return Err(ServiceError::Other("Remote Keystores are not supported.".to_string())); - } - let telemetry = config .telemetry_endpoints .clone() @@ -80,12 +75,7 @@ pub fn new_partial(config: &Configuration) -> Result::new( - config.wasm_method, - config.default_heap_pages, - config.max_runtime_instances, - config.runtime_cache_size, - ); + let executor = sc_service::new_native_or_wasm_executor(config); let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( config, @@ -151,13 +141,6 @@ pub fn new_partial(config: &Configuration) -> Result Result, &'static str> { - // FIXME: here would the concrete keystore be built, - // must return a concrete type (NOT `LocalKeystore`) that - // implements `CryptoStore` and `SyncCryptoStore` - Err("Remote Keystore not supported.") -} - /// Builds a new service for a full client. pub fn new_full(mut config: Configuration) -> Result { let sc_service::PartialComponents { @@ -165,23 +148,12 @@ pub fn new_full(mut config: Configuration) -> Result backend, mut task_manager, import_queue, - mut keystore_container, + keystore_container, select_chain, transaction_pool, other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; - if let Some(url) = &config.keystore_remote { - match remote_keystore(url) { - Ok(k) => keystore_container.set_remote_keystore(k), - Err(e) => { - return Err(ServiceError::Other(format!( - "Error hooking up remote keystore for {}: {}", - url, e - ))) - } - }; - } let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name( &client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"), &config.chain_spec, @@ -239,7 +211,7 @@ pub fn new_full(mut config: Configuration) -> Result network: network.clone(), client: client.clone(), sync_service: sync.clone(), - keystore: keystore_container.sync_keystore(), + keystore: keystore_container.keystore(), task_manager: &mut task_manager, transaction_pool: transaction_pool.clone(), rpc_builder: rpc_extensions_builder, @@ -279,7 +251,7 @@ pub fn new_full(mut config: Configuration) -> Result }, force_authoring, backoff_authoring_blocks, - keystore: keystore_container.sync_keystore(), + keystore: keystore_container.keystore(), sync_oracle: sync.clone(), justification_sync_link: sync.clone(), block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), @@ -299,7 +271,7 @@ pub fn new_full(mut config: Configuration) -> Result // if the node isn't actively participating in consensus then it doesn't // need a keystore, regardless of which protocol we use below. let keystore = if role.is_authority() { - Some(keystore_container.sync_keystore()) + Some(keystore_container.keystore()) } else { None }; diff --git a/pallets/attestation/src/attestations.rs b/pallets/attestation/src/attestations.rs index 56e4768c27..4a68221dc5 100644 --- a/pallets/attestation/src/attestations.rs +++ b/pallets/attestation/src/attestations.rs @@ -15,7 +15,8 @@ // along with this program. If not, see . // If you feel like getting in touch with us, you can do so at info@botlabs.org -use kilt_support::deposit::Deposit; + +use kilt_support::Deposit; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; diff --git a/pallets/attestation/src/benchmarking.rs b/pallets/attestation/src/benchmarking.rs index 4447d89923..fb362f1ac8 100644 --- a/pallets/attestation/src/benchmarking.rs +++ b/pallets/attestation/src/benchmarking.rs @@ -17,7 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite}; -use frame_support::traits::{Currency, Get}; +use frame_support::traits::{fungible::Mutate, Get}; use frame_system::RawOrigin; use sp_runtime::traits::Hash; @@ -34,7 +34,8 @@ benchmarks! { T: core::fmt::Debug, ::EnsureOrigin: GenerateBenchmarkOrigin, T: ctype::Config, - T::BlockNumber: From + T::BlockNumber: From, + ::Currency: Mutate } add { @@ -47,7 +48,7 @@ benchmarks! { creator: attester.clone(), created_at: 0u64.into() }); - ::Currency::make_free_balance_be(&sender, ::Deposit::get() + ::Deposit::get()); + ::Currency::set_balance(&sender, ::Deposit::get() + ::Deposit::get()); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); }: _(origin, claim_hash, ctype_hash, None) @@ -58,7 +59,7 @@ benchmarks! { attester, authorization_id: None, revoked: false, - deposit: kilt_support::deposit::Deposit { + deposit: kilt_support::Deposit { owner: sender, amount: ::Deposit::get(), } @@ -75,7 +76,7 @@ benchmarks! { creator: attester.clone(), created_at: 0u64.into() }); - ::Currency::make_free_balance_be(&sender, ::Deposit::get() + ::Deposit::get()); + ::Currency::set_balance(&sender, ::Deposit::get() + ::Deposit::get()); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); Pallet::::add(origin.clone(), claim_hash, ctype_hash, None)?; @@ -87,7 +88,7 @@ benchmarks! { attester, authorization_id: None, revoked: true, - deposit: kilt_support::deposit::Deposit { + deposit: kilt_support::Deposit { owner: sender, amount: ::Deposit::get(), } @@ -104,7 +105,7 @@ benchmarks! { creator: attester.clone(), created_at: 0u64.into() }); - ::Currency::make_free_balance_be(&sender, ::Deposit::get() + ::Deposit::get()); + ::Currency::set_balance(&sender, ::Deposit::get() + ::Deposit::get()); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); Pallet::::add(origin, claim_hash, ctype_hash, None)?; @@ -124,7 +125,7 @@ benchmarks! { creator: attester.clone(), created_at: 0u64.into() }); - ::Currency::make_free_balance_be(&sender, ::Deposit::get() + ::Deposit::get()); + ::Currency::set_balance(&sender, ::Deposit::get() + ::Deposit::get()); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester); Pallet::::add(origin, claim_hash, ctype_hash, None)?; @@ -145,8 +146,8 @@ benchmarks! { creator: attester.clone(), created_at: 0u64.into() }); - ::Currency::make_free_balance_be(&deposit_owner_old, ::Deposit::get() + ::Deposit::get()); - ::Currency::make_free_balance_be(&deposit_owner_new, ::Deposit::get() + ::Deposit::get()); + ::Currency::set_balance(&deposit_owner_old, ::Deposit::get() + ::Deposit::get()); + ::Currency::set_balance(&deposit_owner_new, ::Deposit::get() + ::Deposit::get()); let origin = ::EnsureOrigin::generate_origin(deposit_owner_old, attester.clone()); Pallet::::add(origin, claim_hash, ctype_hash, None)?; @@ -158,7 +159,7 @@ benchmarks! { attester, authorization_id: None, revoked: false, - deposit: kilt_support::deposit::Deposit { + deposit: kilt_support::Deposit { owner: deposit_owner_new, amount: ::Deposit::get(), } @@ -175,7 +176,7 @@ benchmarks! { creator: attester.clone(), created_at: 0u64.into() }); - ::Currency::make_free_balance_be(&deposit_owner, ::Deposit::get() + ::Deposit::get()); + ::Currency::set_balance(&deposit_owner, ::Deposit::get() + ::Deposit::get()); let origin = ::EnsureOrigin::generate_origin(deposit_owner.clone(), attester.clone()); Pallet::::add(origin, claim_hash, ctype_hash, None).expect("claim should be added"); @@ -188,7 +189,7 @@ benchmarks! { attester, authorization_id: None, revoked: false, - deposit: kilt_support::deposit::Deposit { + deposit: kilt_support::Deposit { owner: deposit_owner, amount: ::Deposit::get(), } diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index 22c2f505ff..527430b6bf 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -63,6 +63,7 @@ pub mod attestations; pub mod default_weights; +pub mod migrations; #[cfg(any(feature = "mock", test))] pub mod mock; @@ -84,21 +85,25 @@ pub use crate::{ #[frame_support::pallet] pub mod pallet { use super::*; + use frame_support::{ dispatch::{DispatchResult, DispatchResultWithPostInfo}, pallet_prelude::*, - traits::{Currency, Get, ReservableCurrency, StorageVersion}, + traits::{ + fungible::{Inspect, MutateHold}, + Get, StorageVersion, + }, }; use frame_system::pallet_prelude::*; use ctype::CtypeHashOf; use kilt_support::{ - deposit::Deposit, traits::{CallSources, StorageDepositCollector}, + Deposit, }; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); /// Type of a claim hash. pub type ClaimHashOf = ::Hash; @@ -111,13 +116,20 @@ pub mod pallet { pub(crate) type AccountIdOf = ::AccountId; - pub(crate) type BalanceOf = <::Currency as Currency>>::Balance; + pub(crate) type BalanceOf = <::Currency as Inspect>>::Balance; pub(crate) type CurrencyOf = ::Currency; + pub(crate) type HoldReasonOf = ::RuntimeHoldReason; + pub type AttestationDetailsOf = AttestationDetails, AttesterOf, AuthorizationIdOf, AccountIdOf, BalanceOf>; + #[pallet::composite_enum] + pub enum HoldReason { + Deposit, + } + #[pallet::config] pub trait Config: frame_system::Config + ctype::Config { type EnsureOrigin: EnsureOrigin< @@ -128,8 +140,10 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; type WeightInfo: WeightInfo; - /// The currency that is used to reserve funds for each attestation. - type Currency: ReservableCurrency>; + type RuntimeHoldReason: From; + + /// The currency that is used to hold funds for each attestation. + type Currency: MutateHold, Reason = HoldReasonOf>; /// The deposit that is required for storing an attestation. #[pallet::constant] @@ -272,7 +286,7 @@ pub mod pallet { .transpose()?; let authorization_id = authorization.as_ref().map(|ac| ac.authorization_id()); - let deposit = kilt_support::reserve_deposit::, CurrencyOf>(payer, deposit_amount)?; + let deposit = AttestationStorageDepositCollector::::create_deposit(payer, deposit_amount)?; log::debug!("insert Attestation"); @@ -397,7 +411,7 @@ pub mod pallet { log::debug!("removing Attestation"); - Self::remove_attestation(attestation, claim_hash); + Self::remove_attestation(attestation, claim_hash)?; Self::deposit_event(Event::AttestationRemoved(who, claim_hash)); Ok(Some(::WeightInfo::remove()).into()) @@ -422,7 +436,7 @@ pub mod pallet { log::debug!("removing Attestation"); - Self::remove_attestation(attestation, claim_hash); + Self::remove_attestation(attestation, claim_hash)?; Self::deposit_event(Event::DepositReclaimed(who, claim_hash)); Ok(()) @@ -468,33 +482,41 @@ pub mod pallet { } impl Pallet { - fn remove_attestation(attestation: AttestationDetailsOf, claim_hash: ClaimHashOf) { - kilt_support::free_deposit::, CurrencyOf>(&attestation.deposit); + fn remove_attestation(attestation: AttestationDetailsOf, claim_hash: ClaimHashOf) -> DispatchResult { + AttestationStorageDepositCollector::::free_deposit(attestation.deposit)?; Attestations::::remove(claim_hash); if let Some(authorization_id) = &attestation.authorization_id { ExternalAttestations::::remove(authorization_id, claim_hash); } + Ok(()) } } - struct AttestationStorageDepositCollector(PhantomData); - impl StorageDepositCollector, ClaimHashOf> for AttestationStorageDepositCollector { + pub(crate) struct AttestationStorageDepositCollector(PhantomData); + impl StorageDepositCollector, ClaimHashOf, T::RuntimeHoldReason> + for AttestationStorageDepositCollector + { type Currency = ::Currency; + type Reason = HoldReason; + + fn reason() -> Self::Reason { + HoldReason::Deposit + } fn deposit( key: &ClaimHashOf, - ) -> Result, >>::Balance>, DispatchError> { + ) -> Result, >>::Balance>, DispatchError> { let attestation = Attestations::::get(key).ok_or(Error::::NotFound)?; Ok(attestation.deposit) } - fn deposit_amount(_key: &ClaimHashOf) -> >>::Balance { + fn deposit_amount(_key: &ClaimHashOf) -> >>::Balance { T::Deposit::get() } fn store_deposit( key: &ClaimHashOf, - deposit: Deposit, >>::Balance>, + deposit: Deposit, >>::Balance>, ) -> Result<(), DispatchError> { let attestation = Attestations::::get(key).ok_or(Error::::NotFound)?; Attestations::::insert(key, AttestationDetails { deposit, ..attestation }); diff --git a/pallets/attestation/src/migrations.rs b/pallets/attestation/src/migrations.rs new file mode 100644 index 0000000000..b613ab426a --- /dev/null +++ b/pallets/attestation/src/migrations.rs @@ -0,0 +1,154 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + traits::{Get, GetStorageVersion, OnRuntimeUpgrade, ReservableCurrency, StorageVersion}, + weights::Weight, +}; +use kilt_support::migration::switch_reserved_to_hold; +use log; +use sp_runtime::SaturatedConversion; +use sp_std::marker::PhantomData; + +use crate::{ + AccountIdOf, Attestations, Config, CurrencyOf, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION, +}; + +const CURRENT_STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + +pub struct BalanceMigration(PhantomData); + +impl OnRuntimeUpgrade for BalanceMigration +where + ::Currency: ReservableCurrency, +{ + fn on_runtime_upgrade() -> frame_support::weights::Weight { + log::info!("Attestation: Initiating migration"); + + let onchain_storage_version = Pallet::::on_chain_storage_version(); + + if onchain_storage_version == CURRENT_STORAGE_VERSION { + TARGET_STORAGE_VERSION.put::>(); + + ::DbWeight::get() + .reads_writes(1, 1) + .saturating_add(do_migration::()) + } else { + log::info!( + "Attestation: No migration needed. This file should be deleted. Current storage version: {:?}, Required Version for update: {:?}", + onchain_storage_version, + CURRENT_STORAGE_VERSION + ); + + ::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + use sp_std::vec; + + let has_all_user_no_holds = Attestations::::iter_values() + .map(|details: crate::AttestationDetailsOf| { + kilt_support::migration::has_user_reserved_balance::, CurrencyOf>( + &details.deposit.owner, + &HoldReason::Deposit.into(), + ) + }) + .all(|user| user); + + assert!( + has_all_user_no_holds, + "Pre Upgrade Attestation: there are users with holds!" + ); + + assert_eq!(Pallet::::on_chain_storage_version(), CURRENT_STORAGE_VERSION); + + log::info!("Attestation: Pre migration checks successful"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_pre_state: sp_std::vec::Vec) -> Result<(), &'static str> { + use frame_support::traits::fungible::InspectHold; + use sp_runtime::Saturating; + use sp_std::collections::btree_map::BTreeMap; + + use crate::BalanceOf; + + let mut map_user_deposit: BTreeMap, BalanceOf> = BTreeMap::new(); + + Attestations::::iter_values().for_each(|details| { + map_user_deposit + .entry(details.deposit.owner) + .and_modify(|balance| *balance = balance.saturating_add(details.deposit.amount)) + .or_insert(details.deposit.amount); + }); + + map_user_deposit + .iter() + .try_for_each(|(who, amount)| -> Result<(), &'static str> { + let hold_balance: BalanceOf = + ::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into(); + + assert!( + amount.eq(&hold_balance), + "Attestation: Hold balance is not matching for attestation {:?}. Expected hold: {:?}. Real hold: {:?}", + who, + amount, + hold_balance + ); + Ok(()) + })?; + + assert_eq!(Pallet::::on_chain_storage_version(), TARGET_STORAGE_VERSION); + + log::info!("Attestation: Post migration checks successful"); + Ok(()) + } +} + +fn do_migration() -> Weight +where + ::Currency: ReservableCurrency, +{ + Attestations::::iter() + .map(|(key, attestations_detail)| -> Weight { + let deposit = attestations_detail.deposit; + let result = switch_reserved_to_hold::, CurrencyOf>( + deposit.owner, + &HoldReason::Deposit.into(), + deposit.amount.saturated_into(), + ); + + if result.is_err() { + log::error!( + " Attestation: Could not convert reserves to hold from attestation: {:?} error: {:?}", + key, + result + ); + } + + // Currency::reserve and Currency::hold each read and write to the DB once. + // Since we are uncertain about which operation may fail, in the event of an + // error, we assume the worst-case scenario here. + ::DbWeight::get().reads_writes(2, 2) + }) + .fold(Weight::zero(), |acc, next| acc.saturating_add(next)) +} diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index 4a1a74fccb..36ca489603 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -30,11 +30,11 @@ use sp_core::H256; use sp_runtime::DispatchError; use ctype::CtypeHashOf; -use kilt_support::deposit::Deposit; +use kilt_support::{traits::StorageDepositCollector, Deposit}; use crate::{ pallet::AuthorizationIdOf, AccountIdOf, AttestationAccessControl, AttestationDetails, AttestationDetailsOf, - AttesterOf, BalanceOf, ClaimHashOf, Config, CurrencyOf, + AttesterOf, BalanceOf, ClaimHashOf, Config, }; #[cfg(test)] @@ -153,7 +153,7 @@ where } pub fn insert_attestation(claim_hash: ClaimHashOf, details: AttestationDetailsOf) { - kilt_support::reserve_deposit::, CurrencyOf>( + crate::AttestationStorageDepositCollector::::create_deposit( details.deposit.owner.clone(), details.deposit.amount, ) @@ -202,7 +202,7 @@ pub(crate) mod runtime { UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Attestation: crate::{Pallet, Call, Storage, Event}, + Attestation: crate::{Pallet, Call, Storage, Event, HoldReason}, Ctype: ctype::{Pallet, Call, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Event}, MockOrigin: mock_origin::{Pallet, Origin}, @@ -246,9 +246,15 @@ pub(crate) mod runtime { pub const ExistentialDeposit: Balance = MILLI_UNIT; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxFreezes: u32 = 50; + pub const MaxHolds : u32 = 50; } impl pallet_balances::Config for Test { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; type Balance = Balance; type DustRemoval = (); type RuntimeEvent = (); @@ -293,7 +299,7 @@ pub(crate) mod runtime { type OriginSuccess = mock_origin::DoubleOrigin>; type RuntimeEvent = (); type WeightInfo = (); - + type RuntimeHoldReason = RuntimeHoldReason; type Currency = Balances; type Deposit = Deposit; type MaxDelegatedAttestations = MaxDelegatedAttestations; @@ -396,7 +402,7 @@ pub(crate) mod runtime { pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); - let keystore = sp_keystore::testing::KeyStore::new(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(std::sync::Arc::new(keystore))); ext diff --git a/pallets/attestation/src/tests.rs b/pallets/attestation/src/tests.rs index 4c1ad729bb..e3b18a3738 100644 --- a/pallets/attestation/src/tests.rs +++ b/pallets/attestation/src/tests.rs @@ -17,15 +17,15 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use ctype::mock::get_ctype_hash; -use frame_support::{assert_noop, assert_ok}; -use sp_runtime::{traits::Zero, DispatchError}; +use frame_support::{assert_noop, assert_ok, traits::fungible::InspectHold}; +use sp_runtime::{traits::Zero, DispatchError, TokenError}; -use kilt_support::{deposit::Deposit, mock::mock_origin::DoubleOrigin}; +use kilt_support::{mock::mock_origin::DoubleOrigin, Deposit}; use crate::{ self as attestation, mock::{runtime::Balances, *}, - AttestationAccessControl, AttesterOf, Config, Error, + AttestationAccessControl, AttesterOf, Config, Error, HoldReason, }; // ############################################################################# @@ -183,7 +183,10 @@ fn test_revoke_remove() { Attestation::attestations(claim_hash).expect("Attestation should be present on chain."); assert!(stored_attestation.revoked); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); assert_ok!(Attestation::remove( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -191,7 +194,7 @@ fn test_revoke_remove() { None )); assert!(Attestation::attestations(claim_hash).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); }); } @@ -219,7 +222,10 @@ fn test_authorized_revoke() { assert!(Attestation::external_attestations(revoker.clone(), claim_hash)); assert!(stored_attestation.revoked); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); }); } @@ -376,7 +382,7 @@ fn test_remove_not_found() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) .build_and_execute_with_sanity_tests(|| { - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); assert_noop!( Attestation::remove(DoubleOrigin(ACCOUNT_00, attester.clone()).into(), claim_hash, None), attestation::Error::::NotFound @@ -400,7 +406,10 @@ fn test_reclaim_deposit() { .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) .build_and_execute_with_sanity_tests(|| { - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); assert_ok!(Attestation::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), claim_hash @@ -410,7 +419,7 @@ fn test_reclaim_deposit() { claim_hash )); assert!(Attestation::attestations(claim_hash).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); }); } @@ -425,13 +434,16 @@ fn test_reclaim_deposit_authorization() { .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) .build_and_execute_with_sanity_tests(|| { - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); assert_ok!(Attestation::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), claim_hash )); assert!(Attestation::attestations(claim_hash).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); }); } @@ -489,7 +501,10 @@ fn test_change_deposit_owner() { .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) .with_attestations(vec![(claim_hash, attestation)]) .build_and_execute_with_sanity_tests(|| { - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); assert_ok!(Attestation::change_deposit_owner( DoubleOrigin(ACCOUNT_01, attester).into(), claim_hash @@ -503,8 +518,11 @@ fn test_change_deposit_owner() { amount: ::Deposit::get() } ); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); }); } @@ -521,10 +539,13 @@ fn test_change_deposit_owner_insufficient_balance() { .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) .with_attestations(vec![(claim_hash, attestation)]) .build_and_execute_with_sanity_tests(|| { - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); assert_noop!( Attestation::change_deposit_owner(DoubleOrigin(ACCOUNT_01, attester).into(), claim_hash), - pallet_balances::Error::::InsufficientBalance + TokenError::CannotCreateHold ); }); } @@ -582,7 +603,7 @@ fn test_update_deposit() { .with_attestations(vec![(claim_hash, attestation)]) .build_and_execute_with_sanity_tests(|| { assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 2 ); assert_ok!(Attestation::update_deposit( @@ -600,7 +621,10 @@ fn test_update_deposit() { ); // old deposit was 2x Deposit::get(), new deposit should be the the default // deposit value. - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); }); } @@ -621,7 +645,7 @@ fn test_update_deposit_unauthorized() { .with_attestations(vec![(claim_hash, attestation)]) .build_and_execute_with_sanity_tests(|| { assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 2 ); assert_noop!( diff --git a/pallets/ctype/src/benchmarking.rs b/pallets/ctype/src/benchmarking.rs index fdd177ac08..6f99496214 100644 --- a/pallets/ctype/src/benchmarking.rs +++ b/pallets/ctype/src/benchmarking.rs @@ -19,7 +19,10 @@ use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite}; use frame_support::{ sp_runtime::traits::Hash, - traits::{Currency, EnsureOrigin, Get}, + traits::{ + fungible::{Inspect, Mutate}, + EnsureOrigin, Get, + }, }; use sp_std::{ convert::{TryFrom, TryInto}, @@ -37,8 +40,9 @@ const MAX_CTYPE_SIZE: u32 = 5 * 1024 * 1024; benchmarks! { where_clause { where - <::Currency as Currency>>::Balance: TryFrom, - <<::Currency as Currency<::AccountId>>::Balance as TryFrom>::Error: Debug, + <::Currency as Inspect>>::Balance: TryFrom, + ::Currency: Mutate, + <<::Currency as Inspect<::AccountId>>::Balance as TryFrom>::Error: Debug, T::EnsureOrigin: GenerateBenchmarkOrigin, T::BlockNumber: From, } @@ -53,7 +57,7 @@ benchmarks! { let ctype_hash = ::Hashing::hash(&ctype[..]); let initial_balance = ::Fee::get() * ctype.len().try_into().unwrap() + ::Currency::minimum_balance(); - ::Currency::make_free_balance_be(&caller, initial_balance); + ::Currency::set_balance(&caller, initial_balance); let origin = T::EnsureOrigin::generate_origin(caller, did.clone()); }: _(origin, ctype) @@ -73,7 +77,7 @@ benchmarks! { let new_block_number = 500u64.into(); let initial_balance = ::Fee::get() * ctype.len().try_into().unwrap() + ::Currency::minimum_balance(); - ::Currency::make_free_balance_be(&caller, initial_balance); + ::Currency::set_balance(&caller, initial_balance); let origin = T::EnsureOrigin::generate_origin(caller, did); Pallet::::add(origin, ctype).expect("CType creation should not fail."); let overarching_origin = T::OverarchingOrigin::try_successful_origin().expect("Successful origin creation should not fail."); diff --git a/pallets/ctype/src/lib.rs b/pallets/ctype/src/lib.rs index 1f55530ad8..a4c27d8f6d 100644 --- a/pallets/ctype/src/lib.rs +++ b/pallets/ctype/src/lib.rs @@ -63,11 +63,15 @@ pub mod pallet { use frame_support::{ pallet_prelude::*, sp_runtime::traits::Hash, - traits::{Currency, ExistenceRequirement, OnUnbalanced, StorageVersion, WithdrawReasons}, + traits::{ + fungible::{Balanced, Credit, Inspect}, + tokens::{Fortitude, Precision, Preservation}, + OnUnbalanced, StorageVersion, + }, }; use frame_system::pallet_prelude::*; use kilt_support::traits::CallSources; - use sp_runtime::{traits::Saturating, SaturatedConversion}; + use sp_runtime::SaturatedConversion; use sp_std::vec::Vec; use crate::ctype_entry::CtypeEntry; @@ -85,8 +89,8 @@ pub mod pallet { pub(crate) type AccountIdOf = ::AccountId; - pub(crate) type BalanceOf = <::Currency as Currency>>::Balance; - type NegativeImbalanceOf = <::Currency as Currency>>::NegativeImbalance; + pub(crate) type BalanceOf = <::Currency as Inspect>>::Balance; + type CreditOf = Credit<::AccountId, ::Currency>; #[pallet::config] pub trait Config: frame_system::Config { @@ -94,11 +98,11 @@ pub mod pallet { type OverarchingOrigin: EnsureOrigin<::RuntimeOrigin>; type OriginSuccess: CallSources, CtypeCreatorOf>; type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type Currency: Currency>; + type Currency: Balanced>; type WeightInfo: WeightInfo; type CtypeCreatorId: Parameter + MaxEncodedLen; type Fee: Get>; - type FeeCollector: OnUnbalanced>; + type FeeCollector: OnUnbalanced>; } #[pallet::pallet] @@ -160,13 +164,13 @@ pub mod pallet { // Check the free balance before we do any heavy work (e.g. calculate the ctype // hash) - let balance = >>::free_balance(&payer); - >>::ensure_can_withdraw( + let balance = >>::reducible_balance( &payer, - T::Fee::get(), - WithdrawReasons::FEE, - balance.saturating_sub(T::Fee::get()), - )?; + Preservation::Preserve, + Fortitude::Polite, + ); + + ensure!(balance >= T::Fee::get(), Error::::UnableToPayFees); let hash = ::Hashing::hash(&ctype[..]); @@ -174,11 +178,12 @@ pub mod pallet { // Collect the fees. This should not fail since we checked the free balance in // the beginning. - let imbalance = >>::withdraw( + let imbalance = >>::withdraw( &payer, T::Fee::get(), - WithdrawReasons::FEE, - ExistenceRequirement::AllowDeath, + Precision::Exact, + Preservation::Protect, + Fortitude::Polite, ) .map_err(|_| Error::::UnableToPayFees)?; diff --git a/pallets/ctype/src/mock.rs b/pallets/ctype/src/mock.rs index e441c4c528..3b941b522d 100644 --- a/pallets/ctype/src/mock.rs +++ b/pallets/ctype/src/mock.rs @@ -113,6 +113,10 @@ pub mod runtime { } impl pallet_balances::Config for Test { + type FreezeIdentifier = (); + type HoldIdentifier = (); + type MaxFreezes = (); + type MaxHolds = (); type Balance = Balance; type DustRemoval = (); type RuntimeEvent = (); @@ -198,12 +202,12 @@ pub mod runtime { #[cfg(feature = "runtime-benchmarks")] pub(crate) fn build_with_keystore(self) -> sp_io::TestExternalities { - use sp_keystore::{testing::KeyStore, KeystoreExt}; + use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_std::sync::Arc; let mut ext = self.build(); - let keystore = KeyStore::new(); + let keystore = MemoryKeystore::new(); ext.register_extension(KeystoreExt(Arc::new(keystore))); ext diff --git a/pallets/ctype/src/tests.rs b/pallets/ctype/src/tests.rs index 463164c301..5f5a922145 100644 --- a/pallets/ctype/src/tests.rs +++ b/pallets/ctype/src/tests.rs @@ -16,7 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::{assert_noop, assert_ok, sp_runtime::traits::Hash}; +use frame_support::{assert_noop, assert_ok, sp_runtime::traits::Hash, traits::fungible::Inspect}; use frame_system::RawOrigin; use sp_runtime::DispatchError; @@ -53,7 +53,7 @@ fn check_successful_ctype_creation() { } ); assert_eq!( - Balances::free_balance(deposit_owner), + Balances::balance(&deposit_owner), initial_balance.saturating_sub(::Fee::get()) ); }); diff --git a/pallets/delegation/src/access_control.rs b/pallets/delegation/src/access_control.rs index 7d10c0ece6..aaff08c81b 100644 --- a/pallets/delegation/src/access_control.rs +++ b/pallets/delegation/src/access_control.rs @@ -221,7 +221,7 @@ mod tests { use attestation::{mock::generate_base_attestation, AttestationAccessControl}; use ctype::mock::get_ctype_hash; - use kilt_support::{deposit::Deposit, mock::mock_origin::DoubleOrigin}; + use kilt_support::{mock::mock_origin::DoubleOrigin, Deposit}; use super::*; use crate::{mock::*, DelegationDetails, DelegationNode}; diff --git a/pallets/delegation/src/benchmarking.rs b/pallets/delegation/src/benchmarking.rs index 0e37be7a0a..f40d44b59a 100644 --- a/pallets/delegation/src/benchmarking.rs +++ b/pallets/delegation/src/benchmarking.rs @@ -22,7 +22,10 @@ use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite}; use frame_support::{ dispatch::DispatchErrorWithPostInfo, storage::bounded_btree_set::BoundedBTreeSet, - traits::{Currency, Get}, + traits::{ + fungible::{Inspect, InspectHold, Mutate}, + Get, + }, }; use frame_system::RawOrigin; use parity_scale_codec::Encode; @@ -63,6 +66,7 @@ where T::CtypeCreatorId: From, ::EnsureOrigin: GenerateBenchmarkOrigin, T::BlockNumber: From, + ::Currency: Mutate, { log::info!("create delegation root"); let root_public = sr25519_generate(KeyTypeId(*b"aura"), None); @@ -71,7 +75,7 @@ where let hierarchy_root_id = generate_delegation_id::(number); let sender: T::AccountId = account("sender", 0, SEED); - ::Currency::make_free_balance_be( + ::Currency::set_balance( &sender, ::Currency::minimum_balance() + ::Deposit::get() + ::Deposit::get(), ); @@ -120,6 +124,7 @@ where <::DelegationSignatureVerification as VerifySignature>::Payload, )>, ::EnsureOrigin: GenerateBenchmarkOrigin, + ::Currency: Mutate, { if level == 0 { return Ok((parent_acc_public, parent_acc_id, parent_id)); @@ -142,7 +147,7 @@ where let sig = (delegation_acc_id.clone(), hash.clone()); // add delegation from delegate to parent - ::Currency::make_free_balance_be( + ::Currency::set_balance( &sender, ::Currency::minimum_balance() + ::Deposit::get() + ::Deposit::get(), ); @@ -201,6 +206,7 @@ where )>, ::EnsureOrigin: GenerateBenchmarkOrigin, T::BlockNumber: From, + ::Currency: Mutate, { let ( DelegationTriplet:: { @@ -236,7 +242,8 @@ benchmarks! { <::DelegationSignatureVerification as VerifySignature>::Payload, )>, ::EnsureOrigin: GenerateBenchmarkOrigin, - T::BlockNumber: From + T::BlockNumber: From, + ::Currency: Mutate } create_hierarchy { @@ -248,7 +255,7 @@ benchmarks! { creator: T::CtypeCreatorId::from(creator.clone()), created_at: 0u64.into(), }); - ::Currency::make_free_balance_be( + ::Currency::set_balance( &sender, ::Currency::minimum_balance() + ::Deposit::get(), ); @@ -289,7 +296,7 @@ benchmarks! { let sig = (delegate_acc_id.clone(), AsRef::<[u8]>::as_ref(&hash_root).to_vec()).into(); let leaf_acc_id: T::DelegationEntityId = root_public.into(); - ::Currency::make_free_balance_be( + ::Currency::set_balance( &sender, ::Currency::minimum_balance() + ::Deposit::get(), ); @@ -313,7 +320,7 @@ benchmarks! { let children: BoundedBTreeSet = root_node.children; let child_id: T::DelegationNodeId = *children.iter().next().ok_or("Root should have children")?; let child_delegation = DelegationNodes::::get(child_id).ok_or("Child of root should have delegation id")?; - ::Currency::make_free_balance_be( + ::Currency::set_balance( &child_delegation.deposit.owner, ::Currency::minimum_balance() + ::Deposit::get(), ); @@ -361,14 +368,14 @@ benchmarks! { let children: BoundedBTreeSet = root_node.children; let child_id: T::DelegationNodeId = *children.iter().next().ok_or("Root should have children")?; let child_delegation = DelegationNodes::::get(child_id).ok_or("Child of root should have delegation id")?; - assert!(!::Currency::reserved_balance(&sender).is_zero()); + assert!(!::Currency::total_balance_on_hold(&sender).is_zero()); let origin = ::EnsureOrigin::generate_origin(sender.clone(), root_acc.into()); }: _(origin, hierarchy_id, r) verify { assert!(!DelegationNodes::::contains_key(hierarchy_id)); assert!(!DelegationNodes::::contains_key(child_id)); assert!(!DelegationNodes::::contains_key(leaf_id)); - assert!(::Currency::reserved_balance(&sender).is_zero()); + assert!(::Currency::total_balance_on_hold(&sender).is_zero()); } // worst case is achieved by removing the root node, since `is_delegating` is not called in remove extrinsic @@ -381,7 +388,7 @@ benchmarks! { let children: BoundedBTreeSet = root_node.children; let child_id: T::DelegationNodeId = *children.iter().next().ok_or("Root should have children")?; let child_delegation = DelegationNodes::::get(child_id).ok_or("Child of root should have delegation id")?; - assert!(!::Currency::reserved_balance(&sender).is_zero()); + assert!(!::Currency::total_balance_on_hold(&sender).is_zero()); let origin = RawOrigin::Signed(sender.clone()); }: _(origin, hierarchy_id, r) @@ -389,7 +396,7 @@ benchmarks! { assert!(!DelegationNodes::::contains_key(hierarchy_id)); assert!(!DelegationNodes::::contains_key(child_id)); assert!(!DelegationNodes::::contains_key(leaf_id)); - assert!(::Currency::reserved_balance(&sender).is_zero()); + assert!(::Currency::total_balance_on_hold(&sender).is_zero()); } can_attest { @@ -459,16 +466,16 @@ benchmarks! { let child_id: T::DelegationNodeId = *children.iter().next().ok_or("Root should have children")?; let child_delegation = DelegationNodes::::get(child_id).ok_or("Child of root should have delegation id")?; - ::Currency::make_free_balance_be( + ::Currency::set_balance( &deposit_owner_new, ::Currency::minimum_balance() + ::Deposit::get(), ); - assert!(!::Currency::reserved_balance(&deposit_owner_old).is_zero()); + assert!(!::Currency::total_balance_on_hold(&deposit_owner_old).is_zero()); let origin = ::EnsureOrigin::generate_origin(deposit_owner_new.clone(), root_acc.into()); }: _(origin, hierarchy_id) verify { - assert_eq!(::Currency::reserved_balance(&deposit_owner_new), ::Deposit::get()); + assert_eq!(::Currency::total_balance_on_hold(&deposit_owner_new), ::Deposit::get()); } update_deposit { @@ -479,7 +486,7 @@ benchmarks! { let child_id: T::DelegationNodeId = *children.iter().next().ok_or("Root should have children")?; let child_delegation = DelegationNodes::::get(child_id).ok_or("Child of root should have delegation id")?; - ::Currency::make_free_balance_be( + ::Currency::set_balance( &deposit_owner, ::Currency::minimum_balance() + ::Deposit::get(), ); diff --git a/pallets/delegation/src/delegation_hierarchy.rs b/pallets/delegation/src/delegation_hierarchy.rs index b24c797460..f501866911 100644 --- a/pallets/delegation/src/delegation_hierarchy.rs +++ b/pallets/delegation/src/delegation_hierarchy.rs @@ -18,7 +18,7 @@ use bitflags::bitflags; use frame_support::{storage::bounded_btree_set::BoundedBTreeSet, traits::Get}; -use kilt_support::deposit::Deposit; +use kilt_support::Deposit; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 12c42e6bc8..f51045a6c1 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -66,6 +66,7 @@ mod access_control; pub mod default_weights; pub mod delegation_hierarchy; +pub mod migrations; #[cfg(any(feature = "mock", test))] pub mod mock; @@ -81,12 +82,7 @@ mod try_state; pub use crate::{access_control::DelegationAc, default_weights::WeightInfo, delegation_hierarchy::*, pallet::*}; -use frame_support::{ - dispatch::DispatchResult, - ensure, - pallet_prelude::Weight, - traits::{Get, ReservableCurrency}, -}; +use frame_support::{dispatch::DispatchResult, ensure, pallet_prelude::Weight, traits::Get}; use kilt_support::traits::StorageDepositCollector; use parity_scale_codec::Encode; use sp_runtime::{traits::Hash, DispatchError}; @@ -98,18 +94,21 @@ pub mod pallet { use super::*; use frame_support::{ pallet_prelude::*, - traits::{Currency, StorageVersion}, + traits::{ + fungible::{Inspect, MutateHold}, + StorageVersion, + }, }; use frame_system::pallet_prelude::*; use kilt_support::{ - deposit::Deposit, signature::{SignatureVerificationError, VerifySignature}, traits::CallSources, + Deposit, }; use scale_info::TypeInfo; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); + pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); /// Type of a delegation node identifier. pub type DelegationNodeIdOf = ::DelegationNodeId; @@ -129,7 +128,7 @@ pub mod pallet { pub(crate) type AccountIdOf = ::AccountId; - pub(crate) type BalanceOf = <::Currency as Currency>>::Balance; + pub(crate) type BalanceOf = <::Currency as Inspect>>::Balance; pub(crate) type CurrencyOf = ::Currency; @@ -143,6 +142,11 @@ pub mod pallet { BalanceOf, >; + #[pallet::composite_enum] + pub enum HoldReason { + Deposit, + } + #[pallet::config] pub trait Config: frame_system::Config + ctype::Config { type Signature: Parameter; @@ -160,9 +164,10 @@ pub mod pallet { type OriginSuccess: CallSources, DelegatorIdOf>; type RuntimeEvent: From> + IsType<::RuntimeEvent>; type WeightInfo: WeightInfo; + type RuntimeHoldReason: From; /// The currency that is used to reserve funds for each delegation. - type Currency: ReservableCurrency>; + type Currency: MutateHold, Reason = Self::RuntimeHoldReason>; /// The deposit that is required for storing a delegation. #[pallet::constant] @@ -738,7 +743,7 @@ pub mod pallet { hierarchy_owner: DelegatorIdOf, deposit_owner: AccountIdOf, ) -> DispatchResult { - CurrencyOf::::reserve(&deposit_owner, ::Deposit::get())?; + DelegationDepositCollector::::create_deposit(deposit_owner.clone(), ::Deposit::get())?; let root_node = DelegationNode::new_root_node( root_id, @@ -765,7 +770,7 @@ pub mod pallet { mut parent_node: DelegationNodeOf, deposit_owner: AccountIdOf, ) -> DispatchResult { - CurrencyOf::::reserve(&deposit_owner, ::Deposit::get())?; + DelegationDepositCollector::::create_deposit(deposit_owner, ::Deposit::get())?; // Add the new node as a child of that node parent_node @@ -978,8 +983,7 @@ pub mod pallet { // We can clear storage now that all children have been removed DelegationNodes::::remove(*delegation); - kilt_support::free_deposit::, CurrencyOf>(&delegation_node.deposit); - + DelegationDepositCollector::::free_deposit(delegation_node.clone().deposit)?; consumed_weight = consumed_weight.saturating_add(T::DbWeight::get().reads_writes(1, 2)); // Deposit event that the delegation has been removed @@ -990,23 +994,30 @@ pub mod pallet { } struct DelegationDepositCollector(PhantomData); - impl StorageDepositCollector, DelegationNodeIdOf> for DelegationDepositCollector { + impl StorageDepositCollector, DelegationNodeIdOf, T::RuntimeHoldReason> + for DelegationDepositCollector + { type Currency = ::Currency; + type Reason = HoldReason; + + fn reason() -> Self::Reason { + HoldReason::Deposit + } fn deposit( key: &DelegationNodeIdOf, - ) -> Result, >>::Balance>, DispatchError> { + ) -> Result, >>::Balance>, DispatchError> { let delegation_node = DelegationNodes::::get(key).ok_or(Error::::DelegationNotFound)?; Ok(delegation_node.deposit) } - fn deposit_amount(_key: &DelegationNodeIdOf) -> >>::Balance { + fn deposit_amount(_key: &DelegationNodeIdOf) -> >>::Balance { ::Deposit::get() } fn store_deposit( key: &DelegationNodeIdOf, - deposit: Deposit, >>::Balance>, + deposit: Deposit, >>::Balance>, ) -> Result<(), DispatchError> { let delegation_node = DelegationNodes::::get(key).ok_or(Error::::DelegationNotFound)?; DelegationNodes::::insert( diff --git a/pallets/delegation/src/migrations.rs b/pallets/delegation/src/migrations.rs new file mode 100644 index 0000000000..d78e44f728 --- /dev/null +++ b/pallets/delegation/src/migrations.rs @@ -0,0 +1,151 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + traits::{Get, GetStorageVersion, OnRuntimeUpgrade, ReservableCurrency, StorageVersion}, + weights::Weight, +}; +use kilt_support::migration::switch_reserved_to_hold; +use log; +use sp_runtime::SaturatedConversion; +use sp_std::marker::PhantomData; + +use crate::{ + AccountIdOf, Config, CurrencyOf, DelegationNodes, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION, +}; + +const CURRENT_STORAGE_VERSION: StorageVersion = StorageVersion::new(3); + +pub struct BalanceMigration(PhantomData); + +impl OnRuntimeUpgrade for BalanceMigration +where + ::Currency: ReservableCurrency, +{ + fn on_runtime_upgrade() -> frame_support::weights::Weight { + log::info!("Delegation: Initiating migration"); + + let onchain_storage_version = Pallet::::on_chain_storage_version(); + if onchain_storage_version == CURRENT_STORAGE_VERSION { + TARGET_STORAGE_VERSION.put::>(); + ::DbWeight::get() + .reads_writes(1, 1) + .saturating_add(do_migration::()) + } else { + log::info!( + "Delegation: No migration needed. This file should be deleted. Current storage version: {:?}, Required Version for update: {:?}", + onchain_storage_version, + CURRENT_STORAGE_VERSION + ); + + ::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + use sp_std::vec; + + let has_all_user_no_holds = DelegationNodes::::iter_values() + .map(|details: crate::DelegationNodeOf| { + kilt_support::migration::has_user_reserved_balance::, CurrencyOf>( + &details.deposit.owner, + &HoldReason::Deposit.into(), + ) + }) + .all(|user| user); + + assert!( + has_all_user_no_holds, + "Pre Upgrade Delegation: there are users with holds!" + ); + + assert_eq!(Pallet::::on_chain_storage_version(), CURRENT_STORAGE_VERSION); + log::info!("Delegation: Pre migration checks successful"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_pre_state: sp_std::vec::Vec) -> Result<(), &'static str> { + use frame_support::traits::fungible::InspectHold; + use sp_runtime::Saturating; + use sp_std::collections::btree_map::BTreeMap; + + use crate::BalanceOf; + + let mut map_user_deposit: BTreeMap, BalanceOf> = BTreeMap::new(); + + DelegationNodes::::iter_values().for_each(|details| { + map_user_deposit + .entry(details.deposit.owner) + .and_modify(|balance| *balance = balance.saturating_add(details.deposit.amount)) + .or_insert(details.deposit.amount); + }); + + map_user_deposit + .iter() + .try_for_each(|(who, amount)| -> Result<(), &'static str> { + let hold_balance: BalanceOf = + ::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into(); + + assert!( + amount.eq(&hold_balance), + "Delegation: Hold balance is not matching for attestation {:?}. Expected hold: {:?}. Real hold: {:?}", + who, + amount, + hold_balance + ); + Ok(()) + })?; + + assert_eq!(Pallet::::on_chain_storage_version(), TARGET_STORAGE_VERSION); + + log::info!("Delegation: Post migration checks successful"); + Ok(()) + } +} + +fn do_migration() -> Weight +where + ::Currency: ReservableCurrency, +{ + DelegationNodes::::iter() + .map(|(key, delegation_detail)| -> Weight { + let deposit = delegation_detail.deposit; + let error = switch_reserved_to_hold::, CurrencyOf>( + deposit.owner, + &HoldReason::Deposit.into(), + deposit.amount.saturated_into(), + ); + + if error.is_err() { + log::error!( + " Delegation: Could not convert reserves to hold from delegation: {:?}, error: {:?}", + key, + error + ); + } + + // Currency::reserve and Currency::hold each read and write to the DB once. + // Since we are uncertain about which operation may fail, in the event of an + // error, we assume the worst-case scenario here. + ::DbWeight::get().reads_writes(2, 2) + }) + .fold(Weight::zero(), |acc, next| acc.saturating_add(next)) +} diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index aef5221439..10bbcc873d 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -18,12 +18,15 @@ use frame_support::{ storage::bounded_btree_set::BoundedBTreeSet, - traits::{Currency, Get}, + traits::{ + fungible::{Inspect, Mutate}, + Get, + }, }; use sp_core::H256; use ctype::{mock as ctype_mock, CtypeHashOf}; -use kilt_support::deposit::Deposit; +use kilt_support::Deposit; use crate::{ self as delegation, AccountIdOf, Config, CurrencyOf, DelegationDetails, DelegationHierarchyDetails, DelegationNode, @@ -73,11 +76,13 @@ pub fn initialize_pallet( delegation_hierarchies: DelegationHierarchyInitialization, ) where T: Config, + ::Currency: Mutate>, { for (root_id, details, hierarchy_owner, deposit_owner) in delegation_hierarchies { // manually mint to enable deposit reserving - let balance = CurrencyOf::::free_balance(&deposit_owner); - CurrencyOf::::make_free_balance_be(&deposit_owner, balance + ::Deposit::get()); + + let balance = CurrencyOf::::balance(&deposit_owner); + CurrencyOf::::set_balance(&deposit_owner, balance + ::Deposit::get()); // reserve deposit and store delegation::Pallet::::create_and_store_new_hierarchy( @@ -98,8 +103,8 @@ pub fn initialize_pallet( // manually mint to enable deposit reserving let deposit_owner = del.1.deposit.owner.clone(); - let balance = CurrencyOf::::free_balance(&deposit_owner.clone()); - CurrencyOf::::make_free_balance_be(&deposit_owner.clone(), balance + ::Deposit::get()); + let balance = CurrencyOf::::balance(&deposit_owner); + CurrencyOf::::set_balance(&deposit_owner, balance + ::Deposit::get()); // reserve deposit and store delegation::Pallet::::store_delegation_under_parent( @@ -256,12 +261,18 @@ pub(crate) mod runtime { } parameter_types! { - pub const ExistentialDeposit: Balance = 0; + pub const ExistentialDeposit: Balance = 1; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; } impl pallet_balances::Config for Test { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; type Balance = Balance; type DustRemoval = (); type RuntimeEvent = (); @@ -304,6 +315,7 @@ pub(crate) mod runtime { impl attestation::Config for Test { type EnsureOrigin = mock_origin::EnsureDoubleOrigin>; type OriginSuccess = mock_origin::DoubleOrigin>; + type RuntimeHoldReason = RuntimeHoldReason; type RuntimeEvent = (); type WeightInfo = (); @@ -327,6 +339,7 @@ pub(crate) mod runtime { impl Config for Test { type Signature = (SubjectId, Vec); + type RuntimeHoldReason = RuntimeHoldReason; type DelegationSignatureVerification = EqualVerify>; type DelegationEntityId = SubjectId; type DelegationNodeId = Hash; @@ -530,7 +543,7 @@ pub(crate) mod runtime { pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); - let keystore = sp_keystore::testing::KeyStore::new(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); ext diff --git a/pallets/delegation/src/tests.rs b/pallets/delegation/src/tests.rs index 0b1e74318f..c0e1f3404f 100644 --- a/pallets/delegation/src/tests.rs +++ b/pallets/delegation/src/tests.rs @@ -16,15 +16,18 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::{assert_err, assert_noop, assert_ok}; +use frame_support::{ + assert_err, assert_noop, assert_ok, + traits::fungible::{Inspect, InspectHold}, +}; use kilt_support::mock::mock_origin::DoubleOrigin; use crate::{ self as delegation, mock::{runtime::*, *}, - Config, Error, + Config, Error, HoldReason, }; -use sp_runtime::traits::Zero; +use sp_runtime::{traits::Zero, TokenError}; // submit_delegation_root_creation_operation() @@ -37,7 +40,11 @@ fn create_root_delegation_successful() { ExtBuilder::default() .with_ctypes(vec![(operation.ctype_hash, creator.clone())]) - .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) + .with_balances(vec![( + ACCOUNT_00, + ::Deposit::get() + + <::Currency as Inspect>>::minimum_balance(), + )]) .build_and_execute_with_sanity_tests(|| { // Create root hierarchy assert_ok!(Delegation::create_hierarchy( @@ -47,7 +54,10 @@ fn create_root_delegation_successful() { )); // Check reserved balance - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); // Get stored hierarchy let stored_hierarchy_details = Delegation::delegation_hierarchies(hierarchy_root_id) @@ -136,8 +146,16 @@ fn create_delegation_direct_root_successful() { ACCOUNT_00, )]) .with_balances(vec![ - (ACCOUNT_00, ::Deposit::get()), - (ACCOUNT_01, ::Deposit::get()), + ( + ACCOUNT_00, + ::Deposit::get() + + <::Currency as Inspect>>::minimum_balance(), + ), + ( + ACCOUNT_01, + ::Deposit::get() + + <::Currency as Inspect>>::minimum_balance(), + ), ]) .build_and_execute_with_sanity_tests(|| { // Create delegation to root @@ -159,7 +177,10 @@ fn create_delegation_direct_root_successful() { generate_base_delegation_creation_operation(delegation_id, delegate_signature, delegation_node); // 1 Deposit should be reserved for hierarchy - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); // Add delegation to root assert_ok!(Delegation::add_delegation( @@ -173,7 +194,7 @@ fn create_delegation_direct_root_successful() { // 2 Deposits should be reserved for hierarchy and delegation to root assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); @@ -215,8 +236,16 @@ fn create_delegation_with_parent_successful() { )]) .with_delegations(vec![(parent_id, parent_node)]) .with_balances(vec![ - (ACCOUNT_00, ::Deposit::get()), - (ACCOUNT_01, ::Deposit::get()), + ( + ACCOUNT_00, + ::Deposit::get() + + <::Currency as Inspect>>::minimum_balance(), + ), + ( + ACCOUNT_01, + ::Deposit::get() + + <::Currency as Inspect>>::minimum_balance(), + ), ]) .build_and_execute_with_sanity_tests(|| { // Create sub-delegation @@ -235,7 +264,7 @@ fn create_delegation_with_parent_successful() { // Should have deposited for hierarchy and parent delegation assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); @@ -251,10 +280,10 @@ fn create_delegation_with_parent_successful() { // Should have deposited for hierarchy, parent delegation and sub-delegation assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 3 * ::Deposit::get() ); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); // Data in stored delegation and operation should match let stored_delegation = @@ -693,10 +722,13 @@ fn list_hierarchy_revoke_and_remove_root_successful() { .build_and_execute_with_sanity_tests(|| { assert!(Delegation::delegation_hierarchies(hierarchy_root_id).is_some()); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); // Revoke root assert_ok!(Delegation::revoke_delegation( @@ -737,8 +769,8 @@ fn list_hierarchy_revoke_and_remove_root_successful() { assert!(Delegation::delegation_hierarchies(hierarchy_root_id).is_none()); assert!(Delegation::delegation_nodes(parent_id).is_none()); assert!(Delegation::delegation_nodes(delegation_id).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); }); } @@ -806,10 +838,13 @@ fn tree_hierarchy_revoke_and_remove_root_successful() { ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); // Removing root should also remove children and hierarchy assert_ok!(Delegation::remove_delegation( @@ -822,8 +857,8 @@ fn tree_hierarchy_revoke_and_remove_root_successful() { assert!(Delegation::delegation_hierarchies(hierarchy_root_id).is_none()); assert!(Delegation::delegation_nodes(delegation1_id).is_none()); assert!(Delegation::delegation_nodes(delegation2_id).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); }); } @@ -888,10 +923,13 @@ fn max_max_revocations_revoke_and_remove_successful() { ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); // Removing root should also remove children and hierarchy assert_ok!(Delegation::remove_delegation( @@ -904,8 +942,8 @@ fn max_max_revocations_revoke_and_remove_successful() { assert!(Delegation::delegation_hierarchies(hierarchy_root_id).is_none()); assert!(Delegation::delegation_nodes(parent_id).is_none()); assert!(Delegation::delegation_nodes(delegation_id).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); }); } @@ -1066,7 +1104,10 @@ fn exact_children_max_revocations_revoke_and_remove_root_error() { (delegation3_id, delegation3_node), ]) .build_and_execute_with_sanity_tests(|| { - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); // Should not revoke root because tree traversal steps are insufficient // assert_err and not assert_noop because the storage is indeed changed, but @@ -1108,9 +1149,12 @@ fn exact_children_max_revocations_revoke_and_remove_root_error() { ); // Should not remove root because tree traversal steps are insufficient - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_eq!( - Balances::reserved_balance(ACCOUNT_01), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), 3 * ::Deposit::get() ); // assert_err and not assert_noop because the storage is indeed changed, but @@ -1128,9 +1172,12 @@ fn exact_children_max_revocations_revoke_and_remove_root_error() { assert!(Delegation::delegation_nodes(delegation1_id).is_some()); assert!(Delegation::delegation_nodes(delegation2_id).is_some()); assert!(Delegation::delegation_nodes(delegation3_id).is_some()); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_eq!( - Balances::reserved_balance(ACCOUNT_01), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), 3 * ::Deposit::get() ); @@ -1143,8 +1190,8 @@ fn exact_children_max_revocations_revoke_and_remove_root_error() { assert!(Delegation::delegation_nodes(operation.id).is_none()); assert!(Delegation::delegation_nodes(delegation1_id).is_none()); assert!(Delegation::delegation_nodes(delegation3_id).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); }); } @@ -1214,10 +1261,13 @@ fn direct_owner_revoke_and_remove_delegation_successful() { ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); // Removing root delegation should also remove its child but not hierarchy root assert_ok!(Delegation::remove_delegation( @@ -1230,8 +1280,11 @@ fn direct_owner_revoke_and_remove_delegation_successful() { assert!(Delegation::delegation_nodes(operation.delegation_id).is_none()); assert!(Delegation::delegation_nodes(parent_id).is_none()); assert!(Delegation::delegation_nodes(delegation_id).is_none()); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); }); } @@ -1271,10 +1324,13 @@ fn parent_owner_revoke_delegation_successful() { .build_and_execute_with_sanity_tests(|| { // Parent should not be able to remove the child delegation directly assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); assert_noop!( Delegation::remove_delegation( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -1316,10 +1372,10 @@ fn parent_owner_revoke_delegation_successful() { assert!(Delegation::delegation_nodes(parent_id).is_some()); assert!(Delegation::delegation_nodes(delegation_id).is_none()); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); }); } @@ -1449,9 +1505,18 @@ fn parent_too_far_revoke_and_remove_delegation_error() { ); // removal - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); - assert_eq!(Balances::reserved_balance(ACCOUNT_02), ::Deposit::get()); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_02), + ::Deposit::get() + ); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); assert_noop!( Delegation::remove_delegation( @@ -1560,8 +1625,8 @@ fn direct_owner_reclaim_deposit_delegation_successful() { assert!(Delegation::delegation_nodes(delegation_id).is_none()); // We have released all the deposits by deleting the root node. - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); }); } @@ -1595,10 +1660,13 @@ fn parent_owner_reclaim_deposit_error() { // Parent should not be able to claim the deposit for the child delegation // directly assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 2 * ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); assert_noop!( Delegation::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), @@ -1975,6 +2043,10 @@ fn is_delegating_delegation_not_found() { // Root -> Delegation 1 let mut ext = ExtBuilder::default() + .with_balances(vec![( + ACCOUNT_00, + <::Currency as Inspect>>::minimum_balance(), + )]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, user_1.clone(), ACCOUNT_00)]) .build(); @@ -2043,7 +2115,10 @@ fn remove_single_hierarchy() { .build_and_execute_with_sanity_tests(|| { assert!(Delegation::delegation_hierarchies(hierarchy_root_id).is_some()); assert!(Delegation::delegation_nodes(hierarchy_root_id).is_some()); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); // Remove assert_noop!( @@ -2061,7 +2136,7 @@ fn remove_single_hierarchy() { )); assert!(Delegation::delegation_hierarchies(hierarchy_root_id).is_none()); assert!(Delegation::delegation_nodes(hierarchy_root_id).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); }); } @@ -2113,12 +2188,18 @@ fn remove_children_gas_runs_out() { (delegation4_id, delegation4_node), ]) .build_and_execute_with_sanity_tests(|| { - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_eq!( - Balances::reserved_balance(ACCOUNT_01), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), 3 * ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_02), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_02), + ::Deposit::get() + ); // Should not be able to remove root because tree traversal steps are // insufficient @@ -2138,12 +2219,18 @@ fn remove_children_gas_runs_out() { assert!(Delegation::delegation_nodes(delegation2_id).is_some()); assert!(Delegation::delegation_nodes(delegation3_id).is_some()); assert!(Delegation::delegation_nodes(delegation4_id).is_some()); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_eq!( - Balances::reserved_balance(ACCOUNT_01), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), 3 * ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_02), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_02), + ::Deposit::get() + ); // Should be able to remove root only with depth = #_of_children + 1 assert_ok!(Delegation::remove_delegation( @@ -2155,9 +2242,9 @@ fn remove_children_gas_runs_out() { assert!(Delegation::delegation_nodes(delegation1_id).is_none()); assert!(Delegation::delegation_nodes(delegation2_id).is_none()); assert!(Delegation::delegation_nodes(delegation3_id).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); - assert!(Balances::reserved_balance(ACCOUNT_02).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_02).is_zero()); }); } @@ -2185,17 +2272,21 @@ fn test_change_deposit_owner() { ExtBuilder::default() .with_balances(vec![ (ACCOUNT_00, ::Deposit::get() * 2), - (ACCOUNT_01, ::Deposit::get()), + ( + ACCOUNT_01, + ::Deposit::get() + + <::Currency as Inspect>>::minimum_balance(), + ), ]) .with_ctypes(vec![(hierarchy_details.ctype_hash, root_owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, root_owner, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) .build_and_execute_with_sanity_tests(|| { assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 3 ); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); assert_ok!(Delegation::change_deposit_owner( DoubleOrigin(ACCOUNT_01, delegate).into(), delegation_id @@ -2203,10 +2294,13 @@ fn test_change_deposit_owner() { // ACCOUNT_00 has still one deposit (there are two nodes) assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 2 ); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); }); } @@ -2235,13 +2329,13 @@ fn test_change_deposit_owner_insufficient_balance() { .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) .build_and_execute_with_sanity_tests(|| { assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 3 ); - assert!(Balances::reserved_balance(ACCOUNT_01).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01).is_zero()); assert_noop!( Delegation::change_deposit_owner(DoubleOrigin(ACCOUNT_01, delegate).into(), delegation_id), - pallet_balances::Error::::InsufficientBalance + TokenError::CannotCreateHold ); }); } @@ -2338,7 +2432,7 @@ fn test_update_deposit() { .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) .build_and_execute_with_sanity_tests(|| { assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 3 ); assert_ok!(Delegation::update_deposit( @@ -2348,7 +2442,7 @@ fn test_update_deposit() { // ACCOUNT_00 has still one deposit (there are two nodes) assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 2 ); }); @@ -2380,7 +2474,7 @@ fn test_update_deposit_unauthorized() { .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) .build_and_execute_with_sanity_tests(|| { assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 3 ); assert_noop!( diff --git a/pallets/did/src/benchmarking.rs b/pallets/did/src/benchmarking.rs index e7ca5c1a73..326d7d915d 100644 --- a/pallets/did/src/benchmarking.rs +++ b/pallets/did/src/benchmarking.rs @@ -17,11 +17,10 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use super::*; - use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, Zero}; use frame_support::{ assert_ok, - traits::{Currency, ReservableCurrency}, + traits::fungible::{Inspect, Mutate, MutateHold}, }; use frame_system::RawOrigin; use parity_scale_codec::Encode; @@ -30,7 +29,7 @@ use sp_io::crypto::{ecdsa_generate, ecdsa_sign, ed25519_generate, ed25519_sign, use sp_runtime::{traits::IdentifyAccount, AccountId32, MultiSigner}; use sp_std::{convert::TryInto, vec::Vec}; -use kilt_support::{deposit::Deposit, signature::VerifySignature}; +use kilt_support::{signature::VerifySignature, Deposit}; use crate::{ did_details::{ @@ -42,7 +41,7 @@ use crate::{ }, service_endpoints::DidEndpoint, signature::DidSignatureVerify, - AccountIdOf, DidAuthorizedCallOperationOf, DidIdentifierOf, + AccountIdOf, DidAuthorizedCallOperationOf, DidIdentifierOf, HoldReason, }; const DEFAULT_ACCOUNT_ID: &str = "tx_submitter"; @@ -89,13 +88,16 @@ fn get_ecdsa_public_delegation_key() -> ecdsa::Public { ecdsa_generate(DELEGATION_KEY_ID, None) } -fn make_free_for_did(account: &AccountIdOf) { - let balance = as Currency>>::minimum_balance() +fn make_free_for_did(account: &AccountIdOf) +where + ::Currency: Mutate, +{ + let balance = as Inspect>>::minimum_balance() + ::BaseDeposit::get() + ::BaseDeposit::get() + ::BaseDeposit::get() + ::Fee::get(); - as Currency>>::make_free_balance_be(account, balance); + as Mutate>>::set_balance(account, balance); } // Must always be dispatched with the DID authentication key @@ -127,6 +129,7 @@ benchmarks! { T::DidIdentifier: From, ::RuntimeOrigin: From>, ::AccountId: From, + ::Currency: Mutate } /* create extrinsic */ @@ -1145,7 +1148,7 @@ benchmarks! { did_details.deposit.owner = did_account.clone(); make_free_for_did::(&did_account); - CurrencyOf::::reserve(&did_account, did_details.deposit.amount).expect("should reserve currency"); + CurrencyOf::::hold(&HoldReason::Deposit.into(), &did_account, did_details.deposit.amount).expect("should reserve currency"); Did::::insert(&did_subject, did_details); let origin = RawOrigin::Signed(did_subject.clone()); @@ -1171,7 +1174,7 @@ benchmarks! { Did::::insert(&did_subject, did_details.clone()); make_free_for_did::(&did_account); - CurrencyOf::::reserve(&did_account, did_details.deposit.amount).expect("should reserve currency"); + CurrencyOf::::hold(&HoldReason::Deposit.into(), &did_account, did_details.deposit.amount).expect("should reserve currency"); let origin = RawOrigin::Signed(did_subject.clone()); let did_to_update = did_subject.clone(); diff --git a/pallets/did/src/did_details.rs b/pallets/did/src/did_details.rs index 7f7c46f805..34a55c86f9 100644 --- a/pallets/did/src/did_details.rs +++ b/pallets/did/src/did_details.rs @@ -23,7 +23,7 @@ use frame_support::{ traits::Get, RuntimeDebug, }; -use kilt_support::deposit::Deposit; +use kilt_support::{traits::StorageDepositCollector, Deposit}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen, WrapperTypeEncode}; use scale_info::TypeInfo; use sp_core::{ecdsa, ed25519, sr25519}; @@ -35,8 +35,8 @@ use sp_std::{convert::TryInto, vec::Vec}; use crate::{ errors::{self, DidError}, - utils, AccountIdOf, BalanceOf, BlockNumberOf, Config, CurrencyOf, DidAuthorizedCallOperationOf, - DidCreationDetailsOf, DidEndpointsCount, DidIdentifierOf, KeyIdOf, Payload, + utils, AccountIdOf, BalanceOf, BlockNumberOf, Config, DidAuthorizedCallOperationOf, DidCreationDetailsOf, + DidDepositCollector, DidEndpointsCount, DidIdentifierOf, KeyIdOf, Payload, }; /// Types of verification keys a DID can control. @@ -343,19 +343,16 @@ impl DidDetails { match new_required_deposit.cmp(&self.deposit.amount) { Ordering::Greater => { let deposit_to_reserve = new_required_deposit.saturating_sub(self.deposit.amount); - kilt_support::reserve_deposit::, CurrencyOf>( - self.deposit.owner.clone(), - deposit_to_reserve, - )?; + DidDepositCollector::::create_deposit(self.deposit.clone().owner, deposit_to_reserve)?; self.deposit.amount = self.deposit.amount.saturating_add(deposit_to_reserve); } Ordering::Less => { let deposit_to_release = self.deposit.amount.saturating_sub(new_required_deposit); - let deposit = Deposit { + + DidDepositCollector::::free_deposit(Deposit { owner: self.deposit.owner.clone(), amount: deposit_to_release, - }; - kilt_support::free_deposit::, CurrencyOf>(&deposit); + })?; self.deposit.amount = self.deposit.amount.saturating_sub(deposit_to_release); } _ => (), @@ -400,7 +397,7 @@ impl DidDetails { let deposit_amount = new_did_details.calculate_deposit(did_subject); new_did_details.deposit.amount = deposit_amount; - kilt_support::reserve_deposit::, CurrencyOf>(details.submitter, deposit_amount)?; + DidDepositCollector::::create_deposit(details.submitter, deposit_amount)?; Ok(new_did_details) } diff --git a/pallets/did/src/lib.rs b/pallets/did/src/lib.rs index 5153926ccc..e6696cd824 100644 --- a/pallets/did/src/lib.rs +++ b/pallets/did/src/lib.rs @@ -80,14 +80,15 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::unused_unit)] +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; pub mod default_weights; pub mod did_details; pub mod errors; +pub mod migrations; pub mod origin; pub mod service_endpoints; -#[cfg(feature = "runtime-benchmarks")] -pub mod benchmarking; #[cfg(test)] mod mock; #[cfg(any(feature = "runtime-benchmarks", test))] @@ -119,7 +120,7 @@ use frame_support::{ dispatch::{DispatchError, DispatchResult, Dispatchable, GetDispatchInfo, PostDispatchInfo}, ensure, storage::types::StorageMap, - traits::{Get, OnUnbalanced, WithdrawReasons}, + traits::{Get, OnUnbalanced}, Parameter, }; use frame_system::ensure_signed; @@ -140,12 +141,16 @@ pub mod pallet { use did_details::DidCreationDetails; use frame_support::{ pallet_prelude::*, - traits::{Currency, ExistenceRequirement, Imbalance, ReservableCurrency, StorageVersion}, + traits::{ + fungible::{Balanced, Credit, Inspect, MutateHold}, + tokens::{Fortitude, Precision, Preservation}, + StorageVersion, + }, }; use frame_system::pallet_prelude::*; use kilt_support::{ - deposit::Deposit, traits::{CallSources, StorageDepositCollector}, + Deposit, }; use service_endpoints::DidEndpoint; use sp_runtime::traits::BadOrigin; @@ -159,7 +164,7 @@ pub mod pallet { }; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); + pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(5); /// Reference to a payload of data of variable size. pub type Payload = [u8]; @@ -183,9 +188,14 @@ pub mod pallet { #[pallet::origin] pub type Origin = DidRawOrigin, AccountIdOf>; - pub type BalanceOf = as Currency>>::Balance; + pub type BalanceOf = as Inspect>>::Balance; pub(crate) type CurrencyOf = ::Currency; - pub(crate) type NegativeImbalanceOf = <::Currency as Currency>>::NegativeImbalance; + pub(crate) type CreditOf = Credit<::AccountId, ::Currency>; + + #[pallet::composite_enum] + pub enum HoldReason { + Deposit, + } pub(crate) type DidCreationDetailsOf = DidCreationDetails, AccountIdOf, ::MaxNewKeyAgreementKeys, DidEndpoint>; @@ -223,8 +233,10 @@ pub mod pallet { /// Overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeHoldReason: From; + /// The currency that is used to reserve funds for each did. - type Currency: ReservableCurrency>; + type Currency: Balanced> + MutateHold, Reason = Self::RuntimeHoldReason>; /// The amount of balance that will be taken for each DID as a deposit /// to incentivise fair use of the on chain storage. The deposits @@ -252,7 +264,7 @@ pub mod pallet { type Fee: Get>; /// The logic for handling the fee. - type FeeCollector: OnUnbalanced>; + type FeeCollector: OnUnbalanced>; /// Maximum number of total public keys which can be stored per DID key /// identifier. This includes the ones currently used for @@ -588,16 +600,16 @@ pub mod pallet { Did::::insert(&did_identifier, did_entry.clone()); - // Withdraw the fee. We made sure that enough balance is available. But if this - // fails, we don't withdraw anything. - let imbalance = >>::withdraw( + let imbalance: CreditOf = >>::withdraw( &did_entry.deposit.owner, T::Fee::get(), - WithdrawReasons::FEE, - ExistenceRequirement::AllowDeath, - ) - .unwrap_or_else(|_| NegativeImbalanceOf::::zero()); + Precision::Exact, + Preservation::Preserve, + Fortitude::Polite, + )?; + T::FeeCollector::on_unbalanced(imbalance); + Self::deposit_event(Event::DidCreated(sender, did_identifier)); Ok(()) @@ -1250,7 +1262,7 @@ pub mod pallet { let did_entry = Did::::take(&did_subject).ok_or(Error::::NotFound)?; DidEndpointsCount::::remove(&did_subject); - kilt_support::free_deposit::, CurrencyOf>(&did_entry.deposit); + DidDepositCollector::::free_deposit(did_entry.deposit)?; // Mark as deleted to prevent potential replay-attacks of re-adding a previously // deleted DID. DidBlacklist::::insert(&did_subject, ()); @@ -1263,18 +1275,25 @@ pub mod pallet { } } - struct DidDepositCollector(PhantomData); - impl StorageDepositCollector, DidIdentifierOf> for DidDepositCollector { - type Currency = T::Currency; + pub(crate) struct DidDepositCollector(PhantomData); + impl StorageDepositCollector, DidIdentifierOf, T::RuntimeHoldReason> + for DidDepositCollector + { + type Currency = ::Currency; + type Reason = HoldReason; + + fn reason() -> Self::Reason { + HoldReason::Deposit + } fn deposit( key: &DidIdentifierOf, - ) -> Result, >>::Balance>, DispatchError> { + ) -> Result, >>::Balance>, DispatchError> { let did_entry = Did::::get(key).ok_or(Error::::NotFound)?; Ok(did_entry.deposit) } - fn deposit_amount(key: &DidIdentifierOf) -> >>::Balance { + fn deposit_amount(key: &DidIdentifierOf) -> >>::Balance { let did_entry = Did::::get(key); match did_entry { Some(entry) => entry.calculate_deposit(key), @@ -1285,7 +1304,7 @@ pub mod pallet { fn store_deposit( key: &DidIdentifierOf, - deposit: Deposit, >>::Balance>, + deposit: Deposit, >>::Balance>, ) -> Result<(), DispatchError> { let did_entry = Did::::get(key).ok_or(Error::::NotFound)?; Did::::insert(key, DidDetails { deposit, ..did_entry }); diff --git a/pallets/did/src/migrations.rs b/pallets/did/src/migrations.rs new file mode 100644 index 0000000000..096d563af8 --- /dev/null +++ b/pallets/did/src/migrations.rs @@ -0,0 +1,147 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + traits::{Get, GetStorageVersion, OnRuntimeUpgrade, ReservableCurrency, StorageVersion}, + weights::Weight, +}; +use kilt_support::migration::switch_reserved_to_hold; +use log; +use sp_runtime::SaturatedConversion; +use sp_std::marker::PhantomData; + +use crate::{AccountIdOf, Config, CurrencyOf, Did, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION}; + +const CURRENT_STORAGE_VERSION: StorageVersion = StorageVersion::new(4); + +pub struct BalanceMigration(PhantomData); + +impl OnRuntimeUpgrade for BalanceMigration +where + ::Currency: ReservableCurrency, +{ + fn on_runtime_upgrade() -> frame_support::weights::Weight { + log::info!("Did: Initiating migration"); + + let onchain_storage_version = Pallet::::on_chain_storage_version(); + if onchain_storage_version == CURRENT_STORAGE_VERSION { + TARGET_STORAGE_VERSION.put::>(); + ::DbWeight::get() + .reads_writes(1, 1) + .saturating_add(do_migration::()) + } else { + log::info!( + "Did: No migration needed. This file should be deleted. Current storage version: {:?}, Required Version for update: {:?}", + onchain_storage_version, + CURRENT_STORAGE_VERSION + ); + ::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + use frame_support::ensure; + use sp_std::vec; + + let has_all_user_no_holds = Did::::iter_values() + .map(|details: crate::did_details::DidDetails| { + kilt_support::migration::has_user_reserved_balance::, CurrencyOf>( + &details.deposit.owner, + &HoldReason::Deposit.into(), + ) + }) + .all(|user| user); + + ensure!(has_all_user_no_holds, "Pre Upgrade Did: there are users with holds!"); + + assert_eq!(Pallet::::on_chain_storage_version(), CURRENT_STORAGE_VERSION); + + log::info!("Did: Pre migration checks successful"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_pre_state: sp_std::vec::Vec) -> Result<(), &'static str> { + use frame_support::traits::fungible::InspectHold; + use sp_runtime::Saturating; + use sp_std::collections::btree_map::BTreeMap; + + use crate::BalanceOf; + + let mut map_user_deposit: BTreeMap, BalanceOf> = BTreeMap::new(); + + Did::::iter_values().for_each(|details| { + map_user_deposit + .entry(details.deposit.owner) + .and_modify(|balance| *balance = balance.saturating_add(details.deposit.amount)) + .or_insert(details.deposit.amount); + }); + + map_user_deposit + .iter() + .try_for_each(|(who, amount)| -> Result<(), &'static str> { + let hold_balance: BalanceOf = + ::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into(); + + assert!( + amount.eq(&hold_balance), + "Did: Hold balance is not matching for attestation {:?}. Expected hold: {:?}. Real hold: {:?}", + who, + amount, + hold_balance + ); + Ok(()) + })?; + + assert_eq!(Pallet::::on_chain_storage_version(), TARGET_STORAGE_VERSION); + + log::info!("Did: Post migration checks successful"); + Ok(()) + } +} + +fn do_migration() -> Weight +where + ::Currency: ReservableCurrency, +{ + Did::::iter() + .map(|(key, did_details)| -> Weight { + let deposit = did_details.deposit; + let result = switch_reserved_to_hold::, CurrencyOf>( + deposit.owner, + &HoldReason::Deposit.into(), + deposit.amount.saturated_into(), + ); + + if result.is_err() { + log::error!( + " Did: Could not convert reserves to hold from did: {:?} error: {:?}", + key, + result + ); + } + + // Currency::reserve and Currency::hold each read and write to the DB once. + // Since we are uncertain about which operation may fail, in the event of an + // error, we assume the worst-case scenario here. + ::DbWeight::get().reads_writes(2, 2) + }) + .fold(Weight::zero(), |acc, next| acc.saturating_add(next)) +} diff --git a/pallets/did/src/mock.rs b/pallets/did/src/mock.rs index cd102e6f70..0521533153 100644 --- a/pallets/did/src/mock.rs +++ b/pallets/did/src/mock.rs @@ -16,13 +16,19 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org +#[cfg(not(feature = "runtime-benchmarks"))] +use crate::{DidRawOrigin, EnsureDidOrigin}; + use frame_support::{ parameter_types, - traits::{Currency, OnUnbalanced, ReservableCurrency}, + traits::{ + fungible::{Balanced, Credit, MutateHold}, + OnUnbalanced, + }, weights::constants::RocksDbWeight, }; use frame_system::EnsureSigned; -use pallet_balances::NegativeImbalance; +use pallet_balances::Pallet as PalletBalance; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_core::{ecdsa, ed25519, sr25519, Pair}; @@ -42,10 +48,9 @@ use crate::{ RelationshipDeriveError, }, service_endpoints::DidEndpoint, - utils as crate_utils, AccountIdOf, Config, CurrencyOf, DidBlacklist, DidEndpointsCount, KeyIdOf, ServiceEndpoints, + utils as crate_utils, AccountIdOf, Config, CurrencyOf, DidBlacklist, DidEndpointsCount, HoldReason, KeyIdOf, + ServiceEndpoints, }; -#[cfg(not(feature = "runtime-benchmarks"))] -use crate::{DidRawOrigin, EnsureDidOrigin}; pub(crate) type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; pub(crate) type Block = frame_system::mocking::MockBlock; @@ -56,7 +61,7 @@ pub(crate) type AccountPublic = ::Signer; pub(crate) type AccountId = ::AccountId; pub(crate) type Index = u64; pub(crate) type BlockNumber = u64; - +type CreditOf = Credit<::AccountId, PalletBalance>; pub(crate) type DidIdentifier = AccountId; pub(crate) type CtypeHash = Hash; @@ -70,7 +75,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - Did: did::{Pallet, Call, Storage, Event, Origin}, + Did: did::{Pallet, Call, Storage, HoldReason, Event, Origin}, Ctype: ctype::{Pallet, Call, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Event}, System: frame_system::{Pallet, Call, Config, Storage, Event}, @@ -133,13 +138,13 @@ parameter_types! { pub struct ToAccount(sp_std::marker::PhantomData); -impl OnUnbalanced> for ToAccount +impl OnUnbalanced> for ToAccount where R: pallet_balances::Config, ::AccountId: From, { - fn on_nonzero_unbalanced(amount: NegativeImbalance) { - pallet_balances::Pallet::::resolve_creating(&ACCOUNT_FEE.into(), amount); + fn on_nonzero_unbalanced(amount: CreditOf) { + let _ = pallet_balances::Pallet::::resolve(&ACCOUNT_FEE.into(), amount); } } @@ -149,6 +154,7 @@ impl Config for Test { type RuntimeCall = RuntimeCall; type EnsureOrigin = EnsureSigned; type KeyDeposit = KeyDeposit; + type RuntimeHoldReason = RuntimeHoldReason; type ServiceEndpointDeposit = KeyDeposit; type OriginSuccess = AccountId; type RuntimeEvent = (); @@ -173,9 +179,15 @@ parameter_types! { pub const ExistentialDeposit: Balance = 500; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; } impl pallet_balances::Config for Test { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; type Balance = Balance; type DustRemoval = (); type RuntimeEvent = (); @@ -493,7 +505,7 @@ impl ExtBuilder { for did in self.dids_stored.iter() { did::Did::::insert(&did.0, did.1.clone()); - CurrencyOf::::reserve(&did.1.deposit.owner, did.1.deposit.amount) + CurrencyOf::::hold(&HoldReason::Deposit.into(), &did.1.deposit.owner, did.1.deposit.amount) .expect("Deposit owner should have enough balance"); } for did in self.deleted_dids.iter() { @@ -521,7 +533,7 @@ impl ExtBuilder { pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(None); - let keystore = sp_keystore::testing::KeyStore::new(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); ext diff --git a/pallets/did/src/mock_utils.rs b/pallets/did/src/mock_utils.rs index b64fe77d93..09a1a89a61 100644 --- a/pallets/did/src/mock_utils.rs +++ b/pallets/did/src/mock_utils.rs @@ -17,7 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::storage::bounded_btree_set::BoundedBTreeSet; -use kilt_support::deposit::Deposit; +use kilt_support::Deposit; use sp_runtime::{traits::Zero, AccountId32, SaturatedConversion}; use sp_std::{ collections::btree_set::BTreeSet, diff --git a/pallets/did/src/tests.rs b/pallets/did/src/tests.rs index 353274201f..bb8084a43d 100644 --- a/pallets/did/src/tests.rs +++ b/pallets/did/src/tests.rs @@ -16,12 +16,15 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::{assert_err, assert_noop, assert_ok, traits::Currency}; +use frame_support::{ + assert_err, assert_noop, assert_ok, + traits::fungible::{Inspect, InspectHold}, +}; use parity_scale_codec::Encode; use sp_core::{ed25519, Pair}; use sp_runtime::{ traits::{BadOrigin, Hash, Zero}, - SaturatedConversion, + SaturatedConversion, TokenError, }; use sp_std::{ collections::btree_set::BTreeSet, @@ -34,7 +37,7 @@ use crate::{ mock::*, mock_utils::*, service_endpoints::DidEndpoint, - Error, + Error, HoldReason, }; // create @@ -50,7 +53,7 @@ fn check_successful_simple_ed25519_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -74,11 +77,11 @@ fn check_successful_simple_ed25519_creation() { assert_eq!(stored_did.last_tx_counter, 0u64); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() ); - assert_eq!(Balances::free_balance(ACCOUNT_FEE), ::Fee::get()); + assert_eq!(Balances::balance(&ACCOUNT_FEE), ::Fee::get()); }); } @@ -93,7 +96,7 @@ fn check_successful_simple_sr25519_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -117,10 +120,10 @@ fn check_successful_simple_sr25519_creation() { assert_eq!(stored_did.last_tx_counter, 0u64); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() ); - assert_eq!(Balances::free_balance(ACCOUNT_FEE), ::Fee::get()); + assert_eq!(Balances::balance(&ACCOUNT_FEE), ::Fee::get()); }); } @@ -135,7 +138,7 @@ fn check_successful_simple_ecdsa_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -159,10 +162,10 @@ fn check_successful_simple_ecdsa_creation() { assert_eq!(stored_did.last_tx_counter, 0u64); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() ); - assert_eq!(Balances::free_balance(ACCOUNT_FEE), ::Fee::get()); + assert_eq!(Balances::balance(&ACCOUNT_FEE), ::Fee::get()); }); } @@ -206,7 +209,7 @@ fn check_successful_complete_creation() { + required_balance_for_key_agreement + ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) @@ -275,13 +278,13 @@ fn check_successful_complete_creation() { ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() + required_balance_for_endpoint + required_balance_for_key_agreement + required_balance_for_keys ); - assert_eq!(Balances::free_balance(ACCOUNT_FEE), ::Fee::get()); + assert_eq!(Balances::balance(&ACCOUNT_FEE), ::Fee::get()); }); } @@ -297,7 +300,9 @@ fn check_deposit_change_by_adding_service_endpoint() { let new_service_endpoint2: DidEndpoint = DidEndpoint::new(b"id2".to_vec(), vec![b"type2".to_vec()], vec![b"url2".to_vec()]); - let balance = ::BaseDeposit::get() + ::ServiceEndpointDeposit::get(); + let balance = ::BaseDeposit::get() + + ::ServiceEndpointDeposit::get() + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(alice_did.clone(), balance)]) @@ -310,15 +315,18 @@ fn check_deposit_change_by_adding_service_endpoint() { )); assert_eq!( - Balances::reserved_balance(alice_did.clone()), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &alice_did), ::ServiceEndpointDeposit::get() + ::BaseDeposit::get() ); - assert_eq!(Balances::free_balance(alice_did.clone()), Zero::zero()); + assert_eq!( + Balances::balance(&alice_did), + <::Currency as Inspect>>::minimum_balance() + ); assert_noop!( Did::add_service_endpoint(RuntimeOrigin::signed(alice_did.clone()), new_service_endpoint2.clone()), - pallet_balances::Error::::InsufficientBalance + TokenError::FundsUnavailable ); assert!(did::ServiceEndpoints::::get(alice_did.clone(), new_service_endpoint.id).is_some()); @@ -332,14 +340,14 @@ fn check_duplicate_did_creation() { let auth_key = get_sr25519_authentication_key(true); let alice_did = get_did_identifier_from_sr25519_key(auth_key.public()); let auth_did_key = DidVerificationKey::from(auth_key.public()); - let mock_did = generate_base_did_details::(auth_did_key, None); + let mock_did = generate_base_did_details::(auth_did_key, Some(ACCOUNT_00)); let details = generate_base_did_creation_details::(alice_did.clone(), ACCOUNT_00); let signature = auth_key.sign(details.encode().as_ref()); let balance = ::BaseDeposit::get() * 20 + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did, mock_did)]) @@ -360,15 +368,15 @@ fn check_unauthorised_submitter_did_creation_error() { let auth_key = get_sr25519_authentication_key(true); let alice_did = get_did_identifier_from_sr25519_key(auth_key.public()); let auth_did_key = DidVerificationKey::from(auth_key.public()); - let mock_did = generate_base_did_details::(auth_did_key, None); + let mock_did = generate_base_did_details::(auth_did_key, Some(ACCOUNT_00)); // Use ACCOUNT_01 to generate the DID creation operation let details = generate_base_did_creation_details::(alice_did.clone(), ACCOUNT_01); let signature = auth_key.sign(details.encode().as_ref()); - let balance = ::BaseDeposit::get() + let balance = ::BaseDeposit::get() * 2 + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did, mock_did)]) @@ -415,7 +423,7 @@ fn check_did_already_deleted_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_deleted_dids(vec![alice_did]) @@ -444,7 +452,7 @@ fn check_invalid_signature_format_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -470,7 +478,7 @@ fn check_invalid_signature_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -496,7 +504,7 @@ fn check_swapped_did_subject_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -525,7 +533,7 @@ fn check_max_limit_key_agreement_keys_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build(None) @@ -561,7 +569,7 @@ fn check_max_limit_service_endpoints_count_did_creation() { let balance = required_balance_for_service_endpoints + ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -589,7 +597,7 @@ fn check_max_limit_service_id_length_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build(None) @@ -624,7 +632,7 @@ fn check_max_limit_service_type_count_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build(None) @@ -653,7 +661,7 @@ fn check_max_limit_service_type_length_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build(None) @@ -688,7 +696,7 @@ fn check_max_limit_service_url_count_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build(None) @@ -717,7 +725,7 @@ fn check_max_limit_service_url_length_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build(None) @@ -746,7 +754,7 @@ fn check_invalid_service_id_character_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() + ::ServiceEndpointDeposit::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -774,7 +782,7 @@ fn check_invalid_service_type_character_did_creation() { let balance = ::BaseDeposit::get() + ::Fee::get() + ::ServiceEndpointDeposit::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -802,7 +810,7 @@ fn check_invalid_service_url_character_did_creation() { let balance = ::BaseDeposit::get() + ::ServiceEndpointDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -1128,7 +1136,8 @@ fn check_max_public_keys_delegation_key_addition_error() { let new_del_key = get_sr25519_delegation_key(false); let key_agreement_keys = get_key_agreement_keys::(MaxTotalKeyAgreementKeys::get()); - let mut did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); assert_ok!(did_details.add_key_agreement_keys(key_agreement_keys, 0u64,)); // Fill public key map to its max by adding @@ -1139,6 +1148,7 @@ fn check_max_public_keys_delegation_key_addition_error() { // Update delegation key. The old one should be removed. ExtBuilder::default() + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(alice_did.clone(), did_details)]) .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); @@ -1160,7 +1170,8 @@ fn check_max_public_keys_reused_key_delegation_key_update_error() { let new_del_key = get_sr25519_delegation_key(true); let key_agreement_keys = get_key_agreement_keys::(MaxTotalKeyAgreementKeys::get()); - let mut did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); assert_ok!(did_details.add_key_agreement_keys(key_agreement_keys, 0u64,)); // Same key for auth and delegation assert_ok!(did_details.update_delegation_key(DidVerificationKey::from(old_del_key.public()), 0u64)); @@ -1175,6 +1186,7 @@ fn check_max_public_keys_reused_key_delegation_key_update_error() { // as authentication key. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_noop!( @@ -1279,9 +1291,11 @@ fn check_key_not_present_delegation_key_deletion_error() { let auth_key = get_ed25519_authentication_key(true); let alice_did = get_did_identifier_from_ed25519_key(auth_key.public()); - let old_did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let old_did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); ExtBuilder::default() + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(alice_did.clone(), old_did_details)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -1417,7 +1431,8 @@ fn check_max_public_keys_attestation_key_addition_error() { let new_att_key = get_sr25519_attestation_key(false); let key_agreement_keys = get_key_agreement_keys::(MaxTotalKeyAgreementKeys::get()); - let mut did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); assert_ok!(did_details.add_key_agreement_keys(key_agreement_keys, 0u64,)); // Fill public key map to its max by adding @@ -1428,6 +1443,7 @@ fn check_max_public_keys_attestation_key_addition_error() { // Update attestation key. The old one should be removed. ExtBuilder::default() + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(alice_did.clone(), did_details)]) .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); @@ -1449,7 +1465,8 @@ fn check_max_public_keys_reused_key_attestation_key_update_error() { let new_att_key = get_sr25519_delegation_key(true); let key_agreement_keys = get_key_agreement_keys::(MaxTotalKeyAgreementKeys::get()); - let mut did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); assert_ok!(did_details.add_key_agreement_keys(key_agreement_keys, 0u64,)); // Same key for auth and attestation assert_ok!(did_details.update_attestation_key(DidVerificationKey::from(old_att_key.public()), 0u64)); @@ -1463,6 +1480,7 @@ fn check_max_public_keys_reused_key_attestation_key_update_error() { // Update attestation key. The old one should not be removed as it is still used // as authentication key. ExtBuilder::default() + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(alice_did.clone(), did_details)]) .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); @@ -1567,9 +1585,11 @@ fn check_key_not_present_attestation_key_deletion_error() { let auth_key = get_ed25519_authentication_key(true); let alice_did = get_did_identifier_from_ed25519_key(auth_key.public()); - let old_did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let old_did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); ExtBuilder::default() + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(alice_did.clone(), old_did_details)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -1621,7 +1641,8 @@ fn check_max_public_keys_key_agreement_key_addition_error() { let key_agreement_keys = get_key_agreement_keys::(MaxTotalKeyAgreementKeys::get()); let new_key_agreement_key = get_x25519_encryption_key(true); - let mut did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); assert_ok!(did_details.add_key_agreement_keys(key_agreement_keys, 0u64,)); // Fill public key map to its max by adding @@ -1631,6 +1652,7 @@ fn check_max_public_keys_key_agreement_key_addition_error() { let new_block_number: BlockNumber = 1; ExtBuilder::default() + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(alice_did.clone(), did_details)]) .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); @@ -1711,9 +1733,11 @@ fn check_key_not_found_key_agreement_key_deletion_error() { let test_enc_key = get_x25519_encryption_key(true); // No enc key added - let old_did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let old_did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); ExtBuilder::default() + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(alice_did.clone(), old_did_details)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -1849,7 +1873,8 @@ fn check_max_services_count_addition_error() { ); let new_service_endpoint = DidEndpoint::new(b"id".to_vec(), vec![b"type".to_vec()], vec![b"url".to_vec()]); - let old_did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let old_did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); ExtBuilder::default() .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) @@ -2029,7 +2054,8 @@ fn check_invalid_service_type_character_addition_error() { let alice_did = get_did_identifier_from_ed25519_key(auth_key.public()); let new_service_details = DidEndpoint::new(b"id".to_vec(), vec!["å".bytes().collect()], vec![b"url".to_vec()]); - let old_did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let old_did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); ExtBuilder::default() .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) @@ -2048,9 +2074,11 @@ fn check_invalid_service_url_character_addition_error() { let alice_did = get_did_identifier_from_ed25519_key(auth_key.public()); let new_service_details = DidEndpoint::new(b"id".to_vec(), vec![b"type".to_vec()], vec!["å".bytes().collect()]); - let old_did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let old_did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); ExtBuilder::default() + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(alice_did.clone(), old_did_details)]) .build_and_execute_with_sanity_tests(None, || { @@ -2097,10 +2125,12 @@ fn check_service_not_present_deletion_error() { let alice_did = get_did_identifier_from_ed25519_key(auth_key.public()); let service_id = b"id".to_vec(); - let old_did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let old_did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) + .with_balances(vec![(alice_did.clone(), DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::remove_service_endpoint( @@ -2125,7 +2155,7 @@ fn check_successful_deletion_no_endpoints() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) @@ -2133,13 +2163,13 @@ fn check_successful_deletion_no_endpoints() { .build_and_execute_with_sanity_tests(None, || { assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 0); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() ); assert_ok!(Did::delete(RuntimeOrigin::signed(alice_did.clone()), 0)); assert!(Did::get_did(alice_did.clone()).is_none()); assert!(Did::get_deleted_did(alice_did.clone()).is_some()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 0); @@ -2171,7 +2201,7 @@ fn check_successful_deletion_with_endpoints() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) @@ -2180,13 +2210,13 @@ fn check_successful_deletion_with_endpoints() { .build_and_execute_with_sanity_tests(None, || { assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 1); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() ); assert_ok!(Did::delete(RuntimeOrigin::signed(alice_did.clone()), 1)); assert!(Did::get_did(alice_did.clone()).is_none()); assert!(Did::get_deleted_did(alice_did.clone()).is_some()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 0); @@ -2213,7 +2243,7 @@ fn check_did_not_present_deletion() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .build_and_execute_with_sanity_tests(None, || { @@ -2236,7 +2266,7 @@ fn check_service_count_too_small_deletion_error() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) @@ -2263,7 +2293,7 @@ fn check_successful_reclaiming() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) @@ -2272,7 +2302,7 @@ fn check_successful_reclaiming() { .build_and_execute_with_sanity_tests(None, || { assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 1); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() ); assert_ok!(Did::reclaim_deposit( @@ -2282,7 +2312,7 @@ fn check_successful_reclaiming() { )); assert!(Did::get_did(alice_did.clone()).is_none()); assert!(Did::get_deleted_did(alice_did.clone()).is_some()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 0); // Re-adding the same DID identifier should fail. @@ -2311,14 +2341,14 @@ fn unauthorized_reclaiming() { let balance = ::BaseDeposit::get() + ::Fee::get() - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) .build_and_execute_with_sanity_tests(None, || { assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() ); assert_noop!( @@ -2340,7 +2370,7 @@ fn check_service_count_too_small_reclaim_error() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) @@ -2383,7 +2413,8 @@ fn check_too_small_tx_counter_after_wrap_call_error() { let auth_key = get_sr25519_authentication_key(true); let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); // After wrapping tx_counter becomes 0 again. mock_did.last_tx_counter = 0u64; @@ -2396,6 +2427,7 @@ fn check_too_small_tx_counter_after_wrap_call_error() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -2414,7 +2446,8 @@ fn check_too_small_tx_counter_call_error() { let auth_key = get_sr25519_authentication_key(true); let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); mock_did.last_tx_counter = 1u64; let mut call_operation = generate_test_did_call( @@ -2426,6 +2459,7 @@ fn check_too_small_tx_counter_call_error() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -2444,7 +2478,7 @@ fn check_equal_tx_counter_call_error() { let auth_key = get_sr25519_authentication_key(true); let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let mut call_operation = generate_test_did_call( DidVerificationKeyRelationship::Authentication, @@ -2455,6 +2489,7 @@ fn check_equal_tx_counter_call_error() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -2473,7 +2508,7 @@ fn check_too_large_tx_counter_call_error() { let auth_key = get_sr25519_authentication_key(true); let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let mut call_operation = generate_test_did_call( DidVerificationKeyRelationship::Authentication, @@ -2484,6 +2519,7 @@ fn check_too_large_tx_counter_call_error() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -2503,7 +2539,7 @@ fn check_tx_block_number_too_low_error() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call( DidVerificationKeyRelationship::Authentication, @@ -2513,6 +2549,7 @@ fn check_tx_block_number_too_low_error() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { // System block number 1 past the max block the operation was allowed for. @@ -2542,7 +2579,7 @@ fn check_tx_block_number_too_high_error() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let mut call_operation = generate_test_did_call( DidVerificationKeyRelationship::Authentication, @@ -2554,6 +2591,7 @@ fn check_tx_block_number_too_high_error() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { // System block number is still too low, meaning that the block number used in @@ -2575,7 +2613,7 @@ fn check_verification_key_not_present_call_error() { let auth_key = get_sr25519_authentication_key(true); let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); // The operation requires the delegation key that is currently not stored for // the given DID. @@ -2587,7 +2625,8 @@ fn check_verification_key_not_present_call_error() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() - .with_dids(vec![(did, mock_did)]) + .with_dids(vec![(did.clone(), mock_did)]) + .with_balances(vec![(did, DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( @@ -2606,7 +2645,7 @@ fn check_invalid_signature_format_call_error() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; let alternative_auth_key = get_ed25519_authentication_key(true); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call( DidVerificationKeyRelationship::Authentication, @@ -2616,6 +2655,7 @@ fn check_invalid_signature_format_call_error() { let signature = alternative_auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -2635,7 +2675,7 @@ fn check_bad_submitter_error() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; let alternative_auth_key = get_sr25519_authentication_key(false); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let submitter = ACCOUNT_01; @@ -2643,7 +2683,8 @@ fn check_bad_submitter_error() { let signature = alternative_auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() - .with_dids(vec![(did, mock_did)]) + .with_dids(vec![(did.clone(), mock_did)]) + .with_balances(vec![(did, DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( @@ -2662,7 +2703,7 @@ fn check_invalid_signature_call_error() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; let alternative_auth_key = get_sr25519_authentication_key(false); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call( DidVerificationKeyRelationship::Authentication, @@ -2672,6 +2713,7 @@ fn check_invalid_signature_call_error() { let signature = alternative_auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -2692,7 +2734,8 @@ fn check_call_attestation_key_successful() { let caller = ACCOUNT_00; let attestation_key = get_ed25519_attestation_key(true); - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); assert_ok!(mock_did.update_attestation_key(DidVerificationKey::from(attestation_key.public()), 0)); let call_operation = generate_test_did_call( @@ -2703,6 +2746,7 @@ fn check_call_attestation_key_successful() { let signature = attestation_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::submit_did_call( @@ -2720,7 +2764,8 @@ fn check_call_attestation_key_error() { let caller = ACCOUNT_00; let attestation_key = get_ed25519_attestation_key(true); - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); assert_ok!(mock_did.update_attestation_key(DidVerificationKey::from(attestation_key.public()), 0)); let call_operation = generate_test_did_call( @@ -2731,6 +2776,7 @@ fn check_call_attestation_key_error() { let signature = attestation_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did.clone(), mock_did)]) .with_ctypes(vec![( ::Hashing::hash(&get_attestation_key_test_input()[..]), @@ -2755,7 +2801,8 @@ fn check_call_delegation_key_successful() { let caller = ACCOUNT_00; let delegation_key = get_ed25519_delegation_key(true); - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(caller.clone())); assert_ok!(mock_did.update_delegation_key(DidVerificationKey::from(delegation_key.public()), 0)); let call_operation = generate_test_did_call( @@ -2767,6 +2814,7 @@ fn check_call_delegation_key_successful() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) + .with_balances(vec![(caller.clone(), DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2783,7 +2831,8 @@ fn check_call_delegation_key_error() { let caller = ACCOUNT_00; let delegation_key = get_ed25519_delegation_key(true); - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); assert_ok!(mock_did.update_delegation_key(DidVerificationKey::from(delegation_key.public()), 0)); let call_operation = generate_test_did_call( @@ -2794,6 +2843,7 @@ fn check_call_delegation_key_error() { let signature = delegation_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did.clone(), mock_did)]) .with_ctypes(vec![( ::Hashing::hash(&get_delegation_key_test_input()[..]), @@ -2817,7 +2867,7 @@ fn check_call_authentication_key_successful() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call( DidVerificationKeyRelationship::Authentication, @@ -2827,6 +2877,7 @@ fn check_call_authentication_key_successful() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::submit_did_call( @@ -2843,7 +2894,7 @@ fn check_call_authentication_key_error() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let caller = ACCOUNT_00; - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call( DidVerificationKeyRelationship::Authentication, @@ -2854,6 +2905,7 @@ fn check_call_authentication_key_error() { ExtBuilder::default() .with_dids(vec![(did.clone(), mock_did)]) + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_ctypes(vec![( ::Hashing::hash(&get_authentication_key_test_input()[..]), did, @@ -2904,14 +2956,15 @@ fn check_authentication_successful_operation_verification() { let auth_key = get_sr25519_authentication_key(true); let did = get_did_identifier_from_sr25519_key(auth_key.public()); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call(DidVerificationKeyRelationship::Authentication, did.clone(), ACCOUNT_00); let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() - .with_dids(vec![(did, mock_did.clone())]) + .with_dids(vec![(did.clone(), mock_did.clone())]) + .with_balances(vec![(did, DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -2929,7 +2982,8 @@ fn check_attestation_successful_operation_verification() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let attestation_key = get_ed25519_attestation_key(true); - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); assert_ok!(mock_did.update_attestation_key(DidVerificationKey::from(attestation_key.public()), 0)); let call_operation = @@ -2937,7 +2991,8 @@ fn check_attestation_successful_operation_verification() { let signature = attestation_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() - .with_dids(vec![(did, mock_did.clone())]) + .with_dids(vec![(did.clone(), mock_did.clone())]) + .with_balances(vec![(did, DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -2955,7 +3010,8 @@ fn check_delegation_successful_operation_verification() { let did = get_did_identifier_from_sr25519_key(auth_key.public()); let delegation_key = get_ecdsa_delegation_key(true); - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); assert_ok!(mock_did.update_delegation_key(DidVerificationKey::from(delegation_key.public()), 0)); let call_operation = generate_test_did_call( @@ -2966,6 +3022,7 @@ fn check_delegation_successful_operation_verification() { let signature = delegation_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did.clone())]) .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::verify_did_operation_signature_and_increase_nonce( @@ -3002,7 +3059,8 @@ fn check_tx_counter_wrap_operation_verification() { let auth_key = get_sr25519_authentication_key(true); let did = get_did_identifier_from_sr25519_key(auth_key.public()); - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); mock_did.last_tx_counter = u64::MAX; let mut call_operation = @@ -3012,7 +3070,8 @@ fn check_tx_counter_wrap_operation_verification() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() - .with_dids(vec![(did, mock_did)]) + .with_dids(vec![(did.clone(), mock_did)]) + .with_balances(vec![(did, DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -3029,7 +3088,8 @@ fn check_smaller_counter_operation_verification() { let auth_key = get_ed25519_authentication_key(true); let did = get_did_identifier_from_ed25519_key(auth_key.public()); - let mut mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut mock_did = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); mock_did.last_tx_counter = 1; let mut call_operation = generate_test_did_call( @@ -3041,7 +3101,8 @@ fn check_smaller_counter_operation_verification() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() - .with_dids(vec![(did, mock_did)]) + .with_dids(vec![(did.clone(), mock_did)]) + .with_balances(vec![(did, DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::verify_did_operation_signature_and_increase_nonce( @@ -3058,7 +3119,7 @@ fn check_equal_counter_operation_verification() { let auth_key = get_ed25519_authentication_key(true); let did = get_did_identifier_from_ed25519_key(auth_key.public()); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let mut call_operation = generate_test_did_call( DidVerificationKeyRelationship::CapabilityDelegation, @@ -3069,6 +3130,7 @@ fn check_equal_counter_operation_verification() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -3086,7 +3148,7 @@ fn check_too_large_counter_operation_verification() { let auth_key = get_ed25519_authentication_key(true); let did = get_did_identifier_from_ed25519_key(auth_key.public()); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let mut call_operation = generate_test_did_call( DidVerificationKeyRelationship::CapabilityDelegation, @@ -3097,7 +3159,8 @@ fn check_too_large_counter_operation_verification() { let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() - .with_dids(vec![(did, mock_did)]) + .with_dids(vec![(did.clone(), mock_did)]) + .with_balances(vec![(did, DEFAULT_BALANCE)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::verify_did_operation_signature_and_increase_nonce( @@ -3114,13 +3177,14 @@ fn check_verification_key_not_present_operation_verification() { let auth_key = get_ed25519_authentication_key(true); let did = get_did_identifier_from_ed25519_key(auth_key.public()); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call(DidVerificationKeyRelationship::AssertionMethod, did.clone(), ACCOUNT_00); let signature = auth_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -3142,13 +3206,14 @@ fn check_invalid_signature_format_operation_verification() { // Expected an Sr25519, given an Ed25519 let invalid_key = get_ed25519_authentication_key(true); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call(DidVerificationKeyRelationship::Authentication, did.clone(), ACCOUNT_00); let signature = invalid_key.sign(call_operation.encode().as_ref()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -3168,13 +3233,14 @@ fn check_invalid_signature_operation_verification() { // Using same key type but different seed (default = false) let alternative_key = get_sr25519_authentication_key(false); - let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mock_did = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(did.clone())); let call_operation = generate_test_did_call(DidVerificationKeyRelationship::Authentication, did.clone(), ACCOUNT_00); let signature = alternative_key.sign(&call_operation.encode()); ExtBuilder::default() + .with_balances(vec![(did.clone(), DEFAULT_BALANCE)]) .with_dids(vec![(did, mock_did)]) .build_and_execute_with_sanity_tests(None, || { assert_noop!( @@ -3194,26 +3260,27 @@ fn check_invalid_signature_operation_verification() { fn test_change_deposit_owner() { let auth_key = get_ed25519_authentication_key(true); let alice_did = get_did_identifier_from_ed25519_key(auth_key.public()); - let mut did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(alice_did.clone())); did_details.deposit.owner = ACCOUNT_00; did_details.deposit.amount = ::BaseDeposit::get(); let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance), (alice_did.clone(), balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) .build_and_execute_with_sanity_tests(None, || { assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::BaseDeposit::get() ); assert_ok!(Did::change_deposit_owner(RuntimeOrigin::signed(alice_did.clone()))); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); assert_eq!( - Balances::reserved_balance(alice_did), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &alice_did), ::BaseDeposit::get() ); }); @@ -3223,13 +3290,14 @@ fn test_change_deposit_owner() { fn test_change_deposit_owner_insufficient_balance() { let auth_key = get_ed25519_authentication_key(true); let alice_did = get_did_identifier_from_ed25519_key(auth_key.public()); - let mut did_details = generate_base_did_details::(DidVerificationKey::from(auth_key.public()), None); + let mut did_details = + generate_base_did_details::(DidVerificationKey::from(auth_key.public()), Some(ACCOUNT_00)); did_details.deposit.owner = ACCOUNT_00; did_details.deposit.amount = ::BaseDeposit::get(); let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) @@ -3237,7 +3305,7 @@ fn test_change_deposit_owner_insufficient_balance() { .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::change_deposit_owner(RuntimeOrigin::signed(alice_did.clone())), - pallet_balances::Error::::InsufficientBalance + TokenError::CannotCreateHold ); }); } @@ -3249,7 +3317,7 @@ fn test_change_deposit_owner_not_found() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(alice_did.clone(), balance)]) @@ -3270,7 +3338,7 @@ fn test_change_deposit_owner_not_authorized() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(alice_did, balance), (bob_did.clone(), balance)]) @@ -3293,14 +3361,14 @@ fn test_update_deposit() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(alice_did.clone(), balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) .build_and_execute_with_sanity_tests(None, || { assert_eq!( - Balances::reserved_balance(alice_did.clone()), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &alice_did), ::BaseDeposit::get() * 2 ); @@ -3310,7 +3378,7 @@ fn test_update_deposit() { )); assert_eq!( - Balances::reserved_balance(alice_did.clone()), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &alice_did), ::BaseDeposit::get() ); @@ -3318,7 +3386,7 @@ fn test_update_deposit() { Did::get_did(&alice_did) .expect("DID should be present on chain.") .deposit, - kilt_support::deposit::Deposit { + kilt_support::Deposit { owner: alice_did, amount: ::BaseDeposit::get(), } @@ -3340,14 +3408,14 @@ fn test_update_deposit_unauthorized() { let balance = ::BaseDeposit::get() * 2 + ::Fee::get() * 2 - + <::Currency as Currency>>::minimum_balance(); + + <::Currency as Inspect>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(alice_did.clone(), balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) .build_and_execute_with_sanity_tests(None, || { assert_eq!( - Balances::reserved_balance(alice_did.clone()), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &alice_did), ::BaseDeposit::get() * 2 ); assert_noop!( diff --git a/pallets/pallet-configuration/Cargo.toml b/pallets/pallet-configuration/Cargo.toml index bcff252f66..f8d5998048 100644 --- a/pallets/pallet-configuration/Cargo.toml +++ b/pallets/pallet-configuration/Cargo.toml @@ -21,7 +21,6 @@ sp-keystore = {workspace = true, features = ["std"]} pallet-balances = {workspace = true} [dependencies] - # Substrate dependencies parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} diff --git a/pallets/pallet-configuration/src/mock.rs b/pallets/pallet-configuration/src/mock.rs index e070be6da0..775e5301e2 100644 --- a/pallets/pallet-configuration/src/mock.rs +++ b/pallets/pallet-configuration/src/mock.rs @@ -90,9 +90,15 @@ pub mod runtime { pub const ExistentialDeposit: Balance = 500; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; } impl pallet_balances::Config for Test { + type FreezeIdentifier = (); + type HoldIdentifier = (); + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; type Balance = Balance; type DustRemoval = (); type RuntimeEvent = (); @@ -132,12 +138,12 @@ pub mod runtime { #[cfg(feature = "runtime-benchmarks")] pub(crate) fn build_with_keystore(self) -> sp_io::TestExternalities { - use sp_keystore::{testing::KeyStore, KeystoreExt}; + use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_std::sync::Arc; let mut ext = self.build(); - let keystore = KeyStore::new(); + let keystore = MemoryKeystore::new(); ext.register_extension(KeystoreExt(Arc::new(keystore))); ext diff --git a/pallets/pallet-did-lookup/Cargo.toml b/pallets/pallet-did-lookup/Cargo.toml index 323b369d1b..6485c5daff 100644 --- a/pallets/pallet-did-lookup/Cargo.toml +++ b/pallets/pallet-did-lookup/Cargo.toml @@ -36,6 +36,7 @@ sha3.workspace = true # Internal dependencies kilt-support.workspace = true +runtime-common.workspace = true # Substrate dependencies frame-support.workspace = true diff --git a/pallets/pallet-did-lookup/src/benchmarking.rs b/pallets/pallet-did-lookup/src/benchmarking.rs index 2f46e34923..885248a8db 100644 --- a/pallets/pallet-did-lookup/src/benchmarking.rs +++ b/pallets/pallet-did-lookup/src/benchmarking.rs @@ -22,7 +22,10 @@ use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite}; use frame_support::{ crypto::ecdsa::ECDSAExt, - traits::{Currency, Get}, + traits::{ + fungible::{Inspect, Mutate}, + Get, + }, }; use frame_system::RawOrigin; use sha3::{Digest, Keccak256}; @@ -33,7 +36,7 @@ use sp_runtime::{ AccountId32, KeyTypeId, }; -use kilt_support::{deposit::Deposit, traits::GenerateBenchmarkOrigin}; +use kilt_support::{traits::GenerateBenchmarkOrigin, Deposit}; use crate::{ account::AccountId20, @@ -47,11 +50,14 @@ const SEED: u32 = 0; // Free 2x deposit amount + existential deposit so that we can use this function // to link an account two times to two different DIDs. -fn make_free_for_did(account: &AccountIdOf) { - let balance = as Currency>>::minimum_balance() +fn make_free_for_did(account: &AccountIdOf) +where + ::Currency: Mutate, +{ + let balance = as Inspect>>::minimum_balance() + ::Deposit::get() + ::Deposit::get(); - as Currency>>::make_free_balance_be(account, balance); + CurrencyOf::::set_balance(account, balance); } benchmarks! { @@ -60,6 +66,7 @@ benchmarks! { T::AccountId: From + From + Into + Into + From, T::DidIdentifier: From, T::EnsureOrigin: GenerateBenchmarkOrigin, + ::Currency: Mutate, } associate_account_multisig_sr25519 { diff --git a/pallets/pallet-did-lookup/src/connection_record.rs b/pallets/pallet-did-lookup/src/connection_record.rs index bcfee9e72d..d94b892cff 100644 --- a/pallets/pallet-did-lookup/src/connection_record.rs +++ b/pallets/pallet-did-lookup/src/connection_record.rs @@ -16,7 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use kilt_support::deposit::Deposit; +use kilt_support::Deposit; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 47e813f57d..65456e7090 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -57,13 +57,17 @@ pub mod pallet { use frame_support::{ ensure, pallet_prelude::*, - traits::{Currency, ReservableCurrency, StorageVersion}, + traits::{ + fungible::{Inspect, InspectHold, MutateHold}, + StorageVersion, + }, }; use frame_system::pallet_prelude::*; use kilt_support::{ - deposit::Deposit, traits::{CallSources, StorageDepositCollector}, + Deposit, }; + use runtime_common::Balance; use sp_runtime::traits::BlockNumberProvider; @@ -75,17 +79,19 @@ pub mod pallet { /// The identifier to which the accounts can be associated. pub(crate) type DidIdentifierOf = ::DidIdentifier; - /// The type used to describe a balance. - pub(crate) type BalanceOf = <::Currency as Currency>>::Balance; - /// The currency module that keeps track of balances. pub(crate) type CurrencyOf = ::Currency; + pub type BalanceOf = as Inspect>>::Balance; /// The connection record type. pub(crate) type ConnectionRecordOf = ConnectionRecord, AccountIdOf, BalanceOf>; - pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); + pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(5); + #[pallet::composite_enum] + pub enum HoldReason { + Deposit, + } #[pallet::config] pub trait Config: frame_system::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -99,8 +105,10 @@ pub mod pallet { /// The identifier to which accounts can get associated. type DidIdentifier: Parameter + AsRef<[u8]> + MaxEncodedLen + MaybeSerializeDeserialize; + type RuntimeHoldReason: From; + /// The currency that is used to reserve funds for each did. - type Currency: ReservableCurrency>; + type Currency: MutateHold, Reason = Self::RuntimeHoldReason, Balance = Balance>; /// The amount of balance that will be taken for each DID as a deposit /// to incentivise fair use of the on chain storage. The deposit can be @@ -246,7 +254,8 @@ pub mod pallet { ); ensure!( - >>::can_reserve( + >>::can_hold( + &HoldReason::Deposit.into(), &sender, ::Deposit::get() ), @@ -280,7 +289,8 @@ pub mod pallet { let source = ::EnsureOrigin::ensure_origin(origin)?; ensure!( - >>::can_reserve( + >>::can_hold( + &HoldReason::Deposit.into(), &source.sender(), ::Deposit::get() ), @@ -405,15 +415,16 @@ pub mod pallet { did: did_identifier.clone(), }; - CurrencyOf::::reserve(&record.deposit.owner, record.deposit.amount)?; + LinkableAccountDepositCollector::::create_deposit(record.clone().deposit.owner, record.deposit.amount)?; - ConnectedDids::::mutate(&account, |did_entry| { + ConnectedDids::::mutate(&account, |did_entry| -> DispatchResult { if let Some(old_connection) = did_entry.replace(record) { ConnectedAccounts::::remove(&old_connection.did, &account); Self::deposit_event(Event::::AssociationRemoved(account.clone(), old_connection.did)); - kilt_support::free_deposit::, CurrencyOf>(&old_connection.deposit); + LinkableAccountDepositCollector::::free_deposit(old_connection.deposit)?; } - }); + Ok(()) + })?; ConnectedAccounts::::insert(&did_identifier, &account, ()); Self::deposit_event(Event::AssociationEstablished(account, did_identifier)); @@ -422,10 +433,9 @@ pub mod pallet { pub(crate) fn remove_association(account: LinkableAccountId) -> DispatchResult { if let Some(connection) = ConnectedDids::::take(&account) { + LinkableAccountDepositCollector::::free_deposit(connection.deposit)?; ConnectedAccounts::::remove(&connection.did, &account); - kilt_support::free_deposit::, CurrencyOf>(&connection.deposit); Self::deposit_event(Event::AssociationRemoved(account, connection.did)); - Ok(()) } else { Err(Error::::NotFound.into()) @@ -433,28 +443,34 @@ pub mod pallet { } } - struct LinkableAccountDepositCollector(PhantomData); - impl StorageDepositCollector, LinkableAccountId> for LinkableAccountDepositCollector { + pub(crate) struct LinkableAccountDepositCollector(PhantomData); + impl StorageDepositCollector, LinkableAccountId, T::RuntimeHoldReason> + for LinkableAccountDepositCollector + { type Currency = T::Currency; + type Reason = HoldReason; + + fn reason() -> Self::Reason { + HoldReason::Deposit + } fn deposit( key: &LinkableAccountId, - ) -> Result, >>::Balance>, DispatchError> { + ) -> Result, >>::Balance>, DispatchError> { let record = ConnectedDids::::get(key).ok_or(Error::::NotFound)?; Ok(record.deposit) } - fn deposit_amount(_key: &LinkableAccountId) -> >>::Balance { + fn deposit_amount(_key: &LinkableAccountId) -> >>::Balance { T::Deposit::get() } fn store_deposit( key: &LinkableAccountId, - deposit: Deposit, >>::Balance>, + deposit: Deposit, >>::Balance>, ) -> Result<(), DispatchError> { let record = ConnectedDids::::get(key).ok_or(Error::::NotFound)?; ConnectedDids::::insert(key, ConnectionRecord { deposit, ..record }); - Ok(()) } } diff --git a/pallets/pallet-did-lookup/src/migrations.rs b/pallets/pallet-did-lookup/src/migrations.rs index e68d8a1a6e..87edd11bda 100644 --- a/pallets/pallet-did-lookup/src/migrations.rs +++ b/pallets/pallet-did-lookup/src/migrations.rs @@ -19,14 +19,19 @@ use frame_support::{ pallet_prelude::ValueQuery, storage_alias, - traits::{Get, GetStorageVersion, OnRuntimeUpgrade, StorageVersion}, + traits::{Get, GetStorageVersion, OnRuntimeUpgrade, ReservableCurrency, StorageVersion}, + weights::Weight, }; +use kilt_support::migration::switch_reserved_to_hold; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_runtime::AccountId32; +use sp_runtime::{AccountId32, SaturatedConversion}; use sp_std::marker::PhantomData; -use crate::{linkable_account::LinkableAccountId, Config, Pallet}; +use crate::{ + linkable_account::LinkableAccountId, AccountIdOf, Config, ConnectedDids, CurrencyOf, HoldReason, Pallet, + STORAGE_VERSION as TARGET_STORAGE_VERSION, +}; /// A unified log target for did-lookup-migration operations. pub const LOG_TARGET: &str = "runtime::pallet-did-lookup::migrations"; @@ -71,7 +76,7 @@ impl OnRuntimeUpgrade for CleanupMigration { if Pallet::::on_chain_storage_version() == StorageVersion::new(3) { log::info!("🔎 DidLookup: Initiating migration"); MigrationStateStore::::kill(); - Pallet::::current_storage_version().put::>(); + StorageVersion::new(4).put::>(); T::DbWeight::get().reads_writes(1, 2) } else { @@ -80,7 +85,7 @@ impl OnRuntimeUpgrade for CleanupMigration { target: LOG_TARGET, "Migration did not execute. This probably should be removed" ); - ::DbWeight::get().reads_writes(1, 0) + ::DbWeight::get().reads(1) } } @@ -114,3 +119,120 @@ impl OnRuntimeUpgrade for CleanupMigration { Ok(()) } } + +const CURRENT_STORAGE_VERSION: StorageVersion = StorageVersion::new(4); + +pub struct BalanceMigration(PhantomData); + +impl OnRuntimeUpgrade for BalanceMigration +where + ::Currency: ReservableCurrency, +{ + fn on_runtime_upgrade() -> frame_support::weights::Weight { + log::info!("Did lookup: Initiating migration"); + + let onchain_storage_version = Pallet::::on_chain_storage_version(); + if onchain_storage_version == CURRENT_STORAGE_VERSION { + TARGET_STORAGE_VERSION.put::>(); + return ::DbWeight::get() + .reads_writes(1, 1) + .saturating_add(do_migration::()); + } + log::info!( + "Did lookup: No migration needed. This file should be deleted. Current storage version: {:?}, Required Version for update: {:?}", + onchain_storage_version, + CURRENT_STORAGE_VERSION + ); + + ::DbWeight::get().reads(1) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + use sp_std::vec; + + let has_all_user_no_holds = ConnectedDids::::iter_values() + .map(|details| { + kilt_support::migration::has_user_reserved_balance::, CurrencyOf>( + &details.deposit.owner, + &HoldReason::Deposit.into(), + ) + }) + .all(|user| user); + + assert!(has_all_user_no_holds, "Did lookup: there are users with holds!"); + + assert_eq!(Pallet::::on_chain_storage_version(), CURRENT_STORAGE_VERSION); + + log::info!("Did lookup: Pre migration checks successful"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_pre_state: sp_std::vec::Vec) -> Result<(), &'static str> { + use frame_support::traits::fungible::InspectHold; + use sp_std::collections::btree_map::BTreeMap; + + use crate::BalanceOf; + + let mut map_user_deposit: BTreeMap, BalanceOf> = BTreeMap::new(); + + ConnectedDids::::iter_values().for_each(|details| { + map_user_deposit + .entry(details.deposit.owner) + .and_modify(|balance| *balance = balance.saturating_add(details.deposit.amount)) + .or_insert(details.deposit.amount); + }); + + map_user_deposit + .iter() + .try_for_each(|(who, amount)| -> Result<(), &'static str> { + let hold_balance: BalanceOf = + ::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into(); + + assert!( + amount.eq(&hold_balance), + "Did lookup: Hold balance is not matching for attestation {:?}. Expected hold: {:?}. Real hold: {:?}", + who, + amount, + hold_balance + ); + Ok(()) + })?; + + assert_eq!(Pallet::::on_chain_storage_version(), TARGET_STORAGE_VERSION); + + log::info!("Did lookup: Post migration checks successful"); + Ok(()) + } +} + +fn do_migration() -> Weight +where + ::Currency: ReservableCurrency, +{ + ConnectedDids::::iter() + .map(|(key, did_details)| -> Weight { + let deposit = did_details.deposit; + let result = switch_reserved_to_hold::, CurrencyOf>( + deposit.owner, + &HoldReason::Deposit.into(), + deposit.amount.saturated_into(), + ); + + if result.is_err() { + log::error!( + "Did lookup: Could not convert reserves to hold from connected did: {:?} error: {:?}", + key, + result + ); + } + + // Currency::reserve and Currency::hold each read and write to the DB once. + // Since we are uncertain about which operation may fail, in the event of an + // error, we assume the worst-case scenario here. + ::DbWeight::get().reads_writes(2, 2) + }) + .fold(Weight::zero(), |acc, next| acc.saturating_add(next)) +} diff --git a/pallets/pallet-did-lookup/src/mock.rs b/pallets/pallet-did-lookup/src/mock.rs index 2d6bf355f5..6107093f77 100644 --- a/pallets/pallet-did-lookup/src/mock.rs +++ b/pallets/pallet-did-lookup/src/mock.rs @@ -16,10 +16,10 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::{parameter_types, traits::ReservableCurrency}; +use frame_support::parameter_types; use kilt_support::{ - deposit::Deposit, mock::{mock_origin, SubjectId}, + traits::StorageDepositCollector, }; use sp_runtime::{ testing::Header, @@ -29,7 +29,7 @@ use sp_runtime::{ use crate::{ self as pallet_did_lookup, linkable_account::LinkableAccountId, AccountIdOf, BalanceOf, Config, ConnectedAccounts, - ConnectedDids, ConnectionRecord, CurrencyOf, DidIdentifierOf, + ConnectedDids, ConnectionRecord, DidIdentifierOf, LinkableAccountDepositCollector, }; pub(crate) type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -50,7 +50,7 @@ frame_support::construct_runtime!( { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Event}, - DidLookup: pallet_did_lookup::{Pallet, Storage, Call, Event}, + DidLookup: pallet_did_lookup::{Pallet, Storage, Call, Event, HoldReason}, MockOrigin: mock_origin::{Pallet, Origin}, } ); @@ -91,9 +91,15 @@ parameter_types! { pub const ExistentialDeposit: Balance = 10; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; } impl pallet_balances::Config for Test { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; type Balance = Balance; type DustRemoval = (); type RuntimeEvent = RuntimeEvent; @@ -111,14 +117,12 @@ parameter_types! { impl pallet_did_lookup::Config for Test { type RuntimeEvent = RuntimeEvent; - + type RuntimeHoldReason = RuntimeHoldReason; type Currency = Balances; type Deposit = DidLookupDeposit; - type EnsureOrigin = mock_origin::EnsureDoubleOrigin; type OriginSuccess = mock_origin::DoubleOrigin; type DidIdentifier = SubjectId; - type WeightInfo = (); } @@ -140,21 +144,19 @@ pub(crate) fn insert_raw_connection( account: LinkableAccountId, deposit: BalanceOf, ) { - let deposit = Deposit { - owner: sender, - amount: deposit, - }; + let deposit = LinkableAccountDepositCollector::::create_deposit(sender, deposit) + .expect("Account should have enough balance"); + let record = ConnectionRecord { deposit, did: did_identifier.clone(), }; - CurrencyOf::::reserve(&record.deposit.owner, record.deposit.amount).expect("Account should have enough balance"); - ConnectedDids::::mutate(&account, |did_entry| { if let Some(old_connection) = did_entry.replace(record) { ConnectedAccounts::::remove(&old_connection.did, &account); - kilt_support::free_deposit::, CurrencyOf>(&old_connection.deposit); + LinkableAccountDepositCollector::::free_deposit(old_connection.deposit) + .expect("Could not release deposit of account"); } }); ConnectedAccounts::::insert(&did_identifier, &account, ()); @@ -210,7 +212,7 @@ impl ExtBuilder { pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); - let keystore = sp_keystore::testing::KeyStore::new(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(std::sync::Arc::new(keystore))); ext diff --git a/pallets/pallet-did-lookup/src/tests.rs b/pallets/pallet-did-lookup/src/tests.rs index bd97aa2dfc..5059a53b15 100644 --- a/pallets/pallet-did-lookup/src/tests.rs +++ b/pallets/pallet-did-lookup/src/tests.rs @@ -16,14 +16,14 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::{assert_noop, assert_ok, crypto::ecdsa::ECDSAExt}; -use kilt_support::{deposit::Deposit, mock::mock_origin}; +use frame_support::{assert_noop, assert_ok, crypto::ecdsa::ECDSAExt, traits::fungible::InspectHold}; +use kilt_support::{mock::mock_origin, Deposit}; use parity_scale_codec::Encode; use sha3::{Digest, Keccak256}; use sp_runtime::{ app_crypto::{ecdsa, sr25519, Pair}, traits::{IdentifyAccount, Zero}, - MultiSignature, MultiSigner, + MultiSignature, MultiSigner, TokenError, }; use crate::{ @@ -32,7 +32,7 @@ use crate::{ linkable_account::LinkableAccountId, mock::*, signature::get_wrapped_payload, - ConnectedAccounts, ConnectedDids, ConnectionRecord, Error, + ConnectedAccounts, ConnectedDids, ConnectionRecord, Error, HoldReason, }; #[test] @@ -57,7 +57,7 @@ fn test_add_association_sender() { ); assert!(ConnectedAccounts::::get(DID_00, LINKABLE_ACCOUNT_00).is_some()); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() ); @@ -76,7 +76,7 @@ fn test_add_association_sender() { assert!(ConnectedAccounts::::get(DID_00, LINKABLE_ACCOUNT_00).is_none()); assert!(ConnectedAccounts::::get(DID_01, LINKABLE_ACCOUNT_00).is_some()); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() ); }); @@ -121,7 +121,7 @@ fn test_add_association_account() { ConnectedAccounts::::get(DID_00, LinkableAccountId::from(account_hash_alice.clone())).is_some() ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() ); @@ -152,7 +152,7 @@ fn test_add_association_account() { ConnectedAccounts::::get(DID_01, LinkableAccountId::from(account_hash_alice.clone())).is_some() ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() ); @@ -177,9 +177,9 @@ fn test_add_association_account() { ConnectedAccounts::::get(DID_00, LinkableAccountId::from(account_hash_alice.clone())).is_none() ); assert!(ConnectedAccounts::::get(DID_01, LinkableAccountId::from(account_hash_alice)).is_some()); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), 0); + assert_eq!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 0); assert_eq!( - Balances::reserved_balance(ACCOUNT_01), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), ::Deposit::get() ); }); @@ -223,7 +223,7 @@ fn test_add_eth_association() { ); assert!(ConnectedAccounts::::get(DID_00, LinkableAccountId::from(eth_account)).is_some()); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() ); }); @@ -294,7 +294,7 @@ fn test_remove_association_sender() { assert!(DidLookup::remove_sender_association(RuntimeOrigin::signed(ACCOUNT_00)).is_ok()); assert_eq!(ConnectedDids::::get(LinkableAccountId::from(ACCOUNT_00)), None); assert!(ConnectedAccounts::::get(DID_01, LinkableAccountId::from(ACCOUNT_00)).is_none()); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), 0); + assert_eq!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), 0); }); } @@ -329,7 +329,7 @@ fn test_remove_association_account() { .is_ok()); assert_eq!(ConnectedDids::::get(LinkableAccountId::from(ACCOUNT_00)), None); assert!(ConnectedAccounts::::get(DID_01, LinkableAccountId::from(ACCOUNT_00)).is_none()); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), 0); + assert_eq!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), 0); }); } @@ -370,7 +370,7 @@ fn test_remove_association_account_not_authorized() { Error::::NotAuthorized ); assert_eq!( - Balances::reserved_balance(ACCOUNT_01), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), ::Deposit::get() ); }); @@ -389,7 +389,7 @@ fn test_reclaim_deposit() { RuntimeOrigin::signed(ACCOUNT_01), ACCOUNT_00.into() )); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), 0); + assert_eq!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), 0); }); } @@ -407,7 +407,7 @@ fn test_reclaim_deposit_not_authorized() { Error::::NotAuthorized ); assert_eq!( - Balances::reserved_balance(ACCOUNT_01), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), ::Deposit::get() ); }); @@ -429,9 +429,9 @@ fn test_change_deposit_owner() { mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into(), ACCOUNT_00.into() )); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); assert_eq!( - Balances::reserved_balance(ACCOUNT_01), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), ::Deposit::get() ); }) @@ -448,7 +448,7 @@ fn test_change_deposit_owner_insufficient_balance() { mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into(), ACCOUNT_00.into() ), - pallet_balances::Error::::InsufficientBalance + TokenError::CannotCreateHold ); }) } @@ -499,7 +499,7 @@ fn test_update_deposit() { ::Deposit::get() * 2, ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 2 ); assert_ok!(DidLookup::update_deposit( @@ -507,7 +507,7 @@ fn test_update_deposit() { ACCOUNT_00.into() )); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() ); }) @@ -528,7 +528,7 @@ fn test_update_deposit_unauthorized() { ::Deposit::get() * 2, ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 2 ); assert_noop!( diff --git a/pallets/pallet-inflation/src/benchmarking.rs b/pallets/pallet-inflation/src/benchmarking.rs index 13613a46a1..a3f9eedade 100644 --- a/pallets/pallet-inflation/src/benchmarking.rs +++ b/pallets/pallet-inflation/src/benchmarking.rs @@ -23,7 +23,7 @@ use super::*; use crate::Pallet as Inflation; use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; -use frame_support::traits::{Currency, Get, OnInitialize}; +use frame_support::traits::{fungible::Inspect, Get, OnInitialize}; use sp_runtime::traits::{One, Saturating}; benchmarks! { diff --git a/pallets/pallet-inflation/src/lib.rs b/pallets/pallet-inflation/src/lib.rs index a744722489..3ef4d72939 100644 --- a/pallets/pallet-inflation/src/lib.rs +++ b/pallets/pallet-inflation/src/lib.rs @@ -47,20 +47,23 @@ pub mod pallet { use super::WeightInfo; use frame_support::{ pallet_prelude::*, - traits::{Currency, OnUnbalanced, StorageVersion}, + traits::{ + fungible::{Balanced, Credit, Inspect}, + OnUnbalanced, StorageVersion, + }, }; use frame_system::pallet_prelude::*; pub(crate) type AccountIdOf = ::AccountId; - pub(crate) type BalanceOf = <::Currency as Currency>>::Balance; - pub(crate) type NegativeImbalanceOf = <::Currency as Currency>>::NegativeImbalance; + pub(crate) type BalanceOf = <::Currency as Inspect>>::Balance; + pub(crate) type CreditOf = Credit<::AccountId, ::Currency>; pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::config] pub trait Config: frame_system::Config { /// Currency type. - type Currency: Currency>; + type Currency: Balanced>; /// The length of the initial period in which the constant reward is /// minted. Once the current block exceeds this, rewards are no further @@ -74,7 +77,7 @@ pub mod pallet { type InitialPeriodReward: Get>; /// The beneficiary to receive the rewards. - type Beneficiary: OnUnbalanced>; + type Beneficiary: OnUnbalanced>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; diff --git a/pallets/pallet-inflation/src/mock.rs b/pallets/pallet-inflation/src/mock.rs index 10c66444c6..b6aa97dbf8 100644 --- a/pallets/pallet-inflation/src/mock.rs +++ b/pallets/pallet-inflation/src/mock.rs @@ -17,10 +17,10 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use crate as pallet_inflation; -use crate::NegativeImbalanceOf; +use crate::CreditOf; use frame_support::{ parameter_types, - traits::{Currency, OnFinalize, OnInitialize, OnUnbalanced}, + traits::{fungible::Balanced, OnFinalize, OnInitialize, OnUnbalanced}, }; use sp_runtime::{ @@ -98,6 +98,10 @@ parameter_types! { } impl pallet_balances::Config for Test { + type FreezeIdentifier = (); + type HoldIdentifier = (); + type MaxFreezes = (); + type MaxHolds = (); type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; @@ -110,10 +114,10 @@ impl pallet_balances::Config for Test { } pub struct ToBeneficiary(); -impl OnUnbalanced> for ToBeneficiary { - fn on_nonzero_unbalanced(amount: NegativeImbalanceOf) { +impl OnUnbalanced> for ToBeneficiary { + fn on_nonzero_unbalanced(amount: CreditOf) { // Must resolve into existing but better to be safe. - ::Currency::resolve_creating(&TREASURY_ACC, amount); + let _ = ::Currency::resolve(&TREASURY_ACC, amount); } } diff --git a/pallets/pallet-inflation/src/tests.rs b/pallets/pallet-inflation/src/tests.rs index a44678dffe..12c92c2370 100644 --- a/pallets/pallet-inflation/src/tests.rs +++ b/pallets/pallet-inflation/src/tests.rs @@ -16,6 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org +use frame_support::traits::fungible::Inspect; use sp_runtime::traits::Zero; use crate::{mock::*, pallet::Config}; @@ -23,12 +24,12 @@ use crate::{mock::*, pallet::Config}; #[test] fn during_initial_period() { new_test_ext().execute_with(|| { - assert!(Balances::free_balance(&TREASURY_ACC).is_zero()); + assert!(Balances::balance(&TREASURY_ACC).is_zero()); assert!(::Currency::total_issuance().is_zero()); roll_to(1); assert_eq!( - Balances::free_balance(&TREASURY_ACC), + Balances::balance(&TREASURY_ACC), ::InitialPeriodReward::get() ); assert_eq!( @@ -38,7 +39,7 @@ fn during_initial_period() { roll_to(2); assert_eq!( - Balances::free_balance(&TREASURY_ACC), + Balances::balance(&TREASURY_ACC), 2 * ::InitialPeriodReward::get() ); assert_eq!( @@ -48,7 +49,7 @@ fn during_initial_period() { roll_to(100); assert_eq!( - Balances::free_balance(&TREASURY_ACC), + Balances::balance(&TREASURY_ACC), 100 * ::InitialPeriodReward::get() ); assert_eq!( @@ -61,16 +62,16 @@ fn during_initial_period() { #[test] fn after_initial_period() { new_test_ext().execute_with(|| { - assert!(Balances::free_balance(&TREASURY_ACC).is_zero()); + assert!(Balances::balance(&TREASURY_ACC).is_zero()); assert!(::Currency::total_issuance().is_zero()); System::set_block_number(::InitialPeriodLength::get()); roll_to(::InitialPeriodLength::get() + 1); - assert!(Balances::free_balance(&TREASURY_ACC).is_zero()); + assert!(Balances::balance(&TREASURY_ACC).is_zero()); assert!(::Currency::total_issuance().is_zero()); roll_to(::InitialPeriodLength::get() + 100); - assert!(Balances::free_balance(&TREASURY_ACC).is_zero()); + assert!(Balances::balance(&TREASURY_ACC).is_zero()); assert!(::Currency::total_issuance().is_zero()); }); } diff --git a/pallets/pallet-web3-names/Cargo.toml b/pallets/pallet-web3-names/Cargo.toml index 844bd1fc29..b2693d372a 100644 --- a/pallets/pallet-web3-names/Cargo.toml +++ b/pallets/pallet-web3-names/Cargo.toml @@ -25,6 +25,7 @@ sp-keystore = {workspace = true, features = ["std"]} # External dependencies parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} +log.workspace = true # Internal dependencies kilt-support.workspace = true @@ -57,6 +58,7 @@ std = [ "scale-info/std", "sp-runtime/std", "sp-std/std", + "log/std" ] try-runtime = [ "frame-support/try-runtime", diff --git a/pallets/pallet-web3-names/src/benchmarking.rs b/pallets/pallet-web3-names/src/benchmarking.rs index ba031d08ed..dce74fcb33 100644 --- a/pallets/pallet-web3-names/src/benchmarking.rs +++ b/pallets/pallet-web3-names/src/benchmarking.rs @@ -21,13 +21,16 @@ use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, vec, Ve use frame_support::{ pallet_prelude::EnsureOrigin, sp_runtime::SaturatedConversion, - traits::{Currency, Get}, + traits::{ + fungible::{Inspect, Mutate}, + Get, + }, BoundedVec, }; use frame_system::RawOrigin; use sp_runtime::app_crypto::sr25519; -use kilt_support::{deposit::Deposit, traits::GenerateBenchmarkOrigin}; +use kilt_support::{traits::GenerateBenchmarkOrigin, Deposit}; use crate::{ mock::insert_raw_w3n, AccountIdOf, Banned, Call, Config, CurrencyOf, Names, Owner, Pallet, Web3NameOf, @@ -37,11 +40,14 @@ use crate::{ const CALLER_SEED: u32 = 0; const OWNER_SEED: u32 = 1; -fn make_free_for_did(account: &AccountIdOf) { - let balance = as Currency>>::minimum_balance() +fn make_free_for_did(account: &AccountIdOf) +where + ::Currency: Mutate, +{ + let balance = as Inspect>>::minimum_balance() + ::Deposit::get() + ::Deposit::get(); - as Currency>>::make_free_balance_be(account, balance); + CurrencyOf::::set_balance(account, balance); } fn generate_web3_name_input(length: usize) -> Vec { @@ -55,6 +61,7 @@ benchmarks! { T::Web3NameOwner: From, T::OwnerOrigin: GenerateBenchmarkOrigin, T::BanOrigin: EnsureOrigin, + ::Currency: Mutate, } claim { diff --git a/pallets/pallet-web3-names/src/lib.rs b/pallets/pallet-web3-names/src/lib.rs index efe16623d6..e58aca6b41 100644 --- a/pallets/pallet-web3-names/src/lib.rs +++ b/pallets/pallet-web3-names/src/lib.rs @@ -21,10 +21,11 @@ #![cfg_attr(not(feature = "std"), no_std)] -pub mod web3_name; - mod default_weights; +pub mod migrations; +pub mod web3_name; + #[cfg(any(test, feature = "runtime-benchmarks"))] mod mock; @@ -44,22 +45,26 @@ pub mod pallet { use frame_support::{ pallet_prelude::*, sp_runtime::SaturatedConversion, - traits::{Currency, ReservableCurrency, StorageVersion}, + traits::{ + fungible::{Inspect, InspectHold, MutateHold}, + StorageVersion, + }, Blake2_128Concat, }; use frame_system::pallet_prelude::*; use parity_scale_codec::FullCodec; + use sp_runtime::DispatchError; use sp_std::{fmt::Debug, vec::Vec}; use kilt_support::{ - deposit::Deposit, traits::{CallSources, StorageDepositCollector}, + Deposit, }; use super::WeightInfo; use crate::web3_name::Web3NameOwnership; - const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); pub type AccountIdOf = ::AccountId; pub type BlockNumberFor = ::BlockNumber; @@ -70,7 +75,7 @@ pub mod pallet { Web3NameOwnership, Deposit, BalanceOf>, BlockNumberFor>; pub(crate) type CurrencyOf = ::Currency; - pub type BalanceOf = as Currency>>::Balance; + pub type BalanceOf = as Inspect>>::Balance; #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] @@ -93,6 +98,11 @@ pub mod pallet { #[pallet::getter(fn is_banned)] pub type Banned = StorageMap<_, Blake2_128Concat, Web3NameOf, ()>; + #[pallet::composite_enum] + pub enum HoldReason { + Deposit, + } + #[pallet::config] pub trait Config: frame_system::Config { /// The origin allowed to ban names. @@ -101,8 +111,10 @@ pub mod pallet { type OwnerOrigin: EnsureOrigin<::RuntimeOrigin, Success = Self::OriginSuccess>; /// The type of origin after a successful origin check. type OriginSuccess: CallSources, Web3NameOwnerOf>; + /// Aggregated hold reason. + type RuntimeHoldReason: From; /// The currency type to reserve and release deposits. - type Currency: ReservableCurrency>; + type Currency: MutateHold, Reason = Self::RuntimeHoldReason>; /// The amount of KILT to deposit to claim a name. #[pallet::constant] type Deposit: Get>; @@ -210,7 +222,7 @@ pub mod pallet { let decoded_name = Self::check_claiming_preconditions(name, &owner, &payer)?; - Self::register_name(decoded_name.clone(), owner.clone(), payer); + Self::register_name(decoded_name.clone(), owner.clone(), payer)?; Self::deposit_event(Event::::Web3NameClaimed { owner, name: decoded_name, @@ -239,7 +251,7 @@ pub mod pallet { let owned_name = Self::check_releasing_preconditions(&owner)?; - Self::unregister_name(&owned_name); + Self::unregister_name(&owned_name)?; Self::deposit_event(Event::::Web3NameReleased { owner, name: owned_name, @@ -267,7 +279,7 @@ pub mod pallet { let decoded_name = Self::check_reclaim_deposit_preconditions(name, &caller)?; - let Web3OwnershipOf:: { owner, .. } = Self::unregister_name(&decoded_name); + let Web3OwnershipOf:: { owner, .. } = Self::unregister_name(&decoded_name)?; Self::deposit_event(Event::::Web3NameReleased { owner, name: decoded_name, @@ -300,7 +312,7 @@ pub mod pallet { let (decoded_name, is_claimed) = Self::check_banning_preconditions(name)?; if is_claimed { - Self::unregister_name(&decoded_name); + Self::unregister_name(&decoded_name)?; } Self::ban_name(&decoded_name); @@ -390,7 +402,11 @@ pub mod pallet { ensure!(!Banned::::contains_key(&name), Error::::Banned); ensure!( - >>::can_reserve(deposit_payer, T::Deposit::get()), + >>::can_hold( + &HoldReason::Deposit.into(), + deposit_payer, + T::Deposit::get() + ), Error::::InsufficientFunds ); @@ -401,14 +417,13 @@ pub mod pallet { /// the provided account. This function must be called after /// `check_claiming_preconditions` as it does not verify all the /// preconditions again. - pub(crate) fn register_name(name: Web3NameOf, owner: Web3NameOwnerOf, deposit_payer: AccountIdOf) { - let deposit = Deposit { - owner: deposit_payer, - amount: T::Deposit::get(), - }; + pub(crate) fn register_name( + name: Web3NameOf, + owner: Web3NameOwnerOf, + deposit_payer: AccountIdOf, + ) -> DispatchResult { let block_number = frame_system::Pallet::::block_number(); - - CurrencyOf::::reserve(&deposit.owner, deposit.amount).unwrap(); + let deposit = Web3NameStorageDepositCollector::::create_deposit(deposit_payer, T::Deposit::get())?; Names::::insert(&owner, name.clone()); Owner::::insert( @@ -419,6 +434,7 @@ pub mod pallet { deposit, }, ); + Ok(()) } /// Verify that the releasing preconditions for an owner are verified. @@ -451,13 +467,14 @@ pub mod pallet { /// original payer. This function must be called after /// `check_releasing_preconditions` as it does not verify all the /// preconditions again. - fn unregister_name(name: &Web3NameOf) -> Web3OwnershipOf { + fn unregister_name(name: &Web3NameOf) -> Result, DispatchError> { let name_ownership = Owner::::take(name).unwrap(); Names::::remove(&name_ownership.owner); - kilt_support::free_deposit::, CurrencyOf>(&name_ownership.deposit); + // Should never fail since we checked in the preconditions + Web3NameStorageDepositCollector::::free_deposit(name_ownership.clone().deposit)?; - name_ownership + Ok(name_ownership) } /// Verify that the banning preconditions are verified. @@ -505,25 +522,31 @@ pub mod pallet { } } - struct Web3NameStorageDepositCollector(PhantomData); - impl StorageDepositCollector, T::Web3Name> for Web3NameStorageDepositCollector { + pub(crate) struct Web3NameStorageDepositCollector(PhantomData); + impl StorageDepositCollector, T::Web3Name, T::RuntimeHoldReason> + for Web3NameStorageDepositCollector + { type Currency = T::Currency; + type Reason = HoldReason; + fn reason() -> Self::Reason { + HoldReason::Deposit + } fn deposit( key: &T::Web3Name, - ) -> Result, >>::Balance>, DispatchError> { + ) -> Result, >>::Balance>, DispatchError> { let w3n_entry = Owner::::get(key).ok_or(Error::::NotFound)?; Ok(w3n_entry.deposit) } - fn deposit_amount(_key: &T::Web3Name) -> >>::Balance { + fn deposit_amount(_key: &T::Web3Name) -> >>::Balance { T::Deposit::get() } fn store_deposit( key: &T::Web3Name, - deposit: Deposit, >>::Balance>, + deposit: Deposit, >>::Balance>, ) -> Result<(), DispatchError> { let w3n_entry = Owner::::get(key).ok_or(Error::::NotFound)?; Owner::::insert(key, Web3OwnershipOf:: { deposit, ..w3n_entry }); diff --git a/pallets/pallet-web3-names/src/migrations.rs b/pallets/pallet-web3-names/src/migrations.rs new file mode 100644 index 0000000000..3580e87fe5 --- /dev/null +++ b/pallets/pallet-web3-names/src/migrations.rs @@ -0,0 +1,145 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + traits::{Get, GetStorageVersion, OnRuntimeUpgrade, ReservableCurrency, StorageVersion}, + weights::Weight, +}; +use kilt_support::migration::switch_reserved_to_hold; +use sp_runtime::SaturatedConversion; +use sp_std::marker::PhantomData; + +use crate::{AccountIdOf, Config, CurrencyOf, HoldReason, Owner, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION}; + +const CURRENT_STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + +pub struct BalanceMigration(PhantomData); + +impl OnRuntimeUpgrade for BalanceMigration +where + ::Currency: ReservableCurrency, +{ + fn on_runtime_upgrade() -> frame_support::weights::Weight { + log::info!("W3n: Initiating migration"); + + let onchain_storage_version = Pallet::::on_chain_storage_version(); + if onchain_storage_version == CURRENT_STORAGE_VERSION { + TARGET_STORAGE_VERSION.put::>(); + ::DbWeight::get() + .reads_writes(1, 1) + .saturating_add(do_migration::()) + } else { + log::info!( + "W3N: No migration needed. This file should be deleted. Current storage version: {:?}, Required Version for update: {:?}", + onchain_storage_version, + CURRENT_STORAGE_VERSION + ); + ::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + use sp_std::vec; + + let has_all_user_no_holds = Owner::::iter_values() + .map(|details: crate::Web3OwnershipOf| { + kilt_support::migration::has_user_reserved_balance::, CurrencyOf>( + &details.deposit.owner, + &HoldReason::Deposit.into(), + ) + }) + .all(|user| user); + + assert!(has_all_user_no_holds, "Pre Upgrade W3n: there are users with holds!"); + + assert_eq!(Pallet::::on_chain_storage_version(), CURRENT_STORAGE_VERSION); + + log::info!("W3n: Pre migration checks successful"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_pre_state: sp_std::vec::Vec) -> Result<(), &'static str> { + use frame_support::traits::fungible::InspectHold; + use sp_runtime::Saturating; + use sp_std::collections::btree_map::BTreeMap; + + use crate::BalanceOf; + + let mut map_user_deposit: BTreeMap, BalanceOf> = BTreeMap::new(); + + Owner::::iter_values().for_each(|details| { + map_user_deposit + .entry(details.deposit.owner) + .and_modify(|balance| *balance = balance.saturating_add(details.deposit.amount)) + .or_insert(details.deposit.amount); + }); + + map_user_deposit + .iter() + .try_for_each(|(who, amount)| -> Result<(), &'static str> { + let hold_balance: BalanceOf = + ::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into(); + + assert!( + amount.eq(&hold_balance), + "W3n: Hold balance is not matching for attestation {:?}. Expected hold: {:?}. Real hold: {:?}", + who, + amount, + hold_balance + ); + Ok(()) + })?; + + assert_eq!(Pallet::::on_chain_storage_version(), TARGET_STORAGE_VERSION); + + log::info!("W3n: Post migration checks successful"); + Ok(()) + } +} + +fn do_migration() -> Weight +where + ::Currency: ReservableCurrency, +{ + Owner::::iter() + .map(|(key, w3n_details)| -> Weight { + let deposit = w3n_details.deposit; + let result = switch_reserved_to_hold::, CurrencyOf>( + deposit.owner, + &HoldReason::Deposit.into(), + deposit.amount.saturated_into(), + ); + + if result.is_err() { + log::error!( + " W3n: Could not convert reserves to hold from w3n: {:?} error: {:?}", + key, + result + ); + } + + // Currency::reserve and Currency::hold each read and write to the DB once. + // Since we are uncertain about which operation may fail, in the event of an + // error, we assume the worst-case scenario here. + ::DbWeight::get().reads_writes(2, 2) + }) + .fold(Weight::zero(), |acc, next| acc.saturating_add(next)) +} diff --git a/pallets/pallet-web3-names/src/mock.rs b/pallets/pallet-web3-names/src/mock.rs index 5a8135bab8..a6b359f6ea 100644 --- a/pallets/pallet-web3-names/src/mock.rs +++ b/pallets/pallet-web3-names/src/mock.rs @@ -15,12 +15,12 @@ // along with this program. If not, see . // If you feel like getting in touch with us, you can do so at info@botlabs.org +use frame_support::traits::fungible::MutateHold; +use kilt_support::Deposit; -use frame_support::traits::ReservableCurrency; - -use kilt_support::deposit::Deposit; - -use crate::{AccountIdOf, BalanceOf, Config, CurrencyOf, Names, Owner, Web3NameOf, Web3NameOwnerOf, Web3OwnershipOf}; +use crate::{ + AccountIdOf, BalanceOf, Config, CurrencyOf, HoldReason, Names, Owner, Web3NameOf, Web3NameOwnerOf, Web3OwnershipOf, +}; pub(crate) type BlockNumberOf = ::BlockNumber; @@ -31,7 +31,8 @@ pub(crate) fn insert_raw_w3n( block_number: BlockNumberOf, deposit: BalanceOf, ) { - CurrencyOf::::reserve(&payer, deposit).expect("Payer should have enough funds for deposit"); + CurrencyOf::::hold(&HoldReason::Deposit.into(), &payer, deposit) + .expect("Payer should have enough funds for deposit"); Names::::insert(&owner, name.clone()); Owner::::insert( @@ -84,7 +85,7 @@ pub(crate) mod runtime { { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Event}, - Web3Names: pallet_web3_names::{Pallet, Storage, Call, Event}, + Web3Names: pallet_web3_names::{Pallet, Storage, Call, Event, HoldReason}, MockOrigin: mock_origin::{Pallet, Origin}, } ); @@ -125,9 +126,15 @@ pub(crate) mod runtime { pub const ExistentialDeposit: Balance = 10; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; } impl pallet_balances::Config for Test { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; type Balance = Balance; type DustRemoval = (); type RuntimeEvent = RuntimeEvent; @@ -158,6 +165,7 @@ pub(crate) mod runtime { type OwnerOrigin = TestOwnerOrigin; type OriginSuccess = TestOriginSuccess; type Currency = Balances; + type RuntimeHoldReason = RuntimeHoldReason; type Deposit = Web3NameDeposit; type RuntimeEvent = RuntimeEvent; type MaxNameLength = MaxNameLength; @@ -224,7 +232,8 @@ pub(crate) mod runtime { ext.execute_with(|| { for (owner, web3_name, payer) in self.claimed_web3_names { - pallet_web3_names::Pallet::::register_name(web3_name, owner, payer); + pallet_web3_names::Pallet::::register_name(web3_name, owner, payer) + .expect("Could not register name"); } for web3_name in self.banned_web3_names { @@ -246,7 +255,7 @@ pub(crate) mod runtime { pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); - let keystore = sp_keystore::testing::KeyStore::new(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(std::sync::Arc::new(keystore))); ext diff --git a/pallets/pallet-web3-names/src/tests.rs b/pallets/pallet-web3-names/src/tests.rs index a69f2c0871..088b5c43b9 100644 --- a/pallets/pallet-web3-names/src/tests.rs +++ b/pallets/pallet-web3-names/src/tests.rs @@ -16,13 +16,17 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::{assert_noop, assert_ok, BoundedVec}; +use frame_support::{ + assert_noop, assert_ok, + traits::fungible::{Inspect, InspectHold}, + BoundedVec, +}; use frame_system::RawOrigin; -use kilt_support::{deposit::Deposit, mock::mock_origin}; -use sp_runtime::{traits::Zero, DispatchError}; +use kilt_support::{mock::mock_origin, Deposit}; +use sp_runtime::{traits::Zero, DispatchError, TokenError}; -use crate::{mock::*, Banned, Config, Error, Names, Owner, Pallet, Web3OwnershipOf}; +use crate::{mock::*, Banned, Config, Error, HoldReason, Names, Owner, Pallet, Web3OwnershipOf}; // ############################################################################# // Name claiming @@ -36,7 +40,7 @@ fn claiming_successful() { .build_and_execute_with_sanity_tests(|| { assert!(Names::::get(&DID_00).is_none()); assert!(Owner::::get(&web3_name_00).is_none()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); assert_ok!(Pallet::::claim( mock_origin::DoubleOrigin(ACCOUNT_00, DID_00).into(), @@ -60,11 +64,11 @@ fn claiming_successful() { } ); // Test that the deposit was reserved correctly. - assert_eq!(Balances::reserved_balance(ACCOUNT_00), Web3NameDeposit::get()); assert_eq!( - Balances::free_balance(ACCOUNT_00), - initial_balance - Web3NameDeposit::get(), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + Web3NameDeposit::get() ); + assert_eq!(Balances::balance(&ACCOUNT_00), initial_balance - Web3NameDeposit::get(),); // Test that the same name cannot be claimed again. assert_noop!( @@ -172,8 +176,8 @@ fn releasing_by_owner_successful() { assert!(Owner::::get(&web3_name_00).is_none()); // Test that the deposit was returned to the payer correctly. - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert_eq!(Balances::free_balance(ACCOUNT_00), initial_balance); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert_eq!(Balances::balance(&ACCOUNT_00), initial_balance); }) } @@ -192,10 +196,9 @@ fn releasing_by_payer_successful() { )); assert!(Names::::get(&DID_00).is_none()); assert!(Owner::::get(&web3_name_00).is_none()); - // Test that the deposit was returned to the payer correctly. - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert_eq!(Balances::free_balance(ACCOUNT_00), initial_balance); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert_eq!(Balances::balance(&ACCOUNT_00), initial_balance); }) } @@ -265,8 +268,8 @@ fn banning_successful() { assert!(Owner::::get(&web3_name_00).is_none()); assert!(Banned::::get(&web3_name_00).is_some()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert_eq!(Balances::free_balance(ACCOUNT_00), initial_balance); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert_eq!(Balances::balance(&ACCOUNT_00), initial_balance); // Ban an unclaimed name assert_ok!(Pallet::::ban(RawOrigin::Root.into(), web3_name_01.clone().0)); @@ -385,8 +388,11 @@ fn test_change_deposit_owner() { amount: ::Deposit::get() } ); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); }) } @@ -400,7 +406,7 @@ fn test_change_deposit_owner_insufficient_balance() { .build_and_execute_with_sanity_tests(|| { assert_noop!( Pallet::::change_deposit_owner(mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into()), - pallet_balances::Error::::InsufficientBalance + TokenError::CannotCreateHold ); }) } @@ -435,7 +441,7 @@ fn test_update_deposit() { ::Deposit::get() * 2, ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 2 ); assert_ok!(Pallet::::update_deposit( @@ -451,7 +457,10 @@ fn test_update_deposit() { amount: ::Deposit::get() } ); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); }) } @@ -470,7 +479,7 @@ fn test_update_deposit_unauthorized() { ::Deposit::get() * 2, ); assert_eq!( - Balances::reserved_balance(ACCOUNT_00), + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), ::Deposit::get() * 2 ); assert_noop!( diff --git a/pallets/parachain-staking/src/api.rs b/pallets/parachain-staking/src/api.rs index 310d9721a5..2e2631d096 100644 --- a/pallets/parachain-staking/src/api.rs +++ b/pallets/parachain-staking/src/api.rs @@ -20,7 +20,7 @@ use crate::{ types::BalanceOf, BlocksAuthored, BlocksRewarded, CandidatePool, Config, DelegatorState, InflationConfig, Pallet, Rewards, TotalCollatorStake, }; -use frame_support::traits::Currency; +use frame_support::traits::fungible::Inspect; use sp_runtime::{ traits::{Saturating, Zero}, Perquintill, diff --git a/pallets/parachain-staking/src/benchmarking.rs b/pallets/parachain-staking/src/benchmarking.rs index 875a994ff6..63ea27237a 100644 --- a/pallets/parachain-staking/src/benchmarking.rs +++ b/pallets/parachain-staking/src/benchmarking.rs @@ -22,7 +22,10 @@ use crate::{types::RoundInfo, *}; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, Zero}; use frame_support::{ assert_ok, - traits::{Currency, Get, OnInitialize}, + traits::{ + fungible::{Inspect, Mutate}, + Get, OnInitialize, + }, }; use frame_system::{Pallet as System, RawOrigin}; use pallet_session::Pallet as Session; @@ -39,7 +42,10 @@ const DELEGATOR_ACCOUNT_SEED: u32 = 1; fn setup_collator_candidates( num_candidates: u32, default_amount: Option, -) -> Vec { +) -> Vec +where + ::Currency: Mutate, +{ let current_collator_count = TopCandidates::::get().len().saturated_into::(); let collators: Vec = (current_collator_count..num_candidates) .map(|i| account("collator", i.saturated_into::(), COLLATOR_ACCOUNT_SEED)) @@ -47,7 +53,7 @@ fn setup_collator_candidates( let amount: T::CurrencyBalance = default_amount.unwrap_or_else(T::MinCollatorCandidateStake::get); for acc in collators.iter() { - T::Currency::make_free_balance_be(acc, amount); + >::set_balance(acc, amount); assert_ok!(Pallet::::join_candidates( T::RuntimeOrigin::from(Some(acc.clone()).into()), amount, @@ -63,7 +69,10 @@ fn setup_collator_candidates( .collect() } -fn fill_delegators(num_delegators: u32, collator: T::AccountId, collator_seed: u32) -> Vec { +fn fill_delegators(num_delegators: u32, collator: T::AccountId, collator_seed: u32) -> Vec +where + ::Currency: Mutate, +{ let state = CandidatePool::::get(&collator).unwrap(); let current_delegators = state.delegators.len().saturated_into::(); @@ -78,7 +87,7 @@ fn fill_delegators(num_delegators: u32, collator: T::AccountId, colla .collect(); for acc in delegators.iter() { - T::Currency::make_free_balance_be(acc, T::MinDelegatorStake::get()); + >::set_balance(acc, T::MinDelegatorStake::get()); assert_ok!(Pallet::::join_delegators( T::RuntimeOrigin::from(Some(acc.clone()).into()), T::Lookup::unlookup(collator.clone()), @@ -115,7 +124,9 @@ where } benchmarks! { - where_clause { where u64: Into<::BlockNumber> } + where_clause { where u64: Into<::BlockNumber>, + ::Currency: Mutate + } on_initialize_no_action { assert_eq!(Round::::get().current, 0u32); @@ -243,7 +254,7 @@ benchmarks! { } let new_candidate = account("new_collator", u32::MAX , COLLATOR_ACCOUNT_SEED); - T::Currency::make_free_balance_be(&new_candidate, min_candidate_stake); + T::Currency::set_balance(&new_candidate, min_candidate_stake); let origin = RawOrigin::Signed(new_candidate.clone()); }: _(origin, min_candidate_stake) @@ -305,7 +316,7 @@ benchmarks! { // increase stake so we can unstake, because current stake is minimum let more_stake = T::MinCollatorCandidateStake::get(); - T::Currency::make_free_balance_be(&candidate, T::CurrencyBalance::from(u128::MAX)); + T::Currency::set_balance(&candidate, T::CurrencyBalance::from(10u128.pow(20))); assert_ok!(Pallet::::candidate_stake_more(RawOrigin::Signed(candidate.clone()).into(), more_stake)); // fill unstake BTreeMap by unstaked many entries of 1 @@ -344,7 +355,7 @@ benchmarks! { let more_stake = T::MinCollatorCandidateStake::get(); // increase stake so we can unstake, because current stake is minimum - T::Currency::make_free_balance_be(&candidate, T::CurrencyBalance::from(u128::MAX)); + T::Currency::set_balance(&candidate, T::CurrencyBalance::from(10u128.pow(20))); assert_ok!(Pallet::::candidate_stake_more(RawOrigin::Signed(candidate.clone()).into(), more_stake)); // fill unstake BTreeMap by unstaked many entries of 1 @@ -372,7 +383,7 @@ benchmarks! { let old_stake = CandidatePool::::get(&candidate).unwrap().stake; let more_stake = T::MinCollatorCandidateStake::get(); - T::Currency::make_free_balance_be(&candidate, T::CurrencyBalance::from(u128::MAX)); + T::Currency::set_balance(&candidate, T::CurrencyBalance::from(10u128.pow(20))); Pallet::::candidate_stake_more(RawOrigin::Signed(candidate.clone()).into(), more_stake).expect("should increase stake"); let new_stake = CandidatePool::::get(&candidate).unwrap().stake; @@ -396,7 +407,7 @@ benchmarks! { let collator = candidates[0].clone(); let delegator = account("new-delegator", 0, DELEGATOR_ACCOUNT_SEED); let amount = T::MinDelegatorStake::get(); - T::Currency::make_free_balance_be(&delegator, amount + amount + amount + amount); + T::Currency::set_balance(&delegator, amount + amount + amount + amount); let unlookup_collator = T::Lookup::unlookup(collator.clone()); @@ -427,7 +438,7 @@ benchmarks! { assert_eq!(DelegatorState::::get(&delegator).unwrap().amount, amount); // increase stake so we can unstake, because current stake is minimum - T::Currency::make_free_balance_be(&delegator, T::CurrencyBalance::from(u128::MAX)); + T::Currency::set_balance(&delegator, T::CurrencyBalance::from(10u128.pow(15))); assert_ok!(Pallet::::delegator_stake_more(RawOrigin::Signed(delegator.clone()).into(), T::CurrencyBalance::from(u as u64))); assert_eq!(DelegatorState::::get(&delegator).unwrap().amount, amount + T::CurrencyBalance::from(u as u64)); @@ -463,7 +474,7 @@ benchmarks! { assert_eq!(DelegatorState::::get(&delegator).unwrap().amount, T::MinDelegatorStake::get()); // increase stake so we can unstake, because current stake is minimum - T::Currency::make_free_balance_be(&delegator, T::CurrencyBalance::from(u128::MAX)); + T::Currency::set_balance(&delegator, T::CurrencyBalance::from(10u128.pow(15))); assert_ok!(Pallet::::delegator_stake_more(RawOrigin::Signed(delegator.clone()).into(), amount + amount)); assert_eq!(DelegatorState::::get(&delegator).unwrap().amount, T::MinDelegatorStake::get() + amount + amount); @@ -500,7 +511,7 @@ benchmarks! { assert_eq!(DelegatorState::::get(&delegator).unwrap().amount, T::MinDelegatorStake::get()); // increase stake so we can unstake, because current stake is minimum - T::Currency::make_free_balance_be(&delegator, T::CurrencyBalance::from(u128::MAX)); + T::Currency::set_balance(&delegator, T::CurrencyBalance::from(10u128.pow(15))); assert_ok!(Pallet::::delegator_stake_more(RawOrigin::Signed(delegator.clone()).into(), amount + amount)); assert_eq!(DelegatorState::::get(&delegator).unwrap().amount, T::MinDelegatorStake::get() + amount + amount); @@ -522,9 +533,9 @@ benchmarks! { let u in 1 .. (T::MaxUnstakeRequests::get() - 1); let candidate = account("collator", 0u32, COLLATOR_ACCOUNT_SEED); - let free_balance = T::CurrencyBalance::from(u128::MAX); + let free_balance = T::CurrencyBalance::from(10u128.pow(15)); let stake = T::MinCollatorCandidateStake::get(); - T::Currency::make_free_balance_be(&candidate, free_balance); + T::Currency::set_balance(&candidate, free_balance); assert_ok!(Pallet::::join_candidates( T::RuntimeOrigin::from(Some(candidate.clone()).into()), stake, @@ -591,7 +602,7 @@ benchmarks! { claim_rewards { let beneficiary = account("beneficiary", 0, 0); let amount = T::MinCollatorCandidateStake::get(); - T::Currency::make_free_balance_be(&beneficiary, amount); + T::Currency::set_balance(&beneficiary, amount); Rewards::::insert(&beneficiary, amount); assert_eq!(pallet_balances::Pallet::::usable_balance(&beneficiary), amount.into()); let origin = RawOrigin::Signed(beneficiary.clone()); diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 84216313cc..cd53f35c8f 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -71,14 +71,14 @@ //! //! ### Terminology //! -//! - **Candidate:** A user which locks up tokens to be included into the set of -//! authorities which author blocks and receive rewards for doing so. +//! - **Candidate:** A user which freezes up tokens to be included into the set +//! of authorities which author blocks and receive rewards for doing so. //! //! - **Collator:** A candidate that was chosen to collate this round. //! -//! - **Delegator:** A user which locks up tokens for collators they trust. When -//! their collator authors a block, the corresponding delegators also receive -//! rewards. +//! - **Delegator:** A user which freezes up tokens for collators they trust. +//! When their collator authors a block, the corresponding delegators also +//! receive rewards. //! //! - **Total Stake:** A collator’s own stake + the sum of delegated stake to //! this collator. @@ -98,8 +98,8 @@ //! a staking round, thus both words are interchangeable in the context of //! this pallet. //! -//! - **Lock:** A freeze on a specified amount of an account's free balance -//! until a specified block number. Multiple locks always operate over the +//! - **Freeze:** A freeze on a specified amount of an account's free balance +//! until a specified block number. Multiple freezes always operate over the //! same funds, so they "overlay" rather than "stack" //! //! ## Genesis config @@ -119,7 +119,6 @@ pub mod benchmarking; pub mod default_weights; -pub mod migration; #[cfg(test)] pub(crate) mod mock; #[cfg(test)] @@ -130,6 +129,7 @@ mod try_state; pub mod api; mod inflation; +pub mod migrations; mod set; mod types; @@ -148,13 +148,17 @@ pub mod pallet { pallet_prelude::*, storage::bounded_btree_map::BoundedBTreeMap, traits::{ - Currency, EstimateNextSessionRotation, Get, Imbalance, LockIdentifier, LockableCurrency, OnUnbalanced, - ReservableCurrency, StorageVersion, WithdrawReasons, + fungible::Balanced, + tokens::{ + fungible::{Inspect, MutateFreeze, Unbalanced}, + Fortitude, Precision, Preservation, + }, + EstimateNextSessionRotation, Get, OnUnbalanced, StorageVersion, }, BoundedVec, }; use frame_system::pallet_prelude::*; - use pallet_balances::{BalanceLock, Locks}; + use pallet_balances::{Freezes, IdAmount}; use pallet_session::ShouldEndSession; use scale_info::TypeInfo; use sp_runtime::{ @@ -163,21 +167,19 @@ pub mod pallet { }; use sp_staking::SessionIndex; use sp_std::prelude::*; + use types::AccountIdOf; use crate::{ set::OrderedSet, types::{ - BalanceOf, Candidate, CandidateOf, CandidateStatus, DelegationCounter, Delegator, NegativeImbalanceOf, - RoundInfo, Stake, StakeOf, TotalStake, + BalanceOf, Candidate, CandidateOf, CandidateStatus, CreditOf, DelegationCounter, Delegator, RoundInfo, + Stake, StakeOf, TotalStake, }, }; use sp_std::{convert::TryInto, fmt::Debug}; - /// Kilt-specific lock for staking rewards. - pub(crate) const STAKING_ID: LockIdentifier = *b"kiltpstk"; - /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(8); + pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(9); /// The 5.1% inflation rate of the third year const INFLATION_3RD_YEAR: Perquintill = Perquintill::from_parts(51_000_000_000_000_000); @@ -187,6 +189,11 @@ pub mod pallet { #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData); + #[pallet::composite_enum] + pub enum FreezeReason { + Staking, + } + /// Configuration trait of this pallet. #[pallet::config] pub trait Config: frame_system::Config + pallet_balances::Config + pallet_session::Config { @@ -197,10 +204,17 @@ pub mod pallet { // multiplication /// The currency type /// Note: Declaration of Balance taken from pallet_gilt - type Currency: Currency - + ReservableCurrency - + LockableCurrency - + Eq; + type Currency: Balanced + + MutateFreeze< + Self::AccountId, + Balance = Self::CurrencyBalance, + Id = ::FreezeIdentifier, + > + Eq; + + type FreezeIdentifier: From + + PartialEq + + Eq + + Into<::FreezeIdentifier>; /// Just the `Currency::Balance` type; we have this item to allow us to /// constrain it to `From`. @@ -303,7 +317,7 @@ pub mod pallet { type NetworkRewardRate: Get; /// The beneficiary to receive the network rewards. - type NetworkRewardBeneficiary: OnUnbalanced>; + type NetworkRewardBeneficiary: OnUnbalanced>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -691,7 +705,7 @@ pub mod pallet { // Setup delegate & collators for &(ref actor, ref opt_val, balance) in &self.stakers { assert!( - T::Currency::free_balance(actor) >= balance, + T::Currency::reducible_balance(actor, Preservation::Expendable, Fortitude::Polite) >= balance, "Account does not have enough balance to stake." ); if let Some(delegated_val) = opt_val { @@ -903,7 +917,7 @@ pub mod pallet { /// delegators. /// /// Prepares unstaking of the candidates and their delegators stake - /// which can be unlocked via `unlock_unstaked` after waiting at + /// which can be unfreezed via `unlock_unstaked` after waiting at /// least `StakeDuration` many blocks. Also increments rewards for the /// collator and their delegators. /// @@ -1092,7 +1106,7 @@ pub mod pallet { /// Execute the network exit of a candidate who requested to leave at /// least `ExitQueueDelay` rounds ago. Prepares unstaking of the - /// candidates and their delegators stake which can be unlocked via + /// candidates and their delegators stake which can be unfreezed via /// `unlock_unstaked` after waiting at least `StakeDuration` many /// blocks. /// @@ -1347,7 +1361,7 @@ pub mod pallet { // check balance ensure!( - pallet_balances::Pallet::::free_balance(acc.clone()) >= amount.into(), + pallet_balances::Pallet::::balance(&acc) >= amount.into(), pallet_balances::Error::::InsufficientBalance ); @@ -1624,9 +1638,9 @@ pub mod pallet { /// /// Weight: O(U) where U is the number of locked unstaking requests /// bounded by `MaxUnstakeRequests`. - /// - Reads: [Origin Account], Unstaking, Locks - /// - Writes: Unstaking, Locks - /// - Kills: Unstaking & Locks if no balance is locked anymore + /// - Reads: [Origin Account], Unstaking, Freezes + /// - Writes: Unstaking, Freezes + /// - Kills: Unstaking & Freezes if no balance is locked anymore /// # #[pallet::call_index(16)] #[pallet::weight(::WeightInfo::unlock_unstaked( @@ -1669,9 +1683,10 @@ pub mod pallet { ensure!(!rewards.is_zero(), Error::::RewardsNotFound); // mint into target - let rewards = T::Currency::deposit_into_existing(&target, rewards)?; + let rewards = + >>::increase_balance(&target, rewards, Precision::Exact)?; - Self::deposit_event(Event::Rewarded(target, rewards.peek())); + Self::deposit_event(Event::Rewarded(target, rewards)); Ok(()) } @@ -2158,7 +2173,13 @@ pub mod pallet { /// amount and updates `Unstaking` storage accordingly. fn increase_lock(who: &T::AccountId, amount: BalanceOf, more: BalanceOf) -> Result { ensure!( - pallet_balances::Pallet::::free_balance(who) >= amount.into(), + pallet_balances::Pallet::::reducible_balance(who, Preservation::Preserve, Fortitude::Polite) + >= more.into(), + pallet_balances::Error::::InsufficientBalance + ); + + ensure!( + >>::total_balance(who) >= amount, pallet_balances::Error::::InsufficientBalance ); @@ -2194,13 +2215,13 @@ pub mod pallet { // Either set a new lock or potentially extend the existing one if amount // exceeds the currently locked amount - T::Currency::extend_lock(STAKING_ID, who, amount, WithdrawReasons::all()); + T::Currency::extend_freeze(&FreezeReason::Staking.into(), who, amount)?; Ok(unstaking_len) } /// Set the unlocking block for the account and corresponding amount - /// which can be unlocked via `unlock_unstaked` after waiting at + /// which can be unfreezed via `unlock_unstaked` after waiting at /// least for `StakeDuration` many blocks. /// /// Throws if the amount is zero (unlikely) or if active unlocking @@ -2293,38 +2314,49 @@ pub mod pallet { let unstaking_len = unstaking.len().saturated_into::(); ensure!(!unstaking.is_empty(), Error::::UnstakingIsEmpty); - let mut total_unlocked: BalanceOf = Zero::zero(); - let mut total_locked: BalanceOf = Zero::zero(); + let mut total_unfreezed: BalanceOf = Zero::zero(); + let mut total_freezed: BalanceOf = Zero::zero(); let mut expired = Vec::new(); - // check potential unlocks - for (block_number, locked_balance) in unstaking.clone().into_iter() { + // check potential unfreezed + for (block_number, freezed_balance) in unstaking.clone().into_iter() { if block_number <= now { expired.push(block_number); - total_unlocked = total_unlocked.saturating_add(locked_balance); + total_unfreezed = total_unfreezed.saturating_add(freezed_balance); } else { - total_locked = total_locked.saturating_add(locked_balance); + total_freezed = total_freezed.saturating_add(freezed_balance); } } for block_number in expired { unstaking.remove(&block_number); } - // iterate balance locks to retrieve amount of locked balance - let locks = Locks::::get(who); - total_locked = if let Some(BalanceLock { amount, .. }) = locks.iter().find(|l| l.id == STAKING_ID) { - amount.saturating_sub(total_unlocked.into()).into() + // iterate balance freezes to retrieve amount of freezed balance + let freezes = Freezes::::get(who); + + total_freezed = if let Some(IdAmount { amount, .. }) = freezes + .iter() + .find(|l| l.id == ::FreezeIdentifier::from(FreezeReason::Staking).into()) + { + amount.saturating_sub(total_unfreezed.into()).into() } else { // should never fail to find the lock since we checked whether unstaking is not // empty but let's be safe Zero::zero() }; - if total_locked.is_zero() { - T::Currency::remove_lock(STAKING_ID, who); + if total_freezed.is_zero() { + T::Currency::thaw( + &::FreezeIdentifier::from(FreezeReason::Staking), + who, + )?; Unstaking::::remove(who); } else { - T::Currency::set_lock(STAKING_ID, who, total_locked, WithdrawReasons::all()); + T::Currency::set_freeze( + &::FreezeIdentifier::from(FreezeReason::Staking), + who, + total_freezed, + )?; Unstaking::::insert(who, unstaking); } @@ -2373,7 +2405,7 @@ pub mod pallet { /// /// `col_reward_rate_per_block * col_max_stake * max_num_of_collators * /// NetworkRewardRate` - fn issue_network_reward() -> NegativeImbalanceOf { + fn issue_network_reward() -> CreditOf { // Multiplication with Perquintill cannot overflow let max_col_rewards = InflationConfig::::get().collator.reward_rate.per_block * MaxCollatorCandidateStake::::get() @@ -2389,7 +2421,7 @@ pub mod pallet { /// Depends on the current total issuance and staking reward /// configuration for collators. pub(crate) fn calc_block_rewards_collator(stake: BalanceOf, multiplier: BalanceOf) -> BalanceOf { - let total_issuance = T::Currency::total_issuance(); + let total_issuance = >>::total_issuance(); let TotalStake { collators: total_collators, .. @@ -2407,7 +2439,7 @@ pub mod pallet { /// Depends on the current total issuance and staking reward /// configuration for delegators. pub(crate) fn calc_block_rewards_delegator(stake: BalanceOf, multiplier: BalanceOf) -> BalanceOf { - let total_issuance = T::Currency::total_issuance(); + let total_issuance = >>::total_issuance(); let TotalStake { delegators: total_delegators, .. diff --git a/pallets/parachain-staking/src/migration.rs b/pallets/parachain-staking/src/migration.rs deleted file mode 100644 index 79e74681a2..0000000000 --- a/pallets/parachain-staking/src/migration.rs +++ /dev/null @@ -1,17 +0,0 @@ -// KILT Blockchain – https://botlabs.org -// Copyright (C) 2019-2023 BOTLabs GmbH - -// The KILT Blockchain is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The KILT Blockchain is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// If you feel like getting in touch with us, you can do so at info@botlabs.org diff --git a/pallets/parachain-staking/src/migrations.rs b/pallets/parachain-staking/src/migrations.rs new file mode 100644 index 0000000000..c3ffb81159 --- /dev/null +++ b/pallets/parachain-staking/src/migrations.rs @@ -0,0 +1,158 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + traits::{ + fungible::freeze::Mutate as MutateFreeze, Get, GetStorageVersion, LockIdentifier, LockableCurrency, + OnRuntimeUpgrade, ReservableCurrency, StorageVersion, + }, + weights::Weight, +}; +use pallet_balances::{BalanceLock, Freezes, IdAmount, Locks}; +use sp_runtime::SaturatedConversion; +use sp_std::marker::PhantomData; + +use crate::{ + types::{AccountIdOf, CurrencyOf}, + Config, FreezeReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION, +}; + +const STAKING_ID: LockIdentifier = *b"kiltpstk"; + +const CURRENT_STORAGE_VERSION: StorageVersion = StorageVersion::new(8); + +pub struct BalanceMigration(PhantomData); + +impl OnRuntimeUpgrade for BalanceMigration +where + ::Currency: ReservableCurrency, + ::Currency: LockableCurrency, +{ + fn on_runtime_upgrade() -> frame_support::weights::Weight { + log::info!("Staking: Initiating migration"); + + let onchain_storage_version = Pallet::::on_chain_storage_version(); + if onchain_storage_version == CURRENT_STORAGE_VERSION { + TARGET_STORAGE_VERSION.put::>(); + ::DbWeight::get() + .reads_writes(1, 1) + .saturating_add(do_migration::()) + } else { + log::info!( + "Staking: No migration needed. This file should be deleted. Current storage version: {:?}, Required Version for update: {:?}", + onchain_storage_version, + CURRENT_STORAGE_VERSION + ); + ::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + use sp_runtime::traits::Zero; + use sp_std::vec; + + let count_freezes = pallet_balances::Freezes::::iter().count(); + assert!(count_freezes.is_zero(), "Staking Pre: There are already freezes."); + + assert_eq!(Pallet::::on_chain_storage_version(), CURRENT_STORAGE_VERSION); + + log::info!("Staking: Pre migration checks successful"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_pre_state: sp_std::vec::Vec) -> Result<(), &'static str> { + use sp_runtime::traits::Zero; + + let count_freezes = pallet_balances::Freezes::::iter().count(); + + assert!(!count_freezes.is_zero(), "Staking: There are still no freezes."); + + assert_eq!(Pallet::::on_chain_storage_version(), TARGET_STORAGE_VERSION); + + log::info!("Staking: Post migration checks successful"); + + Ok(()) + } +} + +fn do_migration() -> Weight +where + ::Currency: ReservableCurrency, + ::Currency: LockableCurrency, +{ + Locks::::iter() + .map(|(user_id, locks)| { + let weight = locks + .iter() + .map(|lock: &BalanceLock<_>| -> Weight { + if lock.id == STAKING_ID { + return update_or_create_freeze::(user_id.clone(), lock); + } + ::DbWeight::get().reads_writes(0, 0) + }) + .fold(Weight::zero(), |acc, next| acc.saturating_add(next)); + weight + }) + .fold(Weight::zero(), |acc, next| acc.saturating_add(next)) +} + +fn update_or_create_freeze( + user_id: T::AccountId, + lock: &BalanceLock<::Balance>, +) -> Weight +where + CurrencyOf: LockableCurrency>, +{ + let freezes = Freezes::::get(&user_id); + + let result = if let Some(IdAmount { amount, .. }) = freezes + .iter() + .find(|freeze| freeze.id == ::FreezeIdentifier::from(FreezeReason::Staking).into()) + { + let total_lock = lock + .amount + .saturated_into::() + .saturating_add((*amount).saturated_into()); + + as MutateFreeze>>::extend_freeze( + &::FreezeIdentifier::from(FreezeReason::Staking), + &user_id, + total_lock.saturated_into(), + ) + } else { + as MutateFreeze>>::set_freeze( + &::FreezeIdentifier::from(FreezeReason::Staking), + &user_id, + lock.amount.saturated_into(), + ) + }; + + as LockableCurrency>>::remove_lock(STAKING_ID, &user_id); + + if result.is_err() { + return ::DbWeight::get().reads(1); + } + + // Currency::reserve and Currency::hold each read and write to the DB once. + // Since we are uncertain about which operation may fail, in the event of an + // error, we assume the worst-case scenario here. + ::DbWeight::get().reads_writes(2, 2) +} diff --git a/pallets/parachain-staking/src/mock.rs b/pallets/parachain-staking/src/mock.rs index ea50a31fd1..2838b8efaf 100644 --- a/pallets/parachain-staking/src/mock.rs +++ b/pallets/parachain-staking/src/mock.rs @@ -20,10 +20,10 @@ #![allow(clippy::from_over_into)] use super::*; -use crate::{self as stake, types::NegativeImbalanceOf}; +use crate::{self as stake, types::CreditOf}; use frame_support::{ assert_ok, construct_runtime, parameter_types, - traits::{Currency, GenesisBuild, OnFinalize, OnInitialize, OnUnbalanced}, + traits::{fungible::Balanced, GenesisBuild, OnFinalize, OnInitialize, OnUnbalanced}, }; use pallet_authorship::EventHandler; use sp_consensus_aura::sr25519::AuthorityId; @@ -59,7 +59,7 @@ construct_runtime!( Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Aura: pallet_aura::{Pallet, Storage}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - StakePallet: stake::{Pallet, Call, Storage, Config, Event}, + StakePallet: stake::{Pallet, Call, Storage, Config, Event, FreezeReason}, Authorship: pallet_authorship::{Pallet, Storage}, } ); @@ -99,9 +99,15 @@ impl frame_system::Config for Test { } parameter_types! { pub const ExistentialDeposit: Balance = 1; + pub const MaxFreezes : u32 = 50; + pub const MaxHolds : u32 = 50; } impl pallet_balances::Config for Test { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; @@ -143,10 +149,10 @@ parameter_types! { } pub struct ToBeneficiary(); -impl OnUnbalanced> for ToBeneficiary { - fn on_nonzero_unbalanced(amount: NegativeImbalanceOf) { +impl OnUnbalanced> for ToBeneficiary { + fn on_nonzero_unbalanced(amount: CreditOf) { // Must resolve into existing but better to be safe. - ::Currency::resolve_creating(&TREASURY_ACC, amount); + let _ = ::Currency::resolve(&TREASURY_ACC, amount); } } @@ -171,6 +177,7 @@ impl Config for Test { type NetworkRewardStart = NetworkRewardStart; type NetworkRewardBeneficiary = ToBeneficiary; type WeightInfo = (); + type FreezeIdentifier = RuntimeFreezeReason; const BLOCKS_PER_YEAR: Self::BlockNumber = 5 * 60 * 24 * 36525 / 100; } diff --git a/pallets/parachain-staking/src/tests.rs b/pallets/parachain-staking/src/tests.rs index 597a193c00..c131360dfc 100644 --- a/pallets/parachain-staking/src/tests.rs +++ b/pallets/parachain-staking/src/tests.rs @@ -21,12 +21,14 @@ use std::{convert::TryInto, iter}; use frame_support::{ - assert_noop, assert_ok, storage::bounded_btree_map::BoundedBTreeMap, traits::EstimateNextSessionRotation, + assert_noop, assert_ok, + storage::bounded_btree_map::BoundedBTreeMap, + traits::{fungible::Inspect, EstimateNextSessionRotation}, BoundedVec, }; use kilt_runtime_api_staking::StakingRates; use pallet_authorship::EventHandler; -use pallet_balances::{BalanceLock, Error as BalancesError, Reasons}; +use pallet_balances::{Error as BalancesError, Freezes, IdAmount}; use pallet_session::{SessionManager, ShouldEndSession}; use sp_runtime::{traits::Zero, Perbill, Permill, Perquintill, SaturatedConversion}; @@ -39,7 +41,7 @@ use crate::{ types::{ BalanceOf, Candidate, CandidateStatus, DelegationCounter, Delegator, RoundInfo, Stake, StakeOf, TotalStake, }, - CandidatePool, Config, Error, Event, Event as StakeEvent, InflationInfo, RewardRate, StakingInfo, STAKING_ID, + CandidatePool, Config, Error, Event, Event as StakeEvent, FreezeReason, InflationInfo, RewardRate, StakingInfo, }; #[test] @@ -114,7 +116,7 @@ fn genesis() { // 1 assert_eq!(Balances::usable_balance(1), 500); - assert_eq!(Balances::free_balance(1), 1000); + assert_eq!(Balances::balance(&1), 1000); assert!(StakePallet::is_active_candidate(&1).is_some()); assert_eq!( StakePallet::candidate_pool(1), @@ -137,7 +139,7 @@ fn genesis() { ); // 2 assert_eq!(Balances::usable_balance(2), 100); - assert_eq!(Balances::free_balance(2), 300); + assert_eq!(Balances::balance(&2), 300); assert!(StakePallet::is_active_candidate(&2).is_some()); assert_eq!( StakePallet::candidate_pool(2), @@ -169,17 +171,17 @@ fn genesis() { for x in 3..7 { assert!(StakePallet::is_delegator(&x)); assert_eq!(Balances::usable_balance(x), 0); - assert_eq!(Balances::free_balance(x), 100); + assert_eq!(Balances::balance(&x), 100); } // Uninvolved for x in 7..10 { assert!(!StakePallet::is_delegator(&x)); } - assert_eq!(Balances::free_balance(7), 100); + assert_eq!(Balances::balance(&7), 100); assert_eq!(Balances::usable_balance(7), 100); - assert_eq!(Balances::free_balance(8), 9); + assert_eq!(Balances::balance(&8), 9); assert_eq!(Balances::usable_balance(8), 9); - assert_eq!(Balances::free_balance(9), 4); + assert_eq!(Balances::balance(&9), 4); assert_eq!(Balances::usable_balance(9), 4); // Safety first checks @@ -232,16 +234,16 @@ fn genesis() { ); for x in 1..5 { assert!(StakePallet::is_active_candidate(&x).is_some()); - assert_eq!(Balances::free_balance(x), 100); + assert_eq!(Balances::balance(&x), 100); assert_eq!(Balances::usable_balance(x), 80); } assert!(StakePallet::is_active_candidate(&5).is_some()); - assert_eq!(Balances::free_balance(5), 100); + assert_eq!(Balances::balance(&5), 100); assert_eq!(Balances::usable_balance(5), 90); // Delegators for x in 6..11 { assert!(StakePallet::is_delegator(&x)); - assert_eq!(Balances::free_balance(x), 100); + assert_eq!(Balances::balance(&x), 100); assert_eq!(Balances::usable_balance(x), 90); } @@ -973,8 +975,8 @@ fn multiple_delegations() { assert_eq!(StakePallet::delegator_state(17).unwrap().amount, 11); assert_eq!(Balances::usable_balance(8), 90); assert_eq!(Balances::usable_balance(17), 89); - assert_eq!(Balances::free_balance(8), 100); - assert_eq!(Balances::free_balance(17), 100); + assert_eq!(Balances::balance(&8), 100); + assert_eq!(Balances::balance(&17), 100); roll_to(35, vec![Some(1), Some(2), Some(3), Some(4)]); assert_ok!(StakePallet::execute_leave_candidates(RuntimeOrigin::signed(2), 2)); @@ -998,8 +1000,8 @@ fn multiple_delegations() { ); assert_eq!(Balances::usable_balance(17), 100); assert_eq!(Balances::usable_balance(8), 100); - assert_eq!(Balances::free_balance(17), 100); - assert_eq!(Balances::free_balance(8), 100); + assert_eq!(Balances::balance(&17), 100); + assert_eq!(Balances::balance(&8), 100); }); } @@ -1287,7 +1289,7 @@ fn delegators_bond() { assert_ok!(StakePallet::execute_leave_candidates(RuntimeOrigin::signed(1), 1)); assert!(!StakePallet::is_delegator(&6)); assert_eq!(Balances::usable_balance(6), 80); - assert_eq!(Balances::free_balance(6), 100); + assert_eq!(Balances::balance(&6), 100); }); } @@ -1612,11 +1614,11 @@ fn coinbase_rewards_many_blocks_simple_check() { let authors: Vec> = (0u64..=end_block).map(|i| Some(i % 2 + 1)).collect(); roll_to_claim_rewards(end_block, authors); - let rewards_1 = Balances::free_balance(1).saturating_sub(40_000_000 * DECIMALS); - let rewards_2 = Balances::free_balance(2).saturating_sub(40_000_000 * DECIMALS); - let rewards_3 = Balances::free_balance(3).saturating_sub(40_000_000 * DECIMALS); - let rewards_4 = Balances::free_balance(4).saturating_sub(20_000_000 * DECIMALS); - let rewards_5 = Balances::free_balance(5).saturating_sub(20_000_000 * DECIMALS); + let rewards_1 = Balances::balance(&1).saturating_sub(40_000_000 * DECIMALS); + let rewards_2 = Balances::balance(&2).saturating_sub(40_000_000 * DECIMALS); + let rewards_3 = Balances::balance(&3).saturating_sub(40_000_000 * DECIMALS); + let rewards_4 = Balances::balance(&4).saturating_sub(20_000_000 * DECIMALS); + let rewards_5 = Balances::balance(&5).saturating_sub(20_000_000 * DECIMALS); let expected_collator_rewards = num_of_years * inflation.collator.reward_rate.annual * 16_000_000 * DECIMALS; let expected_delegator_rewards = @@ -2124,17 +2126,17 @@ fn unlock_unstaked() { let mut unstaking: BoundedBTreeMap, ::MaxUnstakeRequests> = BoundedBTreeMap::new(); assert_ok!(unstaking.try_insert(3, 100)); - let lock = BalanceLock { - id: STAKING_ID, + let freeze = IdAmount { + id: ::FreezeIdentifier::from(FreezeReason::Staking), amount: 100, - reasons: Reasons::All, }; + assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![freeze.clone()]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![freeze.clone()]); // join delegators and revoke again --> consume unstaking at block 3 roll_to(2, vec![]); @@ -2143,28 +2145,28 @@ fn unlock_unstaked() { unstaking.remove(&3); assert_ok!(unstaking.try_insert(4, 100)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![freeze.clone()]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![freeze.clone()]); // should reduce unlocking but not unlock anything roll_to(3, vec![]); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![freeze.clone()]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![freeze.clone()]); roll_to(4, vec![]); unstaking.remove(&4); - assert_eq!(Balances::locks(2), vec![lock]); + assert_eq!(Freezes::::get(2), vec![freeze]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![]); + assert_eq!(Freezes::::get(2), vec![]); }); // less_unstaked_than_restaked @@ -2181,17 +2183,16 @@ fn unlock_unstaked() { let mut unstaking: BoundedBTreeMap, ::MaxUnstakeRequests> = BoundedBTreeMap::new(); assert_ok!(unstaking.try_insert(3, 10)); - let mut lock = BalanceLock { - id: STAKING_ID, + let mut lock = IdAmount { + id: ::FreezeIdentifier::from(FreezeReason::Staking), amount: 10, - reasons: Reasons::All, }; assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // join delegators and revoke again roll_to(2, vec![]); @@ -2201,27 +2202,27 @@ fn unlock_unstaked() { assert_ok!(unstaking.try_insert(4, 100)); lock.amount = 100; assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); roll_to(3, vec![]); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // unlock unstaked, remove lock, empty unlocking roll_to(4, vec![]); unstaking.remove(&4); - assert_eq!(Balances::locks(2), vec![lock]); + assert_eq!(Freezes::::get(2), vec![lock]); assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![]); + assert_eq!(Freezes::::get(2), vec![]); }); // more_unstaked_than_restaked @@ -2240,17 +2241,16 @@ fn unlock_unstaked() { let mut unstaking: BoundedBTreeMap, ::MaxUnstakeRequests> = BoundedBTreeMap::new(); assert_ok!(unstaking.try_insert(3, 100)); - let mut lock = BalanceLock { - id: STAKING_ID, + let mut lock = IdAmount { + id: ::FreezeIdentifier::from(FreezeReason::Staking), amount: 100, - reasons: Reasons::All, }; assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // join delegators and revoke again roll_to(2, vec![]); @@ -2259,30 +2259,30 @@ fn unlock_unstaked() { assert_ok!(unstaking.try_insert(3, 90)); assert_ok!(unstaking.try_insert(4, 10)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // shouldn't be able to unlock anything assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // should reduce unlocking but not unlock anything roll_to(3, vec![]); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // should be able to unlock 90 of 100 from unstaking assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); unstaking.remove(&3); lock.amount = 10; assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); roll_to(4, vec![]); - assert_eq!(Balances::locks(2), vec![lock]); + assert_eq!(Freezes::::get(2), vec![lock]); // should be able to unlock 10 of remaining 10 assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); unstaking.remove(&4); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(2), vec![]); + assert_eq!(Freezes::::get(2), vec![]); }); // test_stake_less @@ -2315,13 +2315,12 @@ fn unlock_unstaked() { let mut unstaking: BoundedBTreeMap, ::MaxUnstakeRequests> = BoundedBTreeMap::new(); assert_ok!(unstaking.try_insert(3, 60)); - let mut lock = BalanceLock { - id: STAKING_ID, + let mut lock = IdAmount { + id: ::FreezeIdentifier::from(FreezeReason::Staking), amount: 200, - reasons: Reasons::All, }; - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); // shouldn't be able to unlock anything @@ -2329,15 +2328,15 @@ fn unlock_unstaked() { assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); roll_to(2, vec![]); assert_ok!(StakePallet::candidate_stake_less(RuntimeOrigin::signed(1), 10),); assert_ok!(StakePallet::delegator_stake_less(RuntimeOrigin::signed(2), 10),); assert_ok!(unstaking.try_insert(4, 10)); - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); // shouldn't be able to unlock anything @@ -2345,16 +2344,16 @@ fn unlock_unstaked() { assert_ok!(StakePallet::unlock_unstaked(RuntimeOrigin::signed(2), 2)); assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); roll_to(3, vec![]); assert_ok!(StakePallet::candidate_stake_less(RuntimeOrigin::signed(1), 10),); assert_ok!(StakePallet::delegator_stake_less(RuntimeOrigin::signed(2), 10),); assert_ok!(unstaking.try_insert(5, 10)); assert_ok!(unstaking.try_insert(5, 10)); - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); // should unlock 60 @@ -2364,8 +2363,8 @@ fn unlock_unstaked() { unstaking.remove(&3); assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); // reach MaxUnstakeRequests roll_to(4, vec![]); @@ -2382,8 +2381,8 @@ fn unlock_unstaked() { assert_ok!(unstaking.try_insert(8, 10)); assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); roll_to(7, vec![]); assert_noop!( @@ -2403,8 +2402,8 @@ fn unlock_unstaked() { lock.amount = 100; assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock.clone()]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock.clone()]); assert_ok!(StakePallet::candidate_stake_less(RuntimeOrigin::signed(1), 40)); assert_ok!(StakePallet::delegator_stake_less(RuntimeOrigin::signed(2), 40)); assert_ok!(unstaking.try_insert(9, 40)); @@ -2414,8 +2413,8 @@ fn unlock_unstaked() { assert_ok!(unstaking.try_insert(9, 20)); assert_eq!(StakePallet::unstaking(1), unstaking); assert_eq!(StakePallet::unstaking(2), unstaking); - assert_eq!(Balances::locks(1), vec![lock.clone()]); - assert_eq!(Balances::locks(2), vec![lock]); + assert_eq!(Freezes::::get(1), vec![lock.clone()]); + assert_eq!(Freezes::::get(2), vec![lock]); }); } @@ -2673,8 +2672,8 @@ fn adjust_reward_rates() { // reward once in first year roll_to_claim_rewards(2, authors.clone()); - let c_rewards_0 = Balances::free_balance(1).saturating_sub(10_000_000 * DECIMALS); - let d_rewards_0 = Balances::free_balance(2).saturating_sub(90_000_000 * DECIMALS); + let c_rewards_0 = Balances::balance(&1).saturating_sub(10_000_000 * DECIMALS); + let d_rewards_0 = Balances::balance(&2).saturating_sub(90_000_000 * DECIMALS); assert!(!c_rewards_0.is_zero()); assert!(!d_rewards_0.is_zero()); @@ -2695,10 +2694,10 @@ fn adjust_reward_rates() { assert_eq!(StakePallet::inflation_config(), inflation_1); // reward once in 2nd year roll_to_claim_rewards(::BLOCKS_PER_YEAR + 2, authors.clone()); - let c_rewards_1 = Balances::free_balance(1) + let c_rewards_1 = Balances::balance(&1) .saturating_sub(10_000_000 * DECIMALS) .saturating_sub(c_rewards_0); - let d_rewards_1 = Balances::free_balance(2) + let d_rewards_1 = Balances::balance(&2) .saturating_sub(90_000_000 * DECIMALS) .saturating_sub(d_rewards_0); assert!( @@ -2724,15 +2723,15 @@ fn adjust_reward_rates() { Perquintill::from_float(0.051), ); assert_eq!(StakePallet::inflation_config(), inflation_2); - // reward once in 3rd year. Rewards should 5.1%. + // reward once in 3rd year roll_to_claim_rewards(2 * ::BLOCKS_PER_YEAR + 2, authors.clone()); - let c_rewards_2 = Balances::free_balance(1) + let c_rewards_2 = Balances::balance(&1) .saturating_sub(10_000_000 * DECIMALS) .saturating_sub(c_rewards_0) .saturating_sub(c_rewards_1); assert!(c_rewards_1 > c_rewards_2); - // should be less as previous (2nd) year - let d_rewards_2 = Balances::free_balance(2) + // should be zero because we set reward rate to zero + let d_rewards_2 = Balances::balance(&2) .saturating_sub(90_000_000 * DECIMALS) .saturating_sub(d_rewards_0) .saturating_sub(d_rewards_1); @@ -3279,7 +3278,7 @@ fn authorities_per_round() { // roll to last block of round 0 roll_to_claim_rewards(4, authors.clone()); let reward_0 = inflation.collator.reward_rate.per_block * stake * 2; - assert_eq!(Balances::free_balance(1), stake + reward_0); + assert_eq!(Balances::balance(&1), stake + reward_0); // increase max selected candidates which will become effective in round 2 assert_ok!(StakePallet::set_max_selected_candidates(RuntimeOrigin::root(), 10)); @@ -3288,22 +3287,19 @@ fn authorities_per_round() { // round 1 roll_to_claim_rewards(9, authors.clone()); let reward_1 = inflation.collator.reward_rate.per_block * stake * 2; - assert_eq!(Balances::free_balance(1), stake + reward_0 + reward_1); + assert_eq!(Balances::balance(&1), stake + reward_0 + reward_1); // roll to last block of round 2 // should multiply with 4 because there are only 4 candidates roll_to_claim_rewards(14, authors.clone()); let reward_2 = inflation.collator.reward_rate.per_block * stake * 4; - assert_eq!(Balances::free_balance(1), stake + reward_0 + reward_1 + reward_2); + assert_eq!(Balances::balance(&1), stake + reward_0 + reward_1 + reward_2); // roll to last block of round 3 // should multiply with 4 because there are only 4 candidates roll_to_claim_rewards(19, authors); let reward_3 = inflation.collator.reward_rate.per_block * stake * 4; - assert_eq!( - Balances::free_balance(1), - stake + reward_0 + reward_1 + reward_2 + reward_3 - ); + assert_eq!(Balances::balance(&1), stake + reward_0 + reward_1 + reward_2 + reward_3); }); } @@ -3444,13 +3440,13 @@ fn network_reward_multiple_blocks() { assert_eq!(max_stake, StakePallet::max_candidate_stake()); let total_collator_stake = max_stake.saturating_mul(::MinCollators::get().into()); assert_eq!(total_collator_stake, StakePallet::total_collator_stake().collators); - assert!(Balances::free_balance(TREASURY_ACC).is_zero()); + assert!(Balances::balance(&TREASURY_ACC).is_zero()); let total_issuance = ::Currency::total_issuance(); // total issuance should not increase when not noting authors because we haven't // reached NetworkRewardStart yet roll_to(10, vec![None]); - assert!(Balances::free_balance(TREASURY_ACC).is_zero()); + assert!(Balances::balance(&TREASURY_ACC).is_zero()); assert_eq!(total_issuance, ::Currency::total_issuance()); // set current block to one block before NetworkRewardStart @@ -3459,12 +3455,12 @@ fn network_reward_multiple_blocks() { // network rewards should only appear 1 block after start roll_to(network_reward_start, vec![None]); - assert!(Balances::free_balance(TREASURY_ACC).is_zero()); + assert!(Balances::balance(&TREASURY_ACC).is_zero()); assert_eq!(total_issuance, ::Currency::total_issuance()); // should mint to treasury now roll_to(network_reward_start + 1, vec![None]); - let network_reward = Balances::free_balance(TREASURY_ACC); + let network_reward = Balances::balance(&TREASURY_ACC); assert!(!network_reward.is_zero()); assert_eq!( total_issuance + network_reward, @@ -3476,7 +3472,7 @@ fn network_reward_multiple_blocks() { // should mint exactly the same amount roll_to(network_reward_start + 2, vec![None]); - assert_eq!(2 * network_reward, Balances::free_balance(TREASURY_ACC)); + assert_eq!(2 * network_reward, Balances::balance(&TREASURY_ACC)); assert_eq!( total_issuance + 2 * network_reward, ::Currency::total_issuance() @@ -3484,7 +3480,7 @@ fn network_reward_multiple_blocks() { // should mint exactly the same amount in each block roll_to(network_reward_start + 100, vec![None]); - assert_eq!(100 * network_reward, Balances::free_balance(TREASURY_ACC)); + assert_eq!(100 * network_reward, Balances::balance(&TREASURY_ACC)); assert_eq!( total_issuance + 100 * network_reward, ::Currency::total_issuance() @@ -3494,7 +3490,7 @@ fn network_reward_multiple_blocks() { // based on MaxCollatorCandidateStake and MaxSelectedCandidates assert_ok!(StakePallet::init_leave_candidates(RuntimeOrigin::signed(1))); roll_to(network_reward_start + 101, vec![None]); - assert_eq!(101 * network_reward, Balances::free_balance(TREASURY_ACC)); + assert_eq!(101 * network_reward, Balances::balance(&TREASURY_ACC)); assert_eq!( total_issuance + 101 * network_reward, ::Currency::total_issuance() @@ -3519,7 +3515,7 @@ fn network_reward_increase_max_candidate_stake() { // should mint to treasury now roll_to(network_reward_start + 1, vec![None]); - let reward_before = Balances::free_balance(TREASURY_ACC); + let reward_before = Balances::balance(&TREASURY_ACC); assert!(!reward_before.is_zero()); assert_eq!( total_issuance + reward_before, @@ -3534,7 +3530,7 @@ fn network_reward_increase_max_candidate_stake() { max_stake_doubled )); roll_to(network_reward_start + 2, vec![None]); - assert_eq!(reward_before + reward_after, Balances::free_balance(TREASURY_ACC)); + assert_eq!(reward_before + reward_after, Balances::balance(&TREASURY_ACC)); assert_eq!( reward_before + reward_after + total_issuance, ::Currency::total_issuance() @@ -3559,7 +3555,7 @@ fn network_reward_increase_max_collator_count() { // should mint to treasury now roll_to(network_reward_start + 1, vec![None]); - let reward_before = Balances::free_balance(TREASURY_ACC); + let reward_before = Balances::balance(&TREASURY_ACC); assert!(!reward_before.is_zero()); assert_eq!( total_issuance + reward_before, @@ -3573,7 +3569,7 @@ fn network_reward_increase_max_collator_count() { ::MinCollators::get() * 3 )); roll_to(network_reward_start + 2, vec![None]); - assert_eq!(reward_before + reward_after, Balances::free_balance(TREASURY_ACC)); + assert_eq!(reward_before + reward_after, Balances::balance(&TREASURY_ACC)); assert_eq!( reward_before + reward_after + total_issuance, ::Currency::total_issuance() @@ -4246,9 +4242,9 @@ fn rewards_incrementing_and_claiming() { assert_ok!(StakePallet::claim_rewards(RuntimeOrigin::signed(1))); assert!(StakePallet::rewards(1).is_zero()); // delegator situation should be unchanged - assert!(Balances::free_balance(1) > DECIMALS); - assert_eq!(Balances::free_balance(2), DECIMALS); - assert_eq!(Balances::free_balance(3), DECIMALS); + assert!(Balances::balance(&1) > DECIMALS); + assert_eq!(Balances::balance(&2), DECIMALS); + assert_eq!(Balances::balance(&3), DECIMALS); // incrementing again should not change anything because collator has not // authored blocks since last inc @@ -4256,9 +4252,9 @@ fn rewards_incrementing_and_claiming() { assert_eq!(StakePallet::blocks_rewarded(2), 2); // claim for 2 to move rewards into balance assert_ok!(StakePallet::claim_rewards(RuntimeOrigin::signed(2))); - assert!(Balances::free_balance(2) > DECIMALS); + assert!(Balances::balance(&2) > DECIMALS); assert!(StakePallet::rewards(2).is_zero()); - assert_eq!(Balances::free_balance(3), DECIMALS); + assert_eq!(Balances::balance(&3), DECIMALS); // should not be able to claim for incorrect role assert_noop!( diff --git a/pallets/parachain-staking/src/types.rs b/pallets/parachain-staking/src/types.rs index 2d3f7899cf..f73198a789 100644 --- a/pallets/parachain-staking/src/types.rs +++ b/pallets/parachain-staking/src/types.rs @@ -16,7 +16,10 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::traits::{Currency, Get}; +use frame_support::traits::{ + fungible::{Credit, Inspect}, + Get, +}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_runtime::{ @@ -309,8 +312,9 @@ pub struct DelegationCounter { pub counter: u32, } +pub type CurrencyOf = ::Currency; pub type AccountIdOf = ::AccountId; -pub type BalanceOf = <::Currency as Currency>>::Balance; +pub type BalanceOf = <::Currency as Inspect>>::Balance; pub type CandidateOf = Candidate, BalanceOf, S>; pub type StakeOf = Stake, BalanceOf>; -pub type NegativeImbalanceOf = <::Currency as Currency>>::NegativeImbalance; +pub(crate) type CreditOf = Credit<::AccountId, ::Currency>; diff --git a/pallets/public-credentials/Cargo.toml b/pallets/public-credentials/Cargo.toml index 506c5589e6..7db115c3d5 100644 --- a/pallets/public-credentials/Cargo.toml +++ b/pallets/public-credentials/Cargo.toml @@ -22,6 +22,7 @@ sp-keystore = {workspace = true, features = ["std"]} # External dependencies parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} +log.workspace = true # Internal dependencies ctype.workspace = true @@ -58,6 +59,7 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", + "log/std" ] try-runtime = [ "frame-support/try-runtime", diff --git a/pallets/public-credentials/src/benchmarking.rs b/pallets/public-credentials/src/benchmarking.rs index fbb928efd5..ad6dd4a581 100644 --- a/pallets/public-credentials/src/benchmarking.rs +++ b/pallets/public-credentials/src/benchmarking.rs @@ -19,15 +19,15 @@ use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, Zero}; use frame_support::{ dispatch::RawOrigin, - traits::{Currency, Get}, + traits::{fungible::Mutate, Get}, BoundedVec, }; use sp_std::{boxed::Box, vec, vec::Vec}; use ctype::CtypeEntryOf; use kilt_support::{ - deposit::Deposit, traits::{GenerateBenchmarkOrigin, GetWorstCase}, + Deposit, }; use crate::{ @@ -40,9 +40,15 @@ use crate::{ const SEED: u32 = 0; -fn reserve_balance(acc: &T::AccountId) { - // Has to be more than the deposit, we do 2x just to be safe - CurrencyOf::::make_free_balance_be(acc, ::Deposit::get() + ::Deposit::get()); +fn reserve_balance(acc: &T::AccountId) +where + ::Currency: Mutate, +{ + // Has to be more than the deposit, we do 3x just to be safe + CurrencyOf::::set_balance( + acc, + ::Deposit::get() + ::Deposit::get() + ::Deposit::get(), + ); } benchmarks! { @@ -54,7 +60,8 @@ benchmarks! { ::EnsureOrigin: GenerateBenchmarkOrigin, ::SubjectId: GetWorstCase + Into> + sp_std::fmt::Debug, ::CredentialId: Default, - T::BlockNumber: From + T::BlockNumber: From, + ::Currency: Mutate, } add { diff --git a/pallets/public-credentials/src/credentials.rs b/pallets/public-credentials/src/credentials.rs index 21c8698b59..b03642c133 100644 --- a/pallets/public-credentials/src/credentials.rs +++ b/pallets/public-credentials/src/credentials.rs @@ -21,7 +21,7 @@ use scale_info::TypeInfo; use frame_support::RuntimeDebug; -use kilt_support::deposit::Deposit; +use kilt_support::Deposit; /// The type of a credentials as incoming from the outside world. /// Some of its fields are parsed and/or transformed inside the `add` operation. diff --git a/pallets/public-credentials/src/lib.rs b/pallets/public-credentials/src/lib.rs index 1c79068161..41b632df59 100644 --- a/pallets/public-credentials/src/lib.rs +++ b/pallets/public-credentials/src/lib.rs @@ -33,6 +33,7 @@ mod access_control; pub mod credentials; pub mod default_weights; +pub mod migrations; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; @@ -56,7 +57,10 @@ pub mod pallet { use frame_support::{ pallet_prelude::*, - traits::{Currency, IsType, ReservableCurrency, StorageVersion}, + traits::{ + fungible::{Inspect, MutateHold}, + IsType, StorageVersion, + }, Parameter, }; use frame_system::pallet_prelude::*; @@ -65,12 +69,12 @@ pub mod pallet { pub use ctype::CtypeHashOf; use kilt_support::{ - deposit::Deposit, traits::{CallSources, StorageDepositCollector}, + Deposit, }; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); // No easy way to check whether the two currencies are the same and check for // `can_withdraw` conditions. Maybe with #[transactional] we could stop caring @@ -98,7 +102,7 @@ pub mod pallet { /// Type of an attester identifier. pub type AttesterOf = ::AttesterId; /// The type of account's balances. - pub type BalanceOf = as Currency>>::Balance; + pub type BalanceOf = as Inspect>>::Balance; pub(crate) type AuthorizationIdOf = ::AuthorizationId; pub type CredentialIdOf = <::CredentialHash as sp_runtime::traits::Hash>::Output; @@ -106,6 +110,11 @@ pub mod pallet { pub type InputCredentialOf = Credential, InputSubjectIdOf, InputClaimsContentOf, ::AccessControl>; + #[pallet::composite_enum] + pub enum HoldReason { + Deposit, + } + #[pallet::config] pub trait Config: frame_system::Config + ctype::Config { /// The access control logic. @@ -116,6 +125,8 @@ pub mod pallet { CtypeHashOf, CredentialIdOf, >; + + type RuntimeHoldReason: From; /// The identifier of the credential attester. type AttesterId: Parameter + MaxEncodedLen; /// The identifier of the authorization info to perform access control @@ -131,7 +142,7 @@ pub mod pallet { /// The type of a credential identifier. type CredentialId: Parameter + MaxEncodedLen; /// The currency that is used to reserve funds for each credential. - type Currency: ReservableCurrency>; + type Currency: MutateHold, Reason = Self::RuntimeHoldReason>; /// The type of the origin when successfully converted from the outer /// origin. type OriginSuccess: CallSources>; @@ -295,7 +306,7 @@ pub mod pallet { Error::::AlreadyAttested ); - let deposit = kilt_support::reserve_deposit::>(payer, deposit_amount) + let deposit = PublicCredentialDepositCollector::::create_deposit(payer, deposit_amount) .map_err(|_| Error::::UnableToPayFees)?; let block_number = frame_system::Pallet::::block_number(); @@ -454,7 +465,7 @@ pub mod pallet { // Removes the credential from storage and generates a `CredentialRemoved` // event. - Self::remove_credential_entry(credential_subject, credential_id, credential_entry); + Self::remove_credential_entry(credential_subject, credential_id, credential_entry)?; Ok(Some(::WeightInfo::remove().saturating_add(ac_weight_used)).into()) } @@ -488,7 +499,7 @@ pub mod pallet { // Removes the credential from storage and generates a `CredentialRemoved` // event. - Self::remove_credential_entry(credential_subject, credential_id, credential_entry); + Self::remove_credential_entry(credential_subject, credential_id, credential_entry)?; Ok(()) } @@ -539,8 +550,8 @@ pub mod pallet { credential_subject: T::SubjectId, credential_id: CredentialIdOf, credential: CredentialEntryOf, - ) { - kilt_support::free_deposit::>(&credential.deposit); + ) -> DispatchResult { + PublicCredentialDepositCollector::::free_deposit(credential.deposit)?; Credentials::::remove(&credential_subject, &credential_id); CredentialSubjects::::remove(&credential_id); @@ -548,6 +559,7 @@ pub mod pallet { subject_id: credential_subject, credential_id, }); + Ok(()) } fn retrieve_credential_entry( @@ -597,24 +609,31 @@ pub mod pallet { } } - struct PublicCredentialDepositCollector(PhantomData); - impl StorageDepositCollector, CredentialIdOf> for PublicCredentialDepositCollector { + pub(crate) struct PublicCredentialDepositCollector(PhantomData); + impl StorageDepositCollector, CredentialIdOf, T::RuntimeHoldReason> + for PublicCredentialDepositCollector + { type Currency = ::Currency; + type Reason = HoldReason; + + fn reason() -> Self::Reason { + HoldReason::Deposit + } fn deposit( credential_id: &CredentialIdOf, - ) -> Result, >>::Balance>, DispatchError> { + ) -> Result, >>::Balance>, DispatchError> { let (_, credential_entry) = Pallet::::retrieve_credential_entry(credential_id)?; Ok(credential_entry.deposit) } - fn deposit_amount(_credential_id: &CredentialIdOf) -> >>::Balance { + fn deposit_amount(_credential_id: &CredentialIdOf) -> >>::Balance { T::Deposit::get() } fn store_deposit( credential_id: &CredentialIdOf, - deposit: Deposit, >>::Balance>, + deposit: Deposit, >>::Balance>, ) -> Result<(), DispatchError> { let credential_subject = CredentialSubjects::::get(credential_id).ok_or(Error::::NotFound)?; Credentials::::try_mutate(&credential_subject, credential_id, |credential_entry| { diff --git a/pallets/public-credentials/src/migrations.rs b/pallets/public-credentials/src/migrations.rs new file mode 100644 index 0000000000..d8ae7abb55 --- /dev/null +++ b/pallets/public-credentials/src/migrations.rs @@ -0,0 +1,153 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + traits::{Get, GetStorageVersion, OnRuntimeUpgrade, ReservableCurrency, StorageVersion}, + weights::Weight, +}; +use kilt_support::migration::switch_reserved_to_hold; +use sp_runtime::SaturatedConversion; +use sp_std::marker::PhantomData; + +use crate::{ + AccountIdOf, Config, Credentials, CurrencyOf, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION, +}; + +const CURRENT_STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + +pub struct BalanceMigration(PhantomData); + +impl OnRuntimeUpgrade for BalanceMigration +where + ::Currency: ReservableCurrency, +{ + fn on_runtime_upgrade() -> frame_support::weights::Weight { + log::info!("Public Credentials: Initiating migration"); + + let onchain_storage_version = Pallet::::on_chain_storage_version(); + + if onchain_storage_version == CURRENT_STORAGE_VERSION { + TARGET_STORAGE_VERSION.put::>(); + + ::DbWeight::get() + .reads_writes(0, 0) + .saturating_add(do_migration::()) + } else { + log::info!( + "Public Credential: No migration needed. This file should be deleted. Current storage version: {:?}, Required Version for update: {:?}", + onchain_storage_version, + CURRENT_STORAGE_VERSION + ); + ::DbWeight::get().reads_writes(0, 0) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + use sp_std::vec; + + let has_all_user_no_holds = Credentials::::iter_values() + .map(|details: crate::CredentialEntryOf| { + kilt_support::migration::has_user_reserved_balance::, CurrencyOf>( + &details.deposit.owner, + &HoldReason::Deposit.into(), + ) + }) + .all(|user| user); + + assert!( + has_all_user_no_holds, + "Pre Upgrade Public Credentials: there are users with holds!" + ); + + assert_eq!(Pallet::::on_chain_storage_version(), CURRENT_STORAGE_VERSION); + + log::info!("Public Credentials: Pre migration checks successful"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_pre_state: sp_std::vec::Vec) -> Result<(), &'static str> { + use frame_support::traits::fungible::InspectHold; + use sp_runtime::Saturating; + use sp_std::collections::btree_map::BTreeMap; + + use crate::BalanceOf; + + let mut map_user_deposit: BTreeMap, BalanceOf> = BTreeMap::new(); + + Credentials::::iter_values().for_each(|details| { + map_user_deposit + .entry(details.deposit.owner) + .and_modify(|balance| *balance = balance.saturating_add(details.deposit.amount)) + .or_insert(details.deposit.amount); + }); + + map_user_deposit + .iter() + .try_for_each(|(who, amount)| -> Result<(), &'static str> { + let hold_balance: BalanceOf = + ::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into(); + + assert!( + amount.eq(&hold_balance), + "Public Credentials: Hold balance is not matching for attestation {:?}. Expected hold: {:?}. Real hold: {:?}", + who, + amount, + hold_balance + ); + Ok(()) + })?; + + assert_eq!(Pallet::::on_chain_storage_version(), TARGET_STORAGE_VERSION); + + log::info!("Public Credentials: Post migration checks successful"); + Ok(()) + } +} + +fn do_migration() -> Weight +where + ::Currency: ReservableCurrency, +{ + Credentials::::iter() + .map(|(key, key2, pc_details)| -> Weight { + let deposit = pc_details.deposit; + let error = switch_reserved_to_hold::, CurrencyOf>( + deposit.owner, + &HoldReason::Deposit.into(), + deposit.amount.saturated_into(), + ); + + if error.is_err() { + log::error!( + "Public Credential: Could not convert reserves to hold from credential: {:?} {:?}, error: {:?}", + key, + key2, + error + ); + } + + // Currency::reserve and Currency::hold each read and write to the DB once. + // Since we are uncertain about which operation may fail, in the event of an + // error, we assume the worst-case scenario here. + ::DbWeight::get().reads_writes(2, 2) + }) + .fold(Weight::zero(), |acc, next| acc.saturating_add(next)) +} diff --git a/pallets/public-credentials/src/mock.rs b/pallets/public-credentials/src/mock.rs index c94e324886..3a94e1dc0a 100644 --- a/pallets/public-credentials/src/mock.rs +++ b/pallets/public-credentials/src/mock.rs @@ -20,11 +20,11 @@ use frame_support::traits::Get; use parity_scale_codec::Encode; use sp_runtime::traits::Hash; -use kilt_support::deposit::Deposit; +use kilt_support::{traits::StorageDepositCollector, Deposit}; use crate::{ AttesterOf, BalanceOf, Config, CredentialEntryOf, CredentialIdOf, CredentialSubjects, Credentials, CtypeHashOf, - CurrencyOf, InputClaimsContentOf, InputCredentialOf, InputSubjectIdOf, + InputClaimsContentOf, InputCredentialOf, InputSubjectIdOf, PublicCredentialDepositCollector, }; // Generate a public credential using a many Default::default() as possible. @@ -76,7 +76,7 @@ pub(crate) fn insert_public_credentials( credential_id: CredentialIdOf, credential_entry: CredentialEntryOf, ) { - kilt_support::reserve_deposit::>( + PublicCredentialDepositCollector::::create_deposit( credential_entry.deposit.owner.clone(), credential_entry.deposit.amount, ) @@ -280,7 +280,7 @@ pub(crate) mod runtime { Ctype: ctype::{Pallet, Call, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Event}, MockOrigin: mock_origin::{Pallet, Origin}, - PublicCredentials: crate::{Pallet, Call, Storage, Event}, + PublicCredentials: crate::{Pallet, Call, Storage,HoldReason, Event}, } ); @@ -319,6 +319,10 @@ pub(crate) mod runtime { } impl pallet_balances::Config for Test { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = ConstU32<10>; + type MaxHolds = ConstU32<10>; type Balance = Balance; type DustRemoval = (); type RuntimeEvent = (); @@ -348,6 +352,7 @@ pub(crate) mod runtime { type AttesterId = SubjectId; type AuthorizationId = SubjectId; type CredentialId = Hash; + type RuntimeHoldReason = RuntimeHoldReason; type CredentialHash = BlakeTwo256; type Currency = Balances; type Deposit = ConstU128<{ 10 * MILLI_UNIT }>; @@ -362,6 +367,8 @@ pub(crate) mod runtime { pub(crate) const ACCOUNT_00: AccountId = AccountId::new([1u8; 32]); pub(crate) const ACCOUNT_01: AccountId = AccountId::new([2u8; 32]); + // Min Balance has to be >= [ExistentialDeposit] + pub(crate) const MIN_BALANCE: Balance = MILLI_UNIT; pub(crate) const ALICE_SEED: [u8; 32] = [0u8; 32]; pub(crate) const BOB_SEED: [u8; 32] = [1u8; 32]; @@ -454,7 +461,7 @@ pub(crate) mod runtime { pub(crate) fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); - let keystore = sp_keystore::testing::KeyStore::new(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(std::sync::Arc::new(keystore))); ext diff --git a/pallets/public-credentials/src/tests.rs b/pallets/public-credentials/src/tests.rs index b60a1dfed3..e1197d0383 100644 --- a/pallets/public-credentials/src/tests.rs +++ b/pallets/public-credentials/src/tests.rs @@ -16,13 +16,18 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::{assert_noop, assert_ok, traits::Get}; +use frame_support::{ + assert_noop, assert_ok, + traits::{fungible::InspectHold, Get}, +}; use sp_runtime::traits::Zero; use ctype::mock::get_ctype_hash; -use kilt_support::{deposit::Deposit, mock::mock_origin::DoubleOrigin}; +use kilt_support::{mock::mock_origin::DoubleOrigin, Deposit}; -use crate::{mock::*, Config, CredentialIdOf, CredentialSubjects, Credentials, Error, InputClaimsContentOf}; +use crate::{ + mock::*, Config, CredentialIdOf, CredentialSubjects, Credentials, Error, HoldReason, InputClaimsContentOf, +}; // add @@ -47,11 +52,11 @@ fn add_successful_without_authorization() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, (deposit) * 2)]) + .with_balances(vec![(ACCOUNT_00, (deposit) * 2 + MIN_BALANCE)]) .with_ctypes(vec![(ctype_hash_1, attester.clone()), (ctype_hash_2, attester.clone())]) .build_and_execute_with_sanity_tests(|| { // Check for 0 reserved deposit - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); assert_ok!(PublicCredentials::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -69,7 +74,10 @@ fn add_successful_without_authorization() { assert_eq!(CredentialSubjects::::get(credential_id_1), Some(subject_id)); // Check deposit reservation logic - assert_eq!(Balances::reserved_balance(ACCOUNT_00), deposit); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + deposit + ); // Re-issuing the same credential will fail assert_noop!( @@ -81,7 +89,10 @@ fn add_successful_without_authorization() { ); // Check deposit has not changed - assert_eq!(Balances::reserved_balance(ACCOUNT_00), deposit); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + deposit + ); System::set_block_number(1); @@ -103,7 +114,10 @@ fn add_successful_without_authorization() { assert_eq!(CredentialSubjects::::get(credential_id_2), Some(subject_id)); // Deposit is 2x now - assert_eq!(Balances::reserved_balance(ACCOUNT_00), 2 * deposit); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + 2 * deposit + ); }); } @@ -122,7 +136,7 @@ fn add_successful_with_authorization() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_ctypes(vec![(ctype_hash, attester.clone())]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::add( @@ -261,7 +275,7 @@ fn revoke_successful() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { @@ -304,7 +318,7 @@ fn revoke_same_attester_wrong_ac() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { @@ -335,7 +349,7 @@ fn revoke_unauthorized() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { @@ -363,7 +377,7 @@ fn revoke_ac_not_found() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { @@ -408,7 +422,7 @@ fn unrevoke_successful() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { @@ -452,7 +466,7 @@ fn unrevoke_same_attester_wrong_ac() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { @@ -484,7 +498,7 @@ fn unrevoke_unauthorized() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .build_and_execute_with_sanity_tests(|| { @@ -513,7 +527,7 @@ fn unrevoke_ac_not_found() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { @@ -555,7 +569,7 @@ fn remove_successful() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::remove( @@ -569,7 +583,7 @@ fn remove_successful() { assert!(CredentialSubjects::::get(credential_id).is_none()); // Check deposit release logic - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); // Removing the same credential again will fail assert_noop!( @@ -590,7 +604,7 @@ fn remove_same_attester_wrong_ac() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::remove( @@ -618,7 +632,7 @@ fn remove_unauthorized() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { @@ -646,7 +660,7 @@ fn remove_ac_not_found() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { @@ -688,7 +702,7 @@ fn reclaim_deposit_successful() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::reclaim_deposit( @@ -701,7 +715,7 @@ fn reclaim_deposit_successful() { assert!(CredentialSubjects::::get(credential_id).is_none()); // Check deposit release logic - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); // Reclaiming the deposit for the same credential again will fail assert_noop!( @@ -742,7 +756,7 @@ fn reclaim_deposit_unauthorized() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { @@ -774,7 +788,10 @@ fn test_change_deposit_owner() { let credential_id: CredentialIdOf = CredentialIdOf::::default(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit), (ACCOUNT_01, deposit)]) + .with_balances(vec![ + (ACCOUNT_00, deposit + MIN_BALANCE), + (ACCOUNT_01, deposit + MIN_BALANCE), + ]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { @@ -791,8 +808,11 @@ fn test_change_deposit_owner() { .owner, ACCOUNT_01 ); - assert_eq!(Balances::reserved_balance(ACCOUNT_01), ::Deposit::get()); - assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_01), + ::Deposit::get() + ); + assert!(Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00).is_zero()); }); } @@ -835,7 +855,10 @@ fn test_change_deposit_owner_unauthorized() { let credential_id: CredentialIdOf = CredentialIdOf::::default(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit), (ACCOUNT_01, deposit)]) + .with_balances(vec![ + (ACCOUNT_00, deposit + MIN_BALANCE), + (ACCOUNT_01, deposit + MIN_BALANCE), + ]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { @@ -867,7 +890,7 @@ fn test_update_deposit() { let credential_id: CredentialIdOf = CredentialIdOf::::default(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit_old)]) + .with_balances(vec![(ACCOUNT_00, deposit_old + MIN_BALANCE)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { @@ -884,7 +907,10 @@ fn test_update_deposit() { .amount, ::Deposit::get() ); - assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); + assert_eq!( + Balances::balance_on_hold(&HoldReason::Deposit.into(), &ACCOUNT_00), + ::Deposit::get() + ); }); } @@ -914,7 +940,7 @@ fn test_update_deposit_unauthorized() { let deposit: Balance = ::Deposit::get(); ExtBuilder::default() - .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_balances(vec![(ACCOUNT_00, deposit + MIN_BALANCE)]) .with_ctypes(vec![(ctype_hash_1, attester)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .build_and_execute_with_sanity_tests(|| { diff --git a/runtime-api/did/src/did_details.rs b/runtime-api/did/src/did_details.rs index 509aa72928..82f6e2fd6f 100644 --- a/runtime-api/did/src/did_details.rs +++ b/runtime-api/did/src/did_details.rs @@ -21,7 +21,7 @@ use scale_info::TypeInfo; use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use did::{did_details::DidPublicKeyDetails, AccountIdOf, BalanceOf, BlockNumberOf, KeyIdOf}; -use kilt_support::deposit::Deposit; +use kilt_support::Deposit; #[derive(Encode, Decode, TypeInfo, Clone, Debug, Eq, PartialEq, MaxEncodedLen)] pub struct DidDetails { diff --git a/runtime-api/did/src/lib.rs b/runtime-api/did/src/lib.rs index 291e779601..ce509776fa 100644 --- a/runtime-api/did/src/lib.rs +++ b/runtime-api/did/src/lib.rs @@ -67,11 +67,11 @@ pub type RawDidLinkedInfo where + pub trait Did where DidIdentifier: Codec, AccountId: Codec, LinkableAccountId: Codec, - BlockNumber: Codec + MaxEncodedLen, + BlockNumber: Codec, Key: Codec, Balance: Codec, { diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 8ae80c73f0..eacbbef9c7 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -1,37 +1,31 @@ [package] authors.workspace = true +description = "Common interfaces, types, constants and functionality for all KILT runtimes." documentation.workspace = true edition.workspace = true homepage.workspace = true license-file.workspace = true +name = "runtime-common" readme.workspace = true repository.workspace = true version.workspace = true -name = "runtime-common" -description = "Common interfaces, types, constants and functionality for all KILT runtimes." [dev-dependencies] sp-io = {workspace = true, features = ["std"]} [dependencies] # External dependencies -parity-scale-codec = {workspace = true, features = ["derive"]} -log.workspace = true kilt-asset-dids.workspace = true +log.workspace = true +parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} smallvec.workspace = true -# Internal dependencies attestation.workspace = true -ctype.workspace = true -delegation = {workspace = true, optional = true} -did = {workspace = true, optional = true} -pallet-did-lookup = {workspace = true, optional = true} -pallet-inflation = {workspace = true, optional = true} kilt-support.workspace = true parachain-staking.workspace = true public-credentials.workspace = true -pallet-web3-names.workspace = true + # Substrate dependencies frame-support.workspace = true @@ -40,6 +34,7 @@ pallet-authorship.workspace = true pallet-balances.workspace = true pallet-membership.workspace = true pallet-transaction-payment.workspace = true +pallet-treasury.workspace = true sp-consensus-aura.workspace = true sp-core.workspace = true sp-io.workspace = true @@ -51,22 +46,21 @@ cumulus-primitives-core.workspace = true # Polkadot dependencies polkadot-parachain.workspace = true -xcm.workspace = true xcm-builder.workspace = true xcm-executor.workspace = true +xcm.workspace = true [features] default = ["std"] fast-gov = [] runtime-benchmarks = [ "attestation/runtime-benchmarks", - "ctype/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "kilt-support/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-membership/runtime-benchmarks", - "parachain-staking/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", "polkadot-parachain/runtime-benchmarks", "public-credentials/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -75,8 +69,7 @@ runtime-benchmarks = [ ] std = [ "attestation/std", - "parity-scale-codec/std", - "ctype/std", + "parity-scale-codec/std", "cumulus-primitives-core/std", "frame-support/std", "frame-system/std", @@ -87,6 +80,7 @@ std = [ "pallet-balances/std", "pallet-membership/std", "pallet-transaction-payment/std", + "pallet-treasury/std", "parachain-staking/std", "polkadot-parachain/std", "public-credentials/std", @@ -102,17 +96,14 @@ std = [ ] try-runtime = [ "attestation/try-runtime", - "delegation", - "did", "frame-support/try-runtime", "frame-system/try-runtime", "kilt-support/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", - "pallet-did-lookup", - "pallet-inflation", "pallet-membership/try-runtime", "pallet-transaction-payment/try-runtime", + "pallet-treasury/try-runtime", "parachain-staking/try-runtime", "public-credentials/try-runtime", ] diff --git a/runtimes/common/src/fees.rs b/runtimes/common/src/fees.rs index c22146249c..d520c0b478 100644 --- a/runtimes/common/src/fees.rs +++ b/runtimes/common/src/fees.rs @@ -18,7 +18,7 @@ use frame_support::{ dispatch::DispatchClass, - traits::{Currency, Get, Imbalance, OnUnbalanced}, + traits::{fungible::Balanced, Currency, Get, Imbalance, OnUnbalanced}, weights::{ Weight, WeightToFee as WeightToFeeT, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }, @@ -28,7 +28,7 @@ use pallet_transaction_payment::OnChargeTransaction; use smallvec::smallvec; use sp_runtime::Perbill; -use crate::{constants::MILLI_KILT, AccountId, Balance, NegativeImbalanceOf}; +use crate::{constants::MILLI_KILT, AccountId, Balance, CreditOf, NegativeImbalanceOf}; /// Split two Imbalances between two unbalanced handlers. /// The first Imbalance will be split according to the given ratio. The second @@ -78,6 +78,22 @@ where } } +pub struct ToAuthorCredit(sp_std::marker::PhantomData); +impl OnUnbalanced> for ToAuthorCredit +where + R: pallet_balances::Config + pallet_authorship::Config, + ::AccountId: From, + ::AccountId: Into, + ::Balance: Into, +{ + fn on_nonzero_unbalanced(amount: CreditOf) { + if let Some(author) = >::author() { + let result = pallet_balances::Pallet::::resolve(&author, amount); + debug_assert!(result.is_ok(), "The whole credit cannot be countered"); + } + } +} + /// Handles converting a weight scalar to a fee value, based on the scale and /// granularity of the node's balance type. /// @@ -139,7 +155,7 @@ mod tests { }; use frame_support::{dispatch::DispatchClass, parameter_types, traits::FindAuthor}; use frame_system::limits; - use sp_core::H256; + use sp_core::{ConstU64, H256}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, @@ -215,9 +231,13 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; + type FreezeIdentifier = (); + type HoldIdentifier = (); + type MaxFreezes = (); + type MaxHolds = (); type RuntimeEvent = RuntimeEvent; type DustRemoval = (); - type ExistentialDeposit = (); + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type MaxLocks = (); type MaxReserves = (); @@ -266,8 +286,8 @@ mod tests { #[test] fn test_fees_and_tip_split() { new_test_ext().execute_with(|| { - let fee = Balances::issue(10); - let tip = Balances::issue(20); + let fee = ::AccountId>>::issue(10); + let tip = ::AccountId>>::issue(20); assert_eq!(Balances::free_balance(TREASURY_ACC), 0); assert_eq!(Balances::free_balance(AUTHOR_ACC), 0); diff --git a/runtimes/common/src/lib.rs b/runtimes/common/src/lib.rs index d627b067a9..d0968c1a02 100644 --- a/runtimes/common/src/lib.rs +++ b/runtimes/common/src/lib.rs @@ -29,9 +29,13 @@ pub use frame_support::weights::constants::{BlockExecutionWeight, ExtrinsicBaseW use frame_support::{ dispatch::DispatchClass, parameter_types, - traits::{Contains, ContainsLengthBound, Currency, Get, SortedMembers}, + traits::{ + fungible::{Balanced, Credit}, + Contains, ContainsLengthBound, Currency, Get, OnUnbalanced, SortedMembers, + }, }; use frame_system::limits; +use pallet_balances::Pallet as PalletBalance; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use sp_runtime::{ generic, @@ -73,6 +77,8 @@ pub mod opaque { /// An index to a block. pub type BlockNumber = u64; +pub(crate) type CreditOf = Credit<::AccountId, PalletBalance>; + /// Alias to 512-bit hash when used in the context of a transaction signature on /// the chain. pub type Signature = MultiSignature; @@ -196,3 +202,17 @@ where }) } } + +pub struct SendDustAndFeesToTreasury(sp_std::marker::PhantomData); + +impl OnUnbalanced> for SendDustAndFeesToTreasury +where + T: pallet_balances::Config, + T: pallet_treasury::Config, +{ + fn on_nonzero_unbalanced(amount: CreditOf) { + let treasury_account_id = pallet_treasury::Pallet::::account_id(); + let result = pallet_balances::Pallet::::resolve(&treasury_account_id, amount); + debug_assert!(result.is_ok(), "The whole credit cannot be countered"); + } +} diff --git a/runtimes/common/src/xcm_config.rs b/runtimes/common/src/xcm_config.rs index 51eed3b5f3..dfd2b48b1f 100644 --- a/runtimes/common/src/xcm_config.rs +++ b/runtimes/common/src/xcm_config.rs @@ -16,8 +16,8 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use core::marker::PhantomData; -use frame_support::{log, match_types, parameter_types, weights::Weight}; +use core::{marker::PhantomData, ops::ControlFlow}; +use frame_support::{log, match_types, parameter_types, traits::ProcessMessageError, weights::Weight}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{AccountId32Aliases, CurrencyAdapter, IsConcrete, ParentIsPreset, SiblingParachainConvertsVia}; @@ -55,64 +55,72 @@ where instructions: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, - ) -> Result<(), ()> { + ) -> Result<(), ProcessMessageError> { Deny::should_execute(origin, instructions, max_weight, weight_credit)?; Allow::should_execute(origin, instructions, max_weight, weight_credit) } } /// Reserved funds to the relay chain can't return. See https://github.com/paritytech/polkadot/issues/5233 +/// Usage of the new xcm matcher. See https://github.com/paritytech/polkadot/pull/7098 pub struct DenyReserveTransferToRelayChain; impl ShouldExecute for DenyReserveTransferToRelayChain { - fn should_execute( + fn should_execute( origin: &MultiLocation, - instructions: &mut [Instruction], + message: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, - ) -> Result<(), ()> { - if instructions.iter().any(|inst| { - matches!( - inst, + ) -> Result<(), ProcessMessageError> { + xcm_builder::MatchXcm::match_next_inst_while( + xcm_builder::CreateMatcher::matcher(message), + |_| true, + |inst| match inst { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, - interior: Here + interior: Here, }, .. - } | DepositReserveAsset { + } + | DepositReserveAsset { dest: MultiLocation { parents: 1, - interior: Here + interior: Here, }, .. - } | TransferReserveAsset { + } + | TransferReserveAsset { dest: MultiLocation { parents: 1, - interior: Here + interior: Here, }, .. + } => { + Err(ProcessMessageError::Unsupported) // Deny } - ) - }) { - return Err(()); // Deny - } - - // Allow reserve transfers to arrive from relay chain - if matches!( - origin, - MultiLocation { - parents: 1, - interior: Here - } - ) && instructions - .iter() - .any(|inst| matches!(inst, ReserveAssetDeposited { .. })) - { - log::warn!( - target: "xcm::barriers", - "Unexpected ReserveAssetDeposited from the relay chain", - ); - } + + // An unexpected reserve transfer has arrived from the Relay Chain. Generally, + // `IsReserve` should not allow this, but we just log it here. + ReserveAssetDeposited { .. } + if matches!( + origin, + MultiLocation { + parents: 1, + interior: Here + } + ) => + { + log::warn!( + target: "xcm::barrier", + "Unexpected ReserveAssetDeposited from the Relay Chain", + ); + Ok(ControlFlow::Continue(())) + } + + _ => Ok(ControlFlow::Continue(())), + }, + )?; + // Permit everything else Ok(()) } diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 7a91954c5e..7aa49850f0 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -173,6 +173,8 @@ parameter_types! { pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; } impl pallet_multisig::Config for Runtime { @@ -196,9 +198,14 @@ impl pallet_indices::Config for Runtime { impl pallet_balances::Config for Runtime { /// The type for recording an account's balance. type Balance = Balance; + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; + /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; - type DustRemoval = Treasury; + type DustRemoval = runtime_common::SendDustAndFeesToTreasury; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = weights::pallet_balances::WeightInfo; @@ -430,6 +437,7 @@ parameter_types! { pub const SpendPeriod: BlockNumber = constants::governance::SPEND_PERIOD; pub const Burn: Permill = Permill::zero(); pub const MaxApprovals: u32 = 100; + pub MaxProposalWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block; } type ApproveOrigin = EitherOfDiverse< @@ -463,6 +471,7 @@ impl pallet_treasury::Config for Runtime { type CouncilCollective = pallet_collective::Instance1; impl pallet_collective::Config for Runtime { + type MaxProposalWeight = MaxProposalWeight; type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; @@ -477,6 +486,7 @@ impl pallet_collective::Config for Runtime { type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; + type MaxProposalWeight = MaxProposalWeight; type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = constants::governance::TechnicalMotionDuration; @@ -535,7 +545,7 @@ impl pallet_configuration::Config for Runtime { impl attestation::Config for Runtime { type EnsureOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; - + type RuntimeHoldReason = RuntimeHoldReason; type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::attestation::WeightInfo; @@ -565,6 +575,7 @@ impl delegation::Config for Runtime { type DelegationSignatureVerification = AlwaysVerify, Self::Signature>; type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = RuntimeHoldReason; type MaxSignatureByteLength = constants::delegation::MaxSignatureByteLength; type MaxParentChecks = constants::delegation::MaxParentChecks; type MaxRevocations = constants::delegation::MaxRevocations; @@ -579,7 +590,7 @@ impl ctype::Config for Runtime { type CtypeCreatorId = AccountId; type Currency = Balances; type Fee = constants::CtypeFee; - type FeeCollector = Treasury; + type FeeCollector = runtime_common::SendDustAndFeesToTreasury; type EnsureOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; @@ -593,13 +604,14 @@ impl did::Config for Runtime { type DidIdentifier = DidIdentifier; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeHoldReason = RuntimeHoldReason; type KeyDeposit = constants::did::KeyDeposit; type ServiceEndpointDeposit = constants::did::ServiceEndpointDeposit; type BaseDeposit = constants::did::DidBaseDeposit; type RuntimeOrigin = RuntimeOrigin; type Currency = Balances; type Fee = constants::did::DidFee; - type FeeCollector = Treasury; + type FeeCollector = runtime_common::SendDustAndFeesToTreasury; #[cfg(not(feature = "runtime-benchmarks"))] type EnsureOrigin = did::EnsureDidOrigin; @@ -625,6 +637,7 @@ impl did::Config for Runtime { } impl pallet_did_lookup::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type RuntimeEvent = RuntimeEvent; type DidIdentifier = DidIdentifier; @@ -644,6 +657,7 @@ impl pallet_web3_names::Config for Runtime { type OriginSuccess = did::DidRawOrigin; type Currency = Balances; type Deposit = constants::web3_names::Web3NameDeposit; + type RuntimeHoldReason = RuntimeHoldReason; type RuntimeEvent = RuntimeEvent; type MaxNameLength = constants::web3_names::MaxNameLength; type MinNameLength = constants::web3_names::MinNameLength; @@ -656,7 +670,7 @@ impl pallet_inflation::Config for Runtime { type Currency = Balances; type InitialPeriodLength = constants::treasury::InitialPeriodLength; type InitialPeriodReward = constants::treasury::InitialPeriodReward; - type Beneficiary = Treasury; + type Beneficiary = runtime_common::SendDustAndFeesToTreasury; type WeightInfo = weights::pallet_inflation::WeightInfo; } @@ -664,7 +678,7 @@ impl parachain_staking::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = Balance; - + type FreezeIdentifier = RuntimeFreezeReason; type MinBlocksPerRound = constants::staking::MinBlocksPerRound; type DefaultBlocksPerRound = constants::staking::DefaultBlocksPerRound; type StakeDuration = constants::staking::StakeDuration; @@ -680,7 +694,7 @@ impl parachain_staking::Config for Runtime { type MaxUnstakeRequests = constants::staking::MaxUnstakeRequests; type NetworkRewardRate = constants::staking::NetworkRewardRate; type NetworkRewardStart = constants::staking::NetworkRewardStart; - type NetworkRewardBeneficiary = Treasury; + type NetworkRewardBeneficiary = runtime_common::SendDustAndFeesToTreasury; type WeightInfo = weights::parachain_staking::WeightInfo; const BLOCKS_PER_YEAR: Self::BlockNumber = constants::BLOCKS_PER_YEAR; @@ -694,6 +708,7 @@ impl pallet_utility::Config for Runtime { } impl public_credentials::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type AccessControl = PalletAuthorize>; type AttesterId = DidIdentifier; type AuthorizationId = AuthorizationId<::DelegationNodeId>; @@ -1081,6 +1096,13 @@ pub type Executive = frame_executive::Executive< ( pallet_did_lookup::migrations::CleanupMigration, runtime_common::migrations::RemoveInsecureRandomnessPallet, + attestation::migrations::BalanceMigration, + delegation::migrations::BalanceMigration, + did::migrations::BalanceMigration, + pallet_did_lookup::migrations::BalanceMigration, + pallet_web3_names::migrations::BalanceMigration, + parachain_staking::migrations::BalanceMigration, + public_credentials::migrations::BalanceMigration, ), >; @@ -1139,6 +1161,14 @@ impl_runtime_apis! { fn metadata() -> OpaqueMetadata { OpaqueMetadata::new(Runtime::metadata().into()) } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } } impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { diff --git a/runtimes/peregrine/src/weights/pallet_balances.rs b/runtimes/peregrine/src/weights/pallet_balances.rs index ff0e1c5cce..5142d679c8 100644 --- a/runtimes/peregrine/src/weights/pallet_balances.rs +++ b/runtimes/peregrine/src/weights/pallet_balances.rs @@ -1,5 +1,3 @@ -// TODO: UPDATE BEFORE RELEASE - // KILT Blockchain – https://botlabs.org // Copyright (C) 2019-2023 BOTLabs GmbH @@ -21,7 +19,7 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-04-05, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-31, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -52,75 +50,75 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); impl pallet_balances::WeightInfo for WeightInfo { - /// Storage: System Account (r:2 w:2) + /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - fn transfer() -> Weight { + fn transfer_allow_death() -> Weight { // Proof Size summary in bytes: - // Measured: `2759` - // Estimated: `5214` - // Minimum execution time: 55_797_000 picoseconds. - Weight::from_parts(55_797_000, 0) - .saturating_add(Weight::from_parts(0, 5214)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Measured: `270` + // Estimated: `3597` + // Minimum execution time: 46_864_000 picoseconds. + Weight::from_parts(46_864_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: - // Measured: `2285` - // Estimated: `2607` - // Minimum execution time: 62_417_000 picoseconds. - Weight::from_parts(62_417_000, 0) - .saturating_add(Weight::from_parts(0, 2607)) + // Measured: `270` + // Estimated: `3597` + // Minimum execution time: 36_091_000 picoseconds. + Weight::from_parts(36_091_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - fn set_balance_creating() -> Weight { + fn force_set_balance_creating() -> Weight { // Proof Size summary in bytes: - // Measured: `2166` - // Estimated: `2607` - // Minimum execution time: 42_209_000 picoseconds. - Weight::from_parts(42_209_000, 0) - .saturating_add(Weight::from_parts(0, 2607)) + // Measured: `481` + // Estimated: `3597` + // Minimum execution time: 14_596_000 picoseconds. + Weight::from_parts(14_596_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - fn set_balance_killing() -> Weight { + fn force_set_balance_killing() -> Weight { // Proof Size summary in bytes: - // Measured: `2166` - // Estimated: `2607` - // Minimum execution time: 55_056_000 picoseconds. - Weight::from_parts(55_056_000, 0) - .saturating_add(Weight::from_parts(0, 2607)) + // Measured: `481` + // Estimated: `3597` + // Minimum execution time: 20_711_000 picoseconds. + Weight::from_parts(20_711_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: System Account (r:3 w:3) + /// Storage: System Account (r:2 w:2) /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `2556` - // Estimated: `7821` - // Minimum execution time: 83_010_000 picoseconds. - Weight::from_parts(83_010_000, 0) - .saturating_add(Weight::from_parts(0, 7821)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `580` + // Estimated: `6204` + // Minimum execution time: 47_308_000 picoseconds. + Weight::from_parts(47_308_000, 0) + .saturating_add(Weight::from_parts(0, 6204)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) fn transfer_all() -> Weight { // Proof Size summary in bytes: - // Measured: `2285` - // Estimated: `2607` - // Minimum execution time: 64_126_000 picoseconds. - Weight::from_parts(64_126_000, 0) - .saturating_add(Weight::from_parts(0, 2607)) + // Measured: `270` + // Estimated: `3597` + // Minimum execution time: 41_303_000 picoseconds. + Weight::from_parts(41_303_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -128,20 +126,33 @@ impl pallet_balances::WeightInfo for WeightInfo { /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) fn force_unreserve() -> Weight { // Proof Size summary in bytes: - // Measured: `1983` - // Estimated: `2607` - // Minimum execution time: 35_770_000 picoseconds. - Weight::from_parts(35_770_000, 0) - .saturating_add(Weight::from_parts(0, 2607)) + // Measured: `481` + // Estimated: `3597` + // Minimum execution time: 16_789_000 picoseconds. + Weight::from_parts(16_789_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: System Account (r:1000 w:1000) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(_u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `424 + u * (149 ±0)` + // Estimated: `2607990` + // Minimum execution time: 16_053_000 picoseconds. + Weight::from_parts(11_795_725_000, 0) + .saturating_add(Weight::from_parts(0, 2607990)) + .saturating_add(T::DbWeight::get().reads(1000)) + .saturating_add(T::DbWeight::get().writes(1000)) + } } #[cfg(test)] mod tests { #[test] - fn test_transfer() { + fn test_transfer_allow_death() { assert!( ::BlockWeights::get() .per_class @@ -149,7 +160,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 5214 + > 3597 ); } #[test] @@ -161,11 +172,11 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 2607 + > 3597 ); } #[test] - fn test_set_balance_creating() { + fn test_force_set_balance_creating() { assert!( ::BlockWeights::get() .per_class @@ -173,11 +184,11 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 2607 + > 3597 ); } #[test] - fn test_set_balance_killing() { + fn test_force_set_balance_killing() { assert!( ::BlockWeights::get() .per_class @@ -185,7 +196,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 2607 + > 3597 ); } #[test] @@ -197,7 +208,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 7821 + > 6204 ); } #[test] @@ -209,7 +220,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 2607 + > 3597 ); } #[test] @@ -221,7 +232,19 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 2607 + > 3597 + ); + } + #[test] + fn test_upgrade_accounts() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 2607990 ); } } diff --git a/runtimes/peregrine/src/weights/pallet_xcm.rs b/runtimes/peregrine/src/weights/pallet_xcm.rs index 088f55bb68..0d86553de1 100644 --- a/runtimes/peregrine/src/weights/pallet_xcm.rs +++ b/runtimes/peregrine/src/weights/pallet_xcm.rs @@ -1,5 +1,3 @@ -// TODO: UPDATE BEFORE RELEASE - // KILT Blockchain – https://botlabs.org // Copyright (C) 2019-2023 BOTLabs GmbH @@ -21,7 +19,7 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-04-05, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-31, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -65,10 +63,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn send() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `4830` - // Minimum execution time: 53_691_000 picoseconds. - Weight::from_parts(53_691_000, 0) - .saturating_add(Weight::from_parts(0, 4830)) + // Estimated: `3540` + // Minimum execution time: 27_096_000 picoseconds. + Weight::from_parts(27_096_000, 0) + .saturating_add(Weight::from_parts(0, 3540)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -108,8 +106,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 23_351_000 picoseconds. - Weight::from_parts(23_351_000, 0) + // Minimum execution time: 10_952_000 picoseconds. + Weight::from_parts(10_952_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -119,8 +117,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_492_000 picoseconds. - Weight::from_parts(5_492_000, 0) + // Minimum execution time: 4_154_000 picoseconds. + Weight::from_parts(4_154_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -143,10 +141,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `8025` - // Minimum execution time: 32_747_000 picoseconds. - Weight::from_parts(32_747_000, 0) - .saturating_add(Weight::from_parts(0, 8025)) + // Estimated: `3540` + // Minimum execution time: 29_654_000 picoseconds. + Weight::from_parts(29_654_000, 0) + .saturating_add(Weight::from_parts(0, 3540)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -167,22 +165,33 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `257` - // Estimated: `8729` - // Minimum execution time: 27_723_000 picoseconds. - Weight::from_parts(27_723_000, 0) - .saturating_add(Weight::from_parts(0, 8729)) + // Estimated: `3722` + // Minimum execution time: 26_946_000 picoseconds. + Weight::from_parts(26_946_000, 0) + .saturating_add(Weight::from_parts(0, 3722)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) + fn force_suspension() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_416_000 picoseconds. + Weight::from_parts(4_416_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: PolkadotXcm SupportedVersion (r:4 w:2) /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) fn migrate_supported_version() -> Weight { // Proof Size summary in bytes: // Measured: `129` - // Estimated: `10029` - // Minimum execution time: 16_511_000 picoseconds. - Weight::from_parts(16_511_000, 0) - .saturating_add(Weight::from_parts(0, 10029)) + // Estimated: `11019` + // Minimum execution time: 16_769_000 picoseconds. + Weight::from_parts(16_769_000, 0) + .saturating_add(Weight::from_parts(0, 11019)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -191,10 +200,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_version_notifiers() -> Weight { // Proof Size summary in bytes: // Measured: `133` - // Estimated: `10033` - // Minimum execution time: 16_697_000 picoseconds. - Weight::from_parts(16_697_000, 0) - .saturating_add(Weight::from_parts(0, 10033)) + // Estimated: `11023` + // Minimum execution time: 15_907_000 picoseconds. + Weight::from_parts(15_907_000, 0) + .saturating_add(Weight::from_parts(0, 11023)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -203,10 +212,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn already_notified_target() -> Weight { // Proof Size summary in bytes: // Measured: `140` - // Estimated: `12515` - // Minimum execution time: 18_638_000 picoseconds. - Weight::from_parts(18_638_000, 0) - .saturating_add(Weight::from_parts(0, 12515)) + // Estimated: `13505` + // Minimum execution time: 16_655_000 picoseconds. + Weight::from_parts(16_655_000, 0) + .saturating_add(Weight::from_parts(0, 13505)) .saturating_add(T::DbWeight::get().reads(5)) } /// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1) @@ -224,10 +233,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn notify_current_targets() -> Weight { // Proof Size summary in bytes: // Measured: `142` - // Estimated: `10257` - // Minimum execution time: 28_545_000 picoseconds. - Weight::from_parts(28_545_000, 0) - .saturating_add(Weight::from_parts(0, 10257)) + // Estimated: `6082` + // Minimum execution time: 26_604_000 picoseconds. + Weight::from_parts(26_604_000, 0) + .saturating_add(Weight::from_parts(0, 6082)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -236,10 +245,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn notify_target_migration_fail() -> Weight { // Proof Size summary in bytes: // Measured: `172` - // Estimated: `7597` - // Minimum execution time: 8_132_000 picoseconds. - Weight::from_parts(8_132_000, 0) - .saturating_add(Weight::from_parts(0, 7597)) + // Estimated: `8587` + // Minimum execution time: 9_040_000 picoseconds. + Weight::from_parts(9_040_000, 0) + .saturating_add(Weight::from_parts(0, 8587)) .saturating_add(T::DbWeight::get().reads(3)) } /// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2) @@ -247,10 +256,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_version_notify_targets() -> Weight { // Proof Size summary in bytes: // Measured: `140` - // Estimated: `10040` - // Minimum execution time: 17_297_000 picoseconds. - Weight::from_parts(17_297_000, 0) - .saturating_add(Weight::from_parts(0, 10040)) + // Estimated: `11030` + // Minimum execution time: 16_032_000 picoseconds. + Weight::from_parts(16_032_000, 0) + .saturating_add(Weight::from_parts(0, 11030)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -269,10 +278,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: // Measured: `146` - // Estimated: `15231` - // Minimum execution time: 34_890_000 picoseconds. - Weight::from_parts(34_890_000, 0) - .saturating_add(Weight::from_parts(0, 15231)) + // Estimated: `11036` + // Minimum execution time: 32_342_000 picoseconds. + Weight::from_parts(32_342_000, 0) + .saturating_add(Weight::from_parts(0, 11036)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -289,7 +298,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 4830 + > 3540 ); } #[test] @@ -301,7 +310,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 8025 + > 3540 ); } #[test] @@ -313,7 +322,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 8729 + > 3722 ); } #[test] @@ -325,7 +334,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 10029 + > 11019 ); } #[test] @@ -337,7 +346,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 10033 + > 11023 ); } #[test] @@ -349,7 +358,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 12515 + > 13505 ); } #[test] @@ -361,7 +370,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 10257 + > 6082 ); } #[test] @@ -373,7 +382,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 7597 + > 8587 ); } #[test] @@ -385,7 +394,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 10040 + > 11030 ); } #[test] @@ -397,7 +406,7 @@ mod tests { .max_extrinsic .unwrap_or_else(::max_value) .proof_size() - > 15231 + > 11036 ); } } diff --git a/runtimes/peregrine/src/xcm_config.rs b/runtimes/peregrine/src/xcm_config.rs index a21d4e1049..b358227a51 100644 --- a/runtimes/peregrine/src/xcm_config.rs +++ b/runtimes/peregrine/src/xcm_config.rs @@ -25,6 +25,7 @@ use frame_support::{ parameter_types, traits::{Contains, Nothing}, }; +use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -170,6 +171,7 @@ impl pallet_xcm::Config for Runtime { type XcmExecuteFilter = Nothing; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; + type AdminOrigin = EnsureRoot; type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; type RuntimeOrigin = RuntimeOrigin; diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 1ef0c9817f..294353892b 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -174,6 +174,8 @@ parameter_types! { pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; } impl pallet_multisig::Config for Runtime { @@ -195,11 +197,15 @@ impl pallet_indices::Config for Runtime { } impl pallet_balances::Config for Runtime { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; /// The type for recording an account's balance. type Balance = Balance; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; - type DustRemoval = Treasury; + type DustRemoval = runtime_common::SendDustAndFeesToTreasury; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = weights::pallet_balances::WeightInfo; @@ -426,6 +432,7 @@ parameter_types! { pub const SpendPeriod: BlockNumber = constants::governance::SPEND_PERIOD; pub const Burn: Permill = Permill::zero(); pub const MaxApprovals: u32 = 100; + pub MaxProposalWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block; } type ApproveOrigin = EitherOfDiverse< @@ -462,6 +469,7 @@ impl pallet_collective::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; + type MaxProposalWeight = MaxProposalWeight; type MotionDuration = constants::governance::CouncilMotionDuration; type MaxProposals = constants::governance::CouncilMaxProposals; type MaxMembers = constants::governance::CouncilMaxMembers; @@ -473,6 +481,7 @@ impl pallet_collective::Config for Runtime { type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; + type MaxProposalWeight = MaxProposalWeight; type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = constants::governance::TechnicalMotionDuration; @@ -523,6 +532,7 @@ impl pallet_tips::Config for Runtime { } impl attestation::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type EnsureOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; @@ -539,6 +549,7 @@ impl attestation::Config for Runtime { impl delegation::Config for Runtime { type DelegationEntityId = DidIdentifier; + type RuntimeHoldReason = RuntimeHoldReason; type DelegationNodeId = Hash; type EnsureOrigin = did::EnsureDidOrigin; @@ -569,7 +580,7 @@ impl ctype::Config for Runtime { type CtypeCreatorId = AccountId; type Currency = Balances; type Fee = constants::CtypeFee; - type FeeCollector = Treasury; + type FeeCollector = runtime_common::SendDustAndFeesToTreasury; type EnsureOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; @@ -584,6 +595,7 @@ impl ctype::Config for Runtime { impl did::Config for Runtime { type DidIdentifier = DidIdentifier; type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = RuntimeHoldReason; type RuntimeCall = RuntimeCall; type RuntimeOrigin = RuntimeOrigin; type Currency = Balances; @@ -591,7 +603,7 @@ impl did::Config for Runtime { type ServiceEndpointDeposit = constants::did::ServiceEndpointDeposit; type BaseDeposit = constants::did::DidBaseDeposit; type Fee = constants::did::DidFee; - type FeeCollector = Treasury; + type FeeCollector = runtime_common::SendDustAndFeesToTreasury; #[cfg(not(feature = "runtime-benchmarks"))] type EnsureOrigin = did::EnsureDidOrigin; @@ -617,6 +629,7 @@ impl did::Config for Runtime { } impl pallet_did_lookup::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type RuntimeEvent = RuntimeEvent; type DidIdentifier = DidIdentifier; @@ -631,6 +644,7 @@ impl pallet_did_lookup::Config for Runtime { } impl pallet_web3_names::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type BanOrigin = EnsureRoot; type OwnerOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; @@ -648,11 +662,12 @@ impl pallet_inflation::Config for Runtime { type Currency = Balances; type InitialPeriodLength = constants::treasury::InitialPeriodLength; type InitialPeriodReward = constants::treasury::InitialPeriodReward; - type Beneficiary = Treasury; + type Beneficiary = runtime_common::SendDustAndFeesToTreasury; type WeightInfo = weights::pallet_inflation::WeightInfo; } impl parachain_staking::Config for Runtime { + type FreezeIdentifier = RuntimeFreezeReason; type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = Balance; @@ -672,7 +687,7 @@ impl parachain_staking::Config for Runtime { type MaxUnstakeRequests = constants::staking::MaxUnstakeRequests; type NetworkRewardRate = constants::staking::NetworkRewardRate; type NetworkRewardStart = constants::staking::NetworkRewardStart; - type NetworkRewardBeneficiary = Treasury; + type NetworkRewardBeneficiary = runtime_common::SendDustAndFeesToTreasury; type WeightInfo = weights::parachain_staking::WeightInfo; const BLOCKS_PER_YEAR: Self::BlockNumber = constants::BLOCKS_PER_YEAR; @@ -687,6 +702,7 @@ impl pallet_utility::Config for Runtime { impl public_credentials::Config for Runtime { type AccessControl = PalletAuthorize>; + type RuntimeHoldReason = RuntimeHoldReason; type AttesterId = DidIdentifier; type AuthorizationId = AuthorizationId<::DelegationNodeId>; type CredentialId = Hash; @@ -1069,6 +1085,13 @@ pub type Executive = frame_executive::Executive< ( pallet_did_lookup::migrations::CleanupMigration, runtime_common::migrations::RemoveInsecureRandomnessPallet, + attestation::migrations::BalanceMigration, + delegation::migrations::BalanceMigration, + did::migrations::BalanceMigration, + pallet_did_lookup::migrations::BalanceMigration, + pallet_web3_names::migrations::BalanceMigration, + parachain_staking::migrations::BalanceMigration, + public_credentials::migrations::BalanceMigration, ), >; @@ -1125,6 +1148,14 @@ impl_runtime_apis! { fn metadata() -> OpaqueMetadata { OpaqueMetadata::new(Runtime::metadata().into()) } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } } impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { diff --git a/runtimes/spiritnet/src/weights/pallet_balances.rs b/runtimes/spiritnet/src/weights/pallet_balances.rs index 6bb8bbfe5d..11e98f3544 100644 --- a/runtimes/spiritnet/src/weights/pallet_balances.rs +++ b/runtimes/spiritnet/src/weights/pallet_balances.rs @@ -16,12 +16,13 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -//! Autogenerated weights for pallet_balances +//! Autogenerated weights for pallet_collective //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-03-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("spiritnet-dev"), DB CACHE: 1024 + // Executed Command: // ./target/release/kilt-parachain // benchmark @@ -40,61 +41,211 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(clippy::unnecessary_cast)] use frame_support::{traits::Get, weights::Weight}; use sp_std::marker::PhantomData; -/// Weights for `pallet_balances`. +/// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); impl pallet_balances::WeightInfo for WeightInfo { - // Storage: System Account (r:2 w:2) - // Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - fn transfer() -> Weight { - Weight::from_parts(72_209_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + fn transfer_allow_death() -> Weight { + // Proof Size summary in bytes: + // Measured: `270` + // Estimated: `3597` + // Minimum execution time: 36_429_000 picoseconds. + Weight::from_parts(37_980_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { - Weight::from_parts(70_328_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - fn set_balance_creating() -> Weight { - Weight::from_parts(49_562_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - fn set_balance_killing() -> Weight { - Weight::from_parts(39_743_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: System Account (r:3 w:3) - // Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + // Proof Size summary in bytes: + // Measured: `270` + // Estimated: `3597` + // Minimum execution time: 27_644_000 picoseconds. + Weight::from_parts(28_433_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + fn force_set_balance_creating() -> Weight { + // Proof Size summary in bytes: + // Measured: `481` + // Estimated: `3597` + // Minimum execution time: 11_317_000 picoseconds. + Weight::from_parts(11_656_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + fn force_set_balance_killing() -> Weight { + // Proof Size summary in bytes: + // Measured: `481` + // Estimated: `3597` + // Minimum execution time: 15_362_000 picoseconds. + Weight::from_parts(15_779_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) fn force_transfer() -> Weight { - Weight::from_parts(76_438_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `580` + // Estimated: `6204` + // Minimum execution time: 38_392_000 picoseconds. + Weight::from_parts(39_183_000, 0) + .saturating_add(Weight::from_parts(0, 6204)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) fn transfer_all() -> Weight { - Weight::from_parts(58_160_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `270` + // Estimated: `3597` + // Minimum execution time: 34_276_000 picoseconds. + Weight::from_parts(35_179_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) fn force_unreserve() -> Weight { - Weight::from_parts(31_980_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `481` + // Estimated: `3597` + // Minimum execution time: 12_914_000 picoseconds. + Weight::from_parts(13_366_000, 0) + .saturating_add(Weight::from_parts(0, 3597)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `6922 + u * (143 ±0)` + // Estimated: `990 + u * (2607 ±0)` + // Minimum execution time: 12_089_000 picoseconds. + Weight::from_parts(12_384_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 6_368 + .saturating_add(Weight::from_parts(10_591_397, 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, 2607).saturating_mul(u.into())) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_transfer_allow_death() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3597 + ); + } + #[test] + fn test_transfer_keep_alive() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3597 + ); + } + #[test] + fn test_force_set_balance_creating() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3597 + ); + } + #[test] + fn test_force_set_balance_killing() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3597 + ); + } + #[test] + fn test_force_transfer() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } + #[test] + fn test_transfer_all() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3597 + ); + } + #[test] + fn test_force_unreserve() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3597 + ); + } + #[test] + fn test_upgrade_accounts() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 990 + ); } } diff --git a/runtimes/spiritnet/src/weights/pallet_xcm.rs b/runtimes/spiritnet/src/weights/pallet_xcm.rs index 8bb2babb73..f5b443b757 100644 --- a/runtimes/spiritnet/src/weights/pallet_xcm.rs +++ b/runtimes/spiritnet/src/weights/pallet_xcm.rs @@ -1,25 +1,10 @@ -// KILT Blockchain – https://botlabs.org -// Copyright (C) 2019-2023 BOTLabs GmbH -// The KILT Blockchain is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The KILT Blockchain is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// If you feel like getting in touch with us, you can do so at info@botlabs.org - -//! Autogenerated weights for pallet_xcm +//! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("spiritnet-dev"), DB CACHE: 1024 // Executed Command: @@ -40,161 +25,370 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(clippy::unnecessary_cast)] use frame_support::{traits::Get, weights::Weight}; use sp_std::marker::PhantomData; -/// Weights for `pallet_xcm`. +/// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - // Storage: PolkadotXcm SupportedVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) - // Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) - // Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn send() -> Weight { - Weight::from_parts(47_819_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `75` + // Estimated: `3540` + // Minimum execution time: 16_473_000 picoseconds. + Weight::from_parts(16_813_000, 0) + .saturating_add(Weight::from_parts(0, 3540)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: Benchmark Override (r:0 w:0) - // Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured) + /// Storage: Benchmark Override (r:0 w:0) + /// Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured) fn teleport_assets() -> Weight { - Weight::from_parts(18_446_744_073_709_551_000 as u64, 0) + // 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: Benchmark Override (r:0 w:0) - // Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured) + /// Storage: Benchmark Override (r:0 w:0) + /// Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured) fn reserve_transfer_assets() -> Weight { - Weight::from_parts(18_446_744_073_709_551_000 as u64, 0) + // 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: Benchmark Override (r:0 w:0) - // Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured) + /// Storage: Benchmark Override (r:0 w:0) + /// Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured) fn execute() -> Weight { - Weight::from_parts(18_446_744_073_709_551_000 as u64, 0) + // 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 Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm SupportedVersion (r:0 w:1) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) fn force_xcm_version() -> Weight { - Weight::from_parts(11_906_000 as u64, 0) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 5_618_000 picoseconds. + Weight::from_parts(5_839_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: PolkadotXcm SafeXcmVersion (r:0 w:1) - // Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:0 w:1) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) fn force_default_xcm_version() -> Weight { - Weight::from_parts(3_726_000 as u64, 0) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: PolkadotXcm VersionNotifiers (r:1 w:1) - // Proof Skipped: PolkadotXcm VersionNotifiers (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm QueryCounter (r:1 w:1) - // Proof Skipped: PolkadotXcm QueryCounter (max_values: Some(1), max_size: None, mode: Measured) - // Storage: PolkadotXcm SupportedVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) - // Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) - // Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) - // Storage: PolkadotXcm Queries (r:0 w:1) - // Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_669_000 picoseconds. + Weight::from_parts(1_777_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: PolkadotXcm VersionNotifiers (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionNotifiers (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm QueryCounter (r:1 w:1) + /// Proof Skipped: PolkadotXcm QueryCounter (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm Queries (r:0 w:1) + /// Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) fn force_subscribe_version_notify() -> Weight { - Weight::from_parts(39_357_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) - } - // Storage: PolkadotXcm VersionNotifiers (r:1 w:1) - // Proof Skipped: PolkadotXcm VersionNotifiers (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm SupportedVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) - // Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) - // Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) - // Storage: PolkadotXcm Queries (r:0 w:1) - // Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) + // Proof Size summary in bytes: + // Measured: `75` + // Estimated: `3540` + // Minimum execution time: 19_873_000 picoseconds. + Weight::from_parts(20_802_000, 0) + .saturating_add(Weight::from_parts(0, 3540)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: PolkadotXcm VersionNotifiers (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionNotifiers (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm Queries (r:0 w:1) + /// Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) fn force_unsubscribe_version_notify() -> Weight { - Weight::from_parts(57_944_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `257` + // Estimated: `3722` + // Minimum execution time: 19_919_000 picoseconds. + Weight::from_parts(20_827_000, 0) + .saturating_add(Weight::from_parts(0, 3722)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) } - // Storage: PolkadotXcm SupportedVersion (r:4 w:2) - // Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) + fn force_suspension() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_597_000 picoseconds. + Weight::from_parts(1_707_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: PolkadotXcm SupportedVersion (r:4 w:2) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) fn migrate_supported_version() -> Weight { - Weight::from_parts(33_805_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `167` + // Estimated: `11057` + // Minimum execution time: 10_805_000 picoseconds. + Weight::from_parts(11_187_000, 0) + .saturating_add(Weight::from_parts(0, 11057)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: PolkadotXcm VersionNotifiers (r:4 w:2) - // Proof Skipped: PolkadotXcm VersionNotifiers (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionNotifiers (r:4 w:2) + /// Proof Skipped: PolkadotXcm VersionNotifiers (max_values: None, max_size: None, mode: Measured) fn migrate_version_notifiers() -> Weight { - Weight::from_parts(35_045_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `171` + // Estimated: `11061` + // Minimum execution time: 10_832_000 picoseconds. + Weight::from_parts(11_129_000, 0) + .saturating_add(Weight::from_parts(0, 11061)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0) - // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0) + /// Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) fn already_notified_target() -> Weight { - Weight::from_parts(39_994_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - } - // Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1) - // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm SupportedVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) - // Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) - // Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) + // Proof Size summary in bytes: + // Measured: `178` + // Estimated: `13543` + // Minimum execution time: 11_720_000 picoseconds. + Weight::from_parts(12_047_000, 0) + .saturating_add(Weight::from_parts(0, 13543)) + .saturating_add(T::DbWeight::get().reads(5)) + } + /// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1) + /// Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn notify_current_targets() -> Weight { - Weight::from_parts(35_628_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `142` + // Estimated: `6082` + // Minimum execution time: 19_071_000 picoseconds. + Weight::from_parts(20_142_000, 0) + .saturating_add(Weight::from_parts(0, 6082)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0) - // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0) + /// Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) fn notify_target_migration_fail() -> Weight { - Weight::from_parts(9_994_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(3 as u64)) + // Proof Size summary in bytes: + // Measured: `172` + // Estimated: `8587` + // Minimum execution time: 6_465_000 picoseconds. + Weight::from_parts(6_695_000, 0) + .saturating_add(Weight::from_parts(0, 8587)) + .saturating_add(T::DbWeight::get().reads(3)) } - // Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2) - // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2) + /// Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) fn migrate_version_notify_targets() -> Weight { - Weight::from_parts(20_693_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2) - // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm SupportedVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) - // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) - // Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) - // Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem HostConfiguration (r:1 w:0) - // Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) - // Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) + // Proof Size summary in bytes: + // Measured: `178` + // Estimated: `11068` + // Minimum execution time: 11_436_000 picoseconds. + Weight::from_parts(11_870_000, 0) + .saturating_add(Weight::from_parts(0, 11068)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2) + /// Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem HostConfiguration (r:1 w:0) + /// Proof Skipped: ParachainSystem HostConfiguration (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn migrate_and_notify_old_targets() -> Weight { - Weight::from_parts(44_084_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(9 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `184` + // Estimated: `11074` + // Minimum execution time: 23_845_000 picoseconds. + Weight::from_parts(24_549_000, 0) + .saturating_add(Weight::from_parts(0, 11074)) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_send() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3540 + ); + } + #[test] + fn test_force_subscribe_version_notify() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3540 + ); + } + #[test] + fn test_force_unsubscribe_version_notify() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3722 + ); + } + #[test] + fn test_migrate_supported_version() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 11057 + ); + } + #[test] + fn test_migrate_version_notifiers() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 11061 + ); + } + #[test] + fn test_already_notified_target() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 13543 + ); + } + #[test] + fn test_notify_current_targets() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6082 + ); + } + #[test] + fn test_notify_target_migration_fail() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 8587 + ); + } + #[test] + fn test_migrate_version_notify_targets() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 11068 + ); + } + #[test] + fn test_migrate_and_notify_old_targets() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 11074 + ); } } diff --git a/runtimes/spiritnet/src/xcm_config.rs b/runtimes/spiritnet/src/xcm_config.rs index e399457755..698ff47eeb 100644 --- a/runtimes/spiritnet/src/xcm_config.rs +++ b/runtimes/spiritnet/src/xcm_config.rs @@ -25,6 +25,7 @@ use frame_support::{ parameter_types, traits::{Contains, Nothing}, }; +use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -167,6 +168,7 @@ impl pallet_xcm::Config for Runtime { type XcmExecuteFilter = Nothing; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; + type AdminOrigin = EnsureRoot; type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; type RuntimeOrigin = RuntimeOrigin; diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs index 5da80f8305..f4d1cb8fbf 100644 --- a/runtimes/standalone/src/lib.rs +++ b/runtimes/standalone/src/lib.rs @@ -29,7 +29,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use frame_support::{ construct_runtime, parameter_types, - traits::{Currency, Everything, InstanceFilter}, + traits::{Everything, InstanceFilter}, weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee, Weight}, }; pub use frame_system::Call as SystemCall; @@ -62,7 +62,6 @@ use runtime_common::{ authorization::{AuthorizationId, PalletAuthorize}, constants::{self, EXISTENTIAL_DEPOSIT, KILT}, errors::PublicCredentialsApiError, - fees::ToAuthor, AccountId, Balance, BlockNumber, DidIdentifier, Hash, Index, Signature, SlowAdjustingFeeUpdate, }; @@ -88,9 +87,6 @@ pub use sp_runtime::BuildStorage; /// Digest item type. pub type DigestItem = generic::DigestItem; -pub type NegativeImbalance = - as Currency<::AccountId>>::NegativeImbalance; - /// Opaque types. These are used by the CLI to instantiate machinery that don't /// need to know the specifics of the runtime. They can then be made to be /// agnostic over specific formats of data like extrinsics, allowing for them to @@ -246,9 +242,15 @@ parameter_types! { pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; + pub const MaxFreezes: u32 = 50; + pub const MaxHolds: u32 = 50; } impl pallet_balances::Config for Runtime { + type FreezeIdentifier = RuntimeFreezeReason; + type HoldIdentifier = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; @@ -288,6 +290,7 @@ parameter_types! { } impl attestation::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type EnsureOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; type RuntimeEvent = RuntimeEvent; @@ -311,6 +314,7 @@ parameter_types! { } impl delegation::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; #[cfg(not(feature = "runtime-benchmarks"))] type Signature = did::DidSignature; #[cfg(not(feature = "runtime-benchmarks"))] @@ -343,7 +347,7 @@ parameter_types! { impl ctype::Config for Runtime { type Currency = Balances; type Fee = Fee; - type FeeCollector = runtime_common::fees::ToAuthor; + type FeeCollector = runtime_common::fees::ToAuthorCredit; type CtypeCreatorId = DidIdentifier; type EnsureOrigin = did::EnsureDidOrigin; @@ -372,6 +376,7 @@ parameter_types! { } impl did::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type DidIdentifier = DidIdentifier; type KeyDeposit = constants::did::KeyDeposit; type ServiceEndpointDeposit = constants::did::ServiceEndpointDeposit; @@ -381,7 +386,7 @@ impl did::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Currency = Balances; type Fee = DidFee; - type FeeCollector = ToAuthor; + type FeeCollector = runtime_common::fees::ToAuthorCredit; #[cfg(not(feature = "runtime-benchmarks"))] type EnsureOrigin = did::EnsureDidOrigin; @@ -407,6 +412,7 @@ impl did::Config for Runtime { } impl pallet_did_lookup::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type RuntimeEvent = RuntimeEvent; type DidIdentifier = DidIdentifier; @@ -421,6 +427,7 @@ impl pallet_did_lookup::Config for Runtime { } impl pallet_web3_names::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type BanOrigin = EnsureRoot; type OwnerOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; @@ -468,6 +475,7 @@ impl pallet_utility::Config for Runtime { } impl public_credentials::Config for Runtime { + type RuntimeHoldReason = RuntimeHoldReason; type AccessControl = PalletAuthorize>; type AttesterId = DidIdentifier; type AuthorizationId = AuthorizationId<::DelegationNodeId>; @@ -831,6 +839,14 @@ impl_runtime_apis! { fn metadata() -> OpaqueMetadata { OpaqueMetadata::new(Runtime::metadata().into()) } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } } impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { diff --git a/support/src/deposit.rs b/support/src/deposit.rs index 00ad18f04e..f2296cd05d 100644 --- a/support/src/deposit.rs +++ b/support/src/deposit.rs @@ -16,10 +16,13 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::traits::ReservableCurrency; +use frame_support::traits::{ + fungible::{hold::Mutate, Inspect}, + tokens::Precision, +}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_runtime::{traits::Zero, DispatchError}; +use sp_runtime::DispatchError; /// An amount of balance reserved by the specified address. #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] @@ -29,18 +32,29 @@ pub struct Deposit { pub amount: Balance, } -pub fn reserve_deposit>( +pub(crate) fn reserve_deposit>( account: Account, deposit_amount: Currency::Balance, + reason: &Currency::Reason, ) -> Result, DispatchError> { - Currency::reserve(&account, deposit_amount)?; + Currency::hold(reason, &account, deposit_amount)?; Ok(Deposit { owner: account, amount: deposit_amount, }) } -pub fn free_deposit>(deposit: &Deposit) { - let err_amount = Currency::unreserve(&deposit.owner, deposit.amount); - debug_assert!(err_amount.is_zero()); +pub(crate) fn free_deposit>( + deposit: &Deposit, + reason: &Currency::Reason, +) -> Result<>::Balance, DispatchError> { + let result = Currency::release(reason, &deposit.owner, deposit.amount, Precision::BestEffort); + debug_assert!( + result == Ok(deposit.amount), + "Released deposit amount does not match with expected amount. Expected: {:?}, Released amount: {:?} Error: {:?}", + deposit.amount, + result.ok(), + result.err(), + ); + result } diff --git a/support/src/lib.rs b/support/src/lib.rs index 2f5a06dae8..c5e9658211 100644 --- a/support/src/lib.rs +++ b/support/src/lib.rs @@ -17,13 +17,15 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org #![cfg_attr(not(feature = "std"), no_std)] -pub mod deposit; -pub use deposit::{free_deposit, reserve_deposit}; +mod deposit; -#[cfg(any(feature = "try-runtime", test))] -pub mod test_utils; +pub use deposit::Deposit; -#[cfg(any(feature = "runtime-benchmarks", feature = "mock"))] -pub mod mock; +pub mod migration; pub mod signature; pub mod traits; + +#[cfg(any(feature = "runtime-benchmarks", feature = "mock"))] +pub mod mock; +#[cfg(any(feature = "try-runtime", test))] +pub mod test_utils; diff --git a/support/src/migration.rs b/support/src/migration.rs new file mode 100644 index 0000000000..d186e0498f --- /dev/null +++ b/support/src/migration.rs @@ -0,0 +1,47 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + pallet_prelude::DispatchResult, + traits::{fungible::hold::Mutate as MutateHold, ReservableCurrency}, +}; +use sp_runtime::{traits::Zero, SaturatedConversion}; + +/// Checks some precondition of the migrations. +pub fn has_user_reserved_balance + MutateHold>( + owner: &AccountId, + reason: &Currency::Reason, +) -> bool { + Currency::balance_on_hold(reason, owner).is_zero() && Currency::reserved_balance(owner) > Zero::zero() +} + +pub fn switch_reserved_to_hold + MutateHold>( + owner: AccountId, + reason: &Currency::Reason, + amount: u128, +) -> DispatchResult { + let remaining_balance = Currency::unreserve(&owner, amount.saturated_into()); + debug_assert!( + remaining_balance.is_zero(), + "Could not unreserve balance. Remaining: {:?}. To unreserve: {:?}", + remaining_balance, + amount + ); + let to_hold_balance = amount.saturating_sub(remaining_balance.saturated_into()); + Currency::hold(reason, &owner, to_hold_balance.saturated_into()) +} diff --git a/support/src/test_utils.rs b/support/src/test_utils.rs index d0bfffed66..37ea78cad2 100644 --- a/support/src/test_utils.rs +++ b/support/src/test_utils.rs @@ -21,5 +21,5 @@ use scale_info::prelude::string::String; /// Logs the error message and returns "Sanity test error" pub fn log_and_return_error_message(error_message: String) -> &'static str { log::error!("{}", error_message); - "Sanity test error" + "Test error" } diff --git a/support/src/traits.rs b/support/src/traits.rs index 0d4050163e..de11c7ca92 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -16,10 +16,13 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::traits::{Currency, ReservableCurrency}; +use frame_support::traits::{ + fungible::hold::Mutate, + tokens::fungible::{Inspect, MutateHold}, +}; use sp_runtime::DispatchError; -use crate::{deposit::Deposit, free_deposit}; +use crate::deposit::{free_deposit, reserve_deposit, Deposit}; /// The sources of a call struct. /// @@ -86,27 +89,52 @@ pub trait ItemFilter { fn should_include(&self, credential: &Item) -> bool; } -pub trait StorageDepositCollector { - type Currency: ReservableCurrency; +pub trait StorageDepositCollector { + type Currency: MutateHold; + // TODO: This could also be replaced with a `Borrow` or an + // `AsRef`, but not sure what trait the runtime composite + // enum implements. + type Reason: Into + Clone; + + /// Returns the hold reason for deposits taken by the deposit collector; + fn reason() -> Self::Reason; /// Returns the deposit of the storage entry that is stored behind the key. - fn deposit( - key: &Key, - ) -> Result>::Balance>, DispatchError>; + fn deposit(key: &Key) + -> Result>::Balance>, DispatchError>; /// Returns the deposit amount that should be reserved for the storage entry /// behind the key. /// /// This value can differ from the actual deposit that is reserved at the /// time, since the deposit can be changed. - fn deposit_amount(key: &Key) -> >::Balance; + fn deposit_amount(key: &Key) -> >::Balance; /// Store the new deposit information in the storage entry behind the key. fn store_deposit( key: &Key, - deposit: Deposit>::Balance>, + deposit: Deposit>::Balance>, ) -> Result<(), DispatchError>; + /// Release the deposit. + fn free_deposit( + deposit: Deposit>::Balance>, + ) -> Result<>::Balance, DispatchError> { + free_deposit::(&deposit, &Self::reason().into()) + } + + /// Creates a new deposit for user. + /// + /// # Errors + /// Can fail if the user has not enough balance. + fn create_deposit( + who: AccountId, + amount: >::Balance, + ) -> Result>::Balance>, DispatchError> { + let reason = Self::reason(); + reserve_deposit::(who, amount, &reason.into()) + } + /// Change the deposit owner. /// /// The deposit balance of the current owner will be freed, while the @@ -114,14 +142,15 @@ pub trait StorageDepositCollector { /// will not change even if the required byte and item fees were updated. fn change_deposit_owner(key: &Key, new_owner: AccountId) -> Result<(), DispatchError> { let deposit = Self::deposit(key)?; + let reason = Self::reason(); - free_deposit::(&deposit); + free_deposit::(&deposit, &reason.clone().into())?; let deposit = Deposit { owner: new_owner, ..deposit }; - Self::Currency::reserve(&deposit.owner, deposit.amount)?; + Self::Currency::hold(&reason.into(), &deposit.owner, deposit.amount)?; Self::store_deposit(key, deposit)?; @@ -136,14 +165,15 @@ pub trait StorageDepositCollector { /// the deposit was raised. fn update_deposit(key: &Key) -> Result<(), DispatchError> { let deposit = Self::deposit(key)?; + let reason = Self::reason(); - free_deposit::(&deposit); + free_deposit::(&deposit, &reason.clone().into())?; let deposit = Deposit { amount: Self::deposit_amount(key), ..deposit }; - Self::Currency::reserve(&deposit.owner, deposit.amount)?; + Self::Currency::hold(&reason.into(), &deposit.owner, deposit.amount)?; Self::store_deposit(key, deposit)?;