diff --git a/Cargo.lock b/Cargo.lock index 2e00f515d318e..536a26ac20614 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,9 +23,9 @@ dependencies = [ [[package]] name = "adler" -version = "0.2.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aead" @@ -131,9 +131,9 @@ dependencies = [ [[package]] name = "arbitrary" -version = "0.4.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db55d72333851e17d572bec876e390cd3b11eb1ef53ae821dd9f3b653d2b4569" +checksum = "698b65a961a9d730fb45b6b0327e20207810c9f61ee421b082b27ba003f49e2b" [[package]] name = "arrayref" @@ -177,10 +177,11 @@ dependencies = [ [[package]] name = "assert_cmd" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dc1679af9a1ab4bea16f228b05d18f8363f8327b1fa8db00d2760cfafc6b61e" +checksum = "f2475b58cd94eb4f70159f4fd8844ba3b807532fe3131b3373fae060bbe30396" dependencies = [ + "bstr", "doc-comment", "predicates", "predicates-core", @@ -190,9 +191,9 @@ dependencies = [ [[package]] name = "assert_matches" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "695579f0f2520f3774bb40461e5adb066459d4e0af4d59d20175484fb8e9edf1" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-attributes" @@ -206,9 +207,9 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.5.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59740d83946db6a5af71ae25ddf9562c2b176b2ca42cf99a455f09f4a220d6b9" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" dependencies = [ "concurrent-queue", "event-listener", @@ -285,13 +286,13 @@ dependencies = [ [[package]] name = "async-process" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8cea09c1fb10a317d1b5af8024eeba256d6554763e85ecd90ff8df31c7bbda" +checksum = "ef37b86e2fa961bae5a4d212708ea0154f904ce31d1a4a7f47e1bbc33a0c040b" dependencies = [ "async-io", "blocking", - "cfg-if 0.1.10", + "cfg-if 1.0.0", "event-listener", "futures-lite", "once_cell", @@ -311,7 +312,7 @@ dependencies = [ "async-io", "async-lock", "async-process", - "crossbeam-utils 0.8.1", + "crossbeam-utils 0.8.3", "futures-channel", "futures-core", "futures-io", @@ -322,7 +323,7 @@ dependencies = [ "memchr", "num_cpus", "once_cell", - "pin-project-lite 0.2.5", + "pin-project-lite 0.2.6", "pin-utils", "slab", "wasm-bindgen-futures", @@ -336,9 +337,9 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-trait" -version = "0.1.42" +version = "0.1.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" +checksum = "7e098e9c493fdf92832223594d9a164f96bdf17ba81a42aff86f85c76768726a" dependencies = [ "proc-macro2", "quote", @@ -355,7 +356,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.5", + "pin-project-lite 0.2.6", ] [[package]] @@ -368,7 +369,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.5", + "pin-project-lite 0.2.6", ] [[package]] @@ -443,9 +444,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bincode" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" +checksum = "d175dfa69e619905c4c3cdb7c3c203fa3bdd5d51184e3afdb2742c0280493772" dependencies = [ "byteorder", "serde", @@ -483,9 +484,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bitvec" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5011ffc90248764d7005b0e10c7294f5aa1bd87d9dd7248f4ad475b347c294d" +checksum = "1f682656975d3a682daff957be4ddeb65d6ad656737cd821f2d00685ae466af1" dependencies = [ "funty", "radium", @@ -560,7 +561,7 @@ dependencies = [ "block-padding 0.1.5", "byte-tools", "byteorder", - "generic-array 0.12.3", + "generic-array 0.12.4", ] [[package]] @@ -619,9 +620,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" dependencies = [ "lazy_static", "memchr", @@ -640,9 +641,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.6.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "byte-slice-cast" @@ -658,9 +659,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "bytes" @@ -724,9 +725,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" dependencies = [ "jobserver", ] @@ -806,9 +807,9 @@ dependencies = [ [[package]] name = "cid" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d88f30b1e74e7063df5711496f3ee6e74a9735d62062242d70cddf77717f18e" +checksum = "ff0e3bc0b6446b3f9663c1a6aba6ef06c5aeaa1bc92bd18077be337198ab9768" dependencies = [ "multibase", "multihash", @@ -887,12 +888,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "const_fn" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" - [[package]] name = "constant_time_eq" version = "0.1.5" @@ -1083,7 +1078,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.1", + "crossbeam-utils 0.8.3", ] [[package]] @@ -1104,8 +1099,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch 0.9.1", - "crossbeam-utils 0.8.1", + "crossbeam-epoch 0.9.3", + "crossbeam-utils 0.8.3", ] [[package]] @@ -1125,13 +1120,12 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" +checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" dependencies = [ "cfg-if 1.0.0", - "const_fn", - "crossbeam-utils 0.8.1", + "crossbeam-utils 0.8.3", "lazy_static", "memoffset 0.6.1", "scopeguard", @@ -1161,9 +1155,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" dependencies = [ "autocfg", "cfg-if 1.0.0", @@ -1182,7 +1176,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", "subtle 1.0.0", ] @@ -1198,9 +1192,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", @@ -1229,9 +1223,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10bcb9d7dcbf7002aaffbb53eac22906b64cdcc127971dcc387d8eb7c95d5560" +checksum = "e8f45d9ad417bcef4817d614a501ab55cdd96a6fdb24f49aab89a54acfd66b19" dependencies = [ "quote", "syn", @@ -1323,7 +1317,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", ] [[package]] @@ -1489,9 +1483,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" dependencies = [ "atty", "humantime 2.1.0", @@ -1548,7 +1542,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", ] [[package]] @@ -1620,7 +1614,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6447e2f8178843749e8c8003206def83ec124a7859475395777a28b5338647c" dependencies = [ "either", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "log", "num-traits", @@ -1675,9 +1669,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ "matches", "percent-encoding 2.1.0", @@ -1725,6 +1719,19 @@ dependencies = [ "structopt", ] +[[package]] +name = "frame-election-provider-support" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-arithmetic", + "sp-npos-elections", + "sp-runtime", + "sp-std", +] + [[package]] name = "frame-executive" version = "3.0.0" @@ -1899,6 +1906,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "fs_extra" version = "1.2.0" @@ -1935,15 +1952,15 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" +checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" dependencies = [ "futures-channel", "futures-core", @@ -1956,9 +1973,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" +checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" dependencies = [ "futures-core", "futures-sink", @@ -1966,9 +1983,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" +checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" [[package]] name = "futures-cpupool" @@ -1976,7 +1993,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" dependencies = [ - "futures 0.1.30", + "futures 0.1.31", "num_cpus", ] @@ -1986,8 +2003,8 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdcef58a173af8148b182684c9f2d5250875adbcaff7b5794073894f9d8634a9" dependencies = [ - "futures 0.1.30", - "futures 0.3.12", + "futures 0.1.31", + "futures 0.3.13", "lazy_static", "log", "parking_lot 0.9.0", @@ -1998,9 +2015,9 @@ dependencies = [ [[package]] name = "futures-executor" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" +checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1" dependencies = [ "futures-core", "futures-task", @@ -2010,9 +2027,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" +checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" [[package]] name = "futures-lite" @@ -2025,15 +2042,15 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.5", + "pin-project-lite 0.2.6", "waker-fn", ] [[package]] name = "futures-macro" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" +checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -2054,18 +2071,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" +checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3" [[package]] name = "futures-task" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" -dependencies = [ - "once_cell", -] +checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" [[package]] name = "futures-timer" @@ -2085,11 +2099,11 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" +checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" dependencies = [ - "futures 0.1.30", + "futures 0.1.31", "futures-channel", "futures-core", "futures-io", @@ -2097,7 +2111,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.5", + "pin-project-lite 0.2.6", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -2112,18 +2126,18 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ "typenum", ] [[package]] name = "generic-array" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed1e761351b56f54eb9dcd0cfaca9fd0daecf93918e1cfc01c8a3d26ee7adcd" +checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309" dependencies = [ "typenum", ] @@ -2226,7 +2240,7 @@ dependencies = [ "byteorder", "bytes 0.4.12", "fnv", - "futures 0.1.30", + "futures 0.1.31", "http 0.1.21", "indexmap", "log", @@ -2263,9 +2277,9 @@ checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "handlebars" -version = "3.5.2" +version = "3.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "964d0e99a61fe9b1b347389b77ebf8b7e1587b70293676aaca7d27e59b9073b2" +checksum = "cdb0867bbc5a3da37a753e78021d5fcf8a4db00e18dd2dd90fd36e24190e162d" dependencies = [ "log", "pest", @@ -2319,9 +2333,9 @@ dependencies = [ [[package]] name = "hex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" @@ -2362,15 +2376,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" dependencies = [ "digest 0.8.1", - "generic-array 0.12.3", + "generic-array 0.12.4", "hmac 0.7.1", ] [[package]] name = "honggfuzz" -version = "0.5.52" +version = "0.5.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ead88897bcad1c396806d6ccba260a0363e11da997472e9e19ab9889969083a2" +checksum = "bea09577d948a98a5f59b7c891e274c4fb35ad52f67782b3d0cb53b9c05301f1" dependencies = [ "arbitrary", "lazy_static", @@ -2406,7 +2420,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "http 0.1.21", "tokio-buf", ] @@ -2423,9 +2437,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "615caabe2c3160b313d52ccc905335f4ed5f10881dd63dc5699d47e90be85691" [[package]] name = "httpdate" @@ -2450,12 +2464,12 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.12.35" +version = "0.12.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" +checksum = "5c843caf6296fc1f93444735205af9ed4e109a539005abb2564ae1d6fad34c52" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "futures-cpupool", "h2 0.1.26", "http 0.1.21", @@ -2480,9 +2494,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.13.9" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf" +checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" dependencies = [ "bytes 0.5.6", "futures-channel", @@ -2494,7 +2508,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.4", + "pin-project 1.0.5", "socket2", "tokio 0.2.25", "tower-service", @@ -2511,7 +2525,7 @@ dependencies = [ "bytes 0.5.6", "ct-logs", "futures-util", - "hyper 0.13.9", + "hyper 0.13.10", "log", "rustls 0.18.1", "rustls-native-certs", @@ -2533,9 +2547,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" dependencies = [ "matches", "unicode-bidi", @@ -2570,7 +2584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b8538953a3f0d0d3868f0a706eb4273535e10d72acb5c82c1c23ae48835c85" dependencies = [ "async-io", - "futures 0.3.12", + "futures 0.3.13", "futures-lite", "if-addrs", "ipnet", @@ -2610,9 +2624,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", "hashbrown", @@ -2646,7 +2660,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64fa110ec7b8f493f416eed552740d10e7030ad5f63b2308f82c9608ec2df275" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "futures-timer 2.0.2", ] @@ -2706,9 +2720,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" dependencies = [ "wasm-bindgen", ] @@ -2720,8 +2734,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "489b9c612e60c766f751ab40fcb43cbb55a1e10bb44a9b4307ed510ca598cbd7" dependencies = [ "failure", - "futures 0.1.30", - "hyper 0.12.35", + "futures 0.1.31", + "hyper 0.12.36", "jsonrpc-core", "jsonrpc-pubsub", "log", @@ -2736,7 +2750,7 @@ version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0745a6379e3edc893c84ec203589790774e4247420033e71a76d3ab4687991fa" dependencies = [ - "futures 0.1.30", + "futures 0.1.31", "log", "serde", "serde_derive", @@ -2770,7 +2784,7 @@ version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb5c4513b7b542f42da107942b7b759f27120b5cc894729f88254b28dff44b7" dependencies = [ - "hyper 0.12.35", + "hyper 0.12.36", "jsonrpc-core", "jsonrpc-server-utils", "log", @@ -2843,8 +2857,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "124797a4ea7430d0675db78e065e53316e3f1a3cbf0ee4d6dbdd42db7b08e193" dependencies = [ "async-trait", - "futures 0.3.12", - "hyper 0.13.9", + "futures 0.3.13", + "hyper 0.13.10", "jsonrpsee-types", "jsonrpsee-utils", "log", @@ -2852,7 +2866,7 @@ dependencies = [ "serde_json", "thiserror", "unicase", - "url 2.2.0", + "url 2.2.1", ] [[package]] @@ -2874,7 +2888,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a8cd20c190e75dc56f7543b9d5713c3186351b301b5507ea6b85d8c403aac78" dependencies = [ "async-trait", - "futures 0.3.12", + "futures 0.3.13", "log", "serde", "serde_json", @@ -2888,9 +2902,9 @@ version = "0.2.0-alpha" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0e45394ec3175a767c3c5bac584560e6ad9b56ebd73216c85ec8bab49619244" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "globset", - "hyper 0.13.9", + "hyper 0.13.10", "jsonrpsee-types", "lazy_static", "log", @@ -2978,7 +2992,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb1e98ba343d0b35f9009a8844cd2b87fa3192f7e79033ac05b00aeae0f3b0b5" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "js-sys", "kvdb", "kvdb-memorydb", @@ -3010,9 +3024,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.84" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff" +checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" [[package]] name = "libloading" @@ -3038,7 +3052,7 @@ checksum = "adc225a49973cf9ab10d0cdd6a4b8f0cda299df9b760824bbb623f15f8f0c95a" dependencies = [ "atomic", "bytes 1.0.1", - "futures 0.3.12", + "futures 0.3.13", "lazy_static", "libp2p-core", "libp2p-deflate", @@ -3063,7 +3077,7 @@ dependencies = [ "libp2p-yamux", "parity-multiaddr", "parking_lot 0.11.1", - "pin-project 1.0.4", + "pin-project 1.0.5", "smallvec 1.6.1", "wasm-timer", ] @@ -3079,7 +3093,7 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "lazy_static", "libsecp256k1", @@ -3088,7 +3102,7 @@ dependencies = [ "multistream-select", "parity-multiaddr", "parking_lot 0.11.1", - "pin-project 1.0.4", + "pin-project 1.0.5", "prost", "prost-build", "rand 0.7.3", @@ -3109,7 +3123,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d42eed63305f0420736fa487f9acef720c4528bd7852a6a760f5ccde4813345" dependencies = [ "flate2", - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", ] @@ -3119,7 +3133,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5153b6db68fd4baa3b304e377db744dd8fea8ff4e4504509ee636abcde88d3e3" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "log", ] @@ -3132,7 +3146,7 @@ checksum = "b3c63dfa06581b24b1d12bf9815b43689a784424be217d6545c800c7c75a207f" dependencies = [ "cuckoofilter", "fnv", - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "libp2p-swarm", "log", @@ -3153,7 +3167,7 @@ dependencies = [ "byteorder", "bytes 1.0.1", "fnv", - "futures 0.3.12", + "futures 0.3.13", "hex_fmt", "libp2p-core", "libp2p-swarm", @@ -3174,7 +3188,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b40fb36a059b7a8cce1514bd8b546fa612e006c9937caa7f5950cb20021fe91e" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "libp2p-swarm", "log", @@ -3195,7 +3209,7 @@ dependencies = [ "bytes 1.0.1", "either", "fnv", - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "libp2p-swarm", "log", @@ -3219,7 +3233,7 @@ dependencies = [ "async-io", "data-encoding", "dns-parser", - "futures 0.3.12", + "futures 0.3.13", "if-watch", "lazy_static", "libp2p-core", @@ -3239,7 +3253,7 @@ checksum = "350ce8b3923594aedabd5d6e3f875d058435052a29c3f32df378bc70d10be464" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.0.1", - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "log", "nohash-hasher", @@ -3257,7 +3271,7 @@ checksum = "4aca322b52a0c5136142a7c3971446fb1e9964923a526c9cc6ef3b7c94e57778" dependencies = [ "bytes 1.0.1", "curve25519-dalek 3.0.2", - "futures 0.3.12", + "futures 0.3.13", "lazy_static", "libp2p-core", "log", @@ -3277,7 +3291,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f3813276d0708c8db0f500d8beda1bda9ad955723b9cb272c41f4727256f73c" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "libp2p-swarm", "log", @@ -3294,7 +3308,7 @@ checksum = "9d58defcadb646ae4b033e130b48d87410bf76394dc3335496cae99dac803e61" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.0.1", - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "log", "prost", @@ -3309,9 +3323,9 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce3374f3b28162db9d3442c9347c4f14cb01e8290052615c7d341d40eae0599" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "log", - "pin-project 1.0.4", + "pin-project 1.0.5", "rand 0.7.3", "salsa20", "sha3", @@ -3325,7 +3339,7 @@ checksum = "10e5552827c33d8326502682da73a0ba4bfa40c1b55b216af3c303f32169dd89" dependencies = [ "async-trait", "bytes 1.0.1", - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "libp2p-swarm", "log", @@ -3344,7 +3358,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7955b973e1fd2bd61ffd43ce261c1223f61f4aacd5bae362a924993f9a25fd98" dependencies = [ "either", - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "log", "rand 0.7.3", @@ -3370,7 +3384,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88a5aef80e519a6cb8e2663605142f97baaaea1a252eecbf8756184765f7471b" dependencies = [ "async-io", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "if-watch", "ipnet", @@ -3387,7 +3401,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80ac51ce419f60be966e02103c17f67ff5dc4422ba83ba54d251d6c62a4ed487" dependencies = [ "async-std", - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "log", ] @@ -3398,7 +3412,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6149c46cb76935c80bc8be6ec6e3ebd5f5e1679765a255fb34331d54610f15dd" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "js-sys", "libp2p-core", "parity-send-wrapper", @@ -3413,14 +3427,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3b1c6a3431045da8b925ed83384e4c5163e14b990572307fca9c507435d4d22" dependencies = [ "either", - "futures 0.3.12", + "futures 0.3.13", "futures-rustls", "libp2p-core", "log", "quicksink", "rw-stream-sink", "soketto", - "url 2.2.0", + "url 2.2.1", "webpki-roots", ] @@ -3430,7 +3444,7 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4819358c542a86ff95f6ae691efb4b94ddaf477079b01a686f5705b79bfc232a" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "libp2p-core", "parking_lot 0.11.1", "thiserror", @@ -3619,9 +3633,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e73be3b7d04a0123e933fea1d50d126cc7196bbc0362c0ce426694f777194eee" +checksum = "04e3e85b970d650e2ae6d70592474087051c11c54da7f7b4949725c5735fbcc6" dependencies = [ "libc", ] @@ -3675,18 +3689,18 @@ dependencies = [ [[package]] name = "minicbor" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3265a9f5210bb726f81ef9c456ae0aff5321cd95748c0e71889b0e19d8f0332b" +checksum = "1c2b2c73f9640fccab53947e2b3474d5071fcbc8f82cac51ddf6c8041a30a9ea" dependencies = [ "minicbor-derive", ] [[package]] name = "minicbor-derive" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130b9455e28a3f308f6579671816a6f2621e2e0cbf55dc2f886345bef699481e" +checksum = "19ce18b5423c573a13e80cb3046ea0af6379ef725dc3af4886bdb8f4e5093068" dependencies = [ "proc-macro2", "quote", @@ -3695,9 +3709,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", "autocfg", @@ -3835,16 +3849,16 @@ checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" [[package]] name = "multistream-select" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10ddc0eb0117736f19d556355464fc87efc8ad98b29e3fd84f02531eb6e90840" +checksum = "7d91ec0a2440aaff5f78ec35631a7027d50386c6163aa975f7caa0d5da4b6ff8" dependencies = [ "bytes 1.0.1", - "futures 0.3.12", + "futures 0.3.13", "log", - "pin-project 1.0.4", + "pin-project 1.0.5", "smallvec 1.6.1", - "unsigned-varint 0.6.0", + "unsigned-varint 0.7.0", ] [[package]] @@ -3854,7 +3868,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6b6147c3d50b4f3cdabfe2ecc94a0191fd3d6ad58aefd9664cf396285883486" dependencies = [ "approx", - "generic-array 0.13.2", + "generic-array 0.13.3", "matrixmultiply", "num-complex", "num-rational", @@ -3913,7 +3927,7 @@ version = "0.8.0" dependencies = [ "derive_more", "fs_extra", - "futures 0.3.12", + "futures 0.3.13", "hash-db", "hex", "kvdb", @@ -3949,7 +3963,7 @@ dependencies = [ name = "node-browser-testing" version = "2.0.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "jsonrpc-core", "libp2p", @@ -3971,7 +3985,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-support", "frame-system", - "futures 0.3.12", + "futures 0.3.13", "hex-literal", "libp2p-wasm-ext", "log", @@ -4143,8 +4157,8 @@ dependencies = [ name = "node-rpc-client" version = "2.0.0" dependencies = [ - "futures 0.1.30", - "hyper 0.12.35", + "futures 0.1.31", + "hyper 0.12.36", "jsonrpc-core-client", "log", "node-primitives", @@ -4309,7 +4323,7 @@ dependencies = [ "frame-support", "frame-system", "fs_extra", - "futures 0.3.12", + "futures 0.3.13", "log", "node-executor", "node-primitives", @@ -4448,9 +4462,9 @@ checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" [[package]] name = "once_cell" -version = "1.5.2" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" dependencies = [ "parking_lot 0.11.1", ] @@ -4588,6 +4602,7 @@ name = "pallet-babe" version = "3.0.0" dependencies = [ "frame-benchmarking", + "frame-election-provider-support", "frame-support", "frame-system", "log", @@ -4604,7 +4619,6 @@ dependencies = [ "sp-consensus-babe", "sp-consensus-vrf", "sp-core", - "sp-election-providers", "sp-io", "sp-runtime", "sp-session", @@ -4771,6 +4785,7 @@ name = "pallet-election-provider-multi-phase" version = "3.0.0" dependencies = [ "frame-benchmarking", + "frame-election-provider-support", "frame-support", "frame-system", "hex-literal", @@ -4783,7 +4798,6 @@ dependencies = [ "serde", "sp-arithmetic", "sp-core", - "sp-election-providers", "sp-io", "sp-npos-elections", "sp-runtime", @@ -4900,6 +4914,7 @@ version = "3.0.0" dependencies = [ "finality-grandpa", "frame-benchmarking", + "frame-election-provider-support", "frame-support", "frame-system", "log", @@ -4914,7 +4929,6 @@ dependencies = [ "serde", "sp-application-crypto", "sp-core", - "sp-election-providers", "sp-finality-grandpa", "sp-io", "sp-keyring", @@ -5014,7 +5028,7 @@ name = "pallet-mmr" version = "3.0.0" dependencies = [ "ckb-merkle-mountain-range", - "env_logger 0.8.2", + "env_logger 0.8.3", "frame-benchmarking", "frame-support", "frame-system", @@ -5130,6 +5144,7 @@ name = "pallet-offences-benchmarking" version = "3.0.0" dependencies = [ "frame-benchmarking", + "frame-election-provider-support", "frame-support", "frame-system", "pallet-babe", @@ -5144,7 +5159,6 @@ dependencies = [ "parity-scale-codec", "serde", "sp-core", - "sp-election-providers", "sp-io", "sp-runtime", "sp-staking", @@ -5257,6 +5271,7 @@ name = "pallet-session-benchmarking" version = "3.0.0" dependencies = [ "frame-benchmarking", + "frame-election-provider-support", "frame-support", "frame-system", "pallet-balances", @@ -5268,7 +5283,6 @@ dependencies = [ "rand 0.7.3", "serde", "sp-core", - "sp-election-providers", "sp-io", "sp-runtime", "sp-session", @@ -5297,6 +5311,7 @@ name = "pallet-staking" version = "3.0.0" dependencies = [ "frame-benchmarking", + "frame-election-provider-support", "frame-support", "frame-system", "hex", @@ -5312,7 +5327,6 @@ dependencies = [ "serde", "sp-application-crypto", "sp-core", - "sp-election-providers", "sp-io", "sp-npos-elections", "sp-runtime", @@ -5328,6 +5342,7 @@ dependencies = [ name = "pallet-staking-fuzz" version = "0.0.0" dependencies = [ + "frame-election-provider-support", "frame-support", "frame-system", "honggfuzz", @@ -5340,7 +5355,6 @@ dependencies = [ "parity-scale-codec", "serde", "sp-core", - "sp-election-providers", "sp-io", "sp-npos-elections", "sp-runtime", @@ -5522,12 +5536,13 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111e193c96758d476d272093a853882668da17489f76bf4361b8decae0b6c515" +checksum = "495197c078e54b8735181aa35c00a327f7f3a3cc00a1ee8c95926dd010f0ec6b" dependencies = [ "blake2-rfc", "crc32fast", + "fs2", "hex", "libc", "log", @@ -5551,14 +5566,14 @@ dependencies = [ "serde", "static_assertions", "unsigned-varint 0.7.0", - "url 2.2.0", + "url 2.2.1", ] [[package]] name = "parity-scale-codec" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c823fdae1bb5ff5708ee61a62697e6296175dc671710876871c853f48592b3" +checksum = "0cd3dab59b5cf4bc81069ade0fc470341a1ef3ad5fa73e5a8943bed2ec12b2e8" dependencies = [ "arrayvec 0.5.2", "bitvec", @@ -5569,9 +5584,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9029e65297c7fd6d7013f0579e193ec2b34ae78eabca854c9417504ad8a2d214" +checksum = "fa04976a81fde04924b40cc4036c4d12841e8bb04325a5cf2ada75731a150a7d" dependencies = [ "proc-macro-crate 0.1.5", "proc-macro2", @@ -5592,7 +5607,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e57fea504fea33f9fbb5f49f378359030e7e026a6ab849bb9e8f0787376f1bf" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "libc", "log", "mio-named-pipes", @@ -5661,7 +5676,7 @@ dependencies = [ "rand 0.7.3", "sha-1 0.8.2", "slab", - "url 2.2.0", + "url 2.2.1", ] [[package]] @@ -5699,7 +5714,7 @@ checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", "lock_api 0.4.2", - "parking_lot_core 0.8.2", + "parking_lot_core 0.8.3", ] [[package]] @@ -5733,14 +5748,14 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall 0.1.57", + "redox_syscall 0.2.5", "smallvec 1.6.1", "winapi 0.3.9", ] @@ -5877,11 +5892,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b70b68509f17aa2857863b6fa00bf21fc93674c7a8893de2f469f6aa7ca2f2" +checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63" dependencies = [ - "pin-project-internal 1.0.4", + "pin-project-internal 1.0.5", ] [[package]] @@ -5897,9 +5912,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" +checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b" dependencies = [ "proc-macro2", "quote", @@ -5914,9 +5929,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cf491442e4b033ed1c722cb9f0df5fcfcf4de682466c46469c36bc47dc5548a" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] name = "pin-utils" @@ -6232,7 +6247,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ - "env_logger 0.8.2", + "env_logger 0.8.3", "log", "rand 0.8.3", ] @@ -6250,9 +6265,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] @@ -6438,7 +6453,7 @@ checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ "crossbeam-channel", "crossbeam-deque 0.8.0", - "crossbeam-utils 0.8.1", + "crossbeam-utils 0.8.3", "lazy_static", "num_cpus", ] @@ -6460,9 +6475,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" dependencies = [ "bitflags", ] @@ -6485,7 +6500,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ "getrandom 0.2.2", - "redox_syscall 0.2.4", + "redox_syscall 0.2.5", ] [[package]] @@ -6564,7 +6579,7 @@ name = "remote-externalities" version = "0.9.0" dependencies = [ "async-std", - "env_logger 0.8.2", + "env_logger 0.8.3", "hex-literal", "jsonrpsee-http-client", "jsonrpsee-proc-macros", @@ -6592,9 +6607,9 @@ checksum = "53552c6c49e1e13f1a203ef0080ab3bbef0beb570a528993e83df057a9d9bba1" [[package]] name = "ring" -version = "0.16.19" +version = "0.16.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", "libc", @@ -6634,7 +6649,7 @@ dependencies = [ "base64 0.13.0", "blake2b_simd", "constant_time_eq", - "crossbeam-utils 0.8.1", + "crossbeam-utils 0.8.3", ] [[package]] @@ -6714,7 +6729,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "pin-project 0.4.27", "static_assertions", ] @@ -6759,7 +6774,7 @@ dependencies = [ "async-trait", "derive_more", "either", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "libp2p", "log", @@ -6787,7 +6802,7 @@ dependencies = [ name = "sc-basic-authorship" version = "0.9.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -6861,7 +6876,7 @@ version = "0.9.0" dependencies = [ "chrono", "fdlimit", - "futures 0.3.12", + "futures 0.3.13", "hex", "libp2p", "log", @@ -6899,7 +6914,7 @@ version = "3.0.0" dependencies = [ "derive_more", "fnv", - "futures 0.3.12", + "futures 0.3.13", "hash-db", "kvdb", "kvdb-memorydb", @@ -6979,7 +6994,7 @@ name = "sc-consensus-aura" version = "0.9.0" dependencies = [ "derive_more", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "getrandom 0.2.2", "log", @@ -7021,7 +7036,7 @@ version = "0.9.0" dependencies = [ "derive_more", "fork-tree", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "log", "merlin", @@ -7075,7 +7090,7 @@ name = "sc-consensus-babe-rpc" version = "0.9.0" dependencies = [ "derive_more", - "futures 0.3.12", + "futures 0.3.13", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7117,7 +7132,7 @@ version = "0.9.0" dependencies = [ "assert_matches", "derive_more", - "futures 0.3.12", + "futures 0.3.13", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7154,7 +7169,7 @@ name = "sc-consensus-pow" version = "0.9.0" dependencies = [ "derive_more", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -7176,7 +7191,7 @@ dependencies = [ name = "sc-consensus-slots" version = "0.9.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -7307,13 +7322,13 @@ dependencies = [ "dyn-clone", "finality-grandpa", "fork-tree", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "linked-hash-map", "log", "parity-scale-codec", "parking_lot 0.11.1", - "pin-project 1.0.4", + "pin-project 1.0.5", "rand 0.7.3", "sc-block-builder", "sc-client-api", @@ -7351,7 +7366,7 @@ version = "0.9.0" dependencies = [ "derive_more", "finality-grandpa", - "futures 0.3.12", + "futures 0.3.13", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7381,7 +7396,7 @@ version = "0.9.0" dependencies = [ "derive_more", "finality-grandpa", - "futures 0.3.12", + "futures 0.3.13", "log", "num-traits", "parity-scale-codec", @@ -7406,7 +7421,7 @@ name = "sc-informant" version = "0.9.0" dependencies = [ "ansi_term 0.12.1", - "futures 0.3.12", + "futures 0.3.13", "log", "parity-util-mem", "sc-client-api", @@ -7424,7 +7439,7 @@ version = "3.0.0" dependencies = [ "async-trait", "derive_more", - "futures 0.3.12", + "futures 0.3.13", "futures-util", "hex", "merlin", @@ -7473,7 +7488,7 @@ dependencies = [ "erased-serde", "fnv", "fork-tree", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "hex", "ip_network", @@ -7485,7 +7500,7 @@ dependencies = [ "nohash-hasher", "parity-scale-codec", "parking_lot 0.11.1", - "pin-project 1.0.4", + "pin-project 1.0.5", "prost", "prost-build", "quickcheck", @@ -7521,7 +7536,7 @@ name = "sc-network-gossip" version = "0.9.0" dependencies = [ "async-std", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "libp2p", "log", @@ -7540,7 +7555,7 @@ name = "sc-network-test" version = "0.8.0" dependencies = [ "async-std", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "libp2p", "log", @@ -7568,10 +7583,10 @@ version = "3.0.0" dependencies = [ "bytes 0.5.6", "fnv", - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "hex", - "hyper 0.13.9", + "hyper 0.13.10", "hyper-rustls", "lazy_static", "log", @@ -7602,7 +7617,7 @@ dependencies = [ name = "sc-peerset" version = "3.0.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "libp2p", "log", "rand 0.7.3", @@ -7624,8 +7639,8 @@ name = "sc-rpc" version = "3.0.0" dependencies = [ "assert_matches", - "futures 0.1.30", - "futures 0.3.12", + "futures 0.1.31", + "futures 0.3.13", "hash-db", "jsonrpc-core", "jsonrpc-pubsub", @@ -7666,7 +7681,7 @@ name = "sc-rpc-api" version = "0.9.0" dependencies = [ "derive_more", - "futures 0.3.12", + "futures 0.3.13", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7688,7 +7703,7 @@ dependencies = [ name = "sc-rpc-server" version = "3.0.0" dependencies = [ - "futures 0.1.30", + "futures 0.1.31", "jsonrpc-core", "jsonrpc-http-server", "jsonrpc-ipc-server", @@ -7722,8 +7737,8 @@ dependencies = [ "async-std", "directories", "exit-future", - "futures 0.1.30", - "futures 0.3.12", + "futures 0.1.31", + "futures 0.3.13", "futures-timer 3.0.2", "hash-db", "jsonrpc-core", @@ -7733,7 +7748,7 @@ dependencies = [ "parity-scale-codec", "parity-util-mem", "parking_lot 0.11.1", - "pin-project 1.0.4", + "pin-project 1.0.5", "rand 0.7.3", "sc-block-builder", "sc-chain-spec", @@ -7789,8 +7804,8 @@ name = "sc-service-test" version = "2.0.0" dependencies = [ "fdlimit", - "futures 0.1.30", - "futures 0.3.12", + "futures 0.1.31", + "futures 0.3.13", "hex-literal", "log", "parity-scale-codec", @@ -7858,11 +7873,11 @@ name = "sc-telemetry" version = "3.0.0" dependencies = [ "chrono", - "futures 0.3.12", + "futures 0.3.13", "libp2p", "log", "parking_lot 0.11.1", - "pin-project 1.0.4", + "pin-project 1.0.5", "rand 0.7.3", "serde", "serde_json", @@ -7915,7 +7930,7 @@ dependencies = [ "assert_matches", "criterion", "derive_more", - "futures 0.3.12", + "futures 0.3.13", "linked-hash-map", "log", "parity-scale-codec", @@ -7938,7 +7953,7 @@ name = "sc-transaction-pool" version = "3.0.0" dependencies = [ "assert_matches", - "futures 0.3.12", + "futures 0.3.13", "futures-diagnose", "hex", "intervalier", @@ -8125,9 +8140,9 @@ checksum = "930c0acf610d3fdb5e2ab6213019aaa04e227ebe9547b0649ba599b16d788bd7" [[package]] name = "serde" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] @@ -8144,9 +8159,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote", @@ -8155,9 +8170,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -8178,9 +8193,9 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce3cdf1b5e620a498ee6f2a171885ac7e22f0e12089ec4b3d22b84921792507c" +checksum = "dfebf75d25bd900fd1e7d11501efab59bc846dbc76196839663e6637bba9f25f" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", @@ -8243,9 +8258,9 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" [[package]] name = "signal-hook" -version = "0.1.17" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" +checksum = "8a7f3f92a1da3d6b1d32245d0cbcbbab0cfc45996d8df619c42bccfa6d2bbb5f" dependencies = [ "libc", "signal-hook-registry", @@ -8337,11 +8352,11 @@ dependencies = [ "base64 0.12.3", "bytes 0.5.6", "flate2", - "futures 0.3.12", + "futures 0.3.13", "httparse", "log", "rand 0.7.3", - "sha-1 0.9.2", + "sha-1 0.9.4", ] [[package]] @@ -8490,7 +8505,7 @@ dependencies = [ name = "sp-blockchain" version = "3.0.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "log", "lru", "parity-scale-codec", @@ -8515,7 +8530,7 @@ dependencies = [ name = "sp-consensus" version = "0.9.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "futures-timer 3.0.2", "libp2p", "log", @@ -8612,7 +8627,7 @@ dependencies = [ "criterion", "dyn-clonable", "ed25519-dalek", - "futures 0.3.12", + "futures 0.3.13", "hash-db", "hash256-std-hasher", "hex", @@ -8668,17 +8683,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-election-providers" -version = "3.0.0" -dependencies = [ - "parity-scale-codec", - "sp-arithmetic", - "sp-npos-elections", - "sp-runtime", - "sp-std", -] - [[package]] name = "sp-externalities" version = "0.9.0" @@ -8720,7 +8724,7 @@ dependencies = [ name = "sp-io" version = "3.0.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "hash-db", "libsecp256k1", "log", @@ -8755,7 +8759,7 @@ version = "0.9.0" dependencies = [ "async-trait", "derive_more", - "futures 0.3.12", + "futures 0.3.13", "merlin", "parity-scale-codec", "parking_lot 0.11.1", @@ -9065,7 +9069,7 @@ name = "sp-transaction-pool" version = "3.0.0" dependencies = [ "derive_more", - "futures 0.3.12", + "futures 0.3.13", "log", "parity-scale-codec", "serde", @@ -9097,7 +9101,7 @@ dependencies = [ name = "sp-utils" version = "3.0.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "futures-core", "futures-timer 3.0.2", "lazy_static", @@ -9249,8 +9253,8 @@ version = "0.9.0" dependencies = [ "chrono", "console_error_panic_hook", - "futures 0.1.30", - "futures 0.3.12", + "futures 0.1.31", + "futures 0.3.13", "futures-timer 3.0.2", "getrandom 0.2.2", "js-sys", @@ -9292,7 +9296,7 @@ version = "3.0.0" dependencies = [ "frame-support", "frame-system", - "futures 0.3.12", + "futures 0.3.13", "jsonrpc-client-transports", "jsonrpc-core", "parity-scale-codec", @@ -9307,7 +9311,7 @@ name = "substrate-frame-rpc-system" version = "3.0.0" dependencies = [ "frame-system-rpc-runtime-api", - "futures 0.3.12", + "futures 0.3.13", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -9334,7 +9338,7 @@ dependencies = [ "async-std", "derive_more", "futures-util", - "hyper 0.13.9", + "hyper 0.13.10", "log", "prometheus", "tokio 0.2.25", @@ -9344,8 +9348,8 @@ dependencies = [ name = "substrate-test-client" version = "2.0.1" dependencies = [ - "futures 0.1.30", - "futures 0.3.12", + "futures 0.1.31", + "futures 0.3.13", "hash-db", "hex", "parity-scale-codec", @@ -9414,7 +9418,7 @@ dependencies = [ name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "parity-scale-codec", "sc-block-builder", "sc-client-api", @@ -9435,7 +9439,7 @@ name = "substrate-test-runtime-transaction-pool" version = "2.0.0" dependencies = [ "derive_more", - "futures 0.3.12", + "futures 0.3.13", "parity-scale-codec", "parking_lot 0.11.1", "sc-transaction-graph", @@ -9449,7 +9453,7 @@ dependencies = [ name = "substrate-test-utils" version = "3.0.0" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "sc-service", "substrate-test-utils-derive", "tokio 0.2.25", @@ -9502,9 +9506,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.60" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "123a78a3596b24fee53a6464ce52d8ecbf62241e6294c7e7fe12086cd161f512" dependencies = [ "proc-macro2", "quote", @@ -9531,15 +9535,15 @@ checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" [[package]] name = "tap" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -9550,7 +9554,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "rand 0.8.3", - "redox_syscall 0.2.4", + "redox_syscall 0.2.5", "remove_dir_all", "winapi 0.3.9", ] @@ -9651,9 +9655,9 @@ dependencies = [ [[package]] name = "tinytemplate" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ada8616fad06a2d0c455adc530de4ef57605a8120cc65da9653e0e9623ca74" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" dependencies = [ "serde", "serde_json", @@ -9681,7 +9685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "mio", "num_cpus", "tokio-codec", @@ -9729,7 +9733,7 @@ checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" dependencies = [ "bytes 0.4.12", "either", - "futures 0.1.30", + "futures 0.1.31", ] [[package]] @@ -9739,7 +9743,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "tokio-io", ] @@ -9749,7 +9753,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" dependencies = [ - "futures 0.1.30", + "futures 0.1.31", "tokio-executor", ] @@ -9760,7 +9764,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.30", + "futures 0.1.31", ] [[package]] @@ -9769,7 +9773,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" dependencies = [ - "futures 0.1.30", + "futures 0.1.31", "tokio-io", "tokio-threadpool", ] @@ -9781,7 +9785,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "log", ] @@ -9803,7 +9807,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d282d483052288b2308ba5ee795f5673b159c9bdf63c385a05609da782a5eae" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "mio", "mio-named-pipes", "tokio 0.1.22", @@ -9816,7 +9820,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.30", + "futures 0.1.31", "lazy_static", "log", "mio", @@ -9846,7 +9850,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" dependencies = [ - "futures 0.1.30", + "futures 0.1.31", ] [[package]] @@ -9856,7 +9860,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" dependencies = [ "fnv", - "futures 0.1.30", + "futures 0.1.31", ] [[package]] @@ -9866,7 +9870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "iovec", "mio", "tokio-io", @@ -9882,7 +9886,7 @@ dependencies = [ "crossbeam-deque 0.7.3", "crossbeam-queue", "crossbeam-utils 0.7.2", - "futures 0.1.30", + "futures 0.1.31", "lazy_static", "log", "num_cpus", @@ -9897,7 +9901,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.30", + "futures 0.1.31", "slab", "tokio-executor", ] @@ -9909,7 +9913,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "log", "mio", "tokio-codec", @@ -9924,7 +9928,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" dependencies = [ "bytes 0.4.12", - "futures 0.1.30", + "futures 0.1.31", "iovec", "libc", "log", @@ -9972,16 +9976,16 @@ checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if 1.0.0", "log", - "pin-project-lite 0.2.5", + "pin-project-lite 0.2.6", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.14" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41768be5b9f3489491825f56f01f25290aa1d3e7cc97e182d4d34360493ba6fa" +checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07" dependencies = [ "proc-macro2", "quote", @@ -9999,19 +10003,19 @@ dependencies = [ [[package]] name = "tracing-futures" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" dependencies = [ - "pin-project 0.4.27", + "pin-project 1.0.5", "tracing", ] [[package]] name = "tracing-log" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" dependencies = [ "lazy_static", "log", @@ -10030,9 +10034,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" +checksum = "8ab8966ac3ca27126141f7999361cc97dd6fb4b71da04c02044fa9045d98bb96" dependencies = [ "ansi_term 0.12.1", "chrono", @@ -10133,9 +10137,9 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.39" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9594b802f041389d2baac680663573dde3103bb4a4926d61d6aba689465978" +checksum = "99471a206425fba51842a9186315f32d91c56eadc21ea4c21f847b59cf778f8b" dependencies = [ "dissimilar", "glob", @@ -10201,9 +10205,9 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" dependencies = [ "tinyvec", ] @@ -10285,12 +10289,12 @@ dependencies = [ [[package]] name = "url" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" +checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" dependencies = [ "form_urlencoded", - "idna 0.2.0", + "idna 0.2.2", "matches", "percent-encoding 2.1.0", ] @@ -10366,7 +10370,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" dependencies = [ - "futures 0.1.30", + "futures 0.1.31", "log", "try-lock", ] @@ -10422,9 +10426,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" +checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -10463,9 +10467,9 @@ checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] name = "wasm-bindgen-test" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25" +checksum = "f0d4da138503a4cf86801b94d95781ee3619faa8feca830569cc6b54997b8b5c" dependencies = [ "console_error_panic_hook", "js-sys", @@ -10477,9 +10481,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b" +checksum = "c3199c33f06500c731d5544664c24d0c2b742b98debc6b1c6f0c6d6e8fb7c19b" dependencies = [ "proc-macro2", "quote", @@ -10502,7 +10506,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "js-sys", "parking_lot 0.11.1", "pin-utils", @@ -10730,27 +10734,27 @@ dependencies = [ [[package]] name = "wast" -version = "32.0.0" +version = "35.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24a3ee360d01d60ed0a0f960ab76a6acce64348cdb0bf8699c2a866fad57c7c" +checksum = "db5ae96da18bb5926341516fd409b5a8ce4e4714da7f0a1063d3b20ac9f9a1e1" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.33" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e8f7f34773fa6318e8897283abf7941c1f250faae4e1a52f82df09c3bad7cce" +checksum = "0b0fa059022c5dabe129f02b429d67086400deb8277f89c975555dacc1dadbcc" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", @@ -10879,7 +10883,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cc7bd8c983209ed5d527f44b01c41b7dc146fd960c61cf9e1d25399841dc271" dependencies = [ - "futures 0.3.12", + "futures 0.3.13", "log", "nohash-hasher", "parking_lot 0.11.1", diff --git a/Cargo.toml b/Cargo.toml index 4d8cfc3e9754d..ef2613979518c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,6 +76,7 @@ members = [ "frame/try-runtime", "frame/elections", "frame/election-provider-multi-phase", + "frame/election-provider-support", "frame/example", "frame/example-offchain-worker", "frame/example-parallel", @@ -145,7 +146,6 @@ members = [ "primitives/database", "primitives/debug-derive", "primitives/externalities", - "primitives/election-providers", "primitives/finality-grandpa", "primitives/inherents", "primitives/io", diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index 6c7bb508b53d1..f7bebce98acf3 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -37,7 +37,7 @@ pallet-offences = { version = "3.0.0", path = "../offences" } pallet-staking = { version = "3.0.0", path = "../staking" } pallet-staking-reward-curve = { version = "3.0.0", path = "../staking/reward-curve" } sp-core = { version = "3.0.0", path = "../../primitives/core" } -sp-election-providers = { version = "3.0.0", path = "../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", path = "../election-provider-support" } [features] default = ["std"] diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index c46b55c2c4ace..ef7a748c60b9d 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -37,7 +37,7 @@ use sp_consensus_babe::{AuthorityId, AuthorityPair, Slot}; use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof}; use sp_staking::SessionIndex; use pallet_staking::EraIndex; -use sp_election_providers::onchain; +use frame_election_provider_support::onchain; use pallet_session::historical as pallet_session_historical; type DummyValidatorId = u64; @@ -187,6 +187,7 @@ parameter_types! { impl onchain::Config for Test { type AccountId = ::AccountId; type BlockNumber = ::BlockNumber; + type BlockWeights = (); type Accuracy = Perbill; type DataProvider = Staking; } diff --git a/frame/election-provider-multi-phase/Cargo.toml b/frame/election-provider-multi-phase/Cargo.toml index 1d63f9df40a25..4b5178faa8e86 100644 --- a/frame/election-provider-multi-phase/Cargo.toml +++ b/frame/election-provider-multi-phase/Cargo.toml @@ -26,7 +26,7 @@ sp-std = { version = "3.0.0", default-features = false, path = "../../primitives sp-runtime = { version = "3.0.0", default-features = false, path = "../../primitives/runtime" } sp-npos-elections = { version = "3.0.0", default-features = false, path = "../../primitives/npos-elections" } sp-arithmetic = { version = "3.0.0", default-features = false, path = "../../primitives/arithmetic" } -sp-election-providers = { version = "3.0.0", default-features = false, path = "../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", default-features = false, path = "../election-provider-support" } # Optional imports for benchmarking frame-benchmarking = { version = "3.1.0", default-features = false, path = "../benchmarking", optional = true } @@ -41,9 +41,9 @@ substrate-test-utils = { version = "3.0.0", path = "../../test-utils" } sp-io = { version = "3.0.0", path = "../../primitives/io" } sp-core = { version = "3.0.0", path = "../../primitives/core" } sp-tracing = { version = "3.0.0", path = "../../primitives/tracing" } -sp-election-providers = { version = "3.0.0", features = ["runtime-benchmarks"], path = "../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", features = ["runtime-benchmarks"], path = "../election-provider-support" } pallet-balances = { version = "3.0.0", path = "../balances" } -frame-benchmarking = { path = "../benchmarking" , version = "3.1.0"} +frame-benchmarking = { version = "3.1.0", path = "../benchmarking" } [features] default = ["std"] @@ -60,7 +60,7 @@ std = [ "sp-runtime/std", "sp-npos-elections/std", "sp-arithmetic/std", - "sp-election-providers/std", + "frame-election-provider-support/std", "log/std", ] runtime-benchmarks = [ diff --git a/frame/election-provider-multi-phase/src/benchmarking.rs b/frame/election-provider-multi-phase/src/benchmarking.rs index 74db28c6e3929..3b1b7bd7a2290 100644 --- a/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/frame/election-provider-multi-phase/src/benchmarking.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2020 Parity Technologies (UK) Ltd. +// Copyright (C) 2021 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,17 +19,16 @@ use super::*; use crate::Module as MultiPhase; - -pub use frame_benchmarking::{account, benchmarks, whitelist_account, whitelisted_caller}; +use frame_benchmarking::impl_benchmark_test_suite; use frame_support::{assert_ok, traits::OnInitialize}; use frame_system::RawOrigin; use rand::{prelude::SliceRandom, rngs::SmallRng, SeedableRng}; -use sp_election_providers::Assignment; +use frame_election_provider_support::Assignment; use sp_arithmetic::traits::One; use sp_runtime::InnerOf; use sp_std::convert::TryInto; -const SEED: u32 = 0; +const SEED: u32 = 999; /// Creates a **valid** solution with exactly the given size. /// @@ -55,9 +54,9 @@ fn solution_with_size( // first generates random targets. let targets: Vec = - (0..size.targets).map(|i| account("Targets", i, SEED)).collect(); + (0..size.targets).map(|i| frame_benchmarking::account("Targets", i, SEED)).collect(); - let mut rng = SmallRng::seed_from_u64(999u64); + let mut rng = SmallRng::seed_from_u64(SEED as u64); // decide who are the winners. let winners = targets @@ -75,7 +74,7 @@ fn solution_with_size( .choose_multiple(&mut rng, >::LIMIT) .cloned() .collect::>(); - let voter = account::("Voter", i, SEED); + let voter = frame_benchmarking::account::("Voter", i, SEED); (voter, stake, winner_votes) }) .collect::>(); @@ -89,7 +88,7 @@ fn solution_with_size( .choose_multiple(&mut rng, >::LIMIT) .cloned() .collect::>(); - let voter = account::("Voter", i, SEED); + let voter = frame_benchmarking::account::("Voter", i, SEED); (voter, stake, votes) }) .collect::>(); @@ -109,8 +108,9 @@ fn solution_with_size( >::put(desired_targets); >::put(RoundSnapshot { voters: all_voters.clone(), targets: targets.clone() }); - // write the snapshot to staking or whoever is the data provider. - T::DataProvider::put_snapshot(all_voters.clone(), targets.clone()); + // write the snapshot to staking or whoever is the data provider, in case it is needed further + // down the road. + T::DataProvider::put_snapshot(all_voters.clone(), targets.clone(), Some(stake)); let cache = helpers::generate_voter_cache::(&all_voters); let stake_of = helpers::stake_of_fn::(&all_voters, &cache); @@ -138,10 +138,12 @@ fn solution_with_size( >::from_assignment(assignments, &voter_index, &target_index).unwrap(); let score = compact.clone().score(&winners, stake_of, voter_at, target_at).unwrap(); let round = >::round(); + + assert!(score[0] > 0, "score is zero, this probably means that the stakes are not set."); RawSolution { compact, score, round } } -benchmarks! { +frame_benchmarking::benchmarks! { on_initialize_nothing { assert!(>::current_phase().is_off()); }: { @@ -157,7 +159,7 @@ benchmarks! { assert!(>::snapshot().is_none()); assert!(>::current_phase().is_off()); }: { - >::on_initialize_open_signed(); + >::on_initialize_open_signed().unwrap(); } verify { assert!(>::snapshot().is_some()); assert!(>::current_phase().is_signed()); @@ -167,7 +169,7 @@ benchmarks! { assert!(>::snapshot().is_none()); assert!(>::current_phase().is_off()); }: { - >::on_initialize_open_unsigned(true, true, 1u32.into()); + >::on_initialize_open_unsigned(true, true, 1u32.into()).unwrap(); } verify { assert!(>::snapshot().is_some()); assert!(>::current_phase().is_unsigned()); @@ -175,21 +177,51 @@ benchmarks! { on_initialize_open_unsigned_without_snapshot { // need to assume signed phase was open before - >::on_initialize_open_signed(); + >::on_initialize_open_signed().unwrap(); assert!(>::snapshot().is_some()); assert!(>::current_phase().is_signed()); }: { - >::on_initialize_open_unsigned(false, true, 1u32.into()); + >::on_initialize_open_unsigned(false, true, 1u32.into()).unwrap(); } verify { assert!(>::snapshot().is_some()); assert!(>::current_phase().is_unsigned()); } + // a call to `::elect` where we only return the queued solution. + elect_queued { + // assume largest values for the election status. These will merely affect the decoding. + let v = T::BenchmarkingConfig::VOTERS[1]; + let t = T::BenchmarkingConfig::TARGETS[1]; + let a = T::BenchmarkingConfig::ACTIVE_VOTERS[1]; + let d = T::BenchmarkingConfig::DESIRED_TARGETS[1]; + + let witness = SolutionOrSnapshotSize { voters: v, targets: t }; + let raw_solution = solution_with_size::(witness, a, d); + let ready_solution = + >::feasibility_check(raw_solution, ElectionCompute::Signed).unwrap(); + + // these are set by the `solution_with_size` function. + assert!(>::get().is_some()); + assert!(>::get().is_some()); + assert!(>::get().is_some()); + >::put(Phase::Signed); + // assume a queued solution is stored, regardless of where it comes from. + >::put(ready_solution); + }: { + let _ = as ElectionProvider>::elect(); + } verify { + assert!(>::queued_solution().is_none()); + assert!(>::get().is_none()); + assert!(>::get().is_none()); + assert!(>::get().is_none()); + assert_eq!(>::get(), >::Off); + } + #[extra] create_snapshot { assert!(>::snapshot().is_none()); }: { - >::create_snapshot() + >::create_snapshot().unwrap() } verify { assert!(>::snapshot().is_some()); } @@ -248,35 +280,8 @@ benchmarks! { } } -#[cfg(test)] -mod test { - use super::*; - use crate::mock::*; - - #[test] - fn test_benchmarks() { - ExtBuilder::default().build_and_execute(|| { - assert_ok!(test_benchmark_feasibility_check::()); - }); - - ExtBuilder::default().build_and_execute(|| { - assert_ok!(test_benchmark_submit_unsigned::()); - }); - - ExtBuilder::default().build_and_execute(|| { - assert_ok!(test_benchmark_on_initialize_open_unsigned_with_snapshot::()); - }); - - ExtBuilder::default().build_and_execute(|| { - assert_ok!(test_benchmark_on_initialize_open_unsigned_without_snapshot::()); - }); - - ExtBuilder::default().build_and_execute(|| { - assert_ok!(test_benchmark_on_initialize_nothing::()); - }); - - ExtBuilder::default().build_and_execute(|| { - assert_ok!(test_benchmark_create_snapshot::()); - }); - } -} +impl_benchmark_test_suite!( + MultiPhase, + crate::mock::ExtBuilder::default().build(), + crate::mock::Runtime, +); diff --git a/frame/election-provider-multi-phase/src/helpers.rs b/frame/election-provider-multi-phase/src/helpers.rs index dd97163d2859c..41d17e6aa9a2b 100644 --- a/frame/election-provider-multi-phase/src/helpers.rs +++ b/frame/election-provider-multi-phase/src/helpers.rs @@ -25,7 +25,7 @@ macro_rules! log { ($level:tt, $pattern:expr $(, $values:expr)* $(,)?) => { log::$level!( target: $crate::LOG_TARGET, - concat!("🗳 ", $pattern) $(, $values)* + concat!("[#{:?}] 🗳 ", $pattern), >::block_number() $(, $values)* ) }; } diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index aca07cae3085a..641807294f05c 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -23,9 +23,10 @@ //! ## Phases //! //! The timeline of pallet is as follows. At each block, -//! [`sp_election_providers::ElectionDataProvider::next_election_prediction`] is used to estimate -//! the time remaining to the next call to [`sp_election_providers::ElectionProvider::elect`]. Based -//! on this, a phase is chosen. The timeline is as follows. +//! [`frame_election_provider_support::ElectionDataProvider::next_election_prediction`] is used to +//! estimate the time remaining to the next call to +//! [`frame_election_provider_support::ElectionProvider::elect`]. Based on this, a phase is chosen. +//! The timeline is as follows. //! //! ```ignore //! elect() @@ -149,7 +150,8 @@ //! are helpful for logging and are thus nested as: //! - [`ElectionError::Miner`]: wraps a [`unsigned::MinerError`]. //! - [`ElectionError::Feasibility`]: wraps a [`FeasibilityError`]. -//! - [`ElectionError::OnChainFallback`]: wraps a [`sp_election_providers::onchain::Error`]. +//! - [`ElectionError::OnChainFallback`]: wraps a +//! [`frame_election_provider_support::onchain::Error`]. //! //! Note that there could be an overlap between these sub-errors. For example, A //! `SnapshotUnavailable` can happen in both miner and feasibility check phase. @@ -184,10 +186,10 @@ //! //! **Recursive Fallback**: Currently, the fallback is a separate enum. A different and fancier way //! of doing this would be to have the fallback be another -//! [`sp_election_providers::ElectionProvider`]. In this case, this pallet can even have the -//! on-chain election provider as fallback, or special _noop_ fallback that simply returns an error, -//! thus replicating [`FallbackStrategy::Nothing`]. In this case, we won't need the additional -//! config OnChainAccuracy either. +//! [`frame_election_provider_support::ElectionProvider`]. In this case, this pallet can even have +//! the on-chain election provider as fallback, or special _noop_ fallback that simply returns an +//! error, thus replicating [`FallbackStrategy::Nothing`]. In this case, we won't need the +//! additional config OnChainAccuracy either. //! //! **Score based on (byte) size**: We should always prioritize small solutions over bigger ones, if //! there is a tie. Even more harsh should be to enforce the bound of the `reduce` algorithm. @@ -200,6 +202,15 @@ //! dependency from staking and the compact solution type. It should be generated at runtime, there //! it should be encoded how many votes each nominators have. Essentially translate //! to this pallet. +//! +//! **More accurate weight for error cases**: Both `ElectionDataProvider` and `ElectionProvider` +//! assume no weight is consumed in their functions, when operations fail with `Err`. This can +//! clearly be improved, but not a priority as we generally expect snapshot creation to fail only +//! due to extreme circumstances. +//! +//! **Take into account the encode/decode weight in benchmarks.** Currently, we only take into +//! account the weight of encode/decode in the `submit_unsigned` given its priority. Nonetheless, +//! all operations on the solution and the snapshot are worthy of taking this into account. #![cfg_attr(not(feature = "std"), no_std)] @@ -211,7 +222,7 @@ use frame_support::{ weights::Weight, }; use frame_system::{ensure_none, offchain::SendTransactionTypes}; -use sp_election_providers::{ElectionDataProvider, ElectionProvider, onchain}; +use frame_election_provider_support::{ElectionDataProvider, ElectionProvider, onchain}; use sp_npos_elections::{ assignment_ratio_to_staked_normalized, is_score_better, CompactSolution, ElectionScore, EvaluateSupport, PerThing128, Supports, VoteWeight, @@ -222,6 +233,7 @@ use sp_runtime::{ TransactionValidityError, ValidTransaction, }, DispatchError, PerThing, Perbill, RuntimeDebug, SaturatedConversion, + traits::Bounded, }; use sp_std::prelude::*; use sp_arithmetic::{ @@ -261,6 +273,7 @@ struct OnChainConfig(sp_std::marker::PhantomData); impl onchain::Config for OnChainConfig { type AccountId = T::AccountId; type BlockNumber = T::BlockNumber; + type BlockWeights = T::BlockWeights; type Accuracy = T::OnChainAccuracy; type DataProvider = T::DataProvider; } @@ -436,6 +449,8 @@ pub enum ElectionError { Miner(unsigned::MinerError), /// An error in the on-chain fallback. OnChainFallback(onchain::Error), + /// An error happened in the data provider. + DataProvider(&'static str), /// No fallback is configured. This is a special case. NoFallbackConfigured, } @@ -563,17 +578,28 @@ pub mod pallet { match current_phase { Phase::Off if remaining <= signed_deadline && remaining > unsigned_deadline => { - Self::on_initialize_open_signed(); - log!(info, "Starting signed phase at #{:?} , round {}.", now, Self::round()); - T::WeightInfo::on_initialize_open_signed() + // NOTE: if signed-phase length is zero, second part of the if-condition fails. + match Self::on_initialize_open_signed() { + Ok(snap_weight) => { + log!(info, "Starting signed phase round {}.", Self::round()); + T::WeightInfo::on_initialize_open_signed().saturating_add(snap_weight) + } + Err(why) => { + // not much we can do about this at this point. + log!(warn, "failed to open signed phase due to {:?}", why); + T::WeightInfo::on_initialize_nothing() + // NOTE: ^^ The trait specifies that this is a noop in terms of weight + // in case of error. + } + } } Phase::Signed | Phase::Off - if remaining <= unsigned_deadline && remaining > 0u32.into() => + if remaining <= unsigned_deadline && remaining > Zero::zero() => { - let (need_snapshot, enabled, additional) = if current_phase == Phase::Signed { + // determine if followed by signed or not. + let (need_snapshot, enabled, signed_weight) = if current_phase == Phase::Signed { // followed by a signed phase: close the signed phase, no need for snapshot. - // TWO_PHASE_NOTE: later on once we have signed phase, this should return - // something else. + // TODO: proper weight https://github.com/paritytech/substrate/pull/7910. (false, true, Weight::zero()) } else { // no signed phase: create a new snapshot, definitely `enable` the unsigned @@ -581,15 +607,25 @@ pub mod pallet { (true, true, Weight::zero()) }; - Self::on_initialize_open_unsigned(need_snapshot, enabled, now); - log!(info, "Starting unsigned phase({}) at #{:?}.", enabled, now); - - let base_weight = if need_snapshot { - T::WeightInfo::on_initialize_open_unsigned_with_snapshot() - } else { - T::WeightInfo::on_initialize_open_unsigned_without_snapshot() - }; - base_weight.saturating_add(additional) + match Self::on_initialize_open_unsigned(need_snapshot, enabled, now) { + Ok(snap_weight) => { + log!(info, "Starting unsigned phase({}).", enabled); + let base_weight = if need_snapshot { + T::WeightInfo::on_initialize_open_unsigned_with_snapshot() + } else { + T::WeightInfo::on_initialize_open_unsigned_without_snapshot() + }; + + base_weight.saturating_add(snap_weight).saturating_add(signed_weight) + } + Err(why) => { + // not much we can do about this at this point. + log!(warn, "failed to open unsigned phase due to {:?}", why); + T::WeightInfo::on_initialize_nothing() + // NOTE: ^^ The trait specifies that this is a noop in terms of weight + // in case of error. + } + } } _ => T::WeightInfo::on_initialize_nothing(), } @@ -601,7 +637,7 @@ pub mod pallet { match Self::try_acquire_offchain_lock(n) { Ok(_) => { let outcome = Self::mine_check_and_submit().map_err(ElectionError::from); - log!(info, "miner exeuction done: {:?}", outcome); + log!(info, "mine_check_and_submit execution done: {:?}", outcome); } Err(why) => log!(warn, "denied offchain worker: {:?}", why), } @@ -838,32 +874,41 @@ pub mod pallet { } impl Pallet { - /// Logic for `::on_initialize` when signed phase is being opened. + /// Logic for [`::on_initialize`] when signed phase is being opened. /// /// This is decoupled for easy weight calculation. - pub(crate) fn on_initialize_open_signed() { + /// + /// Returns `Ok(snapshot_weight)` if success, where `snapshot_weight` is the weight that + /// needs to recorded for the creation of snapshot. + pub(crate) fn on_initialize_open_signed() -> Result { + let weight = Self::create_snapshot()?; >::put(Phase::Signed); - Self::create_snapshot(); Self::deposit_event(Event::SignedPhaseStarted(Self::round())); + Ok(weight.saturating_add(T::DbWeight::get().writes(1))) } - /// Logic for `>::on_initialize` when unsigned phase is being opened. + /// Logic for [`>::on_initialize`] when unsigned phase is being opened. + /// + /// This is decoupled for easy weight calculation. /// - /// This is decoupled for easy weight calculation. Note that the default weight benchmark of - /// this function will assume an empty signed queue for `finalize_signed_phase`. + /// Returns `Ok(snapshot_weight)` if success, where `snapshot_weight` is the weight that + /// needs to recorded for the creation of snapshot. pub(crate) fn on_initialize_open_unsigned( need_snapshot: bool, enabled: bool, now: T::BlockNumber, - ) { - if need_snapshot { + ) -> Result { + let weight = if need_snapshot { // if not being followed by a signed phase, then create the snapshots. debug_assert!(Self::snapshot().is_none()); - Self::create_snapshot(); - } + Self::create_snapshot()? + } else { + 0 + }; >::put(Phase::Unsigned((enabled, now))); Self::deposit_event(Event::UnsignedPhaseStarted(Self::round())); + Ok(weight.saturating_add(T::DbWeight::get().writes(1))) } /// Creates the snapshot. Writes new data to: @@ -871,18 +916,33 @@ impl Pallet { /// 1. [`SnapshotMetadata`] /// 2. [`RoundSnapshot`] /// 3. [`DesiredTargets`] - pub(crate) fn create_snapshot() { - // if any of them don't exist, create all of them. This is a bit conservative. - let targets = T::DataProvider::targets(); - let voters = T::DataProvider::voters(); - let desired_targets = T::DataProvider::desired_targets(); + /// + /// Returns `Ok(consumed_weight)` if operation is okay. + pub(crate) fn create_snapshot() -> Result { + let target_limit = >::max_value().saturated_into::(); + let voter_limit = >::max_value().saturated_into::(); + + let (targets, w1) = + T::DataProvider::targets(Some(target_limit)).map_err(ElectionError::DataProvider)?; + let (voters, w2) = + T::DataProvider::voters(Some(voter_limit)).map_err(ElectionError::DataProvider)?; + let (desired_targets, w3) = + T::DataProvider::desired_targets().map_err(ElectionError::DataProvider)?; + + // defensive-only + if targets.len() > target_limit || voters.len() > voter_limit { + debug_assert!(false, "Snapshot limit has not been respected."); + return Err(ElectionError::DataProvider("Snapshot too big for submission.")); + } + // only write snapshot if all existed. >::put(SolutionOrSnapshotSize { voters: voters.len() as u32, targets: targets.len() as u32, }); >::put(desired_targets); >::put(RoundSnapshot { voters, targets }); + Ok(w1.saturating_add(w2).saturating_add(w3).saturating_add(T::DbWeight::get().writes(3))) } /// Kill everything created by [`Pallet::create_snapshot`]. @@ -998,7 +1058,7 @@ impl Pallet { } /// On-chain fallback of election. - fn onchain_fallback() -> Result, ElectionError> { + fn onchain_fallback() -> Result<(Supports, Weight), ElectionError> { > as ElectionProvider< T::AccountId, T::BlockNumber, @@ -1006,23 +1066,27 @@ impl Pallet { .map_err(Into::into) } - fn do_elect() -> Result, ElectionError> { + fn do_elect() -> Result<(Supports, Weight), ElectionError> { >::take() .map_or_else( || match T::Fallback::get() { FallbackStrategy::OnChain => Self::onchain_fallback() - .map(|r| (r, ElectionCompute::OnChain)) + .map(|(s, w)| (s, w, ElectionCompute::OnChain)) .map_err(Into::into), FallbackStrategy::Nothing => Err(ElectionError::NoFallbackConfigured), }, - |ReadySolution { supports, compute, .. }| Ok((supports, compute)), + |ReadySolution { supports, compute, .. }| Ok(( + supports, + T::WeightInfo::elect_queued(), + compute + )), ) - .map(|(supports, compute)| { + .map(|(supports, weight, compute)| { Self::deposit_event(Event::ElectionFinalized(Some(compute))); if Self::round() != 1 { log!(info, "Finalized election round with compute {:?}.", compute); } - supports + (supports, weight) }) .map_err(|err| { Self::deposit_event(Event::ElectionFinalized(None)); @@ -1038,10 +1102,11 @@ impl ElectionProvider for Pallet { type Error = ElectionError; type DataProvider = T::DataProvider; - fn elect() -> Result, Self::Error> { - let outcome = Self::do_elect(); + fn elect() -> Result<(Supports, Weight), Self::Error> { + let outcome_and_weight = Self::do_elect(); + // IMPORTANT: regardless of if election was `Ok` or `Err`, we shall do some cleanup. Self::post_elect(); - outcome + outcome_and_weight } } @@ -1132,13 +1197,13 @@ mod feasibility_check { .compact .votes1 .iter_mut() - .filter(|(_, t)| *t == 3u16) + .filter(|(_, t)| *t == TargetIndex::from(3u16)) .for_each(|(_, t)| *t += 1); solution.compact.votes2.iter_mut().for_each(|(_, (t0, _), t1)| { - if *t0 == 3u16 { + if *t0 == TargetIndex::from(3u16) { *t0 += 1 }; - if *t1 == 3u16 { + if *t1 == TargetIndex::from(3u16) { *t1 += 1 }; }); @@ -1166,7 +1231,7 @@ mod feasibility_check { .compact .votes1 .iter_mut() - .filter(|(v, _)| *v == 7u32) + .filter(|(v, _)| *v == VoterIndex::from(7u32)) .map(|(v, _)| *v = 8) .count() > 0 ); @@ -1229,7 +1294,7 @@ mod feasibility_check { #[cfg(test)] mod tests { use super::{mock::*, Event, *}; - use sp_election_providers::ElectionProvider; + use frame_election_provider_support::ElectionProvider; use sp_npos_elections::Support; #[test] @@ -1401,7 +1466,7 @@ mod tests { #[test] fn fallback_strategy_works() { - ExtBuilder::default().fallabck(FallbackStrategy::OnChain).build_and_execute(|| { + ExtBuilder::default().fallback(FallbackStrategy::OnChain).build_and_execute(|| { roll_to(15); assert_eq!(MultiPhase::current_phase(), Phase::Signed); @@ -1409,7 +1474,7 @@ mod tests { assert_eq!(MultiPhase::current_phase(), Phase::Unsigned((true, 25))); // zilch solutions thus far. - let supports = MultiPhase::elect().unwrap(); + let (supports, _) = MultiPhase::elect().unwrap(); assert_eq!( supports, @@ -1420,7 +1485,7 @@ mod tests { ) }); - ExtBuilder::default().fallabck(FallbackStrategy::Nothing).build_and_execute(|| { + ExtBuilder::default().fallback(FallbackStrategy::Nothing).build_and_execute(|| { roll_to(15); assert_eq!(MultiPhase::current_phase(), Phase::Signed); @@ -1432,6 +1497,26 @@ mod tests { }) } + #[test] + fn snapshot_creation_fails_if_too_big() { + ExtBuilder::default().build_and_execute(|| { + Targets::set((0..(TargetIndex::max_value() as AccountId) + 1).collect::>()); + + // signed phase failed to open. + roll_to(15); + assert_eq!(MultiPhase::current_phase(), Phase::Off); + + // unsigned phase failed to open. + roll_to(25); + assert_eq!(MultiPhase::current_phase(), Phase::Off); + + // on-chain backup works though. + roll_to(29); + let (supports, _) = MultiPhase::elect().unwrap(); + assert!(supports.len() > 0); + }) + } + #[test] fn number_of_voters_allowed_2sec_block() { // Just a rough estimate with the substrate weights. diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index e7a2924fd2aa6..970f3ab9ffcd0 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -31,7 +31,7 @@ use sp_core::{ }, H256, }; -use sp_election_providers::ElectionDataProvider; +use frame_election_provider_support::{ElectionDataProvider, data_provider}; use sp_npos_elections::{ assignment_ratio_to_staked_normalized, seq_phragmen, to_supports, to_without_backing, CompactSolution, ElectionResult, EvaluateSupport, @@ -60,10 +60,12 @@ frame_support::construct_runtime!( pub(crate) type Balance = u64; pub(crate) type AccountId = u64; +pub(crate) type VoterIndex = u32; +pub(crate) type TargetIndex = u16; sp_npos_elections::generate_solution_type!( #[compact] - pub struct TestCompact::(16) + pub struct TestCompact::(16) ); /// All events of this pallet. @@ -239,6 +241,13 @@ impl multi_phase::weights::WeightInfo for DualMockWeightInfo { <() as multi_phase::weights::WeightInfo>::on_initialize_open_unsigned_without_snapshot() } } + fn elect_queued() -> Weight { + if MockWeightInfo::get() { + Zero::zero() + } else { + <() as multi_phase::weights::WeightInfo>::elect_queued() + } + } fn submit_unsigned(v: u32, t: u32, a: u32, d: u32) -> Weight { if MockWeightInfo::get() { // 10 base @@ -291,18 +300,43 @@ pub struct ExtBuilder {} pub struct StakingMock; impl ElectionDataProvider for StakingMock { - fn targets() -> Vec { - Targets::get() + fn targets(maybe_max_len: Option) -> data_provider::Result<(Vec, Weight)> { + let targets = Targets::get(); + + if maybe_max_len.map_or(false, |max_len| targets.len() > max_len) { + return Err("Targets too big"); + } + + Ok((targets, 0)) } - fn voters() -> Vec<(AccountId, VoteWeight, Vec)> { - Voters::get() + + fn voters( + maybe_max_len: Option, + ) -> data_provider::Result<(Vec<(AccountId, VoteWeight, Vec)>, Weight)> { + let voters = Voters::get(); + if maybe_max_len.map_or(false, |max_len| voters.len() > max_len) { + return Err("Voters too big"); + } + + Ok((voters, 0)) } - fn desired_targets() -> u32 { - DesiredTargets::get() + fn desired_targets() -> data_provider::Result<(u32, Weight)> { + Ok((DesiredTargets::get(), 0)) } + fn next_election_prediction(now: u64) -> u64 { now + EpochLength::get() - now % EpochLength::get() } + + #[cfg(any(feature = "runtime-benchmarks", test))] + fn put_snapshot( + voters: Vec<(AccountId, VoteWeight, Vec)>, + targets: Vec, + _target_stake: Option, + ) { + Targets::set(targets); + Voters::set(voters); + } } impl ExtBuilder { @@ -319,7 +353,7 @@ impl ExtBuilder { ::set(unsigned); self } - pub fn fallabck(self, fallback: FallbackStrategy) -> Self { + pub fn fallback(self, fallback: FallbackStrategy) -> Self { ::set(fallback); self } diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 2039e5d9f0754..3004e69c23c8e 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -66,8 +66,17 @@ impl Pallet { let iters = Self::get_balancing_iters(); // get the solution, with a load of checks to ensure if submitted, IT IS ABSOLUTELY VALID. let (raw_solution, witness) = Self::mine_and_check(iters)?; + let score = raw_solution.score.clone(); + + let call: >>::OverarchingCall = + Call::submit_unsigned(raw_solution, witness).into(); + log!( + info, + "mined a solution with score {:?} and size {}", + score, + call.using_encoded(|b| b.len()) + ); - let call = Call::submit_unsigned(raw_solution, witness).into(); SubmitTransaction::>::submit_unsigned_transaction(call) .map_err(|_| MinerError::PoolSubmissionFailed) } @@ -413,6 +422,9 @@ mod max_weight { fn on_initialize_open_unsigned_with_snapshot() -> Weight { unreachable!() } + fn elect_queued() -> Weight { + 0 + } fn on_initialize_open_unsigned_without_snapshot() -> Weight { unreachable!() } @@ -487,7 +499,7 @@ mod tests { }; use frame_support::{dispatch::Dispatchable, traits::OffchainWorker}; use mock::Call as OuterCall; - use sp_election_providers::Assignment; + use frame_election_provider_support::Assignment; use sp_runtime::{traits::ValidateUnsigned, PerU16}; #[test] diff --git a/frame/election-provider-multi-phase/src/weights.rs b/frame/election-provider-multi-phase/src/weights.rs index 276bba330d24c..e13b82f53a177 100644 --- a/frame/election-provider-multi-phase/src/weights.rs +++ b/frame/election-provider-multi-phase/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_election_provider_multi_phase //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-02-12, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: [], HIGH RANGE: [] +//! DATE: 2021-03-14, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -48,6 +48,7 @@ pub trait WeightInfo { fn on_initialize_open_signed() -> Weight; fn on_initialize_open_unsigned_with_snapshot() -> Weight; fn on_initialize_open_unsigned_without_snapshot() -> Weight; + fn elect_queued() -> Weight; fn submit_unsigned(v: u32, t: u32, a: u32, d: u32, ) -> Weight; fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight; } @@ -56,47 +57,52 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn on_initialize_nothing() -> Weight { - (23_401_000 as Weight) + (22_833_000 as Weight) .saturating_add(T::DbWeight::get().reads(7 as Weight)) } fn on_initialize_open_signed() -> Weight { - (79_260_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) + (106_993_000 as Weight) + .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn on_initialize_open_unsigned_with_snapshot() -> Weight { - (77_745_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) + (106_490_000 as Weight) + .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn on_initialize_open_unsigned_without_snapshot() -> Weight { - (21_764_000 as Weight) + (21_275_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + fn elect_queued() -> Weight { + (7_274_346_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + } fn submit_unsigned(v: u32, t: u32, a: u32, d: u32, ) -> Weight { (0 as Weight) - // Standard Error: 23_000 - .saturating_add((4_171_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 78_000 - .saturating_add((229_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 23_000 - .saturating_add((13_661_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 117_000 - .saturating_add((4_499_000 as Weight).saturating_mul(d as Weight)) + // Standard Error: 19_000 + .saturating_add((4_017_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 66_000 + .saturating_add((130_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 19_000 + .saturating_add((13_057_000 as Weight).saturating_mul(a as Weight)) + // Standard Error: 99_000 + .saturating_add((4_558_000 as Weight).saturating_mul(d as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight { (0 as Weight) // Standard Error: 12_000 - .saturating_add((4_232_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 42_000 - .saturating_add((636_000 as Weight).saturating_mul(t as Weight)) + .saturating_add((4_186_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 40_000 + .saturating_add((803_000 as Weight).saturating_mul(t as Weight)) // Standard Error: 12_000 - .saturating_add((10_294_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 64_000 - .saturating_add((4_428_000 as Weight).saturating_mul(d as Weight)) + .saturating_add((9_806_000 as Weight).saturating_mul(a as Weight)) + // Standard Error: 61_000 + .saturating_add((4_156_000 as Weight).saturating_mul(d as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) } } @@ -104,47 +110,52 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn on_initialize_nothing() -> Weight { - (23_401_000 as Weight) + (22_833_000 as Weight) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) } fn on_initialize_open_signed() -> Weight { - (79_260_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + (106_993_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(8 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } fn on_initialize_open_unsigned_with_snapshot() -> Weight { - (77_745_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + (106_490_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(8 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } fn on_initialize_open_unsigned_without_snapshot() -> Weight { - (21_764_000 as Weight) + (21_275_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + fn elect_queued() -> Weight { + (7_274_346_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + } fn submit_unsigned(v: u32, t: u32, a: u32, d: u32, ) -> Weight { (0 as Weight) - // Standard Error: 23_000 - .saturating_add((4_171_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 78_000 - .saturating_add((229_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 23_000 - .saturating_add((13_661_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 117_000 - .saturating_add((4_499_000 as Weight).saturating_mul(d as Weight)) + // Standard Error: 19_000 + .saturating_add((4_017_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 66_000 + .saturating_add((130_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 19_000 + .saturating_add((13_057_000 as Weight).saturating_mul(a as Weight)) + // Standard Error: 99_000 + .saturating_add((4_558_000 as Weight).saturating_mul(d as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight { (0 as Weight) // Standard Error: 12_000 - .saturating_add((4_232_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 42_000 - .saturating_add((636_000 as Weight).saturating_mul(t as Weight)) + .saturating_add((4_186_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 40_000 + .saturating_add((803_000 as Weight).saturating_mul(t as Weight)) // Standard Error: 12_000 - .saturating_add((10_294_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 64_000 - .saturating_add((4_428_000 as Weight).saturating_mul(d as Weight)) + .saturating_add((9_806_000 as Weight).saturating_mul(a as Weight)) + // Standard Error: 61_000 + .saturating_add((4_156_000 as Weight).saturating_mul(d as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) } } diff --git a/primitives/election-providers/Cargo.toml b/frame/election-provider-support/Cargo.toml similarity index 57% rename from primitives/election-providers/Cargo.toml rename to frame/election-provider-support/Cargo.toml index cf12dce8098d7..b360cd89eb57b 100644 --- a/primitives/election-providers/Cargo.toml +++ b/frame/election-provider-support/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "sp-election-providers" +name = "frame-election-provider-support" version = "3.0.0" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" -description = "Primitive election providers" +description = "election provider supporting traits" readme = "README.md" [package.metadata.docs.rs] @@ -14,20 +14,24 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "3.0.0", default-features = false, path = "../std" } -sp-arithmetic = { version = "3.0.0", default-features = false, path = "../arithmetic" } -sp-npos-elections = { version = "3.0.0", default-features = false, path = "../npos-elections" } +sp-std = { version = "3.0.0", default-features = false, path = "../../primitives/std" } +sp-arithmetic = { version = "3.0.0", default-features = false, path = "../../primitives/arithmetic" } +sp-npos-elections = { version = "3.0.0", default-features = false, path = "../../primitives/npos-elections" } +frame-support = { version = "3.0.0", default-features = false, path = "../support" } +frame-system = { version = "3.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-npos-elections = { version = "3.0.0", path = "../npos-elections" } -sp-runtime = { version = "3.0.0", path = "../runtime" } +sp-npos-elections = { version = "3.0.0", path = "../../primitives/npos-elections" } +sp-runtime = { version = "3.0.0", path = "../../primitives/runtime" } [features] default = ["std"] -runtime-benchmarks = [] std = [ "codec/std", "sp-std/std", "sp-npos-elections/std", "sp-arithmetic/std", + "frame-support/std", + "frame-system/std", ] +runtime-benchmarks = [] diff --git a/primitives/election-providers/src/lib.rs b/frame/election-provider-support/src/lib.rs similarity index 75% rename from primitives/election-providers/src/lib.rs rename to frame/election-provider-support/src/lib.rs index 73ea58c176b26..3d7c2dbac90aa 100644 --- a/primitives/election-providers/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -78,14 +78,15 @@ //! ## Example //! //! ```rust -//! # use sp_election_providers::*; +//! # use frame_election_provider_support::{*, data_provider}; //! # use sp_npos_elections::{Support, Assignment}; +//! # use frame_support::weights::Weight; //! //! type AccountId = u64; //! type Balance = u64; //! type BlockNumber = u32; //! -//! mod data_provider { +//! mod data_provider_mod { //! use super::*; //! //! pub trait Config: Sized { @@ -99,14 +100,16 @@ //! pub struct Module(std::marker::PhantomData); //! //! impl ElectionDataProvider for Module { -//! fn desired_targets() -> u32 { -//! 1 +//! fn desired_targets() -> data_provider::Result<(u32, Weight)> { +//! Ok((1, 0)) //! } -//! fn voters() -> Vec<(AccountId, VoteWeight, Vec)> { -//! Default::default() +//! fn voters(maybe_max_len: Option) +//! -> data_provider::Result<(Vec<(AccountId, VoteWeight, Vec)>, Weight)> +//! { +//! Ok((Default::default(), 0)) //! } -//! fn targets() -> Vec { -//! vec![10, 20, 30] +//! fn targets(maybe_max_len: Option) -> data_provider::Result<(Vec, Weight)> { +//! Ok((vec![10, 20, 30], 0)) //! } //! fn next_election_prediction(now: BlockNumber) -> BlockNumber { //! 0 @@ -125,29 +128,30 @@ //! } //! //! impl ElectionProvider for GenericElectionProvider { -//! type Error = (); +//! type Error = &'static str; //! type DataProvider = T::DataProvider; //! -//! fn elect() -> Result, Self::Error> { -//! Self::DataProvider::targets() -//! .first() -//! .map(|winner| vec![(*winner, Support::default())]) -//! .ok_or(()) +//! fn elect() -> Result<(Supports, Weight), Self::Error> { +//! Self::DataProvider::targets(None) +//! .map_err(|_| "failed to elect") +//! .map(|(t, weight)| { +//! (vec![(t[0], Support::default())], weight) +//! }) //! } //! } //! } //! //! mod runtime { //! use super::generic_election_provider; -//! use super::data_provider; +//! use super::data_provider_mod; //! use super::AccountId; //! //! struct Runtime; //! impl generic_election_provider::Config for Runtime { -//! type DataProvider = data_provider::Module; +//! type DataProvider = data_provider_mod::Module; //! } //! -//! impl data_provider::Config for Runtime { +//! impl data_provider_mod::Config for Runtime { //! type ElectionProvider = generic_election_provider::GenericElectionProvider; //! } //! @@ -160,23 +164,44 @@ pub mod onchain; use sp_std::{prelude::*, fmt::Debug}; +use frame_support::weights::Weight; /// Re-export some type as they are used in the interface. pub use sp_arithmetic::PerThing; pub use sp_npos_elections::{Assignment, ExtendedBalance, PerThing128, Supports, VoteWeight}; +/// Types that are used by the data provider trait. +pub mod data_provider { + /// Alias for the result type of the election data provider. + pub type Result = sp_std::result::Result; +} + /// Something that can provide the data to an [`ElectionProvider`]. pub trait ElectionDataProvider { /// All possible targets for the election, i.e. the candidates. - fn targets() -> Vec; + /// + /// If `maybe_max_len` is `Some(v)` then the resulting vector MUST NOT be longer than `v` items + /// long. + /// + /// It is assumed that this function will only consume a notable amount of weight, when it + /// returns `Ok(_)`. + fn targets(maybe_max_len: Option) -> data_provider::Result<(Vec, Weight)>; /// All possible voters for the election. /// /// Note that if a notion of self-vote exists, it should be represented here. - fn voters() -> Vec<(AccountId, VoteWeight, Vec)>; + /// + /// If `maybe_max_len` is `Some(v)` then the resulting vector MUST NOT be longer than `v` items + /// long. + /// + /// It is assumed that this function will only consume a notable amount of weight, when it + /// returns `Ok(_)`. + fn voters( + maybe_max_len: Option, + ) -> data_provider::Result<(Vec<(AccountId, VoteWeight, Vec)>, Weight)>; /// The number of targets to elect. - fn desired_targets() -> u32; + fn desired_targets() -> data_provider::Result<(u32, Weight)>; /// Provide a best effort prediction about when the next election is about to happen. /// @@ -192,20 +217,23 @@ pub trait ElectionDataProvider { fn put_snapshot( _voters: Vec<(AccountId, VoteWeight, Vec)>, _targets: Vec, + _target_stake: Option, ) { } } #[cfg(feature = "std")] impl ElectionDataProvider for () { - fn targets() -> Vec { - Default::default() + fn targets(_maybe_max_len: Option) -> data_provider::Result<(Vec, Weight)> { + Ok(Default::default()) } - fn voters() -> Vec<(AccountId, VoteWeight, Vec)> { - Default::default() + fn voters( + _maybe_max_len: Option, + ) -> data_provider::Result<(Vec<(AccountId, VoteWeight, Vec)>, Weight)> { + Ok(Default::default()) } - fn desired_targets() -> u32 { - Default::default() + fn desired_targets() -> data_provider::Result<(u32, Weight)> { + Ok(Default::default()) } fn next_election_prediction(now: BlockNumber) -> BlockNumber { now @@ -226,8 +254,8 @@ pub trait ElectionProvider { /// Elect a new set of winners. /// - /// The result is returned in a target major format, namely as vector of supports. - fn elect() -> Result, Self::Error>; + /// The result is returned in a target major format, namely as vector of supports. + fn elect() -> Result<(Supports, Weight), Self::Error>; } #[cfg(feature = "std")] @@ -235,7 +263,7 @@ impl ElectionProvider for () { type Error = &'static str; type DataProvider = (); - fn elect() -> Result, Self::Error> { + fn elect() -> Result<(Supports, Weight), Self::Error> { Err("<() as ElectionProvider> cannot do anything.") } } diff --git a/primitives/election-providers/src/onchain.rs b/frame/election-provider-support/src/onchain.rs similarity index 70% rename from primitives/election-providers/src/onchain.rs rename to frame/election-provider-support/src/onchain.rs index b50dff2ff17d9..b00c8698037c1 100644 --- a/primitives/election-providers/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -20,12 +20,15 @@ use crate::{ElectionDataProvider, ElectionProvider}; use sp_npos_elections::*; use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData, prelude::*}; +use frame_support::{traits::Get, weights::Weight}; /// Errors of the on-chain election. #[derive(Eq, PartialEq, Debug)] pub enum Error { /// An internal error in the NPoS elections crate. NposElections(sp_npos_elections::Error), + /// Errors from the data provider. + DataProvider(&'static str), } impl From for Error { @@ -40,13 +43,20 @@ impl From for Error { /// /// ### Warning /// -/// This can be very expensive to run frequently on-chain. Use with care. +/// This can be very expensive to run frequently on-chain. Use with care. Moreover, this +/// implementation ignores the additional data of the election data provider and gives no insight on +/// how much weight was consumed. +/// +/// Finally, this implementation does not impose any limits on the number of voters and targets that +/// are provided. pub struct OnChainSequentialPhragmen(PhantomData); /// Configuration trait of [`OnChainSequentialPhragmen`]. /// /// Note that this is similar to a pallet traits, but [`OnChainSequentialPhragmen`] is not a pallet. pub trait Config { + /// The block limits. + type BlockWeights: Get; /// The account identifier type. type AccountId: IdentifierT; /// The block number type. @@ -61,10 +71,11 @@ impl ElectionProvider for OnChainSequen type Error = Error; type DataProvider = T::DataProvider; - fn elect() -> Result, Self::Error> { - let voters = Self::DataProvider::voters(); - let targets = Self::DataProvider::targets(); - let desired_targets = Self::DataProvider::desired_targets() as usize; + fn elect() -> Result<(Supports, Weight), Self::Error> { + let (voters, _) = Self::DataProvider::voters(None).map_err(Error::DataProvider)?; + let (targets, _) = Self::DataProvider::targets(None).map_err(Error::DataProvider)?; + let (desired_targets, _) = + Self::DataProvider::desired_targets().map_err(Error::DataProvider)?; let mut stake_map: BTreeMap = BTreeMap::new(); @@ -77,13 +88,13 @@ impl ElectionProvider for OnChainSequen }; let ElectionResult { winners, assignments } = - seq_phragmen::<_, T::Accuracy>(desired_targets, targets, voters, None) + seq_phragmen::<_, T::Accuracy>(desired_targets as usize, targets, voters, None) .map_err(Error::from)?; let staked = assignment_ratio_to_staked_normalized(assignments, &stake_of)?; let winners = to_without_backing(winners); - to_supports(&winners, &staked).map_err(Error::from) + to_supports(&winners, &staked).map_err(Error::from).map(|s| (s, T::BlockWeights::get().max_block)) } } @@ -92,12 +103,13 @@ mod tests { use super::*; use sp_npos_elections::Support; use sp_runtime::Perbill; + use frame_support::weights::Weight; type AccountId = u64; type BlockNumber = u32; - struct Runtime; impl Config for Runtime { + type BlockWeights = (); type AccountId = AccountId; type BlockNumber = BlockNumber; type Accuracy = Perbill; @@ -108,24 +120,23 @@ mod tests { mod mock_data_provider { use super::*; + use crate::data_provider; pub struct DataProvider; impl ElectionDataProvider for DataProvider { - fn voters() -> Vec<(AccountId, VoteWeight, Vec)> { - vec![ - (1, 10, vec![10, 20]), - (2, 20, vec![30, 20]), - (3, 30, vec![10, 30]), - ] + fn voters( + _: Option, + ) -> data_provider::Result<(Vec<(AccountId, VoteWeight, Vec)>, Weight)> { + Ok((vec![(1, 10, vec![10, 20]), (2, 20, vec![30, 20]), (3, 30, vec![10, 30])], 0)) } - fn targets() -> Vec { - vec![10, 20, 30] + fn targets(_: Option) -> data_provider::Result<(Vec, Weight)> { + Ok((vec![10, 20, 30], 0)) } - fn desired_targets() -> u32 { - 2 + fn desired_targets() -> data_provider::Result<(u32, Weight)> { + Ok((2, 0)) } fn next_election_prediction(_: BlockNumber) -> BlockNumber { @@ -137,7 +148,7 @@ mod tests { #[test] fn onchain_seq_phragmen_works() { assert_eq!( - OnChainPhragmen::elect().unwrap(), + OnChainPhragmen::elect().unwrap().0, vec![ ( 10, diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index 2bf7306f58e15..547e3966d52a4 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -39,7 +39,7 @@ pallet-offences = { version = "3.0.0", path = "../offences" } pallet-staking = { version = "3.0.0", path = "../staking" } pallet-staking-reward-curve = { version = "3.0.0", path = "../staking/reward-curve" } pallet-timestamp = { version = "3.0.0", path = "../timestamp" } -sp-election-providers = { version = "3.0.0", path = "../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", path = "../election-provider-support" } [features] default = ["std"] diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 0a24a2344547e..6e83ae481d271 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -40,7 +40,7 @@ use sp_runtime::{ }; use sp_staking::SessionIndex; use pallet_session::historical as pallet_session_historical; -use sp_election_providers::onchain; +use frame_election_provider_support::onchain; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -193,6 +193,7 @@ parameter_types! { impl onchain::Config for Test { type AccountId = ::AccountId; type BlockNumber = ::BlockNumber; + type BlockWeights = (); type Accuracy = Perbill; type DataProvider = Staking; } diff --git a/frame/offences/benchmarking/Cargo.toml b/frame/offences/benchmarking/Cargo.toml index 6be2787734a4f..6c249ebcc61d8 100644 --- a/frame/offences/benchmarking/Cargo.toml +++ b/frame/offences/benchmarking/Cargo.toml @@ -27,7 +27,7 @@ pallet-staking = { version = "3.0.0", default-features = false, features = ["run sp-runtime = { version = "3.0.0", default-features = false, path = "../../../primitives/runtime" } sp-staking = { version = "3.0.0", default-features = false, path = "../../../primitives/staking" } sp-std = { version = "3.0.0", default-features = false, path = "../../../primitives/std" } -sp-election-providers = { version = "3.0.0", default-features = false, path = "../../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", default-features = false, path = "../../election-provider-support" } [dev-dependencies] pallet-staking-reward-curve = { version = "3.0.0", path = "../../staking/reward-curve" } @@ -51,7 +51,7 @@ std = [ "pallet-staking/std", "sp-runtime/std", "sp-staking/std", - "sp-election-providers/std", + "frame-election-provider-support/std", "sp-std/std", "codec/std", ] diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 54d649381eea6..d659025247d1e 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -29,7 +29,7 @@ use sp_runtime::{ traits::IdentityLookup, testing::{Header, UintAuthorityId}, }; -use sp_election_providers::onchain; +use frame_election_provider_support::onchain; use pallet_session::historical as pallet_session_historical; type AccountId = u64; @@ -152,6 +152,7 @@ pub type Extrinsic = sp_runtime::testing::TestXt; impl onchain::Config for Test { type AccountId = AccountId; type BlockNumber = BlockNumber; + type BlockWeights = (); type Accuracy = Perbill; type DataProvider = Staking; } diff --git a/frame/session/benchmarking/Cargo.toml b/frame/session/benchmarking/Cargo.toml index 47265ed5ef7a8..0c83347b1991f 100644 --- a/frame/session/benchmarking/Cargo.toml +++ b/frame/session/benchmarking/Cargo.toml @@ -31,14 +31,14 @@ pallet-staking-reward-curve = { version = "3.0.0", path = "../../staking/reward- sp-io ={ version = "3.0.0", path = "../../../primitives/io" } pallet-timestamp = { version = "3.0.0", path = "../../timestamp" } pallet-balances = { version = "3.0.0", path = "../../balances" } -sp-election-providers = { version = "3.0.0", path = "../../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", path = "../../election-provider-support" } [features] default = ["std"] std = [ "sp-std/std", "sp-session/std", - "sp-election-providers/std", + "frame-election-provider-support/std", "sp-runtime/std", "frame-system/std", "frame-benchmarking/std", diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 0eba5452b28d0..8c392c4e10969 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -20,7 +20,7 @@ #![cfg(test)] use sp_runtime::traits::IdentityLookup; -use sp_election_providers::onchain; +use frame_election_provider_support::onchain; use frame_support::parameter_types; type AccountId = u64; @@ -157,6 +157,7 @@ where impl onchain::Config for Test { type AccountId = AccountId; type BlockNumber = BlockNumber; + type BlockWeights = (); type Accuracy = sp_runtime::Perbill; type DataProvider = Staking; } diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 1f9f29570a223..b4c2819403720 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -28,7 +28,7 @@ pallet-session = { version = "3.0.0", default-features = false, features = ["his pallet-authorship = { version = "3.0.0", default-features = false, path = "../authorship" } sp-application-crypto = { version = "3.0.0", default-features = false, path = "../../primitives/application-crypto" } log = { version = "0.4.14", default-features = false } -sp-election-providers = { version = "3.0.0", default-features = false, path = "../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", default-features = false, path = "../election-provider-support" } # Optional imports for benchmarking frame-benchmarking = { version = "3.1.0", default-features = false, path = "../benchmarking", optional = true } @@ -43,7 +43,7 @@ pallet-timestamp = { version = "3.0.0", path = "../timestamp" } pallet-staking-reward-curve = { version = "3.0.0", path = "../staking/reward-curve" } substrate-test-utils = { version = "3.0.0", path = "../../test-utils" } frame-benchmarking = { version = "3.1.0", path = "../benchmarking" } -sp-election-providers = { version = "3.0.0", features = ["runtime-benchmarks"], path = "../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", features = ["runtime-benchmarks"], path = "../election-provider-support" } rand_chacha = { version = "0.2" } parking_lot = "0.11.1" hex = "0.4" @@ -64,11 +64,11 @@ std = [ "pallet-authorship/std", "sp-application-crypto/std", "log/std", - "sp-election-providers/std", + "frame-election-provider-support/std", ] runtime-benchmarks = [ "frame-benchmarking", - "sp-election-providers/runtime-benchmarks", + "frame-election-provider-support/runtime-benchmarks", "rand_chacha", ] try-runtime = ["frame-support/try-runtime"] diff --git a/frame/staking/fuzzer/Cargo.toml b/frame/staking/fuzzer/Cargo.toml index 84758c6bf65ce..fb36327e5e919 100644 --- a/frame/staking/fuzzer/Cargo.toml +++ b/frame/staking/fuzzer/Cargo.toml @@ -28,7 +28,7 @@ sp-io ={ version = "3.0.0", path = "../../../primitives/io" } sp-core = { version = "3.0.0", path = "../../../primitives/core" } sp-npos-elections = { version = "3.0.0", path = "../../../primitives/npos-elections" } sp-runtime = { version = "3.0.0", path = "../../../primitives/runtime" } -sp-election-providers = { version = "3.0.0", path = "../../../primitives/election-providers" } +frame-election-provider-support = { version = "3.0.0", path = "../../election-provider-support" } serde = "1.0.101" [features] diff --git a/frame/staking/fuzzer/src/mock.rs b/frame/staking/fuzzer/src/mock.rs index 05d001d23858e..a87e1fc083013 100644 --- a/frame/staking/fuzzer/src/mock.rs +++ b/frame/staking/fuzzer/src/mock.rs @@ -158,11 +158,16 @@ where } pub struct MockElectionProvider; -impl sp_election_providers::ElectionProvider for MockElectionProvider { +impl frame_election_provider_support::ElectionProvider + for MockElectionProvider +{ type Error = (); type DataProvider = pallet_staking::Module; - fn elect() -> Result, Self::Error> { + fn elect() -> Result< + (sp_npos_elections::Supports, frame_support::weights::Weight), + Self::Error + > { Err(()) } } diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index ecaa9889b5fb2..8e0273622b059 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -25,12 +25,9 @@ use sp_npos_elections::CompactSolution; use sp_runtime::traits::One; use frame_system::RawOrigin; pub use frame_benchmarking::{ - benchmarks, - account, - whitelisted_caller, - whitelist_account, - impl_benchmark_test_suite, + benchmarks, account, whitelisted_caller, whitelist_account, impl_benchmark_test_suite, }; + const SEED: u32 = 0; const MAX_SPANS: u32 = 100; const MAX_VALIDATORS: u32 = 1000; @@ -768,6 +765,39 @@ benchmarks! { ).is_err() ); } + + get_npos_voters { + // number of validator intention. + let v in 200 .. 400; + // number of nominator intention. + let n in 200 .. 400; + // total number of slashing spans. Assigned to validators randomly. + let s in 1 .. 20; + + let validators = create_validators_with_nominators_for_era::(v, n, MAX_NOMINATIONS, false, None)? + .into_iter() + .map(|v| T::Lookup::lookup(v).unwrap()) + .collect::>(); + + (0..s).for_each(|index| { + add_slashing_spans::(&validators[index as usize], 10); + }); + }: { + let voters = >::get_npos_voters(); + assert_eq!(voters.len() as u32, v + n); + } + + get_npos_targets { + // number of validator intention. + let v in 200 .. 400; + // number of nominator intention. + let n = 500; + + let _ = create_validators_with_nominators_for_era::(v, n, MAX_NOMINATIONS, false, None)?; + }: { + let targets = >::get_npos_targets(); + assert_eq!(targets.len() as u32, v); + } } #[cfg(test)] @@ -875,7 +905,6 @@ mod tests { assert_ok!(test_benchmark_submit_solution_weaker::()); }); } - } impl_benchmark_test_suite!( diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index c57fac43c5600..239effc364434 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -331,7 +331,7 @@ use sp_npos_elections::{ to_supports, EvaluateSupport, seq_phragmen, generate_solution_type, is_score_better, Supports, VoteWeight, CompactSolution, PerThing128, }; -use sp_election_providers::ElectionProvider; +use frame_election_provider_support::{ElectionProvider, data_provider}; pub use weights::WeightInfo; const STAKING_ID: LockIdentifier = *b"staking "; @@ -800,7 +800,7 @@ pub trait Config: frame_system::Config + SendTransactionTypes> { type CurrencyToVote: CurrencyToVote>; /// Something that provides the election functionality. - type ElectionProvider: sp_election_providers::ElectionProvider< + type ElectionProvider: frame_election_provider_support::ElectionProvider< Self::AccountId, Self::BlockNumber, // we only accept an election provider that has staking as data provider. @@ -3345,19 +3345,45 @@ impl Module { } } -impl sp_election_providers::ElectionDataProvider +impl frame_election_provider_support::ElectionDataProvider for Module { - fn desired_targets() -> u32 { - Self::validator_count() + fn desired_targets() -> data_provider::Result<(u32, Weight)> { + Ok((Self::validator_count(), ::DbWeight::get().reads(1))) } - fn voters() -> Vec<(T::AccountId, VoteWeight, Vec)> { - Self::get_npos_voters() + fn voters( + maybe_max_len: Option, + ) -> data_provider::Result<(Vec<(T::AccountId, VoteWeight, Vec)>, Weight)> { + // NOTE: reading these counts already needs to iterate a lot of storage keys, but they get + // cached. This is okay for the case of `Ok(_)`, but bad for `Err(_)`, as the trait does not + // report weight in failures. + let nominator_count = >::iter().count(); + let validator_count = >::iter().count(); + let voter_count = nominator_count.saturating_add(validator_count); + + if maybe_max_len.map_or(false, |max_len| voter_count > max_len) { + return Err("Voter snapshot too big"); + } + + let slashing_span_count = >::iter().count(); + let weight = T::WeightInfo::get_npos_voters( + nominator_count as u32, + validator_count as u32, + slashing_span_count as u32, + ); + Ok((Self::get_npos_voters(), weight)) } - fn targets() -> Vec { - Self::get_npos_targets() + fn targets(maybe_max_len: Option) -> data_provider::Result<(Vec, Weight)> { + let target_count = >::iter().count(); + + if maybe_max_len.map_or(false, |max_len| target_count > max_len) { + return Err("Target snapshot too big"); + } + + let weight = ::DbWeight::get().reads(target_count as u64); + Ok((Self::get_npos_targets(), weight)) } fn next_election_prediction(now: T::BlockNumber) -> T::BlockNumber { @@ -3391,15 +3417,45 @@ impl sp_election_providers::ElectionDataProvider)>, targets: Vec, + target_stake: Option, ) { + use sp_std::convert::TryFrom; targets.into_iter().for_each(|v| { + let stake: BalanceOf = target_stake + .and_then(|w| >::try_from(w).ok()) + .unwrap_or(T::Currency::minimum_balance() * 100u32.into()); + >::insert(v.clone(), v.clone()); + >::insert( + v.clone(), + StakingLedger { + stash: v.clone(), + active: stake, + total: stake, + unlocking: vec![], + claimed_rewards: vec![], + }, + ); >::insert( v, ValidatorPrefs { commission: Perbill::zero(), blocked: false }, ); }); - voters.into_iter().for_each(|(v, _s, t)| { + voters.into_iter().for_each(|(v, s, t)| { + let stake = >::try_from(s).unwrap_or_else(|_| { + panic!("cannot convert a VoteWeight into BalanceOf, benchmark needs reconfiguring.") + }); + >::insert(v.clone(), v.clone()); + >::insert( + v.clone(), + StakingLedger { + stash: v.clone(), + active: stake, + total: stake, + unlocking: vec![], + claimed_rewards: vec![], + }, + ); >::insert( v, Nominations { targets: t, submitted_in: 0, suppressed: false }, diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 0d6701c48b894..b0e3d9629a358 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -37,7 +37,7 @@ use sp_runtime::{ }; use sp_staking::offence::{OffenceDetails, OnOffenceHandler}; use std::{cell::RefCell, collections::HashSet}; -use sp_election_providers::onchain; +use frame_election_provider_support::onchain; pub const INIT_TIMESTAMP: u64 = 30_000; pub const BLOCK_TIME: u64 = 1000; @@ -243,6 +243,7 @@ impl OnUnbalanced> for RewardRemainderMock { impl onchain::Config for Test { type AccountId = AccountId; type BlockNumber = BlockNumber; + type BlockWeights = BlockWeights; type Accuracy = Perbill; type DataProvider = Staking; } diff --git a/frame/staking/src/offchain_election.rs b/frame/staking/src/offchain_election.rs index 8398c2022fc3f..cacfe454ec709 100644 --- a/frame/staking/src/offchain_election.rs +++ b/frame/staking/src/offchain_election.rs @@ -521,6 +521,12 @@ mod test { fn kick(w: u32) -> Weight { unimplemented!() } + fn get_npos_voters(v: u32, n: u32, s: u32) -> Weight { + unimplemented!() + } + fn get_npos_targets(v: u32) -> Weight { + unimplemented!() + } } #[test] diff --git a/frame/staking/src/testing_utils.rs b/frame/staking/src/testing_utils.rs index f6ee89704d8d2..5affc50d81df7 100644 --- a/frame/staking/src/testing_utils.rs +++ b/frame/staking/src/testing_utils.rs @@ -112,10 +112,10 @@ pub fn create_validators( /// - `nominators`: number of bonded nominators. /// - `edge_per_nominator`: number of edge (vote) per nominator. /// - `randomize_stake`: whether to randomize the stakes. -/// - `to_nominate`: if `Some(n)`, only the first `n` bonded validator are voted upon. -/// Else, all of them are considered and `edge_per_nominator` random validators are voted for. +/// - `to_nominate`: if `Some(n)`, only the first `n` bonded validator are voted upon. Else, all of +/// them are considered and `edge_per_nominator` random validators are voted for. /// -/// Return the validators choosen to be nominated. +/// Return the validators chosen to be nominated. pub fn create_validators_with_nominators_for_era( validators: u32, nominators: u32, diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 92e1862e39813..0008f8cdba6dc 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5019,12 +5019,14 @@ fn do_not_die_when_active_is_ed() { mod election_data_provider { use super::*; - use sp_election_providers::ElectionDataProvider; + use frame_election_provider_support::ElectionDataProvider; #[test] fn voters_include_self_vote() { ExtBuilder::default().nominate(false).build().execute_with(|| { - assert!(>::iter().map(|(x, _)| x).all(|v| Staking::voters() + assert!(>::iter().map(|(x, _)| x).all(|v| Staking::voters(None) + .unwrap() + .0 .into_iter() .find(|(w, _, t)| { v == *w && t[0] == *w }) .is_some())) @@ -5036,7 +5038,9 @@ mod election_data_provider { ExtBuilder::default().build().execute_with(|| { assert_eq!(Staking::nominators(101).unwrap().targets, vec![11, 21]); assert_eq!( - >::voters() + >::voters(None) + .unwrap() + .0 .iter() .find(|x| x.0 == 101) .unwrap() @@ -5050,7 +5054,9 @@ mod election_data_provider { // 11 is gone. start_active_era(2); assert_eq!( - >::voters() + >::voters(None) + .unwrap() + .0 .iter() .find(|x| x.0 == 101) .unwrap() @@ -5061,7 +5067,9 @@ mod election_data_provider { // resubmit and it is back assert_ok!(Staking::nominate(Origin::signed(100), vec![11, 21])); assert_eq!( - >::voters() + >::voters(None) + .unwrap() + .0 .iter() .find(|x| x.0 == 101) .unwrap() @@ -5071,6 +5079,14 @@ mod election_data_provider { }) } + #[test] + fn respects_len_limits() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(Staking::voters(Some(1)).unwrap_err(), "Voter snapshot too big"); + assert_eq!(Staking::targets(Some(1)).unwrap_err(), "Target snapshot too big"); + }); + } + #[test] fn estimate_next_election_works() { ExtBuilder::default().session_per_era(5).period(5).build().execute_with(|| { diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index 3489a10135427..e895a9e4d51ea 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-02-13, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: [], HIGH RANGE: [] +//! DATE: 2021-03-14, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -69,161 +69,163 @@ pub trait WeightInfo { fn reap_stash(s: u32, ) -> Weight; fn new_era(v: u32, n: u32, ) -> Weight; fn submit_solution_better(v: u32, n: u32, a: u32, w: u32, ) -> Weight; + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight; + fn get_npos_targets(v: u32, ) -> Weight; } /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn bond() -> Weight { - (81_642_000 as Weight) + (80_317_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn bond_extra() -> Weight { - (66_025_000 as Weight) + (64_495_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn unbond() -> Weight { - (60_810_000 as Weight) + (59_679_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn withdraw_unbonded_update(s: u32, ) -> Weight { - (61_537_000 as Weight) + (61_078_000 as Weight) // Standard Error: 1_000 - .saturating_add((60_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((40_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (95_741_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_754_000 as Weight).saturating_mul(s as Weight)) + (95_129_000 as Weight) + // Standard Error: 2_000 + .saturating_add((2_755_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn validate() -> Weight { - (21_009_000 as Weight) + (20_608_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn kick(k: u32, ) -> Weight { - (31_832_000 as Weight) - // Standard Error: 15_000 - .saturating_add((19_418_000 as Weight).saturating_mul(k as Weight)) + (33_365_000 as Weight) + // Standard Error: 11_000 + .saturating_add((18_830_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } fn nominate(n: u32, ) -> Weight { - (34_304_000 as Weight) - // Standard Error: 20_000 - .saturating_add((5_643_000 as Weight).saturating_mul(n as Weight)) + (33_885_000 as Weight) + // Standard Error: 22_000 + .saturating_add((5_562_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn chill() -> Weight { - (20_103_000 as Weight) + (19_741_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn set_payee() -> Weight { - (13_858_000 as Weight) + (13_674_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn set_controller() -> Weight { - (30_269_000 as Weight) + (29_691_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn set_validator_count() -> Weight { - (2_444_000 as Weight) + (2_375_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn force_no_eras() -> Weight { - (2_766_000 as Weight) + (2_601_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn force_new_era() -> Weight { - (2_724_000 as Weight) + (2_605_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn force_new_era_always() -> Weight { - (2_702_000 as Weight) + (2_584_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn set_invulnerables(v: u32, ) -> Weight { - (2_914_000 as Weight) + (2_725_000 as Weight) // Standard Error: 0 .saturating_add((35_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn force_unstake(s: u32, ) -> Weight { - (64_032_000 as Weight) - // Standard Error: 2_000 - .saturating_add((2_787_000 as Weight).saturating_mul(s as Weight)) + (63_551_000 as Weight) + // Standard Error: 7_000 + .saturating_add((2_844_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn cancel_deferred_slash(s: u32, ) -> Weight { - (5_903_394_000 as Weight) + (5_905_400_000 as Weight) // Standard Error: 391_000 - .saturating_add((34_834_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((34_785_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (141_724_000 as Weight) - // Standard Error: 24_000 - .saturating_add((53_018_000 as Weight).saturating_mul(n as Weight)) + (142_264_000 as Weight) + // Standard Error: 22_000 + .saturating_add((52_542_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) } fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (159_994_000 as Weight) - // Standard Error: 28_000 - .saturating_add((67_746_000 as Weight).saturating_mul(n as Weight)) + (180_166_000 as Weight) + // Standard Error: 23_000 + .saturating_add((66_767_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(12 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } fn rebond(l: u32, ) -> Weight { - (42_177_000 as Weight) - // Standard Error: 1_000 - .saturating_add((82_000 as Weight).saturating_mul(l as Weight)) + (42_577_000 as Weight) + // Standard Error: 12_000 + .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 65_000 - .saturating_add((34_151_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 68_000 + .saturating_add((33_362_000 as Weight).saturating_mul(e as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } fn reap_stash(s: u32, ) -> Weight { - (68_377_000 as Weight) - // Standard Error: 0 - .saturating_add((2_757_000 as Weight).saturating_mul(s as Weight)) + (68_474_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_770_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 908_000 - .saturating_add((588_562_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 903_000 + .saturating_add((594_145_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 45_000 - .saturating_add((83_485_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((83_373_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) @@ -233,172 +235,191 @@ impl WeightInfo for SubstrateWeight { fn submit_solution_better(v: u32, n: u32, a: u32, w: u32, ) -> Weight { (0 as Weight) // Standard Error: 52_000 - .saturating_add((750_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((1_460_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 20_000 - .saturating_add((556_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((754_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 52_000 - .saturating_add((76_201_000 as Weight).saturating_mul(a as Weight)) + .saturating_add((74_798_000 as Weight).saturating_mul(a as Weight)) // Standard Error: 108_000 - .saturating_add((7_271_000 as Weight).saturating_mul(w as Weight)) + .saturating_add((8_108_000 as Weight).saturating_mul(w as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(a as Weight))) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 94_000 + .saturating_add((29_321_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 94_000 + .saturating_add((66_885_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_283_000 + .saturating_add((22_991_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(v as Weight))) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + } + fn get_npos_targets(v: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 26_000 + .saturating_add((10_972_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } } // For backwards compatibility and tests impl WeightInfo for () { fn bond() -> Weight { - (81_642_000 as Weight) + (80_317_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } fn bond_extra() -> Weight { - (66_025_000 as Weight) + (64_495_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn unbond() -> Weight { - (60_810_000 as Weight) + (59_679_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn withdraw_unbonded_update(s: u32, ) -> Weight { - (61_537_000 as Weight) + (61_078_000 as Weight) // Standard Error: 1_000 - .saturating_add((60_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((40_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (95_741_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_754_000 as Weight).saturating_mul(s as Weight)) + (95_129_000 as Weight) + // Standard Error: 2_000 + .saturating_add((2_755_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn validate() -> Weight { - (21_009_000 as Weight) + (20_608_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn kick(k: u32, ) -> Weight { - (31_832_000 as Weight) - // Standard Error: 15_000 - .saturating_add((19_418_000 as Weight).saturating_mul(k as Weight)) + (33_365_000 as Weight) + // Standard Error: 11_000 + .saturating_add((18_830_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } fn nominate(n: u32, ) -> Weight { - (34_304_000 as Weight) - // Standard Error: 20_000 - .saturating_add((5_643_000 as Weight).saturating_mul(n as Weight)) + (33_885_000 as Weight) + // Standard Error: 22_000 + .saturating_add((5_562_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn chill() -> Weight { - (20_103_000 as Weight) + (19_741_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn set_payee() -> Weight { - (13_858_000 as Weight) + (13_674_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn set_controller() -> Weight { - (30_269_000 as Weight) + (29_691_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn set_validator_count() -> Weight { - (2_444_000 as Weight) + (2_375_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn force_no_eras() -> Weight { - (2_766_000 as Weight) + (2_601_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn force_new_era() -> Weight { - (2_724_000 as Weight) + (2_605_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn force_new_era_always() -> Weight { - (2_702_000 as Weight) + (2_584_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn set_invulnerables(v: u32, ) -> Weight { - (2_914_000 as Weight) + (2_725_000 as Weight) // Standard Error: 0 .saturating_add((35_000 as Weight).saturating_mul(v as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn force_unstake(s: u32, ) -> Weight { - (64_032_000 as Weight) - // Standard Error: 2_000 - .saturating_add((2_787_000 as Weight).saturating_mul(s as Weight)) + (63_551_000 as Weight) + // Standard Error: 7_000 + .saturating_add((2_844_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn cancel_deferred_slash(s: u32, ) -> Weight { - (5_903_394_000 as Weight) + (5_905_400_000 as Weight) // Standard Error: 391_000 - .saturating_add((34_834_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((34_785_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (141_724_000 as Weight) - // Standard Error: 24_000 - .saturating_add((53_018_000 as Weight).saturating_mul(n as Weight)) + (142_264_000 as Weight) + // Standard Error: 22_000 + .saturating_add((52_542_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) } fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (159_994_000 as Weight) - // Standard Error: 28_000 - .saturating_add((67_746_000 as Weight).saturating_mul(n as Weight)) + (180_166_000 as Weight) + // Standard Error: 23_000 + .saturating_add((66_767_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(12 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } fn rebond(l: u32, ) -> Weight { - (42_177_000 as Weight) - // Standard Error: 1_000 - .saturating_add((82_000 as Weight).saturating_mul(l as Weight)) + (42_577_000 as Weight) + // Standard Error: 12_000 + .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 65_000 - .saturating_add((34_151_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 68_000 + .saturating_add((33_362_000 as Weight).saturating_mul(e as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } fn reap_stash(s: u32, ) -> Weight { - (68_377_000 as Weight) - // Standard Error: 0 - .saturating_add((2_757_000 as Weight).saturating_mul(s as Weight)) + (68_474_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_770_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 908_000 - .saturating_add((588_562_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 903_000 + .saturating_add((594_145_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 45_000 - .saturating_add((83_485_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((83_373_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(9 as Weight)) .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) @@ -408,16 +429,35 @@ impl WeightInfo for () { fn submit_solution_better(v: u32, n: u32, a: u32, w: u32, ) -> Weight { (0 as Weight) // Standard Error: 52_000 - .saturating_add((750_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((1_460_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 20_000 - .saturating_add((556_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((754_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 52_000 - .saturating_add((76_201_000 as Weight).saturating_mul(a as Weight)) + .saturating_add((74_798_000 as Weight).saturating_mul(a as Weight)) // Standard Error: 108_000 - .saturating_add((7_271_000 as Weight).saturating_mul(w as Weight)) + .saturating_add((8_108_000 as Weight).saturating_mul(w as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(a as Weight))) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(w as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 94_000 + .saturating_add((29_321_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 94_000 + .saturating_add((66_885_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_283_000 + .saturating_add((22_991_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(v as Weight))) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + } + fn get_npos_targets(v: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 26_000 + .saturating_add((10_972_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } } diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index aa8bce966192e..fe601f995ce51 100644 --- a/frame/system/src/offchain.rs +++ b/frame/system/src/offchain.rs @@ -38,10 +38,10 @@ //! //! To be able to use signing, the following trait should be implemented: //! -//! - [`AppCrypto`](./trait.AppCrypto.html): where an application-specific key -//! is defined and can be used by this module's helpers for signing. -//! - [`CreateSignedTransaction`](./trait.CreateSignedTransaction.html): where -//! the manner in which the transaction is constructed is defined. +//! - [`AppCrypto`](./trait.AppCrypto.html): where an application-specific key is defined and can be +//! used by this module's helpers for signing. +//! - [`CreateSignedTransaction`](./trait.CreateSignedTransaction.html): where the manner in which +//! the transaction is constructed is defined. //! //! #### Submit an unsigned transaction with a signed payload //! @@ -53,7 +53,6 @@ //! #### Submit a signed transaction //! //! [`Signer`](./struct.Signer.html) can be used to sign/verify payloads -//! #![warn(missing_docs)] @@ -473,7 +472,7 @@ pub trait SendTransactionTypes { /// The runtime's call type. /// /// This has additional bound to be able to be created from pallet-local `Call` types. - type OverarchingCall: From; + type OverarchingCall: From + codec::Encode; } /// Create signed transaction. diff --git a/primitives/npos-elections/src/lib.rs b/primitives/npos-elections/src/lib.rs index c87085ef9ff8f..433c470d57d43 100644 --- a/primitives/npos-elections/src/lib.rs +++ b/primitives/npos-elections/src/lib.rs @@ -142,10 +142,22 @@ pub trait CompactSolution: Sized { const LIMIT: usize; /// The voter type. Needs to be an index (convert to usize). - type Voter: UniqueSaturatedInto + TryInto + TryFrom + Debug + Copy + Clone; + type Voter: UniqueSaturatedInto + + TryInto + + TryFrom + + Debug + + Copy + + Clone + + Bounded; /// The target type. Needs to be an index (convert to usize). - type Target: UniqueSaturatedInto + TryInto + TryFrom + Debug + Copy + Clone; + type Target: UniqueSaturatedInto + + TryInto + + TryFrom + + Debug + + Copy + + Clone + + Bounded; /// The weight/accuracy type of each vote. type Accuracy: PerThing128;