From 60eab08d8fc5d0a984ddd422b161ae3659019c4a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 11 Feb 2020 16:33:28 +0300 Subject: [PATCH 01/19] Add proposals modules - add iteration 2 codex and engine modules --- modules/proposals/codex/Cargo.lock | 1913 +++++++++++++++++ modules/proposals/codex/Cargo.toml | 103 + modules/proposals/codex/src/lib.rs | 55 + modules/proposals/codex/src/proposal_types.rs | 69 + modules/proposals/codex/src/tests/mock.rs | 122 ++ modules/proposals/codex/src/tests/mod.rs | 28 + modules/proposals/engine/Cargo.lock | 1895 ++++++++++++++++ modules/proposals/engine/Cargo.toml | 98 + modules/proposals/engine/src/errors.rs | 17 + modules/proposals/engine/src/lib.rs | 348 +++ modules/proposals/engine/src/tests/mock.rs | 210 ++ modules/proposals/engine/src/tests/mod.rs | 742 +++++++ modules/proposals/engine/src/types.rs | 435 ++++ 13 files changed, 6035 insertions(+) create mode 100644 modules/proposals/codex/Cargo.lock create mode 100644 modules/proposals/codex/Cargo.toml create mode 100644 modules/proposals/codex/src/lib.rs create mode 100644 modules/proposals/codex/src/proposal_types.rs create mode 100644 modules/proposals/codex/src/tests/mock.rs create mode 100644 modules/proposals/codex/src/tests/mod.rs create mode 100644 modules/proposals/engine/Cargo.lock create mode 100644 modules/proposals/engine/Cargo.toml create mode 100644 modules/proposals/engine/src/errors.rs create mode 100644 modules/proposals/engine/src/lib.rs create mode 100644 modules/proposals/engine/src/tests/mock.rs create mode 100644 modules/proposals/engine/src/tests/mod.rs create mode 100644 modules/proposals/engine/src/types.rs diff --git a/modules/proposals/codex/Cargo.lock b/modules/proposals/codex/Cargo.lock new file mode 100644 index 0000000000..8735dda80e --- /dev/null +++ b/modules/proposals/codex/Cargo.lock @@ -0,0 +1,1913 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "ahash" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3" +dependencies = [ + "const-random", +] + +[[package]] +name = "aho-corasick" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811" +dependencies = [ + "memchr", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + +[[package]] +name = "arrayvec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" + +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" + +[[package]] +name = "backtrace" +version = "0.3.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f80256bc78f67e7df7e36d77366f636ed976895d91fe2ab9efa3973e8fe8c4f" +dependencies = [ + "backtrace-sys", + "cfg-if", + "libc", + "rustc-demangle", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "base58" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bitmask" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" + +[[package]] +name = "bitvec" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" + +[[package]] +name = "blake2-rfc" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +dependencies = [ + "arrayvec 0.4.12", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "byte-slice-cast" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "c2-chacha" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" +dependencies = [ + "ppv-lite86", +] + +[[package]] +name = "cc" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "clear_on_drop" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" +dependencies = [ + "cc", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "const-random" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a" +dependencies = [ + "getrandom", + "proc-macro-hack", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +dependencies = [ + "generic-array", + "subtle 1.0.0", +] + +[[package]] +name = "curve25519-dalek" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" +dependencies = [ + "byteorder", + "clear_on_drop", + "digest", + "rand_core 0.3.1", + "subtle 2.2.2", +] + +[[package]] +name = "derivative" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942ca430eef7a3806595a6737bc388bf51adb888d3fc0dd1b50f1c170167ee3a" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ed25519-dalek" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d07e8b8a8386c3b89a7a4b329fdfa4cb545de2545e9e2ebbc3dd3929253e426" +dependencies = [ + "clear_on_drop", + "curve25519-dalek", + "failure", + "rand 0.6.5", +] + +[[package]] +name = "elastic-array" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" +dependencies = [ + "heapsize", +] + +[[package]] +name = "environmental" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" + +[[package]] +name = "failure" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", + "synstructure", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fixed-hash" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e" +dependencies = [ + "byteorder", + "libc", + "rand 0.5.6", + "rustc-hex", + "static_assertions 0.2.5", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hash-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" +dependencies = [ + "byteorder", + "scopeguard 0.3.3", +] + +[[package]] +name = "hashbrown" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" +dependencies = [ + "ahash", + "autocfg 0.1.7", +] + +[[package]] +name = "heapsize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" +dependencies = [ + "winapi", +] + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "hmac" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +dependencies = [ + "crypto-mac", + "digest", +] + +[[package]] +name = "hmac-drbg" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" +dependencies = [ + "digest", + "generic-array", + "hmac", +] + +[[package]] +name = "impl-codec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e3cae7e99c7ff5a995da2cf78dd0a5383740eda71d98cf7b1910c301ac69b8" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" + +[[package]] +name = "keccak" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" + +[[package]] +name = "libsecp256k1" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" +dependencies = [ + "arrayref", + "crunchy", + "digest", + "hmac-drbg", + "rand 0.7.3", + "sha2", + "subtle 2.2.2", + "typenum", +] + +[[package]] +name = "lock_api" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +dependencies = [ + "scopeguard 0.3.3", +] + +[[package]] +name = "lock_api" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" +dependencies = [ + "scopeguard 1.0.0", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "malloc_size_of_derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" +dependencies = [ + "proc-macro2 1.0.8", + "syn 1.0.14", + "synstructure", +] + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" + +[[package]] +name = "memory-db" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dabfe0a8c69954ae3bcfc5fc14260a85fb80e1bf9f86a155f668d10a67e93dd" +dependencies = [ + "ahash", + "hash-db", + "hashbrown 0.6.3", + "parity-util-mem", +] + +[[package]] +name = "memory_units" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" + +[[package]] +name = "merlin" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.4.2", + "zeroize 1.1.0", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg 1.0.0", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +dependencies = [ + "autocfg 1.0.0", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da4dc79f9e6c81bef96148c8f6b8e72ad4541caa4a24373e900a36da07de03a3" +dependencies = [ + "autocfg 1.0.0", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +dependencies = [ + "autocfg 1.0.0", +] + +[[package]] +name = "num_enum" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be601e38e20a6f3d01049d85801cb9b7a34a8da7a0da70df507bbde7735058c8" +dependencies = [ + "derivative", + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b59f30f6a043f2606adbd0addbf1eef6f2e28e8c4968918b63b7ff97ac0db2a7" +dependencies = [ + "proc-macro-crate", + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "once_cell" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" +dependencies = [ + "parking_lot 0.7.1", +] + +[[package]] +name = "once_cell" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "parity-scale-codec" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f747c06d9f3b2ad387ac881b9667298c81b1243aa9833f086e05996937c35507" +dependencies = [ + "arrayvec 0.5.1", + "bitvec", + "byte-slice-cast", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34e513ff3e406f3ede6796dcdc83d0b32ffb86668cea1ccf7363118abeb00476" +dependencies = [ + "proc-macro-crate", + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "parity-util-mem" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" +dependencies = [ + "cfg-if", + "malloc_size_of_derive", + "winapi", +] + +[[package]] +name = "parity-wasm" +version = "0.40.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" + +[[package]] +name = "parking_lot" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +dependencies = [ + "lock_api 0.1.5", + "parking_lot_core 0.4.0", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api 0.3.3", + "parking_lot_core 0.6.2", + "rustc_version", +] + +[[package]] +name = "parking_lot_core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +dependencies = [ + "libc", + "rand 0.6.5", + "rustc_version", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "rustc_version", + "smallvec", + "winapi", +] + +[[package]] +name = "paste" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "423a519e1c6e828f1e73b720f9d9ed2fa643dce8a7737fb43235ce0b41eeaa49" +dependencies = [ + "paste-impl", + "proc-macro-hack", +] + +[[package]] +name = "paste-impl" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4214c9e912ef61bf42b81ba9a47e8aad1b2ffaf739ab162bf96d1e011f54e6c5" +dependencies = [ + "proc-macro-hack", + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "pbkdf2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" +dependencies = [ + "byteorder", + "crypto-mac", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" + +[[package]] +name = "primitive-types" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83ef7b3b965c0eadcb6838f34f827e1dfb2939bdd5ebd43f9647e009b12b0371" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + +[[package]] +name = "proc-macro2" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" +dependencies = [ + "unicode-xid 0.2.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +dependencies = [ + "proc-macro2 1.0.8", +] + +[[package]] +name = "rand" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "winapi", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.7", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha 0.2.1", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +dependencies = [ + "c2-chacha", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + +[[package]] +name = "regex" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" + +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "safe-mix" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "schnorrkel" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3" +dependencies = [ + "curve25519-dalek", + "failure", + "merlin", + "rand 0.6.5", + "rand_core 0.4.2", + "rand_os", + "sha2", + "subtle 2.2.2", + "zeroize 0.9.3", +] + +[[package]] +name = "scopeguard" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" + +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "sha2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + +[[package]] +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +dependencies = [ + "maybe-uninit", +] + +[[package]] +name = "sr-api-macros" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "blake2-rfc", + "proc-macro-crate", + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "sr-arithmetic" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "serde", + "sr-std", + "substrate-debug-derive", +] + +[[package]] +name = "sr-io" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "hash-db", + "libsecp256k1", + "log", + "parity-scale-codec", + "rustc_version", + "sr-std", + "substrate-externalities", + "substrate-primitives", + "substrate-state-machine", + "substrate-trie", + "tiny-keccak", +] + +[[package]] +name = "sr-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "paste", + "rand 0.7.3", + "serde", + "sr-arithmetic", + "sr-io", + "sr-std", + "substrate-application-crypto", + "substrate-primitives", +] + +[[package]] +name = "sr-staking-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "sr-primitives", + "sr-std", +] + +[[package]] +name = "sr-std" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "sr-version" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "serde", + "sr-primitives", + "sr-std", +] + +[[package]] +name = "srml-authorship" +version = "0.1.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "sr-io", + "sr-primitives", + "sr-std", + "srml-support", + "srml-system", + "substrate-inherents", + "substrate-primitives", +] + +[[package]] +name = "srml-balances" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "safe-mix", + "serde", + "sr-primitives", + "sr-std", + "srml-support", + "srml-system", + "substrate-keyring", +] + +[[package]] +name = "srml-metadata" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "serde", + "sr-std", + "substrate-primitives", +] + +[[package]] +name = "srml-session" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "safe-mix", + "serde", + "sr-io", + "sr-primitives", + "sr-staking-primitives", + "sr-std", + "srml-support", + "srml-system", + "srml-timestamp", + "substrate-trie", +] + +[[package]] +name = "srml-staking" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "safe-mix", + "serde", + "sr-io", + "sr-primitives", + "sr-staking-primitives", + "sr-std", + "srml-authorship", + "srml-session", + "srml-support", + "srml-system", + "substrate-keyring", + "substrate-phragmen", +] + +[[package]] +name = "srml-support" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "bitmask", + "impl-trait-for-tuples", + "log", + "once_cell 0.2.4", + "parity-scale-codec", + "paste", + "serde", + "sr-io", + "sr-primitives", + "sr-std", + "srml-metadata", + "srml-support-procedural", + "substrate-inherents", + "substrate-primitives", +] + +[[package]] +name = "srml-support-procedural" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "sr-api-macros", + "srml-support-procedural-tools", + "syn 0.15.44", +] + +[[package]] +name = "srml-support-procedural-tools" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "proc-macro-crate", + "proc-macro2 0.4.30", + "quote 0.6.13", + "srml-support-procedural-tools-derive", + "syn 0.15.44", +] + +[[package]] +name = "srml-support-procedural-tools-derive" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "srml-system" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "safe-mix", + "serde", + "sr-io", + "sr-primitives", + "sr-std", + "sr-version", + "srml-support", + "substrate-primitives", +] + +[[package]] +name = "srml-timestamp" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "serde", + "sr-primitives", + "sr-std", + "srml-support", + "srml-system", + "substrate-inherents", +] + +[[package]] +name = "static_assertions" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strum" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f" + +[[package]] +name = "strum_macros" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e" +dependencies = [ + "heck", + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "substrate-application-crypto" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "serde", + "sr-io", + "sr-std", + "substrate-primitives", +] + +[[package]] +name = "substrate-bip39" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" +dependencies = [ + "hmac", + "pbkdf2", + "schnorrkel", + "sha2", +] + +[[package]] +name = "substrate-debug-derive" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "substrate-externalities" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "environmental", + "primitive-types", + "sr-std", + "substrate-primitives-storage", +] + +[[package]] +name = "substrate-inherents" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "parking_lot 0.9.0", + "sr-primitives", + "sr-std", +] + +[[package]] +name = "substrate-keyring" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "lazy_static", + "sr-primitives", + "strum", + "strum_macros", + "substrate-primitives", +] + +[[package]] +name = "substrate-panic-handler" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "backtrace", + "log", +] + +[[package]] +name = "substrate-phragmen" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "sr-primitives", + "sr-std", +] + +[[package]] +name = "substrate-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "base58", + "blake2-rfc", + "byteorder", + "ed25519-dalek", + "hash-db", + "hash256-std-hasher", + "hex", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot 0.9.0", + "primitive-types", + "rand 0.7.3", + "regex", + "rustc-hex", + "schnorrkel", + "serde", + "sha2", + "sr-std", + "substrate-bip39", + "substrate-debug-derive", + "substrate-externalities", + "substrate-primitives-storage", + "tiny-bip39", + "tiny-keccak", + "twox-hash", + "wasmi", + "zeroize 0.10.1", +] + +[[package]] +name = "substrate-primitives-storage" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-serde", + "serde", + "sr-std", + "substrate-debug-derive", +] + +[[package]] +name = "substrate-proposals-codex-module" +version = "2.0.0" +dependencies = [ + "num_enum", + "parity-scale-codec", + "serde", + "sr-io", + "sr-primitives", + "sr-staking-primitives", + "sr-std", + "srml-balances", + "srml-staking", + "srml-support", + "srml-system", + "srml-timestamp", + "substrate-primitives", + "substrate-proposals-engine-module", +] + +[[package]] +name = "substrate-proposals-engine-module" +version = "2.0.0" +dependencies = [ + "num_enum", + "parity-scale-codec", + "sr-primitives", + "sr-staking-primitives", + "sr-std", + "srml-balances", + "srml-staking", + "srml-support", + "srml-system", + "srml-timestamp", + "substrate-primitives", +] + +[[package]] +name = "substrate-state-machine" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "hash-db", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot 0.9.0", + "rand 0.7.3", + "substrate-externalities", + "substrate-panic-handler", + "substrate-primitives", + "substrate-trie", + "trie-db", + "trie-root", +] + +[[package]] +name = "substrate-trie" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "hash-db", + "memory-db", + "parity-scale-codec", + "sr-std", + "substrate-primitives", + "trie-db", + "trie-root", +] + +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + +[[package]] +name = "subtle" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid 0.1.0", +] + +[[package]] +name = "syn" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "unicode-xid 0.2.0", +] + +[[package]] +name = "synstructure" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", + "unicode-xid 0.2.0", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tiny-bip39" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" +dependencies = [ + "failure", + "hashbrown 0.1.8", + "hmac", + "once_cell 0.1.8", + "pbkdf2", + "rand 0.6.5", + "sha2", +] + +[[package]] +name = "tiny-keccak" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "toml" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +dependencies = [ + "serde", +] + +[[package]] +name = "trie-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" +dependencies = [ + "elastic-array", + "hash-db", + "hashbrown 0.6.3", + "log", + "rand 0.6.5", +] + +[[package]] +name = "trie-root" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" +dependencies = [ + "hash-db", +] + +[[package]] +name = "twox-hash" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" +dependencies = [ + "rand 0.7.3", +] + +[[package]] +name = "typenum" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" + +[[package]] +name = "uint" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e75a4cdd7b87b28840dba13c483b9a88ee6bbf16ba5c951ee1ecfcf723078e0d" +dependencies = [ + "byteorder", + "crunchy", + "rustc-hex", + "static_assertions 1.1.0", +] + +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasmi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31d26deb2d9a37e6cfed420edce3ed604eab49735ba89035e13c98f9a528313" +dependencies = [ + "libc", + "memory_units", + "num-rational", + "num-traits", + "parity-wasm", + "wasmi-validation", +] + +[[package]] +name = "wasmi-validation" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zeroize" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" + +[[package]] +name = "zeroize" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4090487fa66630f7b166fba2bbb525e247a5449f41c468cc1d98f8ae6ac03120" + +[[package]] +name = "zeroize" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", + "synstructure", +] diff --git a/modules/proposals/codex/Cargo.toml b/modules/proposals/codex/Cargo.toml new file mode 100644 index 0000000000..892f79254b --- /dev/null +++ b/modules/proposals/codex/Cargo.toml @@ -0,0 +1,103 @@ +[package] +name = 'substrate-proposals-codex-module' +version = '2.0.0' +authors = ['Joystream contributors'] +edition = '2018' + +[features] +default = ['std'] +no_std = [] +std = [ + 'sr-staking-primitives/std', + 'staking/std', + 'codec/std', + 'rstd/std', + 'srml-support/std', + 'balances/std', + 'primitives/std', + 'runtime-primitives/std', + 'system/std', + 'timestamp/std', + 'serde', +] + + +[dependencies.num_enum] +default_features = false +version = "0.4.2" + +[dependencies.serde] +features = ['derive'] +optional = true +version = '1.0.101' + +[dependencies.codec] +default-features = false +features = ['derive'] +package = 'parity-scale-codec' +version = '1.0.0' + +[dependencies.primitives] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'substrate-primitives' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.rstd] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'sr-std' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.runtime-primitives] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'sr-primitives' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.sr-staking-primitives] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'sr-staking-primitives' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.srml-support] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-support' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.system] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-system' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.timestamp] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-timestamp' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.staking] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-staking' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.balances] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-balances' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.proposal_engine] +default_features = false +package = 'substrate-proposals-engine-module' +path = '../engine' + +[dev-dependencies.runtime-io] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'sr-io' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' diff --git a/modules/proposals/codex/src/lib.rs b/modules/proposals/codex/src/lib.rs new file mode 100644 index 0000000000..269fd218b8 --- /dev/null +++ b/modules/proposals/codex/src/lib.rs @@ -0,0 +1,55 @@ +//! Proposals codex module for the Joystream platform. Version 2. +//! Contains preset proposal types +//! +//! Supported extrinsics (proposal type): +//! - create_text_proposal +//! + +// Ensure we're `no_std` when compiling for Wasm. +#![cfg_attr(not(feature = "std"), no_std)] + +// Do not delete! Cannot be uncommented by default, because of Parity decl_module! issue. +//#![warn(missing_docs)] + +pub use proposal_types::{ProposalType, TextProposalExecutable}; + +mod proposal_types; +#[cfg(test)] +mod tests; + +use codec::Encode; +use proposal_engine::*; +use rstd::clone::Clone; +use rstd::vec::Vec; +use srml_support::decl_module; + +/// 'Proposals codex' substrate module Trait +pub trait Trait: system::Trait + proposal_engine::Trait {} + +decl_module! { + /// 'Proposal codex' substrate module + pub struct Module for enum Call where origin: T::Origin { + /// Create text (signal) proposal type. On approval prints its content. + pub fn create_text_proposal(origin, title: Vec, body: Vec) { + let parameters = crate::ProposalParameters { + voting_period: T::BlockNumber::from(3u32), + approval_quorum_percentage: 49, + }; + + let text_proposal = TextProposalExecutable{ + title: title.clone(), + body: body.clone() + }; + let proposal_code = text_proposal.encode(); + + >::create_proposal( + origin, + parameters, + title, + body, + text_proposal.proposal_type(), + proposal_code + )?; + } + } +} diff --git a/modules/proposals/codex/src/proposal_types.rs b/modules/proposals/codex/src/proposal_types.rs new file mode 100644 index 0000000000..8596bc5b43 --- /dev/null +++ b/modules/proposals/codex/src/proposal_types.rs @@ -0,0 +1,69 @@ +use codec::{Decode, Encode}; +use num_enum::{IntoPrimitive, TryFromPrimitive}; +use rstd::convert::TryFrom; +use rstd::prelude::*; + +use rstd::str::from_utf8; +use srml_support::{dispatch, print}; + +use crate::{ProposalCodeDecoder, ProposalExecutable}; + +/// Defines allowed proposals types. Integer value serves as proposal_type_id. +#[derive(Debug, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)] +#[repr(u32)] +pub enum ProposalType { + /// Text(signal) proposal type + Text = 1, +} + +impl ProposalType { + fn compose_executable( + &self, + proposal_data: Vec, + ) -> Result, &'static str> { + match self { + ProposalType::Text => TextProposalExecutable::decode(&mut &proposal_data[..]) + .map_err(|err| err.what()) + .map(|obj| Box::new(obj) as Box), + } + } +} + +impl ProposalCodeDecoder for ProposalType { + fn decode_proposal( + proposal_type: u32, + proposal_code: Vec, + ) -> Result, &'static str> { + Self::try_from(proposal_type) + .map_err(|_| "Unsupported proposal type")? + .compose_executable(proposal_code) + } +} + +/// Text (signal) proposal executable code wrapper. Prints its content on execution. +#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, Default)] +pub struct TextProposalExecutable { + /// Text proposal title + pub title: Vec, + + /// Text proposal body + pub body: Vec, +} + +impl TextProposalExecutable { + /// Converts text proposal type to proposal_type_id + pub fn proposal_type(&self) -> u32 { + ProposalType::Text.into() + } +} + +impl ProposalExecutable for TextProposalExecutable { + fn execute(&self) -> dispatch::Result { + print("Proposal: "); + print(from_utf8(self.title.as_slice()).unwrap()); + print("Description:"); + print(from_utf8(self.body.as_slice()).unwrap()); + + Ok(()) + } +} diff --git a/modules/proposals/codex/src/tests/mock.rs b/modules/proposals/codex/src/tests/mock.rs new file mode 100644 index 0000000000..7f3fd33f74 --- /dev/null +++ b/modules/proposals/codex/src/tests/mock.rs @@ -0,0 +1,122 @@ +#![cfg(test)] + +pub use system; + +pub use primitives::{Blake2Hasher, H256}; +pub use runtime_primitives::{ + testing::{Digest, DigestItem, Header, UintAuthorityId}, + traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, + weights::Weight, + BuildStorage, Perbill, +}; + +use proposal_engine::VotersParameters; +use srml_support::{impl_outer_dispatch, impl_outer_origin, parameter_types}; + +impl_outer_origin! { + pub enum Origin for Test {} +} + +// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct Test; +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); + pub const MinimumPeriod: u64 = 5; +} + +impl_outer_dispatch! { + pub enum Call for Test where origin: Origin { + codex::ProposalCodex, + proposals::ProposalsEngine, + } +} + +impl proposal_engine::Trait for Test { + type Event = (); + + type ProposalOrigin = system::EnsureSigned; + + type VoteOrigin = system::EnsureSigned; + + type TotalVotersCounter = MockVotersParameters; + + type ProposalCodeDecoder = crate::ProposalType; +} + +pub struct MockVotersParameters; +impl VotersParameters for MockVotersParameters { + fn total_voters_count() -> u32 { + 4 + } +} + +impl crate::Trait for Test {} + +impl system::Trait for Test { + type Origin = Origin; + type Index = u64; + type BlockNumber = u64; + type Call = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type Event = (); + type BlockHashCount = BlockHashCount; + type MaximumBlockWeight = MaximumBlockWeight; + type MaximumBlockLength = MaximumBlockLength; + type AvailableBlockRatio = AvailableBlockRatio; + type Version = (); +} + +impl timestamp::Trait for Test { + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = MinimumPeriod; +} + +parameter_types! { + pub const ExistentialDeposit: u32 = 0; + pub const TransferFee: u32 = 0; + pub const CreationFee: u32 = 0; + pub const TransactionBaseFee: u32 = 1; + pub const TransactionByteFee: u32 = 0; + pub const InitialMembersBalance: u32 = 0; +} + +impl balances::Trait for Test { + /// The type for recording an account's balance. + type Balance = u64; + /// What to do if an account's free balance gets zeroed. + type OnFreeBalanceZero = (); + /// What to do if a new account is created. + type OnNewAccount = (); + /// The ubiquitous event type. + type Event = (); + + type DustRemoval = (); + type TransferPayment = (); + type ExistentialDeposit = ExistentialDeposit; + type TransferFee = TransferFee; + type CreationFee = CreationFee; +} + +// TODO add a Hook type to capture TriggerElection and CouncilElected hooks + +// This function basically just builds a genesis storage key/value store according to +// our desired mockup. +pub fn initial_test_ext() -> runtime_io::TestExternalities { + let t = system::GenesisConfig::default() + .build_storage::() + .unwrap(); + + t.into() +} + +pub type ProposalCodex = crate::Module; +pub type ProposalsEngine = proposal_engine::Module; diff --git a/modules/proposals/codex/src/tests/mod.rs b/modules/proposals/codex/src/tests/mod.rs new file mode 100644 index 0000000000..2a443f088a --- /dev/null +++ b/modules/proposals/codex/src/tests/mod.rs @@ -0,0 +1,28 @@ +mod mock; + +use mock::*; +use system::RawOrigin; + +#[test] +fn create_text_proposal_codex_call_succeeds() { + initial_test_ext().execute_with(|| { + let origin = RawOrigin::Signed(1).into(); + + assert!( + ProposalCodex::create_text_proposal(origin, b"title".to_vec(), b"body".to_vec(),) + .is_ok() + ); + }); +} + +#[test] +fn create_text_proposal_codex_call_fails_with_insufficient_rights() { + initial_test_ext().execute_with(|| { + let origin = RawOrigin::None.into(); + + assert!( + ProposalCodex::create_text_proposal(origin, b"title".to_vec(), b"body".to_vec(),) + .is_err() + ); + }); +} diff --git a/modules/proposals/engine/Cargo.lock b/modules/proposals/engine/Cargo.lock new file mode 100644 index 0000000000..1d76a22622 --- /dev/null +++ b/modules/proposals/engine/Cargo.lock @@ -0,0 +1,1895 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "ahash" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3" +dependencies = [ + "const-random", +] + +[[package]] +name = "aho-corasick" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811" +dependencies = [ + "memchr", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + +[[package]] +name = "arrayvec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" + +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" + +[[package]] +name = "backtrace" +version = "0.3.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f80256bc78f67e7df7e36d77366f636ed976895d91fe2ab9efa3973e8fe8c4f" +dependencies = [ + "backtrace-sys", + "cfg-if", + "libc", + "rustc-demangle", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "base58" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bitmask" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" + +[[package]] +name = "bitvec" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" + +[[package]] +name = "blake2-rfc" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +dependencies = [ + "arrayvec 0.4.12", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "byte-slice-cast" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "c2-chacha" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" +dependencies = [ + "ppv-lite86", +] + +[[package]] +name = "cc" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "clear_on_drop" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" +dependencies = [ + "cc", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "const-random" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a" +dependencies = [ + "getrandom", + "proc-macro-hack", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +dependencies = [ + "generic-array", + "subtle 1.0.0", +] + +[[package]] +name = "curve25519-dalek" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" +dependencies = [ + "byteorder", + "clear_on_drop", + "digest", + "rand_core 0.3.1", + "subtle 2.2.2", +] + +[[package]] +name = "derivative" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942ca430eef7a3806595a6737bc388bf51adb888d3fc0dd1b50f1c170167ee3a" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ed25519-dalek" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d07e8b8a8386c3b89a7a4b329fdfa4cb545de2545e9e2ebbc3dd3929253e426" +dependencies = [ + "clear_on_drop", + "curve25519-dalek", + "failure", + "rand 0.6.5", +] + +[[package]] +name = "elastic-array" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" +dependencies = [ + "heapsize", +] + +[[package]] +name = "environmental" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" + +[[package]] +name = "failure" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", + "synstructure", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fixed-hash" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e" +dependencies = [ + "byteorder", + "libc", + "rand 0.5.6", + "rustc-hex", + "static_assertions 0.2.5", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hash-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" +dependencies = [ + "byteorder", + "scopeguard 0.3.3", +] + +[[package]] +name = "hashbrown" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" +dependencies = [ + "ahash", + "autocfg 0.1.7", +] + +[[package]] +name = "heapsize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" +dependencies = [ + "winapi", +] + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "hmac" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +dependencies = [ + "crypto-mac", + "digest", +] + +[[package]] +name = "hmac-drbg" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" +dependencies = [ + "digest", + "generic-array", + "hmac", +] + +[[package]] +name = "impl-codec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e3cae7e99c7ff5a995da2cf78dd0a5383740eda71d98cf7b1910c301ac69b8" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" + +[[package]] +name = "keccak" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" + +[[package]] +name = "libsecp256k1" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" +dependencies = [ + "arrayref", + "crunchy", + "digest", + "hmac-drbg", + "rand 0.7.3", + "sha2", + "subtle 2.2.2", + "typenum", +] + +[[package]] +name = "lock_api" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +dependencies = [ + "scopeguard 0.3.3", +] + +[[package]] +name = "lock_api" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" +dependencies = [ + "scopeguard 1.0.0", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "malloc_size_of_derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" +dependencies = [ + "proc-macro2 1.0.8", + "syn 1.0.14", + "synstructure", +] + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" + +[[package]] +name = "memory-db" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dabfe0a8c69954ae3bcfc5fc14260a85fb80e1bf9f86a155f668d10a67e93dd" +dependencies = [ + "ahash", + "hash-db", + "hashbrown 0.6.3", + "parity-util-mem", +] + +[[package]] +name = "memory_units" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" + +[[package]] +name = "merlin" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.4.2", + "zeroize 1.1.0", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg 1.0.0", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +dependencies = [ + "autocfg 1.0.0", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da4dc79f9e6c81bef96148c8f6b8e72ad4541caa4a24373e900a36da07de03a3" +dependencies = [ + "autocfg 1.0.0", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +dependencies = [ + "autocfg 1.0.0", +] + +[[package]] +name = "num_enum" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be601e38e20a6f3d01049d85801cb9b7a34a8da7a0da70df507bbde7735058c8" +dependencies = [ + "derivative", + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b59f30f6a043f2606adbd0addbf1eef6f2e28e8c4968918b63b7ff97ac0db2a7" +dependencies = [ + "proc-macro-crate", + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "once_cell" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" +dependencies = [ + "parking_lot 0.7.1", +] + +[[package]] +name = "once_cell" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "parity-scale-codec" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f747c06d9f3b2ad387ac881b9667298c81b1243aa9833f086e05996937c35507" +dependencies = [ + "arrayvec 0.5.1", + "bitvec", + "byte-slice-cast", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34e513ff3e406f3ede6796dcdc83d0b32ffb86668cea1ccf7363118abeb00476" +dependencies = [ + "proc-macro-crate", + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "parity-util-mem" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" +dependencies = [ + "cfg-if", + "malloc_size_of_derive", + "winapi", +] + +[[package]] +name = "parity-wasm" +version = "0.40.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" + +[[package]] +name = "parking_lot" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +dependencies = [ + "lock_api 0.1.5", + "parking_lot_core 0.4.0", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api 0.3.3", + "parking_lot_core 0.6.2", + "rustc_version", +] + +[[package]] +name = "parking_lot_core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +dependencies = [ + "libc", + "rand 0.6.5", + "rustc_version", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "rustc_version", + "smallvec", + "winapi", +] + +[[package]] +name = "paste" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "423a519e1c6e828f1e73b720f9d9ed2fa643dce8a7737fb43235ce0b41eeaa49" +dependencies = [ + "paste-impl", + "proc-macro-hack", +] + +[[package]] +name = "paste-impl" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4214c9e912ef61bf42b81ba9a47e8aad1b2ffaf739ab162bf96d1e011f54e6c5" +dependencies = [ + "proc-macro-hack", + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "pbkdf2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" +dependencies = [ + "byteorder", + "crypto-mac", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" + +[[package]] +name = "primitive-types" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83ef7b3b965c0eadcb6838f34f827e1dfb2939bdd5ebd43f9647e009b12b0371" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + +[[package]] +name = "proc-macro2" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" +dependencies = [ + "unicode-xid 0.2.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +dependencies = [ + "proc-macro2 1.0.8", +] + +[[package]] +name = "rand" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "winapi", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.7", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha 0.2.1", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +dependencies = [ + "c2-chacha", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + +[[package]] +name = "regex" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" + +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "safe-mix" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "schnorrkel" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3" +dependencies = [ + "curve25519-dalek", + "failure", + "merlin", + "rand 0.6.5", + "rand_core 0.4.2", + "rand_os", + "sha2", + "subtle 2.2.2", + "zeroize 0.9.3", +] + +[[package]] +name = "scopeguard" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" + +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "sha2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + +[[package]] +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +dependencies = [ + "maybe-uninit", +] + +[[package]] +name = "sr-api-macros" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "blake2-rfc", + "proc-macro-crate", + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "sr-arithmetic" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "serde", + "sr-std", + "substrate-debug-derive", +] + +[[package]] +name = "sr-io" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "hash-db", + "libsecp256k1", + "log", + "parity-scale-codec", + "rustc_version", + "sr-std", + "substrate-externalities", + "substrate-primitives", + "substrate-state-machine", + "substrate-trie", + "tiny-keccak", +] + +[[package]] +name = "sr-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "paste", + "rand 0.7.3", + "serde", + "sr-arithmetic", + "sr-io", + "sr-std", + "substrate-application-crypto", + "substrate-primitives", +] + +[[package]] +name = "sr-staking-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "sr-primitives", + "sr-std", +] + +[[package]] +name = "sr-std" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "sr-version" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "serde", + "sr-primitives", + "sr-std", +] + +[[package]] +name = "srml-authorship" +version = "0.1.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "sr-io", + "sr-primitives", + "sr-std", + "srml-support", + "srml-system", + "substrate-inherents", + "substrate-primitives", +] + +[[package]] +name = "srml-balances" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "safe-mix", + "serde", + "sr-primitives", + "sr-std", + "srml-support", + "srml-system", + "substrate-keyring", +] + +[[package]] +name = "srml-metadata" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "serde", + "sr-std", + "substrate-primitives", +] + +[[package]] +name = "srml-session" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "safe-mix", + "serde", + "sr-io", + "sr-primitives", + "sr-staking-primitives", + "sr-std", + "srml-support", + "srml-system", + "srml-timestamp", + "substrate-trie", +] + +[[package]] +name = "srml-staking" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "safe-mix", + "serde", + "sr-io", + "sr-primitives", + "sr-staking-primitives", + "sr-std", + "srml-authorship", + "srml-session", + "srml-support", + "srml-system", + "substrate-keyring", + "substrate-phragmen", +] + +[[package]] +name = "srml-support" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "bitmask", + "impl-trait-for-tuples", + "log", + "once_cell 0.2.4", + "parity-scale-codec", + "paste", + "serde", + "sr-io", + "sr-primitives", + "sr-std", + "srml-metadata", + "srml-support-procedural", + "substrate-inherents", + "substrate-primitives", +] + +[[package]] +name = "srml-support-procedural" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "sr-api-macros", + "srml-support-procedural-tools", + "syn 0.15.44", +] + +[[package]] +name = "srml-support-procedural-tools" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "proc-macro-crate", + "proc-macro2 0.4.30", + "quote 0.6.13", + "srml-support-procedural-tools-derive", + "syn 0.15.44", +] + +[[package]] +name = "srml-support-procedural-tools-derive" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "srml-system" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "safe-mix", + "serde", + "sr-io", + "sr-primitives", + "sr-std", + "sr-version", + "srml-support", + "substrate-primitives", +] + +[[package]] +name = "srml-timestamp" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "serde", + "sr-primitives", + "sr-std", + "srml-support", + "srml-system", + "substrate-inherents", +] + +[[package]] +name = "static_assertions" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strum" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f" + +[[package]] +name = "strum_macros" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e" +dependencies = [ + "heck", + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "substrate-application-crypto" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "serde", + "sr-io", + "sr-std", + "substrate-primitives", +] + +[[package]] +name = "substrate-bip39" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" +dependencies = [ + "hmac", + "pbkdf2", + "schnorrkel", + "sha2", +] + +[[package]] +name = "substrate-debug-derive" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "substrate-externalities" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "environmental", + "primitive-types", + "sr-std", + "substrate-primitives-storage", +] + +[[package]] +name = "substrate-inherents" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "parity-scale-codec", + "parking_lot 0.9.0", + "sr-primitives", + "sr-std", +] + +[[package]] +name = "substrate-keyring" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "lazy_static", + "sr-primitives", + "strum", + "strum_macros", + "substrate-primitives", +] + +[[package]] +name = "substrate-panic-handler" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "backtrace", + "log", +] + +[[package]] +name = "substrate-phragmen" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "sr-primitives", + "sr-std", +] + +[[package]] +name = "substrate-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "base58", + "blake2-rfc", + "byteorder", + "ed25519-dalek", + "hash-db", + "hash256-std-hasher", + "hex", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot 0.9.0", + "primitive-types", + "rand 0.7.3", + "regex", + "rustc-hex", + "schnorrkel", + "serde", + "sha2", + "sr-std", + "substrate-bip39", + "substrate-debug-derive", + "substrate-externalities", + "substrate-primitives-storage", + "tiny-bip39", + "tiny-keccak", + "twox-hash", + "wasmi", + "zeroize 0.10.1", +] + +[[package]] +name = "substrate-primitives-storage" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "impl-serde", + "serde", + "sr-std", + "substrate-debug-derive", +] + +[[package]] +name = "substrate-proposals-engine-module" +version = "2.0.0" +dependencies = [ + "num_enum", + "parity-scale-codec", + "serde", + "sr-io", + "sr-primitives", + "sr-staking-primitives", + "sr-std", + "srml-balances", + "srml-staking", + "srml-support", + "srml-system", + "srml-timestamp", + "substrate-primitives", +] + +[[package]] +name = "substrate-state-machine" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "hash-db", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot 0.9.0", + "rand 0.7.3", + "substrate-externalities", + "substrate-panic-handler", + "substrate-primitives", + "substrate-trie", + "trie-db", + "trie-root", +] + +[[package]] +name = "substrate-trie" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" +dependencies = [ + "hash-db", + "memory-db", + "parity-scale-codec", + "sr-std", + "substrate-primitives", + "trie-db", + "trie-root", +] + +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + +[[package]] +name = "subtle" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid 0.1.0", +] + +[[package]] +name = "syn" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "unicode-xid 0.2.0", +] + +[[package]] +name = "synstructure" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", + "unicode-xid 0.2.0", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tiny-bip39" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" +dependencies = [ + "failure", + "hashbrown 0.1.8", + "hmac", + "once_cell 0.1.8", + "pbkdf2", + "rand 0.6.5", + "sha2", +] + +[[package]] +name = "tiny-keccak" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "toml" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +dependencies = [ + "serde", +] + +[[package]] +name = "trie-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" +dependencies = [ + "elastic-array", + "hash-db", + "hashbrown 0.6.3", + "log", + "rand 0.6.5", +] + +[[package]] +name = "trie-root" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" +dependencies = [ + "hash-db", +] + +[[package]] +name = "twox-hash" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" +dependencies = [ + "rand 0.7.3", +] + +[[package]] +name = "typenum" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" + +[[package]] +name = "uint" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e75a4cdd7b87b28840dba13c483b9a88ee6bbf16ba5c951ee1ecfcf723078e0d" +dependencies = [ + "byteorder", + "crunchy", + "rustc-hex", + "static_assertions 1.1.0", +] + +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasmi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31d26deb2d9a37e6cfed420edce3ed604eab49735ba89035e13c98f9a528313" +dependencies = [ + "libc", + "memory_units", + "num-rational", + "num-traits", + "parity-wasm", + "wasmi-validation", +] + +[[package]] +name = "wasmi-validation" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zeroize" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" + +[[package]] +name = "zeroize" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4090487fa66630f7b166fba2bbb525e247a5449f41c468cc1d98f8ae6ac03120" + +[[package]] +name = "zeroize" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", + "synstructure", +] diff --git a/modules/proposals/engine/Cargo.toml b/modules/proposals/engine/Cargo.toml new file mode 100644 index 0000000000..6656e695ac --- /dev/null +++ b/modules/proposals/engine/Cargo.toml @@ -0,0 +1,98 @@ +[package] +name = 'substrate-proposals-engine-module' +version = '2.0.0' +authors = ['Joystream contributors'] +edition = '2018' + +[features] +default = ['std'] +no_std = [] +std = [ + 'sr-staking-primitives/std', + 'staking/std', + 'codec/std', + 'rstd/std', + 'srml-support/std', + 'balances/std', + 'primitives/std', + 'runtime-primitives/std', + 'system/std', + 'timestamp/std', + 'serde', +] + + +[dependencies.num_enum] +default_features = false +version = "0.4.2" + +[dependencies.serde] +features = ['derive'] +optional = true +version = '1.0.101' + +[dependencies.codec] +default-features = false +features = ['derive'] +package = 'parity-scale-codec' +version = '1.0.0' + +[dependencies.primitives] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'substrate-primitives' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.rstd] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'sr-std' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.runtime-primitives] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'sr-primitives' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.sr-staking-primitives] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'sr-staking-primitives' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.srml-support] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-support' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.system] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-system' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.timestamp] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-timestamp' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.staking] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-staking' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dependencies.balances] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'srml-balances' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' + +[dev-dependencies.runtime-io] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'sr-io' +rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3' diff --git a/modules/proposals/engine/src/errors.rs b/modules/proposals/engine/src/errors.rs new file mode 100644 index 0000000000..602e6ddf98 --- /dev/null +++ b/modules/proposals/engine/src/errors.rs @@ -0,0 +1,17 @@ +pub const MSG_EMPTY_TITLE_PROVIDED: &str = "Proposal cannot have an empty title"; +pub const MSG_EMPTY_BODY_PROVIDED: &str = "Proposal cannot have an empty body"; +pub const MSG_TOO_LONG_TITLE: &str = "Title is too long"; +pub const MSG_TOO_LONG_BODY: &str = "Body is too long"; +pub const MSG_PROPOSAL_NOT_FOUND: &str = "This proposal does not exist"; +pub const MSG_PROPOSAL_EXPIRED: &str = "Voting period is expired for this proposal"; +pub const MSG_PROPOSAL_FINALIZED: &str = "Proposal is finalized already"; +pub const MSG_YOU_ALREADY_VOTED: &str = "You have already voted on this proposal"; +pub const MSG_YOU_DONT_OWN_THIS_PROPOSAL: &str = "You do not own this proposal"; + +//pub const MSG_STAKE_IS_TOO_LOW: &str = "Stake is too low"; +//pub const MSG_STAKE_IS_GREATER_THAN_BALANCE: &str = "Balance is too low to be staked"; +//pub const MSG_ONLY_MEMBERS_CAN_PROPOSE: &str = "Only members can make a proposal"; +//pub const MSG_ONLY_COUNCILORS_CAN_VOTE: &str = "Only councilors can vote on proposals"; +//pub const MSG_PROPOSAL_STATUS_ALREADY_UPDATED: &str = "Proposal status has been updated already"; +//pub const MSG_EMPTY_WASM_CODE_PROVIDED: &str = "Proposal cannot have an empty WASM code"; +//pub const MSG_TOO_LONG_WASM_CODE: &str = "WASM code is too big"; diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs new file mode 100644 index 0000000000..04b641baea --- /dev/null +++ b/modules/proposals/engine/src/lib.rs @@ -0,0 +1,348 @@ +//! Proposals engine module for the Joystream platform. Version 2. +//! Provides methods and extrinsics to create and vote for proposals. +//! +//! Supported extrinsics: +//! - vote +//! - cancel_proposal +//! - veto_proposal +//! +//! Public API (requires root origin): +//! - create_proposal +//! + +// Ensure we're `no_std` when compiling for Wasm. +#![cfg_attr(not(feature = "std"), no_std)] + +// Do not delete! Cannot be uncommented by default, because of Parity decl_module! issue. +//#![warn(missing_docs)] + +pub use types::TallyResult; +pub use types::{Proposal, ProposalParameters, ProposalStatus}; +pub use types::{ProposalCodeDecoder, ProposalExecutable}; +pub use types::{Vote, VoteKind, VotersParameters}; + +mod errors; +mod types; + +#[cfg(test)] +mod tests; + +use rstd::collections::btree_set::BTreeSet; +use rstd::prelude::*; +use runtime_primitives::traits::EnsureOrigin; +use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, StorageDoubleMap}; +use system::ensure_root; + +const DEFAULT_TITLE_MAX_LEN: u32 = 100; +const DEFAULT_BODY_MAX_LEN: u32 = 10_000; + +/// Proposals engine trait. +pub trait Trait: system::Trait + timestamp::Trait { + /// Engine event type. + type Event: From> + Into<::Event>; + + /// Origin from which proposals must come. + type ProposalOrigin: EnsureOrigin; + + /// Origin from which votes must come. + type VoteOrigin: EnsureOrigin; + + /// Provides data for voting. Defines maximum voters count for the proposal. + type TotalVotersCounter: VotersParameters; + + /// Converts proposal code binary to executable representation + type ProposalCodeDecoder: ProposalCodeDecoder; +} + +decl_event!( + pub enum Event + where + ::AccountId + { + /// Emits on proposal creation. + /// Params: + /// * Account id of a proposer. + /// * Id of a newly created proposal after it was saved in storage. + ProposalCreated(AccountId, u32), + + /// Emits on proposal cancellation. + /// Params: + /// * Account id of a proposer. + /// * Id of a cancelled proposal. + ProposalCanceled(AccountId, u32), + + /// Emits on proposal veto. + /// Params: + /// * Id of a vetoed proposal. + ProposalVetoed(u32), + + /// Emits on proposal status change. + /// Params: + /// * Id of a updated proposal. + /// * New proposal status + ProposalStatusUpdated(u32, ProposalStatus), + + /// Emits on voting for the proposal + /// Params: + /// * Voter - an account id of a voter. + /// * Id of a proposal. + /// * Kind of vote. + Voted(AccountId, u32, VoteKind), + } +); + +// Storage for the proposals module +decl_storage! { + trait Store for Module as ProposalsEngine{ + /// Map proposal by its id. + pub Proposals get(fn proposals): map u32 => Proposal; + + /// Count of all proposals that have been created. + pub ProposalCount get(fn proposal_count): u32; + + /// Map proposal executable code by proposal id. + ProposalCode get(fn proposal_codes): map u32 => Vec; + + /// Map votes by proposal id. + VotesByProposalId get(fn votes_by_proposal): map u32 => Vec>; + + /// Ids of proposals that are open for voting (have not been finalized yet). + pub ActiveProposalIds get(fn active_proposal_ids): BTreeSet; + + /// Proposal tally results map + pub(crate) TallyResults get(fn tally_results): map u32 => TallyResult; + + /// Double map for preventing duplicate votes + VoteExistsByAccountByProposal get(fn vote_by_proposal_by_account): + double_map T::AccountId, twox_256(u32) => (); + + + /// Defines max allowed proposal title length. Can be configured. + TitleMaxLen get(title_max_len) config(): u32 = DEFAULT_TITLE_MAX_LEN; + + /// Defines max allowed proposal body length. Can be configured. + BodyMaxLen get(body_max_len) config(): u32 = DEFAULT_BODY_MAX_LEN; + } +} + +decl_module! { + /// 'Proposal engine' substrate module + pub struct Module for enum Call where origin: T::Origin { + + /// Emits an event. Default substrate implementation. + fn deposit_event() = default; + + /// Vote extrinsic. Conditions: origin must allow votes. + pub fn vote(origin, proposal_id: u32, vote: VoteKind) { + let voter_id = T::VoteOrigin::ensure_origin(origin)?; + + ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); + let proposal = Self::proposals(proposal_id); + + let not_expired = !proposal.is_voting_period_expired(Self::current_block()); + ensure!(not_expired, errors::MSG_PROPOSAL_EXPIRED); + + ensure!(proposal.status == ProposalStatus::Active, errors::MSG_PROPOSAL_FINALIZED); + + let did_not_vote_before = !>::exists( + voter_id.clone(), + proposal_id + ); + + ensure!(did_not_vote_before, errors::MSG_YOU_ALREADY_VOTED); + + let new_vote = Vote { + voter_id: voter_id.clone(), + vote_kind: vote.clone(), + }; + + // mutation + + >::mutate(proposal_id, |votes| votes.push(new_vote)); + >::insert(voter_id.clone(), proposal_id, ()); + Self::deposit_event(RawEvent::Voted(voter_id, proposal_id, vote)); + } + + /// Cancel a proposal by its original proposer. + pub fn cancel_proposal(origin, proposal_id: u32) { + let proposer_id = T::ProposalOrigin::ensure_origin(origin)?; + + ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); + let proposal = Self::proposals(proposal_id); + + ensure!(proposer_id == proposal.proposer_id, errors::MSG_YOU_DONT_OWN_THIS_PROPOSAL); + ensure!(proposal.status == ProposalStatus::Active, errors::MSG_PROPOSAL_FINALIZED); + + // mutation + + Self::update_proposal_status(proposal_id, ProposalStatus::Canceled); + Self::deposit_event(RawEvent::ProposalCanceled(proposer_id, proposal_id)); + } + + /// Veto a proposal. Must be root. + pub fn veto_proposal(origin, proposal_id: u32) { + ensure_root(origin)?; + + ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); + let proposal = Self::proposals(proposal_id); + + ensure!(proposal.status == ProposalStatus::Active, errors::MSG_PROPOSAL_FINALIZED); + + // mutation + + Self::update_proposal_status(proposal_id, ProposalStatus::Vetoed); + Self::deposit_event(RawEvent::ProposalVetoed(proposal_id)); + } + + /// Block finalization. Perform voting period check and vote result tally. + fn on_finalize(_n: T::BlockNumber) { + let tally_results = Self::tally(); + + // mutation + + for tally_result in tally_results { + >::insert(tally_result.proposal_id, &tally_result); + + Self::update_proposal_status(tally_result.proposal_id, tally_result.status); + } + } + } +} + +impl Module { + /// Create proposal. Requires 'proposal origin' membership. + pub fn create_proposal( + origin: T::Origin, + parameters: ProposalParameters, + title: Vec, + body: Vec, + proposal_type: u32, + proposal_code: Vec, + ) -> dispatch::Result { + let proposer_id = T::ProposalOrigin::ensure_origin(origin)?; + + ensure!(!title.is_empty(), errors::MSG_EMPTY_TITLE_PROVIDED); + ensure!( + title.len() as u32 <= Self::title_max_len(), + errors::MSG_TOO_LONG_TITLE + ); + + ensure!(!body.is_empty(), errors::MSG_EMPTY_BODY_PROVIDED); + ensure!( + body.len() as u32 <= Self::body_max_len(), + errors::MSG_TOO_LONG_BODY + ); + + let next_proposal_count_value = Self::proposal_count() + 1; + let new_proposal_id = next_proposal_count_value; + + let new_proposal = Proposal { + created: Self::current_block(), + parameters, + title, + body, + proposer_id: proposer_id.clone(), + proposal_type, + status: ProposalStatus::Active, + }; + + // mutation + >::insert(new_proposal_id, new_proposal); + ::insert(new_proposal_id, proposal_code); + ActiveProposalIds::mutate(|ids| ids.insert(new_proposal_id)); + ProposalCount::put(next_proposal_count_value); + + Self::deposit_event(RawEvent::ProposalCreated(proposer_id, new_proposal_id)); + + Ok(()) + } +} + +impl Module { + // Wrapper-function over system::block_number() + fn current_block() -> T::BlockNumber { + >::block_number() + } + + // Executes approved proposal code + fn execute_proposal(proposal_id: u32) { + //let origin = system::RawOrigin::Root.into(); + let proposal = Self::proposals(proposal_id); + let proposal_code = Self::proposal_codes(proposal_id); + + let proposal_code_result = + T::ProposalCodeDecoder::decode_proposal(proposal.proposal_type, proposal_code); + + let new_proposal_status = match proposal_code_result { + Ok(proposal_code) => { + if let Err(error) = proposal_code.execute() { + ProposalStatus::Failed { + error: error.as_bytes().to_vec(), + } + } else { + ProposalStatus::Executed + } + } + Err(error) => ProposalStatus::Failed { + error: error.as_bytes().to_vec(), + }, + }; + + Self::update_proposal_status(proposal_id, new_proposal_status) + } + + /// Voting results tally. + /// Returns proposals with changed status and tally results + fn tally() -> Vec> { + let mut results = Vec::new(); + for &proposal_id in Self::active_proposal_ids().iter() { + let votes = Self::votes_by_proposal(proposal_id); + let proposal = Self::proposals(proposal_id); + + if let Some(tally_result) = proposal.tally_results( + proposal_id, + votes, + T::TotalVotersCounter::total_voters_count(), + Self::current_block(), + ) { + results.push(tally_result); + } + } + + results + } + + /// Updates proposal status and removes proposal id from active id set. + fn update_proposal_status(proposal_id: u32, new_status: ProposalStatus) { + >::mutate(proposal_id, |p| p.status = new_status.clone()); + ActiveProposalIds::mutate(|ids| ids.remove(&proposal_id)); + + Self::deposit_event(RawEvent::ProposalStatusUpdated( + proposal_id, + new_status.clone(), + )); + + match new_status { + ProposalStatus::Rejected | ProposalStatus::Expired => { + Self::reject_proposal(proposal_id) + } + ProposalStatus::Approved => Self::approve_proposal(proposal_id), + ProposalStatus::Active => { + // restore active proposal id + ActiveProposalIds::mutate(|ids| ids.insert(proposal_id)); + } + ProposalStatus::Executed + | ProposalStatus::Failed { .. } + | ProposalStatus::Vetoed + | ProposalStatus::Canceled => {} // do nothing + } + } + + /// Reject a proposal. The staked deposit will be returned to a proposer. + fn reject_proposal(_proposal_id: u32) {} + + /// Approve a proposal. The staked deposit will be returned. + fn approve_proposal(proposal_id: u32) { + Self::execute_proposal(proposal_id); + } +} diff --git a/modules/proposals/engine/src/tests/mock.rs b/modules/proposals/engine/src/tests/mock.rs new file mode 100644 index 0000000000..462fa912af --- /dev/null +++ b/modules/proposals/engine/src/tests/mock.rs @@ -0,0 +1,210 @@ +#![cfg(test)] + +pub use system; + +pub use primitives::{Blake2Hasher, H256}; +pub use runtime_primitives::{ + testing::{Digest, DigestItem, Header, UintAuthorityId}, + traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, + weights::Weight, + BuildStorage, Perbill, +}; + +use crate::VotersParameters; +use srml_support::{impl_outer_dispatch, impl_outer_event, impl_outer_origin, parameter_types}; + +impl_outer_origin! { + pub enum Origin for Test {} +} + +// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct Test; +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); + pub const MinimumPeriod: u64 = 5; +} + +impl_outer_dispatch! { + pub enum Call for Test where origin: Origin { + proposals::ProposalsEngine, + } +} + +mod engine { + pub use crate::Event; +} + +impl_outer_event! { + pub enum TestEvent for Test { + balances, engine, + } +} + +impl crate::Trait for Test { + type Event = TestEvent; + + type ProposalOrigin = system::EnsureSigned; + + type VoteOrigin = system::EnsureSigned; + + type TotalVotersCounter = (); + + type ProposalCodeDecoder = ProposalType; +} + +impl VotersParameters for () { + fn total_voters_count() -> u32 { + 4 + } +} + +impl system::Trait for Test { + type Origin = Origin; + type Index = u64; + type BlockNumber = u64; + type Call = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type Event = TestEvent; + type BlockHashCount = BlockHashCount; + type MaximumBlockWeight = MaximumBlockWeight; + type MaximumBlockLength = MaximumBlockLength; + type AvailableBlockRatio = AvailableBlockRatio; + type Version = (); +} + +impl timestamp::Trait for Test { + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = MinimumPeriod; +} + +parameter_types! { + pub const ExistentialDeposit: u32 = 0; + pub const TransferFee: u32 = 0; + pub const CreationFee: u32 = 0; + pub const TransactionBaseFee: u32 = 1; + pub const TransactionByteFee: u32 = 0; + pub const InitialMembersBalance: u32 = 0; +} + +impl balances::Trait for Test { + /// The type for recording an account's balance. + type Balance = u64; + /// What to do if an account's free balance gets zeroed. + type OnFreeBalanceZero = (); + /// What to do if a new account is created. + type OnNewAccount = (); + + type Event = TestEvent; + + type DustRemoval = (); + type TransferPayment = (); + type ExistentialDeposit = ExistentialDeposit; + type TransferFee = TransferFee; + type CreationFee = CreationFee; +} + +// TODO add a Hook type to capture TriggerElection and CouncilElected hooks + +// This function basically just builds a genesis storage key/value store according to +// our desired mockup. +pub fn initial_test_ext() -> runtime_io::TestExternalities { + let t = system::GenesisConfig::default() + .build_storage::() + .unwrap(); + + t.into() +} + +pub type ProposalsEngine = crate::Module; +pub type System = system::Module; + +use codec::{Decode, Encode}; +use num_enum::{IntoPrimitive, TryFromPrimitive}; +use rstd::convert::TryFrom; +use rstd::prelude::*; + +use srml_support::dispatch; + +use crate::{ProposalCodeDecoder, ProposalExecutable}; + +/// Defines allowed proposals types. Integer value serves as proposal_type_id. +#[derive(Debug, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)] +#[repr(u32)] +pub enum ProposalType { + /// Dummy(Text) proposal type + Dummy = 1, + + /// Testing proposal type for faults + Faulty = 10001, +} + +impl ProposalType { + fn compose_executable( + &self, + proposal_data: Vec, + ) -> Result, &'static str> { + match self { + ProposalType::Dummy => DummyExecutable::decode(&mut &proposal_data[..]) + .map_err(|err| err.what()) + .map(|obj| Box::new(obj) as Box), + ProposalType::Faulty => FaultyExecutable::decode(&mut &proposal_data[..]) + .map_err(|err| err.what()) + .map(|obj| Box::new(obj) as Box), + } + } +} + +impl ProposalCodeDecoder for ProposalType { + fn decode_proposal( + proposal_type: u32, + proposal_code: Vec, + ) -> Result, &'static str> { + Self::try_from(proposal_type) + .map_err(|_| "Unsupported proposal type")? + .compose_executable(proposal_code) + } +} + +/// Testing proposal type +#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, Default)] +pub struct DummyExecutable { + pub title: Vec, + pub body: Vec, +} + +impl DummyExecutable { + pub fn proposal_type(&self) -> u32 { + ProposalType::Dummy.into() + } +} + +impl ProposalExecutable for DummyExecutable { + fn execute(&self) -> dispatch::Result { + Ok(()) + } +} + +/// Faulty proposal executable code wrapper. Used for failed proposal execution tests. +#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, Default)] +pub struct FaultyExecutable; +impl ProposalExecutable for FaultyExecutable { + fn execute(&self) -> dispatch::Result { + Err("Failed") + } +} + +impl FaultyExecutable { + /// Converts faulty proposal type to proposal_type_id + pub fn proposal_type(&self) -> u32 { + ProposalType::Faulty.into() + } +} diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs new file mode 100644 index 0000000000..d76585358d --- /dev/null +++ b/modules/proposals/engine/src/tests/mod.rs @@ -0,0 +1,742 @@ +mod mock; + +use crate::*; +use mock::*; + +use codec::Encode; +use rstd::collections::btree_set::BTreeSet; +use runtime_primitives::traits::{OnFinalize, OnInitialize}; +use srml_support::{dispatch, StorageMap, StorageValue}; +use system::RawOrigin; +use system::{EventRecord, Phase}; + +struct DummyProposalFixture { + parameters: ProposalParameters, + origin: RawOrigin, + proposal_type: u32, + proposal_code: Vec, + title: Vec, + body: Vec, +} + +impl Default for DummyProposalFixture { + fn default() -> Self { + let dummy_proposal = DummyExecutable { + title: b"title".to_vec(), + body: b"body".to_vec(), + }; + + DummyProposalFixture { + parameters: ProposalParameters { + voting_period: 3, + approval_quorum_percentage: 60, + }, + origin: RawOrigin::Signed(1), + proposal_type: dummy_proposal.proposal_type(), + proposal_code: dummy_proposal.encode(), + title: dummy_proposal.title, + body: dummy_proposal.body, + } + } +} + +impl DummyProposalFixture { + fn with_title_and_body(self, title: Vec, body: Vec) -> Self { + DummyProposalFixture { + title, + body, + ..self + } + } + + fn with_parameters(self, parameters: ProposalParameters) -> Self { + DummyProposalFixture { parameters, ..self } + } + + fn with_origin(self, origin: RawOrigin) -> Self { + DummyProposalFixture { origin, ..self } + } + + fn with_proposal_type_and_code(self, proposal_type: u32, proposal_code: Vec) -> Self { + DummyProposalFixture { + proposal_type, + proposal_code, + ..self + } + } + + fn create_proposal_and_assert(self, result: dispatch::Result) { + assert_eq!( + ProposalsEngine::create_proposal( + self.origin.into(), + self.parameters, + self.title, + self.body, + self.proposal_type, + self.proposal_code, + ), + result + ); + } +} + +struct CancelProposalFixture { + origin: RawOrigin, + proposal_id: u32, +} + +impl CancelProposalFixture { + fn new(proposal_id: u32) -> Self { + CancelProposalFixture { + proposal_id, + origin: RawOrigin::Signed(1), + } + } + + fn with_origin(self, origin: RawOrigin) -> Self { + CancelProposalFixture { origin, ..self } + } + + fn cancel_and_assert(self, expected_result: dispatch::Result) { + assert_eq!( + ProposalsEngine::cancel_proposal(self.origin.into(), self.proposal_id,), + expected_result + ); + } +} +struct VetoProposalFixture { + origin: RawOrigin, + proposal_id: u32, +} + +impl VetoProposalFixture { + fn new(proposal_id: u32) -> Self { + VetoProposalFixture { + proposal_id, + origin: RawOrigin::Root, + } + } + + fn with_origin(self, origin: RawOrigin) -> Self { + VetoProposalFixture { origin, ..self } + } + + fn veto_and_assert(self, expected_result: dispatch::Result) { + assert_eq!( + ProposalsEngine::veto_proposal(self.origin.into(), self.proposal_id,), + expected_result + ); + } +} + +struct VoteGenerator { + proposal_id: u32, + current_account_id: u64, + pub auto_increment_voter_id: bool, +} + +impl VoteGenerator { + fn new(proposal_id: u32) -> Self { + VoteGenerator { + proposal_id, + current_account_id: 0, + auto_increment_voter_id: true, + } + } + fn vote_and_assert_ok(&mut self, vote_kind: VoteKind) { + assert_eq!(self.vote(vote_kind), Ok(())); + } + + fn vote_and_assert(&mut self, vote_kind: VoteKind, expected_result: dispatch::Result) { + assert_eq!(self.vote(vote_kind), expected_result); + } + + fn vote(&mut self, vote_kind: VoteKind) -> dispatch::Result { + if self.auto_increment_voter_id { + self.current_account_id += 1; + } + + ProposalsEngine::vote( + system::RawOrigin::Signed(self.current_account_id).into(), + self.proposal_id, + vote_kind, + ) + } +} + +struct EventFixture; +impl EventFixture { + fn assert_events(expected_raw_events: Vec>) { + let expected_events = expected_raw_events + .iter() + .map(|ev| EventRecord { + phase: Phase::ApplyExtrinsic(0), + event: TestEvent::engine(ev.clone()), + topics: vec![], + }) + .collect::>>(); + + assert_eq!(System::events(), expected_events); + } +} + +// Recommendation from Parity on testing on_finalize +// https://substrate.dev/docs/en/next/development/module/tests +fn run_to_block(n: u64) { + while System::block_number() < n { + >::on_finalize(System::block_number()); + >::on_finalize(System::block_number()); + System::set_block_number(System::block_number() + 1); + >::on_initialize(System::block_number()); + >::on_initialize(System::block_number()); + } +} + +fn run_to_block_and_finalize(n: u64) { + run_to_block(n); + >::on_finalize(n); +} + +#[test] +fn create_dummy_proposal_succeeds() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + + dummy_proposal.create_proposal_and_assert(Ok(())); + }); +} + +#[test] +fn create_dummy_proposal_fails_with_insufficient_rights() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default().with_origin(RawOrigin::None); + + dummy_proposal.create_proposal_and_assert(Err("Invalid origin")); + }); +} + +#[test] +fn vote_succeeds() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposal_id); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + }); +} + +#[test] +fn vote_fails_with_insufficient_rights() { + initial_test_ext().execute_with(|| { + assert_eq!( + ProposalsEngine::vote(system::RawOrigin::None.into(), 1, VoteKind::Approve), + Err("Invalid origin") + ); + }); +} + +#[test] +fn proposal_execution_succeeds() { + initial_test_ext().execute_with(|| { + let parameters = ProposalParameters { + voting_period: 3, + approval_quorum_percentage: 60, + }; + + let dummy_proposal = DummyProposalFixture::default().with_parameters(parameters); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposals_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposals_id); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + + run_to_block_and_finalize(2); + + let proposal = >::get(proposals_id); + + assert_eq!( + proposal, + Proposal { + proposal_type: 1, + parameters, + proposer_id: 1, + created: 1, + status: ProposalStatus::Executed, + title: b"title".to_vec(), + body: b"body".to_vec(), + } + ) + }); +} + +#[test] +fn proposal_execution_failed() { + initial_test_ext().execute_with(|| { + let parameters = ProposalParameters { + voting_period: 3, + approval_quorum_percentage: 60, + }; + + let faulty_proposal = FaultyExecutable; + + let dummy_proposal = DummyProposalFixture::default() + .with_parameters(parameters) + .with_proposal_type_and_code(faulty_proposal.proposal_type(), faulty_proposal.encode()); + + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposals_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposals_id); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + + run_to_block_and_finalize(2); + + let proposal = >::get(proposals_id); + + assert_eq!( + proposal, + Proposal { + proposal_type: faulty_proposal.proposal_type(), + parameters, + proposer_id: 1, + created: 1, + status: ProposalStatus::Failed { + error: "Failed".as_bytes().to_vec() + }, + title: b"title".to_vec(), + body: b"body".to_vec(), + } + ) + }); +} + +#[test] +fn tally_calculation_succeeds() { + initial_test_ext().execute_with(|| { + let parameters = ProposalParameters { + voting_period: 3, + approval_quorum_percentage: 49, + }; + + let dummy_proposal = DummyProposalFixture::default().with_parameters(parameters); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposals_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposals_id); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert_ok(VoteKind::Reject); + vote_generator.vote_and_assert_ok(VoteKind::Abstain); + + run_to_block_and_finalize(2); + + let tally_result = >::get(proposals_id); + + assert_eq!( + tally_result, + TallyResult { + proposal_id: proposals_id, + abstentions: 1, + approvals: 2, + rejections: 1, + status: ProposalStatus::Approved, + finalized_at: 1 + } + ) + }); +} + +#[test] +fn rejected_tally_results_and_remove_proposal_id_from_active_succeeds() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposal_id); + vote_generator.vote_and_assert_ok(VoteKind::Reject); + vote_generator.vote_and_assert_ok(VoteKind::Reject); + vote_generator.vote_and_assert_ok(VoteKind::Abstain); + vote_generator.vote_and_assert_ok(VoteKind::Abstain); + + let mut active_proposals_id = ::get(); + + let mut active_proposals_set = BTreeSet::new(); + active_proposals_set.insert(proposal_id); + assert_eq!(active_proposals_id, active_proposals_set); + + run_to_block_and_finalize(2); + + let tally_result = >::get(proposal_id); + + assert_eq!( + tally_result, + TallyResult { + proposal_id, + abstentions: 2, + approvals: 0, + rejections: 2, + status: ProposalStatus::Rejected, + finalized_at: 1 + } + ); + + active_proposals_id = ::get(); + assert_eq!(active_proposals_id, BTreeSet::new()); + }); +} + +#[test] +fn create_proposal_fails_with_invalid_body_or_title() { + initial_test_ext().execute_with(|| { + let mut dummy_proposal = + DummyProposalFixture::default().with_title_and_body(Vec::new(), b"body".to_vec()); + dummy_proposal.create_proposal_and_assert(Err("Proposal cannot have an empty title")); + + dummy_proposal = + DummyProposalFixture::default().with_title_and_body(b"title".to_vec(), Vec::new()); + dummy_proposal.create_proposal_and_assert(Err("Proposal cannot have an empty body")); + + let too_long_title = vec![0; 200]; + dummy_proposal = + DummyProposalFixture::default().with_title_and_body(too_long_title, b"body".to_vec()); + dummy_proposal.create_proposal_and_assert(Err("Title is too long")); + + let too_long_body = vec![0; 11000]; + dummy_proposal = + DummyProposalFixture::default().with_title_and_body(b"title".to_vec(), too_long_body); + dummy_proposal.create_proposal_and_assert(Err("Body is too long")); + }); +} + +#[test] +fn vote_fails_with_expired_voting_period() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + run_to_block_and_finalize(6); + + let mut vote_generator = VoteGenerator::new(proposal_id); + vote_generator.vote_and_assert( + VoteKind::Approve, + Err("Voting period is expired for this proposal"), + ); + }); +} + +#[test] +fn vote_fails_with_not_active_proposal() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposal_id); + vote_generator.vote_and_assert_ok(VoteKind::Reject); + vote_generator.vote_and_assert_ok(VoteKind::Reject); + vote_generator.vote_and_assert_ok(VoteKind::Abstain); + vote_generator.vote_and_assert_ok(VoteKind::Abstain); + + run_to_block_and_finalize(2); + + let mut vote_generator_to_fail = VoteGenerator::new(proposal_id); + vote_generator_to_fail + .vote_and_assert(VoteKind::Approve, Err("Proposal is finalized already")); + }); +} + +#[test] +fn vote_fails_with_absent_proposal() { + initial_test_ext().execute_with(|| { + let mut vote_generator = VoteGenerator::new(2); + vote_generator.vote_and_assert(VoteKind::Approve, Err("This proposal does not exist")); + }); +} + +#[test] +fn vote_fails_on_double_voting() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposal_id); + vote_generator.auto_increment_voter_id = false; + + vote_generator.vote_and_assert_ok(VoteKind::Approve); + vote_generator.vote_and_assert( + VoteKind::Approve, + Err("You have already voted on this proposal"), + ); + }); +} + +#[test] +fn cancel_proposal_succeeds() { + initial_test_ext().execute_with(|| { + let parameters = ProposalParameters { + voting_period: 3, + approval_quorum_percentage: 60, + }; + let dummy_proposal = DummyProposalFixture::default().with_parameters(parameters); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let cancel_proposal = CancelProposalFixture::new(proposal_id); + cancel_proposal.cancel_and_assert(Ok(())); + + let proposal = >::get(proposal_id); + + assert_eq!( + proposal, + Proposal { + proposal_type: 1, + parameters, + proposer_id: 1, + created: 1, + status: ProposalStatus::Canceled, + title: b"title".to_vec(), + body: b"body".to_vec(), + } + ) + }); +} + +#[test] +fn cancel_proposal_fails_with_not_active_proposal() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + run_to_block_and_finalize(6); + + let cancel_proposal = CancelProposalFixture::new(proposal_id); + cancel_proposal.cancel_and_assert(Err("Proposal is finalized already")); + }); +} + +#[test] +fn cancel_proposal_fails_with_not_existing_proposal() { + initial_test_ext().execute_with(|| { + let cancel_proposal = CancelProposalFixture::new(2); + cancel_proposal.cancel_and_assert(Err("This proposal does not exist")); + }); +} + +#[test] +fn cancel_proposal_fails_with_insufficient_rights() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let cancel_proposal = + CancelProposalFixture::new(proposal_id).with_origin(RawOrigin::Signed(2)); + cancel_proposal.cancel_and_assert(Err("You do not own this proposal")); + }); +} + +#[test] +fn veto_proposal_succeeds() { + initial_test_ext().execute_with(|| { + let parameters = ProposalParameters { + voting_period: 3, + approval_quorum_percentage: 60, + }; + let dummy_proposal = DummyProposalFixture::default().with_parameters(parameters); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let veto_proposal = VetoProposalFixture::new(proposal_id); + veto_proposal.veto_and_assert(Ok(())); + + let proposal = >::get(proposal_id); + + assert_eq!( + proposal, + Proposal { + proposal_type: 1, + parameters, + proposer_id: 1, + created: 1, + status: ProposalStatus::Vetoed, + title: b"title".to_vec(), + body: b"body".to_vec(), + } + ) + }); +} + +#[test] +fn veto_proposal_fails_with_not_active_proposal() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + run_to_block_and_finalize(6); + + let veto_proposal = VetoProposalFixture::new(proposal_id); + veto_proposal.veto_and_assert(Err("Proposal is finalized already")); + }); +} + +#[test] +fn veto_proposal_fails_with_not_existing_proposal() { + initial_test_ext().execute_with(|| { + let veto_proposal = VetoProposalFixture::new(2); + veto_proposal.veto_and_assert(Err("This proposal does not exist")); + }); +} + +#[test] +fn veto_proposal_fails_with_insufficient_rights() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let veto_proposal = VetoProposalFixture::new(proposal_id).with_origin(RawOrigin::Signed(2)); + veto_proposal.veto_and_assert(Err("RequireRootOrigin")); + }); +} + +#[test] +fn create_proposal_event_emitted() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + EventFixture::assert_events(vec![RawEvent::ProposalCreated(1, 1)]); + }); +} + +#[test] +fn veto_proposal_event_emitted() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let veto_proposal = VetoProposalFixture::new(proposal_id); + veto_proposal.veto_and_assert(Ok(())); + + EventFixture::assert_events(vec![ + RawEvent::ProposalCreated(1, 1), + RawEvent::ProposalStatusUpdated(1, ProposalStatus::Vetoed), + RawEvent::ProposalVetoed(1), + ]); + }); +} + +#[test] +fn cancel_proposal_event_emitted() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let cancel_proposal = CancelProposalFixture::new(proposal_id); + cancel_proposal.cancel_and_assert(Ok(())); + + EventFixture::assert_events(vec![ + RawEvent::ProposalCreated(1, 1), + RawEvent::ProposalStatusUpdated(1, ProposalStatus::Canceled), + RawEvent::ProposalCanceled(1, 1), + ]); + }); +} + +#[test] +fn vote_proposal_event_emitted() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposal_id); + vote_generator.vote_and_assert_ok(VoteKind::Approve); + + EventFixture::assert_events(vec![ + RawEvent::ProposalCreated(1, 1), + RawEvent::Voted(1, 1, VoteKind::Approve), + ]); + }); +} + +#[test] +fn create_proposal_and_expire_it() { + initial_test_ext().execute_with(|| { + let parameters = ProposalParameters { + voting_period: 3, + approval_quorum_percentage: 49, + }; + + let dummy_proposal = DummyProposalFixture::default().with_parameters(parameters.clone()); + dummy_proposal.create_proposal_and_assert(Ok(())); + + run_to_block_and_finalize(8); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + let proposal = >::get(proposal_id); + + assert_eq!( + proposal, + Proposal { + proposal_type: 1, + parameters, + proposer_id: 1, + created: 1, + status: ProposalStatus::Expired, + title: b"title".to_vec(), + body: b"body".to_vec(), + } + ) + }); +} diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs new file mode 100644 index 0000000000..06656def86 --- /dev/null +++ b/modules/proposals/engine/src/types.rs @@ -0,0 +1,435 @@ +//! Proposals types module for the Joystream platform. Version 2. +//! Provides types for the proposal engine. + +use codec::{Decode, Encode}; +use rstd::cmp::PartialOrd; +use rstd::ops::Add; +use rstd::prelude::*; + +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; +use srml_support::dispatch; + +/// Current status of the proposal +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)] +pub enum ProposalStatus { + /// A new proposal that is available for voting. + Active, + + /// To clear the quorum requirement, the percentage of council members with revealed votes + /// must be no less than the quorum value for the given proposal type. + Approved, + + /// A proposal was rejected + Rejected, + + /// Not enough votes and voting period expired. + Expired, + + /// Proposal was successfully executed + Executed, + + /// Proposal was executed and failed with an error + Failed { + /// Fail error + error: Vec, + }, + + /// Proposal was withdrawn by its proposer. + Canceled, + + /// Proposal was vetoed by root. + Vetoed, +} + +impl Default for ProposalStatus { + fn default() -> Self { + ProposalStatus::Active + } +} + +/// Vote kind for the proposal. Sum of all votes defines proposal status. +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)] +pub enum VoteKind { + /// Pass, an alternative or a ranking, for binary, multiple choice + /// and ranked choice propositions, respectively. + Approve, + + /// Against proposal. + Reject, + + /// Signals presence, but unwillingness to cast judgment on substance of vote. + Abstain, +} + +impl Default for VoteKind { + fn default() -> Self { + VoteKind::Reject + } +} + +/// Proposal parameters required to manage proposal risk. +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Default, Clone, Copy, PartialEq, Eq, Debug)] +pub struct ProposalParameters { + /// During this period, votes can be accepted + pub voting_period: BlockNumber, + + /// Quorum percentage of approving voters required to pass a proposal. + pub approval_quorum_percentage: u32, + // /// Temporary field which defines expected threshold to pass the vote. + // /// Will be changed to percentage + // pub temp_threshold_vote_count: u32, + + //pub stake: BalanceOf, // +} + +/// 'Proposal' contains information necessary for the proposal system functioning. +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] +pub struct Proposal { + /// Proposal type id + pub proposal_type: u32, + + /// Proposals parameter, characterize different proposal types. + pub parameters: ProposalParameters, + + /// Identifier of member proposing. + pub proposer_id: AccountId, + + /// Proposal title + pub title: Vec, + + /// Proposal body + pub body: Vec, + + /// When it was created. + pub created: BlockNumber, + + // Any stake associated with the proposal. + //pub stake: Option> + /// Current proposal status + pub status: ProposalStatus, +} + +impl + PartialOrd + Copy, AccountId> + Proposal +{ + /// Returns whether voting period expired by now + pub fn is_voting_period_expired(&self, now: BlockNumber) -> bool { + now >= self.created + self.parameters.voting_period + } + + /// Voting results tally for single proposal. + /// Parameters: own proposal id, current time, votes. + /// Returns tally results if proposal status will should change + pub fn tally_results( + self, + proposal_id: u32, + votes: Vec>, + total_voters_count: u32, + now: BlockNumber, + ) -> Option> { + let mut abstentions: u32 = 0; + let mut approvals: u32 = 0; + let mut rejections: u32 = 0; + + for vote in votes.iter() { + match vote.vote_kind { + VoteKind::Abstain => abstentions += 1, + VoteKind::Approve => approvals += 1, + VoteKind::Reject => rejections += 1, + } + } + + let proposal_status_decision = ProposalStatusDecision { + proposal: &self, + approvals, + now, + votes_count: votes.len() as u32, + total_voters_count, + }; + + let new_status: Option = + if proposal_status_decision.is_approval_quorum_reached() { + Some(ProposalStatus::Approved) + } else if proposal_status_decision.is_expired() { + Some(ProposalStatus::Expired) + } else if proposal_status_decision.is_voting_completed() { + Some(ProposalStatus::Rejected) + } else { + None + }; + + if let Some(status) = new_status { + Some(TallyResult { + proposal_id, + abstentions, + approvals, + rejections, + status, + finalized_at: now, + }) + } else { + None + } + } +} + +/// Vote. Characterized by voter and vote kind. +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] +pub struct Vote { + /// Origin of the vote + pub voter_id: AccountId, + + /// Vote kind + pub vote_kind: VoteKind, +} + +/// Tally result for the proposal +#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] +#[derive(Encode, Decode, Default, Clone, PartialEq, Eq)] +pub struct TallyResult { + /// Proposal Id + pub proposal_id: u32, + + /// 'Abstention' votes count + pub abstentions: u32, + + /// 'Approve' votes count + pub approvals: u32, + + /// 'Reject' votes count + pub rejections: u32, + + /// Proposal status after tally + pub status: ProposalStatus, + + /// Proposal finalization block number + pub finalized_at: BlockNumber, +} + +/// Provides data for voting. +pub trait VotersParameters { + /// Defines maximum voters count for the proposal + fn total_voters_count() -> u32; +} + +// Calculates quorum, votes threshold, expiration status +struct ProposalStatusDecision<'a, BlockNumber, AccountId> { + proposal: &'a Proposal, + now: BlockNumber, + votes_count: u32, + total_voters_count: u32, + approvals: u32, +} + +impl<'a, BlockNumber, AccountId> ProposalStatusDecision<'a, BlockNumber, AccountId> +where + BlockNumber: Add + PartialOrd + Copy, +{ + // Proposal has been expired and quorum not reached. + pub fn is_expired(&self) -> bool { + self.proposal.is_voting_period_expired(self.now) + } + + // Approval quorum reached for the proposal + pub fn is_approval_quorum_reached(&self) -> bool { + let approval_votes_fraction: f32 = self.approvals as f32 / self.total_voters_count as f32; + + let approval_quorum_fraction = + self.proposal.parameters.approval_quorum_percentage as f32 / 100.0; + + approval_votes_fraction >= approval_quorum_fraction + } + + // All voters had voted + pub fn is_voting_completed(&self) -> bool { + self.votes_count == self.total_voters_count + } +} + +/// Proposal executable code wrapper +pub trait ProposalExecutable { + /// Executes proposal code + fn execute(&self) -> dispatch::Result; +} + +/// Proposal code binary converter +pub trait ProposalCodeDecoder { + /// Converts proposal code binary to executable representation + fn decode_proposal( + proposal_type: u32, + proposal_code: Vec, + ) -> Result, &'static str>; +} + +#[cfg(test)] +mod tests { + use crate::*; + + #[test] + fn proposal_voting_period_expired() { + let mut proposal = Proposal::::default(); + + proposal.created = 1; + proposal.parameters.voting_period = 3; + + assert!(proposal.is_voting_period_expired(4)); + } + + #[test] + fn proposal_voting_period_not_expired() { + let mut proposal = Proposal::::default(); + + proposal.created = 1; + proposal.parameters.voting_period = 3; + + assert!(!proposal.is_voting_period_expired(3)); + } + + #[test] + fn tally_results_proposal_expired() { + let mut proposal = Proposal::::default(); + let proposal_id = 1; + let now = 5; + proposal.created = 1; + proposal.parameters.voting_period = 3; + proposal.parameters.approval_quorum_percentage = 60; + + let votes = vec![ + Vote { + voter_id: 1, + vote_kind: VoteKind::Approve, + }, + Vote { + voter_id: 2, + vote_kind: VoteKind::Approve, + }, + Vote { + voter_id: 4, + vote_kind: VoteKind::Reject, + }, + ]; + + let expected_tally_results = TallyResult { + proposal_id, + abstentions: 0, + approvals: 2, + rejections: 1, + status: ProposalStatus::Expired, + finalized_at: now, + }; + + assert_eq!( + proposal.tally_results(proposal_id, votes, 5, now), + Some(expected_tally_results) + ); + } + #[test] + fn tally_results_proposal_approved() { + let mut proposal = Proposal::::default(); + let proposal_id = 1; + proposal.created = 1; + proposal.parameters.voting_period = 3; + proposal.parameters.approval_quorum_percentage = 60; + + let votes = vec![ + Vote { + voter_id: 1, + vote_kind: VoteKind::Approve, + }, + Vote { + voter_id: 2, + vote_kind: VoteKind::Approve, + }, + Vote { + voter_id: 3, + vote_kind: VoteKind::Approve, + }, + Vote { + voter_id: 4, + vote_kind: VoteKind::Reject, + }, + ]; + + let expected_tally_results = TallyResult { + proposal_id, + abstentions: 0, + approvals: 3, + rejections: 1, + status: ProposalStatus::Approved, + finalized_at: 2, + }; + + assert_eq!( + proposal.tally_results(proposal_id, votes, 5, 2), + Some(expected_tally_results) + ); + } + + #[test] + fn tally_results_proposal_rejected() { + let mut proposal = Proposal::::default(); + let proposal_id = 1; + let now = 2; + + proposal.created = 1; + proposal.parameters.voting_period = 3; + proposal.parameters.approval_quorum_percentage = 60; + + let votes = vec![ + Vote { + voter_id: 1, + vote_kind: VoteKind::Reject, + }, + Vote { + voter_id: 2, + vote_kind: VoteKind::Reject, + }, + Vote { + voter_id: 3, + vote_kind: VoteKind::Abstain, + }, + Vote { + voter_id: 4, + vote_kind: VoteKind::Approve, + }, + ]; + + let expected_tally_results = TallyResult { + proposal_id, + abstentions: 1, + approvals: 1, + rejections: 2, + status: ProposalStatus::Rejected, + finalized_at: now, + }; + + assert_eq!( + proposal.tally_results(proposal_id, votes, 4, now), + Some(expected_tally_results) + ); + } + + #[test] + fn tally_results_are_empty_with_not_expired_voting_period() { + let mut proposal = Proposal::::default(); + let proposal_id = 1; + let now = 2; + + proposal.created = 1; + proposal.parameters.voting_period = 3; + proposal.parameters.approval_quorum_percentage = 60; + + let votes = vec![Vote { + voter_id: 1, + vote_kind: VoteKind::Abstain, + }]; + + assert_eq!(proposal.tally_results(proposal_id, votes, 5, now), None); + } +} From 979b8a40d5d6ea78450d5952e304364b4b586f6c Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 11 Feb 2020 16:36:08 +0300 Subject: [PATCH 02/19] Delete modules *.lock files - delete codex/Cargo.lock - delete engine/Cargo.lock - update gitignore --- .gitignore | 2 + modules/proposals/codex/Cargo.lock | 1913 --------------------------- modules/proposals/engine/Cargo.lock | 1895 -------------------------- 3 files changed, 2 insertions(+), 3808 deletions(-) delete mode 100644 modules/proposals/codex/Cargo.lock delete mode 100644 modules/proposals/engine/Cargo.lock diff --git a/.gitignore b/.gitignore index 7aad7a3ccb..15b05219df 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ joystream_runtime.wasm # Vim .*.sw* + +/modules/**/*.lock \ No newline at end of file diff --git a/modules/proposals/codex/Cargo.lock b/modules/proposals/codex/Cargo.lock deleted file mode 100644 index 8735dda80e..0000000000 --- a/modules/proposals/codex/Cargo.lock +++ /dev/null @@ -1,1913 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "ahash" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3" -dependencies = [ - "const-random", -] - -[[package]] -name = "aho-corasick" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811" -dependencies = [ - "memchr", -] - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" - -[[package]] -name = "backtrace" -version = "0.3.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f80256bc78f67e7df7e36d77366f636ed976895d91fe2ab9efa3973e8fe8c4f" -dependencies = [ - "backtrace-sys", - "cfg-if", - "libc", - "rustc-demangle", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "base58" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bitmask" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" - -[[package]] -name = "bitvec" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" - -[[package]] -name = "blake2-rfc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" -dependencies = [ - "arrayvec 0.4.12", - "constant_time_eq", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "byte-slice-cast" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "c2-chacha" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" -dependencies = [ - "ppv-lite86", -] - -[[package]] -name = "cc" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "clear_on_drop" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" -dependencies = [ - "cc", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "const-random" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a" -dependencies = [ - "const-random-macro", - "proc-macro-hack", -] - -[[package]] -name = "const-random-macro" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a" -dependencies = [ - "getrandom", - "proc-macro-hack", -] - -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array", - "subtle 1.0.0", -] - -[[package]] -name = "curve25519-dalek" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" -dependencies = [ - "byteorder", - "clear_on_drop", - "digest", - "rand_core 0.3.1", - "subtle 2.2.2", -] - -[[package]] -name = "derivative" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942ca430eef7a3806595a6737bc388bf51adb888d3fc0dd1b50f1c170167ee3a" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "ed25519-dalek" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d07e8b8a8386c3b89a7a4b329fdfa4cb545de2545e9e2ebbc3dd3929253e426" -dependencies = [ - "clear_on_drop", - "curve25519-dalek", - "failure", - "rand 0.6.5", -] - -[[package]] -name = "elastic-array" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" -dependencies = [ - "heapsize", -] - -[[package]] -name = "environmental" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" - -[[package]] -name = "failure" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fixed-hash" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e" -dependencies = [ - "byteorder", - "libc", - "rand 0.5.6", - "rustc-hex", - "static_assertions 0.2.5", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "getrandom" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - -[[package]] -name = "hash256-std-hasher" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "hashbrown" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" -dependencies = [ - "byteorder", - "scopeguard 0.3.3", -] - -[[package]] -name = "hashbrown" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" -dependencies = [ - "ahash", - "autocfg 0.1.7", -] - -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi", -] - -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - -[[package]] -name = "hmac" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -dependencies = [ - "crypto-mac", - "digest", -] - -[[package]] -name = "hmac-drbg" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" -dependencies = [ - "digest", - "generic-array", - "hmac", -] - -[[package]] -name = "impl-codec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-serde" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e3cae7e99c7ff5a995da2cf78dd0a5383740eda71d98cf7b1910c301ac69b8" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" - -[[package]] -name = "keccak" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" - -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" -dependencies = [ - "arrayref", - "crunchy", - "digest", - "hmac-drbg", - "rand 0.7.3", - "sha2", - "subtle 2.2.2", - "typenum", -] - -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -dependencies = [ - "scopeguard 0.3.3", -] - -[[package]] -name = "lock_api" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" -dependencies = [ - "scopeguard 1.0.0", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "malloc_size_of_derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" -dependencies = [ - "proc-macro2 1.0.8", - "syn 1.0.14", - "synstructure", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" - -[[package]] -name = "memory-db" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dabfe0a8c69954ae3bcfc5fc14260a85fb80e1bf9f86a155f668d10a67e93dd" -dependencies = [ - "ahash", - "hash-db", - "hashbrown 0.6.3", - "parity-util-mem", -] - -[[package]] -name = "memory_units" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" - -[[package]] -name = "merlin" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" -dependencies = [ - "byteorder", - "keccak", - "rand_core 0.4.2", - "zeroize 1.1.0", -] - -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg 1.0.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" -dependencies = [ - "autocfg 1.0.0", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da4dc79f9e6c81bef96148c8f6b8e72ad4541caa4a24373e900a36da07de03a3" -dependencies = [ - "autocfg 1.0.0", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -dependencies = [ - "autocfg 1.0.0", -] - -[[package]] -name = "num_enum" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be601e38e20a6f3d01049d85801cb9b7a34a8da7a0da70df507bbde7735058c8" -dependencies = [ - "derivative", - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b59f30f6a043f2606adbd0addbf1eef6f2e28e8c4968918b63b7ff97ac0db2a7" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "once_cell" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" -dependencies = [ - "parking_lot 0.7.1", -] - -[[package]] -name = "once_cell" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "parity-scale-codec" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f747c06d9f3b2ad387ac881b9667298c81b1243aa9833f086e05996937c35507" -dependencies = [ - "arrayvec 0.5.1", - "bitvec", - "byte-slice-cast", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34e513ff3e406f3ede6796dcdc83d0b32ffb86668cea1ccf7363118abeb00476" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "parity-util-mem" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" -dependencies = [ - "cfg-if", - "malloc_size_of_derive", - "winapi", -] - -[[package]] -name = "parity-wasm" -version = "0.40.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" - -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.4.0", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.3", - "parking_lot_core 0.6.2", - "rustc_version", -] - -[[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -dependencies = [ - "libc", - "rand 0.6.5", - "rustc_version", - "smallvec", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec", - "winapi", -] - -[[package]] -name = "paste" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "423a519e1c6e828f1e73b720f9d9ed2fa643dce8a7737fb43235ce0b41eeaa49" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - -[[package]] -name = "paste-impl" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4214c9e912ef61bf42b81ba9a47e8aad1b2ffaf739ab162bf96d1e011f54e6c5" -dependencies = [ - "proc-macro-hack", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "pbkdf2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" -dependencies = [ - "byteorder", - "crypto-mac", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" - -[[package]] -name = "primitive-types" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83ef7b3b965c0eadcb6838f34f827e1dfb2939bdd5ebd43f9647e009b12b0371" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-serde", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" -dependencies = [ - "toml", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -dependencies = [ - "unicode-xid 0.2.0", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -dependencies = [ - "proc-macro2 1.0.8", -] - -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha 0.2.1", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -dependencies = [ - "c2-chacha", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "regex" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "safe-mix" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" -dependencies = [ - "rustc_version", -] - -[[package]] -name = "schnorrkel" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3" -dependencies = [ - "curve25519-dalek", - "failure", - "merlin", - "rand 0.6.5", - "rand_core 0.4.2", - "rand_os", - "sha2", - "subtle 2.2.2", - "zeroize 0.9.3", -] - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" - -[[package]] -name = "scopeguard" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "sha2" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "sr-api-macros" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "blake2-rfc", - "proc-macro-crate", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "sr-arithmetic" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "serde", - "sr-std", - "substrate-debug-derive", -] - -[[package]] -name = "sr-io" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "hash-db", - "libsecp256k1", - "log", - "parity-scale-codec", - "rustc_version", - "sr-std", - "substrate-externalities", - "substrate-primitives", - "substrate-state-machine", - "substrate-trie", - "tiny-keccak", -] - -[[package]] -name = "sr-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "paste", - "rand 0.7.3", - "serde", - "sr-arithmetic", - "sr-io", - "sr-std", - "substrate-application-crypto", - "substrate-primitives", -] - -[[package]] -name = "sr-staking-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "sr-std" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "rustc_version", -] - -[[package]] -name = "sr-version" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "srml-authorship" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-inherents", - "substrate-primitives", -] - -[[package]] -name = "srml-balances" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-keyring", -] - -[[package]] -name = "srml-metadata" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-std", - "substrate-primitives", -] - -[[package]] -name = "srml-session" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-trie", -] - -[[package]] -name = "srml-staking" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-authorship", - "srml-session", - "srml-support", - "srml-system", - "substrate-keyring", - "substrate-phragmen", -] - -[[package]] -name = "srml-support" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "bitmask", - "impl-trait-for-tuples", - "log", - "once_cell 0.2.4", - "parity-scale-codec", - "paste", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-metadata", - "srml-support-procedural", - "substrate-inherents", - "substrate-primitives", -] - -[[package]] -name = "srml-support-procedural" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "sr-api-macros", - "srml-support-procedural-tools", - "syn 0.15.44", -] - -[[package]] -name = "srml-support-procedural-tools" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "proc-macro-crate", - "proc-macro2 0.4.30", - "quote 0.6.13", - "srml-support-procedural-tools-derive", - "syn 0.15.44", -] - -[[package]] -name = "srml-support-procedural-tools-derive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "srml-system" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "sr-version", - "srml-support", - "substrate-primitives", -] - -[[package]] -name = "srml-timestamp" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-inherents", -] - -[[package]] -name = "static_assertions" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "strum" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f" - -[[package]] -name = "strum_macros" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e" -dependencies = [ - "heck", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "substrate-application-crypto" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-std", - "substrate-primitives", -] - -[[package]] -name = "substrate-bip39" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" -dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel", - "sha2", -] - -[[package]] -name = "substrate-debug-derive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "substrate-externalities" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "environmental", - "primitive-types", - "sr-std", - "substrate-primitives-storage", -] - -[[package]] -name = "substrate-inherents" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "substrate-keyring" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "lazy_static", - "sr-primitives", - "strum", - "strum_macros", - "substrate-primitives", -] - -[[package]] -name = "substrate-panic-handler" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "backtrace", - "log", -] - -[[package]] -name = "substrate-phragmen" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "sr-primitives", - "sr-std", -] - -[[package]] -name = "substrate-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "base58", - "blake2-rfc", - "byteorder", - "ed25519-dalek", - "hash-db", - "hash256-std-hasher", - "hex", - "impl-serde", - "lazy_static", - "libsecp256k1", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", - "primitive-types", - "rand 0.7.3", - "regex", - "rustc-hex", - "schnorrkel", - "serde", - "sha2", - "sr-std", - "substrate-bip39", - "substrate-debug-derive", - "substrate-externalities", - "substrate-primitives-storage", - "tiny-bip39", - "tiny-keccak", - "twox-hash", - "wasmi", - "zeroize 0.10.1", -] - -[[package]] -name = "substrate-primitives-storage" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-serde", - "serde", - "sr-std", - "substrate-debug-derive", -] - -[[package]] -name = "substrate-proposals-codex-module" -version = "2.0.0" -dependencies = [ - "num_enum", - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-balances", - "srml-staking", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-primitives", - "substrate-proposals-engine-module", -] - -[[package]] -name = "substrate-proposals-engine-module" -version = "2.0.0" -dependencies = [ - "num_enum", - "parity-scale-codec", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-balances", - "srml-staking", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-primitives", -] - -[[package]] -name = "substrate-state-machine" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "hash-db", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", - "rand 0.7.3", - "substrate-externalities", - "substrate-panic-handler", - "substrate-primitives", - "substrate-trie", - "trie-db", - "trie-root", -] - -[[package]] -name = "substrate-trie" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "hash-db", - "memory-db", - "parity-scale-codec", - "sr-std", - "substrate-primitives", - "trie-db", - "trie-root", -] - -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - -[[package]] -name = "subtle" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "unicode-xid 0.2.0", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", - "unicode-xid 0.2.0", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tiny-bip39" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" -dependencies = [ - "failure", - "hashbrown 0.1.8", - "hmac", - "once_cell 0.1.8", - "pbkdf2", - "rand 0.6.5", - "sha2", -] - -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "toml" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" -dependencies = [ - "serde", -] - -[[package]] -name = "trie-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" -dependencies = [ - "elastic-array", - "hash-db", - "hashbrown 0.6.3", - "log", - "rand 0.6.5", -] - -[[package]] -name = "trie-root" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" -dependencies = [ - "hash-db", -] - -[[package]] -name = "twox-hash" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" -dependencies = [ - "rand 0.7.3", -] - -[[package]] -name = "typenum" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" - -[[package]] -name = "uint" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75a4cdd7b87b28840dba13c483b9a88ee6bbf16ba5c951ee1ecfcf723078e0d" -dependencies = [ - "byteorder", - "crunchy", - "rustc-hex", - "static_assertions 1.1.0", -] - -[[package]] -name = "unicode-segmentation" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasmi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31d26deb2d9a37e6cfed420edce3ed604eab49735ba89035e13c98f9a528313" -dependencies = [ - "libc", - "memory_units", - "num-rational", - "num-traits", - "parity-wasm", - "wasmi-validation", -] - -[[package]] -name = "wasmi-validation" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" -dependencies = [ - "parity-wasm", -] - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "zeroize" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" - -[[package]] -name = "zeroize" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4090487fa66630f7b166fba2bbb525e247a5449f41c468cc1d98f8ae6ac03120" - -[[package]] -name = "zeroize" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", - "synstructure", -] diff --git a/modules/proposals/engine/Cargo.lock b/modules/proposals/engine/Cargo.lock deleted file mode 100644 index 1d76a22622..0000000000 --- a/modules/proposals/engine/Cargo.lock +++ /dev/null @@ -1,1895 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "ahash" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3" -dependencies = [ - "const-random", -] - -[[package]] -name = "aho-corasick" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811" -dependencies = [ - "memchr", -] - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" - -[[package]] -name = "backtrace" -version = "0.3.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f80256bc78f67e7df7e36d77366f636ed976895d91fe2ab9efa3973e8fe8c4f" -dependencies = [ - "backtrace-sys", - "cfg-if", - "libc", - "rustc-demangle", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "base58" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bitmask" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" - -[[package]] -name = "bitvec" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" - -[[package]] -name = "blake2-rfc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" -dependencies = [ - "arrayvec 0.4.12", - "constant_time_eq", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "byte-slice-cast" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "c2-chacha" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" -dependencies = [ - "ppv-lite86", -] - -[[package]] -name = "cc" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "clear_on_drop" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" -dependencies = [ - "cc", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "const-random" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a" -dependencies = [ - "const-random-macro", - "proc-macro-hack", -] - -[[package]] -name = "const-random-macro" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a" -dependencies = [ - "getrandom", - "proc-macro-hack", -] - -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array", - "subtle 1.0.0", -] - -[[package]] -name = "curve25519-dalek" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" -dependencies = [ - "byteorder", - "clear_on_drop", - "digest", - "rand_core 0.3.1", - "subtle 2.2.2", -] - -[[package]] -name = "derivative" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942ca430eef7a3806595a6737bc388bf51adb888d3fc0dd1b50f1c170167ee3a" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "ed25519-dalek" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d07e8b8a8386c3b89a7a4b329fdfa4cb545de2545e9e2ebbc3dd3929253e426" -dependencies = [ - "clear_on_drop", - "curve25519-dalek", - "failure", - "rand 0.6.5", -] - -[[package]] -name = "elastic-array" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" -dependencies = [ - "heapsize", -] - -[[package]] -name = "environmental" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" - -[[package]] -name = "failure" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fixed-hash" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e" -dependencies = [ - "byteorder", - "libc", - "rand 0.5.6", - "rustc-hex", - "static_assertions 0.2.5", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "getrandom" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - -[[package]] -name = "hash256-std-hasher" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "hashbrown" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" -dependencies = [ - "byteorder", - "scopeguard 0.3.3", -] - -[[package]] -name = "hashbrown" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" -dependencies = [ - "ahash", - "autocfg 0.1.7", -] - -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi", -] - -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - -[[package]] -name = "hmac" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -dependencies = [ - "crypto-mac", - "digest", -] - -[[package]] -name = "hmac-drbg" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" -dependencies = [ - "digest", - "generic-array", - "hmac", -] - -[[package]] -name = "impl-codec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-serde" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e3cae7e99c7ff5a995da2cf78dd0a5383740eda71d98cf7b1910c301ac69b8" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" - -[[package]] -name = "keccak" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" - -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" -dependencies = [ - "arrayref", - "crunchy", - "digest", - "hmac-drbg", - "rand 0.7.3", - "sha2", - "subtle 2.2.2", - "typenum", -] - -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -dependencies = [ - "scopeguard 0.3.3", -] - -[[package]] -name = "lock_api" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" -dependencies = [ - "scopeguard 1.0.0", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "malloc_size_of_derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" -dependencies = [ - "proc-macro2 1.0.8", - "syn 1.0.14", - "synstructure", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" - -[[package]] -name = "memory-db" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dabfe0a8c69954ae3bcfc5fc14260a85fb80e1bf9f86a155f668d10a67e93dd" -dependencies = [ - "ahash", - "hash-db", - "hashbrown 0.6.3", - "parity-util-mem", -] - -[[package]] -name = "memory_units" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" - -[[package]] -name = "merlin" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" -dependencies = [ - "byteorder", - "keccak", - "rand_core 0.4.2", - "zeroize 1.1.0", -] - -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg 1.0.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" -dependencies = [ - "autocfg 1.0.0", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da4dc79f9e6c81bef96148c8f6b8e72ad4541caa4a24373e900a36da07de03a3" -dependencies = [ - "autocfg 1.0.0", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -dependencies = [ - "autocfg 1.0.0", -] - -[[package]] -name = "num_enum" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be601e38e20a6f3d01049d85801cb9b7a34a8da7a0da70df507bbde7735058c8" -dependencies = [ - "derivative", - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b59f30f6a043f2606adbd0addbf1eef6f2e28e8c4968918b63b7ff97ac0db2a7" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "once_cell" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" -dependencies = [ - "parking_lot 0.7.1", -] - -[[package]] -name = "once_cell" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "parity-scale-codec" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f747c06d9f3b2ad387ac881b9667298c81b1243aa9833f086e05996937c35507" -dependencies = [ - "arrayvec 0.5.1", - "bitvec", - "byte-slice-cast", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34e513ff3e406f3ede6796dcdc83d0b32ffb86668cea1ccf7363118abeb00476" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "parity-util-mem" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" -dependencies = [ - "cfg-if", - "malloc_size_of_derive", - "winapi", -] - -[[package]] -name = "parity-wasm" -version = "0.40.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" - -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.4.0", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.3", - "parking_lot_core 0.6.2", - "rustc_version", -] - -[[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -dependencies = [ - "libc", - "rand 0.6.5", - "rustc_version", - "smallvec", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec", - "winapi", -] - -[[package]] -name = "paste" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "423a519e1c6e828f1e73b720f9d9ed2fa643dce8a7737fb43235ce0b41eeaa49" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - -[[package]] -name = "paste-impl" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4214c9e912ef61bf42b81ba9a47e8aad1b2ffaf739ab162bf96d1e011f54e6c5" -dependencies = [ - "proc-macro-hack", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "pbkdf2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" -dependencies = [ - "byteorder", - "crypto-mac", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" - -[[package]] -name = "primitive-types" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83ef7b3b965c0eadcb6838f34f827e1dfb2939bdd5ebd43f9647e009b12b0371" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-serde", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" -dependencies = [ - "toml", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -dependencies = [ - "unicode-xid 0.2.0", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -dependencies = [ - "proc-macro2 1.0.8", -] - -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha 0.2.1", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -dependencies = [ - "c2-chacha", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "regex" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "safe-mix" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" -dependencies = [ - "rustc_version", -] - -[[package]] -name = "schnorrkel" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3" -dependencies = [ - "curve25519-dalek", - "failure", - "merlin", - "rand 0.6.5", - "rand_core 0.4.2", - "rand_os", - "sha2", - "subtle 2.2.2", - "zeroize 0.9.3", -] - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" - -[[package]] -name = "scopeguard" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "sha2" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "sr-api-macros" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "blake2-rfc", - "proc-macro-crate", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "sr-arithmetic" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "serde", - "sr-std", - "substrate-debug-derive", -] - -[[package]] -name = "sr-io" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "hash-db", - "libsecp256k1", - "log", - "parity-scale-codec", - "rustc_version", - "sr-std", - "substrate-externalities", - "substrate-primitives", - "substrate-state-machine", - "substrate-trie", - "tiny-keccak", -] - -[[package]] -name = "sr-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "paste", - "rand 0.7.3", - "serde", - "sr-arithmetic", - "sr-io", - "sr-std", - "substrate-application-crypto", - "substrate-primitives", -] - -[[package]] -name = "sr-staking-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "sr-std" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "rustc_version", -] - -[[package]] -name = "sr-version" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "srml-authorship" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-inherents", - "substrate-primitives", -] - -[[package]] -name = "srml-balances" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-keyring", -] - -[[package]] -name = "srml-metadata" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-std", - "substrate-primitives", -] - -[[package]] -name = "srml-session" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-trie", -] - -[[package]] -name = "srml-staking" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-authorship", - "srml-session", - "srml-support", - "srml-system", - "substrate-keyring", - "substrate-phragmen", -] - -[[package]] -name = "srml-support" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "bitmask", - "impl-trait-for-tuples", - "log", - "once_cell 0.2.4", - "parity-scale-codec", - "paste", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-metadata", - "srml-support-procedural", - "substrate-inherents", - "substrate-primitives", -] - -[[package]] -name = "srml-support-procedural" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "sr-api-macros", - "srml-support-procedural-tools", - "syn 0.15.44", -] - -[[package]] -name = "srml-support-procedural-tools" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "proc-macro-crate", - "proc-macro2 0.4.30", - "quote 0.6.13", - "srml-support-procedural-tools-derive", - "syn 0.15.44", -] - -[[package]] -name = "srml-support-procedural-tools-derive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "srml-system" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "sr-version", - "srml-support", - "substrate-primitives", -] - -[[package]] -name = "srml-timestamp" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-inherents", -] - -[[package]] -name = "static_assertions" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "strum" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f" - -[[package]] -name = "strum_macros" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e" -dependencies = [ - "heck", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "substrate-application-crypto" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-std", - "substrate-primitives", -] - -[[package]] -name = "substrate-bip39" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" -dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel", - "sha2", -] - -[[package]] -name = "substrate-debug-derive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", -] - -[[package]] -name = "substrate-externalities" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "environmental", - "primitive-types", - "sr-std", - "substrate-primitives-storage", -] - -[[package]] -name = "substrate-inherents" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "substrate-keyring" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "lazy_static", - "sr-primitives", - "strum", - "strum_macros", - "substrate-primitives", -] - -[[package]] -name = "substrate-panic-handler" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "backtrace", - "log", -] - -[[package]] -name = "substrate-phragmen" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "sr-primitives", - "sr-std", -] - -[[package]] -name = "substrate-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "base58", - "blake2-rfc", - "byteorder", - "ed25519-dalek", - "hash-db", - "hash256-std-hasher", - "hex", - "impl-serde", - "lazy_static", - "libsecp256k1", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", - "primitive-types", - "rand 0.7.3", - "regex", - "rustc-hex", - "schnorrkel", - "serde", - "sha2", - "sr-std", - "substrate-bip39", - "substrate-debug-derive", - "substrate-externalities", - "substrate-primitives-storage", - "tiny-bip39", - "tiny-keccak", - "twox-hash", - "wasmi", - "zeroize 0.10.1", -] - -[[package]] -name = "substrate-primitives-storage" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "impl-serde", - "serde", - "sr-std", - "substrate-debug-derive", -] - -[[package]] -name = "substrate-proposals-engine-module" -version = "2.0.0" -dependencies = [ - "num_enum", - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-balances", - "srml-staking", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-primitives", -] - -[[package]] -name = "substrate-state-machine" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "hash-db", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", - "rand 0.7.3", - "substrate-externalities", - "substrate-panic-handler", - "substrate-primitives", - "substrate-trie", - "trie-db", - "trie-root", -] - -[[package]] -name = "substrate-trie" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3" -dependencies = [ - "hash-db", - "memory-db", - "parity-scale-codec", - "sr-std", - "substrate-primitives", - "trie-db", - "trie-root", -] - -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - -[[package]] -name = "subtle" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "unicode-xid 0.2.0", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", - "unicode-xid 0.2.0", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tiny-bip39" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" -dependencies = [ - "failure", - "hashbrown 0.1.8", - "hmac", - "once_cell 0.1.8", - "pbkdf2", - "rand 0.6.5", - "sha2", -] - -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "toml" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" -dependencies = [ - "serde", -] - -[[package]] -name = "trie-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" -dependencies = [ - "elastic-array", - "hash-db", - "hashbrown 0.6.3", - "log", - "rand 0.6.5", -] - -[[package]] -name = "trie-root" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" -dependencies = [ - "hash-db", -] - -[[package]] -name = "twox-hash" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" -dependencies = [ - "rand 0.7.3", -] - -[[package]] -name = "typenum" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" - -[[package]] -name = "uint" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75a4cdd7b87b28840dba13c483b9a88ee6bbf16ba5c951ee1ecfcf723078e0d" -dependencies = [ - "byteorder", - "crunchy", - "rustc-hex", - "static_assertions 1.1.0", -] - -[[package]] -name = "unicode-segmentation" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasmi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31d26deb2d9a37e6cfed420edce3ed604eab49735ba89035e13c98f9a528313" -dependencies = [ - "libc", - "memory_units", - "num-rational", - "num-traits", - "parity-wasm", - "wasmi-validation", -] - -[[package]] -name = "wasmi-validation" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" -dependencies = [ - "parity-wasm", -] - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "zeroize" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" - -[[package]] -name = "zeroize" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4090487fa66630f7b166fba2bbb525e247a5449f41c468cc1d98f8ae6ac03120" - -[[package]] -name = "zeroize" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" -dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", - "synstructure", -] From a56b4c5a0b7b3827c3ce65a1209affebb676b367 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 13 Feb 2020 16:40:55 +0300 Subject: [PATCH 03/19] Fix review comments 1 - introduce ProposalId type - change BTreeSet to the linked_map --- modules/proposals/engine/src/lib.rs | 66 +++++++++++++++------------ modules/proposals/engine/src/types.rs | 10 ++-- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 04b641baea..022032f2bd 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -27,12 +27,13 @@ mod types; #[cfg(test)] mod tests; -use rstd::collections::btree_set::BTreeSet; use rstd::prelude::*; use runtime_primitives::traits::EnsureOrigin; -use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, StorageDoubleMap}; +use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, StorageDoubleMap, Parameter}; use system::ensure_root; + + const DEFAULT_TITLE_MAX_LEN: u32 = 100; const DEFAULT_BODY_MAX_LEN: u32 = 10_000; @@ -52,42 +53,46 @@ pub trait Trait: system::Trait + timestamp::Trait { /// Converts proposal code binary to executable representation type ProposalCodeDecoder: ProposalCodeDecoder; + + /// Proposal Id type + type ProposalId : From + Parameter + Default + Copy; } decl_event!( pub enum Event where - ::AccountId + ::AccountId, + ::ProposalId { /// Emits on proposal creation. /// Params: /// * Account id of a proposer. /// * Id of a newly created proposal after it was saved in storage. - ProposalCreated(AccountId, u32), + ProposalCreated(AccountId, ProposalId), /// Emits on proposal cancellation. /// Params: /// * Account id of a proposer. /// * Id of a cancelled proposal. - ProposalCanceled(AccountId, u32), + ProposalCanceled(AccountId, ProposalId), /// Emits on proposal veto. /// Params: /// * Id of a vetoed proposal. - ProposalVetoed(u32), + ProposalVetoed(ProposalId), /// Emits on proposal status change. /// Params: /// * Id of a updated proposal. /// * New proposal status - ProposalStatusUpdated(u32, ProposalStatus), + ProposalStatusUpdated(ProposalId, ProposalStatus), /// Emits on voting for the proposal /// Params: /// * Voter - an account id of a voter. /// * Id of a proposal. /// * Kind of vote. - Voted(AccountId, u32, VoteKind), + Voted(AccountId, ProposalId, VoteKind), } ); @@ -95,26 +100,27 @@ decl_event!( decl_storage! { trait Store for Module as ProposalsEngine{ /// Map proposal by its id. - pub Proposals get(fn proposals): map u32 => Proposal; + pub Proposals get(fn proposals): map T::ProposalId => Proposal; /// Count of all proposals that have been created. pub ProposalCount get(fn proposal_count): u32; /// Map proposal executable code by proposal id. - ProposalCode get(fn proposal_codes): map u32 => Vec; + ProposalCode get(fn proposal_codes): map T::ProposalId => Vec; /// Map votes by proposal id. - VotesByProposalId get(fn votes_by_proposal): map u32 => Vec>; + VotesByProposalId get(fn votes_by_proposal): map T::ProposalId => Vec>; /// Ids of proposals that are open for voting (have not been finalized yet). - pub ActiveProposalIds get(fn active_proposal_ids): BTreeSet; + pub ActiveProposalIds get(fn active_proposal_ids): linked_map T::ProposalId => (); /// Proposal tally results map - pub(crate) TallyResults get(fn tally_results): map u32 => TallyResult; + pub(crate) TallyResults get(fn tally_results): map T::ProposalId => + TallyResult; /// Double map for preventing duplicate votes VoteExistsByAccountByProposal get(fn vote_by_proposal_by_account): - double_map T::AccountId, twox_256(u32) => (); + double_map T::AccountId, twox_256(T::ProposalId) => (); /// Defines max allowed proposal title length. Can be configured. @@ -133,7 +139,7 @@ decl_module! { fn deposit_event() = default; /// Vote extrinsic. Conditions: origin must allow votes. - pub fn vote(origin, proposal_id: u32, vote: VoteKind) { + pub fn vote(origin, proposal_id: T::ProposalId, vote: VoteKind) { let voter_id = T::VoteOrigin::ensure_origin(origin)?; ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); @@ -164,7 +170,7 @@ decl_module! { } /// Cancel a proposal by its original proposer. - pub fn cancel_proposal(origin, proposal_id: u32) { + pub fn cancel_proposal(origin, proposal_id: T::ProposalId) { let proposer_id = T::ProposalOrigin::ensure_origin(origin)?; ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); @@ -180,7 +186,7 @@ decl_module! { } /// Veto a proposal. Must be root. - pub fn veto_proposal(origin, proposal_id: u32) { + pub fn veto_proposal(origin, proposal_id: T::ProposalId) { ensure_root(origin)?; ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); @@ -247,12 +253,13 @@ impl Module { }; // mutation - >::insert(new_proposal_id, new_proposal); - ::insert(new_proposal_id, proposal_code); - ActiveProposalIds::mutate(|ids| ids.insert(new_proposal_id)); + let proposal_id = T::ProposalId::from(new_proposal_id); + >::insert(proposal_id, new_proposal); + >::insert(proposal_id, proposal_code); + >::insert(proposal_id, ()); ProposalCount::put(next_proposal_count_value); - Self::deposit_event(RawEvent::ProposalCreated(proposer_id, new_proposal_id)); + Self::deposit_event(RawEvent::ProposalCreated(proposer_id, proposal_id)); Ok(()) } @@ -265,7 +272,7 @@ impl Module { } // Executes approved proposal code - fn execute_proposal(proposal_id: u32) { + fn execute_proposal(proposal_id: T::ProposalId) { //let origin = system::RawOrigin::Root.into(); let proposal = Self::proposals(proposal_id); let proposal_code = Self::proposal_codes(proposal_id); @@ -291,11 +298,12 @@ impl Module { Self::update_proposal_status(proposal_id, new_proposal_status) } + // TODO convert to map-filter style /// Voting results tally. /// Returns proposals with changed status and tally results - fn tally() -> Vec> { + fn tally() -> Vec> { let mut results = Vec::new(); - for &proposal_id in Self::active_proposal_ids().iter() { + for (proposal_id, _) in >::enumerate() { let votes = Self::votes_by_proposal(proposal_id); let proposal = Self::proposals(proposal_id); @@ -313,9 +321,9 @@ impl Module { } /// Updates proposal status and removes proposal id from active id set. - fn update_proposal_status(proposal_id: u32, new_status: ProposalStatus) { + fn update_proposal_status(proposal_id: T::ProposalId, new_status: ProposalStatus) { >::mutate(proposal_id, |p| p.status = new_status.clone()); - ActiveProposalIds::mutate(|ids| ids.remove(&proposal_id)); + >::remove(&proposal_id); Self::deposit_event(RawEvent::ProposalStatusUpdated( proposal_id, @@ -329,7 +337,7 @@ impl Module { ProposalStatus::Approved => Self::approve_proposal(proposal_id), ProposalStatus::Active => { // restore active proposal id - ActiveProposalIds::mutate(|ids| ids.insert(proposal_id)); + >::insert(proposal_id, ()); } ProposalStatus::Executed | ProposalStatus::Failed { .. } @@ -339,10 +347,10 @@ impl Module { } /// Reject a proposal. The staked deposit will be returned to a proposer. - fn reject_proposal(_proposal_id: u32) {} + fn reject_proposal(_proposal_id: T::ProposalId) {} /// Approve a proposal. The staked deposit will be returned. - fn approve_proposal(proposal_id: u32) { + fn approve_proposal(proposal_id: T::ProposalId) { Self::execute_proposal(proposal_id); } } diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 06656def86..5c03816bd7 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -125,13 +125,13 @@ impl + PartialOrd + Copy, AccountId> /// Voting results tally for single proposal. /// Parameters: own proposal id, current time, votes. /// Returns tally results if proposal status will should change - pub fn tally_results( + pub fn tally_results( self, - proposal_id: u32, + proposal_id: ProposalId, votes: Vec>, total_voters_count: u32, now: BlockNumber, - ) -> Option> { + ) -> Option> { let mut abstentions: u32 = 0; let mut approvals: u32 = 0; let mut rejections: u32 = 0; @@ -192,9 +192,9 @@ pub struct Vote { /// Tally result for the proposal #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq)] -pub struct TallyResult { +pub struct TallyResult { /// Proposal Id - pub proposal_id: u32, + pub proposal_id: ProposalId, /// 'Abstention' votes count pub abstentions: u32, From 2495f3c27ebcc800a5dff498a21b722287d75d58 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 13 Feb 2020 16:46:27 +0300 Subject: [PATCH 04/19] Fix tests and update codex module --- modules/proposals/codex/src/tests/mock.rs | 2 ++ modules/proposals/engine/src/lib.rs | 8 ++++---- modules/proposals/engine/src/tests/mock.rs | 2 ++ modules/proposals/engine/src/tests/mod.rs | 11 +++-------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/proposals/codex/src/tests/mock.rs b/modules/proposals/codex/src/tests/mock.rs index 7f3fd33f74..dc72ab1d9e 100644 --- a/modules/proposals/codex/src/tests/mock.rs +++ b/modules/proposals/codex/src/tests/mock.rs @@ -45,6 +45,8 @@ impl proposal_engine::Trait for Test { type TotalVotersCounter = MockVotersParameters; type ProposalCodeDecoder = crate::ProposalType; + + type ProposalId = u32; } pub struct MockVotersParameters; diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 022032f2bd..578bf058b2 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -29,11 +29,11 @@ mod tests; use rstd::prelude::*; use runtime_primitives::traits::EnsureOrigin; -use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, StorageDoubleMap, Parameter}; +use srml_support::{ + decl_event, decl_module, decl_storage, dispatch, ensure, Parameter, StorageDoubleMap, +}; use system::ensure_root; - - const DEFAULT_TITLE_MAX_LEN: u32 = 100; const DEFAULT_BODY_MAX_LEN: u32 = 10_000; @@ -55,7 +55,7 @@ pub trait Trait: system::Trait + timestamp::Trait { type ProposalCodeDecoder: ProposalCodeDecoder; /// Proposal Id type - type ProposalId : From + Parameter + Default + Copy; + type ProposalId: From + Parameter + Default + Copy; } decl_event!( diff --git a/modules/proposals/engine/src/tests/mock.rs b/modules/proposals/engine/src/tests/mock.rs index 462fa912af..a39ad3ff8f 100644 --- a/modules/proposals/engine/src/tests/mock.rs +++ b/modules/proposals/engine/src/tests/mock.rs @@ -54,6 +54,8 @@ impl crate::Trait for Test { type TotalVotersCounter = (); type ProposalCodeDecoder = ProposalType; + + type ProposalId = u32; } impl VotersParameters for () { diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index d76585358d..9ec0b5d45e 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -166,7 +166,7 @@ impl VoteGenerator { struct EventFixture; impl EventFixture { - fn assert_events(expected_raw_events: Vec>) { + fn assert_events(expected_raw_events: Vec>) { let expected_events = expected_raw_events .iter() .map(|ev| EventRecord { @@ -377,11 +377,7 @@ fn rejected_tally_results_and_remove_proposal_id_from_active_succeeds() { vote_generator.vote_and_assert_ok(VoteKind::Abstain); vote_generator.vote_and_assert_ok(VoteKind::Abstain); - let mut active_proposals_id = ::get(); - - let mut active_proposals_set = BTreeSet::new(); - active_proposals_set.insert(proposal_id); - assert_eq!(active_proposals_id, active_proposals_set); + assert!(>::exists(proposal_id)); run_to_block_and_finalize(2); @@ -399,8 +395,7 @@ fn rejected_tally_results_and_remove_proposal_id_from_active_succeeds() { } ); - active_proposals_id = ::get(); - assert_eq!(active_proposals_id, BTreeSet::new()); + assert!(!>::exists(proposal_id)); }); } From a77f8e254597192a54ae57d302bf814566ed3a4f Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 14 Feb 2020 12:03:34 +0300 Subject: [PATCH 05/19] Embed tally results into the proposal object --- modules/proposals/engine/src/lib.rs | 32 ++++++------- modules/proposals/engine/src/tests/mod.rs | 42 ++++++++++++----- modules/proposals/engine/src/types.rs | 56 +++++++++-------------- 3 files changed, 68 insertions(+), 62 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 578bf058b2..1e37e70d5e 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -114,10 +114,6 @@ decl_storage! { /// Ids of proposals that are open for voting (have not been finalized yet). pub ActiveProposalIds get(fn active_proposal_ids): linked_map T::ProposalId => (); - /// Proposal tally results map - pub(crate) TallyResults get(fn tally_results): map T::ProposalId => - TallyResult; - /// Double map for preventing duplicate votes VoteExistsByAccountByProposal get(fn vote_by_proposal_by_account): double_map T::AccountId, twox_256(T::ProposalId) => (); @@ -202,14 +198,12 @@ decl_module! { /// Block finalization. Perform voting period check and vote result tally. fn on_finalize(_n: T::BlockNumber) { - let tally_results = Self::tally(); + let proposals_with_ready_result = Self::tally(); // mutation - - for tally_result in tally_results { - >::insert(tally_result.proposal_id, &tally_result); - - Self::update_proposal_status(tally_result.proposal_id, tally_result.status); + for (proposal_id, proposal, new_status) in proposals_with_ready_result { + >::insert(proposal_id, proposal); + Self::update_proposal_status(proposal_id, new_status); } } } @@ -250,6 +244,7 @@ impl Module { proposer_id: proposer_id.clone(), proposal_type, status: ProposalStatus::Active, + tally_results: None, }; // mutation @@ -301,19 +296,24 @@ impl Module { // TODO convert to map-filter style /// Voting results tally. /// Returns proposals with changed status and tally results - fn tally() -> Vec> { + fn tally() -> Vec<( + T::ProposalId, + Proposal, + ProposalStatus, + )> { let mut results = Vec::new(); for (proposal_id, _) in >::enumerate() { let votes = Self::votes_by_proposal(proposal_id); - let proposal = Self::proposals(proposal_id); + let mut proposal = Self::proposals(proposal_id); - if let Some(tally_result) = proposal.tally_results( - proposal_id, + proposal.update_tally_results( votes, T::TotalVotersCounter::total_voters_count(), Self::current_block(), - ) { - results.push(tally_result); + ); + + if let Some(tally_results) = proposal.tally_results.clone() { + results.push((proposal_id, proposal, tally_results.status)); } } diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index 9ec0b5d45e..68528b3e20 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -4,7 +4,6 @@ use crate::*; use mock::*; use codec::Encode; -use rstd::collections::btree_set::BTreeSet; use runtime_primitives::traits::{OnFinalize, OnInitialize}; use srml_support::{dispatch, StorageMap, StorageValue}; use system::RawOrigin; @@ -273,6 +272,13 @@ fn proposal_execution_succeeds() { status: ProposalStatus::Executed, title: b"title".to_vec(), body: b"body".to_vec(), + tally_results: Some(TallyResult { + abstentions: 0, + approvals: 4, + rejections: 0, + status: ProposalStatus::Approved, + finalized_at: 1 + }), } ) }); @@ -319,6 +325,13 @@ fn proposal_execution_failed() { }, title: b"title".to_vec(), body: b"body".to_vec(), + tally_results: Some(TallyResult { + abstentions: 0, + approvals: 4, + rejections: 0, + status: ProposalStatus::Approved, + finalized_at: 1 + }), } ) }); @@ -346,18 +359,17 @@ fn tally_calculation_succeeds() { run_to_block_and_finalize(2); - let tally_result = >::get(proposals_id); + let proposal = >::get(proposals_id); assert_eq!( - tally_result, - TallyResult { - proposal_id: proposals_id, + proposal.tally_results, + Some(TallyResult { abstentions: 1, approvals: 2, rejections: 1, status: ProposalStatus::Approved, finalized_at: 1 - } + }) ) }); } @@ -381,18 +393,17 @@ fn rejected_tally_results_and_remove_proposal_id_from_active_succeeds() { run_to_block_and_finalize(2); - let tally_result = >::get(proposal_id); + let proposal = >::get(proposal_id); assert_eq!( - tally_result, - TallyResult { - proposal_id, + proposal.tally_results, + Some(TallyResult { abstentions: 2, approvals: 0, rejections: 2, status: ProposalStatus::Rejected, finalized_at: 1 - } + }) ); assert!(!>::exists(proposal_id)); @@ -520,6 +531,7 @@ fn cancel_proposal_succeeds() { status: ProposalStatus::Canceled, title: b"title".to_vec(), body: b"body".to_vec(), + tally_results: None, } ) }); @@ -592,6 +604,7 @@ fn veto_proposal_succeeds() { status: ProposalStatus::Vetoed, title: b"title".to_vec(), body: b"body".to_vec(), + tally_results: None, } ) }); @@ -731,6 +744,13 @@ fn create_proposal_and_expire_it() { status: ProposalStatus::Expired, title: b"title".to_vec(), body: b"body".to_vec(), + tally_results: Some(TallyResult { + abstentions: 0, + approvals: 0, + rejections: 0, + status: ProposalStatus::Expired, + finalized_at: 4 + }), } ) }); diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 5c03816bd7..0c4dae8495 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -112,6 +112,9 @@ pub struct Proposal { //pub stake: Option> /// Current proposal status pub status: ProposalStatus, + + /// Tally result for the proposal + pub tally_results: Option>, } impl + PartialOrd + Copy, AccountId> @@ -122,16 +125,15 @@ impl + PartialOrd + Copy, AccountId> now >= self.created + self.parameters.voting_period } - /// Voting results tally for single proposal. - /// Parameters: own proposal id, current time, votes. - /// Returns tally results if proposal status will should change - pub fn tally_results( - self, - proposal_id: ProposalId, + /// Calculates and updates voting results tally for current proposal. + /// Parameters: current time, votes, total voters number involved (council size) + /// Returns whether tally results are ready. + pub fn update_tally_results( + &mut self, votes: Vec>, total_voters_count: u32, now: BlockNumber, - ) -> Option> { + ) { let mut abstentions: u32 = 0; let mut approvals: u32 = 0; let mut rejections: u32 = 0; @@ -145,7 +147,7 @@ impl + PartialOrd + Copy, AccountId> } let proposal_status_decision = ProposalStatusDecision { - proposal: &self, + proposal: self, approvals, now, votes_count: votes.len() as u32, @@ -163,9 +165,8 @@ impl + PartialOrd + Copy, AccountId> None }; - if let Some(status) = new_status { + self.tally_results = if let Some(status) = new_status { Some(TallyResult { - proposal_id, abstentions, approvals, rejections, @@ -174,7 +175,7 @@ impl + PartialOrd + Copy, AccountId> }) } else { None - } + }; } } @@ -192,10 +193,7 @@ pub struct Vote { /// Tally result for the proposal #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq)] -pub struct TallyResult { - /// Proposal Id - pub proposal_id: ProposalId, - +pub struct TallyResult { /// 'Abstention' votes count pub abstentions: u32, @@ -294,7 +292,6 @@ mod tests { #[test] fn tally_results_proposal_expired() { let mut proposal = Proposal::::default(); - let proposal_id = 1; let now = 5; proposal.created = 1; proposal.parameters.voting_period = 3; @@ -316,7 +313,6 @@ mod tests { ]; let expected_tally_results = TallyResult { - proposal_id, abstentions: 0, approvals: 2, rejections: 1, @@ -324,15 +320,12 @@ mod tests { finalized_at: now, }; - assert_eq!( - proposal.tally_results(proposal_id, votes, 5, now), - Some(expected_tally_results) - ); + proposal.update_tally_results(votes, 5, now); + assert_eq!(proposal.tally_results, Some(expected_tally_results)); } #[test] fn tally_results_proposal_approved() { let mut proposal = Proposal::::default(); - let proposal_id = 1; proposal.created = 1; proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; @@ -357,7 +350,6 @@ mod tests { ]; let expected_tally_results = TallyResult { - proposal_id, abstentions: 0, approvals: 3, rejections: 1, @@ -365,16 +357,13 @@ mod tests { finalized_at: 2, }; - assert_eq!( - proposal.tally_results(proposal_id, votes, 5, 2), - Some(expected_tally_results) - ); + proposal.update_tally_results(votes, 5, 2); + assert_eq!(proposal.tally_results, Some(expected_tally_results)); } #[test] fn tally_results_proposal_rejected() { let mut proposal = Proposal::::default(); - let proposal_id = 1; let now = 2; proposal.created = 1; @@ -401,7 +390,6 @@ mod tests { ]; let expected_tally_results = TallyResult { - proposal_id, abstentions: 1, approvals: 1, rejections: 2, @@ -409,16 +397,13 @@ mod tests { finalized_at: now, }; - assert_eq!( - proposal.tally_results(proposal_id, votes, 4, now), - Some(expected_tally_results) - ); + proposal.update_tally_results(votes, 4, now); + assert_eq!(proposal.tally_results, Some(expected_tally_results)); } #[test] fn tally_results_are_empty_with_not_expired_voting_period() { let mut proposal = Proposal::::default(); - let proposal_id = 1; let now = 2; proposal.created = 1; @@ -430,6 +415,7 @@ mod tests { vote_kind: VoteKind::Abstain, }]; - assert_eq!(proposal.tally_results(proposal_id, votes, 5, now), None); + proposal.update_tally_results(votes, 5, now); + assert_eq!(proposal.tally_results, None); } } From 29c63ff57e78a6af0f9637bc3f7f29877c9856f8 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 14 Feb 2020 12:27:43 +0300 Subject: [PATCH 06/19] Embed votes into the proposal struct --- modules/proposals/engine/src/lib.rs | 12 +++++------- modules/proposals/engine/src/tests/mod.rs | 13 ++++++++++-- modules/proposals/engine/src/types.rs | 24 ++++++++++++----------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 1e37e70d5e..b6b969b90a 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -108,9 +108,6 @@ decl_storage! { /// Map proposal executable code by proposal id. ProposalCode get(fn proposal_codes): map T::ProposalId => Vec; - /// Map votes by proposal id. - VotesByProposalId get(fn votes_by_proposal): map T::ProposalId => Vec>; - /// Ids of proposals that are open for voting (have not been finalized yet). pub ActiveProposalIds get(fn active_proposal_ids): linked_map T::ProposalId => (); @@ -139,7 +136,7 @@ decl_module! { let voter_id = T::VoteOrigin::ensure_origin(origin)?; ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); - let proposal = Self::proposals(proposal_id); + let mut proposal = Self::proposals(proposal_id); let not_expired = !proposal.is_voting_period_expired(Self::current_block()); ensure!(not_expired, errors::MSG_PROPOSAL_EXPIRED); @@ -158,9 +155,11 @@ decl_module! { vote_kind: vote.clone(), }; + proposal.votes.push(new_vote); + // mutation - >::mutate(proposal_id, |votes| votes.push(new_vote)); + >::insert(proposal_id, proposal); >::insert(voter_id.clone(), proposal_id, ()); Self::deposit_event(RawEvent::Voted(voter_id, proposal_id, vote)); } @@ -245,6 +244,7 @@ impl Module { proposal_type, status: ProposalStatus::Active, tally_results: None, + votes: Vec::new(), }; // mutation @@ -303,11 +303,9 @@ impl Module { )> { let mut results = Vec::new(); for (proposal_id, _) in >::enumerate() { - let votes = Self::votes_by_proposal(proposal_id); let mut proposal = Self::proposals(proposal_id); proposal.update_tally_results( - votes, T::TotalVotersCounter::total_voters_count(), Self::current_block(), ); diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index 68528b3e20..70c39434c2 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -132,6 +132,7 @@ struct VoteGenerator { proposal_id: u32, current_account_id: u64, pub auto_increment_voter_id: bool, + pub saved_votes: Vec> } impl VoteGenerator { @@ -140,14 +141,17 @@ impl VoteGenerator { proposal_id, current_account_id: 0, auto_increment_voter_id: true, + saved_votes: Vec::new(), } } fn vote_and_assert_ok(&mut self, vote_kind: VoteKind) { - assert_eq!(self.vote(vote_kind), Ok(())); + self.vote_and_assert(vote_kind, Ok(())); } fn vote_and_assert(&mut self, vote_kind: VoteKind, expected_result: dispatch::Result) { - assert_eq!(self.vote(vote_kind), expected_result); + assert_eq!(self.vote(vote_kind.clone()), expected_result); + + self.saved_votes.push( Vote{voter_id: self.current_account_id, vote_kind}); } fn vote(&mut self, vote_kind: VoteKind) -> dispatch::Result { @@ -279,6 +283,7 @@ fn proposal_execution_succeeds() { status: ProposalStatus::Approved, finalized_at: 1 }), + votes: vote_generator.saved_votes, } ) }); @@ -332,6 +337,7 @@ fn proposal_execution_failed() { status: ProposalStatus::Approved, finalized_at: 1 }), + votes: vote_generator.saved_votes, } ) }); @@ -532,6 +538,7 @@ fn cancel_proposal_succeeds() { title: b"title".to_vec(), body: b"body".to_vec(), tally_results: None, + votes: Vec::new(), } ) }); @@ -605,6 +612,7 @@ fn veto_proposal_succeeds() { title: b"title".to_vec(), body: b"body".to_vec(), tally_results: None, + votes: Vec::new(), } ) }); @@ -751,6 +759,7 @@ fn create_proposal_and_expire_it() { status: ProposalStatus::Expired, finalized_at: 4 }), + votes: Vec::new(), } ) }); diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 0c4dae8495..f426617a1e 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -115,6 +115,9 @@ pub struct Proposal { /// Tally result for the proposal pub tally_results: Option>, + + /// Votes for the proposal + pub votes: Vec>, } impl + PartialOrd + Copy, AccountId> @@ -130,7 +133,6 @@ impl + PartialOrd + Copy, AccountId> /// Returns whether tally results are ready. pub fn update_tally_results( &mut self, - votes: Vec>, total_voters_count: u32, now: BlockNumber, ) { @@ -138,7 +140,7 @@ impl + PartialOrd + Copy, AccountId> let mut approvals: u32 = 0; let mut rejections: u32 = 0; - for vote in votes.iter() { + for vote in self.votes.iter() { match vote.vote_kind { VoteKind::Abstain => abstentions += 1, VoteKind::Approve => approvals += 1, @@ -150,7 +152,7 @@ impl + PartialOrd + Copy, AccountId> proposal: self, approvals, now, - votes_count: votes.len() as u32, + votes_count: self.votes.len() as u32, total_voters_count, }; @@ -297,7 +299,7 @@ mod tests { proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; - let votes = vec![ + proposal.votes = vec![ Vote { voter_id: 1, vote_kind: VoteKind::Approve, @@ -320,7 +322,7 @@ mod tests { finalized_at: now, }; - proposal.update_tally_results(votes, 5, now); + proposal.update_tally_results(5, now); assert_eq!(proposal.tally_results, Some(expected_tally_results)); } #[test] @@ -330,7 +332,7 @@ mod tests { proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; - let votes = vec![ + proposal.votes = vec![ Vote { voter_id: 1, vote_kind: VoteKind::Approve, @@ -357,7 +359,7 @@ mod tests { finalized_at: 2, }; - proposal.update_tally_results(votes, 5, 2); + proposal.update_tally_results(5, 2); assert_eq!(proposal.tally_results, Some(expected_tally_results)); } @@ -370,7 +372,7 @@ mod tests { proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; - let votes = vec![ + proposal.votes = vec![ Vote { voter_id: 1, vote_kind: VoteKind::Reject, @@ -397,7 +399,7 @@ mod tests { finalized_at: now, }; - proposal.update_tally_results(votes, 4, now); + proposal.update_tally_results(4, now); assert_eq!(proposal.tally_results, Some(expected_tally_results)); } @@ -410,12 +412,12 @@ mod tests { proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; - let votes = vec![Vote { + proposal.votes = vec![Vote { voter_id: 1, vote_kind: VoteKind::Abstain, }]; - proposal.update_tally_results(votes, 5, now); + proposal.update_tally_results(5, now); assert_eq!(proposal.tally_results, None); } } From a856fd206cbbaeb49df11c79f24afbf67c1ffd18 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 14 Feb 2020 15:18:50 +0300 Subject: [PATCH 07/19] Change VoteExistsByProposalByAccount cache - change VoteExistsByProposalByAccount to proposal_id first key - clear cache on proposal finalization --- modules/proposals/engine/src/lib.rs | 26 ++++++++---------- modules/proposals/engine/src/tests/mod.rs | 32 +++++++++++++++++++++-- modules/proposals/engine/src/types.rs | 6 +---- 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index b6b969b90a..de8b43928e 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -111,9 +111,9 @@ decl_storage! { /// Ids of proposals that are open for voting (have not been finalized yet). pub ActiveProposalIds get(fn active_proposal_ids): linked_map T::ProposalId => (); - /// Double map for preventing duplicate votes - VoteExistsByAccountByProposal get(fn vote_by_proposal_by_account): - double_map T::AccountId, twox_256(T::ProposalId) => (); + /// Double map for preventing duplicate votes. Should be cleaned after usage. + pub(crate) VoteExistsByProposalByAccount get(fn vote_by_proposal_by_account): + double_map T::ProposalId, twox_256(T::AccountId) => (); /// Defines max allowed proposal title length. Can be configured. @@ -143,9 +143,9 @@ decl_module! { ensure!(proposal.status == ProposalStatus::Active, errors::MSG_PROPOSAL_FINALIZED); - let did_not_vote_before = !>::exists( + let did_not_vote_before = !>::exists( + proposal_id, voter_id.clone(), - proposal_id ); ensure!(did_not_vote_before, errors::MSG_YOU_ALREADY_VOTED); @@ -160,7 +160,7 @@ decl_module! { // mutation >::insert(proposal_id, proposal); - >::insert(voter_id.clone(), proposal_id, ()); + >::insert( proposal_id, voter_id.clone(), ()); Self::deposit_event(RawEvent::Voted(voter_id, proposal_id, vote)); } @@ -320,8 +320,11 @@ impl Module { /// Updates proposal status and removes proposal id from active id set. fn update_proposal_status(proposal_id: T::ProposalId, new_status: ProposalStatus) { + if new_status != ProposalStatus::Active { + >::remove(&proposal_id); + >::remove_prefix(&proposal_id); + } >::mutate(proposal_id, |p| p.status = new_status.clone()); - >::remove(&proposal_id); Self::deposit_event(RawEvent::ProposalStatusUpdated( proposal_id, @@ -333,14 +336,7 @@ impl Module { Self::reject_proposal(proposal_id) } ProposalStatus::Approved => Self::approve_proposal(proposal_id), - ProposalStatus::Active => { - // restore active proposal id - >::insert(proposal_id, ()); - } - ProposalStatus::Executed - | ProposalStatus::Failed { .. } - | ProposalStatus::Vetoed - | ProposalStatus::Canceled => {} // do nothing + _ => {} // do nothing } } diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index 70c39434c2..a39301da22 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -132,7 +132,7 @@ struct VoteGenerator { proposal_id: u32, current_account_id: u64, pub auto_increment_voter_id: bool, - pub saved_votes: Vec> + pub saved_votes: Vec>, } impl VoteGenerator { @@ -151,7 +151,10 @@ impl VoteGenerator { fn vote_and_assert(&mut self, vote_kind: VoteKind, expected_result: dispatch::Result) { assert_eq!(self.vote(vote_kind.clone()), expected_result); - self.saved_votes.push( Vote{voter_id: self.current_account_id, vote_kind}); + self.saved_votes.push(Vote { + voter_id: self.current_account_id, + vote_kind, + }); } fn vote(&mut self, vote_kind: VoteKind) -> dispatch::Result { @@ -764,3 +767,28 @@ fn create_proposal_and_expire_it() { ) }); } + +#[test] +fn voting_internal_cache_works_and_got_cleaned_successfully() { + initial_test_ext().execute_with(|| { + let dummy_proposal = DummyProposalFixture::default(); + dummy_proposal.create_proposal_and_assert(Ok(())); + + // last created proposal id equals current proposal count + let proposal_id = ::get(); + + let mut vote_generator = VoteGenerator::new(proposal_id); + vote_generator.vote_and_assert_ok(VoteKind::Reject); + vote_generator.vote_and_assert_ok(VoteKind::Reject); + vote_generator.vote_and_assert_ok(VoteKind::Abstain); + vote_generator.vote_and_assert_ok(VoteKind::Abstain); + + // cache exists + assert!(>::exists(proposal_id, 1)); + + run_to_block_and_finalize(2); + + // cache cleared + assert!(!>::exists(proposal_id, 1)); + }); +} \ No newline at end of file diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index f426617a1e..65127aab24 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -131,11 +131,7 @@ impl + PartialOrd + Copy, AccountId> /// Calculates and updates voting results tally for current proposal. /// Parameters: current time, votes, total voters number involved (council size) /// Returns whether tally results are ready. - pub fn update_tally_results( - &mut self, - total_voters_count: u32, - now: BlockNumber, - ) { + pub fn update_tally_results(&mut self, total_voters_count: u32, now: BlockNumber) { let mut abstentions: u32 = 0; let mut approvals: u32 = 0; let mut rejections: u32 = 0; From 484ae584cfc7fe521ed71e59b11d8497b1c70569 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 14 Feb 2020 16:15:31 +0300 Subject: [PATCH 08/19] Refactor tally() method - rename and refactor tally() method in functional style - introduce internal type FinalizedProposalData --- modules/proposals/engine/src/lib.rs | 74 ++++++++++++++--------- modules/proposals/engine/src/tests/mod.rs | 12 +++- modules/proposals/engine/src/types.rs | 12 ++++ 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index de8b43928e..dff8cba91c 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -16,6 +16,7 @@ // Do not delete! Cannot be uncommented by default, because of Parity decl_module! issue. //#![warn(missing_docs)] +use types::FinalizedProposalData; pub use types::TallyResult; pub use types::{Proposal, ProposalParameters, ProposalStatus}; pub use types::{ProposalCodeDecoder, ProposalExecutable}; @@ -34,7 +35,9 @@ use srml_support::{ }; use system::ensure_root; +// Max allowed proposal title length. Can be used if config value is not filled. const DEFAULT_TITLE_MAX_LEN: u32 = 100; +// Max allowed proposal body length. Can be used if config value is not filled. const DEFAULT_BODY_MAX_LEN: u32 = 10_000; /// Proposals engine trait. @@ -197,12 +200,12 @@ decl_module! { /// Block finalization. Perform voting period check and vote result tally. fn on_finalize(_n: T::BlockNumber) { - let proposals_with_ready_result = Self::tally(); + let finalized_proposals_data = Self::get_finalized_proposals_data(); // mutation - for (proposal_id, proposal, new_status) in proposals_with_ready_result { - >::insert(proposal_id, proposal); - Self::update_proposal_status(proposal_id, new_status); + for proposal_data in finalized_proposals_data { + >::insert(proposal_data.proposal_id, proposal_data.proposal); + Self::update_proposal_status(proposal_data.proposal_id, proposal_data.status); } } } @@ -293,31 +296,46 @@ impl Module { Self::update_proposal_status(proposal_id, new_proposal_status) } - // TODO convert to map-filter style - /// Voting results tally. - /// Returns proposals with changed status and tally results - fn tally() -> Vec<( - T::ProposalId, - Proposal, - ProposalStatus, - )> { - let mut results = Vec::new(); - for (proposal_id, _) in >::enumerate() { - let mut proposal = Self::proposals(proposal_id); - - proposal.update_tally_results( - T::TotalVotersCounter::total_voters_count(), - Self::current_block(), - ); - - if let Some(tally_results) = proposal.tally_results.clone() { - results.push((proposal_id, proposal, tally_results.status)); - } - } - - results + /// Enumerates through active proposals. Tally Voting results. + /// Returns proposals with changed status, id and calculated tally results + fn get_finalized_proposals_data( + ) -> Vec> { + // enumerate active proposals id and gather finalization data + >::enumerate() + .map(|(proposal_id, _)| { + // load current proposal + let mut proposal = Self::proposals(proposal_id); + + // calculates voting results + proposal.update_tally_results( + T::TotalVotersCounter::total_voters_count(), + Self::current_block(), + ); + + // get new status from tally results + let mut new_status = ProposalStatus::Active; + if let Some(tally_results) = proposal.tally_results.clone() { + new_status = tally_results.status; + } + // proposal is finalized if not active + let finalized = new_status != ProposalStatus::Active; + + ( + FinalizedProposalData { + proposal_id, + proposal, + status: new_status, + }, + finalized, + ) + }) + .filter(|(_, finalized)| *finalized) // filter only finalized proposals + .map(|(data, _)| data) // get rid of used 'finalized' flag + .collect() // compose output vector } + // TODO: to be refactored or removed after introducing stakes. Events should be fired on actions + // such as 'rejected' or 'approved'. /// Updates proposal status and removes proposal id from active id set. fn update_proposal_status(proposal_id: T::ProposalId, new_status: ProposalStatus) { if new_status != ProposalStatus::Active { @@ -336,7 +354,7 @@ impl Module { Self::reject_proposal(proposal_id) } ProposalStatus::Approved => Self::approve_proposal(proposal_id), - _ => {} // do nothing + _ => {} // do nothing } } diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index a39301da22..8c2a99017e 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -784,11 +784,17 @@ fn voting_internal_cache_works_and_got_cleaned_successfully() { vote_generator.vote_and_assert_ok(VoteKind::Abstain); // cache exists - assert!(>::exists(proposal_id, 1)); + assert!(>::exists( + proposal_id, + 1 + )); run_to_block_and_finalize(2); // cache cleared - assert!(!>::exists(proposal_id, 1)); + assert!(!>::exists( + proposal_id, + 1 + )); }); -} \ No newline at end of file +} diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 65127aab24..b9a473f568 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -263,6 +263,18 @@ pub trait ProposalCodeDecoder { ) -> Result, &'static str>; } +/// Data container for the finalized proposal results +pub(crate) struct FinalizedProposalData { + /// Proposal id + pub proposal_id: ProposalId, + + /// Proposal to be finalized + pub proposal: Proposal, + + /// Proposal finalization status + pub status: ProposalStatus, +} + #[cfg(test)] mod tests { use crate::*; From 1cea688324d7e7e4126fe15fa3931763b462bce2 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 14 Feb 2020 16:36:08 +0300 Subject: [PATCH 09/19] Codex module build fix --- modules/proposals/engine/src/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index b9a473f568..c860e19305 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -189,8 +189,8 @@ pub struct Vote { } /// Tally result for the proposal -#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] -#[derive(Encode, Decode, Default, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] pub struct TallyResult { /// 'Abstention' votes count pub abstentions: u32, From f5857b3d9350af6b8d36e8d873c2f7a5dbea71d8 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 14 Feb 2020 16:57:57 +0300 Subject: [PATCH 10/19] Introduce proposer_id instead of account_id --- modules/proposals/codex/src/tests/mock.rs | 2 ++ modules/proposals/engine/src/lib.rs | 22 ++++++++----- modules/proposals/engine/src/tests/mock.rs | 2 ++ modules/proposals/engine/src/tests/mod.rs | 2 +- modules/proposals/engine/src/types.rs | 36 +++++++++++++--------- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/modules/proposals/codex/src/tests/mock.rs b/modules/proposals/codex/src/tests/mock.rs index dc72ab1d9e..5f1f9eb113 100644 --- a/modules/proposals/codex/src/tests/mock.rs +++ b/modules/proposals/codex/src/tests/mock.rs @@ -47,6 +47,8 @@ impl proposal_engine::Trait for Test { type ProposalCodeDecoder = crate::ProposalType; type ProposalId = u32; + + type ProposerId = u64; } pub struct MockVotersParameters; diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index dff8cba91c..305468e681 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -59,25 +59,29 @@ pub trait Trait: system::Trait + timestamp::Trait { /// Proposal Id type type ProposalId: From + Parameter + Default + Copy; + + /// Type for the proposer id. Should be authenticated by account id. + type ProposerId: From + Parameter + Default; } decl_event!( pub enum Event where ::AccountId, - ::ProposalId + ::ProposalId, + ::ProposerId, { /// Emits on proposal creation. /// Params: /// * Account id of a proposer. /// * Id of a newly created proposal after it was saved in storage. - ProposalCreated(AccountId, ProposalId), + ProposalCreated(ProposerId, ProposalId), /// Emits on proposal cancellation. /// Params: /// * Account id of a proposer. /// * Id of a cancelled proposal. - ProposalCanceled(AccountId, ProposalId), + ProposalCanceled(ProposerId, ProposalId), /// Emits on proposal veto. /// Params: @@ -103,7 +107,8 @@ decl_event!( decl_storage! { trait Store for Module as ProposalsEngine{ /// Map proposal by its id. - pub Proposals get(fn proposals): map T::ProposalId => Proposal; + pub Proposals get(fn proposals): map T::ProposalId => + Proposal; /// Count of all proposals that have been created. pub ProposalCount get(fn proposal_count): u32; @@ -169,7 +174,8 @@ decl_module! { /// Cancel a proposal by its original proposer. pub fn cancel_proposal(origin, proposal_id: T::ProposalId) { - let proposer_id = T::ProposalOrigin::ensure_origin(origin)?; + let account_id = T::ProposalOrigin::ensure_origin(origin)?; + let proposer_id = T::ProposerId::from(account_id); ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); let proposal = Self::proposals(proposal_id); @@ -221,7 +227,8 @@ impl Module { proposal_type: u32, proposal_code: Vec, ) -> dispatch::Result { - let proposer_id = T::ProposalOrigin::ensure_origin(origin)?; + let account_id = T::ProposalOrigin::ensure_origin(origin)?; + let proposer_id = T::ProposerId::from(account_id); ensure!(!title.is_empty(), errors::MSG_EMPTY_TITLE_PROVIDED); ensure!( @@ -299,7 +306,8 @@ impl Module { /// Enumerates through active proposals. Tally Voting results. /// Returns proposals with changed status, id and calculated tally results fn get_finalized_proposals_data( - ) -> Vec> { + ) -> Vec> + { // enumerate active proposals id and gather finalization data >::enumerate() .map(|(proposal_id, _)| { diff --git a/modules/proposals/engine/src/tests/mock.rs b/modules/proposals/engine/src/tests/mock.rs index a39ad3ff8f..2fbf601e63 100644 --- a/modules/proposals/engine/src/tests/mock.rs +++ b/modules/proposals/engine/src/tests/mock.rs @@ -56,6 +56,8 @@ impl crate::Trait for Test { type ProposalCodeDecoder = ProposalType; type ProposalId = u32; + + type ProposerId = u64; } impl VotersParameters for () { diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index 8c2a99017e..ff3582b30e 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -172,7 +172,7 @@ impl VoteGenerator { struct EventFixture; impl EventFixture { - fn assert_events(expected_raw_events: Vec>) { + fn assert_events(expected_raw_events: Vec>) { let expected_events = expected_raw_events .iter() .map(|ev| EventRecord { diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index c860e19305..cfca9b4631 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -89,7 +89,7 @@ pub struct ProposalParameters { /// 'Proposal' contains information necessary for the proposal system functioning. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] -pub struct Proposal { +pub struct Proposal { /// Proposal type id pub proposal_type: u32, @@ -97,7 +97,7 @@ pub struct Proposal { pub parameters: ProposalParameters, /// Identifier of member proposing. - pub proposer_id: AccountId, + pub proposer_id: ProposerId, /// Proposal title pub title: Vec, @@ -120,8 +120,9 @@ pub struct Proposal { pub votes: Vec>, } -impl + PartialOrd + Copy, AccountId> - Proposal +impl Proposal +where + BlockNumber: Add + PartialOrd + Copy, { /// Returns whether voting period expired by now pub fn is_voting_period_expired(&self, now: BlockNumber) -> bool { @@ -215,15 +216,16 @@ pub trait VotersParameters { } // Calculates quorum, votes threshold, expiration status -struct ProposalStatusDecision<'a, BlockNumber, AccountId> { - proposal: &'a Proposal, +struct ProposalStatusDecision<'a, BlockNumber, AccountId, ProposerId> { + proposal: &'a Proposal, now: BlockNumber, votes_count: u32, total_voters_count: u32, approvals: u32, } -impl<'a, BlockNumber, AccountId> ProposalStatusDecision<'a, BlockNumber, AccountId> +impl<'a, BlockNumber, AccountId, ProposerId> + ProposalStatusDecision<'a, BlockNumber, AccountId, ProposerId> where BlockNumber: Add + PartialOrd + Copy, { @@ -264,24 +266,28 @@ pub trait ProposalCodeDecoder { } /// Data container for the finalized proposal results -pub(crate) struct FinalizedProposalData { +pub(crate) struct FinalizedProposalData { /// Proposal id pub proposal_id: ProposalId, /// Proposal to be finalized - pub proposal: Proposal, + pub proposal: Proposal, /// Proposal finalization status pub status: ProposalStatus, } +//pub trait Proposer { +// ensure_origin(T::) +//} + #[cfg(test)] mod tests { use crate::*; #[test] fn proposal_voting_period_expired() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); proposal.created = 1; proposal.parameters.voting_period = 3; @@ -291,7 +297,7 @@ mod tests { #[test] fn proposal_voting_period_not_expired() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); proposal.created = 1; proposal.parameters.voting_period = 3; @@ -301,7 +307,7 @@ mod tests { #[test] fn tally_results_proposal_expired() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); let now = 5; proposal.created = 1; proposal.parameters.voting_period = 3; @@ -335,7 +341,7 @@ mod tests { } #[test] fn tally_results_proposal_approved() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); proposal.created = 1; proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; @@ -373,7 +379,7 @@ mod tests { #[test] fn tally_results_proposal_rejected() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); let now = 2; proposal.created = 1; @@ -413,7 +419,7 @@ mod tests { #[test] fn tally_results_are_empty_with_not_expired_voting_period() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); let now = 2; proposal.created = 1; From 3b79fae2e2c7184c23b894cb06c8c208fcd63b7d Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 14 Feb 2020 17:09:32 +0300 Subject: [PATCH 11/19] Introduce VoterId type instead of AccountId for voting --- modules/proposals/codex/src/tests/mock.rs | 2 ++ modules/proposals/engine/src/lib.rs | 25 ++++++++++++---------- modules/proposals/engine/src/tests/mock.rs | 2 ++ modules/proposals/engine/src/tests/mod.rs | 6 +++--- modules/proposals/engine/src/types.rs | 25 ++++++++++------------ 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/modules/proposals/codex/src/tests/mock.rs b/modules/proposals/codex/src/tests/mock.rs index 5f1f9eb113..9b8142a463 100644 --- a/modules/proposals/codex/src/tests/mock.rs +++ b/modules/proposals/codex/src/tests/mock.rs @@ -49,6 +49,8 @@ impl proposal_engine::Trait for Test { type ProposalId = u32; type ProposerId = u64; + + type VoterId = u64; } pub struct MockVotersParameters; diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 305468e681..aa58375cf1 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -62,14 +62,17 @@ pub trait Trait: system::Trait + timestamp::Trait { /// Type for the proposer id. Should be authenticated by account id. type ProposerId: From + Parameter + Default; + + /// Type for the voter id. Should be authenticated by account id. + type VoterId: From + Parameter + Default + Clone; } decl_event!( pub enum Event where - ::AccountId, ::ProposalId, ::ProposerId, + ::VoterId, { /// Emits on proposal creation. /// Params: @@ -99,7 +102,7 @@ decl_event!( /// * Voter - an account id of a voter. /// * Id of a proposal. /// * Kind of vote. - Voted(AccountId, ProposalId, VoteKind), + Voted(VoterId, ProposalId, VoteKind), } ); @@ -108,7 +111,7 @@ decl_storage! { trait Store for Module as ProposalsEngine{ /// Map proposal by its id. pub Proposals get(fn proposals): map T::ProposalId => - Proposal; + Proposal; /// Count of all proposals that have been created. pub ProposalCount get(fn proposal_count): u32; @@ -120,9 +123,8 @@ decl_storage! { pub ActiveProposalIds get(fn active_proposal_ids): linked_map T::ProposalId => (); /// Double map for preventing duplicate votes. Should be cleaned after usage. - pub(crate) VoteExistsByProposalByAccount get(fn vote_by_proposal_by_account): - double_map T::ProposalId, twox_256(T::AccountId) => (); - + pub(crate) VoteExistsByProposalByVoter get(fn vote_by_proposal_by_voter): + double_map T::ProposalId, twox_256(T::VoterId) => (); /// Defines max allowed proposal title length. Can be configured. TitleMaxLen get(title_max_len) config(): u32 = DEFAULT_TITLE_MAX_LEN; @@ -141,7 +143,8 @@ decl_module! { /// Vote extrinsic. Conditions: origin must allow votes. pub fn vote(origin, proposal_id: T::ProposalId, vote: VoteKind) { - let voter_id = T::VoteOrigin::ensure_origin(origin)?; + let account_id = T::VoteOrigin::ensure_origin(origin)?; + let voter_id = T::VoterId::from(account_id); ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); let mut proposal = Self::proposals(proposal_id); @@ -151,7 +154,7 @@ decl_module! { ensure!(proposal.status == ProposalStatus::Active, errors::MSG_PROPOSAL_FINALIZED); - let did_not_vote_before = !>::exists( + let did_not_vote_before = !>::exists( proposal_id, voter_id.clone(), ); @@ -168,7 +171,7 @@ decl_module! { // mutation >::insert(proposal_id, proposal); - >::insert( proposal_id, voter_id.clone(), ()); + >::insert( proposal_id, voter_id.clone(), ()); Self::deposit_event(RawEvent::Voted(voter_id, proposal_id, vote)); } @@ -306,7 +309,7 @@ impl Module { /// Enumerates through active proposals. Tally Voting results. /// Returns proposals with changed status, id and calculated tally results fn get_finalized_proposals_data( - ) -> Vec> + ) -> Vec> { // enumerate active proposals id and gather finalization data >::enumerate() @@ -348,7 +351,7 @@ impl Module { fn update_proposal_status(proposal_id: T::ProposalId, new_status: ProposalStatus) { if new_status != ProposalStatus::Active { >::remove(&proposal_id); - >::remove_prefix(&proposal_id); + >::remove_prefix(&proposal_id); } >::mutate(proposal_id, |p| p.status = new_status.clone()); diff --git a/modules/proposals/engine/src/tests/mock.rs b/modules/proposals/engine/src/tests/mock.rs index 2fbf601e63..b27310c727 100644 --- a/modules/proposals/engine/src/tests/mock.rs +++ b/modules/proposals/engine/src/tests/mock.rs @@ -58,6 +58,8 @@ impl crate::Trait for Test { type ProposalId = u32; type ProposerId = u64; + + type VoterId = u64; } impl VotersParameters for () { diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index ff3582b30e..38831a1b94 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -172,7 +172,7 @@ impl VoteGenerator { struct EventFixture; impl EventFixture { - fn assert_events(expected_raw_events: Vec>) { + fn assert_events(expected_raw_events: Vec>) { let expected_events = expected_raw_events .iter() .map(|ev| EventRecord { @@ -784,7 +784,7 @@ fn voting_internal_cache_works_and_got_cleaned_successfully() { vote_generator.vote_and_assert_ok(VoteKind::Abstain); // cache exists - assert!(>::exists( + assert!(>::exists( proposal_id, 1 )); @@ -792,7 +792,7 @@ fn voting_internal_cache_works_and_got_cleaned_successfully() { run_to_block_and_finalize(2); // cache cleared - assert!(!>::exists( + assert!(!>::exists( proposal_id, 1 )); diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index cfca9b4631..9db9c8210a 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -89,7 +89,7 @@ pub struct ProposalParameters { /// 'Proposal' contains information necessary for the proposal system functioning. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] -pub struct Proposal { +pub struct Proposal { /// Proposal type id pub proposal_type: u32, @@ -117,10 +117,10 @@ pub struct Proposal { pub tally_results: Option>, /// Votes for the proposal - pub votes: Vec>, + pub votes: Vec>, } -impl Proposal +impl Proposal where BlockNumber: Add + PartialOrd + Copy, { @@ -181,9 +181,9 @@ where /// Vote. Characterized by voter and vote kind. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] -pub struct Vote { +pub struct Vote { /// Origin of the vote - pub voter_id: AccountId, + pub voter_id: VoterId, /// Vote kind pub vote_kind: VoteKind, @@ -216,16 +216,16 @@ pub trait VotersParameters { } // Calculates quorum, votes threshold, expiration status -struct ProposalStatusDecision<'a, BlockNumber, AccountId, ProposerId> { - proposal: &'a Proposal, +struct ProposalStatusDecision<'a, BlockNumber, VoterId, ProposerId> { + proposal: &'a Proposal, now: BlockNumber, votes_count: u32, total_voters_count: u32, approvals: u32, } -impl<'a, BlockNumber, AccountId, ProposerId> - ProposalStatusDecision<'a, BlockNumber, AccountId, ProposerId> +impl<'a, BlockNumber, VoterId, ProposerId> + ProposalStatusDecision<'a, BlockNumber, VoterId, ProposerId> where BlockNumber: Add + PartialOrd + Copy, { @@ -266,20 +266,17 @@ pub trait ProposalCodeDecoder { } /// Data container for the finalized proposal results -pub(crate) struct FinalizedProposalData { +pub(crate) struct FinalizedProposalData { /// Proposal id pub proposal_id: ProposalId, /// Proposal to be finalized - pub proposal: Proposal, + pub proposal: Proposal, /// Proposal finalization status pub status: ProposalStatus, } -//pub trait Proposer { -// ensure_origin(T::) -//} #[cfg(test)] mod tests { From cc81780fcbbb97ab19919dd90d1dfebbe833cbff Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 14 Feb 2020 17:49:44 +0300 Subject: [PATCH 12/19] Add TODO: add maximum allowed active proposals --- modules/proposals/engine/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index aa58375cf1..578c041567 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -35,6 +35,8 @@ use srml_support::{ }; use system::ensure_root; +// TODO: add maximum allowed active proposals + // Max allowed proposal title length. Can be used if config value is not filled. const DEFAULT_TITLE_MAX_LEN: u32 = 100; // Max allowed proposal body length. Can be used if config value is not filled. From def6faf1f4dc973226eb7c6016a796361b0fe206 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 17 Feb 2020 12:13:35 +0300 Subject: [PATCH 13/19] Remove redundant check on voting --- modules/proposals/engine/src/errors.rs | 1 - modules/proposals/engine/src/lib.rs | 3 --- modules/proposals/engine/src/tests/mod.rs | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/proposals/engine/src/errors.rs b/modules/proposals/engine/src/errors.rs index 602e6ddf98..d4ebd3e44f 100644 --- a/modules/proposals/engine/src/errors.rs +++ b/modules/proposals/engine/src/errors.rs @@ -3,7 +3,6 @@ pub const MSG_EMPTY_BODY_PROVIDED: &str = "Proposal cannot have an empty body"; pub const MSG_TOO_LONG_TITLE: &str = "Title is too long"; pub const MSG_TOO_LONG_BODY: &str = "Body is too long"; pub const MSG_PROPOSAL_NOT_FOUND: &str = "This proposal does not exist"; -pub const MSG_PROPOSAL_EXPIRED: &str = "Voting period is expired for this proposal"; pub const MSG_PROPOSAL_FINALIZED: &str = "Proposal is finalized already"; pub const MSG_YOU_ALREADY_VOTED: &str = "You have already voted on this proposal"; pub const MSG_YOU_DONT_OWN_THIS_PROPOSAL: &str = "You do not own this proposal"; diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 578c041567..afd6df76f8 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -151,9 +151,6 @@ decl_module! { ensure!(>::exists(proposal_id), errors::MSG_PROPOSAL_NOT_FOUND); let mut proposal = Self::proposals(proposal_id); - let not_expired = !proposal.is_voting_period_expired(Self::current_block()); - ensure!(not_expired, errors::MSG_PROPOSAL_EXPIRED); - ensure!(proposal.status == ProposalStatus::Active, errors::MSG_PROPOSAL_FINALIZED); let did_not_vote_before = !>::exists( diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index 38831a1b94..0e017503c0 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -456,7 +456,7 @@ fn vote_fails_with_expired_voting_period() { let mut vote_generator = VoteGenerator::new(proposal_id); vote_generator.vote_and_assert( VoteKind::Approve, - Err("Voting period is expired for this proposal"), + Err("Proposal is finalized already"), ); }); } From 753fff5bcb4619115fd0f591a570647c16a6383a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 17 Feb 2020 14:08:46 +0300 Subject: [PATCH 14/19] Add VotingResults type Migrating from TallyResults and vote calculation in the end of block to vote calculation on the vote() extrinsic call. --- modules/proposals/engine/src/lib.rs | 11 +++-- modules/proposals/engine/src/tests/mod.rs | 22 +++++++-- modules/proposals/engine/src/types.rs | 59 ++++++++++++++++------- 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index afd6df76f8..a9bbac137e 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -17,9 +17,9 @@ //#![warn(missing_docs)] use types::FinalizedProposalData; -pub use types::TallyResult; pub use types::{Proposal, ProposalParameters, ProposalStatus}; pub use types::{ProposalCodeDecoder, ProposalExecutable}; +pub use types::{TallyResult, VotingResults}; pub use types::{Vote, VoteKind, VotersParameters}; mod errors; @@ -126,7 +126,7 @@ decl_storage! { /// Double map for preventing duplicate votes. Should be cleaned after usage. pub(crate) VoteExistsByProposalByVoter get(fn vote_by_proposal_by_voter): - double_map T::ProposalId, twox_256(T::VoterId) => (); + double_map T::ProposalId, twox_256(T::VoterId) => VoteKind; /// Defines max allowed proposal title length. Can be configured. TitleMaxLen get(title_max_len) config(): u32 = DEFAULT_TITLE_MAX_LEN; @@ -166,11 +166,12 @@ decl_module! { }; proposal.votes.push(new_vote); + proposal.voting_results.add_vote(vote.clone()); // mutation >::insert(proposal_id, proposal); - >::insert( proposal_id, voter_id.clone(), ()); + >::insert( proposal_id, voter_id.clone(), vote.clone()); Self::deposit_event(RawEvent::Voted(voter_id, proposal_id, vote)); } @@ -257,6 +258,7 @@ impl Module { status: ProposalStatus::Active, tally_results: None, votes: Vec::new(), + voting_results: VotingResults::default(), }; // mutation @@ -308,8 +310,7 @@ impl Module { /// Enumerates through active proposals. Tally Voting results. /// Returns proposals with changed status, id and calculated tally results fn get_finalized_proposals_data( - ) -> Vec> - { + ) -> Vec> { // enumerate active proposals id and gather finalization data >::enumerate() .map(|(proposal_id, _)| { diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index 0e017503c0..192ae7ba69 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -286,6 +286,11 @@ fn proposal_execution_succeeds() { status: ProposalStatus::Approved, finalized_at: 1 }), + voting_results : VotingResults { + abstentions: 0, + approvals: 4, + rejections: 0, + }, votes: vote_generator.saved_votes, } ) @@ -341,6 +346,11 @@ fn proposal_execution_failed() { finalized_at: 1 }), votes: vote_generator.saved_votes, + voting_results : VotingResults { + abstentions: 0, + approvals: 4, + rejections: 0, + }, } ) }); @@ -454,10 +464,7 @@ fn vote_fails_with_expired_voting_period() { run_to_block_and_finalize(6); let mut vote_generator = VoteGenerator::new(proposal_id); - vote_generator.vote_and_assert( - VoteKind::Approve, - Err("Proposal is finalized already"), - ); + vote_generator.vote_and_assert(VoteKind::Approve, Err("Proposal is finalized already")); }); } @@ -542,6 +549,7 @@ fn cancel_proposal_succeeds() { body: b"body".to_vec(), tally_results: None, votes: Vec::new(), + voting_results : VotingResults::default(), } ) }); @@ -616,6 +624,7 @@ fn veto_proposal_succeeds() { body: b"body".to_vec(), tally_results: None, votes: Vec::new(), + voting_results : VotingResults::default(), } ) }); @@ -762,6 +771,11 @@ fn create_proposal_and_expire_it() { status: ProposalStatus::Expired, finalized_at: 4 }), + voting_results : VotingResults { + abstentions: 0, + approvals: 0, + rejections: 0, + }, votes: Vec::new(), } ) diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 9db9c8210a..90c26813e4 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -86,6 +86,24 @@ pub struct ProposalParameters { //pub stake: BalanceOf, // } +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] +pub struct VotingResults { + pub abstentions: u32, + pub approvals: u32, + pub rejections: u32, +} + +impl VotingResults { + pub fn add_vote(&mut self, vote: VoteKind) { + match vote { + VoteKind::Abstain => self.abstentions += 1, + VoteKind::Approve => self.approvals += 1, + VoteKind::Reject => self.rejections += 1, + } + } +} + /// 'Proposal' contains information necessary for the proposal system functioning. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] @@ -118,6 +136,8 @@ pub struct Proposal { /// Votes for the proposal pub votes: Vec>, + + pub voting_results: VotingResults, } impl Proposal @@ -133,21 +153,9 @@ where /// Parameters: current time, votes, total voters number involved (council size) /// Returns whether tally results are ready. pub fn update_tally_results(&mut self, total_voters_count: u32, now: BlockNumber) { - let mut abstentions: u32 = 0; - let mut approvals: u32 = 0; - let mut rejections: u32 = 0; - - for vote in self.votes.iter() { - match vote.vote_kind { - VoteKind::Abstain => abstentions += 1, - VoteKind::Approve => approvals += 1, - VoteKind::Reject => rejections += 1, - } - } - let proposal_status_decision = ProposalStatusDecision { proposal: self, - approvals, + approvals: self.voting_results.approvals, now, votes_count: self.votes.len() as u32, total_voters_count, @@ -166,9 +174,9 @@ where self.tally_results = if let Some(status) = new_status { Some(TallyResult { - abstentions, - approvals, - rejections, + abstentions: self.voting_results.abstentions, + approvals: self.voting_results.approvals, + rejections: self.voting_results.rejections, status, finalized_at: now, }) @@ -277,7 +285,6 @@ pub(crate) struct FinalizedProposalData Date: Mon, 17 Feb 2020 14:24:34 +0300 Subject: [PATCH 15/19] Remove votes from the Proposal --- modules/proposals/engine/src/lib.rs | 11 +-- modules/proposals/engine/src/tests/mod.rs | 15 ++-- modules/proposals/engine/src/types.rs | 102 +++++++--------------- 3 files changed, 37 insertions(+), 91 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index a9bbac137e..3d82d8149a 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -113,7 +113,7 @@ decl_storage! { trait Store for Module as ProposalsEngine{ /// Map proposal by its id. pub Proposals get(fn proposals): map T::ProposalId => - Proposal; + Proposal; /// Count of all proposals that have been created. pub ProposalCount get(fn proposal_count): u32; @@ -160,12 +160,6 @@ decl_module! { ensure!(did_not_vote_before, errors::MSG_YOU_ALREADY_VOTED); - let new_vote = Vote { - voter_id: voter_id.clone(), - vote_kind: vote.clone(), - }; - - proposal.votes.push(new_vote); proposal.voting_results.add_vote(vote.clone()); // mutation @@ -257,7 +251,6 @@ impl Module { proposal_type, status: ProposalStatus::Active, tally_results: None, - votes: Vec::new(), voting_results: VotingResults::default(), }; @@ -310,7 +303,7 @@ impl Module { /// Enumerates through active proposals. Tally Voting results. /// Returns proposals with changed status, id and calculated tally results fn get_finalized_proposals_data( - ) -> Vec> { + ) -> Vec> { // enumerate active proposals id and gather finalization data >::enumerate() .map(|(proposal_id, _)| { diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index 192ae7ba69..3688b4dbd9 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -286,12 +286,11 @@ fn proposal_execution_succeeds() { status: ProposalStatus::Approved, finalized_at: 1 }), - voting_results : VotingResults { + voting_results: VotingResults { abstentions: 0, approvals: 4, rejections: 0, }, - votes: vote_generator.saved_votes, } ) }); @@ -345,8 +344,7 @@ fn proposal_execution_failed() { status: ProposalStatus::Approved, finalized_at: 1 }), - votes: vote_generator.saved_votes, - voting_results : VotingResults { + voting_results: VotingResults { abstentions: 0, approvals: 4, rejections: 0, @@ -548,8 +546,7 @@ fn cancel_proposal_succeeds() { title: b"title".to_vec(), body: b"body".to_vec(), tally_results: None, - votes: Vec::new(), - voting_results : VotingResults::default(), + voting_results: VotingResults::default(), } ) }); @@ -623,8 +620,7 @@ fn veto_proposal_succeeds() { title: b"title".to_vec(), body: b"body".to_vec(), tally_results: None, - votes: Vec::new(), - voting_results : VotingResults::default(), + voting_results: VotingResults::default(), } ) }); @@ -771,12 +767,11 @@ fn create_proposal_and_expire_it() { status: ProposalStatus::Expired, finalized_at: 4 }), - voting_results : VotingResults { + voting_results: VotingResults { abstentions: 0, approvals: 0, rejections: 0, }, - votes: Vec::new(), } ) }); diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 90c26813e4..8fc48d45da 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -102,12 +102,16 @@ impl VotingResults { VoteKind::Reject => self.rejections += 1, } } + + pub fn votes_number(&self) -> u32 { + self.abstentions + self.approvals + self.rejections + } } /// 'Proposal' contains information necessary for the proposal system functioning. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] -pub struct Proposal { +pub struct Proposal { /// Proposal type id pub proposal_type: u32, @@ -134,13 +138,10 @@ pub struct Proposal { /// Tally result for the proposal pub tally_results: Option>, - /// Votes for the proposal - pub votes: Vec>, - pub voting_results: VotingResults, } -impl Proposal +impl Proposal where BlockNumber: Add + PartialOrd + Copy, { @@ -157,7 +158,7 @@ where proposal: self, approvals: self.voting_results.approvals, now, - votes_count: self.votes.len() as u32, + votes_count: self.voting_results.votes_number(), total_voters_count, }; @@ -224,16 +225,15 @@ pub trait VotersParameters { } // Calculates quorum, votes threshold, expiration status -struct ProposalStatusDecision<'a, BlockNumber, VoterId, ProposerId> { - proposal: &'a Proposal, +struct ProposalStatusDecision<'a, BlockNumber, ProposerId> { + proposal: &'a Proposal, now: BlockNumber, votes_count: u32, total_voters_count: u32, approvals: u32, } -impl<'a, BlockNumber, VoterId, ProposerId> - ProposalStatusDecision<'a, BlockNumber, VoterId, ProposerId> +impl<'a, BlockNumber, ProposerId> ProposalStatusDecision<'a, BlockNumber, ProposerId> where BlockNumber: Add + PartialOrd + Copy, { @@ -274,12 +274,12 @@ pub trait ProposalCodeDecoder { } /// Data container for the finalized proposal results -pub(crate) struct FinalizedProposalData { +pub(crate) struct FinalizedProposalData { /// Proposal id pub proposal_id: ProposalId, /// Proposal to be finalized - pub proposal: Proposal, + pub proposal: Proposal, /// Proposal finalization status pub status: ProposalStatus, @@ -291,7 +291,7 @@ mod tests { #[test] fn proposal_voting_period_expired() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); proposal.created = 1; proposal.parameters.voting_period = 3; @@ -301,7 +301,7 @@ mod tests { #[test] fn proposal_voting_period_not_expired() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); proposal.created = 1; proposal.parameters.voting_period = 3; @@ -311,26 +311,15 @@ mod tests { #[test] fn tally_results_proposal_expired() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); let now = 5; proposal.created = 1; proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; - proposal.votes = vec![ - Vote { - voter_id: 1, - vote_kind: VoteKind::Approve, - }, - Vote { - voter_id: 2, - vote_kind: VoteKind::Approve, - }, - Vote { - voter_id: 4, - vote_kind: VoteKind::Reject, - }, - ]; + proposal.voting_results.add_vote(VoteKind::Reject); + proposal.voting_results.add_vote(VoteKind::Approve); + proposal.voting_results.add_vote(VoteKind::Approve); proposal.voting_results = VotingResults { abstentions: 0, @@ -351,29 +340,15 @@ mod tests { } #[test] fn tally_results_proposal_approved() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); proposal.created = 1; proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; - proposal.votes = vec![ - Vote { - voter_id: 1, - vote_kind: VoteKind::Approve, - }, - Vote { - voter_id: 2, - vote_kind: VoteKind::Approve, - }, - Vote { - voter_id: 3, - vote_kind: VoteKind::Approve, - }, - Vote { - voter_id: 4, - vote_kind: VoteKind::Reject, - }, - ]; + proposal.voting_results.add_vote(VoteKind::Reject); + proposal.voting_results.add_vote(VoteKind::Approve); + proposal.voting_results.add_vote(VoteKind::Approve); + proposal.voting_results.add_vote(VoteKind::Approve); proposal.voting_results = VotingResults { abstentions: 0, @@ -395,31 +370,17 @@ mod tests { #[test] fn tally_results_proposal_rejected() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); let now = 2; proposal.created = 1; proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; - proposal.votes = vec![ - Vote { - voter_id: 1, - vote_kind: VoteKind::Reject, - }, - Vote { - voter_id: 2, - vote_kind: VoteKind::Reject, - }, - Vote { - voter_id: 3, - vote_kind: VoteKind::Abstain, - }, - Vote { - voter_id: 4, - vote_kind: VoteKind::Approve, - }, - ]; + proposal.voting_results.add_vote(VoteKind::Reject); + proposal.voting_results.add_vote(VoteKind::Reject); + proposal.voting_results.add_vote(VoteKind::Abstain); + proposal.voting_results.add_vote(VoteKind::Approve); proposal.voting_results = VotingResults { abstentions: 1, @@ -441,17 +402,14 @@ mod tests { #[test] fn tally_results_are_empty_with_not_expired_voting_period() { - let mut proposal = Proposal::::default(); + let mut proposal = Proposal::::default(); let now = 2; proposal.created = 1; proposal.parameters.voting_period = 3; proposal.parameters.approval_quorum_percentage = 60; - proposal.votes = vec![Vote { - voter_id: 1, - vote_kind: VoteKind::Abstain, - }]; + proposal.voting_results.add_vote(VoteKind::Abstain); proposal.update_tally_results(5, now); assert_eq!(proposal.tally_results, None); From bbabc6726ee05fb3aa4b13f0f2997021b0a8f89b Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 17 Feb 2020 14:39:22 +0300 Subject: [PATCH 16/19] Introduce define_proposal_decision_status() Migrating out from TallyResults --- modules/proposals/engine/src/lib.rs | 10 +++++++--- modules/proposals/engine/src/types.rs | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 3d82d8149a..83e5da9aa1 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -316,10 +316,14 @@ impl Module { Self::current_block(), ); - // get new status from tally results + let decision_status = proposal.define_proposal_decision_status( + T::TotalVotersCounter::total_voters_count(), + Self::current_block(), + ); + let mut new_status = ProposalStatus::Active; - if let Some(tally_results) = proposal.tally_results.clone() { - new_status = tally_results.status; + if let Some(status) = decision_status { + new_status = status; } // proposal is finalized if not active let finalized = new_status != ProposalStatus::Active; diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 8fc48d45da..def521ca82 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -185,6 +185,30 @@ where None }; } + + pub fn define_proposal_decision_status( + &self, + total_voters_count: u32, + now: BlockNumber, + ) -> Option { + let proposal_status_decision = ProposalStatusDecision { + proposal: self, + approvals: self.voting_results.approvals, + now, + votes_count: self.voting_results.votes_number(), + total_voters_count, + }; + + if proposal_status_decision.is_approval_quorum_reached() { + Some(ProposalStatus::Approved) + } else if proposal_status_decision.is_expired() { + Some(ProposalStatus::Expired) + } else if proposal_status_decision.is_voting_completed() { + Some(ProposalStatus::Rejected) + } else { + None + } + } } /// Vote. Characterized by voter and vote kind. From b2278bfd35b0f5410c150d4de63d94155b857db8 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 17 Feb 2020 15:24:16 +0300 Subject: [PATCH 17/19] Remove TallyResults and Vote types --- modules/proposals/engine/src/lib.rs | 17 +- modules/proposals/engine/src/tests/mod.rs | 63 +++----- modules/proposals/engine/src/types.rs | 184 +++++++--------------- 3 files changed, 84 insertions(+), 180 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 83e5da9aa1..966db34877 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -17,10 +17,10 @@ //#![warn(missing_docs)] use types::FinalizedProposalData; +pub use types::VotingResults; pub use types::{Proposal, ProposalParameters, ProposalStatus}; pub use types::{ProposalCodeDecoder, ProposalExecutable}; -pub use types::{TallyResult, VotingResults}; -pub use types::{Vote, VoteKind, VotersParameters}; +pub use types::{VoteKind, VotersParameters}; mod errors; mod types; @@ -250,8 +250,8 @@ impl Module { proposer_id: proposer_id.clone(), proposal_type, status: ProposalStatus::Active, - tally_results: None, voting_results: VotingResults::default(), + finalized_at: None, }; // mutation @@ -308,13 +308,7 @@ impl Module { >::enumerate() .map(|(proposal_id, _)| { // load current proposal - let mut proposal = Self::proposals(proposal_id); - - // calculates voting results - proposal.update_tally_results( - T::TotalVotersCounter::total_voters_count(), - Self::current_block(), - ); + let proposal = Self::proposals(proposal_id); let decision_status = proposal.define_proposal_decision_status( T::TotalVotersCounter::total_voters_count(), @@ -333,6 +327,7 @@ impl Module { proposal_id, proposal, status: new_status, + finalized_at: Self::current_block(), }, finalized, ) @@ -342,13 +337,13 @@ impl Module { .collect() // compose output vector } + // TODO: update proposal.finalized_at // TODO: to be refactored or removed after introducing stakes. Events should be fired on actions // such as 'rejected' or 'approved'. /// Updates proposal status and removes proposal id from active id set. fn update_proposal_status(proposal_id: T::ProposalId, new_status: ProposalStatus) { if new_status != ProposalStatus::Active { >::remove(&proposal_id); - >::remove_prefix(&proposal_id); } >::mutate(proposal_id, |p| p.status = new_status.clone()); diff --git a/modules/proposals/engine/src/tests/mod.rs b/modules/proposals/engine/src/tests/mod.rs index 3688b4dbd9..0eabc6fac5 100644 --- a/modules/proposals/engine/src/tests/mod.rs +++ b/modules/proposals/engine/src/tests/mod.rs @@ -132,7 +132,6 @@ struct VoteGenerator { proposal_id: u32, current_account_id: u64, pub auto_increment_voter_id: bool, - pub saved_votes: Vec>, } impl VoteGenerator { @@ -141,7 +140,6 @@ impl VoteGenerator { proposal_id, current_account_id: 0, auto_increment_voter_id: true, - saved_votes: Vec::new(), } } fn vote_and_assert_ok(&mut self, vote_kind: VoteKind) { @@ -150,11 +148,6 @@ impl VoteGenerator { fn vote_and_assert(&mut self, vote_kind: VoteKind, expected_result: dispatch::Result) { assert_eq!(self.vote(vote_kind.clone()), expected_result); - - self.saved_votes.push(Vote { - voter_id: self.current_account_id, - vote_kind, - }); } fn vote(&mut self, vote_kind: VoteKind) -> dispatch::Result { @@ -279,18 +272,12 @@ fn proposal_execution_succeeds() { status: ProposalStatus::Executed, title: b"title".to_vec(), body: b"body".to_vec(), - tally_results: Some(TallyResult { - abstentions: 0, - approvals: 4, - rejections: 0, - status: ProposalStatus::Approved, - finalized_at: 1 - }), voting_results: VotingResults { abstentions: 0, approvals: 4, rejections: 0, }, + finalized_at: None, } ) }); @@ -337,25 +324,19 @@ fn proposal_execution_failed() { }, title: b"title".to_vec(), body: b"body".to_vec(), - tally_results: Some(TallyResult { - abstentions: 0, - approvals: 4, - rejections: 0, - status: ProposalStatus::Approved, - finalized_at: 1 - }), voting_results: VotingResults { abstentions: 0, approvals: 4, rejections: 0, }, + finalized_at: None, } ) }); } #[test] -fn tally_calculation_succeeds() { +fn voting_results_calculation_succeeds() { initial_test_ext().execute_with(|| { let parameters = ProposalParameters { voting_period: 3, @@ -379,20 +360,18 @@ fn tally_calculation_succeeds() { let proposal = >::get(proposals_id); assert_eq!( - proposal.tally_results, - Some(TallyResult { + proposal.voting_results, + VotingResults { abstentions: 1, approvals: 2, rejections: 1, - status: ProposalStatus::Approved, - finalized_at: 1 - }) + } ) }); } #[test] -fn rejected_tally_results_and_remove_proposal_id_from_active_succeeds() { +fn rejected_voting_results_and_remove_proposal_id_from_active_succeeds() { initial_test_ext().execute_with(|| { let dummy_proposal = DummyProposalFixture::default(); dummy_proposal.create_proposal_and_assert(Ok(())); @@ -413,16 +392,16 @@ fn rejected_tally_results_and_remove_proposal_id_from_active_succeeds() { let proposal = >::get(proposal_id); assert_eq!( - proposal.tally_results, - Some(TallyResult { + proposal.voting_results, + VotingResults { abstentions: 2, approvals: 0, rejections: 2, - status: ProposalStatus::Rejected, - finalized_at: 1 - }) + } ); + assert_eq!(proposal.status, ProposalStatus::Rejected,); + assert!(!>::exists(proposal_id)); }); } @@ -545,8 +524,8 @@ fn cancel_proposal_succeeds() { status: ProposalStatus::Canceled, title: b"title".to_vec(), body: b"body".to_vec(), - tally_results: None, voting_results: VotingResults::default(), + finalized_at: None, } ) }); @@ -619,8 +598,8 @@ fn veto_proposal_succeeds() { status: ProposalStatus::Vetoed, title: b"title".to_vec(), body: b"body".to_vec(), - tally_results: None, voting_results: VotingResults::default(), + finalized_at: None, } ) }); @@ -760,25 +739,19 @@ fn create_proposal_and_expire_it() { status: ProposalStatus::Expired, title: b"title".to_vec(), body: b"body".to_vec(), - tally_results: Some(TallyResult { - abstentions: 0, - approvals: 0, - rejections: 0, - status: ProposalStatus::Expired, - finalized_at: 4 - }), voting_results: VotingResults { abstentions: 0, approvals: 0, rejections: 0, }, + finalized_at: None, } ) }); } #[test] -fn voting_internal_cache_works_and_got_cleaned_successfully() { +fn voting_internal_cache_exists_after_proposal_finalization() { initial_test_ext().execute_with(|| { let dummy_proposal = DummyProposalFixture::default(); dummy_proposal.create_proposal_and_assert(Ok(())); @@ -800,8 +773,8 @@ fn voting_internal_cache_works_and_got_cleaned_successfully() { run_to_block_and_finalize(2); - // cache cleared - assert!(!>::exists( + // cache still exists and is not cleared + assert!(>::exists( proposal_id, 1 )); diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index def521ca82..005841f2a7 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -135,10 +135,12 @@ pub struct Proposal { /// Current proposal status pub status: ProposalStatus, - /// Tally result for the proposal - pub tally_results: Option>, - + /// Curring voting result for the proposal pub voting_results: VotingResults, + + // TODO: update proposal.finalized_at + /// Proposal finalization block number + pub finalized_at: Option, } impl Proposal @@ -150,42 +152,9 @@ where now >= self.created + self.parameters.voting_period } - /// Calculates and updates voting results tally for current proposal. - /// Parameters: current time, votes, total voters number involved (council size) - /// Returns whether tally results are ready. - pub fn update_tally_results(&mut self, total_voters_count: u32, now: BlockNumber) { - let proposal_status_decision = ProposalStatusDecision { - proposal: self, - approvals: self.voting_results.approvals, - now, - votes_count: self.voting_results.votes_number(), - total_voters_count, - }; - - let new_status: Option = - if proposal_status_decision.is_approval_quorum_reached() { - Some(ProposalStatus::Approved) - } else if proposal_status_decision.is_expired() { - Some(ProposalStatus::Expired) - } else if proposal_status_decision.is_voting_completed() { - Some(ProposalStatus::Rejected) - } else { - None - }; - - self.tally_results = if let Some(status) = new_status { - Some(TallyResult { - abstentions: self.voting_results.abstentions, - approvals: self.voting_results.approvals, - rejections: self.voting_results.rejections, - status, - finalized_at: now, - }) - } else { - None - }; - } - + /// Determines the finalized proposal status using voting results tally for current proposal. + /// Parameters: current time, total voters number involved (council size) + /// Returns whether the proposal has finalized status pub fn define_proposal_decision_status( &self, total_voters_count: u32, @@ -211,36 +180,6 @@ where } } -/// Vote. Characterized by voter and vote kind. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] -pub struct Vote { - /// Origin of the vote - pub voter_id: VoterId, - - /// Vote kind - pub vote_kind: VoteKind, -} - -/// Tally result for the proposal -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] -pub struct TallyResult { - /// 'Abstention' votes count - pub abstentions: u32, - - /// 'Approve' votes count - pub approvals: u32, - - /// 'Reject' votes count - pub rejections: u32, - - /// Proposal status after tally - pub status: ProposalStatus, - - /// Proposal finalization block number - pub finalized_at: BlockNumber, -} /// Provides data for voting. pub trait VotersParameters { @@ -307,6 +246,9 @@ pub(crate) struct FinalizedProposalData { /// Proposal finalization status pub status: ProposalStatus, + + /// Proposal finalization block number + pub finalized_at: BlockNumber, } #[cfg(test)] @@ -334,7 +276,7 @@ mod tests { } #[test] - fn tally_results_proposal_expired() { + fn define_proposal_decision_status_returns_expired() { let mut proposal = Proposal::::default(); let now = 5; proposal.created = 1; @@ -345,25 +287,21 @@ mod tests { proposal.voting_results.add_vote(VoteKind::Approve); proposal.voting_results.add_vote(VoteKind::Approve); - proposal.voting_results = VotingResults { - abstentions: 0, - approvals: 2, - rejections: 1, - }; - - let expected_tally_results = TallyResult { - abstentions: 0, - approvals: 2, - rejections: 1, - status: ProposalStatus::Expired, - finalized_at: now, - }; - - proposal.update_tally_results(5, now); - assert_eq!(proposal.tally_results, Some(expected_tally_results)); + assert_eq!( + proposal.voting_results, + VotingResults { + abstentions: 0, + approvals: 2, + rejections: 1, + } + ); + + let expected_proposal_status = proposal.define_proposal_decision_status(5, now); + assert_eq!(expected_proposal_status, Some(ProposalStatus::Expired)); } #[test] - fn tally_results_proposal_approved() { + fn define_proposal_decision_status_returns_approved() { + let now = 2; let mut proposal = Proposal::::default(); proposal.created = 1; proposal.parameters.voting_period = 3; @@ -374,26 +312,21 @@ mod tests { proposal.voting_results.add_vote(VoteKind::Approve); proposal.voting_results.add_vote(VoteKind::Approve); - proposal.voting_results = VotingResults { - abstentions: 0, - approvals: 3, - rejections: 1, - }; - - let expected_tally_results = TallyResult { - abstentions: 0, - approvals: 3, - rejections: 1, - status: ProposalStatus::Approved, - finalized_at: 2, - }; - - proposal.update_tally_results(5, 2); - assert_eq!(proposal.tally_results, Some(expected_tally_results)); + assert_eq!( + proposal.voting_results, + VotingResults { + abstentions: 0, + approvals: 3, + rejections: 1, + } + ); + + let expected_proposal_status = proposal.define_proposal_decision_status(5, now); + assert_eq!(expected_proposal_status, Some(ProposalStatus::Approved)); } #[test] - fn tally_results_proposal_rejected() { + fn define_proposal_decision_status_returns_rejected() { let mut proposal = Proposal::::default(); let now = 2; @@ -406,26 +339,21 @@ mod tests { proposal.voting_results.add_vote(VoteKind::Abstain); proposal.voting_results.add_vote(VoteKind::Approve); - proposal.voting_results = VotingResults { - abstentions: 1, - approvals: 1, - rejections: 2, - }; - - let expected_tally_results = TallyResult { - abstentions: 1, - approvals: 1, - rejections: 2, - status: ProposalStatus::Rejected, - finalized_at: now, - }; - - proposal.update_tally_results(4, now); - assert_eq!(proposal.tally_results, Some(expected_tally_results)); + assert_eq!( + proposal.voting_results, + VotingResults { + abstentions: 1, + approvals: 1, + rejections: 2, + } + ); + + let expected_proposal_status = proposal.define_proposal_decision_status(4, now); + assert_eq!(expected_proposal_status, Some(ProposalStatus::Rejected)); } #[test] - fn tally_results_are_empty_with_not_expired_voting_period() { + fn define_proposal_decision_status_returns_none() { let mut proposal = Proposal::::default(); let now = 2; @@ -434,8 +362,16 @@ mod tests { proposal.parameters.approval_quorum_percentage = 60; proposal.voting_results.add_vote(VoteKind::Abstain); - - proposal.update_tally_results(5, now); - assert_eq!(proposal.tally_results, None); + assert_eq!( + proposal.voting_results, + VotingResults { + abstentions: 1, + approvals: 0, + rejections: 0, + } + ); + + let expected_proposal_status = proposal.define_proposal_decision_status(5, now); + assert_eq!(expected_proposal_status, None); } } From f350622fb5f81e97da2e3e4985b3a348825d7562 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 17 Feb 2020 15:42:23 +0300 Subject: [PATCH 18/19] Add comments and refactor - refactor map-filter-map pattern to the filter_map - add comments --- modules/proposals/engine/src/lib.rs | 25 +++++++++---------------- modules/proposals/engine/src/types.rs | 8 ++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/modules/proposals/engine/src/lib.rs b/modules/proposals/engine/src/lib.rs index 966db34877..1324c105d1 100644 --- a/modules/proposals/engine/src/lib.rs +++ b/modules/proposals/engine/src/lib.rs @@ -36,6 +36,7 @@ use srml_support::{ use system::ensure_root; // TODO: add maximum allowed active proposals +// TODO: update proposal.finalized_at - update on all proposal finalization points. // Max allowed proposal title length. Can be used if config value is not filled. const DEFAULT_TITLE_MAX_LEN: u32 = 100; @@ -301,12 +302,12 @@ impl Module { } /// Enumerates through active proposals. Tally Voting results. - /// Returns proposals with changed status, id and calculated tally results + /// Returns proposals with finalized status and id fn get_finalized_proposals_data( ) -> Vec> { // enumerate active proposals id and gather finalization data >::enumerate() - .map(|(proposal_id, _)| { + .filter_map(|(proposal_id, _)| { // load current proposal let proposal = Self::proposals(proposal_id); @@ -315,25 +316,17 @@ impl Module { Self::current_block(), ); - let mut new_status = ProposalStatus::Active; if let Some(status) = decision_status { - new_status = status; - } - // proposal is finalized if not active - let finalized = new_status != ProposalStatus::Active; - - ( - FinalizedProposalData { + Some(FinalizedProposalData { proposal_id, proposal, - status: new_status, + status, finalized_at: Self::current_block(), - }, - finalized, - ) + }) + } else { + None + } }) - .filter(|(_, finalized)| *finalized) // filter only finalized proposals - .map(|(data, _)| data) // get rid of used 'finalized' flag .collect() // compose output vector } diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 005841f2a7..4e18153c23 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -86,15 +86,22 @@ pub struct ProposalParameters { //pub stake: BalanceOf, // } +/// Contains current voting results #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)] pub struct VotingResults { + /// 'Abstain' votes counter pub abstentions: u32, + + /// 'Approve' votes counter pub approvals: u32, + + /// 'Reject' votes counter pub rejections: u32, } impl VotingResults { + /// Add vote to the related counter pub fn add_vote(&mut self, vote: VoteKind) { match vote { VoteKind::Abstain => self.abstentions += 1, @@ -103,6 +110,7 @@ impl VotingResults { } } + /// Calculates number of votes so far pub fn votes_number(&self) -> u32 { self.abstentions + self.approvals + self.rejections } From f2e78a362fa3f4bedc88234eb0d56f5d81112cb1 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 17 Feb 2020 15:43:32 +0300 Subject: [PATCH 19/19] Apply cargo fmt --- modules/proposals/engine/src/types.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/proposals/engine/src/types.rs b/modules/proposals/engine/src/types.rs index 4e18153c23..943b47ec97 100644 --- a/modules/proposals/engine/src/types.rs +++ b/modules/proposals/engine/src/types.rs @@ -188,7 +188,6 @@ where } } - /// Provides data for voting. pub trait VotersParameters { /// Defines maximum voters count for the proposal