From cb10d13483bddb185db638bc6f1ac1f424bb2b54 Mon Sep 17 00:00:00 2001 From: gpestana Date: Wed, 14 Dec 2022 10:34:08 +0100 Subject: [PATCH 01/22] EPM and staking pallets: Adds new crate for integration tests a --- .../test-election-provider/Cargo.lock | 3506 +++++++++++++++++ .../test-election-provider/Cargo.toml | 39 + .../test-election-provider/src/lib.rs | 25 + .../test-election-provider/src/mock.rs | 324 ++ 4 files changed, 3894 insertions(+) create mode 100644 frame/election-provider-multi-phase/test-election-provider/Cargo.lock create mode 100644 frame/election-provider-multi-phase/test-election-provider/Cargo.toml create mode 100644 frame/election-provider-multi-phase/test-election-provider/src/lib.rs create mode 100644 frame/election-provider-multi-phase/test-election-provider/src/mock.rs diff --git a/frame/election-provider-multi-phase/test-election-provider/Cargo.lock b/frame/election-provider-multi-phase/test-election-provider/Cargo.lock new file mode 100644 index 0000000000000..f55bb48fdc9ac --- /dev/null +++ b/frame/election-provider-multi-phase/test-election-provider/Cargo.lock @@ -0,0 +1,3506 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.8", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" + +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + +[[package]] +name = "array-bytes" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "async-trait" +version = "0.1.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base58" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b12e5fd123190ce1c2e559308a94c9bacad77907d4c6005d9e58fe1a0689e55e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + +[[package]] +name = "cc" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" + +[[package]] +name = "cfg-expr" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +dependencies = [ + "smallvec", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "num-integer", + "num-traits", + "winapi", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "const-oid" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-entity" +version = "0.88.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0f1b2fdc18776956370cf8d9b009ded3f855350c480c1c52142510961f352" +dependencies = [ + "serde", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array 0.14.6", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.6", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.6", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.6", + "subtle", +] + +[[package]] +name = "curve25519-dalek" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" +dependencies = [ + "byteorder", + "digest 0.8.1", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "cxx" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", + "subtle", +] + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "dyn-clonable" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" +dependencies = [ + "dyn-clonable-impl", + "dyn-clone", +] + +[[package]] +name = "dyn-clonable-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dyn-clone" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek 3.2.0", + "hashbrown", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array 0.14.6", + "group", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "environmental" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "frame-benchmarking" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "frame-system", + "linregress", + "log", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "sp-storage", +] + +[[package]] +name = "frame-election-provider-solution-type" +version = "4.0.0-dev" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-election-provider-support" +version = "4.0.0-dev" +dependencies = [ + "frame-election-provider-solution-type", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-npos-elections", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "frame-metadata" +version = "15.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df6bb8542ef006ef0de09a5c4420787d79823c0ed7924225822362fd2bf2ff2d" +dependencies = [ + "cfg-if", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "frame-support" +version = "4.0.0-dev" +dependencies = [ + "bitflags", + "frame-metadata", + "frame-support-procedural", + "impl-trait-for-tuples", + "k256", + "log", + "once_cell", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-core-hashing-proc-macro", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-weights", + "tt-call", +] + +[[package]] +name = "frame-support-procedural" +version = "4.0.0-dev" +dependencies = [ + "Inflector", + "cfg-expr", + "frame-support-procedural-tools", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "4.0.0-dev" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "3.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-system" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-version", + "sp-weights", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-executor" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-macro" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +dependencies = [ + "fallible-iterator", + "stable_deref_trait", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hash-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.6", + "hmac 0.8.1", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown", + "serde", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "io-lifetimes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "keccak" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" + +[[package]] +name = "libm" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] + +[[package]] +name = "linregress" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6c601a85f5ecd1aba625247bca0031585fb1c446461b142878a16f8245ddeb8" +dependencies = [ + "nalgebra", + "statrs", +] + +[[package]] +name = "linux-raw-sys" +version = "0.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matrixmultiply" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +dependencies = [ + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memory-db" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66" +dependencies = [ + "hash-db", + "hashbrown", +] + +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + +[[package]] +name = "merlin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "miniz_oxide" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +dependencies = [ + "adler", +] + +[[package]] +name = "nalgebra" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "462fffe4002f4f2e1f6a9dcf12cc1a6fc0e15989014efc02a941d3e0f5dc2120" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational", + "num-traits", + "rand 0.8.5", + "rand_distr", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec 0.7.2", + "itoa", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "crc32fast", + "hashbrown", + "indexmap", + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "pallet-authorship" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-authorship", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-bags-list" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "pallet-balances" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-election-provider-multi-phase" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-election-provider-support-benchmarking", + "parity-scale-codec", + "rand 0.7.3", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-std", + "static_assertions", + "strum", +] + +[[package]] +name = "pallet-election-provider-support-benchmarking" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-system", + "parity-scale-codec", + "sp-npos-elections", + "sp-runtime", +] + +[[package]] +name = "pallet-election-provider-test" +version = "1.0.0" +dependencies = [ + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-bags-list", + "pallet-balances", + "pallet-election-provider-multi-phase", + "pallet-session", + "pallet-staking", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-session" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-trie", +] + +[[package]] +name = "pallet-staking" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-bags-list", + "pallet-session", + "parity-scale-codec", + "scale-info", + "serde", + "sp-application-crypto", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-timestamp" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "parity-scale-codec" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +dependencies = [ + "arrayvec 0.7.2", + "bitvec", + "byte-slice-cast", + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "parity-wasm" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.42.0", +] + +[[package]] +name = "paste" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1c2c742266c2f1041c914ba65355a83ae8747b05f208319784083583494b4b" + +[[package]] +name = "pbkdf2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +dependencies = [ + "crypto-mac 0.8.0", +] + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primitive-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "scale-info", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.8", +] + +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b15debb4f9d60d767cd8ca9ef7abb2452922f3214671ff052defc7f3502c44" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abfa8511e9e94fd3de6585a3d3cd00e01ed556dc9814829280af0e8dc72a8f36" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac 0.12.1", + "zeroize", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustix" +version = "0.35.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.42.0", +] + +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "scale-info" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "schnorrkel" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "curve25519-dalek 2.1.3", + "getrandom 0.1.16", + "merlin", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2 0.8.2", + "subtle", + "zeroize", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array 0.14.6", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9512ffd81e3a3503ed401f79c33168b9148c75038956039166cd750eaa037c3" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "serde" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core 0.6.4", +] + +[[package]] +name = "simba" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e82063457853d00243beda9952e910b82593e4b07ae9f721b9278a99a0d3d5c" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "sp-api" +version = "4.0.0-dev" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "sp-api-proc-macro", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", + "sp-version", + "thiserror", +] + +[[package]] +name = "sp-api-proc-macro" +version = "4.0.0-dev" +dependencies = [ + "blake2", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-application-crypto" +version = "7.0.0" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-arithmetic" +version = "6.0.0" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-debug-derive", + "sp-std", + "static_assertions", +] + +[[package]] +name = "sp-authorship" +version = "4.0.0-dev" +dependencies = [ + "async-trait", + "parity-scale-codec", + "sp-inherents", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-core" +version = "7.0.0" +dependencies = [ + "array-bytes", + "base58", + "bitflags", + "blake2", + "byteorder", + "dyn-clonable", + "ed25519-zebra", + "futures", + "hash-db", + "hash256-std-hasher", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin", + "num-traits", + "parity-scale-codec", + "parking_lot", + "primitive-types", + "rand 0.7.3", + "regex", + "scale-info", + "schnorrkel", + "secp256k1", + "secrecy", + "serde", + "sp-core-hashing", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "wasmi", + "zeroize", +] + +[[package]] +name = "sp-core-hashing" +version = "5.0.0" +dependencies = [ + "blake2", + "byteorder", + "digest 0.10.6", + "sha2 0.10.6", + "sha3", + "sp-std", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing-proc-macro" +version = "5.0.0" +dependencies = [ + "proc-macro2", + "quote", + "sp-core-hashing", + "syn", +] + +[[package]] +name = "sp-debug-derive" +version = "5.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-externalities" +version = "0.13.0" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-std", + "sp-storage", +] + +[[package]] +name = "sp-inherents" +version = "4.0.0-dev" +dependencies = [ + "async-trait", + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-core", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-io" +version = "7.0.0" +dependencies = [ + "bytes", + "ed25519-dalek", + "futures", + "hash-db", + "libsecp256k1", + "log", + "parity-scale-codec", + "parking_lot", + "secp256k1", + "sp-core", + "sp-externalities", + "sp-keystore", + "sp-runtime-interface", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "sp-wasm-interface", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keystore" +version = "0.13.0" +dependencies = [ + "async-trait", + "futures", + "merlin", + "parity-scale-codec", + "parking_lot", + "schnorrkel", + "sp-core", + "sp-externalities", + "thiserror", +] + +[[package]] +name = "sp-npos-elections" +version = "4.0.0-dev" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-arithmetic", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-panic-handler" +version = "5.0.0" +dependencies = [ + "backtrace", + "lazy_static", + "regex", +] + +[[package]] +name = "sp-runtime" +version = "7.0.0" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "paste", + "rand 0.7.3", + "scale-info", + "serde", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-weights", +] + +[[package]] +name = "sp-runtime-interface" +version = "7.0.0" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec", + "primitive-types", + "sp-externalities", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-storage", + "sp-tracing", + "sp-wasm-interface", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "6.0.0" +dependencies = [ + "Inflector", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-session" +version = "4.0.0-dev" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "sp-staking" +version = "4.0.0-dev" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-state-machine" +version = "0.13.0" +dependencies = [ + "hash-db", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot", + "rand 0.7.3", + "smallvec", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-std", + "sp-trie", + "thiserror", + "tracing", + "trie-root", +] + +[[package]] +name = "sp-std" +version = "5.0.0" + +[[package]] +name = "sp-storage" +version = "7.0.0" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-timestamp" +version = "4.0.0-dev" +dependencies = [ + "async-trait", + "futures-timer", + "log", + "parity-scale-codec", + "sp-api", + "sp-inherents", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-tracing" +version = "6.0.0" +dependencies = [ + "parity-scale-codec", + "sp-std", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sp-trie" +version = "7.0.0" +dependencies = [ + "ahash", + "hash-db", + "hashbrown", + "lazy_static", + "lru", + "memory-db", + "nohash-hasher", + "parity-scale-codec", + "parking_lot", + "scale-info", + "sp-core", + "sp-std", + "thiserror", + "tracing", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-version" +version = "5.0.0" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-core-hashing-proc-macro", + "sp-runtime", + "sp-std", + "sp-version-proc-macro", + "thiserror", +] + +[[package]] +name = "sp-version-proc-macro" +version = "4.0.0-dev" +dependencies = [ + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-wasm-interface" +version = "7.0.0" +dependencies = [ + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std", + "wasmi", + "wasmtime", +] + +[[package]] +name = "sp-weights" +version = "4.0.0" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-core", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ss58-registry" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d92659e7d18d82b803824a9ba5a6022cff101c3491d027c1c1d8d30e749284" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "statrs" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05bdbb8e4e78216a85785a85d3ec3183144f98d0097b9281802c019bb07a6f05" +dependencies = [ + "approx", + "lazy_static", + "nalgebra", + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "substrate-bip39" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +dependencies = [ + "hmac 0.11.0", + "pbkdf2 0.8.0", + "schnorrkel", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "target-lexicon" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tiny-bip39" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +dependencies = [ + "anyhow", + "hmac 0.8.1", + "once_cell", + "pbkdf2 0.4.0", + "rand 0.7.3", + "rustc-hash", + "sha2 0.9.9", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "trie-db" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004e1e8f92535694b4cb1444dc5a8073ecf0815e3357f729638b9f8fc4062908" +dependencies = [ + "hash-db", + "hashbrown", + "log", + "rustc-hex", + "smallvec", +] + +[[package]] +name = "trie-root" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a36c5ca3911ed3c9a5416ee6c679042064b93fc637ded67e25f92e68d783891" +dependencies = [ + "hash-db", +] + +[[package]] +name = "tt-call" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "digest 0.10.6", + "rand 0.8.5", + "static_assertions", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "wasmi" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" +dependencies = [ + "parity-wasm", + "wasmi-validation", + "wasmi_core", +] + +[[package]] +name = "wasmi-validation" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "wasmi_core" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" +dependencies = [ + "downcast-rs", + "libm", + "memory_units", + "num-rational", + "num-traits", +] + +[[package]] +name = "wasmparser" +version = "0.89.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5d3e08b13876f96dd55608d03cd4883a0545884932d5adf11925876c96daef" +dependencies = [ + "indexmap", +] + +[[package]] +name = "wasmtime" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad5af6ba38311282f2a21670d96e78266e8c8e2f38cbcd52c254df6ccbc7731" +dependencies = [ + "anyhow", + "bincode", + "cfg-if", + "indexmap", + "libc", + "log", + "object", + "once_cell", + "paste", + "psm", + "serde", + "target-lexicon", + "wasmparser", + "wasmtime-environ", + "wasmtime-jit", + "wasmtime-runtime", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45de63ddfc8b9223d1adc8f7b2ee5f35d1f6d112833934ad7ea66e4f4339e597" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-environ" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebb881c61f4f627b5d45c54e629724974f8a8890d455bcbe634330cc27309644" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1985c628011fe26adf5e23a5301bdc79b245e0e338f14bb58b39e4e25e4d8681" +dependencies = [ + "addr2line", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli", + "log", + "object", + "rustc-demangle", + "rustix", + "serde", + "target-lexicon", + "thiserror", + "wasmtime-environ", + "wasmtime-runtime", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f671b588486f5ccec8c5a3dba6b4c07eac2e66ab8c60e6f4e53717c77f709731" +dependencies = [ + "once_cell", +] + +[[package]] +name = "wasmtime-runtime" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8f92ad4b61736339c29361da85769ebc200f184361959d1792832e592a1afd" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "indexmap", + "libc", + "log", + "mach", + "memoffset", + "paste", + "rand 0.8.5", + "rustix", + "thiserror", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-jit-debug", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-types" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23d61cb4c46e837b431196dd06abb11731541021916d03476a178b54dc07aeb" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/frame/election-provider-multi-phase/test-election-provider/Cargo.toml b/frame/election-provider-multi-phase/test-election-provider/Cargo.toml new file mode 100644 index 0000000000000..e75d48e797e4e --- /dev/null +++ b/frame/election-provider-multi-phase/test-election-provider/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "pallet-election-provider-test" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "FRAME election provider multi phase pallet tests with staking pallet, bags-list and session pallets" +publish = false + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[workspace] + +[dev-dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +scale-info = { version = "2.0.1", features = ["derive"] } +log = { version = "0.4.17", default-features = false } + +sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } +sp-io = { version = "7.0.0", path = "../../../primitives/io" } +sp-std = { version = "5.0.0", path = "../../../primitives/std" } +sp-staking = { version = "4.0.0-dev", path = "../../../primitives/staking" } +sp-core = { version = "7.0.0", path = "../../../primitives/core" } +sp-npos-elections = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/npos-elections" } + +frame-system = { version = "4.0.0-dev", path = "../../system" } +frame-support = { version = "4.0.0-dev", path = "../../support" } +frame-election-provider-support = { version = "4.0.0-dev", path = "../../election-provider-support" } + +pallet-election-provider-multi-phase = { version = "4.0.0-dev", path = "../../election-provider-multi-phase" } +pallet-staking = { version = "4.0.0-dev", path = "../../staking" } +pallet-bags-list = { version = "4.0.0-dev", path = "../../bags-list" } +pallet-balances = { version = "4.0.0-dev", path = "../../balances" } +pallet-timestamp = { version = "4.0.0-dev", path = "../../timestamp" } +pallet-session = { version = "4.0.0-dev", path = "../../session" } + diff --git a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs new file mode 100644 index 0000000000000..d4bd9aeadb575 --- /dev/null +++ b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs @@ -0,0 +1,25 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#![cfg(test)] + +mod mock; + +#[test] +fn test_one() { + assert!(true); +} diff --git a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs new file mode 100644 index 0000000000000..00a9995279058 --- /dev/null +++ b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs @@ -0,0 +1,324 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use frame_support::{parameter_types, traits}; +use frame_system::EnsureRoot; +use sp_core::{ConstU32, H256}; +use sp_npos_elections::{BalancingConfig, VoteWeight}; +use sp_runtime::{testing, traits::IdentityLookup, transaction_validity, PerU16, Perbill}; +use sp_std::prelude::*; + +use frame_election_provider_support::{onchain, SequentialPhragmen, Weight}; +use pallet_election_provider_multi_phase::{unsigned::MinerConfig, SolutionAccuracyOf}; + +// Duration in number of blocks for each of the EPM phases. +const EPM_PHASE_DURATION: u32 = 10; + +pub(crate) type AccountId = u128; +pub(crate) type AccountIndex = u32; +pub(crate) type BlockNumber = u64; +pub(crate) type Balance = u128; +pub(crate) type VoterIndex = u32; +pub(crate) type TargetIndex = u16; + +impl frame_system::Config for Runtime { + type BaseCallFilter = traits::Everything; + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = AccountIndex; + type BlockNumber = BlockNumber; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = sp_runtime::traits::BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = sp_runtime::testing::Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = traits::ConstU32<16>; +} + +parameter_types! { + pub static ExistentialDeposit: Balance = 1; +} + +impl pallet_balances::Config for Runtime { + type MaxLocks = traits::ConstU32<1024>; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; + type Balance = Balance; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); +} + +impl pallet_timestamp::Config for Runtime { + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = traits::ConstU64<5>; + type WeightInfo = (); +} + +parameter_types! { + pub static Period: BlockNumber = 5; + pub static Offset: BlockNumber = 0; +} + +sp_runtime::impl_opaque_keys! { + pub struct SessionKeys { + pub other: OtherSessionHandler, + } +} + +impl pallet_session::Config for Runtime { + type SessionManager = pallet_session::historical::NoteHistoricalRoot; + type Keys = SessionKeys; + type ShouldEndSession = pallet_session::PeriodicSessions; + type SessionHandler = (OtherSessionHandler,); + type RuntimeEvent = RuntimeEvent; + type ValidatorId = AccountId; + type ValidatorIdOf = pallet_staking::StashOf; + type NextSessionRotation = pallet_session::PeriodicSessions; + type WeightInfo = (); +} +impl pallet_session::historical::Config for Runtime { + type FullIdentification = pallet_staking::Exposure; + type FullIdentificationOf = pallet_staking::ExposureOf; +} + +frame_election_provider_support::generate_solution_type!( + #[compact] + pub struct MockNposSolution::< + VoterIndex = VoterIndex, + TargetIndex = TargetIndex, + Accuracy = PerU16, + MaxVoters = ConstU32::<2_000> + >(16) +); + +parameter_types! { + pub SignedPhase: u32 = EPM_PHASE_DURATION; + pub UnsignedPhase: u32 = EPM_PHASE_DURATION; + pub BetterSignedThreshold: Perbill = Perbill::zero(); + pub BetterUnsignedThreshold: Perbill = Perbill::zero(); + pub OffchainRepeat: u32 = 5; + pub TransactionPriority: transaction_validity::TransactionPriority = 1; + pub MaxWinners: u32 = 100; + pub MaxVotesPerVoter: u32 = 16; + pub MaxNominations: u32 = 16; + + pub static MaxElectingVoters: VoterIndex = 1000; + pub static MaxElectableTargets: TargetIndex = 1000; + pub static MaxActiveValidators: u32 = 1000; + pub static Balancing: Option = Some( BalancingConfig { iterations: 0, tolerance: 0 } ); +} + +impl pallet_election_provider_multi_phase::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = (); + type EstimateCallFee = frame_support::traits::ConstU32<8>; + type SignedPhase = SignedPhase; + type UnsignedPhase = UnsignedPhase; + type BetterSignedThreshold = BetterSignedThreshold; + type BetterUnsignedThreshold = BetterUnsignedThreshold; + type OffchainRepeat = OffchainRepeat; + type MinerTxPriority = TransactionPriority; + type MinerConfig = Self; + type SignedMaxSubmissions = ConstU32<10>; + type SignedRewardBase = (); + type SignedDepositBase = (); + type SignedDepositByte = (); + type SignedMaxRefunds = ConstU32<3>; + type SignedDepositWeight = (); + type SignedMaxWeight = (); + type SlashHandler = (); + type RewardHandler = (); + type DataProvider = Staking; + type Fallback = onchain::OnChainExecution; + type GovernanceFallback = onchain::OnChainExecution; + type Solver = SequentialPhragmen, Balancing>; + type ForceOrigin = EnsureRoot; + type MaxElectableTargets = MaxElectableTargets; + type MaxElectingVoters = MaxElectingVoters; + type MaxWinners = MaxWinners; + type BenchmarkingConfig = ElectionProviderBenchmarkConfig; + type WeightInfo = (); +} + +impl MinerConfig for Runtime { + type AccountId = AccountId; + type Solution = MockNposSolution; + type MaxVotesPerVoter = MaxNominations; + type MaxLength = (); + type MaxWeight = (); + + fn solution_weight(_voters: u32, _targets: u32, _active_voters: u32, _degree: u32) -> Weight { + Weight::zero() + } +} + +const THRESHOLDS: [VoteWeight; 9] = [10, 20, 30, 40, 50, 60, 1_000, 2_000, 10_000]; + +parameter_types! { + pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS; + pub const SessionsPerEra: sp_staking::SessionIndex = 6; + pub const BondingDuration: sp_staking::EraIndex = 24 * 28; + pub const SlashDeferDuration: sp_staking::EraIndex = 24 * 7; // 1/4 the bonding duration. + pub const MaxNominatorRewardedPerValidator: u32 = 256; + pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub HistoryDepth: u32 = 84; +} + +impl pallet_bags_list::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type ScoreProvider = Staking; + type BagThresholds = BagThresholds; + type Score = VoteWeight; +} + +impl pallet_staking::Config for Runtime { + type MaxNominations = MaxNominations; + type Currency = Balances; + type CurrencyBalance = Balance; + type UnixTime = pallet_timestamp::Pallet; + type CurrencyToVote = traits::U128CurrencyToVote; + type RewardRemainder = (); + type RuntimeEvent = RuntimeEvent; + type Slash = (); // burn slashes + type Reward = (); // rewards are minted from the void + type SessionsPerEra = SessionsPerEra; + type BondingDuration = BondingDuration; + type SlashDeferDuration = SlashDeferDuration; + type SlashCancelOrigin = EnsureRoot; // root can cancel slashes + type SessionInterface = Self; + type EraPayout = (); + type NextNewSession = Session; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type OffendingValidatorsThreshold = OffendingValidatorsThreshold; + type ElectionProvider = ElectionProviderMultiPhase; + type GenesisElectionProvider = onchain::OnChainExecution; + type VoterList = BagsList; + type TargetList = pallet_staking::UseValidatorsMap; + type MaxUnlockingChunks = ConstU32<32>; + type HistoryDepth = HistoryDepth; + type OnStakerSlash = (); + type WeightInfo = pallet_staking::weights::SubstrateWeight; + type BenchmarkingConfig = StakingBenchmarkingConfig; +} + +impl frame_system::offchain::SendTransactionTypes for Runtime +where + RuntimeCall: From, +{ + type OverarchingCall = RuntimeCall; + type Extrinsic = Extrinsic; +} + +type Block = frame_system::mocking::MockBlock; +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Extrinsic = testing::TestXt; + +frame_support::construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: frame_system::{Pallet, Call, Event}, + ElectionProviderMultiPhase: pallet_election_provider_multi_phase, + Staking: pallet_staking, + Balances: pallet_balances, + BagsList: pallet_bags_list, + Session: pallet_session, + } +); + +pub struct OnChainSeqPhragmen; + +parameter_types! { + pub VotersBound: u32 = 600; + pub TargetsBound: u32 = 400; +} + +impl onchain::Config for OnChainSeqPhragmen { + type System = Runtime; + type Solver = SequentialPhragmen< + AccountId, + pallet_election_provider_multi_phase::SolutionAccuracyOf, + >; + type DataProvider = Staking; //StakingTemporary; + type WeightInfo = (); + type MaxWinners = MaxWinners; + type VotersBound = VotersBound; + type TargetsBound = TargetsBound; +} + +pub struct StakingBenchmarkingConfig; +impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig { + type MaxNominators = traits::ConstU32<1000>; + type MaxValidators = traits::ConstU32<1000>; +} + +pub struct ElectionProviderBenchmarkConfig; + +impl pallet_election_provider_multi_phase::BenchmarkingConfig for ElectionProviderBenchmarkConfig { + const VOTERS: [u32; 2] = [1000, 2000]; + const TARGETS: [u32; 2] = [500, 1000]; + const ACTIVE_VOTERS: [u32; 2] = [500, 800]; + const DESIRED_TARGETS: [u32; 2] = [200, 400]; + const SNAPSHOT_MAXIMUM_VOTERS: u32 = 1000; + const MINER_MAXIMUM_VOTERS: u32 = 1000; + const MAXIMUM_TARGETS: u32 = 300; +} + +pub struct OtherSessionHandler; +impl traits::OneSessionHandler for OtherSessionHandler { + type Key = testing::UintAuthorityId; + + fn on_genesis_session<'a, I: 'a>(_: I) + where + I: Iterator, + AccountId: 'a, + { + } + + fn on_new_session<'a, I: 'a>(_: bool, _: I, _: I) + where + I: Iterator, + AccountId: 'a, + { + } + + fn on_disabled(_validator_index: u32) {} +} + +impl sp_runtime::BoundToRuntimeAppPublic for OtherSessionHandler { + type Public = testing::UintAuthorityId; +} From 3ec154105d64447d6c4e08e6fab0b11ca991085a Mon Sep 17 00:00:00 2001 From: gpestana Date: Fri, 16 Dec 2022 12:51:14 +0100 Subject: [PATCH 02/22] Adds ExtBuilder and helpers with initial conditions assertions --- .../test-election-provider/Cargo.lock | 1 + .../test-election-provider/Cargo.toml | 1 + .../test-election-provider/src/lib.rs | 32 ++- .../test-election-provider/src/mock.rs | 256 +++++++++++++++--- 4 files changed, 244 insertions(+), 46 deletions(-) diff --git a/frame/election-provider-multi-phase/test-election-provider/Cargo.lock b/frame/election-provider-multi-phase/test-election-provider/Cargo.lock index f55bb48fdc9ac..15d6f29c68e97 100644 --- a/frame/election-provider-multi-phase/test-election-provider/Cargo.lock +++ b/frame/election-provider-multi-phase/test-election-provider/Cargo.lock @@ -1644,6 +1644,7 @@ dependencies = [ "sp-runtime", "sp-staking", "sp-std", + "sp-tracing", ] [[package]] diff --git a/frame/election-provider-multi-phase/test-election-provider/Cargo.toml b/frame/election-provider-multi-phase/test-election-provider/Cargo.toml index e75d48e797e4e..477eae5d57413 100644 --- a/frame/election-provider-multi-phase/test-election-provider/Cargo.toml +++ b/frame/election-provider-multi-phase/test-election-provider/Cargo.toml @@ -25,6 +25,7 @@ sp-std = { version = "5.0.0", path = "../../../primitives/std" } sp-staking = { version = "4.0.0-dev", path = "../../../primitives/staking" } sp-core = { version = "7.0.0", path = "../../../primitives/core" } sp-npos-elections = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/npos-elections" } +sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" } frame-system = { version = "4.0.0-dev", path = "../../system" } frame-support = { version = "4.0.0-dev", path = "../../support" } diff --git a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs index d4bd9aeadb575..1804eb5b79a26 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs @@ -16,10 +16,36 @@ // limitations under the License. #![cfg(test)] - mod mock; +use frame_support::bounded_vec; +use mock::{agents::*, *}; + #[test] -fn test_one() { - assert!(true); +fn test_extbuilder_and_helpers() { + ExtBuilder.phases(5, 5).build_and_execute(|| { + assert_eq!(Balances::free_balance(ACCOUNT_1), 100); + + assert_eq!(System::block_number(), 0); + assert!(ElectionProviderMultiPhase::current_phase().is_off()); + + roll_to_signed(); + assert!(ElectionProviderMultiPhase::current_phase().is_signed()); + assert_eq!(System::block_number(), 5); + + roll_to_unsigned(); + assert!(ElectionProviderMultiPhase::current_phase().is_unsigned()); + assert_eq!(System::block_number(), 10); + }); + + ExtBuilder + .add_voter(ACCOUNT_0, 100, bounded_vec![ACCOUNT_0, ACCOUNT_1]) + .build_and_execute(|| { + // TODO: add staking genesis init in extbuilder + + roll_to_unsigned(); + let _snapshot = ElectionProviderMultiPhase::snapshot(); + + // TODO: check snapshot + }); } diff --git a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs index 00a9995279058..44e0eb1c0e203 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::{parameter_types, traits}; +use frame_support::{bounded_vec, parameter_types, traits, traits::Hooks, BoundedVec}; use frame_system::EnsureRoot; use sp_core::{ConstU32, H256}; use sp_npos_elections::{BalancingConfig, VoteWeight}; @@ -23,17 +23,37 @@ use sp_runtime::{testing, traits::IdentityLookup, transaction_validity, PerU16, use sp_std::prelude::*; use frame_election_provider_support::{onchain, SequentialPhragmen, Weight}; -use pallet_election_provider_multi_phase::{unsigned::MinerConfig, SolutionAccuracyOf}; +use pallet_election_provider_multi_phase::{ + unsigned::{MinerConfig, VoterOf}, + SolutionAccuracyOf, +}; -// Duration in number of blocks for each of the EPM phases. -const EPM_PHASE_DURATION: u32 = 10; +type Block = frame_system::mocking::MockBlock; +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Extrinsic = testing::TestXt; + +frame_support::construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: frame_system, + ElectionProviderMultiPhase: pallet_election_provider_multi_phase, + Staking: pallet_staking, + Balances: pallet_balances, + BagsList: pallet_bags_list, + Session: pallet_session, + } +); pub(crate) type AccountId = u128; pub(crate) type AccountIndex = u32; pub(crate) type BlockNumber = u64; -pub(crate) type Balance = u128; +pub(crate) type Balance = u64; pub(crate) type VoterIndex = u32; pub(crate) type TargetIndex = u16; +pub(crate) type Moment = u64; impl frame_system::Config for Runtime { type BaseCallFilter = traits::Everything; @@ -78,15 +98,27 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); } +parameter_types! { + pub static CapturedMoment: Option = None; +} + +// TOOD(gpestana) needed or can we set Timestamp::OnTimestampSet = ()? +pub struct MockOnTimestampSet; +impl traits::OnTimestampSet for MockOnTimestampSet { + fn on_timestamp_set(moment: Moment) { + CapturedMoment::mutate(|x| *x = Some(moment)); + } +} + impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); + type Moment = Moment; + type OnTimestampSet = MockOnTimestampSet; type MinimumPeriod = traits::ConstU64<5>; type WeightInfo = (); } parameter_types! { - pub static Period: BlockNumber = 5; + pub static Period: BlockNumber = 15; pub static Offset: BlockNumber = 0; } @@ -123,25 +155,24 @@ frame_election_provider_support::generate_solution_type!( ); parameter_types! { - pub SignedPhase: u32 = EPM_PHASE_DURATION; - pub UnsignedPhase: u32 = EPM_PHASE_DURATION; - pub BetterSignedThreshold: Perbill = Perbill::zero(); - pub BetterUnsignedThreshold: Perbill = Perbill::zero(); - pub OffchainRepeat: u32 = 5; - pub TransactionPriority: transaction_validity::TransactionPriority = 1; - pub MaxWinners: u32 = 100; - pub MaxVotesPerVoter: u32 = 16; - pub MaxNominations: u32 = 16; - + pub static SignedPhase: BlockNumber = 10; + pub static UnsignedPhase: BlockNumber = 5; pub static MaxElectingVoters: VoterIndex = 1000; pub static MaxElectableTargets: TargetIndex = 1000; pub static MaxActiveValidators: u32 = 1000; pub static Balancing: Option = Some( BalancingConfig { iterations: 0, tolerance: 0 } ); + pub static BetterSignedThreshold: Perbill = Perbill::zero(); + pub static BetterUnsignedThreshold: Perbill = Perbill::zero(); + pub static OffchainRepeat: u32 = 5; + pub static TransactionPriority: transaction_validity::TransactionPriority = 1; + pub static MaxWinners: u32 = 100; + pub static MaxVotesPerVoter: u32 = 16; + pub static MaxNominations: u32 = 16; } impl pallet_election_provider_multi_phase::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Currency = (); + type Currency = Balances; type EstimateCallFee = frame_support::traits::ConstU32<8>; type SignedPhase = SignedPhase; type UnsignedPhase = UnsignedPhase; @@ -187,9 +218,9 @@ const THRESHOLDS: [VoteWeight; 9] = [10, 20, 30, 40, 50, 60, 1_000, 2_000, 10_00 parameter_types! { pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS; - pub const SessionsPerEra: sp_staking::SessionIndex = 6; - pub const BondingDuration: sp_staking::EraIndex = 24 * 28; - pub const SlashDeferDuration: sp_staking::EraIndex = 24 * 7; // 1/4 the bonding duration. + pub const SessionsPerEra: sp_staking::SessionIndex = 1; + pub const BondingDuration: sp_staking::EraIndex = 28; + pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. pub const MaxNominatorRewardedPerValidator: u32 = 256; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); pub HistoryDepth: u32 = 84; @@ -208,7 +239,7 @@ impl pallet_staking::Config for Runtime { type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = pallet_timestamp::Pallet; - type CurrencyToVote = traits::U128CurrencyToVote; + type CurrencyToVote = traits::SaturatingCurrencyToVote; type RewardRemainder = (); type RuntimeEvent = RuntimeEvent; type Slash = (); // burn slashes @@ -241,25 +272,6 @@ where type Extrinsic = Extrinsic; } -type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Extrinsic = testing::TestXt; - -frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system::{Pallet, Call, Event}, - ElectionProviderMultiPhase: pallet_election_provider_multi_phase, - Staking: pallet_staking, - Balances: pallet_balances, - BagsList: pallet_bags_list, - Session: pallet_session, - } -); - pub struct OnChainSeqPhragmen; parameter_types! { @@ -273,7 +285,7 @@ impl onchain::Config for OnChainSeqPhragmen { AccountId, pallet_election_provider_multi_phase::SolutionAccuracyOf, >; - type DataProvider = Staking; //StakingTemporary; + type DataProvider = Staking; type WeightInfo = (); type MaxWinners = MaxWinners; type VotersBound = VotersBound; @@ -322,3 +334,161 @@ impl traits::OneSessionHandler for OtherSessionHandler { impl sp_runtime::BoundToRuntimeAppPublic for OtherSessionHandler { type Public = testing::UintAuthorityId; } + +#[derive(Default)] +pub struct ExtBuilder; + +pub mod agents { + use super::AccountId; + + pub const ACCOUNT_0: AccountId = 0; + pub const ACCOUNT_1: AccountId = 1; + pub const ACCOUNT_2: AccountId = 2; + pub const ACCOUNT_3: AccountId = 3; + pub const ACCOUNT_4: AccountId = 4; + pub const ACCOUNT_5: AccountId = 5; + pub const ACCOUNT_6: AccountId = 6; + pub const ACCOUNT_7: AccountId = 7; + pub const ACCOUNT_8: AccountId = 8; + pub const ACCOUNT_9: AccountId = 9; + pub const ACCOUNT_10: AccountId = 10; +} + +use agents::*; + +parameter_types! { + pub static Targets: Vec = vec![ACCOUNT_0, ACCOUNT_1, ACCOUNT_2, ACCOUNT_3]; + pub static Voters: Vec> = vec![ + (ACCOUNT_0, 10, bounded_vec![ACCOUNT_9, ACCOUNT_10]), + (ACCOUNT_1, 10, bounded_vec![ACCOUNT_0, ACCOUNT_2]), + (ACCOUNT_2, 10, bounded_vec![ACCOUNT_0]), + (ACCOUNT_3, 10, bounded_vec![ACCOUNT_7, ACCOUNT_8, ACCOUNT_9, ACCOUNT_10]), + // self votes. + (ACCOUNT_10, 10, bounded_vec![ACCOUNT_10]), + (ACCOUNT_9, 20, bounded_vec![ACCOUNT_9]), + (ACCOUNT_8, 30, bounded_vec![ACCOUNT_8]), + (ACCOUNT_7, 40, bounded_vec![ACCOUNT_7]), + ]; +} + +impl ExtBuilder { + pub fn build(self) -> sp_io::TestExternalities { + sp_tracing::try_init_simple(); + let mut storage = + frame_system::GenesisConfig::default().build_storage::().unwrap(); + + let _ = pallet_balances::GenesisConfig:: { + balances: vec![ + (ACCOUNT_0, 100), + (ACCOUNT_1, 100), + (ACCOUNT_2, 100), + (ACCOUNT_3, 100), + (ACCOUNT_4, 100), + (ACCOUNT_5, 100), + (ACCOUNT_6, 100), + (ACCOUNT_7, 100), + (ACCOUNT_8, 100), + (ACCOUNT_9, 100), + (ACCOUNT_10, 100), + ], + } + .assimilate_storage(&mut storage); + + sp_io::TestExternalities::from(storage) + } + + pub fn phases(self, signed: BlockNumber, unsigned: BlockNumber) -> Self { + ::set(signed); + ::set(unsigned); + self + } + + pub fn add_voter( + self, + who: AccountId, + stake: Balance, + targets: BoundedVec, + ) -> Self { + VOTERS.with(|v| v.borrow_mut().push((who, stake, targets))); + self + } + + pub fn build_and_execute(self, test: impl FnOnce() -> ()) { + self.build().execute_with(test) + } +} + +// Fast forward `n` blocks. +pub fn roll_to(n: BlockNumber) { + let now = System::block_number(); + for i in now + 1..=n { + System::set_block_number(i); + ElectionProviderMultiPhase::on_initialize(i); + Staking::on_initialize(i); + } +} + +// Fast forward until EPM signed phase. +pub fn roll_to_signed() { + while !matches!( + ElectionProviderMultiPhase::current_phase(), + pallet_election_provider_multi_phase::Phase::Signed + ) { + roll_to(System::block_number() + 1); + } +} + +// Fast forward until EPM unsigned phase. +pub fn roll_to_unsigned() { + while !matches!( + ElectionProviderMultiPhase::current_phase(), + pallet_election_provider_multi_phase::Phase::Unsigned(_) + ) { + roll_to(System::block_number() + 1); + } +} + +parameter_types! { + static EPMEventsIndex: usize = 0; + static SessionEventsIndex: usize = 0; + static StakingEventsIndex: usize = 0; +} + +// TODO(gpestana): refactor to events_sinve_last_call() -> Vec<_> +pub fn epm_events_since_last_call() -> Vec> { + let all: Vec<_> = System::events() + .into_iter() + .filter_map(|r| { + if let RuntimeEvent::ElectionProviderMultiPhase(inner) = r.event { + Some(inner) + } else { + None + } + }) + .collect(); + let seen = EPMEventsIndex::get(); + EPMEventsIndex::set(all.len()); + all.into_iter().skip(seen).collect() +} + +// TODO(gpestana): refactor to events_sinve_last_call() -> Vec<_> +pub fn session_events_since_last_call() -> Vec { + let all: Vec<_> = System::events() + .into_iter() + .filter_map(|r| if let RuntimeEvent::Session(inner) = r.event { Some(inner) } else { None }) + .collect(); + let seen = SessionEventsIndex::get(); + SessionEventsIndex::set(all.len()); + all.into_iter().skip(seen).collect() +} + +// TODO(gpestana): refactor to events_sinve_last_call() -> Vec<_> +pub fn staking_events_since_last_call() -> Vec> { + let all: Vec<_> = System::events() + .into_iter() + .filter_map(|r| if let RuntimeEvent::Staking(inner) = r.event { Some(inner) } else { None }) + .collect(); + let seen = StakingEventsIndex::get(); + StakingEventsIndex::set(all.len()); + all.into_iter().skip(seen).collect() +} From b818b2946c25ce1b9171c354fba72f53b2830283 Mon Sep 17 00:00:00 2001 From: gpestana Date: Sun, 1 Jan 2023 18:21:32 +0100 Subject: [PATCH 03/22] removes account helpers; adds staking, session, etc genesis --- .../test-election-provider/src/lib.rs | 70 ++-- .../test-election-provider/src/mock.rs | 314 +++++++++++++----- 2 files changed, 276 insertions(+), 108 deletions(-) diff --git a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs index 1804eb5b79a26..b46e902ed0f97 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs @@ -18,34 +18,54 @@ #![cfg(test)] mod mock; -use frame_support::bounded_vec; -use mock::{agents::*, *}; +pub(crate) const LOG_TARGET: &str = "tests::epm"; -#[test] -fn test_extbuilder_and_helpers() { - ExtBuilder.phases(5, 5).build_and_execute(|| { - assert_eq!(Balances::free_balance(ACCOUNT_1), 100); - - assert_eq!(System::block_number(), 0); - assert!(ElectionProviderMultiPhase::current_phase().is_off()); - - roll_to_signed(); - assert!(ElectionProviderMultiPhase::current_phase().is_signed()); - assert_eq!(System::block_number(), 5); +use mock::*; +use sp_core::Get; - roll_to_unsigned(); - assert!(ElectionProviderMultiPhase::current_phase().is_unsigned()); - assert_eq!(System::block_number(), 10); - }); +// syntactic sugar for logging. +#[macro_export] +macro_rules! log { + ($level:tt, $patter:expr $(, $values:expr)* $(,)?) => { + log::$level!( + target: crate::LOG_TARGET, + concat!("🛠️ ", $patter) $(, $values)* + ) + }; +} - ExtBuilder - .add_voter(ACCOUNT_0, 100, bounded_vec![ACCOUNT_0, ACCOUNT_1]) - .build_and_execute(|| { - // TODO: add staking genesis init in extbuilder +fn log_current_time() { + log!( + trace, + "block: {:?}, session: {:?}, era: {:?}, EPM phase: {:?} ts: {:?}", + System::block_number(), + Session::current_index(), + Staking::current_era(), + ElectionProviderMultiPhase::current_phase(), + Timestamp::now() + ); +} - roll_to_unsigned(); - let _snapshot = ElectionProviderMultiPhase::snapshot(); +#[test] +fn block_session_and_era_advances_helpers() { + ExtBuilder::default().initialize_first_session(true).build_and_execute(|| { + let advance_by = 6; + for _ in 1..=advance_by { + log_current_time(); + advance_session(); + } - // TODO: check snapshot - }); + // each session has `Period` blocks. + assert_eq!(System::block_number(), advance_by * Period::get()); + // each era has `SessionsPerEra` sessions. + assert_eq!( + Staking::current_era().unwrap(), + Session::current_index() / >::get() + ); + }); } + +#[test] +/// Replicates the [Kusama incident](https://hackmd.io/Dt1L-JMtRc2y5FiOQik88A) of 8th Dec 2022. +/// +fn enters_emergency_phase_after_forcing_before_elect() {} diff --git a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs index 44e0eb1c0e203..59e61af540987 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs @@ -15,18 +15,30 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::{bounded_vec, parameter_types, traits, traits::Hooks, BoundedVec}; +#![allow(dead_code)] // TODO(gpestana): remove when ready + +use frame_support::{ + parameter_types, traits, + traits::{GenesisBuild, Hooks}, +}; use frame_system::EnsureRoot; -use sp_core::{ConstU32, H256}; +use sp_core::{ConstU32, Get, H256}; use sp_npos_elections::{BalancingConfig, VoteWeight}; -use sp_runtime::{testing, traits::IdentityLookup, transaction_validity, PerU16, Perbill}; +use sp_runtime::{ + testing, + traits::{IdentityLookup, Zero}, + transaction_validity, PerU16, Perbill, +}; +use sp_staking::{EraIndex, SessionIndex}; use sp_std::prelude::*; +use std::collections::BTreeMap; use frame_election_provider_support::{onchain, SequentialPhragmen, Weight}; -use pallet_election_provider_multi_phase::{ - unsigned::{MinerConfig, VoterOf}, - SolutionAccuracyOf, -}; +use pallet_election_provider_multi_phase::{unsigned::MinerConfig, SolutionAccuracyOf}; +use pallet_staking::StakerStatus; + +pub const INIT_TIMESTAMP: u64 = 30_000; +pub const BLOCK_TIME: u64 = 1000; type Block = frame_system::mocking::MockBlock; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -44,6 +56,8 @@ frame_support::construct_runtime!( Balances: pallet_balances, BagsList: pallet_bags_list, Session: pallet_session, + Historical: pallet_session::historical, + Timestamp: pallet_timestamp, } ); @@ -102,17 +116,9 @@ parameter_types! { pub static CapturedMoment: Option = None; } -// TOOD(gpestana) needed or can we set Timestamp::OnTimestampSet = ()? -pub struct MockOnTimestampSet; -impl traits::OnTimestampSet for MockOnTimestampSet { - fn on_timestamp_set(moment: Moment) { - CapturedMoment::mutate(|x| *x = Some(moment)); - } -} - impl pallet_timestamp::Config for Runtime { type Moment = Moment; - type OnTimestampSet = MockOnTimestampSet; + type OnTimestampSet = (); type MinimumPeriod = traits::ConstU64<5>; type WeightInfo = (); } @@ -218,7 +224,7 @@ const THRESHOLDS: [VoteWeight; 9] = [10, 20, 30, 40, 50, 60, 1_000, 2_000, 10_00 parameter_types! { pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS; - pub const SessionsPerEra: sp_staking::SessionIndex = 1; + pub const SessionsPerEra: sp_staking::SessionIndex = 2; pub const BondingDuration: sp_staking::EraIndex = 28; pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. pub const MaxNominatorRewardedPerValidator: u32 = 256; @@ -238,7 +244,7 @@ impl pallet_staking::Config for Runtime { type MaxNominations = MaxNominations; type Currency = Balances; type CurrencyBalance = Balance; - type UnixTime = pallet_timestamp::Pallet; + type UnixTime = Timestamp; type CurrencyToVote = traits::SaturatingCurrencyToVote; type RewardRemainder = (); type RuntimeEvent = RuntimeEvent; @@ -335,41 +341,41 @@ impl sp_runtime::BoundToRuntimeAppPublic for OtherSessionHandler { type Public = testing::UintAuthorityId; } -#[derive(Default)] -pub struct ExtBuilder; - -pub mod agents { - use super::AccountId; - - pub const ACCOUNT_0: AccountId = 0; - pub const ACCOUNT_1: AccountId = 1; - pub const ACCOUNT_2: AccountId = 2; - pub const ACCOUNT_3: AccountId = 3; - pub const ACCOUNT_4: AccountId = 4; - pub const ACCOUNT_5: AccountId = 5; - pub const ACCOUNT_6: AccountId = 6; - pub const ACCOUNT_7: AccountId = 7; - pub const ACCOUNT_8: AccountId = 8; - pub const ACCOUNT_9: AccountId = 9; - pub const ACCOUNT_10: AccountId = 10; +pub struct ExtBuilder { + nominate: bool, + validator_count: u32, + minimum_validator_count: u32, + invulnerables: Vec, + has_stakers: bool, + initialize_first_session: bool, + pub min_nominator_bond: Balance, + min_validator_bond: Balance, + balance_factor: Balance, + status: BTreeMap>, + stakes: BTreeMap, + stakers: Vec<(AccountId, AccountId, Balance, StakerStatus)>, +} + +impl Default for ExtBuilder { + fn default() -> Self { + Self { + nominate: true, + validator_count: 2, + minimum_validator_count: 0, + balance_factor: 1, + invulnerables: vec![], + has_stakers: true, + initialize_first_session: true, + min_nominator_bond: ExistentialDeposit::get(), + min_validator_bond: ExistentialDeposit::get(), + status: Default::default(), + stakes: Default::default(), + stakers: Default::default(), + } + } } -use agents::*; - -parameter_types! { - pub static Targets: Vec = vec![ACCOUNT_0, ACCOUNT_1, ACCOUNT_2, ACCOUNT_3]; - pub static Voters: Vec> = vec![ - (ACCOUNT_0, 10, bounded_vec![ACCOUNT_9, ACCOUNT_10]), - (ACCOUNT_1, 10, bounded_vec![ACCOUNT_0, ACCOUNT_2]), - (ACCOUNT_2, 10, bounded_vec![ACCOUNT_0]), - (ACCOUNT_3, 10, bounded_vec![ACCOUNT_7, ACCOUNT_8, ACCOUNT_9, ACCOUNT_10]), - // self votes. - (ACCOUNT_10, 10, bounded_vec![ACCOUNT_10]), - (ACCOUNT_9, 20, bounded_vec![ACCOUNT_9]), - (ACCOUNT_8, 30, bounded_vec![ACCOUNT_8]), - (ACCOUNT_7, 40, bounded_vec![ACCOUNT_7]), - ]; -} +parameter_types! {} impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { @@ -379,55 +385,197 @@ impl ExtBuilder { let _ = pallet_balances::GenesisConfig:: { balances: vec![ - (ACCOUNT_0, 100), - (ACCOUNT_1, 100), - (ACCOUNT_2, 100), - (ACCOUNT_3, 100), - (ACCOUNT_4, 100), - (ACCOUNT_5, 100), - (ACCOUNT_6, 100), - (ACCOUNT_7, 100), - (ACCOUNT_8, 100), - (ACCOUNT_9, 100), - (ACCOUNT_10, 100), + (1, 10 * self.balance_factor), + (2, 20 * self.balance_factor), + (3, 300 * self.balance_factor), + (4, 400 * self.balance_factor), + // controllers + (10, self.balance_factor), + (20, self.balance_factor), + (30, self.balance_factor), + (40, self.balance_factor), + (50, self.balance_factor), + // stashes + (11, self.balance_factor * 1000), + (21, self.balance_factor * 2000), + (31, self.balance_factor * 2000), + (41, self.balance_factor * 2000), + (51, self.balance_factor * 2000), + // optional nominator + (100, self.balance_factor * 2000), + (101, self.balance_factor * 2000), + // aux accounts + (60, self.balance_factor), + (61, self.balance_factor * 2000), + (70, self.balance_factor), + (71, self.balance_factor * 2000), + (80, self.balance_factor), + (81, self.balance_factor * 2000), + // This allows us to have a total_payout different from 0. + (999, 1_000_000_000_000), ], } .assimilate_storage(&mut storage); - sp_io::TestExternalities::from(storage) - } + let mut stakers = vec![]; + if self.has_stakers { + stakers = vec![ + // (stash, ctrl, stake, status) + // these two will be elected in the default test where we elect 2. + (11, 10, self.balance_factor * 1000, StakerStatus::::Validator), + (21, 20, self.balance_factor * 1000, StakerStatus::::Validator), + // a loser validator + (31, 30, self.balance_factor * 500, StakerStatus::::Validator), + // an idle validator + (41, 40, self.balance_factor * 1000, StakerStatus::::Idle), + ]; + // optionally add a nominator + if self.nominate { + stakers.push(( + 101, + 100, + self.balance_factor * 500, + StakerStatus::::Nominator(vec![11, 21]), + )) + } + // replace any of the status if needed. + self.status.into_iter().for_each(|(stash, status)| { + let (_, _, _, ref mut prev_status) = stakers + .iter_mut() + .find(|s| s.0 == stash) + .expect("set_status staker should exist; qed"); + *prev_status = status; + }); + // replaced any of the stakes if needed. + self.stakes.into_iter().for_each(|(stash, stake)| { + let (_, _, ref mut prev_stake, _) = stakers + .iter_mut() + .find(|s| s.0 == stash) + .expect("set_stake staker should exits; qed."); + *prev_stake = stake; + }); + // extend stakers if needed. + stakers.extend(self.stakers) + } + + let _ = pallet_staking::GenesisConfig:: { + stakers: stakers.clone(), + validator_count: self.validator_count, + minimum_validator_count: self.minimum_validator_count, + invulnerables: self.invulnerables, + slash_reward_fraction: Perbill::from_percent(10), + min_nominator_bond: self.min_nominator_bond, + min_validator_bond: self.min_validator_bond, + ..Default::default() + } + .assimilate_storage(&mut storage); + + let _ = pallet_session::GenesisConfig:: { + keys: if self.has_stakers { + // set the keys for the first session. + stakers + .into_iter() + .map(|(id, ..)| (id, id, SessionKeys { other: (id as u64).into() })) + .collect() + } else { + // set some dummy validators in genesis. + (0..self.validator_count as u128) + .map(|id| (id, id, SessionKeys { other: (id as u64).into() })) + .collect() + }, + } + .assimilate_storage(&mut storage); + let mut ext = sp_io::TestExternalities::from(storage); + + if self.initialize_first_session { + // We consider all test to start after timestamp is initialized This must be ensured by + // having `timestamp::on_initialize` called before `staking::on_initialize`. Also, if + // session length is 1, then it is already triggered. + ext.execute_with(|| { + System::set_block_number(1); + Session::on_initialize(1); + >::on_initialize(1); + Timestamp::set_timestamp(INIT_TIMESTAMP); + }); + } + + ext + } + pub fn balance_factor(mut self, factor: Balance) -> Self { + self.balance_factor = factor; + self + } + pub fn initialize_first_session(mut self, init: bool) -> Self { + self.initialize_first_session = init; + self + } pub fn phases(self, signed: BlockNumber, unsigned: BlockNumber) -> Self { ::set(signed); ::set(unsigned); self } - - pub fn add_voter( - self, - who: AccountId, - stake: Balance, - targets: BoundedVec, - ) -> Self { - VOTERS.with(|v| v.borrow_mut().push((who, stake, targets))); - self - } - pub fn build_and_execute(self, test: impl FnOnce() -> ()) { self.build().execute_with(test) } } -// Fast forward `n` blocks. +// Progress to given block, triggering session and era changes as we progress. pub fn roll_to(n: BlockNumber) { - let now = System::block_number(); - for i in now + 1..=n { - System::set_block_number(i); - ElectionProviderMultiPhase::on_initialize(i); - Staking::on_initialize(i); + for b in (System::block_number()) + 1..=n { + System::set_block_number(b); + Session::on_initialize(b); + Staking::on_initialize(b); + ElectionProviderMultiPhase::on_initialize(b); + Timestamp::set_timestamp(System::block_number() * BLOCK_TIME + INIT_TIMESTAMP); + if b != n { + Staking::on_finalize(System::block_number()); + } } } +/// Progresses from the current block number (whatever that may be) to the `P * session_index + 1`. +pub(crate) fn start_session(session_index: SessionIndex) { + let end: u64 = if Offset::get().is_zero() { + (session_index as u64) * Period::get() + } else { + Offset::get() + (session_index.saturating_sub(1) as u64) * Period::get() + }; + + roll_to(end); + // session must have progressed properly. + assert_eq!( + Session::current_index(), + session_index, + "current session index = {}, expected = {}", + Session::current_index(), + session_index, + ); +} + +/// Go one session forward. +pub(crate) fn advance_session() { + let current_index = Session::current_index(); + start_session(current_index + 1); +} + +/// Progress until the given era. +pub(crate) fn start_active_era(era_index: EraIndex) { + start_session((era_index * >::get()).into()); + assert_eq!(active_era(), era_index); + // One way or another, current_era must have changed before the active era, so they must match + // at this point. + assert_eq!(current_era(), active_era()); +} + +pub(crate) fn active_era() -> EraIndex { + Staking::active_era().unwrap().index +} + +pub(crate) fn current_era() -> EraIndex { + Staking::current_era().unwrap() +} + // Fast forward until EPM signed phase. pub fn roll_to_signed() { while !matches!( @@ -454,7 +602,7 @@ parameter_types! { static StakingEventsIndex: usize = 0; } -// TODO(gpestana): refactor to events_sinve_last_call() -> Vec<_> +// TODO(gpestana): macro this pub fn epm_events_since_last_call() -> Vec> { let all: Vec<_> = System::events() .into_iter() @@ -471,7 +619,7 @@ pub fn epm_events_since_last_call() -> Vec Vec<_> +// TODO(gpestana): macro this pub fn session_events_since_last_call() -> Vec { let all: Vec<_> = System::events() .into_iter() From 624c728619fc608c8bb06bd018c83112e3bf99b2 Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 2 Jan 2023 01:03:04 +0100 Subject: [PATCH 04/22] Adds kusama incident test case --- .../test-election-provider/src/lib.rs | 82 ++++++++++--- .../test-election-provider/src/mock.rs | 110 ++++++++++-------- 2 files changed, 127 insertions(+), 65 deletions(-) diff --git a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs index b46e902ed0f97..16aa43979e577 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs @@ -22,6 +22,9 @@ pub(crate) const LOG_TARGET: &str = "tests::epm"; use mock::*; use sp_core::Get; +use sp_npos_elections::{to_supports, StakedAssignment}; + +use crate::mock::RuntimeOrigin; // syntactic sugar for logging. #[macro_export] @@ -47,25 +50,72 @@ fn log_current_time() { } #[test] -fn block_session_and_era_advances_helpers() { +/// Replicates the Kusama incident of 8th Dec 2022 and its resolution through the governance +/// fallback. +/// +/// After enough slashes to exceed the `Staking::OffendingValidatorsThreshold`, the staking pallet +/// set `Forcing::ForceNew`. When a new session starts, staking will start to force a new era and +/// calls ::elect(). If at this point EPM and the staking miners did not +/// have enough time to queue a new solution (snapshot + solution submission), the election request +/// fails. If there is no election fallback mechanism in place, EPM enters in emergency mode. +/// Recovery: Once EPM is in emergency mode, subsequent calls to `elect()` will fail until a new +/// solution is added to EPM's `QueuedSolution` queue. This can be achieved through +/// `Call::set_emergency_election_result` or `Call::governance_fallback` dispatchables. Once a new +/// solution is added to the queue, EPM phase transitions to `Phase::Off` and the election flow +/// restarts. +fn enters_emergency_phase_after_forcing_before_elect() { ExtBuilder::default().initialize_first_session(true).build_and_execute(|| { - let advance_by = 6; - for _ in 1..=advance_by { - log_current_time(); - advance_session(); - } - - // each session has `Period` blocks. - assert_eq!(System::block_number(), advance_by * Period::get()); - // each era has `SessionsPerEra` sessions. - assert_eq!( - Staking::current_era().unwrap(), - Session::current_index() / >::get() + log!( + trace, + "current validators (staking): {:?}", + >::validators() ); + let session_validators_before = Session::validators(); + + roll_to_epm_off(); + assert!(ElectionProviderMultiPhase::current_phase().is_off()); + + assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::NotForcing); + // slashes until staking gets into `Forcing::ForceNew`. + add_slash(&11); + + assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::ForceNew); + + advance_session(); + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + + // try to advance 2 eras. + advance_n_sessions(>::get().into()); + advance_n_sessions(>::get().into()); + + // EPM is still in emergency phase. + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + + // session validator set remains the same. + assert_eq!(Session::validators(), session_validators_before); + + // performs recovery through the set emergency result. + let supports = to_supports(&vec![ + StakedAssignment { who: 21, distribution: vec![(21, 10)] }, + StakedAssignment { who: 31, distribution: vec![(21, 10), (31, 10)] }, + StakedAssignment { who: 41, distribution: vec![(41, 10)] }, + ]); + assert!(ElectionProviderMultiPhase::set_emergency_election_result( + RuntimeOrigin::root(), + supports + ) + .is_ok()); + + // EPM can now roll to signed phase to proceed with elections. The validator set is the + // expected (ie. set through `set_emergency_election_result`). + roll_to_epm_signed(); + assert!(ElectionProviderMultiPhase::current_phase().is_signed()); + assert_eq!(Session::validators(), vec![21, 31, 41]); }); } #[test] -/// Replicates the [Kusama incident](https://hackmd.io/Dt1L-JMtRc2y5FiOQik88A) of 8th Dec 2022. -/// -fn enters_emergency_phase_after_forcing_before_elect() {} +/// Continously slash validators in the validator set while in emergency phase. +fn continuous_slashes_in_emergency() { + // TODO(gpestana) +} diff --git a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs index 59e61af540987..ef70d131d7f54 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs @@ -29,7 +29,10 @@ use sp_runtime::{ traits::{IdentityLookup, Zero}, transaction_validity, PerU16, Perbill, }; -use sp_staking::{EraIndex, SessionIndex}; +use sp_staking::{ + offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}, + EraIndex, SessionIndex, +}; use sp_std::prelude::*; use std::collections::BTreeMap; @@ -162,7 +165,7 @@ frame_election_provider_support::generate_solution_type!( parameter_types! { pub static SignedPhase: BlockNumber = 10; - pub static UnsignedPhase: BlockNumber = 5; + pub static UnsignedPhase: BlockNumber = 1; pub static MaxElectingVoters: VoterIndex = 1000; pub static MaxElectableTargets: TargetIndex = 1000; pub static MaxActiveValidators: u32 = 1000; @@ -197,7 +200,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type SlashHandler = (); type RewardHandler = (); type DataProvider = Staking; - type Fallback = onchain::OnChainExecution; + type Fallback = + frame_election_provider_support::NoElection<(AccountId, BlockNumber, Staking, MaxWinners)>; type GovernanceFallback = onchain::OnChainExecution; type Solver = SequentialPhragmen, Balancing>; type ForceOrigin = EnsureRoot; @@ -228,7 +232,7 @@ parameter_types! { pub const BondingDuration: sp_staking::EraIndex = 28; pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. pub const MaxNominatorRewardedPerValidator: u32 = 256; - pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(10); pub HistoryDepth: u32 = 84; } @@ -534,6 +538,11 @@ pub fn roll_to(n: BlockNumber) { } } +// Progress one block. +pub fn roll_one() { + roll_to(System::block_number() + 1); +} + /// Progresses from the current block number (whatever that may be) to the `P * session_index + 1`. pub(crate) fn start_session(session_index: SessionIndex) { let end: u64 = if Offset::get().is_zero() { @@ -559,6 +568,14 @@ pub(crate) fn advance_session() { start_session(current_index + 1); } +/// Advances `n` sessions forward. +pub(crate) fn advance_n_sessions(n: u32) { + let current_index = Session::current_index(); + for i in 0..n { + start_session(current_index + i); + } +} + /// Progress until the given era. pub(crate) fn start_active_era(era_index: EraIndex) { start_session((era_index * >::get()).into()); @@ -568,6 +585,10 @@ pub(crate) fn start_active_era(era_index: EraIndex) { assert_eq!(current_era(), active_era()); } +pub(crate) fn start_next_active_era() { + start_active_era(active_era() + 1) +} + pub(crate) fn active_era() -> EraIndex { Staking::active_era().unwrap().index } @@ -577,7 +598,7 @@ pub(crate) fn current_era() -> EraIndex { } // Fast forward until EPM signed phase. -pub fn roll_to_signed() { +pub fn roll_to_epm_signed() { while !matches!( ElectionProviderMultiPhase::current_phase(), pallet_election_provider_multi_phase::Phase::Signed @@ -587,7 +608,7 @@ pub fn roll_to_signed() { } // Fast forward until EPM unsigned phase. -pub fn roll_to_unsigned() { +pub fn roll_to_epm_unsigned() { while !matches!( ElectionProviderMultiPhase::current_phase(), pallet_election_provider_multi_phase::Phase::Unsigned(_) @@ -596,47 +617,38 @@ pub fn roll_to_unsigned() { } } -parameter_types! { - static EPMEventsIndex: usize = 0; - static SessionEventsIndex: usize = 0; - static StakingEventsIndex: usize = 0; -} - -// TODO(gpestana): macro this -pub fn epm_events_since_last_call() -> Vec> { - let all: Vec<_> = System::events() - .into_iter() - .filter_map(|r| { - if let RuntimeEvent::ElectionProviderMultiPhase(inner) = r.event { - Some(inner) - } else { - None - } - }) - .collect(); - let seen = EPMEventsIndex::get(); - EPMEventsIndex::set(all.len()); - all.into_iter().skip(seen).collect() -} - -// TODO(gpestana): macro this -pub fn session_events_since_last_call() -> Vec { - let all: Vec<_> = System::events() - .into_iter() - .filter_map(|r| if let RuntimeEvent::Session(inner) = r.event { Some(inner) } else { None }) - .collect(); - let seen = SessionEventsIndex::get(); - SessionEventsIndex::set(all.len()); - all.into_iter().skip(seen).collect() -} - -// TODO(gpestana): refactor to events_sinve_last_call() -> Vec<_> -pub fn staking_events_since_last_call() -> Vec> { - let all: Vec<_> = System::events() - .into_iter() - .filter_map(|r| if let RuntimeEvent::Staking(inner) = r.event { Some(inner) } else { None }) - .collect(); - let seen = StakingEventsIndex::get(); - StakingEventsIndex::set(all.len()); - all.into_iter().skip(seen).collect() +// Fast forward until EPM off. +pub fn roll_to_epm_off() { + while !matches!( + ElectionProviderMultiPhase::current_phase(), + pallet_election_provider_multi_phase::Phase::Off + ) { + roll_to(System::block_number() + 1); + } +} + +pub(crate) fn on_offence_now( + offenders: &[OffenceDetails< + AccountId, + pallet_session::historical::IdentificationTuple, + >], + slash_fraction: &[Perbill], +) { + let now = Staking::active_era().unwrap().index; + let _ = Staking::on_offence( + offenders, + slash_fraction, + Staking::eras_start_session_index(now).unwrap(), + DisableStrategy::WhenSlashed, + ); +} + +pub(crate) fn add_slash(who: &AccountId) { + on_offence_now( + &[OffenceDetails { + offender: (*who, Staking::eras_stakers(active_era(), *who)), + reporters: vec![], + }], + &[Perbill::from_percent(10)], + ); } From 73197ae3c359b27701412a8f78de1e772d3a1e2a Mon Sep 17 00:00:00 2001 From: gpestana Date: Thu, 5 Jan 2023 13:47:24 +0100 Subject: [PATCH 05/22] Prepare for slashing test --- .../test-election-provider/src/lib.rs | 45 ++++++++++- .../test-election-provider/src/mock.rs | 77 +++++++++++-------- 2 files changed, 86 insertions(+), 36 deletions(-) diff --git a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs index 16aa43979e577..d4d9f0a802078 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs @@ -74,6 +74,7 @@ fn enters_emergency_phase_after_forcing_before_elect() { roll_to_epm_off(); assert!(ElectionProviderMultiPhase::current_phase().is_off()); + log_current_time(); assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::NotForcing); // slashes until staking gets into `Forcing::ForceNew`. @@ -83,6 +84,7 @@ fn enters_emergency_phase_after_forcing_before_elect() { advance_session(); assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + log_current_time(); // try to advance 2 eras. advance_n_sessions(>::get().into()); @@ -109,13 +111,50 @@ fn enters_emergency_phase_after_forcing_before_elect() { // EPM can now roll to signed phase to proceed with elections. The validator set is the // expected (ie. set through `set_emergency_election_result`). roll_to_epm_signed(); + log_current_time(); assert!(ElectionProviderMultiPhase::current_phase().is_signed()); assert_eq!(Session::validators(), vec![21, 31, 41]); }); } #[test] -/// Continously slash validators in the validator set while in emergency phase. -fn continuous_slashes_in_emergency() { - // TODO(gpestana) +/// Continously slash 10% of the active validators per era, even during the emergency phase. +fn continous_slashes() { + ExtBuilder::default() + .initialize_first_session(true) + .validator_count(10) + .build_and_execute(|| { + assert_eq!(Session::validators().len(), 10); + + roll_to_epm_off(); + assert!(ElectionProviderMultiPhase::current_phase().is_off()); + + println!( + "slashing 11, set: {:?} - {:?}", + Session::validators(), + ElectionProviderMultiPhase::current_phase() + ); + add_slash(&11); + advance_n_sessions(>::get().into()); + assert_eq!( + pallet_staking::ForceEra::::get(), + pallet_staking::Forcing::NotForcing + ); + + println!( + "slashing 12, set: {:?} - {:?}", + Session::validators(), + ElectionProviderMultiPhase::current_phase() + ); + add_slash(&12); + advance_n_sessions(>::get().into()); + assert_eq!( + pallet_staking::ForceEra::::get(), + pallet_staking::Forcing::NotForcing + ); + }); } + +#[test] +/// Continously slash 10% of the active validators per era while in emergency phase. +fn continuous_slashes_in_emergency() {} diff --git a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs index ef70d131d7f54..cab1e5681a205 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs @@ -15,11 +15,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![allow(dead_code)] // TODO(gpestana): remove when ready +#![allow(dead_code)] use frame_support::{ parameter_types, traits, traits::{GenesisBuild, Hooks}, + weights::constants, }; use frame_system::EnsureRoot; use sp_core::{ConstU32, Get, H256}; @@ -74,7 +75,7 @@ pub(crate) type Moment = u64; impl frame_system::Config for Runtime { type BaseCallFilter = traits::Everything; - type BlockWeights = (); + type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -99,8 +100,14 @@ impl frame_system::Config for Runtime { type MaxConsumers = traits::ConstU32<16>; } +const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); parameter_types! { pub static ExistentialDeposit: Balance = 1; + pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights + ::with_sensible_defaults( + Weight::from_parts(2u64 * constants::WEIGHT_REF_TIME_PER_SECOND, u64::MAX), + NORMAL_DISPATCH_RATIO, + ); } impl pallet_balances::Config for Runtime { @@ -165,7 +172,7 @@ frame_election_provider_support::generate_solution_type!( parameter_types! { pub static SignedPhase: BlockNumber = 10; - pub static UnsignedPhase: BlockNumber = 1; + pub static UnsignedPhase: BlockNumber = 5; pub static MaxElectingVoters: VoterIndex = 1000; pub static MaxElectableTargets: TargetIndex = 1000; pub static MaxActiveValidators: u32 = 1000; @@ -173,6 +180,8 @@ parameter_types! { pub static BetterSignedThreshold: Perbill = Perbill::zero(); pub static BetterUnsignedThreshold: Perbill = Perbill::zero(); pub static OffchainRepeat: u32 = 5; + pub static MinerMaxLength: u32 = 256; + pub static MinerMaxWeight: Weight = BlockWeights::get().max_block; pub static TransactionPriority: transaction_validity::TransactionPriority = 1; pub static MaxWinners: u32 = 100; pub static MaxVotesPerVoter: u32 = 16; @@ -216,10 +225,10 @@ impl MinerConfig for Runtime { type AccountId = AccountId; type Solution = MockNposSolution; type MaxVotesPerVoter = MaxNominations; - type MaxLength = (); - type MaxWeight = (); + type MaxLength = MinerMaxLength; + type MaxWeight = MinerMaxWeight; - fn solution_weight(_voters: u32, _targets: u32, _active_voters: u32, _degree: u32) -> Weight { + fn solution_weight(_v: u32, _t: u32, _a: u32, _d: u32) -> Weight { Weight::zero() } } @@ -232,7 +241,7 @@ parameter_types! { pub const BondingDuration: sp_staking::EraIndex = 28; pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. pub const MaxNominatorRewardedPerValidator: u32 = 256; - pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(10); + pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(40); pub HistoryDepth: u32 = 84; } @@ -346,7 +355,6 @@ impl sp_runtime::BoundToRuntimeAppPublic for OtherSessionHandler { } pub struct ExtBuilder { - nominate: bool, validator_count: u32, minimum_validator_count: u32, invulnerables: Vec, @@ -363,7 +371,6 @@ pub struct ExtBuilder { impl Default for ExtBuilder { fn default() -> Self { Self { - nominate: true, validator_count: 2, minimum_validator_count: 0, balance_factor: 1, @@ -399,22 +406,24 @@ impl ExtBuilder { (30, self.balance_factor), (40, self.balance_factor), (50, self.balance_factor), - // stashes - (11, self.balance_factor * 1000), - (21, self.balance_factor * 2000), - (31, self.balance_factor * 2000), - (41, self.balance_factor * 2000), - (51, self.balance_factor * 2000), - // optional nominator - (100, self.balance_factor * 2000), - (101, self.balance_factor * 2000), - // aux accounts (60, self.balance_factor), - (61, self.balance_factor * 2000), (70, self.balance_factor), - (71, self.balance_factor * 2000), (80, self.balance_factor), - (81, self.balance_factor * 2000), + (90, self.balance_factor), + (100, self.balance_factor), + (200, self.balance_factor), + // stashes + (11, self.balance_factor * 1000), + (21, self.balance_factor * 2000), + (31, self.balance_factor * 3000), + (41, self.balance_factor * 4000), + (51, self.balance_factor * 5000), + (61, self.balance_factor * 6000), + (71, self.balance_factor * 7000), + (81, self.balance_factor * 8000), + (91, self.balance_factor * 9000), + (101, self.balance_factor * 10000), + (201, self.balance_factor * 20000), // This allows us to have a total_payout different from 0. (999, 1_000_000_000_000), ], @@ -428,20 +437,18 @@ impl ExtBuilder { // these two will be elected in the default test where we elect 2. (11, 10, self.balance_factor * 1000, StakerStatus::::Validator), (21, 20, self.balance_factor * 1000, StakerStatus::::Validator), - // a loser validator + // loser validatos if validator_count() is default. (31, 30, self.balance_factor * 500, StakerStatus::::Validator), + (41, 40, self.balance_factor * 500, StakerStatus::::Validator), + (51, 50, self.balance_factor * 500, StakerStatus::::Validator), + (61, 60, self.balance_factor * 500, StakerStatus::::Validator), + (71, 70, self.balance_factor * 500, StakerStatus::::Validator), + (81, 80, self.balance_factor * 500, StakerStatus::::Validator), + (91, 90, self.balance_factor * 500, StakerStatus::::Validator), + (101, 100, self.balance_factor * 500, StakerStatus::::Validator), // an idle validator - (41, 40, self.balance_factor * 1000, StakerStatus::::Idle), + (201, 200, self.balance_factor * 1000, StakerStatus::::Idle), ]; - // optionally add a nominator - if self.nominate { - stakers.push(( - 101, - 100, - self.balance_factor * 500, - StakerStatus::::Nominator(vec![11, 21]), - )) - } // replace any of the status if needed. self.status.into_iter().for_each(|(stash, status)| { let (_, _, _, ref mut prev_status) = stakers @@ -519,6 +526,10 @@ impl ExtBuilder { ::set(unsigned); self } + pub fn validator_count(mut self, n: u32) -> Self { + self.validator_count = n; + self + } pub fn build_and_execute(self, test: impl FnOnce() -> ()) { self.build().execute_with(test) } From 762b0c0fc2938fbd7f52602a90e66b3f88f96762 Mon Sep 17 00:00:00 2001 From: gpestana Date: Fri, 6 Jan 2023 17:59:01 +0100 Subject: [PATCH 06/22] Adds solution submission --- .../test-election-provider/src/lib.rs | 29 ++++--- .../test-election-provider/src/mock.rs | 81 +++++++++++++------ 2 files changed, 74 insertions(+), 36 deletions(-) diff --git a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs index d4d9f0a802078..160dffdbda4d5 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs @@ -21,7 +21,6 @@ mod mock; pub(crate) const LOG_TARGET: &str = "tests::epm"; use mock::*; -use sp_core::Get; use sp_npos_elections::{to_supports, StakedAssignment}; use crate::mock::RuntimeOrigin; @@ -49,6 +48,18 @@ fn log_current_time() { ); } +#[test] +fn setup_works() { + ExtBuilder::default().initialize_first_session(true).build_and_execute(|| { + assert_eq!(active_era(), 0); + + start_next_active_era(); + start_next_active_era(); + start_next_active_era(); + start_next_active_era(); + }); +} + #[test] /// Replicates the Kusama incident of 8th Dec 2022 and its resolution through the governance /// fallback. @@ -82,13 +93,13 @@ fn enters_emergency_phase_after_forcing_before_elect() { assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::ForceNew); - advance_session(); + advance_session_delayed_solution(); assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); log_current_time(); - // try to advance 2 eras. - advance_n_sessions(>::get().into()); - advance_n_sessions(>::get().into()); + // try to advance 2 eras with a delayed solution. + start_next_active_era_delayed_solution(); + start_next_active_era_delayed_solution(); // EPM is still in emergency phase. assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); @@ -135,7 +146,7 @@ fn continous_slashes() { ElectionProviderMultiPhase::current_phase() ); add_slash(&11); - advance_n_sessions(>::get().into()); + start_next_active_era(); assert_eq!( pallet_staking::ForceEra::::get(), pallet_staking::Forcing::NotForcing @@ -147,14 +158,10 @@ fn continous_slashes() { ElectionProviderMultiPhase::current_phase() ); add_slash(&12); - advance_n_sessions(>::get().into()); + start_next_active_era(); assert_eq!( pallet_staking::ForceEra::::get(), pallet_staking::Forcing::NotForcing ); }); } - -#[test] -/// Continously slash 10% of the active validators per era while in emergency phase. -fn continuous_slashes_in_emergency() {} diff --git a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs index cab1e5681a205..337b246d1040d 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs @@ -38,9 +38,13 @@ use sp_std::prelude::*; use std::collections::BTreeMap; use frame_election_provider_support::{onchain, SequentialPhragmen, Weight}; -use pallet_election_provider_multi_phase::{unsigned::MinerConfig, SolutionAccuracyOf}; +use pallet_election_provider_multi_phase::{ + unsigned::MinerConfig, ElectionCompute, QueuedSolution, SolutionAccuracyOf, +}; use pallet_staking::StakerStatus; +use crate::log_current_time; + pub const INIT_TIMESTAMP: u64 = 30_000; pub const BLOCK_TIME: u64 = 1000; @@ -535,34 +539,48 @@ impl ExtBuilder { } } -// Progress to given block, triggering session and era changes as we progress. -pub fn roll_to(n: BlockNumber) { +// Progress to given block, triggering session and era changes as we progress and ensuring that +// there is a solution queued when expected. +pub fn roll_to(n: BlockNumber, delay_solution: bool) { for b in (System::block_number()) + 1..=n { System::set_block_number(b); Session::on_initialize(b); - Staking::on_initialize(b); - ElectionProviderMultiPhase::on_initialize(b); Timestamp::set_timestamp(System::block_number() * BLOCK_TIME + INIT_TIMESTAMP); + + // if EPM is in off phase, there's no solution and the solution should not be delayed, try + // minining and queue a solution. + if ElectionProviderMultiPhase::snapshot().is_none() && + ElectionProviderMultiPhase::current_phase().is_off() && + !delay_solution + { + ElectionProviderMultiPhase::on_initialize(n); + let _ = try_queue_solution(ElectionCompute::Signed); + } else { + ElectionProviderMultiPhase::on_initialize(n); + }; + Staking::on_initialize(b); if b != n { Staking::on_finalize(System::block_number()); } } + log_current_time(); } // Progress one block. -pub fn roll_one() { - roll_to(System::block_number() + 1); +pub fn roll_one(delay_solution: bool) { + roll_to(System::block_number() + 1, delay_solution); } /// Progresses from the current block number (whatever that may be) to the `P * session_index + 1`. -pub(crate) fn start_session(session_index: SessionIndex) { +pub(crate) fn start_session(session_index: SessionIndex, delay_solution: bool) { let end: u64 = if Offset::get().is_zero() { (session_index as u64) * Period::get() } else { Offset::get() + (session_index.saturating_sub(1) as u64) * Period::get() }; - roll_to(end); + roll_to(end, delay_solution); + // session must have progressed properly. assert_eq!( Session::current_index(), @@ -576,28 +594,31 @@ pub(crate) fn start_session(session_index: SessionIndex) { /// Go one session forward. pub(crate) fn advance_session() { let current_index = Session::current_index(); - start_session(current_index + 1); + start_session(current_index + 1, false); } -/// Advances `n` sessions forward. -pub(crate) fn advance_n_sessions(n: u32) { +pub(crate) fn advance_session_delayed_solution() { let current_index = Session::current_index(); - for i in 0..n { - start_session(current_index + i); - } + start_session(current_index + 1, true); } /// Progress until the given era. -pub(crate) fn start_active_era(era_index: EraIndex) { - start_session((era_index * >::get()).into()); - assert_eq!(active_era(), era_index); - // One way or another, current_era must have changed before the active era, so they must match - // at this point. - assert_eq!(current_era(), active_era()); +pub(crate) fn start_active_era(era_index: EraIndex, delay_solution: bool) { + start_session((era_index * >::get()).into(), delay_solution); + + // if the solution was not delayed, era should have progressed. + if !delay_solution { + assert_eq!(active_era(), era_index); + assert_eq!(current_era(), active_era()); + } } pub(crate) fn start_next_active_era() { - start_active_era(active_era() + 1) + start_active_era(active_era() + 1, false) +} + +pub(crate) fn start_next_active_era_delayed_solution() { + start_active_era(active_era() + 1, true) } pub(crate) fn active_era() -> EraIndex { @@ -614,7 +635,7 @@ pub fn roll_to_epm_signed() { ElectionProviderMultiPhase::current_phase(), pallet_election_provider_multi_phase::Phase::Signed ) { - roll_to(System::block_number() + 1); + roll_to(System::block_number() + 1, false); } } @@ -624,7 +645,7 @@ pub fn roll_to_epm_unsigned() { ElectionProviderMultiPhase::current_phase(), pallet_election_provider_multi_phase::Phase::Unsigned(_) ) { - roll_to(System::block_number() + 1); + roll_to(System::block_number() + 1, false); } } @@ -634,10 +655,20 @@ pub fn roll_to_epm_off() { ElectionProviderMultiPhase::current_phase(), pallet_election_provider_multi_phase::Phase::Off ) { - roll_to(System::block_number() + 1); + roll_to(System::block_number() + 1, false); } } +// Queue a solution based on the current snapshot. +pub(crate) fn try_queue_solution(when: ElectionCompute) -> Result<(), ()> { + let raw_solution = ElectionProviderMultiPhase::mine_solution().map_err(|_| ())?; + ElectionProviderMultiPhase::feasibility_check(raw_solution.0, when) + .map(|ready| { + QueuedSolution::::put(ready); + }) + .map_err(|_| ()) +} + pub(crate) fn on_offence_now( offenders: &[OffenceDetails< AccountId, From 869b6775d23ef8f98f8ff5bba79d6e7aac11d5a2 Mon Sep 17 00:00:00 2001 From: gpestana Date: Fri, 6 Jan 2023 18:49:20 +0100 Subject: [PATCH 07/22] slash_through_offending_threshold --- .../test-election-provider/src/lib.rs | 13 +++++++++---- .../test-election-provider/src/mock.rs | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs index 160dffdbda4d5..1ff36e103d01b 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/lib.rs @@ -55,8 +55,13 @@ fn setup_works() { start_next_active_era(); start_next_active_era(); - start_next_active_era(); - start_next_active_era(); + assert_eq!(active_era(), 2); + + // if the solution is delayed, EPM will end up in emergency mode and eras won't progress. + start_next_active_era_delayed_solution(); + start_next_active_era_delayed_solution(); + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + assert_eq!(active_era(), 3); }); } @@ -88,8 +93,8 @@ fn enters_emergency_phase_after_forcing_before_elect() { log_current_time(); assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::NotForcing); - // slashes until staking gets into `Forcing::ForceNew`. - add_slash(&11); + // slashes so that staking goes into `Forcing::ForceNew`. + slash_through_offending_threshold(); assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::ForceNew); diff --git a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs index 337b246d1040d..863d80bcbdd6f 100644 --- a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs +++ b/frame/election-provider-multi-phase/test-election-provider/src/mock.rs @@ -548,7 +548,7 @@ pub fn roll_to(n: BlockNumber, delay_solution: bool) { Timestamp::set_timestamp(System::block_number() * BLOCK_TIME + INIT_TIMESTAMP); // if EPM is in off phase, there's no solution and the solution should not be delayed, try - // minining and queue a solution. + // "minining" and queue a solution. if ElectionProviderMultiPhase::snapshot().is_none() && ElectionProviderMultiPhase::current_phase().is_off() && !delay_solution @@ -685,6 +685,7 @@ pub(crate) fn on_offence_now( ); } +// Add offence to validator, slash it. pub(crate) fn add_slash(who: &AccountId) { on_offence_now( &[OffenceDetails { @@ -694,3 +695,18 @@ pub(crate) fn add_slash(who: &AccountId) { &[Perbill::from_percent(10)], ); } + +// Slashes enough validators to cross the `Staking::OffendingValidatorsThreshold`. +pub(crate) fn slash_through_offending_threshold() { + let validators = Session::validators(); + let mut remaining_slashes = + ::OffendingValidatorsThreshold::get() * + validators.len() as u32; + + for v in validators.into_iter() { + if remaining_slashes != 0 { + add_slash(&v); + remaining_slashes -= 1; + } + } +} From eeb0438924e96a16ebe37d516f942421a339d47c Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 9 Jan 2023 00:52:49 +0100 Subject: [PATCH 08/22] Renames e2e integration tests dir and crate --- .../Cargo.lock | 50 +++++++++---------- .../Cargo.toml | 2 +- .../src/lib.rs | 0 .../src/mock.rs | 0 4 files changed, 26 insertions(+), 26 deletions(-) rename frame/election-provider-multi-phase/{test-election-provider => test-staking-e2e}/Cargo.lock (99%) rename frame/election-provider-multi-phase/{test-election-provider => test-staking-e2e}/Cargo.toml (97%) rename frame/election-provider-multi-phase/{test-election-provider => test-staking-e2e}/src/lib.rs (100%) rename frame/election-provider-multi-phase/{test-election-provider => test-staking-e2e}/src/mock.rs (100%) diff --git a/frame/election-provider-multi-phase/test-election-provider/Cargo.lock b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock similarity index 99% rename from frame/election-provider-multi-phase/test-election-provider/Cargo.lock rename to frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock index 15d6f29c68e97..a17ce1bb0d357 100644 --- a/frame/election-provider-multi-phase/test-election-provider/Cargo.lock +++ b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock @@ -1588,63 +1588,63 @@ dependencies = [ ] [[package]] -name = "pallet-election-provider-multi-phase" -version = "4.0.0-dev" +name = "pallet-election-provider-e2e-test" +version = "1.0.0" dependencies = [ - "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", - "pallet-election-provider-support-benchmarking", + "pallet-bags-list", + "pallet-balances", + "pallet-election-provider-multi-phase", + "pallet-session", + "pallet-staking", + "pallet-timestamp", "parity-scale-codec", - "rand 0.7.3", "scale-info", - "sp-arithmetic", "sp-core", "sp-io", "sp-npos-elections", "sp-runtime", + "sp-staking", "sp-std", - "static_assertions", - "strum", + "sp-tracing", ] [[package]] -name = "pallet-election-provider-support-benchmarking" +name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" dependencies = [ "frame-benchmarking", "frame-election-provider-support", + "frame-support", "frame-system", + "log", + "pallet-election-provider-support-benchmarking", "parity-scale-codec", + "rand 0.7.3", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", "sp-npos-elections", "sp-runtime", + "sp-std", + "static_assertions", + "strum", ] [[package]] -name = "pallet-election-provider-test" -version = "1.0.0" +name = "pallet-election-provider-support-benchmarking" +version = "4.0.0-dev" dependencies = [ + "frame-benchmarking", "frame-election-provider-support", - "frame-support", "frame-system", - "log", - "pallet-bags-list", - "pallet-balances", - "pallet-election-provider-multi-phase", - "pallet-session", - "pallet-staking", - "pallet-timestamp", "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", "sp-npos-elections", "sp-runtime", - "sp-staking", - "sp-std", - "sp-tracing", ] [[package]] diff --git a/frame/election-provider-multi-phase/test-election-provider/Cargo.toml b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.toml similarity index 97% rename from frame/election-provider-multi-phase/test-election-provider/Cargo.toml rename to frame/election-provider-multi-phase/test-staking-e2e/Cargo.toml index 477eae5d57413..432b732b48e9d 100644 --- a/frame/election-provider-multi-phase/test-election-provider/Cargo.toml +++ b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-election-provider-test" +name = "pallet-election-provider-e2e-test" version = "1.0.0" authors = ["Parity Technologies "] edition = "2021" diff --git a/frame/election-provider-multi-phase/test-election-provider/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs similarity index 100% rename from frame/election-provider-multi-phase/test-election-provider/src/lib.rs rename to frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs diff --git a/frame/election-provider-multi-phase/test-election-provider/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs similarity index 100% rename from frame/election-provider-multi-phase/test-election-provider/src/mock.rs rename to frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs From 888fa741a34efaef3d9b88e1faca136f687f5134 Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 9 Jan 2023 02:34:39 +0100 Subject: [PATCH 09/22] consistently slash 10% of validator set --- .../test-staking-e2e/src/lib.rs | 48 ++++++++----------- .../test-staking-e2e/src/mock.rs | 17 +++++++ 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index 1ff36e103d01b..09c45f16fd518 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -22,6 +22,7 @@ pub(crate) const LOG_TARGET: &str = "tests::epm"; use mock::*; use sp_npos_elections::{to_supports, StakedAssignment}; +use sp_runtime::Perbill; use crate::mock::RuntimeOrigin; @@ -141,32 +142,25 @@ fn continous_slashes() { .validator_count(10) .build_and_execute(|| { assert_eq!(Session::validators().len(), 10); - - roll_to_epm_off(); - assert!(ElectionProviderMultiPhase::current_phase().is_off()); - - println!( - "slashing 11, set: {:?} - {:?}", - Session::validators(), - ElectionProviderMultiPhase::current_phase() - ); - add_slash(&11); - start_next_active_era(); - assert_eq!( - pallet_staking::ForceEra::::get(), - pallet_staking::Forcing::NotForcing - ); - - println!( - "slashing 12, set: {:?} - {:?}", - Session::validators(), - ElectionProviderMultiPhase::current_phase() - ); - add_slash(&12); - start_next_active_era(); - assert_eq!( - pallet_staking::ForceEra::::get(), - pallet_staking::Forcing::NotForcing - ); + let mut active_validator_set = Session::validators(); + + // slash 10% of the active validators and progress era. + while active_validator_set.len() != 0 { + let slashed = slash_percentage(Perbill::from_percent(10)); + assert_eq!(slashed.len(), 1); + start_next_active_era(); + + let _ = slashed + .iter() + .map(|s| active_validator_set.retain(|x| x != s)) + .collect::>(); + + log!( + trace, + "slashed 10% of active validators ({:?}). After slash: {:?}", + slashed, + active_validator_set + ); + } }); } diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 863d80bcbdd6f..f4bee90f19c76 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -710,3 +710,20 @@ pub(crate) fn slash_through_offending_threshold() { } } } + +// Slashes a percentage of the active nominators that haven't been slashed yet, with +// a minimum of 1 validator slash. +pub(crate) fn slash_percentage(percentage: Perbill) -> Vec { + let validators = Session::validators(); + let mut remaining_slashes = (percentage * validators.len() as u32).max(1); + let mut slashed = vec![]; + + for v in validators.into_iter() { + if remaining_slashes != 0 { + add_slash(&v); + slashed.push(v); + remaining_slashes -= 1; + } + } + slashed +} From 8e735387f0f63c726e89f81e7d23e0412613b638 Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 9 Jan 2023 12:47:38 +0100 Subject: [PATCH 10/22] finishes continous_slashes_below_offending_threshold test --- .../test-staking-e2e/src/lib.rs | 45 ++++++++++++------- .../test-staking-e2e/src/mock.rs | 30 ++++++++++--- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index 09c45f16fd518..e7d71de6da7dc 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -54,13 +54,13 @@ fn setup_works() { ExtBuilder::default().initialize_first_session(true).build_and_execute(|| { assert_eq!(active_era(), 0); - start_next_active_era(); - start_next_active_era(); + assert!(start_next_active_era().is_ok()); + assert!(start_next_active_era().is_ok()); assert_eq!(active_era(), 2); // if the solution is delayed, EPM will end up in emergency mode and eras won't progress. - start_next_active_era_delayed_solution(); - start_next_active_era_delayed_solution(); + assert!(start_next_active_era_delayed_solution().is_ok()); + assert!(start_next_active_era_delayed_solution().is_ok()); assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); assert_eq!(active_era(), 3); }); @@ -104,8 +104,8 @@ fn enters_emergency_phase_after_forcing_before_elect() { log_current_time(); // try to advance 2 eras with a delayed solution. - start_next_active_era_delayed_solution(); - start_next_active_era_delayed_solution(); + assert!(start_next_active_era_delayed_solution().is_ok()); + assert!(start_next_active_era_delayed_solution().is_ok()); // EPM is still in emergency phase. assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); @@ -135,8 +135,16 @@ fn enters_emergency_phase_after_forcing_before_elect() { } #[test] -/// Continously slash 10% of the active validators per era, even during the emergency phase. -fn continous_slashes() { +/// Continously slash 10% of the active validators per era. +/// +/// Since the `OffendingValidatorsThreshold` is only checked per era staking does not force a new +/// era even as the number of active validators is decreasing across eras. When processing a new +/// slash, staking calculates the offending threshold based on the lenght of the current list of +/// active validators. Thus, slashing a percentage of the current validators that is lower than +/// `OffendingValidatorsThreshold` will never force a new era. However, as the slashes progress, if +/// the subsequent elections do not meet the minimum election untrusted score, the election will +/// fail and enter in emenergency mode. +fn continous_slashes_below_offending_threshold() { ExtBuilder::default() .initialize_first_session(true) .validator_count(10) @@ -144,16 +152,23 @@ fn continous_slashes() { assert_eq!(Session::validators().len(), 10); let mut active_validator_set = Session::validators(); - // slash 10% of the active validators and progress era. - while active_validator_set.len() != 0 { + // set a minimum election score. + assert!(set_minimum_election_score(500, 1000, 500).is_ok()); + + // slash 10% of the active validators and progress era until the minimum trusted score + // is reached. + while active_validator_set.len() > 0 { let slashed = slash_percentage(Perbill::from_percent(10)); assert_eq!(slashed.len(), 1); - start_next_active_era(); - let _ = slashed - .iter() - .map(|s| active_validator_set.retain(|x| x != s)) - .collect::>(); + // break loop when era does not progress; EPM is in emergency phase as election + // failed due to election minimum score. + if start_next_active_era().is_err() { + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + break + } + + active_validator_set = Session::validators(); log!( trace, diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index f4bee90f19c76..62081f3a72853 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -17,6 +17,7 @@ #![allow(dead_code)] +use _feps::ExtendedBalance; use frame_support::{ parameter_types, traits, traits::{GenesisBuild, Hooks}, @@ -24,7 +25,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use sp_core::{ConstU32, Get, H256}; -use sp_npos_elections::{BalancingConfig, VoteWeight}; +use sp_npos_elections::{BalancingConfig, ElectionScore, VoteWeight}; use sp_runtime::{ testing, traits::{IdentityLookup, Zero}, @@ -603,21 +604,22 @@ pub(crate) fn advance_session_delayed_solution() { } /// Progress until the given era. -pub(crate) fn start_active_era(era_index: EraIndex, delay_solution: bool) { +pub(crate) fn start_active_era(era_index: EraIndex, delay_solution: bool) -> Result<(), ()> { start_session((era_index * >::get()).into(), delay_solution); // if the solution was not delayed, era should have progressed. - if !delay_solution { - assert_eq!(active_era(), era_index); - assert_eq!(current_era(), active_era()); + if !delay_solution && (active_era() != era_index || current_era() != active_era()) { + Err(()) + } else { + Ok(()) } } -pub(crate) fn start_next_active_era() { +pub(crate) fn start_next_active_era() -> Result<(), ()> { start_active_era(active_era() + 1, false) } -pub(crate) fn start_next_active_era_delayed_solution() { +pub(crate) fn start_next_active_era_delayed_solution() -> Result<(), ()> { start_active_era(active_era() + 1, true) } @@ -727,3 +729,17 @@ pub(crate) fn slash_percentage(percentage: Perbill) -> Vec { } slashed } + +pub(crate) fn set_minimum_election_score( + minimal_stake: ExtendedBalance, + sum_stake: ExtendedBalance, + sum_stake_squared: ExtendedBalance, +) -> Result<(), ()> { + let election_score = ElectionScore { minimal_stake, sum_stake, sum_stake_squared }; + ElectionProviderMultiPhase::set_minimum_untrusted_score( + RuntimeOrigin::root(), + Some(election_score), + ) + .map(|_| ()) + .map_err(|_| ()) +} From 632e209ab79d2e5a9b5f288fae5306fde93c1a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Mon, 13 Mar 2023 08:35:35 +0000 Subject: [PATCH 11/22] Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> --- frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index e7d71de6da7dc..8092666707f1f 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -135,7 +135,7 @@ fn enters_emergency_phase_after_forcing_before_elect() { } #[test] -/// Continously slash 10% of the active validators per era. +/// Continuously slash 10% of the active validators per era. /// /// Since the `OffendingValidatorsThreshold` is only checked per era staking does not force a new /// era even as the number of active validators is decreasing across eras. When processing a new From ffc9aaeaeef4756e2bcf29c9d0176e3b52469157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Mon, 13 Mar 2023 08:35:42 +0000 Subject: [PATCH 12/22] Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> --- frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index 8092666707f1f..280e40b8e3ee9 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -139,7 +139,7 @@ fn enters_emergency_phase_after_forcing_before_elect() { /// /// Since the `OffendingValidatorsThreshold` is only checked per era staking does not force a new /// era even as the number of active validators is decreasing across eras. When processing a new -/// slash, staking calculates the offending threshold based on the lenght of the current list of +/// slash, staking calculates the offending threshold based on the length of the current list of /// active validators. Thus, slashing a percentage of the current validators that is lower than /// `OffendingValidatorsThreshold` will never force a new era. However, as the slashes progress, if /// the subsequent elections do not meet the minimum election untrusted score, the election will From 81b2275405ab65ad08d0460db8ce436f03dc7020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Mon, 13 Mar 2023 13:41:51 +0000 Subject: [PATCH 13/22] Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index 280e40b8e3ee9..3b4bd5934d3eb 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); From b3c6e984cca12a833d57b79c8c4cd701ad95c925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 15 Mar 2023 05:09:30 +0000 Subject: [PATCH 14/22] Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- .../test-staking-e2e/src/mock.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 62081f3a72853..9edad997f98f7 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -299,8 +299,8 @@ where pub struct OnChainSeqPhragmen; parameter_types! { - pub VotersBound: u32 = 600; - pub TargetsBound: u32 = 400; + pub static VotersBound: u32 = 600; + pub static TargetsBound: u32 = 400; } impl onchain::Config for OnChainSeqPhragmen { From a1dcd6c85471e9e04b8fc36c567b92630bd6bc6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 15 Mar 2023 05:10:08 +0000 Subject: [PATCH 15/22] Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 9edad997f98f7..0c29f4107398f 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -365,7 +365,7 @@ pub struct ExtBuilder { invulnerables: Vec, has_stakers: bool, initialize_first_session: bool, - pub min_nominator_bond: Balance, + min_nominator_bond: Balance, min_validator_bond: Balance, balance_factor: Balance, status: BTreeMap>, From 79d8d4b1d9b28c2257e77ddfce6d44a2637cc6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 15 Mar 2023 05:10:20 +0000 Subject: [PATCH 16/22] Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 0c29f4107398f..c6727a197cd7e 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -391,7 +391,6 @@ impl Default for ExtBuilder { } } -parameter_types! {} impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { From ac52c0b3bc6df2acaf55f5bea41d1176fb9c438e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 15 Mar 2023 06:11:17 +0100 Subject: [PATCH 17/22] mock fixes --- .../test-staking-e2e/src/mock.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index c6727a197cd7e..2e4aca19ed849 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -25,7 +25,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use sp_core::{ConstU32, Get, H256}; -use sp_npos_elections::{BalancingConfig, ElectionScore, VoteWeight}; +use sp_npos_elections::{ElectionScore, VoteWeight}; use sp_runtime::{ testing, traits::{IdentityLookup, Zero}, @@ -127,10 +127,6 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub static CapturedMoment: Option = None; -} - impl pallet_timestamp::Config for Runtime { type Moment = Moment; type OnTimestampSet = (); @@ -181,9 +177,6 @@ parameter_types! { pub static MaxElectingVoters: VoterIndex = 1000; pub static MaxElectableTargets: TargetIndex = 1000; pub static MaxActiveValidators: u32 = 1000; - pub static Balancing: Option = Some( BalancingConfig { iterations: 0, tolerance: 0 } ); - pub static BetterSignedThreshold: Perbill = Perbill::zero(); - pub static BetterUnsignedThreshold: Perbill = Perbill::zero(); pub static OffchainRepeat: u32 = 5; pub static MinerMaxLength: u32 = 256; pub static MinerMaxWeight: Weight = BlockWeights::get().max_block; @@ -199,8 +192,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type EstimateCallFee = frame_support::traits::ConstU32<8>; type SignedPhase = SignedPhase; type UnsignedPhase = UnsignedPhase; - type BetterSignedThreshold = BetterSignedThreshold; - type BetterUnsignedThreshold = BetterUnsignedThreshold; + type BetterSignedThreshold = (); + type BetterUnsignedThreshold = (); type OffchainRepeat = OffchainRepeat; type MinerTxPriority = TransactionPriority; type MinerConfig = Self; @@ -217,7 +210,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type Fallback = frame_election_provider_support::NoElection<(AccountId, BlockNumber, Staking, MaxWinners)>; type GovernanceFallback = onchain::OnChainExecution; - type Solver = SequentialPhragmen, Balancing>; + type Solver = SequentialPhragmen, ()>; type ForceOrigin = EnsureRoot; type MaxElectableTargets = MaxElectableTargets; type MaxElectingVoters = MaxElectingVoters; From 40ac80f5d510a8633733f58c99e1b9867e07862b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 15 Mar 2023 06:25:40 +0100 Subject: [PATCH 18/22] Additional checks to delayed solution eras and mock fixes --- .../test-staking-e2e/src/lib.rs | 8 +++-- .../test-staking-e2e/src/mock.rs | 31 ++++++++----------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index 3b4bd5934d3eb..ef2208c3a5952 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -18,7 +18,7 @@ #![cfg(test)] mod mock; -pub(crate) const LOG_TARGET: &str = "tests::epm"; +pub(crate) const LOG_TARGET: &str = "tests::e2e-epm"; use mock::*; use sp_npos_elections::{to_supports, StakedAssignment}; @@ -70,7 +70,7 @@ fn setup_works() { /// Replicates the Kusama incident of 8th Dec 2022 and its resolution through the governance /// fallback. /// -/// After enough slashes to exceed the `Staking::OffendingValidatorsThreshold`, the staking pallet +/// After enough slashes exceeded the `Staking::OffendingValidatorsThreshold`, the staking pallet /// set `Forcing::ForceNew`. When a new session starts, staking will start to force a new era and /// calls ::elect(). If at this point EPM and the staking miners did not /// have enough time to queue a new solution (snapshot + solution submission), the election request @@ -103,9 +103,12 @@ fn enters_emergency_phase_after_forcing_before_elect() { assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); log_current_time(); + let era_before_delayed_next = Staking::current_era(); // try to advance 2 eras with a delayed solution. assert!(start_next_active_era_delayed_solution().is_ok()); + assert_eq!(Staking::current_era(), era_before_delayed_next); assert!(start_next_active_era_delayed_solution().is_ok()); + assert_eq!(Staking::current_era(), era_before_delayed_next); // EPM is still in emergency phase. assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); @@ -131,6 +134,7 @@ fn enters_emergency_phase_after_forcing_before_elect() { log_current_time(); assert!(ElectionProviderMultiPhase::current_phase().is_signed()); assert_eq!(Session::validators(), vec![21, 31, 41]); + assert_eq!(Staking::current_era(), era_before_delayed_next.map(|e| e + 1)); }); } diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 2e4aca19ed849..9ee03a401ca80 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -215,7 +215,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type MaxElectableTargets = MaxElectableTargets; type MaxElectingVoters = MaxElectingVoters; type MaxWinners = MaxWinners; - type BenchmarkingConfig = ElectionProviderBenchmarkConfig; + type BenchmarkingConfig = NoopElectionProviderBenchmarkConfig; type WeightInfo = (); } @@ -278,7 +278,7 @@ impl pallet_staking::Config for Runtime { type HistoryDepth = HistoryDepth; type OnStakerSlash = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; - type BenchmarkingConfig = StakingBenchmarkingConfig; + type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; } impl frame_system::offchain::SendTransactionTypes for Runtime @@ -309,22 +309,18 @@ impl onchain::Config for OnChainSeqPhragmen { type TargetsBound = TargetsBound; } -pub struct StakingBenchmarkingConfig; -impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig { - type MaxNominators = traits::ConstU32<1000>; - type MaxValidators = traits::ConstU32<1000>; -} - -pub struct ElectionProviderBenchmarkConfig; +pub struct NoopElectionProviderBenchmarkConfig; -impl pallet_election_provider_multi_phase::BenchmarkingConfig for ElectionProviderBenchmarkConfig { - const VOTERS: [u32; 2] = [1000, 2000]; - const TARGETS: [u32; 2] = [500, 1000]; - const ACTIVE_VOTERS: [u32; 2] = [500, 800]; - const DESIRED_TARGETS: [u32; 2] = [200, 400]; - const SNAPSHOT_MAXIMUM_VOTERS: u32 = 1000; - const MINER_MAXIMUM_VOTERS: u32 = 1000; - const MAXIMUM_TARGETS: u32 = 300; +impl pallet_election_provider_multi_phase::BenchmarkingConfig + for NoopElectionProviderBenchmarkConfig +{ + const VOTERS: [u32; 2] = [0, 0]; + const TARGETS: [u32; 2] = [0, 0]; + const ACTIVE_VOTERS: [u32; 2] = [0, 0]; + const DESIRED_TARGETS: [u32; 2] = [0, 0]; + const SNAPSHOT_MAXIMUM_VOTERS: u32 = 0; + const MINER_MAXIMUM_VOTERS: u32 = 0; + const MAXIMUM_TARGETS: u32 = 0; } pub struct OtherSessionHandler; @@ -384,7 +380,6 @@ impl Default for ExtBuilder { } } - impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); From f1de0a937aaa996accbc0b87d1072dba06b70d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 15 Mar 2023 08:38:13 +0100 Subject: [PATCH 19/22] nits and addresses review comments; splits ext_builder into one per pallet --- .../test-staking-e2e/src/lib.rs | 67 +++-- .../test-staking-e2e/src/mock.rs | 274 ++++++++++-------- 2 files changed, 180 insertions(+), 161 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index ef2208c3a5952..ab5a164c64f49 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -51,7 +51,7 @@ fn log_current_time() { #[test] fn setup_works() { - ExtBuilder::default().initialize_first_session(true).build_and_execute(|| { + ExtBuilder::default().build_and_execute(|| { assert_eq!(active_era(), 0); assert!(start_next_active_era().is_ok()); @@ -81,7 +81,7 @@ fn setup_works() { /// solution is added to the queue, EPM phase transitions to `Phase::Off` and the election flow /// restarts. fn enters_emergency_phase_after_forcing_before_elect() { - ExtBuilder::default().initialize_first_session(true).build_and_execute(|| { + ExtBuilder::default().build_and_execute(|| { log!( trace, "current validators (staking): {:?}", @@ -149,37 +149,36 @@ fn enters_emergency_phase_after_forcing_before_elect() { /// the subsequent elections do not meet the minimum election untrusted score, the election will /// fail and enter in emenergency mode. fn continous_slashes_below_offending_threshold() { - ExtBuilder::default() - .initialize_first_session(true) - .validator_count(10) - .build_and_execute(|| { - assert_eq!(Session::validators().len(), 10); - let mut active_validator_set = Session::validators(); - - // set a minimum election score. - assert!(set_minimum_election_score(500, 1000, 500).is_ok()); - - // slash 10% of the active validators and progress era until the minimum trusted score - // is reached. - while active_validator_set.len() > 0 { - let slashed = slash_percentage(Perbill::from_percent(10)); - assert_eq!(slashed.len(), 1); - - // break loop when era does not progress; EPM is in emergency phase as election - // failed due to election minimum score. - if start_next_active_era().is_err() { - assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); - break - } - - active_validator_set = Session::validators(); - - log!( - trace, - "slashed 10% of active validators ({:?}). After slash: {:?}", - slashed, - active_validator_set - ); + let staking_builder = StakingExtBuilder::default().validator_count(10); + + ExtBuilder::default().staking(staking_builder).build_and_execute(|| { + assert_eq!(Session::validators().len(), 10); + let mut active_validator_set = Session::validators(); + + // set a minimum election score. + assert!(set_minimum_election_score(500, 1000, 500).is_ok()); + + // slash 10% of the active validators and progress era until the minimum trusted score + // is reached. + while active_validator_set.len() > 0 { + let slashed = slash_percentage(Perbill::from_percent(10)); + assert_eq!(slashed.len(), 1); + + // break loop when era does not progress; EPM is in emergency phase as election + // failed due to election minimum score. + if start_next_active_era().is_err() { + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + break } - }); + + active_validator_set = Session::validators(); + + log!( + trace, + "slashed 10% of active validators ({:?}). After slash: {:?}", + slashed, + active_validator_set + ); + } + }); } diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 9ee03a401ca80..db08bf8ef471f 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -149,11 +149,11 @@ impl pallet_session::Config for Runtime { type SessionManager = pallet_session::historical::NoteHistoricalRoot; type Keys = SessionKeys; type ShouldEndSession = pallet_session::PeriodicSessions; + type NextSessionRotation = pallet_session::PeriodicSessions; type SessionHandler = (OtherSessionHandler,); type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; - type NextSessionRotation = pallet_session::PeriodicSessions; type WeightInfo = (); } impl pallet_session::historical::Config for Runtime { @@ -348,34 +348,126 @@ impl sp_runtime::BoundToRuntimeAppPublic for OtherSessionHandler { type Public = testing::UintAuthorityId; } -pub struct ExtBuilder { +pub struct StakingExtBuilder { validator_count: u32, minimum_validator_count: u32, - invulnerables: Vec, - has_stakers: bool, - initialize_first_session: bool, min_nominator_bond: Balance, min_validator_bond: Balance, - balance_factor: Balance, status: BTreeMap>, stakes: BTreeMap, stakers: Vec<(AccountId, AccountId, Balance, StakerStatus)>, } -impl Default for ExtBuilder { +impl Default for StakingExtBuilder { fn default() -> Self { + let stakers = vec![ + // (stash, ctrl, stake, status) + // these two will be elected in the default test where we elect 2. + (11, 10, 1000, StakerStatus::::Validator), + (21, 20, 1000, StakerStatus::::Validator), + // loser validatos if validator_count() is default. + (31, 30, 500, StakerStatus::::Validator), + (41, 40, 500, StakerStatus::::Validator), + (51, 50, 500, StakerStatus::::Validator), + (61, 60, 500, StakerStatus::::Validator), + (71, 70, 500, StakerStatus::::Validator), + (81, 80, 500, StakerStatus::::Validator), + (91, 90, 500, StakerStatus::::Validator), + (101, 100, 500, StakerStatus::::Validator), + // an idle validator + (201, 200, 1000, StakerStatus::::Idle), + ]; + Self { validator_count: 2, minimum_validator_count: 0, - balance_factor: 1, - invulnerables: vec![], - has_stakers: true, - initialize_first_session: true, min_nominator_bond: ExistentialDeposit::get(), min_validator_bond: ExistentialDeposit::get(), status: Default::default(), stakes: Default::default(), - stakers: Default::default(), + stakers, + } + } +} + +impl StakingExtBuilder { + pub fn validator_count(mut self, n: u32) -> Self { + self.validator_count = n; + self + } +} + +pub struct EpmExtBuilder {} + +impl Default for EpmExtBuilder { + fn default() -> Self { + EpmExtBuilder {} + } +} + +impl EpmExtBuilder { + pub fn phases(self, signed: BlockNumber, unsigned: BlockNumber) -> Self { + ::set(signed); + ::set(unsigned); + self + } +} + +struct BalancesExtBuilder { + balances: Vec<(AccountId, Balance)>, +} + +impl Default for BalancesExtBuilder { + fn default() -> Self { + let balances = vec![ + // (account_id, balance) + (1, 10), + (2, 20), + (3, 300), + (4, 400), + // controllers + (10, 100), + (20, 100), + (30, 100), + (40, 100), + (50, 100), + (60, 100), + (70, 100), + (80, 100), + (90, 100), + (100, 100), + (200, 100), + // stashes + (11, 1000), + (21, 2000), + (31, 3000), + (41, 4000), + (51, 5000), + (61, 6000), + (71, 7000), + (81, 8000), + (91, 9000), + (101, 10000), + (201, 20000), + // This allows us to have a total_payout different from 0. + (999, 1_000_000_000_000), + ]; + Self { balances } + } +} + +pub struct ExtBuilder { + staking_builder: StakingExtBuilder, + epm_builder: EpmExtBuilder, + balances_builder: BalancesExtBuilder, +} + +impl Default for ExtBuilder { + fn default() -> Self { + Self { + staking_builder: StakingExtBuilder::default(), + epm_builder: EpmExtBuilder::default(), + balances_builder: BalancesExtBuilder::default(), } } } @@ -386,142 +478,70 @@ impl ExtBuilder { let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); - let _ = pallet_balances::GenesisConfig:: { - balances: vec![ - (1, 10 * self.balance_factor), - (2, 20 * self.balance_factor), - (3, 300 * self.balance_factor), - (4, 400 * self.balance_factor), - // controllers - (10, self.balance_factor), - (20, self.balance_factor), - (30, self.balance_factor), - (40, self.balance_factor), - (50, self.balance_factor), - (60, self.balance_factor), - (70, self.balance_factor), - (80, self.balance_factor), - (90, self.balance_factor), - (100, self.balance_factor), - (200, self.balance_factor), - // stashes - (11, self.balance_factor * 1000), - (21, self.balance_factor * 2000), - (31, self.balance_factor * 3000), - (41, self.balance_factor * 4000), - (51, self.balance_factor * 5000), - (61, self.balance_factor * 6000), - (71, self.balance_factor * 7000), - (81, self.balance_factor * 8000), - (91, self.balance_factor * 9000), - (101, self.balance_factor * 10000), - (201, self.balance_factor * 20000), - // This allows us to have a total_payout different from 0. - (999, 1_000_000_000_000), - ], - } - .assimilate_storage(&mut storage); - - let mut stakers = vec![]; - if self.has_stakers { - stakers = vec![ - // (stash, ctrl, stake, status) - // these two will be elected in the default test where we elect 2. - (11, 10, self.balance_factor * 1000, StakerStatus::::Validator), - (21, 20, self.balance_factor * 1000, StakerStatus::::Validator), - // loser validatos if validator_count() is default. - (31, 30, self.balance_factor * 500, StakerStatus::::Validator), - (41, 40, self.balance_factor * 500, StakerStatus::::Validator), - (51, 50, self.balance_factor * 500, StakerStatus::::Validator), - (61, 60, self.balance_factor * 500, StakerStatus::::Validator), - (71, 70, self.balance_factor * 500, StakerStatus::::Validator), - (81, 80, self.balance_factor * 500, StakerStatus::::Validator), - (91, 90, self.balance_factor * 500, StakerStatus::::Validator), - (101, 100, self.balance_factor * 500, StakerStatus::::Validator), - // an idle validator - (201, 200, self.balance_factor * 1000, StakerStatus::::Idle), - ]; - // replace any of the status if needed. - self.status.into_iter().for_each(|(stash, status)| { - let (_, _, _, ref mut prev_status) = stakers - .iter_mut() - .find(|s| s.0 == stash) - .expect("set_status staker should exist; qed"); - *prev_status = status; - }); - // replaced any of the stakes if needed. - self.stakes.into_iter().for_each(|(stash, stake)| { - let (_, _, ref mut prev_stake, _) = stakers - .iter_mut() - .find(|s| s.0 == stash) - .expect("set_stake staker should exits; qed."); - *prev_stake = stake; - }); - // extend stakers if needed. - stakers.extend(self.stakers) - } + let _ = + pallet_balances::GenesisConfig:: { balances: self.balances_builder.balances } + .assimilate_storage(&mut storage); + + let mut stakers = self.staking_builder.stakers.clone(); + self.staking_builder.status.into_iter().for_each(|(stash, status)| { + let (_, _, _, ref mut prev_status) = stakers + .iter_mut() + .find(|s| s.0 == stash) + .expect("set_status staker should exist; qed"); + *prev_status = status; + }); + // replaced any of the stakes if needed. + self.staking_builder.stakes.into_iter().for_each(|(stash, stake)| { + let (_, _, ref mut prev_stake, _) = stakers + .iter_mut() + .find(|s| s.0 == stash) + .expect("set_stake staker should exits; qed."); + *prev_stake = stake; + }); let _ = pallet_staking::GenesisConfig:: { stakers: stakers.clone(), - validator_count: self.validator_count, - minimum_validator_count: self.minimum_validator_count, - invulnerables: self.invulnerables, + validator_count: self.staking_builder.validator_count, + minimum_validator_count: self.staking_builder.minimum_validator_count, slash_reward_fraction: Perbill::from_percent(10), - min_nominator_bond: self.min_nominator_bond, - min_validator_bond: self.min_validator_bond, + min_nominator_bond: self.staking_builder.min_nominator_bond, + min_validator_bond: self.staking_builder.min_validator_bond, ..Default::default() } .assimilate_storage(&mut storage); let _ = pallet_session::GenesisConfig:: { - keys: if self.has_stakers { - // set the keys for the first session. - stakers - .into_iter() - .map(|(id, ..)| (id, id, SessionKeys { other: (id as u64).into() })) - .collect() - } else { - // set some dummy validators in genesis. - (0..self.validator_count as u128) - .map(|id| (id, id, SessionKeys { other: (id as u64).into() })) - .collect() - }, + // set the keys for the first session. + keys: stakers + .into_iter() + .map(|(id, ..)| (id, id, SessionKeys { other: (id as u64).into() })) + .collect(), } .assimilate_storage(&mut storage); let mut ext = sp_io::TestExternalities::from(storage); - if self.initialize_first_session { - // We consider all test to start after timestamp is initialized This must be ensured by - // having `timestamp::on_initialize` called before `staking::on_initialize`. Also, if - // session length is 1, then it is already triggered. - ext.execute_with(|| { - System::set_block_number(1); - Session::on_initialize(1); - >::on_initialize(1); - Timestamp::set_timestamp(INIT_TIMESTAMP); - }); - } + // We consider all test to start after timestamp is initialized This must be ensured by + // having `timestamp::on_initialize` called before `staking::on_initialize`. + ext.execute_with(|| { + System::set_block_number(1); + Session::on_initialize(1); + >::on_initialize(1); + Timestamp::set_timestamp(INIT_TIMESTAMP); + }); ext } - pub fn balance_factor(mut self, factor: Balance) -> Self { - self.balance_factor = factor; - self - } - pub fn initialize_first_session(mut self, init: bool) -> Self { - self.initialize_first_session = init; + pub fn staking(mut self, builder: StakingExtBuilder) -> Self { + self.staking_builder = builder; self } - pub fn phases(self, signed: BlockNumber, unsigned: BlockNumber) -> Self { - ::set(signed); - ::set(unsigned); - self - } - pub fn validator_count(mut self, n: u32) -> Self { - self.validator_count = n; + + pub fn epm(mut self, builder: EpmExtBuilder) -> Self { + self.epm_builder = builder; self } + pub fn build_and_execute(self, test: impl FnOnce() -> ()) { self.build().execute_with(test) } From 84dfba6915ebacc509d44debf8fdc4e693862981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 15 Mar 2023 08:43:28 +0100 Subject: [PATCH 20/22] helper to set balances ext builder --- .../test-staking-e2e/src/mock.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index db08bf8ef471f..054aea1a061dc 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -413,7 +413,7 @@ impl EpmExtBuilder { } } -struct BalancesExtBuilder { +pub struct BalancesExtBuilder { balances: Vec<(AccountId, Balance)>, } @@ -542,6 +542,11 @@ impl ExtBuilder { self } + pub fn balances(mut self, builder: BalancesExtBuilder) -> Self { + self.balances_builder = builder; + self + } + pub fn build_and_execute(self, test: impl FnOnce() -> ()) { self.build().execute_with(test) } From 9829cc13fc374a0aa0600a18e491a70919328d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 15 Mar 2023 10:01:39 +0100 Subject: [PATCH 21/22] bring up mock.rs to master --- .../test-staking-e2e/Cargo.lock | 522 +++++++++++------- .../test-staking-e2e/src/mock.rs | 8 +- 2 files changed, 317 insertions(+), 213 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock index a17ce1bb0d357..b179ab7059a48 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock +++ b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock @@ -38,6 +38,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "getrandom 0.2.8", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.20" @@ -67,9 +79,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "approx" @@ -196,6 +208,17 @@ dependencies = [ "digest 0.10.6", ] +[[package]] +name = "blake2b_simd" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +dependencies = [ + "arrayref", + "arrayvec 0.7.2", + "constant_time_eq", +] + [[package]] name = "block-buffer" version = "0.7.3" @@ -235,6 +258,18 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "bounded-collections" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a071c348a5ef6da1d3a87166b408170b46002382b1dda83992b5c2208cefb370" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "serde", +] + [[package]] name = "bumpalo" version = "3.11.1" @@ -253,6 +288,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" + [[package]] name = "byteorder" version = "1.4.3" @@ -314,6 +355,12 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" +[[package]] +name = "constant_time_eq" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -340,9 +387,9 @@ dependencies = [ [[package]] name = "cranelift-entity" -version = "0.88.2" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87a0f1b2fdc18776956370cf8d9b009ded3f855350c480c1c52142510961f352" +checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705" dependencies = [ "serde", ] @@ -484,6 +531,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "derive-syn-parse" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -597,7 +655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ "curve25519-dalek 3.2.0", - "hashbrown", + "hashbrown 0.12.3", "hex", "rand_core 0.6.4", "sha2 0.9.9", @@ -656,6 +714,19 @@ dependencies = [ "libc", ] +[[package]] +name = "expander" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "fake-simd" version = "0.1.2" @@ -690,11 +761,21 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "frame-benchmarking" version = "4.0.0-dev" dependencies = [ "frame-support", + "frame-support-procedural", "frame-system", "linregress", "log", @@ -710,6 +791,7 @@ dependencies = [ "sp-runtime-interface", "sp-std", "sp-storage", + "static_assertions", ] [[package]] @@ -732,6 +814,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-arithmetic", + "sp-core", "sp-npos-elections", "sp-runtime", "sp-std", @@ -754,6 +837,7 @@ name = "frame-support" version = "4.0.0-dev" dependencies = [ "bitflags", + "environmental", "frame-metadata", "frame-support-procedural", "impl-trait-for-tuples", @@ -786,6 +870,7 @@ version = "4.0.0-dev" dependencies = [ "Inflector", "cfg-expr", + "derive-syn-parse", "frame-support-procedural-tools", "itertools", "proc-macro2", @@ -830,6 +915,12 @@ dependencies = [ "sp-weights", ] +[[package]] +name = "fs-err" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" + [[package]] name = "funty" version = "2.0.0" @@ -958,10 +1049,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -998,9 +1087,9 @@ dependencies = [ [[package]] name = "hash-db" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" +checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" [[package]] name = "hash256-std-hasher" @@ -1017,7 +1106,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", ] [[package]] @@ -1105,6 +1203,16 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -1141,7 +1249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", "serde", ] @@ -1156,9 +1264,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.7.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] [[package]] name = "itertools" @@ -1282,19 +1394,18 @@ dependencies = [ [[package]] name = "linregress" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c601a85f5ecd1aba625247bca0031585fb1c446461b142878a16f8245ddeb8" +checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" dependencies = [ "nalgebra", - "statrs", ] [[package]] name = "linux-raw-sys" -version = "0.0.46" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "lock_api" @@ -1315,15 +1426,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "lru" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" -dependencies = [ - "hashbrown", -] - [[package]] name = "mach" version = "0.3.2" @@ -1357,6 +1459,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memfd" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +dependencies = [ + "rustix", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -1368,12 +1479,11 @@ dependencies = [ [[package]] name = "memory-db" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66" +checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" dependencies = [ "hash-db", - "hashbrown", ] [[package]] @@ -1405,9 +1515,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.27.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "462fffe4002f4f2e1f6a9dcf12cc1a6fc0e15989014efc02a941d3e0f5dc2120" +checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" dependencies = [ "approx", "matrixmultiply", @@ -1415,17 +1525,15 @@ dependencies = [ "num-complex", "num-rational", "num-traits", - "rand 0.8.5", - "rand_distr", "simba", "typenum", ] [[package]] name = "nalgebra-macros" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" +checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" dependencies = [ "proc-macro2", "quote", @@ -1497,7 +1605,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -1517,7 +1624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", - "hashbrown", + "hashbrown 0.12.3", "indexmap", "memchr", ] @@ -1549,7 +1656,6 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "scale-info", - "sp-authorship", "sp-runtime", "sp-std", ] @@ -1623,7 +1729,7 @@ dependencies = [ "log", "pallet-election-provider-support-benchmarking", "parity-scale-codec", - "rand 0.7.3", + "rand 0.8.5", "scale-info", "sp-arithmetic", "sp-core", @@ -1631,7 +1737,6 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "static_assertions", "strum", ] @@ -1677,7 +1782,6 @@ dependencies = [ "frame-system", "log", "pallet-authorship", - "pallet-bags-list", "pallet-session", "parity-scale-codec", "scale-info", @@ -1708,9 +1812,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.2.1" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -1723,9 +1827,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.3" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1770,22 +1874,28 @@ checksum = "cf1c2c742266c2f1041c914ba65355a83ae8747b05f208319784083583494b4b" [[package]] name = "pbkdf2" -version = "0.4.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" dependencies = [ - "crypto-mac 0.8.0", + "crypto-mac 0.11.1", ] [[package]] name = "pbkdf2" -version = "0.8.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "crypto-mac 0.11.1", + "digest 0.10.6", ] +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1882,7 +1992,6 @@ dependencies = [ "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc", - "rand_pcg", ] [[package]] @@ -1934,16 +2043,6 @@ dependencies = [ "getrandom 0.2.8", ] -[[package]] -name = "rand_distr" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" -dependencies = [ - "num-traits", - "rand 0.8.5", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -1953,15 +2052,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", -] - [[package]] name = "rawpointer" version = "0.2.1" @@ -2054,16 +2144,16 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustix" -version = "0.35.13" +version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -2078,6 +2168,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +[[package]] +name = "safe_arch" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" +dependencies = [ + "bytemuck", +] + [[package]] name = "scale-info" version = "2.3.1" @@ -2104,6 +2203,17 @@ dependencies = [ "syn", ] +[[package]] +name = "schnellru" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" +dependencies = [ + "ahash 0.8.3", + "cfg-if", + "hashbrown 0.13.2", +] + [[package]] name = "schnorrkel" version = "0.9.1" @@ -2273,14 +2383,15 @@ dependencies = [ [[package]] name = "simba" -version = "0.5.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e82063457853d00243beda9952e910b82593e4b07ae9f721b9278a99a0d3d5c" +checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" dependencies = [ "approx", "num-complex", "num-traits", "paste", + "wide", ] [[package]] @@ -2319,7 +2430,9 @@ dependencies = [ name = "sp-api-proc-macro" version = "4.0.0-dev" dependencies = [ + "Inflector", "blake2", + "expander", "proc-macro-crate", "proc-macro2", "quote", @@ -2347,22 +2460,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-debug-derive", "sp-std", "static_assertions", ] -[[package]] -name = "sp-authorship" -version = "4.0.0-dev" -dependencies = [ - "async-trait", - "parity-scale-codec", - "sp-inherents", - "sp-runtime", - "sp-std", -] - [[package]] name = "sp-core" version = "7.0.0" @@ -2371,7 +2472,7 @@ dependencies = [ "base58", "bitflags", "blake2", - "byteorder", + "bounded-collections", "dyn-clonable", "ed25519-zebra", "futures", @@ -2382,11 +2483,10 @@ dependencies = [ "libsecp256k1", "log", "merlin", - "num-traits", "parity-scale-codec", "parking_lot", "primitive-types", - "rand 0.7.3", + "rand 0.8.5", "regex", "scale-info", "schnorrkel", @@ -2403,7 +2503,6 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", - "wasmi", "zeroize", ] @@ -2411,7 +2510,7 @@ dependencies = [ name = "sp-core-hashing" version = "5.0.0" dependencies = [ - "blake2", + "blake2b_simd", "byteorder", "digest 0.10.6", "sha2 0.10.6", @@ -2456,6 +2555,7 @@ dependencies = [ "async-trait", "impl-trait-for-tuples", "parity-scale-codec", + "scale-info", "sp-core", "sp-runtime", "sp-std", @@ -2467,13 +2567,12 @@ name = "sp-io" version = "7.0.0" dependencies = [ "bytes", + "ed25519", "ed25519-dalek", "futures", - "hash-db", "libsecp256k1", "log", "parity-scale-codec", - "parking_lot", "secp256k1", "sp-core", "sp-externalities", @@ -2483,7 +2582,6 @@ dependencies = [ "sp-std", "sp-tracing", "sp-trie", - "sp-wasm-interface", "tracing", "tracing-core", ] @@ -2535,7 +2633,7 @@ dependencies = [ "log", "parity-scale-codec", "paste", - "rand 0.7.3", + "rand 0.8.5", "scale-info", "serde", "sp-application-crypto", @@ -2593,6 +2691,7 @@ version = "4.0.0-dev" dependencies = [ "parity-scale-codec", "scale-info", + "sp-core", "sp-runtime", "sp-std", ] @@ -2603,10 +2702,9 @@ version = "0.13.0" dependencies = [ "hash-db", "log", - "num-traits", "parity-scale-codec", "parking_lot", - "rand 0.7.3", + "rand 0.8.5", "smallvec", "sp-core", "sp-externalities", @@ -2615,7 +2713,6 @@ dependencies = [ "sp-trie", "thiserror", "tracing", - "trie-root", ] [[package]] @@ -2642,7 +2739,6 @@ dependencies = [ "futures-timer", "log", "parity-scale-codec", - "sp-api", "sp-inherents", "sp-runtime", "sp-std", @@ -2664,16 +2760,16 @@ dependencies = [ name = "sp-trie" version = "7.0.0" dependencies = [ - "ahash", + "ahash 0.8.3", "hash-db", - "hashbrown", + "hashbrown 0.12.3", "lazy_static", - "lru", "memory-db", "nohash-hasher", "parity-scale-codec", "parking_lot", "scale-info", + "schnellru", "sp-core", "sp-std", "thiserror", @@ -2712,6 +2808,7 @@ dependencies = [ name = "sp-wasm-interface" version = "7.0.0" dependencies = [ + "anyhow", "impl-trait-for-tuples", "log", "parity-scale-codec", @@ -2724,7 +2821,6 @@ dependencies = [ name = "sp-weights" version = "4.0.0" dependencies = [ - "impl-trait-for-tuples", "parity-scale-codec", "scale-info", "serde", @@ -2772,19 +2868,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "statrs" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05bdbb8e4e78216a85785a85d3ec3183144f98d0097b9281802c019bb07a6f05" -dependencies = [ - "approx", - "lazy_static", - "nalgebra", - "num-traits", - "rand 0.8.5", -] - [[package]] name = "strum" version = "0.24.1" @@ -2901,17 +2984,17 @@ dependencies = [ [[package]] name = "tiny-bip39" -version = "0.8.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" dependencies = [ "anyhow", - "hmac 0.8.1", + "hmac 0.12.1", "once_cell", - "pbkdf2 0.4.0", - "rand 0.7.3", + "pbkdf2 0.11.0", + "rand 0.8.5", "rustc-hash", - "sha2 0.9.9", + "sha2 0.10.6", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -3020,12 +3103,12 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.24.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "004e1e8f92535694b4cb1444dc5a8073ecf0815e3357f729638b9f8fc4062908" +checksum = "634d75c77ea43f2ad8ea9d9c58de49dfc9c3995bdef32b503df7883ff054e7f1" dependencies = [ "hash-db", - "hashbrown", + "hashbrown 0.13.2", "log", "rustc-hex", "smallvec", @@ -3033,9 +3116,9 @@ dependencies = [ [[package]] name = "trie-root" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a36c5ca3911ed3c9a5416ee6c679042064b93fc637ded67e25f92e68d783891" +checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" dependencies = [ "hash-db", ] @@ -3076,6 +3159,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicode-bidi" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" + [[package]] name = "unicode-ident" version = "1.0.5" @@ -3103,6 +3192,17 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "valuable" version = "0.1.0" @@ -3216,18 +3316,19 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.89.1" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5d3e08b13876f96dd55608d03cd4883a0545884932d5adf11925876c96daef" +checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" dependencies = [ "indexmap", + "url", ] [[package]] name = "wasmtime" -version = "1.0.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad5af6ba38311282f2a21670d96e78266e8c8e2f38cbcd52c254df6ccbc7731" +checksum = "f6e89f9819523447330ffd70367ef4a18d8c832e24e8150fe054d1d912841632" dependencies = [ "anyhow", "bincode", @@ -3245,23 +3346,23 @@ dependencies = [ "wasmtime-environ", "wasmtime-jit", "wasmtime-runtime", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-asm-macros" -version = "1.0.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45de63ddfc8b9223d1adc8f7b2ee5f35d1f6d112833934ad7ea66e4f4339e597" +checksum = "9bd3a5e46c198032da934469f3a6e48649d1f9142438e4fd4617b68a35644b8a" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-environ" -version = "1.0.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebb881c61f4f627b5d45c54e629724974f8a8890d455bcbe634330cc27309644" +checksum = "9a6db9fc52985ba06ca601f2ff0ff1f526c5d724c7ac267b47326304b0c97883" dependencies = [ "anyhow", "cranelift-entity", @@ -3278,9 +3379,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "1.0.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1985c628011fe26adf5e23a5301bdc79b245e0e338f14bb58b39e4e25e4d8681" +checksum = "b77e3a52cd84d0f7f18554afa8060cfe564ccac61e3b0802d3fd4084772fa5f6" dependencies = [ "addr2line", "anyhow", @@ -3291,29 +3392,39 @@ dependencies = [ "log", "object", "rustc-demangle", - "rustix", "serde", "target-lexicon", - "thiserror", "wasmtime-environ", + "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-jit-debug" -version = "1.0.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f671b588486f5ccec8c5a3dba6b4c07eac2e66ab8c60e6f4e53717c77f709731" +checksum = "d0245e8a9347017c7185a72e215218a802ff561545c242953c11ba00fccc930f" dependencies = [ "once_cell", ] +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67d412e9340ab1c83867051d8d1d7c90aa8c9afc91da086088068e2734e25064" +dependencies = [ + "cfg-if", + "libc", + "windows-sys 0.42.0", +] + [[package]] name = "wasmtime-runtime" -version = "1.0.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8f92ad4b61736339c29361da85769ebc200f184361959d1792832e592a1afd" +checksum = "d594e791b5fdd4dbaf8cf7ae62f2e4ff85018ce90f483ca6f42947688e48827d" dependencies = [ "anyhow", "cc", @@ -3322,22 +3433,22 @@ dependencies = [ "libc", "log", "mach", + "memfd", "memoffset", "paste", "rand 0.8.5", "rustix", - "thiserror", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-types" -version = "1.0.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23d61cb4c46e837b431196dd06abb11731541021916d03476a178b54dc07aeb" +checksum = "a6688d6f96d4dbc1f89fab626c56c1778936d122b5f4ae7a57c2eb42b8d982e2" dependencies = [ "cranelift-entity", "serde", @@ -3345,6 +3456,16 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wide" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b689b6c49d6549434bf944e6b0f39238cf63693cb7a147e9d887507fffa3b223" +dependencies = [ + "bytemuck", + "safe_arch", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3376,19 +3497,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", -] - [[package]] name = "windows-sys" version = "0.42.0" @@ -3396,85 +3504,79 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc", ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.0" +name = "windows-sys" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] [[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" +name = "windows-targets" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] [[package]] -name = "windows_aarch64_msvc" -version = "0.42.0" +name = "windows_aarch64_gnullvm" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] -name = "windows_i686_gnu" -version = "0.36.1" +name = "windows_aarch64_msvc" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "wyz" diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 054aea1a061dc..cd23a0bbef8a7 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -38,7 +38,7 @@ use sp_staking::{ use sp_std::prelude::*; use std::collections::BTreeMap; -use frame_election_provider_support::{onchain, SequentialPhragmen, Weight}; +use frame_election_provider_support::{onchain, ElectionDataProvider, SequentialPhragmen, Weight}; use pallet_election_provider_multi_phase::{ unsigned::MinerConfig, ElectionCompute, QueuedSolution, SolutionAccuracyOf, }; @@ -222,9 +222,11 @@ impl pallet_election_provider_multi_phase::Config for Runtime { impl MinerConfig for Runtime { type AccountId = AccountId; type Solution = MockNposSolution; - type MaxVotesPerVoter = MaxNominations; + type MaxVotesPerVoter = + <::DataProvider as ElectionDataProvider>::MaxVotesPerVoter; type MaxLength = MinerMaxLength; type MaxWeight = MinerMaxWeight; + type MaxWinners = MaxWinners; fn solution_weight(_v: u32, _t: u32, _a: u32, _d: u32) -> Weight { Weight::zero() @@ -264,7 +266,7 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; - type SlashCancelOrigin = EnsureRoot; // root can cancel slashes + type AdminOrigin = EnsureRoot; // root can cancel slashes type SessionInterface = Self; type EraPayout = (); type NextNewSession = Session; From 3eb15b6e42cbb0d5b8fc94a382668b7d2efc7340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 16 Mar 2023 09:27:35 +0100 Subject: [PATCH 22/22] integration test fixes and additions --- .../test-staking-e2e/src/lib.rs | 110 +++++++++++------- .../test-staking-e2e/src/mock.rs | 88 ++++++++------ 2 files changed, 120 insertions(+), 78 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index ab5a164c64f49..c8f7d48a89ecf 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -21,6 +21,7 @@ mod mock; pub(crate) const LOG_TARGET: &str = "tests::e2e-epm"; use mock::*; +use sp_core::Get; use sp_npos_elections::{to_supports, StakedAssignment}; use sp_runtime::Perbill; @@ -50,20 +51,35 @@ fn log_current_time() { } #[test] -fn setup_works() { +fn block_progression_works() { ExtBuilder::default().build_and_execute(|| { assert_eq!(active_era(), 0); + assert_eq!(Session::current_index(), 0); + assert!(ElectionProviderMultiPhase::current_phase().is_off()); assert!(start_next_active_era().is_ok()); - assert!(start_next_active_era().is_ok()); - assert_eq!(active_era(), 2); + assert_eq!(active_era(), 1); + assert_eq!(Session::current_index(), >::get()); + + assert!(ElectionProviderMultiPhase::current_phase().is_off()); + + roll_to_epm_signed(); + assert!(ElectionProviderMultiPhase::current_phase().is_signed()); + }); + + ExtBuilder::default().build_and_execute(|| { + assert_eq!(active_era(), 0); + assert_eq!(Session::current_index(), 0); + assert!(ElectionProviderMultiPhase::current_phase().is_off()); - // if the solution is delayed, EPM will end up in emergency mode and eras won't progress. - assert!(start_next_active_era_delayed_solution().is_ok()); assert!(start_next_active_era_delayed_solution().is_ok()); + // if the solution is delayed, EPM will end up in emergency mode.. assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); - assert_eq!(active_era(), 3); - }); + // .. era won't progress.. + assert_eq!(active_era(), 0); + // .. but session does. + assert_eq!(Session::current_index(), 2); + }) } #[test] @@ -79,9 +95,11 @@ fn setup_works() { /// solution is added to EPM's `QueuedSolution` queue. This can be achieved through /// `Call::set_emergency_election_result` or `Call::governance_fallback` dispatchables. Once a new /// solution is added to the queue, EPM phase transitions to `Phase::Off` and the election flow -/// restarts. +/// restarts. Note that in this test case, the emergency throttling is disabled. fn enters_emergency_phase_after_forcing_before_elect() { - ExtBuilder::default().build_and_execute(|| { + let epm_builder = EpmExtBuilder::default().disable_emergency_throttling(); + + ExtBuilder::default().epm(epm_builder).build_and_execute(|| { log!( trace, "current validators (staking): {:?}", @@ -91,7 +109,6 @@ fn enters_emergency_phase_after_forcing_before_elect() { roll_to_epm_off(); assert!(ElectionProviderMultiPhase::current_phase().is_off()); - log_current_time(); assert_eq!(pallet_staking::ForceEra::::get(), pallet_staking::Forcing::NotForcing); // slashes so that staking goes into `Forcing::ForceNew`. @@ -104,10 +121,10 @@ fn enters_emergency_phase_after_forcing_before_elect() { log_current_time(); let era_before_delayed_next = Staking::current_era(); - // try to advance 2 eras with a delayed solution. + // try to advance 2 eras. assert!(start_next_active_era_delayed_solution().is_ok()); assert_eq!(Staking::current_era(), era_before_delayed_next); - assert!(start_next_active_era_delayed_solution().is_ok()); + assert!(start_next_active_era().is_err()); assert_eq!(Staking::current_era(), era_before_delayed_next); // EPM is still in emergency phase. @@ -131,8 +148,7 @@ fn enters_emergency_phase_after_forcing_before_elect() { // EPM can now roll to signed phase to proceed with elections. The validator set is the // expected (ie. set through `set_emergency_election_result`). roll_to_epm_signed(); - log_current_time(); - assert!(ElectionProviderMultiPhase::current_phase().is_signed()); + //assert!(ElectionProviderMultiPhase::current_phase().is_signed()); assert_eq!(Session::validators(), vec![21, 31, 41]); assert_eq!(Staking::current_era(), era_before_delayed_next.map(|e| e + 1)); }); @@ -150,35 +166,41 @@ fn enters_emergency_phase_after_forcing_before_elect() { /// fail and enter in emenergency mode. fn continous_slashes_below_offending_threshold() { let staking_builder = StakingExtBuilder::default().validator_count(10); - - ExtBuilder::default().staking(staking_builder).build_and_execute(|| { - assert_eq!(Session::validators().len(), 10); - let mut active_validator_set = Session::validators(); - - // set a minimum election score. - assert!(set_minimum_election_score(500, 1000, 500).is_ok()); - - // slash 10% of the active validators and progress era until the minimum trusted score - // is reached. - while active_validator_set.len() > 0 { - let slashed = slash_percentage(Perbill::from_percent(10)); - assert_eq!(slashed.len(), 1); - - // break loop when era does not progress; EPM is in emergency phase as election - // failed due to election minimum score. - if start_next_active_era().is_err() { - assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); - break + let epm_builder = EpmExtBuilder::default().disable_emergency_throttling(); + + ExtBuilder::default() + .staking(staking_builder) + .epm(epm_builder) + .build_and_execute(|| { + assert_eq!(Session::validators().len(), 10); + let mut active_validator_set = Session::validators(); + + roll_to_epm_signed(); + + // set a minimum election score. + assert!(set_minimum_election_score(500, 1000, 500).is_ok()); + + // slash 10% of the active validators and progress era until the minimum trusted score + // is reached. + while active_validator_set.len() > 0 { + let slashed = slash_percentage(Perbill::from_percent(10)); + assert_eq!(slashed.len(), 1); + + // break loop when era does not progress; EPM is in emergency phase as election + // failed due to election minimum score. + if start_next_active_era().is_err() { + assert!(ElectionProviderMultiPhase::current_phase().is_emergency()); + break + } + + active_validator_set = Session::validators(); + + log!( + trace, + "slashed 10% of active validators ({:?}). After slash: {:?}", + slashed, + active_validator_set + ); } - - active_validator_set = Session::validators(); - - log!( - trace, - "slashed 10% of active validators ({:?}). After slash: {:?}", - slashed, - active_validator_set - ); - } - }); + }); } diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index cd23a0bbef8a7..19f568737c852 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -44,7 +44,7 @@ use pallet_election_provider_multi_phase::{ }; use pallet_staking::StakerStatus; -use crate::log_current_time; +use crate::{log, log_current_time}; pub const INIT_TIMESTAMP: u64 = 30_000; pub const BLOCK_TIME: u64 = 1000; @@ -135,7 +135,7 @@ impl pallet_timestamp::Config for Runtime { } parameter_types! { - pub static Period: BlockNumber = 15; + pub static Period: BlockNumber = 30; pub static Offset: BlockNumber = 0; } @@ -173,7 +173,10 @@ frame_election_provider_support::generate_solution_type!( parameter_types! { pub static SignedPhase: BlockNumber = 10; - pub static UnsignedPhase: BlockNumber = 5; + pub static UnsignedPhase: BlockNumber = 10; + // we expect a minimum of 3 blocks in signed phase and unsigned phases before trying + // enetering in emergency phase after the election failed. + pub static MinBlocksBeforeEmergency: BlockNumber = 3; pub static MaxElectingVoters: VoterIndex = 1000; pub static MaxElectableTargets: TargetIndex = 1000; pub static MaxActiveValidators: u32 = 1000; @@ -408,6 +411,11 @@ impl Default for EpmExtBuilder { } impl EpmExtBuilder { + pub fn disable_emergency_throttling(self) -> Self { + ::set(0); + self + } + pub fn phases(self, signed: BlockNumber, unsigned: BlockNumber) -> Self { ::set(signed); ::set(unsigned); @@ -562,38 +570,37 @@ pub fn roll_to(n: BlockNumber, delay_solution: bool) { Session::on_initialize(b); Timestamp::set_timestamp(System::block_number() * BLOCK_TIME + INIT_TIMESTAMP); - // if EPM is in off phase, there's no solution and the solution should not be delayed, try - // "minining" and queue a solution. - if ElectionProviderMultiPhase::snapshot().is_none() && - ElectionProviderMultiPhase::current_phase().is_off() && - !delay_solution - { - ElectionProviderMultiPhase::on_initialize(n); - let _ = try_queue_solution(ElectionCompute::Signed); - } else { - ElectionProviderMultiPhase::on_initialize(n); - }; + // TODO(gpestana): implement a realistic OCW worker insted of simulating it + // https://github.com/paritytech/substrate/issues/13589 + // if there's no solution queued and the solution should not be delayed, try mining and + // queue a solution. + if ElectionProviderMultiPhase::current_phase().is_signed() && !delay_solution { + let _ = try_queue_solution(ElectionCompute::Signed).map_err(|e| { + log!(info, "failed to mine/queue solution: {:?}", e); + }); + } + ElectionProviderMultiPhase::on_initialize(b); + Staking::on_initialize(b); if b != n { Staking::on_finalize(System::block_number()); } - } - log_current_time(); -} -// Progress one block. -pub fn roll_one(delay_solution: bool) { - roll_to(System::block_number() + 1, delay_solution); + log_current_time(); + } } -/// Progresses from the current block number (whatever that may be) to the `P * session_index + 1`. +/// Progresses from the current block number (whatever that may be) to the block where the session +/// `session_index` starts. pub(crate) fn start_session(session_index: SessionIndex, delay_solution: bool) { let end: u64 = if Offset::get().is_zero() { - (session_index as u64) * Period::get() + Period::get() * (session_index as u64) } else { - Offset::get() + (session_index.saturating_sub(1) as u64) * Period::get() + Offset::get() * (session_index as u64) + Period::get() * (session_index as u64) }; + assert!(end >= System::block_number()); + roll_to(end, delay_solution); // session must have progressed properly. @@ -617,10 +624,29 @@ pub(crate) fn advance_session_delayed_solution() { start_session(current_index + 1, true); } +pub(crate) fn start_next_active_era() -> Result<(), ()> { + start_active_era(active_era() + 1, false) +} + +pub(crate) fn start_next_active_era_delayed_solution() -> Result<(), ()> { + start_active_era(active_era() + 1, true) +} + /// Progress until the given era. pub(crate) fn start_active_era(era_index: EraIndex, delay_solution: bool) -> Result<(), ()> { + let era_before = current_era(); + start_session((era_index * >::get()).into(), delay_solution); + log!( + info, + "start_active_era - era_before: {}, current era: {} -> progress to: {} -> after era: {}", + era_before, + active_era(), + era_index, + current_era(), + ); + // if the solution was not delayed, era should have progressed. if !delay_solution && (active_era() != era_index || current_era() != active_era()) { Err(()) @@ -629,14 +655,6 @@ pub(crate) fn start_active_era(era_index: EraIndex, delay_solution: bool) -> Res } } -pub(crate) fn start_next_active_era() -> Result<(), ()> { - start_active_era(active_era() + 1, false) -} - -pub(crate) fn start_next_active_era_delayed_solution() -> Result<(), ()> { - start_active_era(active_era() + 1, true) -} - pub(crate) fn active_era() -> EraIndex { Staking::active_era().unwrap().index } @@ -676,13 +694,15 @@ pub fn roll_to_epm_off() { } // Queue a solution based on the current snapshot. -pub(crate) fn try_queue_solution(when: ElectionCompute) -> Result<(), ()> { - let raw_solution = ElectionProviderMultiPhase::mine_solution().map_err(|_| ())?; +pub(crate) fn try_queue_solution(when: ElectionCompute) -> Result<(), String> { + let raw_solution = ElectionProviderMultiPhase::mine_solution() + .map_err(|e| format!("error mining solution: {:?}", e))?; + ElectionProviderMultiPhase::feasibility_check(raw_solution.0, when) .map(|ready| { QueuedSolution::::put(ready); }) - .map_err(|_| ()) + .map_err(|e| format!("error in solution feasibility: {:?}", e)) } pub(crate) fn on_offence_now(