diff --git a/Cargo.lock b/Cargo.lock index f49eee1cb2..0877be2163 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if 1.0.0", "cipher", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "opaque-debug 0.3.0", ] @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.55" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd" +checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" [[package]] name = "approx" @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "async-global-executor" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" +checksum = "c026b7e44f1316b567ee750fea85103f87fcb80792b860e979f221259796ca0a" dependencies = [ "async-channel", "async-executor", @@ -301,9 +301,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8" +checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" [[package]] name = "async-trait" @@ -667,9 +667,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "blocking" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046e47d4b2d391b1f6f8b407b1deb8dee56c1852ccd868becf2710f601b5f427" +checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" dependencies = [ "async-channel", "async-task", @@ -1055,9 +1055,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.1.2" +version = "3.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5177fac1ab67102d8989464efd043c6ff44191b1557ec1ddd489b4f7e1447e77" +checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123" dependencies = [ "atty", "bitflags", @@ -1072,9 +1072,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.1.2" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d42c94ce7c2252681b5fed4d3627cc807b13dfc033246bd05d5b252399000e" +checksum = "da95d038ede1a964ce99f49cbe27a7fb538d1da595e4b4f70b8c8f338d17bf16" dependencies = [ "heck 0.4.0", "proc-macro-error", @@ -1149,9 +1149,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" dependencies = [ "libc", ] @@ -1256,9 +1256,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" +checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -1277,10 +1277,11 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" +checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" dependencies = [ + "autocfg", "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", @@ -1290,9 +1291,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ "cfg-if 1.0.0", "lazy_static", @@ -1345,9 +1346,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa" +checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" dependencies = [ "quote", "syn", @@ -1397,7 +1398,7 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "clap", "sc-cli", @@ -1407,7 +1408,7 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", @@ -1431,7 +1432,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-client-consensus-common", @@ -1460,7 +1461,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -1481,7 +1482,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-relay-chain" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-client-consensus-common", @@ -1505,7 +1506,7 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -1530,7 +1531,7 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", @@ -1554,7 +1555,7 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-client-collator", "cumulus-client-consensus-common", @@ -1583,7 +1584,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "frame-executive", "frame-support", @@ -1601,7 +1602,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-pallet-parachain-system-proc-macro", "cumulus-primitives-core", @@ -1631,7 +1632,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -1642,7 +1643,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-session-benchmarking" version = "3.0.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "frame-benchmarking", "frame-support", @@ -1656,7 +1657,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1674,7 +1675,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-core" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "frame-support", "parity-scale-codec", @@ -1690,7 +1691,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1713,7 +1714,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "sp-inherents", @@ -1724,7 +1725,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1745,7 +1746,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-local" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1773,7 +1774,7 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -1958,9 +1959,9 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", @@ -2023,15 +2024,15 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" +checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" [[package]] name = "ed25519" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed12bbf7b5312f8da1c2722bc06d8c6b12c2d86a7fb35a194c7f3e6fc2bbe39" +checksum = "3d5c4b5e5959dc2c2b89918d8e2cc40fcdd623cef026ed09d2f0ee05199dc8e4" dependencies = [ "signature", ] @@ -2760,9 +2761,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" +checksum = "62eeb471aa3e3c9197aa4bfeabfe02982f6dc96f750486c0bb0009ac58b26d2b" dependencies = [ "bytes 1.1.0", "fnv", @@ -2779,9 +2780,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.2.1" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25546a65e5cf1f471f3438796fc634650b31d7fcde01d444c309aeb28b92e3a8" +checksum = "99d6a30320f094710245150395bc763ad23128d6a1ebbad7594dc4164b62c56b" dependencies = [ "log", "pest", @@ -3150,9 +3151,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" +checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c" [[package]] name = "itertools" @@ -3363,7 +3364,7 @@ dependencies = [ "soketto", "thiserror", "tokio", - "tokio-rustls 0.23.2", + "tokio-rustls 0.23.3", "tokio-util", "tracing", "webpki-roots 0.22.2", @@ -3769,9 +3770,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.119" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" +checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" [[package]] name = "libloading" @@ -4165,7 +4166,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "lru 0.7.2", + "lru 0.7.3", "rand 0.7.3", "smallvec", "unsigned-varint 0.7.1", @@ -4334,9 +4335,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +checksum = "6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859" dependencies = [ "cc", "pkg-config", @@ -4413,9 +4414,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "274353858935c992b13c0ca408752e2121da852d07dec7ce5f108c77dfa14d1f" +checksum = "fcb87f3080f6d1d69e8c564c0fcfde1d7aa8cc451ce40cae89479111f03bc0eb" dependencies = [ "hashbrown 0.11.2", ] @@ -4431,9 +4432,9 @@ dependencies = [ [[package]] name = "lz4" -version = "1.23.2" +version = "1.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aac20ed6991e01bf6a2e68cc73df2b389707403662a8ba89f68511fb340f724c" +checksum = "4edcb94251b1c375c459e5abe9fb0168c1c826c3370172684844f8f3f8d1a885" dependencies = [ "libc", "lz4-sys", @@ -4441,9 +4442,9 @@ dependencies = [ [[package]] name = "lz4-sys" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca79aa95d8b3226213ad454d328369853be3a1382d89532a854f4d69640acae" +checksum = "d7be8908e2ed6f31c02db8a9fa962f03e36c53fbfde437363eae3306b85d7e17" dependencies = [ "cc", "libc", @@ -4686,9 +4687,9 @@ dependencies = [ [[package]] name = "mick-jaeger" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2c2cc134e57461f0898b0e921f0a7819b5e3f3a4335b9aa390ce81a5f36fb9" +checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" dependencies = [ "futures 0.3.21", "rand 0.8.5", @@ -4732,14 +4733,15 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" +checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" dependencies = [ "libc", "log", "miow 0.3.7", "ntapi", + "wasi 0.11.0+wasi-snapshot-preview1", "winapi 0.3.9", ] @@ -5053,13 +5055,12 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "nom" -version = "7.1.0" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" dependencies = [ "memchr", "minimal-lexical", - "version_check", ] [[package]] @@ -5091,6 +5092,16 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa 0.4.8", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -5157,9 +5168,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" [[package]] name = "opaque-debug" @@ -5625,6 +5636,7 @@ dependencies = [ "frame-support", "frame-system", "kilt-support", + "log", "pallet-balances", "parity-scale-codec", "runtime-common", @@ -6354,7 +6366,7 @@ dependencies = [ [[package]] name = "parachain-info" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -6393,9 +6405,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09aa6c5bb8070cf0456d9fc228b3022e900aae9092c48c9c45facf97422efc1d" +checksum = "865edee5b792f537356d9e55cbc138e7f4718dc881a7ea45a18b37bf61c21e3d" dependencies = [ "blake2-rfc", "crc32fast", @@ -6576,7 +6588,7 @@ dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall 0.2.10", + "redox_syscall 0.2.11", "smallvec", "winapi 0.3.9", ] @@ -6589,7 +6601,7 @@ checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.2.10", + "redox_syscall 0.2.11", "smallvec", "windows-sys", ] @@ -6869,7 +6881,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0e dependencies = [ "derive_more", "futures 0.3.21", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6890,7 +6902,7 @@ version = "0.9.17" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0ecd4760b146ecf33f5e867d707d789e21e060" dependencies = [ "futures 0.3.21", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6998,7 +7010,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0e dependencies = [ "derive_more", "futures 0.3.21", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -7094,7 +7106,7 @@ dependencies = [ "futures 0.3.21", "futures-timer", "kvdb", - "lru 0.7.2", + "lru 0.7.3", "merlin", "parity-scale-codec", "polkadot-node-jaeger", @@ -7222,7 +7234,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0e dependencies = [ "futures 0.3.21", "kvdb", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -7446,7 +7458,7 @@ dependencies = [ "derive_more", "futures 0.3.21", "itertools", - "lru 0.7.2", + "lru 0.7.3", "metered-channel", "parity-scale-codec", "pin-project 1.0.10", @@ -7472,7 +7484,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0e dependencies = [ "futures 0.3.21", "futures-timer", - "lru 0.7.2", + "lru 0.7.3", "parity-util-mem", "parking_lot 0.11.2", "polkadot-node-metrics", @@ -7818,7 +7830,7 @@ dependencies = [ "kusama-runtime", "kvdb", "kvdb-rocksdb", - "lru 0.7.2", + "lru 0.7.3", "pallet-babe", "pallet-im-online", "pallet-mmr-primitives", @@ -7954,7 +7966,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "opaque-debug 0.3.0", "universal-hash", ] @@ -7966,7 +7978,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" dependencies = [ "cfg-if 1.0.0", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "opaque-debug 0.3.0", "universal-hash", ] @@ -8143,9 +8155,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57" dependencies = [ "proc-macro2", ] @@ -8286,21 +8298,22 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55" dependencies = [ "getrandom 0.2.5", - "redox_syscall 0.2.10", + "redox_syscall 0.2.11", + "thiserror", ] [[package]] @@ -8349,9 +8362,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "aho-corasick", "memchr", @@ -9297,7 +9310,7 @@ dependencies = [ "linked-hash-map", "linked_hash_set", "log", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "parking_lot 0.11.2", "pin-project 1.0.10", @@ -9334,7 +9347,7 @@ dependencies = [ "futures-timer", "libp2p", "log", - "lru 0.7.2", + "lru 0.7.3", "sc-network", "sp-runtime", "substrate-prometheus-endpoint", @@ -9896,7 +9909,7 @@ checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "digest 0.9.0", "opaque-debug 0.3.0", ] @@ -9921,7 +9934,7 @@ checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "digest 0.9.0", "opaque-debug 0.3.0", ] @@ -9933,7 +9946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ "cfg-if 1.0.0", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "digest 0.10.3", ] @@ -10196,7 +10209,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22 dependencies = [ "futures 0.3.21", "log", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "parking_lot 0.11.2", "sp-api", @@ -10887,11 +10900,12 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f9799e6d412271cb2414597581128b03f3285f260ea49f5363d07df6a332b3e" +checksum = "7b84a70894df7a73666e0694f44b41a9571625e9546fb58a0818a565d2c7e084" dependencies = [ "Inflector", + "num-format", "proc-macro2", "quote", "serde", @@ -11064,9 +11078,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" dependencies = [ "proc-macro2", "quote", @@ -11106,25 +11120,25 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "libc", - "redox_syscall 0.2.10", + "redox_syscall 0.2.11", "remove_dir_all", "winapi 0.3.9", ] [[package]] name = "termcolor" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] [[package]] name = "textwrap" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" @@ -11240,7 +11254,7 @@ dependencies = [ "bytes 1.1.0", "libc", "memchr", - "mio 0.8.0", + "mio 0.8.2", "num_cpus", "once_cell", "pin-project-lite 0.2.8", @@ -11274,9 +11288,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" +checksum = "4151fda0cf2798550ad0b34bcfc9b9dcc2a9d2471c895c68f3a8818e54f2389e" dependencies = [ "rustls 0.20.4", "tokio", @@ -11326,9 +11340,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f" +checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f" dependencies = [ "cfg-if 1.0.0", "pin-project-lite 0.2.8", @@ -11338,9 +11352,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8276d9a4a3a558d7b7ad5303ad50b53d58264641b82914b7ada36bd762e7a716" +checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" dependencies = [ "proc-macro2", "quote", @@ -11349,9 +11363,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" +checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c" dependencies = [ "lazy_static", "valuable", @@ -11737,6 +11751,12 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.79" @@ -12179,9 +12199,9 @@ dependencies = [ [[package]] name = "which" -version = "4.2.4" +version = "4.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2" +checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" dependencies = [ "either", "lazy_static", @@ -12394,9 +12414,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50344758e2f40e3a1fcfc8f6f91aa57b5f8ebd8d27919fe6451f15aaaf9ee608" +checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" dependencies = [ "zeroize_derive", ] diff --git a/pallets/pallet-did-lookup/Cargo.toml b/pallets/pallet-did-lookup/Cargo.toml index e3185565cd..09a295278d 100644 --- a/pallets/pallet-did-lookup/Cargo.toml +++ b/pallets/pallet-did-lookup/Cargo.toml @@ -19,6 +19,7 @@ sp-keystore = {branch = "polkadot-v0.9.17", default-features = false, git = "htt [dependencies] codec = {default-features = false, features = ["derive"], package = "parity-scale-codec", version = "2.3.1"} +log = "0.4" scale-info = {version = "1.0", default-features = false, features = ["derive"]} # KILT @@ -49,7 +50,13 @@ std = [ "frame-benchmarking/std", "frame-support/std", "frame-system/std", + "log/std", "scale-info/std", "sp-runtime/std", "sp-std/std", ] + +try-runtime = [ + "frame-support/try-runtime", + "kilt-support/try-runtime", +] diff --git a/pallets/pallet-did-lookup/src/benchmarking.rs b/pallets/pallet-did-lookup/src/benchmarking.rs index 13e4ba10d5..eb0fede07c 100644 --- a/pallets/pallet-did-lookup/src/benchmarking.rs +++ b/pallets/pallet-did-lookup/src/benchmarking.rs @@ -19,7 +19,7 @@ //! Benchmarking -use crate::{AccountIdOf, Call, Config, ConnectedDids, CurrencyOf, Pallet}; +use crate::{AccountIdOf, Call, Config, ConnectedAccounts, ConnectedDids, CurrencyOf, Pallet}; use codec::Encode; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite}; @@ -31,8 +31,12 @@ use sp_runtime::{app_crypto::sr25519, KeyTypeId}; 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() + ::Deposit::get(); + let balance = as Currency>>::minimum_balance() + + ::Deposit::get() + + ::Deposit::get(); as Currency>>::make_free_balance_be(account, balance); } @@ -48,6 +52,7 @@ benchmarks! { associate_account { let caller: T::AccountId = account("caller", 0, SEED); let did: T::DidIdentifier = account("did", 0, SEED); + let previous_did: T::DidIdentifier = account("prev", 0, SEED + 1); let connected_acc = sr25519_generate(KeyTypeId(*b"aura"), None); let connected_acc_id: T::AccountId = connected_acc.into(); let bn: ::BlockNumber = 500_u32.into(); @@ -57,21 +62,34 @@ benchmarks! { .into(); make_free_for_did::(&caller); - let origin = T::EnsureOrigin::generate_origin(caller, did); + + // Add existing connected_acc -> previous_did connection that will be replaced + Pallet::::add_association(caller.clone(), previous_did.clone(), connected_acc_id.clone()).expect("should create previous association"); + assert!(ConnectedAccounts::::get(&previous_did, T::AccountId::from(connected_acc)).is_some()); + let origin = T::EnsureOrigin::generate_origin(caller, did.clone()); }: _(origin, connected_acc_id, bn, sig) verify { assert!(ConnectedDids::::get(T::AccountId::from(connected_acc)).is_some()); + assert!(ConnectedAccounts::::get(&previous_did, T::AccountId::from(connected_acc)).is_none()); + assert!(ConnectedAccounts::::get(did, T::AccountId::from(connected_acc)).is_some()); } associate_sender { let caller: T::AccountId = account("caller", 0, SEED); let did: T::DidIdentifier = account("did", 0, SEED); + let previous_did: T::DidIdentifier = account("prev", 0, SEED + 1); make_free_for_did::(&caller); - let origin = T::EnsureOrigin::generate_origin(caller.clone(), did); + + // Add existing sender -> previous_did connection that will be replaced + Pallet::::add_association(caller.clone(), previous_did.clone(), caller.clone()).expect("should create previous association"); + assert!(ConnectedAccounts::::get(&previous_did, &caller).is_some()); + let origin = T::EnsureOrigin::generate_origin(caller.clone(), did.clone()); }: _(origin) verify { - assert!(ConnectedDids::::get(caller).is_some()); + assert!(ConnectedDids::::get(&caller).is_some()); + assert!(ConnectedAccounts::::get(previous_did, &caller).is_none()); + assert!(ConnectedAccounts::::get(did, caller).is_some()); } remove_sender_association { @@ -79,12 +97,13 @@ benchmarks! { let did: T::DidIdentifier = account("did", 0, SEED); make_free_for_did::(&caller); - Pallet::::add_association(caller.clone(), did, caller.clone()).expect("should create association"); + Pallet::::add_association(caller.clone(), did.clone(), caller.clone()).expect("should create association"); let origin = RawOrigin::Signed(caller.clone()); }: _(origin) verify { - assert!(ConnectedDids::::get(caller).is_none()); + assert!(ConnectedDids::::get(&caller).is_none()); + assert!(ConnectedAccounts::::get(did, caller).is_none()); } remove_account_association { @@ -94,10 +113,12 @@ benchmarks! { Pallet::::add_association(caller.clone(), did.clone(), caller.clone()).expect("should create association"); - let origin = T::EnsureOrigin::generate_origin(caller.clone(), did); - }: _(origin, caller.clone()) + let origin = T::EnsureOrigin::generate_origin(caller.clone(), did.clone()); + let caller_clone = caller.clone(); + }: _(origin, caller_clone) verify { - assert!(ConnectedDids::::get(caller).is_none()); + assert!(ConnectedDids::::get(&caller).is_none()); + assert!(ConnectedAccounts::::get(did, caller).is_none()); } } diff --git a/pallets/pallet-did-lookup/src/default_weights.rs b/pallets/pallet-did-lookup/src/default_weights.rs index dc0b878cc8..ec036e02ab 100644 --- a/pallets/pallet-did-lookup/src/default_weights.rs +++ b/pallets/pallet-did-lookup/src/default_weights.rs @@ -19,8 +19,8 @@ //! Autogenerated weights for pallet_did_lookup //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-11-19, STEPS: {{cmd.steps}}\, REPEAT: {{cmd.repeat}}\, LOW RANGE: {{cmd.lowest_range_values}}\, HIGH RANGE: {{cmd.highest_range_values}}\ -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 +//! DATE: 2022-03-24, STEPS: {{cmd.steps}}\, REPEAT: {{cmd.repeat}}\, LOW RANGE: {{cmd.lowest_range_values}}\, HIGH RANGE: {{cmd.highest_range_values}}\ +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: // target/release/kilt-parachain @@ -36,7 +36,6 @@ // --output=pallets/pallet-did-lookup/src/default_weights.rs // --template=.maintain/weight-template.hbs - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -56,52 +55,72 @@ pub trait WeightInfo { /// Weights for pallet_did_lookup using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_account() -> Weight { - (74_292_000_u64) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + (111_846_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } + // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_sender() -> Weight { - (17_673_000_u64) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + (52_637_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_sender_association() -> Weight { - (19_086_000_u64) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + (35_370_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_account_association() -> Weight { - (21_926_000_u64) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + (36_181_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } } // For backwards compatibility and tests impl WeightInfo for () { + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_account() -> Weight { - (74_292_000_u64) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + (111_846_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_sender() -> Weight { - (17_673_000_u64) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + (52_637_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_sender_association() -> Weight { - (19_086_000_u64) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + (35_370_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_account_association() -> Weight { - (21_926_000_u64) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + (36_181_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } } diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 81f81ea341..9877c0d54e 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -26,6 +26,7 @@ mod connection_record; pub mod default_weights; +pub mod migrations; #[cfg(test)] mod tests; @@ -70,7 +71,7 @@ pub mod pallet { /// The connection record type. pub(crate) type ConnectionRecordOf = ConnectionRecord, AccountIdOf, BalanceOf>; - pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); #[pallet::config] pub trait Config: frame_system::Config { @@ -110,6 +111,14 @@ pub mod pallet { #[pallet::getter(fn connected_dids)] pub type ConnectedDids = StorageMap<_, Blake2_128Concat, AccountIdOf, ConnectionRecordOf>; + /// Mapping from (DID + account identifier) -> (). + /// The empty tuple is used as a sentinel value to simply indicate the + /// presence of a given tuple in the map. + #[pallet::storage] + #[pallet::getter(fn connected_accounts)] + pub type ConnectedAccounts = + StorageDoubleMap<_, Blake2_128Concat, DidIdentifierOf, Blake2_128Concat, AccountIdOf, ()>; + #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { @@ -129,7 +138,7 @@ pub mod pallet { /// and the account ID. NotAuthorized, - /// The supplied proof of ownership was outdated and will not + /// The supplied proof of ownership was outdated. OutdatedProof, /// The account has insufficient funds and can't pay the fees or reserve @@ -153,8 +162,8 @@ pub mod pallet { /// /// # /// Weight: O(1) - /// - Reads: ConnectedDids + DID Origin Check - /// - Writes: ConnectedDids + /// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check + /// - Writes: ConnectedDids + ConnectedAccounts /// # #[pallet::weight(::WeightInfo::associate_account())] pub fn associate_account( @@ -196,8 +205,8 @@ pub mod pallet { /// /// # /// Weight: O(1) - /// - Reads: ConnectedDids + DID Origin Check - /// - Writes: ConnectedDids + /// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check + /// - Writes: ConnectedDids + ConnectedAccounts /// # #[pallet::weight(::WeightInfo::associate_sender())] pub fn associate_sender(origin: OriginFor) -> DispatchResult { @@ -222,8 +231,8 @@ pub mod pallet { /// /// # /// Weight: O(1) - /// - Reads: ConnectedDids - /// - Writes: ConnectedDids + /// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check + /// - Writes: ConnectedDids + ConnectedAccounts /// # #[pallet::weight(::WeightInfo::remove_sender_association())] pub fn remove_sender_association(origin: OriginFor) -> DispatchResult { @@ -240,8 +249,8 @@ pub mod pallet { /// /// # /// Weight: O(1) - /// - Reads: ConnectedDids + DID Origin Check - /// - Writes: ConnectedDids + /// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check + /// - Writes: ConnectedDids + ConnectedAccounts /// # #[pallet::weight(::WeightInfo::remove_account_association())] pub fn remove_account_association(origin: OriginFor, account: AccountIdOf) -> DispatchResult { @@ -293,11 +302,13 @@ pub mod pallet { CurrencyOf::::reserve(&record.deposit.owner, record.deposit.amount)?; ConnectedDids::::mutate(&account, |did_entry| { - if let Some(old_did) = did_entry.replace(record) { - Self::deposit_event(Event::::AssociationRemoved(account.clone(), old_did.did)); - kilt_support::free_deposit::, CurrencyOf>(&old_did.deposit); + 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); } }); + ConnectedAccounts::::insert(&did_identifier, &account, ()); Self::deposit_event(Event::AssociationEstablished(account, did_identifier)); Ok(()) @@ -305,6 +316,7 @@ pub mod pallet { pub(crate) fn remove_association(account: AccountIdOf) -> DispatchResult { if let Some(connection) = ConnectedDids::::take(&account) { + ConnectedAccounts::::remove(&connection.did, &account); kilt_support::free_deposit::, CurrencyOf>(&connection.deposit); Self::deposit_event(Event::AssociationRemoved(account, connection.did)); diff --git a/pallets/pallet-did-lookup/src/migrations.rs b/pallets/pallet-did-lookup/src/migrations.rs new file mode 100644 index 0000000000..06715d10c1 --- /dev/null +++ b/pallets/pallet-did-lookup/src/migrations.rs @@ -0,0 +1,90 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2022 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{Config, ConnectedAccounts, ConnectedDids, Pallet}; +use frame_support::{ + dispatch::Weight, + traits::{Get, GetStorageVersion, OnRuntimeUpgrade}, +}; +use sp_std::marker::PhantomData; + +pub struct LookupReverseIndexMigration(PhantomData); + +impl OnRuntimeUpgrade for LookupReverseIndexMigration { + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + assert!(Pallet::::on_chain_storage_version() < Pallet::::current_storage_version()); + assert_eq!(ConnectedAccounts::::iter().count(), 0); + + log::info!( + "👥 DID lookup pallet to {:?} passes PRE migrate checks ✅", + Pallet::::current_storage_version() + ); + + Ok(()) + } + + fn on_runtime_upgrade() -> frame_support::weights::Weight { + // Account for the new storage version written below. + let initial_weight = T::DbWeight::get().writes(1); + + // Origin was disabled, so there cannot be any existing links. But we check just + // to be sure. + let total_weight: Weight = + ConnectedDids::::iter().fold(initial_weight, |total_weight, (account, record)| { + ConnectedAccounts::::insert(record.did, account, ()); + // One read for the `ConnectedDids` entry, one write for the new + // `ConnectedAccounts` entry. + total_weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)) + }); + + Pallet::::current_storage_version().put::>(); + + log::info!( + "👥 completed DID lookup pallet migration to {:?} ✅", + Pallet::::current_storage_version() + ); + + total_weight + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + assert_eq!( + Pallet::::on_chain_storage_version(), + Pallet::::current_storage_version() + ); + + // Verify DID -> Account integrity. + ConnectedDids::::iter().for_each(|(account, record)| { + assert!(ConnectedAccounts::::contains_key(record.did, account)); + }); + // Verify Account -> DID integrity. + ConnectedAccounts::::iter().for_each(|(did, account, _)| { + let entry = ConnectedDids::::get(account).expect("Should find a record for the given account."); + assert_eq!(entry.did, did); + }); + + log::info!( + "👥 DID lookup pallet to {:?} passes POST migrate checks ✅", + Pallet::::current_storage_version() + ); + + Ok(()) + } +} diff --git a/pallets/pallet-did-lookup/src/tests.rs b/pallets/pallet-did-lookup/src/tests.rs index 48acdcd0e7..db8802a70b 100644 --- a/pallets/pallet-did-lookup/src/tests.rs +++ b/pallets/pallet-did-lookup/src/tests.rs @@ -26,7 +26,7 @@ use sp_runtime::{ MultiSignature, MultiSigner, }; -use crate::{mock::*, ConnectedDids, ConnectionRecord, Error}; +use crate::{mock::*, ConnectedAccounts, ConnectedDids, ConnectionRecord, Error}; #[test] fn test_add_association_sender() { @@ -46,6 +46,7 @@ fn test_add_association_sender() { } }) ); + assert!(ConnectedAccounts::::get(DID_00, ACCOUNT_00).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -63,6 +64,8 @@ fn test_add_association_sender() { } }) ); + assert!(ConnectedAccounts::::get(DID_00, ACCOUNT_00).is_none()); + assert!(ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -100,6 +103,7 @@ fn test_add_association_account() { } }) ); + assert!(ConnectedAccounts::::get(DID_00, &account_hash_alice).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -123,6 +127,8 @@ fn test_add_association_account() { } }) ); + assert!(ConnectedAccounts::::get(DID_00, &account_hash_alice).is_none()); + assert!(ConnectedAccounts::::get(DID_01, &account_hash_alice).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -146,6 +152,8 @@ fn test_add_association_account() { } }) ); + assert!(ConnectedAccounts::::get(DID_00, &account_hash_alice).is_none()); + assert!(ConnectedAccounts::::get(DID_01, &account_hash_alice).is_some()); assert_eq!(Balances::reserved_balance(ACCOUNT_00), 0); assert_eq!( Balances::reserved_balance(ACCOUNT_01), @@ -211,6 +219,7 @@ fn test_remove_association_sender() { // remove association assert!(DidLookup::remove_sender_association(Origin::signed(ACCOUNT_00)).is_ok()); assert_eq!(ConnectedDids::::get(ACCOUNT_00), None); + assert!(ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_none()); assert_eq!(Balances::reserved_balance(ACCOUNT_00), 0); }); } @@ -241,6 +250,7 @@ fn test_remove_association_account() { ) .is_ok()); assert_eq!(ConnectedDids::::get(ACCOUNT_00), None); + assert!(ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_none()); assert_eq!(Balances::reserved_balance(ACCOUNT_01), 0); }); } diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index 36fce11822..2b68f78ed1 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -209,6 +209,7 @@ try-runtime = [ "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-collective/try-runtime", + "pallet-did-lookup/try-runtime", "pallet-democracy/try-runtime", "pallet-indices/try-runtime", "pallet-membership/try-runtime", diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index cb4ea942c6..46a8df87a2 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -28,7 +28,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ construct_runtime, parameter_types, - traits::{EnsureOneOf, InstanceFilter, OnRuntimeUpgrade, PrivilegeCmp}, + traits::{EnsureOneOf, InstanceFilter, PrivilegeCmp}, weights::{constants::RocksDbWeight, Weight}, }; use frame_system::EnsureRoot; @@ -927,6 +927,7 @@ impl did::DeriveDidCallAuthorizationVerificationKeyRelationship for Call { Call::Did(did::Call::create { .. }) => Err(did::RelationshipDeriveError::NotCallableByDid), Call::Did { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), Call::Web3Names { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), + Call::DidLookup { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), Call::Utility(pallet_utility::Call::batch { calls }) => single_key_relationship(&calls[..]), Call::Utility(pallet_utility::Call::batch_all { calls }) => single_key_relationship(&calls[..]), #[cfg(not(feature = "runtime-benchmarks"))] @@ -976,40 +977,9 @@ pub type Executive = frame_executive::Executive< // Executes pallet hooks in reverse order of definition in construct_runtime // If we want to switch to AllPalletsWithSystem, we need to reorder the staking pallets AllPalletsReversedWithSystemFirst, - ( - SchedulerMigrationV3, - delegation::migrations::v3::DelegationMigrationV3, - did::migrations::v4::DidMigrationV4, - parachain_staking::migrations::v7::ParachainStakingMigrationV7, - ), + pallet_did_lookup::migrations::LookupReverseIndexMigration, >; -// Migration for scheduler pallet to move from a plain Call to a CallOrHash. -pub struct SchedulerMigrationV3; - -impl OnRuntimeUpgrade for SchedulerMigrationV3 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - Scheduler::migrate_v1_to_v3() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - Scheduler::pre_migrate_to_v3() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::dispatch::GetStorageVersion; - - Scheduler::post_migrate_to_v3()?; - log::info!( - "Scheduler migrated to version {:?}", - Scheduler::current_storage_version() - ); - Ok(()) - } -} - impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { diff --git a/runtimes/peregrine/src/tests.rs b/runtimes/peregrine/src/tests.rs index 3a6fe68b8f..d9e3b1b699 100644 --- a/runtimes/peregrine/src/tests.rs +++ b/runtimes/peregrine/src/tests.rs @@ -27,6 +27,9 @@ use runtime_common::constants::{ web3_names::MAX_NAME_BYTE_LENGTH, MAX_INDICES_BYTE_LENGTH, }; +#[cfg(test)] +use runtime_common::{AccountId, BlockNumber}; + use super::{Call, Runtime}; #[test] @@ -121,6 +124,43 @@ fn test_derive_did_verification_relation_ctype() { ); } +#[test] +fn test_derive_did_key_web3name() { + assert_eq!( + Call::Web3Names(pallet_web3_names::Call::claim { + name: b"test-name".to_vec().try_into().unwrap() + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); + + assert_eq!( + Call::Web3Names(pallet_web3_names::Call::release_by_owner {}).derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); +} + +#[test] +fn test_derive_did_key_lookup() { + assert_eq!( + Call::DidLookup(pallet_did_lookup::Call::associate_account { + account: AccountId::new([1u8; 32]), + expiration: BlockNumber::default(), + proof: sp_runtime::MultiSignature::from(sp_core::ed25519::Signature([0; 64])), + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); + + assert_eq!( + Call::DidLookup(pallet_did_lookup::Call::remove_account_association { + account: AccountId::new([1u8; 32]), + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); +} + #[test] fn test_derive_did_verification_relation_fail() { let c1 = Call::Ctype(ctype::Call::add { diff --git a/runtimes/peregrine/src/weights/pallet_did-lookup.rs b/runtimes/peregrine/src/weights/pallet_did-lookup.rs new file mode 100644 index 0000000000..3071edb8c8 --- /dev/null +++ b/runtimes/peregrine/src/weights/pallet_did-lookup.rs @@ -0,0 +1,82 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2022 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for pallet_did_lookup +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/kilt-parachain +// benchmark +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet-did-lookup +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./runtimes/peregrine/src/weights/pallet_did-lookup.rs +// --template=.maintain/runtime-weight-template.hbs + +#![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; + +/// Weight functions for `pallet_did_lookup`. +pub struct WeightInfo(PhantomData); +impl pallet_did_lookup::WeightInfo for WeightInfo { + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) + fn associate_account() -> Weight { + (114_124_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) + fn associate_sender() -> Weight { + (55_985_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn remove_sender_association() -> Weight { + (36_223_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn remove_account_association() -> Weight { + (39_356_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } +} diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml index bcd9c3a12a..67047c38da 100644 --- a/runtimes/spiritnet/Cargo.toml +++ b/runtimes/spiritnet/Cargo.toml @@ -210,6 +210,7 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-collective/try-runtime", "pallet-democracy/try-runtime", + "pallet-did-lookup/try-runtime", "pallet-indices/try-runtime", "pallet-membership/try-runtime", "pallet-preimage/try-runtime", diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 6e6808d675..80ccf938fa 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -28,7 +28,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ construct_runtime, parameter_types, - traits::{Contains, EnsureOneOf, InstanceFilter, OnRuntimeUpgrade, PrivilegeCmp}, + traits::{Contains, EnsureOneOf, InstanceFilter, PrivilegeCmp}, weights::{constants::RocksDbWeight, Weight}, }; use frame_system::EnsureRoot; @@ -931,6 +931,7 @@ impl did::DeriveDidCallAuthorizationVerificationKeyRelationship for Call { Call::Did(did::Call::create { .. }) => Err(did::RelationshipDeriveError::NotCallableByDid), Call::Did { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), Call::Web3Names { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), + Call::DidLookup { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), Call::Utility(pallet_utility::Call::batch { calls }) => single_key_relationship(&calls[..]), Call::Utility(pallet_utility::Call::batch_all { calls }) => single_key_relationship(&calls[..]), #[cfg(not(feature = "runtime-benchmarks"))] @@ -980,40 +981,9 @@ pub type Executive = frame_executive::Executive< // Executes pallet hooks in reverse order of definition in construct_runtime // If we want to switch to AllPalletsWithSystem, we need to reorder the staking pallets AllPalletsReversedWithSystemFirst, - ( - SchedulerMigrationV3, - delegation::migrations::v3::DelegationMigrationV3, - did::migrations::v4::DidMigrationV4, - parachain_staking::migrations::v7::ParachainStakingMigrationV7, - ), + pallet_did_lookup::migrations::LookupReverseIndexMigration, >; -// Migration for scheduler pallet to move from a plain Call to a CallOrHash. -pub struct SchedulerMigrationV3; - -impl OnRuntimeUpgrade for SchedulerMigrationV3 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - Scheduler::migrate_v1_to_v3() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - Scheduler::pre_migrate_to_v3() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::dispatch::GetStorageVersion; - - Scheduler::post_migrate_to_v3()?; - log::info!( - "Scheduler migrated to version {:?}", - Scheduler::current_storage_version() - ); - Ok(()) - } -} - impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { diff --git a/runtimes/spiritnet/src/tests.rs b/runtimes/spiritnet/src/tests.rs index 02a2e92fd9..d056ed6980 100644 --- a/runtimes/spiritnet/src/tests.rs +++ b/runtimes/spiritnet/src/tests.rs @@ -27,6 +27,9 @@ use runtime_common::constants::{ web3_names::MAX_NAME_BYTE_LENGTH, MAX_INDICES_BYTE_LENGTH, }; +#[cfg(test)] +use runtime_common::{AccountId, BlockNumber}; + use super::{Call, Runtime}; #[test] @@ -121,6 +124,43 @@ fn test_derive_did_verification_relation_ctype() { ); } +#[test] +fn test_derive_did_key_web3name() { + assert_eq!( + Call::Web3Names(pallet_web3_names::Call::claim { + name: b"test-name".to_vec().try_into().unwrap() + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); + + assert_eq!( + Call::Web3Names(pallet_web3_names::Call::release_by_owner {}).derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); +} + +#[test] +fn test_derive_did_key_lookup() { + assert_eq!( + Call::DidLookup(pallet_did_lookup::Call::associate_account { + account: AccountId::new([1u8; 32]), + expiration: BlockNumber::default(), + proof: sp_runtime::MultiSignature::from(sp_core::ed25519::Signature([0; 64])), + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); + + assert_eq!( + Call::DidLookup(pallet_did_lookup::Call::remove_account_association { + account: AccountId::new([1u8; 32]), + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); +} + #[test] fn test_derive_did_verification_relation_fail() { let c1 = Call::Ctype(ctype::Call::add { diff --git a/runtimes/spiritnet/src/weights/pallet_did-lookup.rs b/runtimes/spiritnet/src/weights/pallet_did-lookup.rs new file mode 100644 index 0000000000..9f3dad3192 --- /dev/null +++ b/runtimes/spiritnet/src/weights/pallet_did-lookup.rs @@ -0,0 +1,82 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2022 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for pallet_did_lookup +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-24, 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 +// --chain=spiritnet-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet-did-lookup +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./runtimes/spiritnet/src/weights/pallet_did-lookup.rs +// --template=.maintain/runtime-weight-template.hbs + +#![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; + +/// Weight functions for `pallet_did_lookup`. +pub struct WeightInfo(PhantomData); +impl pallet_did_lookup::WeightInfo for WeightInfo { + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) + fn associate_account() -> Weight { + (111_855_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) + fn associate_sender() -> Weight { + (53_834_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn remove_sender_association() -> Weight { + (35_194_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn remove_account_association() -> Weight { + (38_608_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } +} diff --git a/runtimes/standalone/Cargo.toml b/runtimes/standalone/Cargo.toml index 9e3895ce73..33988492b9 100644 --- a/runtimes/standalone/Cargo.toml +++ b/runtimes/standalone/Cargo.toml @@ -152,6 +152,7 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", + "pallet-did-lookup/try-runtime", "pallet-grandpa/try-runtime", "pallet-indices/try-runtime", "pallet-proxy/try-runtime", diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs index f7f94bf3d5..2e05c60cdb 100644 --- a/runtimes/standalone/src/lib.rs +++ b/runtimes/standalone/src/lib.rs @@ -669,6 +669,7 @@ impl did::DeriveDidCallAuthorizationVerificationKeyRelationship for Call { Call::Did(did::Call::create { .. }) => Err(did::RelationshipDeriveError::NotCallableByDid), Call::Did { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), Call::Web3Names { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), + Call::DidLookup { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), Call::Utility(pallet_utility::Call::batch { calls }) => single_key_relationship(&calls[..]), Call::Utility(pallet_utility::Call::batch_all { calls }) => single_key_relationship(&calls[..]), #[cfg(not(feature = "runtime-benchmarks"))]