diff --git a/.travis.yml b/.travis.yml index 5fc40dd352..fb8c6a5ad3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,16 +7,11 @@ language: rust # sometimes break the build. When cache is enabled do not use the produced WASM build. # This also means the binary should not be used to produce the final chainspec file (because the same # one is embedded in the binary) -cache: cargo +# cache: cargo rust: - stable -matrix: - include: - - os: linux - env: TARGET=x86_64-unknown-linux-gnu - # Skip Rust build in a pull request if no rust project files were modified before_install: - | @@ -30,8 +25,8 @@ before_install: fi install: - - rustup install nightly-2020-05-23 - - rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-23 + - rustup install nightly + - rustup target add wasm32-unknown-unknown --toolchain nightly # travis installs rust using rustup with the "minimal" profile so these tools are not installed by default - rustup component add rustfmt - rustup component add clippy @@ -41,7 +36,8 @@ before_script: script: # we set release as build type for all steps to benefit from already compiled packages in prior steps - - BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --target=${TARGET} -- -D warnings - - BUILD_DUMMY_WASM_BINARY=1 cargo test --release --verbose --all --target=${TARGET} - - TRIGGER_WASM_BUILD=1 WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release --target=${TARGET} -p joystream-node - - ls -l ./target/${TARGET}/release/wbuild/joystream-node-runtime/ \ No newline at end of file + - BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release -- -D warnings + - BUILD_DUMMY_WASM_BINARY=1 cargo test --release + - TRIGGER_WASM_BUILD=1 cargo build --release + - ls -l ./target/release/wbuild/joystream-node-runtime/ + - ./target/release/joystream-node --version diff --git a/Cargo.lock b/Cargo.lock index 6f6bf05c38..9d8cae3af2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,43 +1,79 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" + [[package]] name = "adler32" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" +checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d" [[package]] -name = "aes-ctr" -version = "0.3.0" +name = "aead" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" +dependencies = [ + "generic-array 0.14.3", +] + +[[package]] +name = "aes" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" +checksum = "f7001367fde4c768a19d1029f0a8be5abd9308e1119846d5bd9ad26297b8faf5" dependencies = [ "aes-soft", "aesni", - "ctr", - "stream-cipher", + "block-cipher", +] + +[[package]] +name = "aes-gcm" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f5007801316299f922a6198d1d09a0bae95786815d066d5880d13f7c45ead1" +dependencies = [ + "aead", + "aes", + "block-cipher", + "ghash", + "subtle 2.2.2", ] [[package]] name = "aes-soft" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +checksum = "4925647ee64e5056cf231608957ce7c81e12d6d6e316b9ce1404778cc1d35fa7" dependencies = [ - "block-cipher-trait", - "byteorder 1.3.4", - "opaque-debug", + "block-cipher", + "byteorder", + "opaque-debug 0.2.3", ] [[package]] name = "aesni" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +checksum = "d050d39b0b7688b3a3254394c3e30a9d66c41dcf9b05b0e2dbdc623f6505d264" dependencies = [ - "block-cipher-trait", - "opaque-debug", - "stream-cipher", + "block-cipher", + "opaque-debug 0.2.3", ] [[package]] @@ -58,6 +94,17 @@ dependencies = [ "memchr", ] +[[package]] +name = "alga" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f823d037a7ec6ea2197046bafd4ae150e6bc36f9ca347404f46a46823fa84f2" +dependencies = [ + "approx", + "num-complex", + "num-traits 0.2.11", +] + [[package]] name = "ansi_term" version = "0.11.0" @@ -77,22 +124,25 @@ dependencies = [ ] [[package]] -name = "app_dirs" -version = "1.2.1" +name = "anyhow" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" + +[[package]] +name = "approx" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" +checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" dependencies = [ - "ole32-sys", - "shell32-sys", - "winapi 0.2.8", - "xdg", + "num-traits 0.2.11", ] [[package]] name = "arc-swap" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d663a8e9a99154b5fb793032533f6328da35e23aac63d5c152279aa8ba356825" +checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" [[package]] name = "arrayref" @@ -130,10 +180,64 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" dependencies = [ - "quote 1.0.3", + "quote 1.0.7", "syn 1.0.17", ] +[[package]] +name = "assert_matches" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" + +[[package]] +name = "async-std" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "538ecb01eb64eecd772087e5b6f7540cbc917f047727339a472dafed2185b267" +dependencies = [ + "async-task", + "broadcaster", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "futures-core", + "futures-io", + "futures-timer 2.0.2", + "kv-log-macro", + "log", + "memchr", + "mio", + "mio-uds", + "num_cpus", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "async-task" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ac2c016b079e771204030951c366db398864f5026f84a44dafb0ff20f02085d" +dependencies = [ + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "async-tls" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95fd83426b89b034bf4e9ceb9c533c2f2386b813fd3dcae0a425ec6f1837d78a" +dependencies = [ + "futures 0.3.4", + "rustls", + "webpki", + "webpki-roots 0.19.0", +] + [[package]] name = "atty" version = "0.2.14" @@ -187,32 +291,31 @@ checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" [[package]] name = "base64" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder 1.3.4", -] +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" [[package]] name = "bindgen" -version = "0.47.3" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df683a55b54b41d5ea8ebfaebb5aa7e6b84e3f3006a78f010dadc9ca88469260" +checksum = "c72a978d268b1d70b0e963217e60fdabd9523a941457a6c42a7315d15c7e89e5" dependencies = [ "bitflags", "cexpr", "cfg-if", "clang-sys", "clap", - "env_logger 0.6.2", - "hashbrown 0.1.8", + "env_logger", "lazy_static", + "lazycell", "log", "peeking_take_while", - "proc-macro2 0.4.30", - "quote 0.6.13", + "proc-macro2", + "quote 1.0.7", "regex", + "rustc-hash", + "shlex", "which", ] @@ -245,9 +348,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" dependencies = [ "byte-tools", - "crypto-mac", - "digest", - "opaque-debug", + "crypto-mac 0.7.0", + "digest 0.8.1", + "opaque-debug 0.2.3", +] + +[[package]] +name = "blake2" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84ce5b6108f8e154604bd4eb76a2f726066c3464d5a552a4229262a18c9bb471" +dependencies = [ + "byte-tools", + "byteorder", + "crypto-mac 0.8.0", + "digest 0.9.0", + "opaque-debug 0.2.3", ] [[package]] @@ -260,6 +376,28 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "blake2b_simd" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" +dependencies = [ + "arrayref", + "arrayvec 0.5.1", + "constant_time_eq", +] + +[[package]] +name = "blake2s_simd" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9e07352b829279624ceb7c64adb4f585dacdb81d35cafae81139ccd617cf44" +dependencies = [ + "arrayref", + "arrayvec 0.5.1", + "constant_time_eq", +] + [[package]] name = "block-buffer" version = "0.7.3" @@ -268,17 +406,26 @@ checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ "block-padding", "byte-tools", - "byteorder 1.3.4", - "generic-array", + "byteorder", + "generic-array 0.12.3", ] [[package]] -name = "block-cipher-trait" -version = "0.6.2" +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.3", +] + +[[package]] +name = "block-cipher" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +checksum = "fa136449e765dc7faa244561ccae839c394048667929af599b5d931ebe7b7f10" dependencies = [ - "generic-array", + "generic-array 0.14.3", ] [[package]] @@ -291,22 +438,30 @@ dependencies = [ ] [[package]] -name = "bs58" -version = "0.2.5" +name = "broadcaster" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95ee6bba9d950218b6cc910cf62bc9e0a171d0f4537e3627b0f54d08549b188" +checksum = "d9c972e21e0d055a36cf73e4daae870941fe7a8abcd5ac3396aab9e4c126bd87" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "futures-util", + "parking_lot 0.10.2", + "slab", +] [[package]] name = "bs58" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" +checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" [[package]] name = "bstr" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" +checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" dependencies = [ "memchr", ] @@ -329,12 +484,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" -[[package]] -name = "byteorder" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" - [[package]] name = "byteorder" version = "1.3.4" @@ -347,16 +496,16 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" dependencies = [ - "byteorder 1.3.4", + "byteorder", "either", "iovec", ] [[package]] name = "bytes" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" [[package]] name = "c_linked_list" @@ -366,18 +515,18 @@ checksum = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" [[package]] name = "cc" -version = "1.0.50" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" +checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" dependencies = [ "jobserver", ] [[package]] name = "cexpr" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" +checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" dependencies = [ "nom", ] @@ -388,17 +537,41 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +[[package]] +name = "chacha20" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "086c0f07ac275808b7bf9a39f2fd013aae1498be83632814c8c4e0bd53f2dc58" +dependencies = [ + "stream-cipher", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18b0c90556d8e3fec7cf18d84a2f53d27b21288f2fe481b830fadcf809e48205" +dependencies = [ + "aead", + "chacha20", + "poly1305", + "stream-cipher", + "zeroize", +] + [[package]] name = "chain-spec-builder" -version = "2.1.0" +version = "3.0.0" dependencies = [ "ansi_term 0.12.1", "joystream-node", "rand 0.7.3", + "sc-chain-spec", + "sc-keystore", + "sc-telemetry", + "sp-core", "structopt", - "substrate-keystore", - "substrate-primitives", - "substrate-telemetry", ] [[package]] @@ -407,16 +580,18 @@ version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" dependencies = [ + "js-sys", "num-integer", - "num-traits", + "num-traits 0.2.11", "time", + "wasm-bindgen", ] [[package]] name = "clang-sys" -version = "0.26.4" +version = "0.29.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef0c1bcf2e99c649104bd7a7012d8f8802684400e03db0ec0af48583c6fa0e4" +checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" dependencies = [ "glob", "libc", @@ -425,9 +600,9 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.0" +version = "2.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" dependencies = [ "ansi_term 0.11.0", "atty", @@ -456,6 +631,26 @@ dependencies = [ "bitflags", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "console_log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7871d2947441b0fdd8e2bd1ce2a2f75304f896582c0d572162d48290683c48" +dependencies = [ + "log", + "web-sys", +] + [[package]] name = "const-random" version = "0.1.8" @@ -463,7 +658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a" dependencies = [ "const-random-macro", - "proc-macro-hack 0.5.15", + "proc-macro-hack", ] [[package]] @@ -473,7 +668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a" dependencies = [ "getrandom", - "proc-macro-hack 0.5.15", + "proc-macro-hack", ] [[package]] @@ -482,6 +677,28 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + [[package]] name = "crc32fast" version = "1.2.0" @@ -493,11 +710,12 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.3.9" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" +checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" dependencies = [ - "crossbeam-utils 0.6.6", + "cfg-if", + "crossbeam-utils", ] [[package]] @@ -507,7 +725,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" dependencies = [ "crossbeam-epoch", - "crossbeam-utils 0.7.2", + "crossbeam-utils", "maybe-uninit", ] @@ -519,31 +737,22 @@ checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ "autocfg 1.0.0", "cfg-if", - "crossbeam-utils 0.7.2", + "crossbeam-utils", "lazy_static", "maybe-uninit", "memoffset", - "scopeguard 1.1.0", + "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" -dependencies = [ - "cfg-if", - "crossbeam-utils 0.7.2", -] - -[[package]] -name = "crossbeam-utils" -version = "0.6.6" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" dependencies = [ "cfg-if", - "lazy_static", + "crossbeam-utils", + "maybe-uninit", ] [[package]] @@ -569,131 +778,102 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "generic-array", + "generic-array 0.12.3", "subtle 1.0.0", ] [[package]] -name = "ct-logs" -version = "0.6.0" +name = "crypto-mac" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3686f5fa27dbc1d76c751300376e167c5a43387f44bb451fd1c24776e49113" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "sct", + "generic-array 0.14.3", + "subtle 2.2.2", ] [[package]] -name = "ctr" -version = "0.3.2" +name = "ct-logs" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" +checksum = "4d3686f5fa27dbc1d76c751300376e167c5a43387f44bb451fd1c24776e49113" dependencies = [ - "block-cipher-trait", - "stream-cipher", + "sct", ] [[package]] -name = "ctrlc" -version = "3.1.4" +name = "curve25519-dalek" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4ba686dff9fa4c1c9636ce1010b0cf98ceb421361b0bb3d6faeec43bd217a7" +checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" dependencies = [ - "nix", - "winapi 0.3.8", + "byteorder", + "digest 0.8.1", + "rand_core 0.5.1", + "subtle 2.2.2", + "zeroize", ] [[package]] -name = "cuckoofilter" -version = "0.3.2" +name = "data-encoding" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -dependencies = [ - "byteorder 0.5.3", - "rand 0.3.23", -] +checksum = "72aa14c04dfae8dd7d8a2b1cb7ca2152618cd01336dbfe704b8dcbf8d41dbd69" [[package]] -name = "curve25519-dalek" -version = "1.2.3" +name = "derive_more" +version = "0.99.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" +checksum = "298998b1cf6b5b2c8a7b023dfd45821825ce3ba8a8af55c921a0e734e4653f76" dependencies = [ - "byteorder 1.3.4", - "clear_on_drop", - "digest", - "rand_core 0.3.1", - "subtle 2.2.2", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "curve25519-dalek" +name = "difference" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" -dependencies = [ - "byteorder 1.3.4", - "digest", - "rand_core 0.5.1", - "subtle 2.2.2", - "zeroize 1.1.0", -] +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] -name = "data-encoding" -version = "2.2.0" +name = "digest" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c0346158a19b3627234e15596f5e465c360fcdb97d817bcb255e0510f5a788" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.3", +] [[package]] -name = "derivative" -version = "2.1.0" +name = "digest" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eae4d76b7cefedd1b4f8cc24378b2fbd1ac1b66e3bbebe8e2192d3be81cb355" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "generic-array 0.14.3", ] [[package]] -name = "derive_more" -version = "0.14.1" +name = "directories" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" +checksum = "551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "rustc_version", - "syn 0.15.44", + "cfg-if", + "dirs-sys", ] [[package]] -name = "derive_more" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" -dependencies = [ - "lazy_static", - "proc-macro2 0.4.30", - "quote 0.6.13", - "regex", - "rustc_version", - "syn 0.15.44", -] - -[[package]] -name = "difference" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" - -[[package]] -name = "digest" -version = "0.8.1" +name = "dirs-sys" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" dependencies = [ - "generic-array", + "libc", + "redox_users", + "winapi 0.3.8", ] [[package]] @@ -702,7 +882,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" dependencies = [ - "byteorder 1.3.4", + "byteorder", "quick-error", ] @@ -718,18 +898,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" -[[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 1.2.3", - "failure", - "rand 0.6.5", -] - [[package]] name = "ed25519-dalek" version = "1.0.0-pre.3" @@ -737,9 +905,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" dependencies = [ "clear_on_drop", - "curve25519-dalek 2.0.0", + "curve25519-dalek", "rand 0.7.3", - "sha2", + "sha2 0.8.1", ] [[package]] @@ -749,25 +917,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] -name = "elastic-array" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" -dependencies = [ - "heapsize", -] - -[[package]] -name = "env_logger" -version = "0.6.2" +name = "enum-primitive-derive" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +checksum = "e2b90e520ec62c1864c8c78d637acbfe8baf5f63240f2fb8165b8325c07812dd" dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "num-traits 0.1.43", + "quote 0.3.15", + "syn 0.11.11", ] [[package]] @@ -791,21 +948,20 @@ checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" [[package]] name = "erased-serde" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88b6d1705e16a4d62e05ea61cc0496c2bd190f4fa8e5c1f11ce747be6bcf3d1" +checksum = "6ca8b296792113e1500fd935ae487be6e00ce318952a6880555554824d6ebf38" dependencies = [ "serde", ] [[package]] name = "exit-future" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8013f441e38e31c670e7f34ec8f1d5d3a2bd9d303c1ff83976ca886005e8f48" +checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.1.29", - "parking_lot 0.7.1", + "futures 0.3.4", ] [[package]] @@ -824,8 +980,8 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", "synstructure", ] @@ -847,26 +1003,26 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.9.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34754852da8d86bc509715292c73140a5b678656d0b16132acd6737bdb5fd5f8" +checksum = "8feb87a63249689640ac9c011742c33139204e3c134293d3054022276869133b" dependencies = [ - "futures 0.1.29", - "hashbrown 0.6.3", + "either", + "futures 0.3.4", + "futures-timer 2.0.2", "log", - "num-traits", + "num-traits 0.2.11", "parity-scale-codec", "parking_lot 0.9.0", ] [[package]] name = "fixed-hash" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3367952ceb191f4ab95dd5685dc163ac539e36202f9fcfd0cb22f9f9c542fefc" +checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" dependencies = [ - "byteorder 1.3.4", - "libc", + "byteorder", "rand 0.7.3", "rustc-hex", "static_assertions", @@ -874,23 +1030,21 @@ dependencies = [ [[package]] name = "fixedbitset" -version = "0.1.9" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" [[package]] name = "flate2" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" +checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e" dependencies = [ "cfg-if", "crc32fast", - "futures 0.1.29", "libc", "libz-sys", "miniz_oxide", - "tokio-io", ] [[package]] @@ -899,19 +1053,19 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da62c4f1b81918835a8c6a484a397775fff5953fe83529afd51b05f5c6a6617d" dependencies = [ - "num-traits", + "num-traits 0.2.11", ] [[package]] name = "fnv" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "parity-scale-codec", ] @@ -922,6 +1076,164 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69a039c3498dc930fe810151a34ba0c1c70b02b8625035592e74432f678591f2" +[[package]] +name = "frame-benchmarking" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "linregress", + "parity-scale-codec", + "paste", + "sp-api", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", +] + +[[package]] +name = "frame-benchmarking-cli" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-benchmarking", + "parity-scale-codec", + "sc-cli", + "sc-client-db", + "sc-executor", + "sc-service", + "sp-core", + "sp-externalities", + "sp-runtime", + "sp-state-machine", + "structopt", +] + +[[package]] +name = "frame-executive" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "serde", + "sp-io", + "sp-runtime", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "frame-metadata" +version = "11.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "serde", + "sp-core", + "sp-std", +] + +[[package]] +name = "frame-support" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "bitmask", + "frame-metadata", + "frame-support-procedural", + "impl-trait-for-tuples", + "log", + "once_cell", + "parity-scale-codec", + "paste", + "serde", + "smallvec 1.4.1", + "sp-arithmetic", + "sp-core", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "frame-support-procedural" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support-procedural-tools", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "frame-system" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "impl-trait-for-tuples", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-version", +] + +[[package]] +name = "frame-system-benchmarking" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "frame-system-rpc-runtime-api" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-api", +] + [[package]] name = "fs-swap" version = "0.2.4" @@ -994,7 +1306,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a" dependencies = [ "futures-core-preview", - "futures-sink-preview", ] [[package]] @@ -1019,6 +1330,22 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "futures-diagnose" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdcef58a173af8148b182684c9f2d5250875adbcaff7b5794073894f9d8634a9" +dependencies = [ + "futures 0.1.29", + "futures 0.3.4", + "lazy_static", + "log", + "parking_lot 0.9.0", + "pin-project", + "serde", + "serde_json", +] + [[package]] name = "futures-executor" version = "0.3.4" @@ -1031,67 +1358,30 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "futures-executor-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75236e88bd9fe88e5e8bfcd175b665d0528fe03ca4c5207fabc028c8f9d93e98" -dependencies = [ - "futures-core-preview", - "futures-util-preview", - "num_cpus", -] - [[package]] name = "futures-io" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" -[[package]] -name = "futures-io-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4914ae450db1921a56c91bde97a27846287d062087d4a652efc09bb3a01ebda" - [[package]] name = "futures-macro" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" dependencies = [ - "proc-macro-hack 0.5.15", - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro-hack", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", ] -[[package]] -name = "futures-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1dce2a0267ada5c6ff75a8ba864b4e679a9e2aa44262af7a3b5516d530d76e" -dependencies = [ - "futures-channel-preview", - "futures-core-preview", - "futures-executor-preview", - "futures-io-preview", - "futures-sink-preview", - "futures-util-preview", -] - [[package]] name = "futures-sink" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6" -[[package]] -name = "futures-sink-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec" - [[package]] name = "futures-task" version = "0.3.4" @@ -1100,13 +1390,18 @@ checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" [[package]] name = "futures-timer" -version = "0.4.0" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" + +[[package]] +name = "futures-timer" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878f1d2fc31355fa02ed2372e741b0c17e58373341e6a122569b4623a14a7d33" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" dependencies = [ - "futures-core-preview", - "futures-util-preview", - "pin-utils", + "gloo-timers", + "send_wrapper 0.4.0", ] [[package]] @@ -1115,6 +1410,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" dependencies = [ + "futures 0.1.29", "futures-channel", "futures-core", "futures-io", @@ -1123,7 +1419,7 @@ dependencies = [ "futures-task", "memchr", "pin-utils", - "proc-macro-hack 0.5.15", + "proc-macro-hack", "proc-macro-nested", "slab", ] @@ -1134,16 +1430,36 @@ version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" dependencies = [ - "futures 0.1.29", "futures-channel-preview", "futures-core-preview", - "futures-io-preview", - "futures-sink-preview", - "memchr", "pin-utils", "slab", ] +[[package]] +name = "futures_codec" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0a73299e4718f5452e45980fc1d6957a070abe308d3700b63b8673f47e1c2b3" +dependencies = [ + "bytes 0.5.6", + "futures 0.3.4", + "memchr", + "pin-project", +] + +[[package]] +name = "futures_codec" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe8859feb7140742ed1a2a85a07941100ad2b5f98a421b353931d718a34144d1" +dependencies = [ + "bytes 0.5.6", + "futures 0.3.4", + "memchr", + "pin-project", +] + [[package]] name = "gcc" version = "0.3.55" @@ -1159,6 +1475,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "generic-array" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60fb4bb6bba52f78a471264d9a3b7d026cc0af47b22cd2cffbc0b787ca003e63" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "get_if_addrs" version = "0.5.3" @@ -1190,13 +1516,23 @@ dependencies = [ "cfg-if", "libc", "wasi", + "wasm-bindgen", +] + +[[package]] +name = "ghash" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6e27f0689a6e15944bdce7e45425efb87eaa8ab0c6e87f11d0987a9133e2531" +dependencies = [ + "polyval", ] [[package]] name = "glob" -version = "0.2.11" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "globset" @@ -1211,17 +1547,30 @@ dependencies = [ "regex", ] +[[package]] +name = "gloo-timers" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "h2" version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" dependencies = [ - "byteorder 1.3.4", + "byteorder", "bytes 0.4.12", "fnv", "futures 0.1.29", - "http", + "http 0.1.21", "indexmap", "log", "slab", @@ -1229,6 +1578,25 @@ dependencies = [ "tokio-io", ] +[[package]] +name = "h2" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" +dependencies = [ + "bytes 0.5.6", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.1", + "indexmap", + "slab", + "tokio 0.2.22", + "tokio-util", + "tracing", +] + [[package]] name = "hash-db" version = "0.15.2" @@ -1244,16 +1612,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" -dependencies = [ - "byteorder 1.3.4", - "scopeguard 0.3.3", -] - [[package]] name = "hashbrown" version = "0.6.3" @@ -1265,12 +1623,12 @@ dependencies = [ ] [[package]] -name = "heapsize" -version = "0.4.2" +name = "hashbrown" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" +checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" dependencies = [ - "winapi 0.3.8", + "autocfg 1.0.0", ] [[package]] @@ -1291,12 +1649,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - [[package]] name = "hex" version = "0.4.2" @@ -1305,40 +1657,21 @@ checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" [[package]] name = "hex-literal" -version = "0.1.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc2928beef125e519d69ae1baa8c37ea2e0d3848545217f6db0179c5eb1d639" +checksum = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" dependencies = [ - "hex-literal-impl 0.1.2", - "proc-macro-hack 0.4.2", -] - -[[package]] -name = "hex-literal" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" -dependencies = [ - "hex-literal-impl 0.2.1", - "proc-macro-hack 0.5.15", -] - -[[package]] -name = "hex-literal-impl" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520870c3213943eb8d7803e80180d12a6c7ceb4ae74602544529d1643dc4ddda" -dependencies = [ - "proc-macro-hack 0.4.2", + "hex-literal-impl", + "proc-macro-hack", ] [[package]] name = "hex-literal-impl" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" +checksum = "853f769599eb31de176303197b7ba4973299c38c7a7604a6bc88c3eef05b9b46" dependencies = [ - "proc-macro-hack 0.5.15", + "proc-macro-hack", ] [[package]] @@ -1347,8 +1680,8 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" dependencies = [ - "crypto-mac", - "digest", + "crypto-mac 0.7.0", + "digest 0.8.1", ] [[package]] @@ -1357,8 +1690,8 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" dependencies = [ - "digest", - "generic-array", + "digest 0.8.1", + "generic-array 0.12.3", "hmac", ] @@ -1373,6 +1706,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes 0.5.6", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.1.0" @@ -1381,10 +1725,20 @@ checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" dependencies = [ "bytes 0.4.12", "futures 0.1.29", - "http", + "http 0.1.21", "tokio-buf", ] +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes 0.5.6", + "http 0.2.1", +] + [[package]] name = "httparse" version = "1.3.4" @@ -1409,9 +1763,9 @@ dependencies = [ "bytes 0.4.12", "futures 0.1.29", "futures-cpupool", - "h2", - "http", - "http-body", + "h2 0.1.26", + "http 0.1.21", + "http-body 0.1.0", "httparse", "iovec", "itoa", @@ -1419,32 +1773,57 @@ dependencies = [ "net2", "rustc_version", "time", - "tokio", + "tokio 0.1.22", "tokio-buf", - "tokio-executor", + "tokio-executor 0.1.10", "tokio-io", "tokio-reactor", "tokio-tcp", "tokio-threadpool", "tokio-timer", - "want", + "want 0.2.0", +] + +[[package]] +name = "hyper" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e68a8dd9716185d9e64ea473ea6ef63529252e3e27623295a0378a19665d5eb" +dependencies = [ + "bytes 0.5.6", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.2.6", + "http 0.2.1", + "http-body 0.3.1", + "httparse", + "itoa", + "pin-project", + "socket2", + "time", + "tokio 0.2.22", + "tower-service", + "tracing", + "want 0.3.0", ] [[package]] name = "hyper-rustls" -version = "0.17.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719d85c7df4a7f309a77d145340a063ea929dcb2e025bae46a80345cffec2952" +checksum = "ac965ea399ec3a25ac7d13b8affd4b8f39325cca00858ddf5eb29b79e6b14b08" dependencies = [ - "bytes 0.4.12", + "bytes 0.5.6", "ct-logs", - "futures 0.1.29", - "hyper", + "futures-util", + "hyper 0.13.7", + "log", "rustls", - "tokio-io", + "rustls-native-certs", + "tokio 0.2.22", "tokio-rustls", "webpki", - "webpki-roots 0.17.0", ] [[package]] @@ -1502,18 +1881,19 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", ] [[package]] name = "indexmap" -version = "1.3.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" dependencies = [ "autocfg 1.0.0", + "hashbrown 0.8.1", ] [[package]] @@ -1523,10 +1903,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" [[package]] -name = "interleaved-ordered" -version = "0.1.1" +name = "intervalier" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" +checksum = "64fa110ec7b8f493f416eed552740d10e7030ad5f63b2308f82c9608ec2df275" +dependencies = [ + "futures 0.3.4", + "futures-timer 2.0.2", +] [[package]] name = "iovec" @@ -1537,6 +1921,12 @@ dependencies = [ "libc", ] +[[package]] +name = "ip_network" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee15951c035f79eddbef745611ec962f63f4558f1dadf98ab723cc603487c6f" + [[package]] name = "ipnet" version = "2.3.0" @@ -1552,11 +1942,20 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" [[package]] name = "jobserver" @@ -1569,106 +1968,127 @@ dependencies = [ [[package]] name = "joystream-node" -version = "2.7.0" +version = "3.0.0" dependencies = [ - "ctrlc", - "derive_more 0.14.1", - "exit-future", - "futures 0.1.29", - "hex 0.4.2", - "hex-literal 0.2.1", + "frame-benchmarking", + "frame-benchmarking-cli", + "frame-system", + "futures 0.3.4", "joystream-node-runtime", - "jsonrpc-core 13.2.0", - "libp2p", - "log", + "jsonrpc-core", + "node-inspect", + "pallet-grandpa", + "pallet-im-online", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc", "parity-scale-codec", - "parking_lot 0.9.0", - "rand 0.7.3", + "sc-authority-discovery", + "sc-basic-authorship", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-babe-rpc", + "sc-consensus-epochs", + "sc-executor", + "sc-finality-grandpa", + "sc-finality-grandpa-rpc", + "sc-keystore", + "sc-network", + "sc-rpc-api", + "sc-service", + "sc-transaction-pool", "serde", "serde_json", - "sr-io", - "sr-primitives", - "srml-im-online", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-core", + "sp-finality-grandpa", + "sp-finality-tracker", + "sp-inherents", + "sp-keyring", + "sp-runtime", + "sp-timestamp", + "sp-transaction-pool", "structopt", - "substrate-authority-discovery", - "substrate-basic-authorship", - "substrate-cli", - "substrate-client", - "substrate-client-db", - "substrate-consensus-babe", - "substrate-consensus-babe-primitives", - "substrate-executor", - "substrate-finality-grandpa", - "substrate-finality-grandpa-primitives", - "substrate-inherents", - "substrate-network", - "substrate-offchain", - "substrate-primitives", - "substrate-rpc", - "substrate-service", - "substrate-telemetry", - "substrate-transaction-pool", - "tokio", - "vergen", + "substrate-browser-utils", + "substrate-build-script-utils", + "substrate-frame-rpc-system", + "tempfile", + "wasm-bindgen", + "wasm-bindgen-futures", ] [[package]] name = "joystream-node-runtime" -version = "6.21.0" -dependencies = [ +version = "7.0.0" +dependencies = [ + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-collective", + "pallet-common", + "pallet-content-working-group", + "pallet-finality-tracker", + "pallet-forum", + "pallet-governance", + "pallet-grandpa", + "pallet-hiring", + "pallet-im-online", + "pallet-membership", + "pallet-memo", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-proposals-codex", + "pallet-proposals-discussion", + "pallet-proposals-engine", + "pallet-randomness-collective-flip", + "pallet-recurring-reward", + "pallet-service-discovery", + "pallet-session", + "pallet-session-benchmarking", + "pallet-stake", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-storage", + "pallet-sudo", + "pallet-timestamp", + "pallet-token-mint", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-versioned-store", + "pallet-versioned-store-permissions", + "pallet-working-group", "parity-scale-codec", - "safe-mix", "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "sr-version", - "srml-authority-discovery", - "srml-authorship", - "srml-babe", - "srml-balances", - "srml-executive", - "srml-finality-tracker", - "srml-grandpa", - "srml-im-online", - "srml-indices", - "srml-offences", - "srml-randomness-collective-flip", - "srml-session", - "srml-staking", - "srml-staking-reward-curve", - "srml-sudo", - "srml-support", - "srml-system", - "srml-system-rpc-runtime-api", - "srml-timestamp", - "srml-transaction-payment", - "substrate-authority-discovery-primitives", - "substrate-client", - "substrate-common-module", - "substrate-consensus-babe-primitives", - "substrate-content-working-group-module", - "substrate-forum-module", - "substrate-governance-module", - "substrate-hiring-module", - "substrate-membership-module", - "substrate-memo-module", - "substrate-offchain-primitives", - "substrate-primitives", - "substrate-proposals-codex-module", - "substrate-proposals-discussion-module", - "substrate-proposals-engine-module", - "substrate-recurring-reward-module", - "substrate-service-discovery-module", - "substrate-session", - "substrate-stake-module", - "substrate-storage-module", - "substrate-token-mint-module", - "substrate-versioned-store", - "substrate-versioned-store-permissions-module", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-core", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", "substrate-wasm-builder-runner", - "substrate-working-group-module", ] [[package]] @@ -1682,13 +2102,13 @@ dependencies = [ [[package]] name = "jsonrpc-client-transports" -version = "14.0.5" +version = "14.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a9ae166c4d1f702d297cd76d4b55758ace80272ffc6dbb139fdc1bf810de40b" +checksum = "ecbdaacc17243168d9d1fa6b2bd7556a27e1e60a621d8a2a6e590ae2b145d158" dependencies = [ "failure", "futures 0.1.29", - "jsonrpc-core 14.0.5", + "jsonrpc-core", "jsonrpc-pubsub", "log", "serde", @@ -1698,22 +2118,9 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "13.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d767c183a7e58618a609499d359ce3820700b3ebb4823a18c343b4a2a41a0d" -dependencies = [ - "futures 0.1.29", - "log", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "jsonrpc-core" -version = "14.0.5" +version = "14.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe3b688648f1ef5d5072229e2d672ecb92cbff7d1c79bcf3fd5898f3f3df0970" +checksum = "a0747307121ffb9703afd93afbd0fb4f854c38fb873f2c8b90e0e902f27c7b62" dependencies = [ "futures 0.1.29", "log", @@ -1724,78 +2131,93 @@ dependencies = [ [[package]] name = "jsonrpc-core-client" -version = "14.0.5" +version = "14.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080dc110be17701097df238fad3c816d4a478a1899dfbcf8ec8957dd40ec7304" +checksum = "34221123bc79b66279a3fde2d3363553835b43092d629b34f2e760c44dc94713" dependencies = [ "jsonrpc-client-transports", ] [[package]] name = "jsonrpc-derive" -version = "14.0.5" +version = "14.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8609af8f63b626e8e211f52441fcdb6ec54f1a446606b10d5c89ae9bf8a20058" +checksum = "0fadf6945e227246825a583514534d864554e9f23d80b3c77d034b10983db5ef" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", ] [[package]] name = "jsonrpc-http-server" -version = "14.0.6" +version = "14.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816d63997ea45d3634608edbef83ddb35e661f7c0b27b5b72f237e321f0e9807" +checksum = "0da906d682799df05754480dac1b9e70ec92e12c19ebafd2662a5ea1c9fd6522" dependencies = [ - "hyper", - "jsonrpc-core 14.0.5", + "hyper 0.12.35", + "jsonrpc-core", "jsonrpc-server-utils", "log", "net2", - "parking_lot 0.10.0", + "parking_lot 0.10.2", "unicase", ] +[[package]] +name = "jsonrpc-ipc-server" +version = "14.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dedccd693325d833963b549e959137f30a7a0ea650cde92feda81dc0c1393cb5" +dependencies = [ + "jsonrpc-core", + "jsonrpc-server-utils", + "log", + "parity-tokio-ipc", + "parking_lot 0.10.2", + "tokio-service", +] + [[package]] name = "jsonrpc-pubsub" -version = "14.0.6" +version = "14.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b31c9b90731276fdd24d896f31bb10aecf2e5151733364ae81123186643d939" +checksum = "2d44f5602a11d657946aac09357956d2841299ed422035edf140c552cb057986" dependencies = [ - "jsonrpc-core 14.0.5", + "jsonrpc-core", "log", - "parking_lot 0.10.0", + "parking_lot 0.10.2", + "rand 0.7.3", "serde", ] [[package]] name = "jsonrpc-server-utils" -version = "14.0.5" +version = "14.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b7635e618a0edbbe0d2a2bbbc69874277c49383fcf6c3c0414491cfb517d22" +checksum = "56cbfb462e7f902e21121d9f0d1c2b77b2c5b642e1a4e8f4ebfa2e15b94402bb" dependencies = [ "bytes 0.4.12", "globset", - "jsonrpc-core 14.0.5", + "jsonrpc-core", "lazy_static", "log", - "tokio", + "tokio 0.1.22", "tokio-codec", "unicase", ] [[package]] name = "jsonrpc-ws-server" -version = "14.0.6" +version = "14.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94e5773b2ae66e0e02c80775ce6bbba6f15d5bb47c14ec36a36fcf94f8df851" +checksum = "903d3109fe7c4acb932b567e1e607e0f524ed04741b09fb0e61841bc40a022fc" dependencies = [ - "jsonrpc-core 14.0.5", + "jsonrpc-core", "jsonrpc-server-utils", "log", - "parking_lot 0.10.0", + "parking_lot 0.10.2", "slab", "ws", ] @@ -1816,38 +2238,69 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + [[package]] name = "kvdb" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e763b2a9b500ba47948061d1e8bc3b5f03a8a1f067dbcf822a4d2c84d2b54a3a" dependencies = [ - "elastic-array", - "parity-bytes", + "parity-util-mem", + "smallvec 1.4.1", ] [[package]] name = "kvdb-memorydb" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73027d5e228de6f503b5b7335d530404fc26230a6ae3e09b33ec6e45408509a4" dependencies = [ "kvdb", - "parking_lot 0.6.4", + "parity-util-mem", + "parking_lot 0.10.2", ] [[package]] name = "kvdb-rocksdb" -version = "0.1.4" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84384eca250c7ff67877eda5336f28a86586aaee24acb945643590671f6bfce1" dependencies = [ - "elastic-array", "fs-swap", - "interleaved-ordered", "kvdb", "log", "num_cpus", - "parking_lot 0.6.4", + "owning_ref", + "parity-util-mem", + "parking_lot 0.10.2", "regex", "rocksdb", + "smallvec 1.4.1", +] + +[[package]] +name = "kvdb-web" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c7f36acb1841d4c701d30ae1f2cfd242e805991443f75f6935479ed3de64903" +dependencies = [ + "futures 0.3.4", + "js-sys", + "kvdb", + "kvdb-memorydb", + "log", + "parity-util-mem", + "send_wrapper 0.3.0", + "wasm-bindgen", + "web-sys", ] [[package]] @@ -1864,9 +2317,27 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" [[package]] name = "libc" -version = "0.2.68" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" + +[[package]] +name = "libflate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9bac9023e1db29c084f9f8cd9d3852e5e8fddf98fb47c4964a0ea4663d95949" +dependencies = [ + "adler32", + "crc32fast", + "libflate_lz77", + "rle-decode-fast", +] + +[[package]] +name = "libflate_lz77" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" +checksum = "3286f09f7d4926fc486334f28d8d2e6ebe4f7f9994494b6dab27ddfad2c9b11b" [[package]] name = "libloading" @@ -1878,401 +2349,299 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "libm" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" + [[package]] name = "libp2p" -version = "0.13.2" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b4674c6738fdd8b1cf7104dd046abcef78dc932fe25f8eb40f3a8e71341717d" +checksum = "057eba5432d3e740e313c6e13c9153d0cb76b4f71bfc2e5242ae5bdb7d41af67" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", + "bytes 0.5.6", + "futures 0.3.4", "lazy_static", "libp2p-core", "libp2p-core-derive", - "libp2p-deflate", "libp2p-dns", - "libp2p-floodsub", "libp2p-identify", "libp2p-kad", "libp2p-mdns", "libp2p-mplex", "libp2p-noise", "libp2p-ping", - "libp2p-plaintext", - "libp2p-secio", "libp2p-swarm", "libp2p-tcp", - "libp2p-uds", "libp2p-wasm-ext", "libp2p-websocket", "libp2p-yamux", - "parity-multiaddr 0.6.0", - "parity-multihash 0.2.3", - "parking_lot 0.9.0", - "smallvec 0.6.13", - "tokio-codec", - "tokio-executor", - "tokio-io", + "multihash", + "parity-multiaddr 0.9.1", + "parking_lot 0.10.2", + "pin-project", + "smallvec 1.4.1", "wasm-timer", ] [[package]] name = "libp2p-core" -version = "0.13.2" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01efc769c392d0d8863a7160d266f9b9f794968554f87490c8af4aa34ccaa94f" +checksum = "3a0387b930c3d4c2533dc4893c1e0394185ddcc019846121b1b27491e45a2c08" dependencies = [ "asn1_der", - "bs58 0.3.0", - "bytes 0.4.12", - "ed25519-dalek 1.0.0-pre.3", - "failure", + "bs58", + "ed25519-dalek", + "either", "fnv", - "futures 0.1.29", + "futures 0.3.4", + "futures-timer 3.0.2", "lazy_static", "libsecp256k1", "log", + "multihash", "multistream-select", - "parity-multiaddr 0.6.0", - "parity-multihash 0.2.3", - "parking_lot 0.9.0", - "protobuf", - "quick-error", + "parity-multiaddr 0.9.1", + "parking_lot 0.10.2", + "pin-project", + "prost", + "prost-build", "rand 0.7.3", "ring", "rw-stream-sink", - "sha2", - "smallvec 0.6.13", - "tokio-executor", - "tokio-io", - "unsigned-varint 0.2.3", - "untrusted", + "sha2 0.8.1", + "smallvec 1.4.1", + "thiserror", + "unsigned-varint 0.4.0", "void", - "wasm-timer", - "zeroize 1.1.0", + "zeroize", ] [[package]] name = "libp2p-core-derive" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eeb2704ac14c60f31967e351ed928b848526a5fc6db4104520020665012826f" -dependencies = [ - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "libp2p-deflate" -version = "0.5.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b0bf5d37692ac90e2bffa436bec26c0b0def6c0cab7ea85ff67a353d58aaa" +checksum = "f09548626b737ed64080fde595e06ce1117795b8b9fc4d2629fa36561c583171" dependencies = [ - "flate2", - "futures 0.1.29", - "libp2p-core", - "tokio-io", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] name = "libp2p-dns" -version = "0.13.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3175fb0fc9016c95c8517a297bbdb5fb6bfbd5665bacd2eb23495d1cbdeb033" +checksum = "3cc186d9a941fd0207cf8f08ef225a735e2d7296258f570155e525f6ee732f87" dependencies = [ - "futures 0.1.29", + "futures 0.3.4", "libp2p-core", "log", - "tokio-dns-unofficial", -] - -[[package]] -name = "libp2p-floodsub" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b360bbaad2560d6b8a905bd63528273d933fe54475a44def47f31e23108b3683" -dependencies = [ - "bs58 0.3.0", - "bytes 0.4.12", - "cuckoofilter", - "fnv", - "futures 0.1.29", - "libp2p-core", - "libp2p-swarm", - "protobuf", - "rand 0.6.5", - "smallvec 0.6.13", - "tokio-io", ] [[package]] name = "libp2p-identify" -version = "0.13.2" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c087bcd044a6f67a994573a92a109487a902a31555e4e63bcc4ae144c45594fe" +checksum = "62f76075b170d908bae616f550ade410d9d27c013fa69042551dbfc757c7c094" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", + "futures 0.3.4", "libp2p-core", "libp2p-swarm", "log", - "parity-multiaddr 0.6.0", - "protobuf", - "smallvec 0.6.13", - "tokio-codec", - "tokio-io", - "unsigned-varint 0.2.3", + "prost", + "prost-build", + "smallvec 1.4.1", "wasm-timer", ] [[package]] name = "libp2p-kad" -version = "0.13.2" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcaf76a5b33b6c0203e85d450ae1855cae6860dc82eb0174ac1fee8bf68f7af5" +checksum = "41d6c1d5100973527ae70d82687465b17049c1b717a7964de38b8e65000878ff" dependencies = [ "arrayvec 0.5.1", - "bytes 0.4.12", + "bytes 0.5.6", "either", "fnv", - "futures 0.1.29", + "futures 0.3.4", + "futures_codec 0.3.4", "libp2p-core", "libp2p-swarm", "log", - "parity-multiaddr 0.6.0", - "parity-multihash 0.2.3", - "protobuf", + "multihash", + "prost", + "prost-build", "rand 0.7.3", - "sha2", - "smallvec 0.6.13", - "tokio-codec", - "tokio-io", + "sha2 0.8.1", + "smallvec 1.4.1", "uint", - "unsigned-varint 0.2.3", + "unsigned-varint 0.3.3", "void", "wasm-timer", ] [[package]] name = "libp2p-mdns" -version = "0.13.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4c2e225a7dfc571c3ad77a0a5ecccc9537afe42d72289ac9f19768567cd677d" +checksum = "7f55b2d4b80986e5bf158270ab23268ec0e7f644ece5436fbaabc5155472f357" dependencies = [ + "async-std", "data-encoding", "dns-parser", - "futures 0.1.29", + "either", + "futures 0.3.4", + "lazy_static", "libp2p-core", "libp2p-swarm", "log", "net2", - "parity-multiaddr 0.6.0", - "rand 0.6.5", - "smallvec 0.6.13", - "tokio-io", - "tokio-reactor", - "tokio-udp", + "rand 0.7.3", + "smallvec 1.4.1", "void", "wasm-timer", ] [[package]] name = "libp2p-mplex" -version = "0.13.0" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2fe584816d993dc0f893396521a3c93191d78a6f28a892b150baa714a12c3e5" +checksum = "be7d913a4cd57de2013257ec73f07d77bfce390b370023e2d59083e5ca079864" dependencies = [ - "bytes 0.4.12", + "bytes 0.5.6", "fnv", - "futures 0.1.29", + "futures 0.3.4", + "futures_codec 0.4.0", "libp2p-core", "log", - "parking_lot 0.8.0", - "tokio-codec", - "tokio-io", - "unsigned-varint 0.2.3", + "parking_lot 0.10.2", + "unsigned-varint 0.4.0", ] [[package]] name = "libp2p-noise" -version = "0.11.1" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50494fcba7cdab08390d72b3cb9d2c72fcf178e6a0c1043855ab259d818b972" +checksum = "a03db664653369f46ee03fcec483a378c20195089bb43a26cb9fb0058009ac88" dependencies = [ - "bytes 0.4.12", - "curve25519-dalek 1.2.3", - "futures 0.1.29", + "curve25519-dalek", + "futures 0.3.4", "lazy_static", "libp2p-core", "log", - "protobuf", + "prost", + "prost-build", "rand 0.7.3", - "ring", + "sha2 0.8.1", "snow", - "tokio-io", + "static_assertions", "x25519-dalek", - "zeroize 1.1.0", + "zeroize", ] [[package]] name = "libp2p-ping" -version = "0.13.1" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b975ad345eb9bb29ddc64670664a50a8ab3e66e28357abb0f83cfc0a9ca2d78" +checksum = "b8dedd34e35a9728d52d59ef36a218e411359a353f9011b2574b86ee790978f6" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", + "futures 0.3.4", "libp2p-core", "libp2p-swarm", "log", - "parity-multiaddr 0.6.0", "rand 0.7.3", - "tokio-io", "void", "wasm-timer", ] [[package]] -name = "libp2p-plaintext" -version = "0.13.1" +name = "libp2p-swarm" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f07be6983e1c00e8f6a5676da54ed3a8cae7fb50f1fb6ea163414613ca656cc" +checksum = "ce53ff4d127cf8b39adf84dbd381ca32d49bd85788cee08e6669da2495993930" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", + "futures 0.3.4", "libp2p-core", "log", - "protobuf", - "rw-stream-sink", - "tokio-io", + "rand 0.7.3", + "smallvec 1.4.1", "void", -] - -[[package]] -name = "libp2p-secio" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04aa6d67a5fb2b36241a1ba54037a13deb2594cf141e43b597ce379521d530a8" -dependencies = [ - "aes-ctr", - "bytes 0.4.12", - "ctr", - "futures 0.1.29", - "hmac", - "js-sys", - "lazy_static", - "libp2p-core", - "log", - "parity-send-wrapper", - "protobuf", - "rand 0.6.5", - "ring", - "rw-stream-sink", - "sha2", - "tokio-codec", - "tokio-io", - "twofish", - "untrusted", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "libp2p-swarm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd55bc9f5f9eac2bb1ff24ca3c8a655810a566ac38c7a6ee1f30aced5a62905b" -dependencies = [ - "futures 0.1.29", - "libp2p-core", - "smallvec 0.6.13", - "tokio-io", - "void", - "wasm-timer", + "wasm-timer", ] [[package]] name = "libp2p-tcp" -version = "0.13.0" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234a7093d05651ab5630db926a4a42ca8978a65bab8c27c2ce2b66b200c76989" +checksum = "9481500c5774c62e8c413e9535b3f33a0e3dbacf2da63b8d3056c686a9df4146" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", + "async-std", + "futures 0.3.4", + "futures-timer 3.0.2", "get_if_addrs", "ipnet", "libp2p-core", "log", - "tokio-io", - "tokio-tcp", - "tokio-timer", -] - -[[package]] -name = "libp2p-uds" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2fe0648967da3e56e4a55055c857c8c48326b66be0047d0e04c8ca60d34630" -dependencies = [ - "futures 0.1.29", - "libp2p-core", - "log", - "tokio-uds", + "socket2", ] [[package]] name = "libp2p-wasm-ext" -version = "0.6.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7b8f2bd81fb356e81352d4513856bc21215ecf91502aa1f55b6449642a9acf" +checksum = "f59fdbb5706f2723ca108c088b1c7a37f735a8c328021f0508007162627e9885" dependencies = [ - "futures 0.1.29", + "futures 0.3.4", "js-sys", "libp2p-core", "parity-send-wrapper", - "tokio-io", "wasm-bindgen", "wasm-bindgen-futures", ] [[package]] name = "libp2p-websocket" -version = "0.13.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d74d4fc229ad7e8d1a973178786bdcd5dadbdd7b9822c4477c8687df6f82f66" +checksum = "085fbe4c05c4116c2164ab4d5a521eb6e00516c444f61b3ee9f68c7b1e53580b" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", + "async-tls", + "bytes 0.5.6", + "either", + "futures 0.3.4", "libp2p-core", "log", + "quicksink", + "rustls", "rw-stream-sink", "soketto", - "tokio-codec", - "tokio-io", - "tokio-rustls", "url 2.1.1", + "webpki", "webpki-roots 0.18.0", ] [[package]] name = "libp2p-yamux" -version = "0.13.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1913eb7dd6eb5515957b6f1770296f6921968db87bc9b985f0e974b6657e1003" +checksum = "8da33e7b5f49c75c6a8afb0b8d1e229f5fa48be9f39bd14cdbc21459a02ac6fc" dependencies = [ - "futures 0.1.29", + "futures 0.3.4", "libp2p-core", - "log", - "tokio-io", + "parking_lot 0.10.2", + "thiserror", "yamux", ] [[package]] name = "librocksdb-sys" -version = "5.18.3" +version = "6.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19778314deaa7048f2ea7d07b8aa12e1c227acebe975a37eeab6d2f8c74e41b" +checksum = "883213ae3d09bfc3d104aefe94b25ebb183b6f4d3a515b23b14817e1f4854005" dependencies = [ "bindgen", "cc", @@ -2288,10 +2657,10 @@ checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" dependencies = [ "arrayref", "crunchy", - "digest", + "digest 0.8.1", "hmac-drbg", "rand 0.7.3", - "sha2", + "sha2 0.8.1", "subtle 2.2.2", "typenum", ] @@ -2310,45 +2679,37 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" [[package]] name = "linked_hash_set" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7c91c4c7bbeb4f2f7c4e5be11e6a05bd6830bc37249c47ce1ad86ad453ff9c" +checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" dependencies = [ "linked-hash-map", ] [[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -dependencies = [ - "owning_ref", - "scopeguard 0.3.3", -] - -[[package]] -name = "lock_api" -version = "0.2.0" +name = "linregress" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" +checksum = "9290cf6f928576eeb9c096c6fad9d8d452a0a1a70a2bbffa6e36064eedc0aac9" dependencies = [ - "scopeguard 1.1.0", + "failure", + "nalgebra", + "statrs", ] [[package]] name = "lock_api" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" dependencies = [ - "scopeguard 1.1.0", + "scopeguard", ] [[package]] @@ -2361,23 +2722,12 @@ dependencies = [ ] [[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "malloc_size_of_derive" -version = "0.1.1" +name = "lru" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" +checksum = "0609345ddee5badacf857d4f547e0e5a2e987db77085c24cd887f73573a04237" dependencies = [ - "proc-macro2 1.0.10", - "syn 1.0.17", - "synstructure", + "hashbrown 0.6.3", ] [[package]] @@ -2386,6 +2736,15 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +[[package]] +name = "matrixmultiply" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4f7ec66360130972f34830bfad9ef05c6610a43938a467bcc9ab9369ab3478f" +dependencies = [ + "rawpointer", +] + [[package]] name = "maybe-uninit" version = "2.0.0" @@ -2398,20 +2757,30 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi 0.3.8", +] + [[package]] name = "memoffset" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" +checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" dependencies = [ "autocfg 1.0.0", ] [[package]] name = "memory-db" -version = "0.15.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dabfe0a8c69954ae3bcfc5fc14260a85fb80e1bf9f86a155f668d10a67e93dd" +checksum = "fb2999ff7a65d5a1d72172f6d51fa2ea03024b51aee709ba5ff81c3c629a2410" dependencies = [ "ahash", "hash-db", @@ -2427,30 +2796,30 @@ checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" [[package]] name = "merlin" -version = "1.3.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" +checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" dependencies = [ - "byteorder 1.3.4", + "byteorder", "keccak", - "rand_core 0.4.2", - "zeroize 1.1.0", + "rand_core 0.5.1", + "zeroize", ] [[package]] name = "miniz_oxide" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" +checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" dependencies = [ - "adler32", + "adler", ] [[package]] name = "mio" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" dependencies = [ "cfg-if", "fuchsia-zircon", @@ -2459,7 +2828,7 @@ dependencies = [ "kernel32-sys", "libc", "log", - "miow", + "miow 0.2.1", "net2", "slab", "winapi 0.2.8", @@ -2477,6 +2846,18 @@ dependencies = [ "slab", ] +[[package]] +name = "mio-named-pipes" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" +dependencies = [ + "log", + "mio", + "miow 0.3.5", + "winapi 0.3.8", +] + [[package]] name = "mio-uds" version = "0.6.7" @@ -2500,6 +2881,16 @@ dependencies = [ "ws2_32-sys", ] +[[package]] +name = "miow" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +dependencies = [ + "socket2", + "winapi 0.3.8", +] + [[package]] name = "mockall" version = "0.7.1" @@ -2522,29 +2913,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e14e8643cb12103b56efb963e5f9640b69b0f7bdcc460002092df4b0e959f" dependencies = [ "cfg-if", - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", ] +[[package]] +name = "multihash" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75db05d738947aa5389863aadafbcf2e509d7ba099dc2ddcdf4fc66bf7a9e03" +dependencies = [ + "blake2b_simd", + "blake2s_simd", + "digest 0.8.1", + "sha-1", + "sha2 0.8.1", + "sha3", + "unsigned-varint 0.3.3", +] + [[package]] name = "multimap" -version = "0.4.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04b9f127583ed176e163fb9ec6f3e793b87e21deedd5734a69386a18a0151" +checksum = "d8883adfde9756c1d30b0f519c9b8c502a94b41ac62f696453c37c7fc0a958ce" [[package]] name = "multistream-select" -version = "0.6.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc3ef54aab1b2e37e911bcb99e376dbe4c1e0710afcdb8428608e4f993b39c47" +checksum = "c9157e87afbc2ef0d84cc0345423d715f445edde00141c93721c162de35a05e5" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", + "bytes 0.5.6", + "futures 0.3.4", "log", - "smallvec 0.6.13", - "tokio-io", - "unsigned-varint 0.2.3", + "pin-project", + "smallvec 1.4.1", + "unsigned-varint 0.4.0", +] + +[[package]] +name = "nalgebra" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaa9fddbc34c8c35dd2108515587b8ce0cab396f17977b8c738568e4edb521a2" +dependencies = [ + "alga", + "approx", + "generic-array 0.12.3", + "matrixmultiply", + "num-complex", + "num-rational", + "num-traits 0.2.11", + "rand 0.6.5", + "typenum", ] [[package]] @@ -2558,15 +2981,29 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.33" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" dependencies = [ "cfg-if", "libc", "winapi 0.3.8", ] +[[package]] +name = "netstat2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29449d242064c48d3057a194b049a2bdcccadda16faa18a91468677b44e8d422" +dependencies = [ + "bitflags", + "byteorder", + "enum-primitive-derive", + "libc", + "num-traits 0.2.11", + "thiserror", +] + [[package]] name = "nix" version = "0.17.0" @@ -2580,6 +3017,23 @@ dependencies = [ "void", ] +[[package]] +name = "node-inspect" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "log", + "parity-scale-codec", + "sc-cli", + "sc-client-api", + "sc-service", + "sp-blockchain", + "sp-core", + "sp-runtime", + "structopt", +] + [[package]] name = "nodrop" version = "0.1.14" @@ -2588,18 +3042,18 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" [[package]] name = "nohash-hasher" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721a2bf1c26159ebf17e0a980bc4ce61f4b2fec5ec3b42d42fddd7a84a9e538f" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "nom" -version = "4.2.3" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" dependencies = [ "memchr", - "version_check 0.1.5", + "version_check", ] [[package]] @@ -2608,6 +3062,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "ntapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "num-bigint" version = "0.2.6" @@ -2616,7 +3079,17 @@ checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ "autocfg 1.0.0", "num-integer", - "num-traits", + "num-traits 0.2.11", +] + +[[package]] +name = "num-complex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" +dependencies = [ + "autocfg 1.0.0", + "num-traits 0.2.11", ] [[package]] @@ -2626,7 +3099,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" dependencies = [ "autocfg 1.0.0", - "num-traits", + "num-traits 0.2.11", ] [[package]] @@ -2638,7 +3111,16 @@ dependencies = [ "autocfg 1.0.0", "num-bigint", "num-integer", - "num-traits", + "num-traits 0.2.11", +] + +[[package]] +name = "num-traits" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +dependencies = [ + "num-traits 0.2.11", ] [[package]] @@ -2648,70 +3130,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" dependencies = [ "autocfg 1.0.0", + "libm", ] [[package]] name = "num_cpus" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ "hermit-abi", "libc", ] [[package]] -name = "num_enum" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca565a7df06f3d4b485494f25ba05da1435950f4dc263440eda7a6fa9b8e36e4" -dependencies = [ - "derivative", - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "ole32-sys" -version = "0.2.0" +name = "once_cell" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" +checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "parking_lot 0.10.2", ] [[package]] -name = "once_cell" -version = "0.1.8" +name = "opaque-debug" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" -dependencies = [ - "parking_lot 0.7.1", -] +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] -name = "once_cell" -version = "0.2.4" +name = "opaque-debug" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "opaque-debug" -version = "0.2.3" +name = "openssl-probe" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "owning_ref" @@ -2723,2871 +3180,3607 @@ dependencies = [ ] [[package]] -name = "parity-bytes" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" - -[[package]] -name = "parity-multiaddr" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" +name = "pallet-authority-discovery" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "arrayref", - "bs58 0.2.5", - "byteorder 1.3.4", - "bytes 0.4.12", - "data-encoding", - "parity-multihash 0.1.3", - "percent-encoding 1.0.1", + "frame-support", + "frame-system", + "pallet-session", + "parity-scale-codec", "serde", - "unsigned-varint 0.2.3", - "url 1.7.2", + "sp-application-crypto", + "sp-authority-discovery", + "sp-runtime", + "sp-std", ] [[package]] -name = "parity-multiaddr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82afcb7461eae5d122543d8be1c57d306ed89af2d6ff7f8b0f5a3cc8f7e511bc" +name = "pallet-authorship" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "arrayref", - "bs58 0.3.0", - "byteorder 1.3.4", - "bytes 0.4.12", - "data-encoding", - "parity-multihash 0.2.3", - "percent-encoding 2.1.0", - "serde", - "unsigned-varint 0.2.3", - "url 2.1.1", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-authorship", + "sp-inherents", + "sp-runtime", + "sp-std", ] [[package]] -name = "parity-multihash" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3" +name = "pallet-babe" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "blake2", - "bytes 0.4.12", - "rand 0.6.5", - "sha-1", - "sha2", - "sha3", - "unsigned-varint 0.2.3", + "frame-support", + "frame-system", + "pallet-session", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-application-crypto", + "sp-consensus-babe", + "sp-consensus-vrf", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", + "sp-timestamp", ] [[package]] -name = "parity-multihash" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a1cd2ba02391b81367bec529fb209019d718684fdc8ad6a712c2b536e46f775" +name = "pallet-balances" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "blake2", - "bytes 0.5.4", - "rand 0.7.3", - "sha-1", - "sha2", - "sha3", - "unsigned-varint 0.3.2", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "serde", + "sp-runtime", + "sp-std", ] [[package]] -name = "parity-scale-codec" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329c8f7f4244ddb5c37c103641027a76c530e65e8e4b8240b29f81ea40508b17" +name = "pallet-collective" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "arrayvec 0.5.1", - "bitvec", - "byte-slice-cast", - "parity-scale-codec-derive", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "parity-scale-codec-derive" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0ec292e92e8ec7c58e576adacc1e3f399c597c8f263c42f18420abe58e7245" +name = "pallet-common" +version = "3.0.0" dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "frame-support", + "frame-system", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-runtime", ] [[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" +name = "pallet-content-working-group" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-common", + "pallet-hiring", + "pallet-membership", + "pallet-recurring-reward", + "pallet-stake", + "pallet-timestamp", + "pallet-token-mint", + "pallet-versioned-store", + "pallet-versioned-store-permissions", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] [[package]] -name = "parity-util-mem" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" +name = "pallet-finality-tracker" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "cfg-if", - "malloc_size_of_derive", - "winapi 0.3.8", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "serde", + "sp-finality-tracker", + "sp-inherents", + "sp-runtime", + "sp-std", ] [[package]] -name = "parity-wasm" -version = "0.40.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" +name = "pallet-forum" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-common", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] [[package]] -name = "parking_lot" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" +name = "pallet-governance" +version = "3.0.0" dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.3.1", + "frame-support", + "frame-system", + "pallet-balances", + "pallet-common", + "pallet-membership", + "pallet-recurring-reward", + "pallet-timestamp", + "pallet-token-mint", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +name = "pallet-grandpa" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.4.0", + "frame-support", + "frame-system", + "pallet-finality-tracker", + "pallet-session", + "parity-scale-codec", + "serde", + "sp-application-crypto", + "sp-core", + "sp-finality-grandpa", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", ] [[package]] -name = "parking_lot" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" +name = "pallet-hiring" +version = "3.0.0" dependencies = [ - "lock_api 0.2.0", - "parking_lot_core 0.5.0", - "rustc_version", + "frame-support", + "frame-system", + "mockall", + "pallet-balances", + "pallet-stake", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +name = "pallet-im-online" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "lock_api 0.3.3", - "parking_lot_core 0.6.2", - "rustc_version", + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "serde", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", ] [[package]] -name = "parking_lot" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" +name = "pallet-membership" +version = "3.0.0" dependencies = [ - "lock_api 0.3.3", - "parking_lot_core 0.7.0", + "frame-support", + "frame-system", + "pallet-balances", + "pallet-common", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "parking_lot_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" +name = "pallet-memo" +version = "3.0.0" dependencies = [ - "libc", - "rand 0.5.6", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", + "frame-support", + "frame-system", + "pallet-common", + "parity-scale-codec", + "sp-arithmetic", + "sp-std", ] [[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +name = "pallet-offences" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "libc", - "rand 0.6.5", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", + "frame-support", + "frame-system", + "pallet-balances", + "parity-scale-codec", + "serde", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-offences-benchmarking" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-im-online", + "pallet-offences", + "pallet-session", + "pallet-staking", + "parity-scale-codec", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-proposals-codex" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-common", + "pallet-content-working-group", + "pallet-governance", + "pallet-hiring", + "pallet-membership", + "pallet-proposals-discussion", + "pallet-proposals-engine", + "pallet-recurring-reward", + "pallet-stake", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-timestamp", + "pallet-token-mint", + "pallet-versioned-store", + "pallet-versioned-store-permissions", + "pallet-working-group", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", ] [[package]] -name = "parking_lot_core" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" +name = "pallet-proposals-discussion" +version = "3.0.0" dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "rand 0.6.5", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", + "frame-support", + "frame-system", + "pallet-balances", + "pallet-common", + "pallet-membership", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +name = "pallet-proposals-engine" +version = "3.0.0" dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", + "frame-support", + "frame-system", + "mockall", + "pallet-balances", + "pallet-common", + "pallet-membership", + "pallet-stake", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "parking_lot_core" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" +name = "pallet-randomness-collective-flip" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "smallvec 1.2.0", - "winapi 0.3.8", + "frame-support", + "frame-system", + "parity-scale-codec", + "safe-mix", + "sp-runtime", + "sp-std", ] [[package]] -name = "paste" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4fb1930692d1b6a9cfabdde3d06ea0a7d186518e2f4d67660d8970e2fa647a" +name = "pallet-recurring-reward" +version = "3.0.0" dependencies = [ - "paste-impl", - "proc-macro-hack 0.5.15", + "frame-support", + "frame-system", + "pallet-balances", + "pallet-token-mint", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", +] + +[[package]] +name = "pallet-service-discovery" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-common", + "pallet-hiring", + "pallet-membership", + "pallet-recurring-reward", + "pallet-stake", + "pallet-timestamp", + "pallet-token-mint", + "pallet-working-group", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "paste-impl" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62486e111e571b1e93b710b61e8f493c0013be39629b714cb166bdb06aa5a8a" +name = "pallet-session" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "proc-macro-hack 0.5.15", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-trie", ] [[package]] -name = "pbkdf2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" +name = "pallet-session-benchmarking" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "byteorder 1.3.4", - "crypto-mac", + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-session", + "pallet-staking", + "sp-runtime", + "sp-std", ] [[package]] -name = "pdqselect" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec91767ecc0a0bbe558ce8c9da33c068066c57ecc8bb8477ef8c1ad3ef77c27" +name = "pallet-stake" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-timestamp", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] [[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +name = "pallet-staking" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "rand_chacha 0.2.2", + "serde", + "sp-application-crypto", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-staking", + "sp-std", + "static_assertions", +] [[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +name = "pallet-staking-reward-curve" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] [[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +name = "pallet-storage" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-common", + "pallet-hiring", + "pallet-membership", + "pallet-recurring-reward", + "pallet-stake", + "pallet-timestamp", + "pallet-token-mint", + "pallet-working-group", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] [[package]] -name = "petgraph" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" +name = "pallet-sudo" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "fixedbitset", + "frame-support", + "frame-system", + "parity-scale-codec", + "serde", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "pin-utils" -version = "0.1.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" +name = "pallet-timestamp" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "serde", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-std", + "sp-timestamp", +] [[package]] -name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" +name = "pallet-token-mint" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", +] [[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +name = "pallet-transaction-payment" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "pallet-transaction-payment-rpc-runtime-api", + "parity-scale-codec", + "serde", + "smallvec 1.4.1", + "sp-runtime", + "sp-std", +] [[package]] -name = "predicates" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030" +name = "pallet-transaction-payment-rpc" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "difference", - "float-cmp", - "normalize-line-endings", - "predicates-core", - "regex", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "pallet-transaction-payment-rpc-runtime-api", + "parity-scale-codec", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", ] [[package]] -name = "predicates-core" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" +name = "pallet-transaction-payment-rpc-runtime-api" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "parity-scale-codec", + "serde", + "sp-api", + "sp-runtime", + "sp-std", +] [[package]] -name = "predicates-tree" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +name = "pallet-versioned-store" +version = "3.0.0" dependencies = [ - "predicates-core", - "treeline", + "frame-support", + "frame-system", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "primitive-types" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4336f4f5d5524fa60bcbd6fe626f9223d8142a50e7053e979acdf0da41ab975" +name = "pallet-versioned-store-permissions" +version = "3.0.0" dependencies = [ - "fixed-hash", - "impl-codec", - "impl-serde 0.3.0", - "uint", + "frame-support", + "frame-system", + "pallet-timestamp", + "pallet-versioned-store", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-working-group" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-common", + "pallet-hiring", + "pallet-membership", + "pallet-recurring-reward", + "pallet-stake", + "pallet-timestamp", + "pallet-token-mint", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] -name = "proc-macro-crate" -version = "0.1.4" +name = "parity-db" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" +checksum = "00d595e372d119261593297debbe4193811a4dc811d2a1ccbb8caaa6666ad7ab" dependencies = [ - "toml", + "blake2-rfc", + "crc32fast", + "libc", + "log", + "memmap", + "parking_lot 0.10.2", ] [[package]] -name = "proc-macro-error" -version = "0.2.6" +name = "parity-multiaddr" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097" +checksum = "f77055f9e81921a8cc7bebeb6cded3d128931d51f1e3dd6251f0770a6d431477" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "parity-multihash", + "percent-encoding 2.1.0", + "serde", + "static_assertions", + "unsigned-varint 0.3.3", + "url 2.1.1", ] [[package]] -name = "proc-macro-hack" -version = "0.4.2" +name = "parity-multiaddr" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463bf29e7f11344e58c9e01f171470ab15c925c6822ad75028cc1c0e1d1eb63b" +checksum = "cc20af3143a62c16e7c9e92ea5c6ae49f7d271d97d4d8fe73afc28f0514a3d0f" dependencies = [ - "proc-macro-hack-impl", + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding 2.1.0", + "serde", + "static_assertions", + "unsigned-varint 0.4.0", + "url 2.1.1", ] [[package]] -name = "proc-macro-hack" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" - -[[package]] -name = "proc-macro-hack-impl" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c47dcb1594802de8c02f3b899e2018c78291168a22c281be21ea0fb4796842" - -[[package]] -name = "proc-macro-nested" -version = "0.1.4" +name = "parity-multihash" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" +checksum = "7a1cd2ba02391b81367bec529fb209019d718684fdc8ad6a712c2b536e46f775" +dependencies = [ + "blake2 0.8.1", + "bytes 0.5.6", + "rand 0.7.3", + "sha-1", + "sha2 0.8.1", + "sha3", + "unsigned-varint 0.3.3", +] [[package]] -name = "proc-macro2" -version = "0.4.30" +name = "parity-scale-codec" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +checksum = "a74f02beb35d47e0706155c9eac554b50c671e0d868fe8296bcdf44a9a4847bf" dependencies = [ - "unicode-xid 0.1.0", + "arrayvec 0.5.1", + "bitvec", + "byte-slice-cast", + "parity-scale-codec-derive", + "serde", ] [[package]] -name = "proc-macro2" -version = "1.0.10" +name = "parity-scale-codec-derive" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" +checksum = "5a0ec292e92e8ec7c58e576adacc1e3f399c597c8f263c42f18420abe58e7245" dependencies = [ - "unicode-xid 0.2.0", + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "prost" -version = "0.5.0" +name = "parity-send-wrapper" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d14b1c185652833d24aaad41c5832b0be5616a590227c1fbff57c616754b23" -dependencies = [ - "byteorder 1.3.4", - "bytes 0.4.12", - "prost-derive", -] +checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" [[package]] -name = "prost-build" -version = "0.5.0" +name = "parity-tokio-ipc" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb788126ea840817128183f8f603dce02cb7aea25c2a0b764359d8e20010702e" +checksum = "1e57fea504fea33f9fbb5f49f378359030e7e026a6ab849bb9e8f0787376f1bf" dependencies = [ "bytes 0.4.12", - "heck", - "itertools", + "futures 0.1.29", + "libc", "log", - "multimap", - "petgraph", - "prost", - "prost-types", - "tempfile", - "which", + "mio-named-pipes", + "miow 0.3.5", + "rand 0.7.3", + "tokio 0.1.22", + "tokio-named-pipes", + "tokio-uds", + "winapi 0.3.8", ] [[package]] -name = "prost-derive" -version = "0.5.0" +name = "parity-util-mem" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e7dc378b94ac374644181a2247cebf59a6ec1c88b49ac77f3a94b86b79d0e11" +checksum = "2c6e2583649a3ca84894d1d71da249abcfda54d5aca24733d72ca10d0f02361c" dependencies = [ - "failure", - "itertools", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", + "cfg-if", + "impl-trait-for-tuples", + "parity-util-mem-derive", + "parking_lot 0.10.2", + "primitive-types", + "smallvec 1.4.1", + "winapi 0.3.8", ] [[package]] -name = "prost-types" -version = "0.5.0" +name = "parity-util-mem-derive" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de482a366941c8d56d19b650fac09ca08508f2a696119ee7513ad590c8bac6f" +checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ - "bytes 0.4.12", - "prost", + "proc-macro2", + "syn 1.0.17", + "synstructure", ] [[package]] -name = "protobuf" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20" - -[[package]] -name = "quick-error" -version = "1.2.3" +name = "parity-wasm" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" [[package]] -name = "quote" -version = "0.6.13" +name = "parking_lot" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" dependencies = [ - "proc-macro2 0.4.30", + "lock_api", + "parking_lot_core 0.6.2", + "rustc_version", ] [[package]] -name = "quote" -version = "1.0.3" +name = "parking_lot" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ - "proc-macro2 1.0.10", + "lock_api", + "parking_lot_core 0.7.2", ] [[package]] -name = "radium" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" - -[[package]] -name = "rand" -version = "0.3.23" +name = "parking_lot_core" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" dependencies = [ + "cfg-if", + "cloudabi", "libc", - "rand 0.4.6", + "redox_syscall", + "rustc_version", + "smallvec 0.6.13", + "winapi 0.3.8", ] [[package]] -name = "rand" -version = "0.4.6" +name = "parking_lot_core" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ - "fuchsia-cprng", + "cfg-if", + "cloudabi", "libc", - "rand_core 0.3.1", - "rdrand", + "redox_syscall", + "smallvec 1.4.1", "winapi 0.3.8", ] [[package]] -name = "rand" -version = "0.5.6" +name = "paste" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" +checksum = "ab4fb1930692d1b6a9cfabdde3d06ea0a7d186518e2f4d67660d8970e2fa647a" dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.8", + "paste-impl", + "proc-macro-hack", ] [[package]] -name = "rand" -version = "0.6.5" +name = "paste-impl" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +checksum = "a62486e111e571b1e93b710b61e8f493c0013be39629b714cb166bdb06aa5a8a" 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 0.3.8", + "proc-macro-hack", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "rand" -version = "0.7.3" +name = "pbkdf2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" dependencies = [ - "getrandom", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", + "byteorder", + "crypto-mac 0.7.0", ] [[package]] -name = "rand_chacha" -version = "0.1.1" +name = "pdqselect" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", -] +checksum = "4ec91767ecc0a0bbe558ce8c9da33c068066c57ecc8bb8477ef8c1ad3ef77c27" [[package]] -name = "rand_chacha" -version = "0.2.2" +name = "peeking_take_while" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] -name = "rand_core" -version = "0.3.1" +name = "percent-encoding" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" [[package]] -name = "rand_core" -version = "0.4.2" +name = "percent-encoding" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] -name = "rand_core" +name = "petgraph" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" dependencies = [ - "getrandom", + "fixedbitset", + "indexmap", ] [[package]] -name = "rand_hc" -version = "0.1.0" +name = "pin-project" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17" dependencies = [ - "rand_core 0.3.1", + "pin-project-internal", ] [[package]] -name = "rand_hc" -version = "0.2.0" +name = "pin-project-internal" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" dependencies = [ - "rand_core 0.5.1", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "rand_isaac" -version = "0.1.1" +name = "pin-project-lite" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] +checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" [[package]] -name = "rand_jitter" -version = "0.1.4" +name = "pin-utils" +version = "0.1.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.8", -] +checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" [[package]] -name = "rand_os" -version = "0.1.3" +name = "pkg-config" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.8", -] +checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" [[package]] -name = "rand_pcg" -version = "0.1.2" +name = "platforms" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] +checksum = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" [[package]] -name = "rand_xorshift" -version = "0.1.1" +name = "poly1305" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +checksum = "d9b42192ab143ed7619bf888a7f9c6733a9a2153b218e2cd557cfdb52fbf9bb1" dependencies = [ - "rand_core 0.3.1", + "universal-hash", ] [[package]] -name = "rayon" -version = "1.3.0" +name = "polyval" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" +checksum = "d9a50142b55ab3ed0e9f68dfb3709f1d90d29da24e91033f28b96330643107dc" dependencies = [ - "crossbeam-deque", - "either", - "rayon-core", + "cfg-if", + "universal-hash", ] [[package]] -name = "rayon-core" -version = "1.7.0" +name = "ppv-lite86" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" -dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils 0.7.2", - "lazy_static", - "num_cpus", -] +checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" [[package]] -name = "rdrand" -version = "0.4.0" +name = "predicates" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +checksum = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030" dependencies = [ - "rand_core 0.3.1", + "difference", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", ] [[package]] -name = "redox_syscall" -version = "0.1.56" +name = "predicates-core" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" [[package]] -name = "regex" -version = "1.3.6" +name = "predicates-tree" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" +checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local 1.0.1", + "predicates-core", + "treeline", ] [[package]] -name = "regex-syntax" -version = "0.6.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" - -[[package]] -name = "remove_dir_all" -version = "0.5.2" +name = "primitive-types" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +checksum = "d3dedac218327b6b55fff5ef05f63ce5127024e1a36342836da7e92cbfac4531" dependencies = [ - "winapi 0.3.8", + "fixed-hash", + "impl-codec", + "impl-serde 0.3.0", + "uint", ] [[package]] -name = "ring" -version = "0.16.12" +name = "proc-macro-crate" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" +checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" dependencies = [ - "cc", - "lazy_static", - "libc", - "spin", - "untrusted", - "web-sys", - "winapi 0.3.8", + "toml", ] [[package]] -name = "rocksdb" -version = "0.11.0" +name = "proc-macro-error" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1651697fefd273bfb4fd69466cc2a9d20de557a0213b97233b22b5e95924b5e" +checksum = "fc175e9777c3116627248584e8f8b3e2987405cabe1c0adf7d1dd28f09dc7880" dependencies = [ - "libc", - "librocksdb-sys", + "proc-macro-error-attr", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", + "version_check", ] [[package]] -name = "rpassword" -version = "4.0.5" +name = "proc-macro-error-attr" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99371657d3c8e4d816fb6221db98fa408242b0b53bac08f8676a41f8554fe99f" +checksum = "3cc9795ca17eb581285ec44936da7fc2335a3f34f2ddd13118b6f4d515435c50" dependencies = [ - "libc", - "winapi 0.3.8", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", + "syn-mid", + "version_check", ] [[package]] -name = "rustc-demangle" -version = "0.1.16" +name = "proc-macro-hack" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" [[package]] -name = "rustc-hex" -version = "2.1.0" +name = "proc-macro-nested" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" [[package]] -name = "rustc_version" -version = "0.2.3" +name = "proc-macro2" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ - "semver", + "unicode-xid 0.2.0", ] [[package]] -name = "rustls" -version = "0.16.0" +name = "procfs" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" +checksum = "c434e93ef69c216e68e4f417c927b4f31502c3560b72cfdb6827e2321c5c6b3e" dependencies = [ - "base64", - "log", - "ring", - "sct", - "webpki", + "bitflags", + "byteorder", + "chrono", + "hex", + "lazy_static", + "libc", + "libflate", ] [[package]] -name = "rw-stream-sink" -version = "0.1.2" +name = "prometheus" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" +checksum = "b0575e258dab62268e7236d7307caa38848acbda7ec7ab87bd9093791e999d20" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "tokio-io", + "cfg-if", + "fnv", + "lazy_static", + "protobuf", + "spin", + "thiserror", ] [[package]] -name = "ryu" -version = "1.0.3" +name = "prost" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" +checksum = "ce49aefe0a6144a45de32927c77bd2859a5f7677b55f220ae5b744e87389c212" +dependencies = [ + "bytes 0.5.6", + "prost-derive", +] [[package]] -name = "safe-mix" -version = "1.0.1" +name = "prost-build" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" +checksum = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26" dependencies = [ - "rustc_version", + "bytes 0.5.6", + "heck", + "itertools 0.8.2", + "log", + "multimap", + "petgraph", + "prost", + "prost-types", + "tempfile", + "which", ] [[package]] -name = "schnorrkel" -version = "0.8.5" +name = "prost-derive" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3" +checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72" dependencies = [ - "curve25519-dalek 1.2.3", - "failure", - "merlin", - "rand 0.6.5", - "rand_core 0.4.2", - "rand_os", - "sha2", - "subtle 2.2.2", - "zeroize 0.9.3", + "anyhow", + "itertools 0.8.2", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "scopeguard" -version = "0.3.3" +name = "prost-types" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +checksum = "1834f67c0697c001304b75be76f67add9c89742eda3a085ad8ee0bb38c3417aa" +dependencies = [ + "bytes 0.5.6", + "prost", +] [[package]] -name = "scopeguard" -version = "1.1.0" +name = "protobuf" +version = "2.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "d883f78645c21b7281d21305181aa1f4dd9e9363e7cf2566c93121552cff003e" [[package]] -name = "sct" -version = "0.6.0" +name = "quick-error" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" -dependencies = [ - "ring", - "untrusted", -] +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] -name = "semver" -version = "0.9.0" +name = "quicksink" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858" dependencies = [ - "semver-parser", + "futures-core", + "futures-sink", + "pin-project-lite", ] [[package]] -name = "semver-parser" -version = "0.7.0" +name = "quote" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] -name = "send_wrapper" -version = "0.2.0" +name = "quote" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] [[package]] -name = "serde" -version = "1.0.106" +name = "radium" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" -dependencies = [ - "serde_derive", -] +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" [[package]] -name = "serde_derive" -version = "1.0.106" +name = "rand" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" +checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "libc", + "rand 0.4.6", ] [[package]] -name = "serde_json" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" dependencies = [ - "itoa", - "ryu", - "serde", + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi 0.3.8", ] [[package]] -name = "sha-1" -version = "0.8.2" +name = "rand" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "winapi 0.3.8", ] [[package]] -name = "sha1" -version = "0.6.0" +name = "rand" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" +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 0.1.2", + "rand_xorshift", + "winapi 0.3.8", +] [[package]] -name = "sha2" -version = "0.8.1" +name = "rand" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", + "getrandom", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", + "rand_pcg 0.2.1", ] [[package]] -name = "sha3" -version = "0.8.2" +name = "rand_chacha" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" dependencies = [ - "block-buffer", - "byte-tools", - "digest", - "keccak", - "opaque-debug", + "autocfg 0.1.7", + "rand_core 0.3.1", ] [[package]] -name = "shell32-sys" -version = "0.1.2" +name = "rand_chacha" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] -name = "slab" +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 = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" [[package]] -name = "slog" -version = "2.5.2" +name = "rand_core" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "erased-serde", + "getrandom", ] [[package]] -name = "slog-async" -version = "2.3.0" -source = "git+https://github.com/paritytech/slog-async#0329dc74feb3afe93d0cd2533a472b7ceab44aaf" +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" dependencies = [ - "crossbeam-channel", - "slog", - "take_mut", - "thread_local 0.3.6", + "rand_core 0.3.1", ] [[package]] -name = "slog-json" -version = "2.3.0" +name = "rand_hc" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "chrono", - "erased-serde", - "serde", - "serde_json", - "slog", + "rand_core 0.5.1", ] [[package]] -name = "slog-scope" -version = "4.3.0" +name = "rand_isaac" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c44c89dd8b0ae4537d1ae318353eaf7840b4869c536e31c41e963d1ea523ee6" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" dependencies = [ - "arc-swap", - "lazy_static", - "slog", + "rand_core 0.3.1", ] [[package]] -name = "slog_derive" -version = "0.1.1" +name = "rand_jitter" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eff3b513cf2e0d1a60e1aba152dc72bedc5b05585722bb3cebd7bcb1e31b98f" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", + "libc", + "rand_core 0.4.2", + "winapi 0.3.8", ] [[package]] -name = "smallvec" -version = "0.6.13" +name = "rand_os" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" dependencies = [ - "maybe-uninit", + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "wasm-bindgen", + "winapi 0.3.8", ] [[package]] -name = "smallvec" -version = "1.2.0" +name = "rand_pcg" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.4.2", +] [[package]] -name = "snow" -version = "0.6.2" +name = "rand_pcg" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb767eee7d257ba202f0b9b08673bc13b22281632ef45267b19f13100accd2f" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "arrayref", "rand_core 0.5.1", - "ring", - "rustc_version", - "subtle 2.2.2", ] [[package]] -name = "soketto" -version = "0.2.3" +name = "rand_xorshift" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bceb1a3a15232d013d9a3b7cac9e5ce8e2313f348f01d4bc1097e5e53aa07095" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" dependencies = [ - "base64", - "bytes 0.4.12", - "flate2", - "futures 0.1.29", - "http", - "httparse", - "log", - "rand 0.6.5", - "sha1", - "smallvec 0.6.13", - "tokio-codec", - "tokio-io", + "rand_core 0.3.1", ] [[package]] -name = "spin" -version = "0.5.2" +name = "rawpointer" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] -name = "sr-api-macros" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rayon" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" dependencies = [ - "blake2-rfc", - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "autocfg 1.0.0", + "crossbeam-deque", + "either", + "rayon-core", ] [[package]] -name = "sr-arithmetic" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rayon-core" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "serde", - "sr-std", - "substrate-debug-derive", + "crossbeam-deque", + "crossbeam-queue", + "crossbeam-utils", + "lazy_static", + "num_cpus", ] [[package]] -name = "sr-io" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" dependencies = [ - "hash-db", - "libsecp256k1", - "log", - "parity-scale-codec", - "rustc_version", - "sr-std", - "substrate-externalities", - "substrate-primitives", - "substrate-state-machine", - "substrate-trie", - "tiny-keccak", + "rand_core 0.3.1", ] [[package]] -name = "sr-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + +[[package]] +name = "redox_users" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" 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", + "getrandom", + "redox_syscall", + "rust-argon2", ] [[package]] -name = "sr-staking-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "ref-cast" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "745c1787167ddae5569661d5ffb8b25ae5fedbf46717eaa92d652221cec72623" dependencies = [ - "parity-scale-codec", - "sr-primitives", - "sr-std", + "ref-cast-impl", ] [[package]] -name = "sr-std" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "ref-cast-impl" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144" dependencies = [ - "rustc_version", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "sr-version" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "regex" +version = "1.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" dependencies = [ - "impl-serde 0.2.3", - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", ] [[package]] -name = "srml-authority-discovery" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-session", - "srml-support", - "srml-system", - "substrate-application-crypto", - "substrate-primitives", -] +name = "regex-syntax" +version = "0.6.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" [[package]] -name = "srml-authorship" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-inherents", - "substrate-primitives", + "winapi 0.3.8", ] [[package]] -name = "srml-babe" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rental" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8545debe98b2b139fb04cad8618b530e9b07c152d99a5de83c860b877d67847f" dependencies = [ - "hex-literal 0.2.1", - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-session", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-consensus-babe-primitives", - "substrate-inherents", + "rental-impl", + "stable_deref_trait", ] [[package]] -name = "srml-balances" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rental-impl" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-keyring", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "srml-executive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "ring" +version = "0.16.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.8", ] [[package]] -name = "srml-finality-tracker" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-inherents", -] +name = "rle-decode-fast" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" [[package]] -name = "srml-grandpa" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rocksdb" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61aa17a99a2413cd71c1106691bf59dad7de0cd5099127f90e9d99c429c40d4a" dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-finality-tracker", - "srml-session", - "srml-support", - "srml-system", - "substrate-finality-grandpa-primitives", - "substrate-primitives", + "libc", + "librocksdb-sys", ] [[package]] -name = "srml-im-online" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rpassword" +version = "4.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99371657d3c8e4d816fb6221db98fa408242b0b53bac08f8676a41f8554fe99f" dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-authorship", - "srml-session", - "srml-support", - "srml-system", - "substrate-application-crypto", - "substrate-primitives", + "libc", + "winapi 0.3.8", ] [[package]] -name = "srml-indices" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rust-argon2" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-keyring", - "substrate-primitives", + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", ] [[package]] -name = "srml-metadata" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-std", - "substrate-primitives", -] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" [[package]] -name = "srml-offences" -version = "1.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", + "semver", ] [[package]] -name = "srml-randomness-collective-flip" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rustls" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1" dependencies = [ - "parity-scale-codec", - "safe-mix", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", + "base64", + "log", + "ring", + "sct", + "webpki", ] [[package]] -name = "srml-session" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rustls-native-certs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75ffeb84a6bd9d014713119542ce415db3a3e4748f0bfce1e1416cd224a23a5" 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", + "openssl-probe", + "rustls", + "schannel", + "security-framework", ] [[package]] -name = "srml-staking" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "rw-stream-sink" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" 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", + "futures 0.3.4", + "pin-project", + "static_assertions", ] [[package]] -name = "srml-staking-reward-curve" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "safe-mix" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "rustc_version", ] [[package]] -name = "srml-sudo" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-authority-discovery" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "bytes 0.5.6", + "derive_more", + "futures 0.3.4", + "futures-timer 3.0.2", + "libp2p", + "log", "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", + "prost", + "prost-build", + "rand 0.7.3", + "sc-client-api", + "sc-keystore", + "sc-network", + "serde_json", + "sp-api", + "sp-authority-discovery", + "sp-blockchain", + "sp-core", + "sp-runtime", + "substrate-prometheus-endpoint", ] [[package]] -name = "srml-support" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-basic-authorship" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "bitmask", - "impl-trait-for-tuples", + "futures 0.3.4", + "futures-timer 3.0.2", "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", + "sc-block-builder", + "sc-client-api", + "sc-proposer-metrics", + "sc-telemetry", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-transaction-pool", + "substrate-prometheus-endpoint", + "tokio-executor 0.2.0-alpha.6", +] + +[[package]] +name = "sc-block-builder" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sc-client-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "sp-state-machine", ] [[package]] -name = "srml-support-procedural" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-chain-spec" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "sr-api-macros", - "srml-support-procedural-tools", - "syn 1.0.17", + "impl-trait-for-tuples", + "sc-chain-spec-derive", + "sc-network", + "sc-telemetry", + "serde", + "serde_json", + "sp-chain-spec", + "sp-core", + "sp-runtime", ] [[package]] -name = "srml-support-procedural-tools" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-chain-spec-derive" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "srml-support-procedural-tools-derive", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", ] [[package]] -name = "srml-support-procedural-tools-derive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-cli" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "ansi_term 0.12.1", + "atty", + "chrono", + "derive_more", + "env_logger", + "fdlimit", + "futures 0.3.4", + "lazy_static", + "log", + "names", + "nix", + "parity-util-mem", + "regex", + "rpassword", + "sc-client-api", + "sc-informant", + "sc-network", + "sc-service", + "sc-telemetry", + "sc-tracing", + "serde_json", + "sp-blockchain", + "sp-core", + "sp-keyring", + "sp-panic-handler", + "sp-runtime", + "sp-state-machine", + "sp-utils", + "sp-version", + "structopt", + "substrate-prometheus-endpoint", + "time", + "tokio 0.2.22", ] [[package]] -name = "srml-system" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-client-api" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "impl-trait-for-tuples", + "derive_more", + "fnv", + "futures 0.3.4", + "hash-db", + "hex-literal", + "kvdb", + "lazy_static", + "log", "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "sr-version", - "srml-support", - "substrate-primitives", + "parking_lot 0.10.2", + "sc-executor", + "sc-telemetry", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-database", + "sp-externalities", + "sp-inherents", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-storage", + "sp-transaction-pool", + "sp-trie", + "sp-utils", + "sp-version", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-client-db" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "blake2-rfc", + "hash-db", + "kvdb", + "kvdb-memorydb", + "kvdb-rocksdb", + "linked-hash-map", + "log", + "parity-db", + "parity-scale-codec", + "parity-util-mem", + "parking_lot 0.10.2", + "sc-client-api", + "sc-executor", + "sc-state-db", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-database", + "sp-runtime", + "sp-state-machine", + "sp-trie", + "substrate-prometheus-endpoint", ] [[package]] -name = "srml-system-rpc-runtime-api" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-consensus" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "parity-scale-codec", - "substrate-client", + "sc-client-api", + "sp-blockchain", + "sp-consensus", + "sp-runtime", ] [[package]] -name = "srml-timestamp" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-consensus-babe" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "impl-trait-for-tuples", + "derive_more", + "fork-tree", + "futures 0.3.4", + "futures-timer 3.0.2", + "log", + "merlin", + "num-bigint", + "num-rational", + "num-traits 0.2.11", "parity-scale-codec", + "parking_lot 0.10.2", + "pdqselect", + "rand 0.7.3", + "sc-client-api", + "sc-consensus-epochs", + "sc-consensus-slots", + "sc-consensus-uncles", + "sc-keystore", + "sc-telemetry", + "schnorrkel", + "serde", + "sp-api", + "sp-application-crypto", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-vrf", + "sp-core", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-timestamp", + "sp-version", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-consensus-babe-rpc" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "futures 0.3.4", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "sc-consensus-babe", + "sc-consensus-epochs", + "sc-keystore", + "sc-rpc-api", "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-inherents", + "sp-api", + "sp-application-crypto", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-core", + "sp-runtime", ] [[package]] -name = "srml-transaction-payment" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-consensus-epochs" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "fork-tree", "parity-scale-codec", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "srml-transaction-payment-rpc-runtime-api", + "parking_lot 0.10.2", + "sc-client-api", + "sp-blockchain", + "sp-runtime", ] [[package]] -name = "srml-transaction-payment-rpc-runtime-api" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-consensus-slots" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "futures 0.3.4", + "futures-timer 3.0.2", + "log", "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "substrate-client", + "parking_lot 0.10.2", + "sc-client-api", + "sc-telemetry", + "sp-api", + "sp-application-crypto", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-state-machine", ] [[package]] -name = "stable_deref_trait" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" +name = "sc-consensus-uncles" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "log", + "sc-client-api", + "sp-authorship", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", +] [[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +name = "sc-executor" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "lazy_static", + "libsecp256k1", + "log", + "parity-scale-codec", + "parity-wasm", + "parking_lot 0.10.2", + "sc-executor-common", + "sc-executor-wasmi", + "sp-api", + "sp-core", + "sp-externalities", + "sp-io", + "sp-panic-handler", + "sp-runtime-interface", + "sp-serializer", + "sp-trie", + "sp-version", + "sp-wasm-interface", + "wasmi", +] [[package]] -name = "stream-cipher" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" +name = "sc-executor-common" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "generic-array", + "derive_more", + "log", + "parity-scale-codec", + "parity-wasm", + "sp-allocator", + "sp-core", + "sp-runtime-interface", + "sp-serializer", + "sp-wasm-interface", + "wasmi", ] [[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" +name = "sc-executor-wasmi" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "bytes 0.4.12", + "log", + "parity-scale-codec", + "sc-executor-common", + "sp-allocator", + "sp-core", + "sp-runtime-interface", + "sp-wasm-interface", + "wasmi", ] [[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "structopt" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b3a3e93f5ad553c38b3301c8a0a0cec829a36783f6a0c467fc4bf553a5f5bf" +name = "sc-finality-grandpa" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "clap", - "structopt-derive", + "assert_matches", + "derive_more", + "finality-grandpa", + "fork-tree", + "futures 0.3.4", + "futures-timer 3.0.2", + "log", + "parity-scale-codec", + "parking_lot 0.10.2", + "pin-project", + "rand 0.7.3", + "sc-block-builder", + "sc-client-api", + "sc-consensus", + "sc-keystore", + "sc-network", + "sc-network-gossip", + "sc-telemetry", + "serde_json", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-finality-grandpa", + "sp-finality-tracker", + "sp-inherents", + "sp-runtime", + "sp-utils", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-finality-grandpa-rpc" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "finality-grandpa", + "futures 0.3.4", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "log", + "sc-finality-grandpa", + "serde", + "serde_json", ] [[package]] -name = "structopt-derive" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea692d40005b3ceba90a9fe7a78fa8d4b82b0ce627eebbffc329aab850f3410e" +name = "sc-informant" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "ansi_term 0.12.1", + "futures 0.3.4", + "log", + "parity-util-mem", + "parking_lot 0.10.2", + "sc-client-api", + "sc-network", + "sp-blockchain", + "sp-runtime", + "sp-transaction-pool", + "sp-utils", + "wasm-timer", ] [[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" +name = "sc-keystore" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "heck", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", + "derive_more", + "hex", + "merlin", + "parking_lot 0.10.2", + "rand 0.7.3", + "serde_json", + "sp-application-crypto", + "sp-core", + "subtle 2.2.2", ] [[package]] -name = "substrate-application-crypto" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-light" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "hash-db", + "lazy_static", "parity-scale-codec", - "serde", - "sr-io", - "sr-std", - "substrate-primitives", + "parking_lot 0.10.2", + "sc-client-api", + "sc-executor", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-externalities", + "sp-runtime", + "sp-state-machine", ] [[package]] -name = "substrate-authority-discovery" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-network" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "bytes 0.4.12", - "derive_more 0.15.0", - "futures-preview", - "futures-timer", + "bitflags", + "bs58", + "bytes 0.5.6", + "derive_more", + "either", + "erased-serde", + "fnv", + "fork-tree", + "futures 0.3.4", + "futures-timer 3.0.2", + "futures_codec 0.3.4", + "hex", + "ip_network", "libp2p", + "linked-hash-map", + "linked_hash_set", "log", + "lru", + "nohash-hasher", "parity-scale-codec", + "parking_lot 0.10.2", + "pin-project", "prost", "prost-build", + "rand 0.7.3", + "sc-block-builder", + "sc-client-api", + "sc-peerset", + "serde", "serde_json", - "sr-primitives", - "substrate-authority-discovery-primitives", - "substrate-client", - "substrate-network", - "substrate-primitives", + "slog", + "slog_derive", + "smallvec 0.6.13", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "sp-utils", + "substrate-prometheus-endpoint", + "thiserror", + "unsigned-varint 0.3.3", + "void", + "wasm-timer", + "zeroize", ] [[package]] -name = "substrate-authority-discovery-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-network-gossip" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "parity-scale-codec", - "sr-primitives", - "sr-std", - "substrate-client", + "futures 0.3.4", + "futures-timer 3.0.2", + "libp2p", + "log", + "lru", + "sc-network", + "sp-runtime", + "wasm-timer", ] [[package]] -name = "substrate-basic-authorship" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-offchain" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "futures-preview", + "bytes 0.5.6", + "fnv", + "futures 0.3.4", + "futures-timer 3.0.2", + "hyper 0.13.7", + "hyper-rustls", "log", + "num_cpus", "parity-scale-codec", - "sr-primitives", - "substrate-client", - "substrate-consensus-common", - "substrate-inherents", - "substrate-primitives", - "substrate-telemetry", - "substrate-transaction-pool", + "parking_lot 0.10.2", + "rand 0.7.3", + "sc-client-api", + "sc-keystore", + "sc-network", + "sp-api", + "sp-core", + "sp-offchain", + "sp-runtime", + "sp-utils", + "threadpool", ] [[package]] -name = "substrate-bip39" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" +name = "sc-peerset" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel", - "sha2", + "futures 0.3.4", + "libp2p", + "log", + "serde_json", + "sp-utils", + "wasm-timer", ] [[package]] -name = "substrate-chain-spec" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-proposer-metrics" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "impl-trait-for-tuples", + "log", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-rpc" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "futures 0.3.4", + "hash-db", + "jsonrpc-core", + "jsonrpc-pubsub", + "log", + "parity-scale-codec", + "parking_lot 0.10.2", + "sc-block-builder", + "sc-client-api", + "sc-executor", + "sc-keystore", + "sc-rpc-api", + "serde_json", + "sp-api", + "sp-blockchain", + "sp-chain-spec", + "sp-core", + "sp-offchain", + "sp-rpc", + "sp-runtime", + "sp-session", + "sp-state-machine", + "sp-transaction-pool", + "sp-utils", + "sp-version", +] + +[[package]] +name = "sc-rpc-api" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "futures 0.3.4", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "jsonrpc-pubsub", + "log", + "parity-scale-codec", + "parking_lot 0.10.2", "serde", "serde_json", - "sr-primitives", - "substrate-chain-spec-derive", - "substrate-network", - "substrate-primitives", - "substrate-telemetry", + "sp-chain-spec", + "sp-core", + "sp-rpc", + "sp-runtime", + "sp-transaction-pool", + "sp-version", ] [[package]] -name = "substrate-chain-spec-derive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-rpc-server" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "jsonrpc-core", + "jsonrpc-http-server", + "jsonrpc-ipc-server", + "jsonrpc-pubsub", + "jsonrpc-ws-server", + "log", + "serde", + "serde_json", + "sp-runtime", ] [[package]] -name = "substrate-cli" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-service" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "ansi_term 0.12.1", - "app_dirs", - "atty", - "clap", - "derive_more 0.15.0", - "env_logger 0.7.1", + "derive_more", + "directories", "exit-future", - "fdlimit", "futures 0.1.29", - "futures-preview", + "futures 0.3.4", + "futures-timer 3.0.2", + "hash-db", + "jsonrpc-pubsub", "lazy_static", "log", - "names", - "regex", - "rpassword", + "netstat2", + "parity-multiaddr 0.7.3", + "parity-scale-codec", + "parity-util-mem", + "parking_lot 0.10.2", + "pin-project", + "procfs", + "rand 0.7.3", + "sc-block-builder", + "sc-chain-spec", + "sc-client-api", + "sc-client-db", + "sc-executor", + "sc-informant", + "sc-keystore", + "sc-light", + "sc-network", + "sc-offchain", + "sc-rpc", + "sc-rpc-server", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "serde", "serde_json", - "sr-primitives", - "structopt", - "substrate-client", - "substrate-header-metadata", - "substrate-keyring", - "substrate-network", - "substrate-panic-handler", - "substrate-primitives", - "substrate-service", - "substrate-state-machine", - "substrate-telemetry", - "time", - "tokio", + "slog", + "sp-api", + "sp-application-crypto", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-externalities", + "sp-io", + "sp-runtime", + "sp-session", + "sp-state-machine", + "sp-transaction-pool", + "sp-trie", + "sp-utils", + "sp-version", + "substrate-prometheus-endpoint", + "sysinfo", + "tempfile", + "tracing", + "wasm-timer", ] [[package]] -name = "substrate-client" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sc-state-db" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "derive_more 0.15.0", - "fnv", - "futures 0.1.29", - "futures-preview", - "hash-db", - "hex-literal 0.2.1", - "kvdb", "log", "parity-scale-codec", - "parking_lot 0.9.0", - "sr-api-macros", - "sr-primitives", - "sr-std", - "sr-version", - "substrate-consensus-common", - "substrate-executor", - "substrate-header-metadata", - "substrate-inherents", - "substrate-keyring", - "substrate-primitives", - "substrate-state-machine", - "substrate-telemetry", - "substrate-trie", -] - -[[package]] -name = "substrate-client-db" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" + "parity-util-mem", + "parity-util-mem-derive", + "parking_lot 0.10.2", + "sc-client-api", + "sp-core", +] + +[[package]] +name = "sc-telemetry" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hash-db", - "kvdb", - "kvdb-memorydb", - "kvdb-rocksdb", + "bytes 0.5.6", + "futures 0.3.4", + "futures-timer 3.0.2", + "libp2p", + "log", + "parking_lot 0.10.2", + "pin-project", + "rand 0.7.3", + "serde", + "slog", + "slog-json", + "slog-scope", + "take_mut", + "void", + "wasm-timer", +] + +[[package]] +name = "sc-tracing" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "erased-serde", + "log", + "parking_lot 0.10.2", + "rustc-hash", + "sc-telemetry", + "serde", + "serde_json", + "slog", + "sp-tracing", + "tracing-core", +] + +[[package]] +name = "sc-transaction-graph" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "futures 0.3.4", "linked-hash-map", "log", + "parity-util-mem", + "parking_lot 0.10.2", + "serde", + "sp-blockchain", + "sp-core", + "sp-runtime", + "sp-transaction-pool", + "sp-utils", + "wasm-timer", +] + +[[package]] +name = "sc-transaction-pool" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "futures 0.3.4", + "futures-diagnose", + "intervalier", + "log", "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "substrate-client", - "substrate-consensus-common", - "substrate-executor", - "substrate-header-metadata", - "substrate-primitives", - "substrate-state-db", - "substrate-state-machine", - "substrate-trie", + "parity-util-mem", + "parking_lot 0.10.2", + "sc-client-api", + "sc-transaction-graph", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-runtime", + "sp-tracing", + "sp-transaction-pool", + "sp-utils", + "substrate-prometheus-endpoint", + "wasm-timer", +] + +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi 0.3.8", +] + +[[package]] +name = "schnorrkel" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" +dependencies = [ + "arrayref", + "arrayvec 0.5.1", + "curve25519-dalek", + "getrandom", + "merlin", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2 0.8.1", + "subtle 2.2.2", + "zeroize", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[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 = "send_wrapper" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" + +[[package]] +name = "send_wrapper" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686ef91cf020ad8d4aca9a7047641fd6add626b7b89e14546c2b6a76781cf822" + +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + +[[package]] +name = "serde" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" +dependencies = [ + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "serde_json" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" +dependencies = [ + "itoa", + "ryu", + "serde", ] [[package]] -name = "substrate-common-module" -version = "1.2.0" +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "srml-support", - "srml-system", - "srml-timestamp", + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", ] [[package]] -name = "substrate-consensus-babe" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + +[[package]] +name = "sha2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" dependencies = [ - "derive_more 0.15.0", - "fork-tree", - "futures 0.1.29", - "futures-preview", - "futures-timer", - "log", - "merlin", - "num-bigint", - "num-rational", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", - "pdqselect", - "rand 0.7.3", - "schnorrkel", - "sr-io", - "sr-primitives", - "sr-version", - "srml-babe", - "srml-support", - "substrate-application-crypto", - "substrate-client", - "substrate-consensus-babe-primitives", - "substrate-consensus-common", - "substrate-consensus-slots", - "substrate-consensus-uncles", - "substrate-header-metadata", - "substrate-inherents", - "substrate-keystore", - "substrate-primitives", - "substrate-telemetry", -] - -[[package]] -name = "substrate-consensus-babe-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" dependencies = [ - "parity-scale-codec", - "schnorrkel", - "sr-primitives", - "sr-std", - "substrate-application-crypto", - "substrate-client", - "substrate-consensus-slots", + "block-buffer 0.9.0", + "cfg-if", + "cpuid-bool", + "digest 0.9.0", + "opaque-debug 0.3.0", ] [[package]] -name = "substrate-consensus-common" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sha3" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" dependencies = [ - "derive_more 0.15.0", - "futures-preview", - "futures-timer", - "libp2p", - "log", - "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "sr-std", - "sr-version", - "substrate-inherents", - "substrate-primitives", + "block-buffer 0.7.3", + "byte-tools", + "digest 0.8.1", + "keccak", + "opaque-debug 0.2.3", ] [[package]] -name = "substrate-consensus-slots" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" + +[[package]] +name = "signal-hook-registry" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" dependencies = [ - "futures-preview", - "futures-timer", - "log", - "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "substrate-client", - "substrate-consensus-common", - "substrate-inherents", - "substrate-primitives", - "substrate-telemetry", + "arc-swap", + "libc", ] [[package]] -name = "substrate-consensus-uncles" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "slog" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99" dependencies = [ - "log", - "sr-primitives", - "srml-authorship", - "substrate-client", - "substrate-consensus-common", - "substrate-inherents", - "substrate-primitives", + "erased-serde", ] [[package]] -name = "substrate-content-working-group-module" -version = "1.1.0" +name = "slog-json" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" dependencies = [ - "parity-scale-codec", + "chrono", + "erased-serde", "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-forum-module", - "substrate-hiring-module", - "substrate-membership-module", - "substrate-primitives", - "substrate-recurring-reward-module", - "substrate-stake-module", - "substrate-token-mint-module", - "substrate-versioned-store", - "substrate-versioned-store-permissions-module", -] - -[[package]] -name = "substrate-debug-derive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "serde_json", + "slog", ] [[package]] -name = "substrate-executor" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "slog-scope" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c44c89dd8b0ae4537d1ae318353eaf7840b4869c536e31c41e963d1ea523ee6" dependencies = [ - "derive_more 0.15.0", + "arc-swap", "lazy_static", - "libsecp256k1", - "log", - "parity-scale-codec", - "parity-wasm", - "parking_lot 0.9.0", - "sr-io", - "sr-version", - "substrate-externalities", - "substrate-panic-handler", - "substrate-primitives", - "substrate-serializer", - "substrate-trie", - "substrate-wasm-interface", - "tiny-keccak", - "wasmi", + "slog", ] [[package]] -name = "substrate-externalities" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "slog_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a945ec7f7ce853e89ffa36be1e27dce9a43e82ff9093bf3461c30d5da74ed11b" dependencies = [ - "environmental", - "primitive-types", - "sr-std", - "substrate-primitives-storage", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "substrate-finality-grandpa" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" dependencies = [ - "finality-grandpa", - "fork-tree", - "futures 0.1.29", - "futures-preview", - "log", - "parity-scale-codec", - "parking_lot 0.9.0", - "rand 0.7.3", - "serde_json", - "sr-primitives", - "srml-finality-tracker", - "substrate-client", - "substrate-consensus-common", - "substrate-finality-grandpa-primitives", - "substrate-header-metadata", - "substrate-inherents", - "substrate-keystore", - "substrate-network", - "substrate-primitives", - "substrate-telemetry", - "tokio-executor", - "tokio-timer", + "maybe-uninit", ] [[package]] -name = "substrate-finality-grandpa-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "smallvec" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" + +[[package]] +name = "snow" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32bf8474159a95551661246cda4976e89356999e3cbfef36f493dacc3fae1e8e" dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "substrate-application-crypto", - "substrate-client", + "aes-gcm", + "blake2 0.9.0", + "chacha20poly1305", + "rand 0.7.3", + "rand_core 0.5.1", + "ring", + "rustc_version", + "sha2 0.9.1", + "subtle 2.2.2", + "x25519-dalek", ] [[package]] -name = "substrate-forum-module" -version = "1.2.2" +name = "socket2" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" dependencies = [ - "hex-literal 0.1.4", - "parity-scale-codec", - "quote 0.6.13", - "serde", - "serde_derive", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-support-procedural", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-primitives", + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", ] [[package]] -name = "substrate-governance-module" -version = "1.0.0" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-membership-module", - "substrate-primitives", - "substrate-recurring-reward-module", - "substrate-token-mint-module", -] - -[[package]] -name = "substrate-header-metadata" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "soketto" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c9dab3f95c9ebdf3a88268c19af668f637a3c5039c2c56ff2d40b1b2d64a25b" dependencies = [ - "lru-cache", - "parking_lot 0.9.0", - "sr-primitives", + "base64", + "bytes 0.5.6", + "flate2", + "futures 0.3.4", + "http 0.2.1", + "httparse", + "log", + "rand 0.7.3", + "sha1", + "smallvec 1.4.1", + "static_assertions", + "thiserror", ] [[package]] -name = "substrate-hiring-module" -version = "1.0.2" +name = "sp-allocator" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hex-literal 0.1.4", - "mockall", - "parity-scale-codec", - "quote 0.6.13", - "serde", - "serde_derive", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-support-procedural", - "srml-system", - "srml-timestamp", - "substrate-primitives", - "substrate-stake-module", + "derive_more", + "log", + "sp-core", + "sp-std", + "sp-wasm-interface", ] [[package]] -name = "substrate-inherents" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-api" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "hash-db", "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "sr-std", + "sp-api-proc-macro", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-version", ] [[package]] -name = "substrate-keyring" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-api-proc-macro" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "lazy_static", - "sr-primitives", - "strum", - "strum_macros", - "substrate-primitives", + "blake2-rfc", + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "substrate-keystore" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-application-crypto" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "derive_more 0.15.0", - "hex 0.3.2", - "parking_lot 0.9.0", - "rand 0.7.3", - "serde_json", - "substrate-application-crypto", - "substrate-primitives", - "subtle 2.2.2", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-std", ] [[package]] -name = "substrate-membership-module" -version = "1.1.0" +name = "sp-arithmetic" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "integer-sqrt", + "num-traits 0.2.11", "parity-scale-codec", "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-primitives", + "sp-debug-derive", + "sp-std", ] [[package]] -name = "substrate-memo-module" -version = "1.0.0" +name = "sp-authority-discovery" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-common-module", + "sp-api", + "sp-application-crypto", + "sp-runtime", + "sp-std", ] [[package]] -name = "substrate-network" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-authorship" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "bitflags", - "bytes 0.4.12", - "derive_more 0.15.0", - "either", - "erased-serde", - "fnv", - "fork-tree", - "futures 0.1.29", - "futures-preview", - "futures-timer", - "libp2p", - "linked-hash-map", - "linked_hash_set", - "log", - "lru-cache", "parity-scale-codec", - "parking_lot 0.9.0", - "rand 0.7.3", - "rustc-hex", - "serde", - "serde_json", - "slog", - "slog_derive", - "smallvec 0.6.13", - "sr-primitives", - "substrate-client", - "substrate-consensus-babe-primitives", - "substrate-consensus-common", - "substrate-header-metadata", - "substrate-peerset", - "substrate-primitives", - "tokio-io", - "unsigned-varint 0.2.3", - "void", - "zeroize 0.10.1", + "sp-inherents", + "sp-runtime", + "sp-std", ] [[package]] -name = "substrate-offchain" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-block-builder" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "bytes 0.4.12", - "fnv", - "futures 0.1.29", - "futures-preview", - "futures-timer", - "hyper", - "hyper-rustls", - "log", - "num_cpus", "parity-scale-codec", - "parking_lot 0.9.0", - "rand 0.7.3", - "sr-primitives", - "substrate-client", - "substrate-keystore", - "substrate-network", - "substrate-offchain-primitives", - "substrate-primitives", - "substrate-transaction-pool", - "threadpool", + "sp-api", + "sp-inherents", + "sp-runtime", + "sp-std", ] [[package]] -name = "substrate-offchain-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-blockchain" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "sr-primitives", - "substrate-client", + "derive_more", + "log", + "lru", + "parity-scale-codec", + "parking_lot 0.10.2", + "sp-block-builder", + "sp-consensus", + "sp-runtime", + "sp-state-machine", ] [[package]] -name = "substrate-panic-handler" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-chain-spec" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "backtrace", - "log", + "serde", + "serde_json", ] [[package]] -name = "substrate-peerset" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-consensus" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "futures-preview", + "derive_more", + "futures 0.3.4", + "futures-timer 3.0.2", "libp2p", - "linked-hash-map", "log", - "lru-cache", - "serde_json", + "parity-scale-codec", + "parking_lot 0.10.2", + "serde", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-utils", + "sp-version", + "substrate-prometheus-endpoint", + "wasm-timer", ] [[package]] -name = "substrate-phragmen" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-consensus-babe" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "serde", - "sr-primitives", - "sr-std", + "merlin", + "parity-scale-codec", + "sp-api", + "sp-application-crypto", + "sp-consensus", + "sp-consensus-vrf", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "sp-consensus-vrf" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "schnorrkel", + "sp-core", + "sp-runtime", + "sp-std", ] [[package]] -name = "substrate-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-core" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "base58", "blake2-rfc", - "byteorder 1.3.4", - "ed25519-dalek 0.9.1", + "byteorder", + "derive_more", + "ed25519-dalek", + "futures 0.3.4", "hash-db", "hash256-std-hasher", - "hex 0.4.2", - "impl-serde 0.2.3", + "hex", + "impl-serde 0.3.0", "lazy_static", "libsecp256k1", "log", - "num-traits", + "merlin", + "num-traits 0.2.11", "parity-scale-codec", - "parking_lot 0.9.0", + "parity-util-mem", + "parking_lot 0.10.2", "primitive-types", "rand 0.7.3", "regex", - "rustc-hex", "schnorrkel", "serde", - "sha2", - "sr-std", + "sha2 0.8.1", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", "substrate-bip39", - "substrate-debug-derive", - "substrate-externalities", - "substrate-primitives-storage", "tiny-bip39", "tiny-keccak", "twox-hash", "wasmi", - "zeroize 0.10.1", + "zeroize", ] [[package]] -name = "substrate-primitives-storage" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-database" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "impl-serde 0.2.3", - "serde", - "sr-std", - "substrate-debug-derive", + "kvdb", + "parking_lot 0.10.2", ] [[package]] -name = "substrate-proposals-codex-module" -version = "2.1.0" +name = "sp-debug-derive" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "sp-externalities" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "num_enum", + "environmental", "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-balances", - "srml-staking", - "srml-staking-reward-curve", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-content-working-group-module", - "substrate-governance-module", - "substrate-hiring-module", - "substrate-membership-module", - "substrate-primitives", - "substrate-proposals-discussion-module", - "substrate-proposals-engine-module", - "substrate-recurring-reward-module", - "substrate-stake-module", - "substrate-token-mint-module", - "substrate-versioned-store", - "substrate-versioned-store-permissions-module", - "substrate-working-group-module", -] - -[[package]] -name = "substrate-proposals-discussion-module" -version = "2.0.0" + "sp-std", + "sp-storage", +] + +[[package]] +name = "sp-finality-grandpa" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "num_enum", + "finality-grandpa", + "log", "parity-scale-codec", "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-membership-module", - "substrate-primitives", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-runtime", + "sp-std", ] [[package]] -name = "substrate-proposals-engine-module" -version = "2.0.0" +name = "sp-finality-tracker" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "mockall", - "num_enum", "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-membership-module", - "substrate-primitives", - "substrate-stake-module", + "sp-inherents", + "sp-std", ] [[package]] -name = "substrate-recurring-reward-module" -version = "1.0.1" +name = "sp-inherents" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hex-literal 0.1.4", + "derive_more", "parity-scale-codec", - "quote 0.6.13", - "serde", - "serde_derive", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-support-procedural", - "srml-system", - "srml-timestamp", - "substrate-primitives", - "substrate-token-mint-module", + "parking_lot 0.10.2", + "sp-core", + "sp-std", ] [[package]] -name = "substrate-rpc" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-io" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "futures-preview", + "futures 0.3.4", "hash-db", - "jsonrpc-core 14.0.5", - "jsonrpc-pubsub", + "libsecp256k1", "log", "parity-scale-codec", - "parking_lot 0.9.0", - "serde_json", - "sr-primitives", - "sr-version", - "substrate-client", - "substrate-executor", - "substrate-keystore", - "substrate-primitives", - "substrate-rpc-api", - "substrate-rpc-primitives", - "substrate-session", - "substrate-state-machine", - "substrate-transaction-pool", + "parking_lot 0.10.2", + "sp-core", + "sp-externalities", + "sp-runtime-interface", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "sp-wasm-interface", ] [[package]] -name = "substrate-rpc-api" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-keyring" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "lazy_static", + "sp-core", + "sp-runtime", + "strum", +] + +[[package]] +name = "sp-npos-elections" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "derive_more 0.15.0", - "futures-preview", - "jsonrpc-core 14.0.5", - "jsonrpc-core-client", - "jsonrpc-derive", - "jsonrpc-pubsub", - "log", "parity-scale-codec", - "parking_lot 0.9.0", "serde", - "serde_json", - "sr-version", - "substrate-primitives", - "substrate-rpc-primitives", - "substrate-transaction-graph", + "sp-arithmetic", + "sp-npos-elections-compact", + "sp-std", ] [[package]] -name = "substrate-rpc-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-npos-elections-compact" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "serde", - "substrate-primitives", + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "substrate-rpc-servers" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-offchain" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "jsonrpc-core 14.0.5", - "jsonrpc-http-server", - "jsonrpc-pubsub", - "jsonrpc-ws-server", + "sp-api", + "sp-core", + "sp-runtime", +] + +[[package]] +name = "sp-panic-handler" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "backtrace", "log", - "serde", - "serde_json", - "sr-primitives", ] [[package]] -name = "substrate-serializer" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-rpc" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "serde", - "serde_json", + "sp-core", ] [[package]] -name = "substrate-service" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-runtime" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "derive_more 0.15.0", - "exit-future", - "futures 0.1.29", - "futures-preview", - "lazy_static", + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", "log", - "parity-multiaddr 0.5.0", "parity-scale-codec", - "parking_lot 0.9.0", + "parity-util-mem", + "paste", + "rand 0.7.3", "serde", - "serde_json", - "slog", - "sr-io", - "sr-primitives", - "substrate-application-crypto", - "substrate-chain-spec", - "substrate-client", - "substrate-client-db", - "substrate-consensus-common", - "substrate-executor", - "substrate-keystore", - "substrate-network", - "substrate-offchain", - "substrate-primitives", - "substrate-rpc", - "substrate-rpc-servers", - "substrate-session", - "substrate-telemetry", - "substrate-transaction-pool", - "sysinfo", - "target_info", - "tokio-executor", - "tokio-timer", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-inherents", + "sp-io", + "sp-std", ] [[package]] -name = "substrate-service-discovery-module" -version = "2.0.0" +name = "sp-runtime-interface" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-hiring-module", - "substrate-membership-module", - "substrate-primitives", - "substrate-recurring-reward-module", - "substrate-stake-module", - "substrate-token-mint-module", - "substrate-working-group-module", -] - -[[package]] -name = "substrate-session" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" + "primitive-types", + "sp-externalities", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-tracing", + "sp-wasm-interface", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "sr-primitives", - "sr-std", - "substrate-client", - "substrate-primitives", + "Inflector", + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "substrate-stake-module" -version = "2.0.0" +name = "sp-serializer" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hex-literal 0.1.4", - "parity-scale-codec", - "quote 0.6.13", "serde", - "serde_derive", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-support-procedural", - "srml-system", - "srml-timestamp", - "substrate-primitives", + "serde_json", ] [[package]] -name = "substrate-state-db" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-session" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "log", "parity-scale-codec", - "parking_lot 0.9.0", - "substrate-primitives", + "sp-api", + "sp-core", + "sp-runtime", + "sp-staking", + "sp-std", ] [[package]] -name = "substrate-state-machine" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-staking" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-state-machine" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "hash-db", + "itertools 0.9.0", "log", - "num-traits", + "num-traits 0.2.11", "parity-scale-codec", - "parking_lot 0.9.0", + "parking_lot 0.10.2", "rand 0.7.3", - "substrate-externalities", - "substrate-panic-handler", - "substrate-primitives", - "substrate-trie", + "smallvec 1.4.1", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-trie", "trie-db", "trie-root", ] [[package]] -name = "substrate-storage-module" -version = "2.0.0" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-hiring-module", - "substrate-membership-module", - "substrate-primitives", - "substrate-recurring-reward-module", - "substrate-stake-module", - "substrate-token-mint-module", - "substrate-working-group-module", -] - -[[package]] -name = "substrate-telemetry" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-std" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" + +[[package]] +name = "sp-storage" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "futures-preview", - "futures-timer", - "libp2p", - "log", - "parking_lot 0.9.0", - "rand 0.7.3", + "impl-serde 0.2.3", + "ref-cast", "serde", - "slog", - "slog-async", - "slog-json", - "slog-scope", - "tokio-io", - "void", + "sp-debug-derive", + "sp-std", ] [[package]] -name = "substrate-token-mint-module" -version = "1.0.1" +name = "sp-timestamp" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hex-literal 0.1.4", + "impl-trait-for-tuples", "parity-scale-codec", - "quote 0.6.13", - "serde", - "serde_derive", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-support-procedural", - "srml-system", - "srml-timestamp", - "substrate-primitives", + "sp-api", + "sp-inherents", + "sp-runtime", + "sp-std", + "wasm-timer", ] [[package]] -name = "substrate-transaction-graph" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-tracing" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "derive_more 0.15.0", - "futures-preview", "log", - "parking_lot 0.9.0", - "serde", - "sr-primitives", - "substrate-primitives", + "rental", + "tracing", ] [[package]] -name = "substrate-transaction-pool" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-transaction-pool" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "derive_more 0.15.0", + "derive_more", "futures 0.3.4", "log", "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "substrate-client", - "substrate-primitives", - "substrate-transaction-graph", + "serde", + "sp-api", + "sp-blockchain", + "sp-runtime", + "sp-utils", ] [[package]] -name = "substrate-trie" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "sp-trie" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "hash-db", "memory-db", "parity-scale-codec", - "sr-std", - "substrate-primitives", + "sp-core", + "sp-std", "trie-db", "trie-root", ] [[package]] -name = "substrate-versioned-store" -version = "1.0.1" +name = "sp-utils" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "futures 0.3.4", + "futures-core", + "futures-timer 3.0.2", + "lazy_static", + "prometheus", +] + +[[package]] +name = "sp-version" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hex-literal 0.1.4", + "impl-serde 0.2.3", "parity-scale-codec", - "quote 0.6.13", "serde", - "serde_derive", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-support-procedural", - "srml-system", - "srml-timestamp", - "substrate-primitives", + "sp-runtime", + "sp-std", ] [[package]] -name = "substrate-versioned-store-permissions-module" -version = "1.0.1" +name = "sp-wasm-interface" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hex-literal 0.1.4", + "impl-trait-for-tuples", "parity-scale-codec", - "quote 0.6.13", - "serde", - "serde_derive", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-support-procedural", - "srml-system", - "srml-timestamp", - "substrate-primitives", - "substrate-versioned-store", + "sp-std", + "wasmi", ] [[package]] -name = "substrate-wasm-builder-runner" -version = "1.0.5" +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "stable_deref_trait" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "statrs" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10102ac8d55e35db2b3fafc26f81ba8647da2e15879ab686a67e6d19af2685e8" +dependencies = [ + "rand 0.5.6", +] + +[[package]] +name = "stream-cipher" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f8ed9974042b8c3672ff3030a69fcc03b74c47c3d1ecb7755e8a3626011e88" +dependencies = [ + "generic-array 0.14.3", +] + +[[package]] +name = "string" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" +dependencies = [ + "bytes 0.4.12", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de2f5e239ee807089b62adce73e48c625e0ed80df02c7ab3f068f5db5281065c" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510413f9de616762a4fbeab62509bf15c729603b72d7cd71280fbca431b1c118" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "strum" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6138f8f88a16d90134763314e3fc76fa3ed6a7db4725d6acf9a3ef95a3188d22" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81" +dependencies = [ + "heck", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "substrate-bip39" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30c70de7e7d5fd404fe26db1e7a4d6b553e2760b1ac490f249c04a960c483b8" +checksum = "c004e8166d6e0aa3a9d5fa673e5b7098ff25f930de1013a21341988151e681bb" +dependencies = [ + "hmac", + "pbkdf2", + "schnorrkel", + "sha2 0.8.1", +] + +[[package]] +name = "substrate-browser-utils" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "chrono", + "clear_on_drop", + "console_error_panic_hook", + "console_log", + "futures 0.1.29", + "futures 0.3.4", + "futures-timer 3.0.2", + "js-sys", + "kvdb-web", + "libp2p-wasm-ext", + "log", + "rand 0.6.5", + "rand 0.7.3", + "sc-chain-spec", + "sc-informant", + "sc-network", + "sc-service", + "sp-database", + "wasm-bindgen", + "wasm-bindgen-futures", +] [[package]] -name = "substrate-wasm-interface" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" +name = "substrate-build-script-utils" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "wasmi", + "platforms", ] [[package]] -name = "substrate-working-group-module" -version = "1.1.0" +name = "substrate-frame-rpc-system" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "frame-system-rpc-runtime-api", + "futures 0.3.4", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "log", "parity-scale-codec", + "sc-client-api", + "sc-rpc-api", "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-hiring-module", - "substrate-membership-module", - "substrate-primitives", - "substrate-recurring-reward-module", - "substrate-stake-module", - "substrate-token-mint-module", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-core", + "sp-runtime", + "sp-transaction-pool", +] + +[[package]] +name = "substrate-prometheus-endpoint" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "async-std", + "derive_more", + "futures-util", + "hyper 0.13.7", + "log", + "prometheus", + "tokio 0.2.22", ] +[[package]] +name = "substrate-wasm-builder-runner" +version = "1.0.6" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" + [[package]] name = "subtle" version = "1.0.0" @@ -5602,13 +6795,13 @@ checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" [[package]] name = "syn" -version = "0.15.44" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", + "quote 0.3.15", + "synom", + "unicode-xid 0.0.4", ] [[package]] @@ -5617,32 +6810,54 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "unicode-xid 0.2.0", ] +[[package]] +name = "syn-mid" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" +dependencies = [ + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +dependencies = [ + "unicode-xid 0.0.4", +] + [[package]] name = "synstructure" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", "unicode-xid 0.2.0", ] [[package]] name = "sysinfo" -version = "0.9.6" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f4b2468c629cffba39c0a4425849ab3cdb03d9dfacba69684609aea04d08ff9" +checksum = "1cac193374347e7c263c5f547524f36ff8ec6702d56c8799c8331d26dffe8c1e" dependencies = [ "cfg-if", "doc-comment", "libc", + "ntapi", + "once_cell", "rayon", "winapi 0.3.8", ] @@ -5653,12 +6868,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" -[[package]] -name = "target_info" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" - [[package]] name = "tempfile" version = "3.1.0" @@ -5692,12 +6901,23 @@ dependencies = [ ] [[package]] -name = "thread_local" -version = "0.3.6" +name = "thiserror" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" dependencies = [ - "lazy_static", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +dependencies = [ + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -5711,9 +6931,9 @@ dependencies = [ [[package]] name = "threadpool" -version = "1.7.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" dependencies = [ "num_cpus", ] @@ -5731,24 +6951,25 @@ dependencies = [ [[package]] name = "tiny-bip39" -version = "0.6.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" +checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" dependencies = [ "failure", - "hashbrown 0.1.8", "hmac", - "once_cell 0.1.8", + "once_cell", "pbkdf2", - "rand 0.6.5", - "sha2", + "rand 0.7.3", + "rustc-hash", + "sha2 0.8.1", + "unicode-normalization", ] [[package]] name = "tiny-keccak" -version = "1.5.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" dependencies = [ "crunchy", ] @@ -5765,11 +6986,11 @@ dependencies = [ "num_cpus", "tokio-codec", "tokio-current-thread", - "tokio-executor", + "tokio-executor 0.1.10", "tokio-fs", "tokio-io", "tokio-reactor", - "tokio-sync", + "tokio-sync 0.1.8", "tokio-tcp", "tokio-threadpool", "tokio-timer", @@ -5777,6 +6998,28 @@ dependencies = [ "tokio-uds", ] +[[package]] +name = "tokio" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +dependencies = [ + "bytes 0.5.6", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "libc", + "memchr", + "mio", + "mio-uds", + "num_cpus", + "pin-project-lite", + "signal-hook-registry", + "slab", + "winapi 0.3.8", +] + [[package]] name = "tokio-buf" version = "0.1.1" @@ -5806,29 +7049,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" dependencies = [ "futures 0.1.29", - "tokio-executor", + "tokio-executor 0.1.10", ] [[package]] -name = "tokio-dns-unofficial" -version = "0.4.0" +name = "tokio-executor" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c65483db54eb91b4ef3a9389a3364558590faf30ce473141707c0e16fda975" +checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" dependencies = [ + "crossbeam-utils", "futures 0.1.29", - "futures-cpupool", - "lazy_static", - "tokio", ] [[package]] name = "tokio-executor" -version = "0.1.10" +version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" +checksum = "9ee9ceecf69145923834ea73f32ba40c790fd877b74a7817dd0b089f1eb9c7c8" dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures-util-preview", + "lazy_static", + "tokio-sync 0.2.0-alpha.6", ] [[package]] @@ -5853,13 +7095,26 @@ dependencies = [ "log", ] +[[package]] +name = "tokio-named-pipes" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d282d483052288b2308ba5ee795f5673b159c9bdf63c385a05609da782a5eae" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "mio", + "mio-named-pipes", + "tokio 0.1.22", +] + [[package]] name = "tokio-reactor" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" dependencies = [ - "crossbeam-utils 0.7.2", + "crossbeam-utils", "futures 0.1.29", "lazy_static", "log", @@ -5867,25 +7122,32 @@ dependencies = [ "num_cpus", "parking_lot 0.9.0", "slab", - "tokio-executor", + "tokio-executor 0.1.10", "tokio-io", - "tokio-sync", + "tokio-sync 0.1.8", ] [[package]] name = "tokio-rustls" -version = "0.10.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d7cf08f990090abd6c6a73cab46fed62f85e8aef8b99e4b918a9f4a637f0676" +checksum = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "iovec", + "futures-core", "rustls", - "tokio-io", + "tokio 0.2.22", "webpki", ] +[[package]] +name = "tokio-service" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" +dependencies = [ + "futures 0.1.29", +] + [[package]] name = "tokio-sync" version = "0.1.8" @@ -5896,6 +7158,17 @@ dependencies = [ "futures 0.1.29", ] +[[package]] +name = "tokio-sync" +version = "0.2.0-alpha.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f1aaeb685540f7407ea0e27f1c9757d258c7c6bf4e3eb19da6fc59b747239d2" +dependencies = [ + "fnv", + "futures-core-preview", + "futures-util-preview", +] + [[package]] name = "tokio-tcp" version = "0.1.4" @@ -5918,13 +7191,13 @@ checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" dependencies = [ "crossbeam-deque", "crossbeam-queue", - "crossbeam-utils 0.7.2", + "crossbeam-utils", "futures 0.1.29", "lazy_static", "log", "num_cpus", "slab", - "tokio-executor", + "tokio-executor 0.1.10", ] [[package]] @@ -5933,10 +7206,10 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" dependencies = [ - "crossbeam-utils 0.7.2", + "crossbeam-utils", "futures 0.1.29", "slab", - "tokio-executor", + "tokio-executor 0.1.10", ] [[package]] @@ -5956,9 +7229,9 @@ dependencies = [ [[package]] name = "tokio-uds" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798" +checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" dependencies = [ "bytes 0.4.12", "futures 0.1.29", @@ -5972,6 +7245,20 @@ dependencies = [ "tokio-reactor", ] +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio 0.2.22", +] + [[package]] name = "toml" version = "0.5.6" @@ -5981,6 +7268,44 @@ dependencies = [ "serde", ] +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] +name = "tracing" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e2a2de6b0d5cbb13fc21193a2296888eaab62b6044479aafb3c54c01c29fcd" +dependencies = [ + "cfg-if", + "log", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" +dependencies = [ + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "tracing-core" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f" +dependencies = [ + "lazy_static", +] + [[package]] name = "treeline" version = "0.1.0" @@ -5989,42 +7314,31 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] name = "trie-db" -version = "0.15.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" +checksum = "cb230c24c741993b04cfccbabb45acff6f6480c5f00d3ed8794ea43db3a9d727" dependencies = [ - "elastic-array", "hash-db", "hashbrown 0.6.3", "log", - "rand 0.6.5", + "rustc-hex", + "smallvec 1.4.1", ] [[package]] name = "trie-root" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" +checksum = "652931506d2c1244d7217a70b99f56718a7b4161b37f04e7cd868072a99f68cd" dependencies = [ "hash-db", ] [[package]] name = "try-lock" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" - -[[package]] -name = "twofish" -version = "0.2.0" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -dependencies = [ - "block-cipher-trait", - "byteorder 1.3.4", - "opaque-debug", -] +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "twox-hash" @@ -6043,11 +7357,11 @@ checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" [[package]] name = "uint" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75a4cdd7b87b28840dba13c483b9a88ee6bbf16ba5c951ee1ecfcf723078e0d" +checksum = "173cd16430c206dc1a430af8a89a0e9c076cf15cb42b4aedb10e8cc8fee73681" dependencies = [ - "byteorder 1.3.4", + "byteorder", "crunchy", "rustc-hex", "static_assertions", @@ -6059,7 +7373,7 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" dependencies = [ - "version_check 0.9.1", + "version_check", ] [[package]] @@ -6077,7 +7391,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" dependencies = [ - "smallvec 1.2.0", + "smallvec 1.4.1", ] [[package]] @@ -6088,15 +7402,15 @@ checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" [[package]] name = "unicode-width" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.1.0" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" [[package]] name = "unicode-xid" @@ -6104,27 +7418,43 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +[[package]] +name = "universal-hash" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +dependencies = [ + "generic-array 0.14.3", + "subtle 2.2.2", +] + [[package]] name = "unsigned-varint" -version = "0.2.3" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f0023a96687fe169081e8adce3f65e3874426b7886e9234d490af2dc077959" +checksum = "f67332660eb59a6f1eb24ff1220c9e8d01738a8503c6002e30bcfe4bd9f2b4a9" dependencies = [ - "bytes 0.4.12", - "tokio-codec", + "bytes 0.5.6", + "futures-io", + "futures-util", + "futures_codec 0.3.4", ] [[package]] name = "unsigned-varint" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f38e01ad4b98f042e166c1bf9a13f9873a99d79eaa171ce7ca81e6dd0f895d8a" +checksum = "669d776983b692a906c881fcd0cfb34271a48e197e4d6cb8df32b05bfc3d3fa5" +dependencies = [ + "bytes 0.5.6", + "futures_codec 0.4.0", +] [[package]] name = "untrusted" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" @@ -6150,37 +7480,21 @@ dependencies = [ [[package]] name = "vcpkg" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" +checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" [[package]] name = "vec_map" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" - -[[package]] -name = "vergen" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ce50d8996df1f85af15f2cd8d33daae6e479575123ef4314a51a70a230739cb" -dependencies = [ - "bitflags", - "chrono", -] - -[[package]] -name = "version_check" -version = "0.1.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] name = "void" @@ -6199,6 +7513,16 @@ dependencies = [ "try-lock", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -6224,20 +7548,19 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.3.27" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" +checksum = "7add542ea1ac7fdaa9dc25e031a6af33b7d63376292bd24140c637d00d1c312a" dependencies = [ "cfg-if", - "futures 0.1.29", "js-sys", "wasm-bindgen", "web-sys", @@ -6249,7 +7572,7 @@ version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" dependencies = [ - "quote 1.0.3", + "quote 1.0.7", "wasm-bindgen-macro-support", ] @@ -6259,8 +7582,8 @@ version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -6274,37 +7597,39 @@ checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" [[package]] name = "wasm-timer" -version = "0.1.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa3e01d234bb71760e685cfafa5e2c96f8ad877c161a721646356651069e26ac" +checksum = "324c5e65a08699c9c4334ba136597ab22b85dccd4b65dd1e36ccf8f723a95b54" dependencies = [ - "futures 0.1.29", + "futures 0.3.4", "js-sys", - "send_wrapper", - "tokio-timer", + "parking_lot 0.9.0", + "pin-utils", + "send_wrapper 0.2.0", "wasm-bindgen", + "wasm-bindgen-futures", "web-sys", ] [[package]] name = "wasmi" -version = "0.5.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31d26deb2d9a37e6cfed420edce3ed604eab49735ba89035e13c98f9a528313" +checksum = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" dependencies = [ "libc", "memory_units", "num-rational", - "num-traits", + "num-traits 0.2.11", "parity-wasm", "wasmi-validation", ] [[package]] name = "wasmi-validation" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" +checksum = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" dependencies = [ "parity-wasm", ] @@ -6321,9 +7646,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" +checksum = "ab146130f5f790d45f82aeeb09e55a256573373ec64409fc19a6fb82fb1032ae" dependencies = [ "ring", "untrusted", @@ -6331,29 +7656,28 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b" +checksum = "91cd5736df7f12a964a5067a12c62fa38e1bd8080aff1f80bc29be7c80d19ab4" dependencies = [ "webpki", ] [[package]] name = "webpki-roots" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cd5736df7f12a964a5067a12c62fa38e1bd8080aff1f80bc29be7c80d19ab4" +checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739" dependencies = [ "webpki", ] [[package]] name = "which" -version = "2.0.1" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" dependencies = [ - "failure", "libc", ] @@ -6387,9 +7711,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi 0.3.8", ] @@ -6406,7 +7730,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c51a2c47b5798ccc774ffb93ff536aec7c4275d722fd9c740c83cdd1af1f2d94" dependencies = [ - "byteorder 1.3.4", + "byteorder", "bytes 0.4.12", "httparse", "log", @@ -6430,50 +7754,29 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" +checksum = "637ff90c9540fa3073bb577e65033069e4bae7c79d49d74aa3ffdf5342a53217" dependencies = [ - "clear_on_drop", - "curve25519-dalek 1.2.3", - "rand_core 0.3.1", + "curve25519-dalek", + "rand_core 0.5.1", + "zeroize", ] -[[package]] -name = "xdg" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" - [[package]] name = "yamux" -version = "0.2.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2758f29014c1cb7a6e74c1b1160ac8c8203be342d35b73462fc6a13cc6385423" +checksum = "cd37e58a1256a0b328ce9c67d8b62ecdd02f4803ba443df478835cb1a41a637c" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", + "futures 0.3.4", "log", "nohash-hasher", - "parking_lot 0.9.0", - "quick-error", + "parking_lot 0.10.2", "rand 0.7.3", - "tokio-codec", - "tokio-io", + "static_assertions", ] -[[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" @@ -6489,8 +7792,8 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote 1.0.7", "syn 1.0.17", "synstructure", ] diff --git a/README.md b/README.md index a02cd6cf47..47c8a285a8 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,12 @@ During a rebase/merge you may want to skip all hooks, you can use `HUSKY_SKIP_HO HUSKY_SKIP_HOOKS=1 git rebase ... ``` +## RLS Extension in VScode or Atom Editors + +If you use RLS extension in your IDE, start your editor with the `BUILD_DUMMY_WASM_BINARY=1` environment set to workaround a build issue that occurs in the IDE only. + +`BUILD_DUMMY_WASM_BINARY=1 code ./joystream` + ## Authors See the list of [contributors](https://github.com/Joystream/joystream/graphs/contributors) who participated in this project. diff --git a/node/Cargo.toml b/node/Cargo.toml index 575c9df614..f7ccadb54d 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,9 +1,9 @@ [package] -authors = ['Joystream'] +authors = ['Joystream contributors'] build = 'build.rs' edition = '2018' name = 'joystream-node' -version = '2.7.0' +version = '3.0.0' default-run = "joystream-node" [[bin]] @@ -14,143 +14,97 @@ path = 'bin/main.rs' crate-type = ["cdylib", "rlib"] [dependencies] -hex-literal = '0.2.1' -derive_more = '0.14.0' -exit-future = '0.1.4' -futures = '0.1.29' -log = '0.4.8' -parking_lot = '0.9.0' -tokio = '0.1.22' -jsonrpc-core = '13.2.0' -rand = '0.7.2' -structopt = '=0.3.5' +# third-party dependencies +serde = { version = "1.0.102", features = ["derive"] } +futures = { version = "0.3.1", features = ["compat"] } +jsonrpc-core = "14.2.0" +structopt = { version = "0.3.8", optional = true} serde_json = '1.0' -serde = '1.0' -hex = '0.4' -# https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -# quote = '<=1.0.2' -[dependencies.node-runtime] -package = 'joystream-node-runtime' -path = '../runtime' - -[dependencies.substrate-basic-authorship] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-basic-authorship' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.babe] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-consensus-babe' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.babe-primitives] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-consensus-babe-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.ctrlc] -features = ['termination'] -version = '3.0' - -[dependencies.inherents] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-inherents' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.network] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-network' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.primitives] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.sr-io] -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-cli] -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-client] -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-executor] -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-service] -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.transaction-pool] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-transaction-pool' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-telemetry] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-telemetry' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.grandpa] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-finality-grandpa' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.grandpa-primitives] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-finality-grandpa-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.im-online] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-im-online' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-rpc] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-rpc' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.authority-discovery] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-authority-discovery' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.client-db] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-client-db' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.runtime-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.offchain] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-offchain' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.libp2p] -version = '0.13.2' -default-features = false +# primitives +sp-authority-discovery = { package = 'sp-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-consensus-babe = { package = 'sp-consensus-babe', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-finality-grandpa = { package = 'sp-finality-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-core = { package = 'sp-core', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-runtime = { package = 'sp-runtime', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-finality-tracker = { package = 'sp-finality-tracker', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-inherents = { package = 'sp-inherents', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-consensus = { package = 'sp-consensus', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-transaction-pool = { package = 'sp-transaction-pool', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-api = { package = 'sp-api', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-blockchain = { package = 'sp-blockchain', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-block-builder = { package = 'sp-block-builder', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } + +# client dependencies +sc-client-api = { package = 'sc-client-api', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-chain-spec = { package = 'sc-chain-spec', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-consensus = { package = 'sc-consensus', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-transaction-pool = { package = 'sc-transaction-pool', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-network = { package = 'sc-network', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-consensus-babe = { package = 'sc-consensus-babe', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sc-finality-grandpa = { package = 'sc-finality-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-basic-authorship = { package = 'sc-basic-authorship', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-service = { package = 'sc-service', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-authority-discovery = { package = 'sc-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-consensus-epochs = { package = 'sc-consensus-epochs', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-keystore = { package = 'sc-keystore', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-consensus-babe-rpc = { package = 'sc-consensus-babe-rpc', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-finality-grandpa-rpc = { package = 'sc-finality-grandpa-rpc', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-rpc-api = { package = 'sc-rpc-api', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-executor = { package = 'sc-executor', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } + +# frame dependencies +pallet-im-online = { package = 'pallet-im-online', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +pallet-transaction-payment-rpc = { package = 'pallet-transaction-payment-rpc', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +substrate-frame-rpc-system = { package = 'substrate-frame-rpc-system', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +frame-benchmarking = { package = 'frame-benchmarking', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } + +# node-specific dependencies +node-runtime = { package= "joystream-node-runtime", path = "../runtime" } + +# CLI-specific dependencies +sc-cli = { package = 'sc-cli', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true } +frame-benchmarking-cli = { package = 'frame-benchmarking-cli', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true } +node-inspect = { package = 'node-inspect', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true } + +# WASM-specific dependencies +wasm-bindgen = { version = "0.2.57", optional = true } +wasm-bindgen-futures = { version = "0.4.7", optional = true } +browser-utils = { package = 'substrate-browser-utils', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true} + +[dev-dependencies] +tempfile = "3.1.0" +codec = { package = "parity-scale-codec", version = "1.3.1" } +sp-timestamp = { package = 'sp-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-keyring = { package = 'sp-keyring', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-consensus-babe = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', features = ["test-helpers"]} +frame-system = { package = 'frame-system', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +pallet-transaction-payment = { package = 'pallet-transaction-payment', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +pallet-grandpa = { package = 'pallet-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } [build-dependencies] -vergen = '3' +structopt = { version = "0.3.8", optional = true } +node-inspect = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true} +sc-cli = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true} +frame-benchmarking-cli = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true } +substrate-build-script-utils = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true } + +[features] +default = [ "cli" ] +browser = [ + "browser-utils", + "wasm-bindgen", + "wasm-bindgen-futures", +] +cli = [ + "node-inspect", + "sc-cli", + "frame-benchmarking-cli", + "sc-service/db", + "structopt", + "substrate-build-script-utils", +] +runtime-benchmarks = [ + "node-runtime/runtime-benchmarks", + "frame-benchmarking-cli", +] diff --git a/node/bin/main.rs b/node/bin/main.rs index 70006bf571..9298282e3a 100644 --- a/node/bin/main.rs +++ b/node/bin/main.rs @@ -14,27 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Joystream node. If not, see . -//! Substrate Node Template CLI library. +//! Joystream Node. #![warn(missing_docs)] -#![warn(unused_extern_crates)] -use joystream_node::cli; -pub use substrate_cli::{error, IntoExit, VersionInfo}; - -fn main() { - let version = VersionInfo { - name: "Joystream Node", - commit: env!("VERGEN_SHA_SHORT"), - version: env!("CARGO_PKG_VERSION"), - executable_name: "joystream-node", - author: "Joystream", - description: "Joystream substrate node", - support_url: "https://www.joystream.org/", - }; - - if let Err(e) = cli::run(::std::env::args(), cli::Exit, version) { - eprintln!("Fatal error: {}\n\n{:?}", e, e); - std::process::exit(1) - } +fn main() -> sc_cli::Result<()> { + joystream_node::command::run() } diff --git a/node/build.rs b/node/build.rs index 9a51c38b81..f148b56c32 100644 --- a/node/build.rs +++ b/node/build.rs @@ -1,27 +1,72 @@ -use std::{env, path::PathBuf}; +// This file is part of Substrate. -use vergen::{generate_cargo_keys, ConstantsFlags}; +// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 -const ERROR_MSG: &str = "Failed to generate metadata files"; +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . fn main() { - generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG); - - let mut manifest_dir = PathBuf::from( - env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is always set by cargo."), - ); - - while manifest_dir.parent().is_some() { - if manifest_dir.join(".git/HEAD").exists() { - println!( - "cargo:rerun-if-changed={}", - manifest_dir.join(".git/HEAD").display() - ); - return; - } + #[cfg(feature = "cli")] + cli::main(); +} + +#[cfg(feature = "cli")] +mod cli { + include!("src/cli.rs"); + + use sc_cli::structopt::clap::Shell; + use std::{env, fs, path::Path}; + use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; + + pub fn main() { + build_shell_completion(); + generate_cargo_keys(); - manifest_dir.pop(); + rerun_if_git_head_changed(); } - println!("cargo:warning=Could not find `.git/HEAD` from manifest dir!"); + /// Build shell completion scripts for all known shells + /// Full list in https://github.com/kbknapp/clap-rs/blob/e9d0562a1dc5dfe731ed7c767e6cee0af08f0cf9/src/app/parser.rs#L123 + fn build_shell_completion() { + for shell in &[ + Shell::Bash, + Shell::Fish, + Shell::Zsh, + Shell::Elvish, + Shell::PowerShell, + ] { + build_completion(shell); + } + } + + /// Build the shell auto-completion for a given Shell + fn build_completion(shell: &Shell) { + let outdir = match env::var_os("OUT_DIR") { + None => return, + Some(dir) => dir, + }; + let path = Path::new(&outdir) + .parent() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap() + .join("completion-scripts"); + + fs::create_dir(&path).ok(); + + Cli::clap().gen_completions("joystream-node", *shell, &path); + } } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 6e8c973fba..5b8ea39cd1 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -19,30 +19,33 @@ // Example: voting_period: 1 * DAY #![allow(clippy::identity_op)] +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use serde_json as json; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_core::{sr25519, Pair, Public}; +use sp_finality_grandpa::AuthorityId as GrandpaId; +use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_runtime::Perbill; + use node_runtime::{ versioned_store::InputValidationLengthConstraint as VsInputValidation, AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig, CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig, - DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig, - MembersConfig, MigrationConfig, Perbill, ProposalsCodexConfig, SessionConfig, SessionKeys, - Signature, StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig, SystemConfig, - VersionedStoreConfig, DAYS, WASM_BINARY, + DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, MembersConfig, + ProposalsCodexConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig, + StorageWorkingGroupConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY, }; -pub use node_runtime::{AccountId, GenesisConfig}; -use primitives::{sr25519, Pair, Public}; -use runtime_primitives::traits::{IdentifyAccount, Verify}; -use babe_primitives::AuthorityId as BabeId; -use grandpa_primitives::AuthorityId as GrandpaId; -use im_online::sr25519::AuthorityId as ImOnlineId; -use serde_json as json; +pub use node_runtime::{AccountId, GenesisConfig}; type AccountPublic = ::Signer; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. -pub type ChainSpec = substrate_service::ChainSpec; +pub type ChainSpec = sc_service::GenericChainSpec; use node_runtime::common::constraints::InputValidationLengthConstraint; +use sc_chain_spec::ChainType; /// The chain specification option. This is expected to come in from the CLI and /// is little more than one of a number of alternatives which can easily be converted @@ -73,21 +76,35 @@ where /// Helper function to generate stash, controller and session key from seed pub fn get_authority_keys_from_seed( seed: &str, -) -> (AccountId, AccountId, GrandpaId, BabeId, ImOnlineId) { +) -> ( + AccountId, + AccountId, + GrandpaId, + BabeId, + ImOnlineId, + AuthorityDiscoveryId, +) { ( get_account_id_from_seed::(&format!("{}//stash", seed)), get_account_id_from_seed::(seed), get_from_seed::(seed), get_from_seed::(seed), get_from_seed::(seed), + get_from_seed::(seed), ) } -fn session_keys(grandpa: GrandpaId, babe: BabeId, im_online: ImOnlineId) -> SessionKeys { +fn session_keys( + grandpa: GrandpaId, + babe: BabeId, + im_online: ImOnlineId, + authority_discovery: AuthorityDiscoveryId, +) -> SessionKeys { SessionKeys { grandpa, babe, im_online, + authority_discovery, } } @@ -98,6 +115,7 @@ impl Alternative { Alternative::Development => ChainSpec::from_genesis( "Development", "dev", + ChainType::Development, || { testnet_genesis( vec![get_authority_keys_from_seed("Alice")], @@ -111,7 +129,7 @@ impl Alternative { crate::proposals_config::development(), ) }, - vec![], + Vec::new(), None, None, Some(chain_spec_properties()), @@ -120,6 +138,7 @@ impl Alternative { Alternative::LocalTestnet => ChainSpec::from_genesis( "Local Testnet", "local_testnet", + ChainType::Local, || { testnet_genesis( vec![ @@ -144,7 +163,7 @@ impl Alternative { crate::proposals_config::development(), ) }, - vec![], + Vec::new(), None, None, Some(chain_spec_properties()), @@ -152,14 +171,6 @@ impl Alternative { ), }) } - - pub(crate) fn from(s: &str) -> Option { - match s { - "dev" => Some(Alternative::Development), - "local" => Some(Alternative::LocalTestnet), - _ => None, - } - } } fn new_vs_validation(min: u16, max_min_diff: u16) -> VsInputValidation { @@ -180,7 +191,14 @@ pub fn chain_spec_properties() -> json::map::Map { } pub fn testnet_genesis( - initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId, ImOnlineId)>, + initial_authorities: Vec<( + AccountId, + AccountId, + GrandpaId, + BabeId, + ImOnlineId, + AuthorityDiscoveryId, + )>, root_key: AccountId, endowed_accounts: Vec, cpcp: node_runtime::ProposalsConfigParameters, @@ -197,29 +215,15 @@ pub fn testnet_genesis( code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), }), - balances: Some(BalancesConfig { + pallet_balances: Some(BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, ENDOWMENT)) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .collect(), - vesting: vec![], }), - indices: Some(IndicesConfig { ids: vec![] }), - session: Some(SessionConfig { - keys: initial_authorities - .iter() - .map(|x| { - ( - x.0.clone(), - session_keys(x.2.clone(), x.3.clone(), x.4.clone()), - ) - }) - .collect::>(), - }), - staking: Some(StakingConfig { - current_era: 0, + pallet_staking: Some(StakingConfig { validator_count: 20, minimum_validator_count: 1, stakers: initial_authorities @@ -230,15 +234,29 @@ pub fn testnet_genesis( slash_reward_fraction: Perbill::from_percent(10), ..Default::default() }), - sudo: Some(SudoConfig { key: root_key }), - babe: Some(BabeConfig { + pallet_sudo: Some(SudoConfig { + key: root_key.clone(), + }), + pallet_babe: Some(BabeConfig { authorities: vec![], }), - im_online: Some(ImOnlineConfig { keys: vec![] }), - authority_discovery: Some(AuthorityDiscoveryConfig { keys: vec![] }), - grandpa: Some(GrandpaConfig { + pallet_im_online: Some(ImOnlineConfig { keys: vec![] }), + pallet_authority_discovery: Some(AuthorityDiscoveryConfig { keys: vec![] }), + pallet_grandpa: Some(GrandpaConfig { authorities: vec![], }), + pallet_session: Some(SessionConfig { + keys: initial_authorities + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()), + ) + }) + .collect::>(), + }), council: Some(CouncilConfig { active_council: vec![], term_ends_at: 1, @@ -260,9 +278,7 @@ pub fn testnet_genesis( default_paid_membership_fee: 100u128, members: vec![], }), - forum: Some(crate::forum_config::from_serialized::create( - endowed_accounts[0].clone(), - )), + forum: Some(crate::forum_config::from_serialized::create(root_key)), data_object_type_registry: Some(DataObjectTypeRegistryConfig { first_data_object_type_id: 1, }), @@ -310,7 +326,6 @@ pub fn testnet_genesis( channel_banner_constraint: InputValidationLengthConstraint::new(5, 1024), channel_title_constraint: InputValidationLengthConstraint::new(5, 1024), }), - migration: Some(MigrationConfig {}), proposals_codex: Some(ProposalsCodexConfig { set_validator_count_proposal_voting_period: cpcp .set_validator_count_proposal_voting_period, diff --git a/node/src/cli.rs b/node/src/cli.rs index 9c33d231aa..6acca3e920 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -1,128 +1,48 @@ -use crate::chain_spec; -use crate::new_full_start; -use crate::service; -use futures::{future, sync::oneshot, Future}; -use log::info; -use std::cell::RefCell; -pub use substrate_cli::{error, IntoExit, VersionInfo}; -use substrate_cli::{informant, parse_and_prepare, NoCustom, ParseAndPrepare}; -use substrate_service::{AbstractService, Configuration, Roles as ServiceRoles}; -use tokio::runtime::Runtime; - -/// Parse command line arguments into service configuration. -pub fn run(args: I, exit: E, version: VersionInfo) -> error::Result<()> -where - I: IntoIterator, - T: Into + Clone, - E: IntoExit, -{ - type Config = Configuration<(), T>; - match parse_and_prepare::(&version, "joystream-node", args) { - ParseAndPrepare::Run(cmd) => cmd.run( - load_spec, - exit, - |exit, _cli_args, _custom_args, config: Config<_>| { - info!("{}", version.name); - info!(" version {}", config.full_version()); - info!(" by {}, 2019", version.author); - info!("Chain specification: {}", config.chain_spec.name()); - info!("Node name: {}", config.name); - info!("Roles: {:?}", config.roles); - let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?; - match config.roles { - ServiceRoles::LIGHT => run_until_exit( - runtime, - service::new_light(config).map_err(|e| format!("{:?}", e))?, - exit, - ), - _ => run_until_exit( - runtime, - service::new_full(config).map_err(|e| format!("{:?}", e))?, - exit, - ), - } - .map_err(|e| format!("{:?}", e)) - }, - ), - ParseAndPrepare::BuildSpec(cmd) => cmd.run::(load_spec), - ParseAndPrepare::ExportBlocks(cmd) => cmd.run_with_builder( - |config: Config<_>| Ok(new_full_start!(config).0), - load_spec, - exit, - ), - ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder( - |config: Config<_>| Ok(new_full_start!(config).0), - load_spec, - exit, - ), - ParseAndPrepare::PurgeChain(cmd) => cmd.run(load_spec), - ParseAndPrepare::RevertChain(cmd) => { - cmd.run_with_builder(|config: Config<_>| Ok(new_full_start!(config).0), load_spec) - } - ParseAndPrepare::CustomCommand(_) => Ok(()), - }?; - - Ok(()) -} - -fn load_spec(id: &str) -> Result, String> { - Ok(match chain_spec::Alternative::from(id) { - Some(spec) => Some(spec.load()?), - None => None, - }) -} - -fn run_until_exit(mut runtime: Runtime, service: T, e: E) -> error::Result<()> -where - T: AbstractService, - E: IntoExit, -{ - let (exit_send, exit) = exit_future::signal(); - - let informant = informant::build(&service); - runtime.executor().spawn(exit.until(informant).map(|_| ())); - - // we eagerly drop the service so that the internal exit future is fired, - // but we need to keep holding a reference to the global telemetry guard - let _telemetry = service.telemetry(); - - let service_res = { - let exit = e - .into_exit() - .map_err(|_| error::Error::Other("Exit future failed.".into())); - let service = service.map_err(error::Error::Service); - let select = service.select(exit).map(|_| ()).map_err(|(err, _)| err); - runtime.block_on(select) - }; - - exit_send.fire(); - - // TODO [andre]: timeout this future #1318 - let _ = runtime.shutdown_on_idle().wait(); - - service_res +// Copyright 2019 Joystream Contributors +// This file is part of Joystream node. + +// Joystream node is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Joystream node is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Joystream node. If not, see . + +use sc_cli::RunCmd; +use structopt::StructOpt; + +/// An overarching CLI command definition. +#[derive(Debug, StructOpt)] +pub struct Cli { + /// Possible subcommand with parameters. + #[structopt(subcommand)] + pub subcommand: Option, + #[allow(missing_docs)] + #[structopt(flatten)] + pub run: RunCmd, } -// handles ctrl-c -pub struct Exit; -impl IntoExit for Exit { - type Exit = future::MapErr, fn(oneshot::Canceled) -> ()>; - fn into_exit(self) -> Self::Exit { - // can't use signal directly here because CtrlC takes only `Fn`. - let (exit_send, exit) = oneshot::channel(); - - let exit_send_cell = RefCell::new(Some(exit_send)); - ctrlc::set_handler(move || { - let exit_send = exit_send_cell - .try_borrow_mut() - .expect("signal handler not reentrant; qed") - .take(); - if let Some(exit_send) = exit_send { - exit_send.send(()).expect("Error sending exit notification"); - } - }) - .expect("Error setting Ctrl-C handler"); - - exit.map_err(drop) - } +/// Possible subcommands of the main binary. +#[derive(Debug, StructOpt)] +pub enum Subcommand { + /// A set of base subcommands handled by `sc_cli`. + #[structopt(flatten)] + Base(sc_cli::Subcommand), + + /// The custom inspect subcommmand for decoding blocks and extrinsics. + #[structopt( + name = "inspect", + about = "Decode given block or extrinsic using current native runtime." + )] + Inspect(node_inspect::cli::InspectCmd), + + /// The custom benchmark subcommmand benchmarking runtime pallets. + #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")] + Benchmark(frame_benchmarking_cli::BenchmarkCmd), } diff --git a/node/src/command.rs b/node/src/command.rs new file mode 100644 index 0000000000..5372c9c7eb --- /dev/null +++ b/node/src/command.rs @@ -0,0 +1,100 @@ +// Copyright 2019 Joystream Contributors +// This file is part of Joystream node. + +// Joystream node is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Joystream node is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Joystream node. If not, see . + +use crate::cli::{Cli, Subcommand}; +use crate::node_executor; +use crate::node_rpc; +use crate::{chain_spec, service}; + +use node_executor::Executor; +use node_runtime::{opaque::Block, RuntimeApi}; +use sc_cli::{Result, SubstrateCli}; +use sc_finality_grandpa::{self as grandpa}; + +impl SubstrateCli for Cli { + fn impl_name() -> &'static str { + "Joystream Node" + } + + fn support_url() -> &'static str { + "https://www.joystream.org/" + } + + fn copyright_start_year() -> i32 { + 2019 + } + + fn executable_name() -> &'static str { + "joystream-node" + } + + fn impl_version() -> &'static str { + env!("SUBSTRATE_CLI_IMPL_VERSION") + } + + fn description() -> &'static str { + env!("CARGO_PKG_DESCRIPTION") + } + + fn author() -> &'static str { + env!("CARGO_PKG_AUTHORS") + } + + fn load_spec(&self, id: &str) -> std::result::Result, String> { + Ok(match id { + "dev" => Box::new(chain_spec::Alternative::Development.load()?), + "local" => Box::new(chain_spec::Alternative::LocalTestnet.load()?), + path => Box::new(chain_spec::ChainSpec::from_json_file( + std::path::PathBuf::from(path), + )?), + }) + } +} + +/// Parse command line arguments into service configuration. +pub fn run() -> Result<()> { + let cli = Cli::from_args(); + + match &cli.subcommand { + None => { + let runner = cli.create_runner(&cli.run)?; + runner.run_node(service::new_light, service::new_full, node_runtime::VERSION) + } + Some(Subcommand::Inspect(cmd)) => { + let runner = cli.create_runner(cmd)?; + + runner.sync_run(|config| cmd.run::(config)) + } + Some(Subcommand::Benchmark(cmd)) => { + if cfg!(feature = "runtime-benchmarks") { + let runner = cli.create_runner(cmd)?; + + runner.sync_run(|config| cmd.run::(config)) + } else { + println!( + "Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`." + ); + Ok(()) + } + } + Some(Subcommand::Base(subcommand)) => { + let runner = cli.create_runner(subcommand)?; + + runner.run_subcommand(subcommand, |config| Ok(new_full_start!(config).0)) + } + } +} diff --git a/node/src/lib.rs b/node/src/lib.rs index 00e26a1d52..3715eeffdf 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -3,4 +3,8 @@ pub mod cli; pub mod forum_config; pub mod members_config; pub mod proposals_config; +#[macro_use] pub mod service; +pub mod command; +pub mod node_executor; +pub mod node_rpc; diff --git a/node/src/members_config.rs b/node/src/members_config.rs index 23172e9918..7b33e21b9b 100644 --- a/node/src/members_config.rs +++ b/node/src/members_config.rs @@ -1,7 +1,7 @@ use serde::Deserialize; use serde_json::Result; -use primitives::crypto::{AccountId32, Ss58Codec}; +use sp_core::crypto::{AccountId32, Ss58Codec}; #[derive(Deserialize)] struct Member { @@ -12,18 +12,6 @@ struct Member { about: String, } -// fn test_load_members() -> Result> { -// let data = r#" -// [{ -// "address": "5Gn9n7SDJ7VgHqHQWYzkSA4vX6DCmS5TFWdHxikTXp9b4L32", -// "handle": "mokhtar", -// "avatar_uri": "http://mokhtar.net/avatar.png", -// "about": "Mokhtar" -// }]"#; - -// serde_json::from_str(data) -// } - fn parse_members_json() -> Result> { let data = include_str!("../res/acropolis_members.json"); serde_json::from_str(data) diff --git a/node/src/node_executor.rs b/node/src/node_executor.rs new file mode 100644 index 0000000000..665ca94898 --- /dev/null +++ b/node/src/node_executor.rs @@ -0,0 +1,10 @@ +use sc_executor::native_executor_instance; + +// Declare an instance of the native executor named `Executor`. Include the wasm binary as the +// equivalent wasm code. +native_executor_instance!( + pub Executor, + node_runtime::api::dispatch, + node_runtime::native_version, + frame_benchmarking::benchmarking::HostFunctions, +); diff --git a/node/src/node_rpc.rs b/node/src/node_rpc.rs new file mode 100644 index 0000000000..f33509e208 --- /dev/null +++ b/node/src/node_rpc.rs @@ -0,0 +1,188 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! A collection of node-specific RPC methods. +//! +//! Since `substrate` core functionality makes no assumptions +//! about the modules used inside the runtime, so do +//! RPC methods defined in `sc-rpc` crate. +//! It means that `client/rpc` can't have any methods that +//! need some strong assumptions about the particular runtime. +//! +//! The RPCs available in this crate however can make some assumptions +//! about how the runtime is constructed and what FRAME pallets +//! are part of it. Therefore all node-runtime-specific RPCs can +//! be placed here or imported from corresponding FRAME RPC definitions. + +#![warn(missing_docs)] + +use std::sync::Arc; + +use node_runtime::UncheckedExtrinsic; +use node_runtime::{opaque::Block, AccountId, Balance, BlockNumber, Hash, Index}; +use sc_consensus_babe::{Config, Epoch}; +use sc_consensus_babe_rpc::BabeRpcHandler; +use sc_consensus_epochs::SharedEpochChanges; +use sc_finality_grandpa::{SharedAuthoritySet, SharedVoterState}; +use sc_finality_grandpa_rpc::GrandpaRpcHandler; +use sc_keystore::KeyStorePtr; +use sc_rpc_api::DenyUnsafe; +use sp_api::ProvideRuntimeApi; +use sp_block_builder::BlockBuilder; +use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; +use sp_consensus::SelectChain; +use sp_consensus_babe::BabeApi; +use sp_transaction_pool::TransactionPool; + +/// Light client extra dependencies. +pub struct LightDeps { + /// The client instance to use. + pub client: Arc, + /// Transaction pool instance. + pub pool: Arc

, + /// Remote access to the blockchain (async). + pub remote_blockchain: Arc>, + /// Fetcher instance. + pub fetcher: Arc, +} + +/// Extra dependencies for BABE. +pub struct BabeDeps { + /// BABE protocol config. + pub babe_config: Config, + /// BABE pending epoch changes. + pub shared_epoch_changes: SharedEpochChanges, + /// The keystore that manages the keys of the node. + pub keystore: KeyStorePtr, +} + +/// Extra dependencies for GRANDPA +pub struct GrandpaDeps { + /// Voting round info. + pub shared_voter_state: SharedVoterState, + /// Authority set info. + pub shared_authority_set: SharedAuthoritySet, +} + +/// Full client dependencies. +pub struct FullDeps { + /// The client instance to use. + pub client: Arc, + /// Transaction pool instance. + pub pool: Arc

, + /// The SelectChain Strategy + pub select_chain: SC, + /// Whether to deny unsafe calls + pub deny_unsafe: DenyUnsafe, + /// BABE specific dependencies. + pub babe: BabeDeps, + /// GRANDPA specific dependencies. + pub grandpa: GrandpaDeps, +} + +/// Instantiate all Full RPC extensions. +pub fn create_full(deps: FullDeps) -> jsonrpc_core::IoHandler +where + C: ProvideRuntimeApi, + C: HeaderBackend + HeaderMetadata + 'static, + C: Send + Sync + 'static, + C::Api: substrate_frame_rpc_system::AccountNonceApi, + C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi< + Block, + Balance, + UncheckedExtrinsic, + >, + C::Api: BabeApi, + C::Api: BlockBuilder, + P: TransactionPool + 'static, + M: jsonrpc_core::Metadata + Default, + SC: SelectChain + 'static, +{ + use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; + use substrate_frame_rpc_system::{FullSystem, SystemApi}; + + let mut io = jsonrpc_core::IoHandler::default(); + let FullDeps { + client, + pool, + select_chain, + deny_unsafe, + babe, + grandpa, + } = deps; + let BabeDeps { + keystore, + babe_config, + shared_epoch_changes, + } = babe; + let GrandpaDeps { + shared_voter_state, + shared_authority_set, + } = grandpa; + + io.extend_with(SystemApi::to_delegate(FullSystem::new( + client.clone(), + pool, + deny_unsafe, + ))); + // Making synchronous calls in light client freezes the browser currently, + // more context: https://github.com/paritytech/substrate/pull/3480 + // These RPCs should use an asynchronous caller instead. + io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new( + client.clone(), + ))); + io.extend_with(sc_consensus_babe_rpc::BabeApi::to_delegate( + BabeRpcHandler::new( + client, + shared_epoch_changes, + keystore, + babe_config, + select_chain, + deny_unsafe, + ), + )); + io.extend_with(sc_finality_grandpa_rpc::GrandpaApi::to_delegate( + GrandpaRpcHandler::new(shared_authority_set, shared_voter_state), + )); + + io +} + +/// Instantiate all Light RPC extensions. +pub fn create_light(deps: LightDeps) -> jsonrpc_core::IoHandler +where + C: sp_blockchain::HeaderBackend, + C: Send + Sync + 'static, + F: sc_client_api::light::Fetcher + 'static, + P: TransactionPool + 'static, + M: jsonrpc_core::Metadata + Default, +{ + use substrate_frame_rpc_system::{LightSystem, SystemApi}; + + let LightDeps { + client, + pool, + remote_blockchain, + fetcher, + } = deps; + let mut io = jsonrpc_core::IoHandler::default(); + io.extend_with(SystemApi::::to_delegate( + LightSystem::new(client, remote_blockchain, fetcher, pool), + )); + + io +} diff --git a/node/src/service.rs b/node/src/service.rs index 64bf0a03d9..0aeed1e7a1 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -16,107 +16,141 @@ #![warn(unused_extern_crates)] -// Clippy linter warning. -#![allow(clippy::type_complexity)] // disable it because this is foreign code and can be changed any time - -// Clippy linter warning. -#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design - -//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. - -use client_db::Backend; -use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; -use inherents::InherentDataProviders; -use network::{construct_simple_protocol, NetworkService}; -use node_runtime::{self, opaque::Block, GenesisConfig, RuntimeApi}; -use offchain::OffchainWorkers; -use primitives::Blake2Hasher; -use runtime_primitives::traits::Block as BlockT; -use std::sync::Arc; -use substrate_client::{Client, LocalCallExecutor, LongestChain}; -pub use substrate_executor::{native_executor_instance, NativeExecutor}; -use substrate_service::{ - error::Error as ServiceError, AbstractService, Configuration, NetworkStatus, Service, - ServiceBuilder, -}; -use transaction_pool::{self, txpool::Pool as TransactionPool}; +// Substrate implementation issue. +#![allow(clippy::redundant_closure_call)] -construct_simple_protocol! { - /// Demo protocol attachment for substrate. - pub struct NodeProtocol where Block = Block { } -} +//! Service implementation. Specialized wrapper over substrate service. -// Declare an instance of the native executor named `Executor`. Include the wasm binary as the -// equivalent wasm code. -native_executor_instance!( - pub Executor, - node_runtime::api::dispatch, - node_runtime::native_version -); +use node_runtime::opaque::Block; +use node_runtime::RuntimeApi; +use sc_consensus::LongestChain; +use sc_finality_grandpa::{ + self as grandpa, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider, +}; +use sc_service::{ + config::Configuration, error::Error as ServiceError, AbstractService, ServiceBuilder, +}; +use sp_inherents::InherentDataProviders; +use std::sync::Arc; + +use crate::node_executor; +use crate::node_rpc; /// Starts a `ServiceBuilder` for a full service. /// /// Use this macro if you don't actually need the full service, but just the builder in order to /// be able to perform chain operations. -#[macro_export] macro_rules! new_full_start { ($config:expr) => {{ - // type RpcExtension = jsonrpc_core::IoHandler; + use std::sync::Arc; + let mut import_setup = None; - let inherent_data_providers = inherents::InherentDataProviders::new(); + let mut rpc_setup = None; + let inherent_data_providers = sp_inherents::InherentDataProviders::new(); - let builder = substrate_service::ServiceBuilder::new_full::< - node_runtime::opaque::Block, - node_runtime::RuntimeApi, - crate::service::Executor, + let builder = sc_service::ServiceBuilder::new_full::< + Block, + RuntimeApi, + node_executor::Executor, >($config)? - .with_select_chain(|_config, backend| { - Ok(substrate_client::LongestChain::new(backend.clone())) - })? - .with_transaction_pool(|config, client| { - Ok(transaction_pool::txpool::Pool::new( - config, - transaction_pool::FullChainApi::new(client), + .with_select_chain(|_config, backend| Ok(sc_consensus::LongestChain::new(backend.clone())))? + .with_transaction_pool(|builder| { + let pool_api = sc_transaction_pool::FullChainApi::new(builder.client().clone()); + let config = builder.config(); + + Ok(sc_transaction_pool::BasicPool::new( + config.transaction_pool.clone(), + std::sync::Arc::new(pool_api), + builder.prometheus_registry(), )) })? - .with_import_queue(|_config, client, mut select_chain, _transaction_pool| { - let select_chain = select_chain - .take() - .ok_or_else(|| substrate_service::Error::SelectChainRequired)?; - let (grandpa_block_import, grandpa_link) = - grandpa::block_import::<_, _, _, node_runtime::RuntimeApi, _>( + .with_import_queue( + |_config, + client, + mut select_chain, + _transaction_pool, + spawn_task_handle, + prometheus_registry| { + let select_chain = select_chain + .take() + .ok_or_else(|| sc_service::Error::SelectChainRequired)?; + let (grandpa_block_import, grandpa_link) = grandpa::block_import( client.clone(), - &*client, + &(client.clone() as Arc<_>), select_chain, )?; - let justification_import = grandpa_block_import.clone(); - - let (block_import, babe_link) = babe::block_import( - babe::Config::get_or_compute(&*client)?, - grandpa_block_import, - client.clone(), - client.clone(), - )?; - - let import_queue = babe::import_queue( - babe_link.clone(), - block_import.clone(), - Some(Box::new(justification_import)), - None, - client.clone(), - client, - inherent_data_providers.clone(), - )?; - - import_setup = Some((block_import, grandpa_link, babe_link)); - Ok(import_queue) + let justification_import = grandpa_block_import.clone(); + + let (block_import, babe_link) = sc_consensus_babe::block_import( + sc_consensus_babe::Config::get_or_compute(&*client)?, + grandpa_block_import, + client.clone(), + )?; + + let import_queue = sc_consensus_babe::import_queue( + babe_link.clone(), + block_import.clone(), + Some(Box::new(justification_import)), + None, + client, + inherent_data_providers.clone(), + spawn_task_handle, + prometheus_registry, + )?; + + import_setup = Some((block_import, grandpa_link, babe_link)); + Ok(import_queue) + }, + )? + .with_rpc_extensions_builder(|builder| { + let grandpa_link = import_setup + .as_ref() + .map(|s| &s.1) + .expect("GRANDPA LinkHalf is present for full services or set up failed; qed."); + + let shared_authority_set = grandpa_link.shared_authority_set().clone(); + let shared_voter_state = grandpa::SharedVoterState::empty(); + + rpc_setup = Some((shared_voter_state.clone())); + + let babe_link = import_setup + .as_ref() + .map(|s| &s.2) + .expect("BabeLink is present for full services or set up failed; qed."); + + let babe_config = babe_link.config().clone(); + let shared_epoch_changes = babe_link.epoch_changes().clone(); + + let client = builder.client().clone(); + let pool = builder.pool().clone(); + let select_chain = builder + .select_chain() + .cloned() + .expect("SelectChain is present for full services or set up failed; qed."); + let keystore = builder.keystore().clone(); + + Ok(move |deny_unsafe| { + let deps = node_rpc::FullDeps { + client: client.clone(), + pool: pool.clone(), + select_chain: select_chain.clone(), + deny_unsafe, + babe: node_rpc::BabeDeps { + babe_config: babe_config.clone(), + shared_epoch_changes: shared_epoch_changes.clone(), + keystore: keystore.clone(), + }, + grandpa: node_rpc::GrandpaDeps { + shared_voter_state: shared_voter_state.clone(), + shared_authority_set: shared_authority_set.clone(), + }, + }; + + node_rpc::create_full(deps) + }) })?; - // We don't have any custom rpc commands... - // .with_rpc_extensions(|client, pool| -> RpcExtension { - // node_rpc::create(client, pool) - // })?; - (builder, import_setup, inherent_data_providers) + (builder, import_setup, inherent_data_providers, rpc_setup) }}; } @@ -126,58 +160,57 @@ macro_rules! new_full_start { /// concrete types instead. macro_rules! new_full { ($config:expr, $with_startup_data: expr) => {{ - use futures::sync::mpsc; - use network::DhtEvent; + use futures::prelude::*; + use sc_network::Event; + use sc_client_api::ExecutorProvider; + use sp_core::traits::BareCryptoStorePtr; let ( - is_authority, + role, force_authoring, name, - disable_grandpa + disable_grandpa, ) = ( - $config.roles.is_authority(), + $config.role.clone(), $config.force_authoring, - $config.name.clone(), - $config.disable_grandpa + $config.network.node_name.clone(), + $config.disable_grandpa, ); - // sentry nodes announce themselves as authorities to the network - // and should run the same protocols authorities do, but it should - // never actively participate in any consensus process. - let participates_in_consensus = is_authority && !$config.sentry_mode; - - let (builder, mut import_setup, inherent_data_providers) = new_full_start!($config); - - // Dht event channel from the network to the authority discovery module. Use bounded channel to ensure - // back-pressure. Authority discovery is triggering one event per authority within the current authority set. - // This estimates the authority set size to be somewhere below 10 000 thereby setting the channel buffer size to - // 10 000. - let (dht_event_tx, _dht_event_rx) = - mpsc::channel::(10_000); + let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) = + new_full_start!($config); - let service = builder.with_network_protocol(|_| Ok(crate::service::NodeProtocol::new()))? - .with_finality_proof_provider(|client, backend| - Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, client)) as _) - )? - .with_dht_event_tx(dht_event_tx)? - .build()?; + let service = builder + .with_finality_proof_provider(|client, backend| { + // GenesisAuthoritySetProvider is implemented for StorageAndProofProvider + let provider = client as Arc>; + Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, provider)) as _) + })? + .build_full()?; let (block_import, grandpa_link, babe_link) = import_setup.take() - .expect("Link Half and Block Import are present for Full Services or setup failed before. qed"); + .expect("Link Half and Block Import are present for Full Services or setup failed before. qed"); + + let shared_voter_state = rpc_setup.take() + .expect("The SharedVoterState is present for Full Services or setup failed before. qed"); ($with_startup_data)(&block_import, &babe_link); - if participates_in_consensus { - let proposer = substrate_basic_authorship::ProposerFactory { - client: service.client(), - transaction_pool: service.transaction_pool(), - }; + if let sc_service::config::Role::Authority { .. } = &role { + let proposer = sc_basic_authorship::ProposerFactory::new( + service.client(), + service.transaction_pool(), + service.prometheus_registry().as_ref(), + ); let client = service.client(); let select_chain = service.select_chain() - .ok_or(substrate_service::Error::SelectChainRequired)?; + .ok_or(sc_service::Error::SelectChainRequired)?; + + let can_author_with = + sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let babe_config = babe::BabeParams { + let babe_config = sc_consensus_babe::BabeParams { keystore: service.keystore(), client, select_chain, @@ -187,62 +220,95 @@ macro_rules! new_full { inherent_data_providers: inherent_data_providers.clone(), force_authoring, babe_link, + can_author_with, }; - let babe = babe::start_babe(babe_config)?; - service.spawn_essential_task(babe); - } + let babe = sc_consensus_babe::start_babe(babe_config)?; + service.spawn_essential_task_handle().spawn_blocking("babe-proposer", babe); + } + + // Spawn authority discovery module. + if matches!(role, sc_service::config::Role::Authority{..} | sc_service::config::Role::Sentry {..}) { + let (sentries, authority_discovery_role) = match role { + sc_service::config::Role::Authority { ref sentry_nodes } => ( + sentry_nodes.clone(), + sc_authority_discovery::Role::Authority ( + service.keystore(), + ), + ), + sc_service::config::Role::Sentry {..} => ( + vec![], + sc_authority_discovery::Role::Sentry, + ), + _ => unreachable!("Due to outer matches! constraint; qed.") + }; + + let network = service.network(); + let dht_event_stream = network.event_stream("authority-discovery").filter_map(|e| async move { match e { + Event::Dht(e) => Some(e), + _ => None, + }}).boxed(); + let authority_discovery = sc_authority_discovery::AuthorityDiscovery::new( + service.client(), + network, + sentries, + dht_event_stream, + authority_discovery_role, + service.prometheus_registry(), + ); + + service.spawn_task_handle().spawn("authority-discovery", authority_discovery); + } - // if the node isn't actively participating in consensus then it doesn't + // if the node isn't actively participating in consensus then it doesn't // need a keystore, regardless of which protocol we use below. - let keystore = if participates_in_consensus { - Some(service.keystore()) + let keystore = if role.is_authority() { + Some(service.keystore() as BareCryptoStorePtr) } else { None - }; - - let config = grandpa::Config { - // FIXME #1578 make this available through chainspec - gossip_duration: std::time::Duration::from_millis(333), - justification_period: 512, - name: Some(name), - observer_enabled: true, - keystore, - is_authority, - }; - - match (is_authority, disable_grandpa) { - (false, false) => { - // start the lightweight GRANDPA observer - service.spawn_task(Box::new(grandpa::run_grandpa_observer( - config, - grandpa_link, - service.network(), - service.on_exit(), - )?)); - }, - (true, false) => { - // start the full GRANDPA voter - let grandpa_config = grandpa::GrandpaParams { - config, - link: grandpa_link, - network: service.network(), - inherent_data_providers: inherent_data_providers.clone(), - on_exit: service.on_exit(), - telemetry_on_connect: Some(service.telemetry_on_connect_stream()), - voting_rule: grandpa::VotingRulesBuilder::default().build(), - }; - // the GRANDPA voter task is considered infallible, i.e. - // if it fails we take down the service with it. - service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?); - }, - (_, true) => { - grandpa::setup_disabled_grandpa( - service.client(), - &inherent_data_providers, - service.network(), - )?; - }, + }; + + let config = grandpa::Config { + // FIXME #1578 make this available through chainspec + gossip_duration: std::time::Duration::from_millis(333), + justification_period: 512, + name: Some(name), + observer_enabled: false, + keystore, + is_authority: role.is_network_authority(), + }; + + let enable_grandpa = !disable_grandpa; + if enable_grandpa { + // start the full GRANDPA voter + // NOTE: non-authorities could run the GRANDPA observer protocol, but at + // this point the full voter should provide better guarantees of block + // and vote data availability than the observer. The observer has not + // been tested extensively yet and having most nodes in a network run it + // could lead to finality stalls. + let grandpa_config = grandpa::GrandpaParams { + config, + link: grandpa_link, + network: service.network(), + inherent_data_providers: inherent_data_providers.clone(), + telemetry_on_connect: Some(service.telemetry_on_connect_stream()), + voting_rule: grandpa::VotingRulesBuilder::default().build(), + prometheus_registry: service.prometheus_registry(), + shared_voter_state, + }; + + // the GRANDPA voter task is considered infallible, i.e. + // if it fails we take down the service with it. + service.spawn_essential_task_handle().spawn_blocking( + "grandpa-voter", + grandpa::run_grandpa_voter(grandpa_config)? + ); + } else { + grandpa::setup_disabled_grandpa( + service.client(), + &inherent_data_providers, + service.network(), + )?; } Ok((service, inherent_data_providers)) @@ -252,70 +318,49 @@ macro_rules! new_full { }} } -#[allow(dead_code)] -type ConcreteBlock = node_runtime::opaque::Block; -#[allow(dead_code)] -type ConcreteClient = Client< - Backend, - LocalCallExecutor, NativeExecutor>, - ConcreteBlock, - node_runtime::RuntimeApi, ->; -#[allow(dead_code)] -type ConcreteBackend = Backend; - -/// A specialized configuration object for setting up the node.. -pub type NodeConfiguration = - Configuration; - /// Builds a new service for a full client. -pub fn new_full(config: NodeConfiguration) --> Result< - Service< - ConcreteBlock, - ConcreteClient, - LongestChain, - NetworkStatus, - NetworkService::Hash>, - TransactionPool>, - OffchainWorkers< - ConcreteClient, - >::OffchainStorage, - ConcreteBlock, - > - >, - ServiceError, -> -{ +pub fn new_full(config: Configuration) -> Result { new_full!(config).map(|(service, _)| service) } /// Builds a new service for a light client. -pub fn new_light( - config: NodeConfiguration, -) -> Result { - // type RpcExtension = jsonrpc_core::IoHandler; +pub fn new_light(config: Configuration) -> Result { let inherent_data_providers = InherentDataProviders::new(); - let service = ServiceBuilder::new_light::(config)? + let service = ServiceBuilder::new_light::(config)? .with_select_chain(|_config, backend| Ok(LongestChain::new(backend.clone())))? - .with_transaction_pool(|config, client| { - Ok(TransactionPool::new( - config, - transaction_pool::FullChainApi::new(client), - )) + .with_transaction_pool(|builder| { + let fetcher = builder + .fetcher() + .ok_or_else(|| "Trying to start light transaction pool without active fetcher")?; + let pool_api = + sc_transaction_pool::LightChainApi::new(builder.client().clone(), fetcher); + let pool = sc_transaction_pool::BasicPool::with_revalidation_type( + builder.config().transaction_pool.clone(), + Arc::new(pool_api), + builder.prometheus_registry(), + sc_transaction_pool::RevalidationType::Light, + ); + Ok(pool) })? .with_import_queue_and_fprb( - |_config, client, backend, fetcher, _select_chain, _tx_pool| { + |_config, + client, + backend, + fetcher, + _select_chain, + _tx_pool, + spawn_task_handle, + registry| { let fetch_checker = fetcher .map(|fetcher| fetcher.checker().clone()) .ok_or_else(|| { "Trying to start light import queue without active fetch checker" })?; - let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi>( + let grandpa_block_import = grandpa::light_block_import( client.clone(), backend, - &*client, + &(client.clone() as Arc<_>), Arc::new(fetch_checker), )?; @@ -323,35 +368,49 @@ pub fn new_light( let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder(); - let (babe_block_import, babe_link) = babe::block_import( - babe::Config::get_or_compute(&*client)?, + let (babe_block_import, babe_link) = sc_consensus_babe::block_import( + sc_consensus_babe::Config::get_or_compute(&*client)?, grandpa_block_import, client.clone(), - client.clone(), )?; - let import_queue = babe::import_queue( + let import_queue = sc_consensus_babe::import_queue( babe_link, babe_block_import, None, Some(Box::new(finality_proof_import)), - client.clone(), client, inherent_data_providers.clone(), + spawn_task_handle, + registry, )?; Ok((import_queue, finality_proof_request_builder)) }, )? - .with_network_protocol(|_| Ok(NodeProtocol::new()))? .with_finality_proof_provider(|client, backend| { - Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _) + // GenesisAuthoritySetProvider is implemented for StorageAndProofProvider + let provider = client as Arc>; + Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _) + })? + .with_rpc_extensions(|builder| { + let fetcher = builder + .fetcher() + .ok_or_else(|| "Trying to start node RPC without active fetcher")?; + let remote_blockchain = builder + .remote_backend() + .ok_or_else(|| "Trying to start node RPC without active remote blockchain")?; + + let light_deps = node_rpc::LightDeps { + remote_blockchain, + fetcher, + client: builder.client().clone(), + pool: builder.pool(), + }; + + Ok(node_rpc::create_light(light_deps)) })? - // We don't have any custom rpc extensions - // .with_rpc_extensions(|client, pool| -> RpcExtension { - // node_rpc::create(client, pool) - // })? - .build()?; + .build_light()?; Ok(service) } diff --git a/runtime-modules/common/Cargo.toml b/runtime-modules/common/Cargo.toml index df598a6ca8..b4c98bd9a7 100644 --- a/runtime-modules/common/Cargo.toml +++ b/runtime-modules/common/Cargo.toml @@ -1,52 +1,24 @@ [package] -name = 'substrate-common-module' -version = '1.2.0' +name = 'pallet-common' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + [features] default = ['std'] std = [ - 'sr-primitives/std', - 'srml-support/std', - 'system/std', - 'timestamp/std', + 'serde', 'codec/std', - 'serde' + 'sp-runtime/std', + 'frame-support/std', + 'system/std', + 'pallet-timestamp/std', ] - - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' \ No newline at end of file diff --git a/runtime-modules/common/src/currency.rs b/runtime-modules/common/src/currency.rs index 50d9ebaef0..2daa057358 100644 --- a/runtime-modules/common/src/currency.rs +++ b/runtime-modules/common/src/currency.rs @@ -1,5 +1,5 @@ -use sr_primitives::traits::Convert; -use srml_support::traits::{Currency, LockableCurrency, ReservableCurrency}; +use frame_support::traits::{Currency, LockableCurrency, ReservableCurrency}; +use sp_runtime::traits::Convert; pub trait GovernanceCurrency: system::Trait + Sized { type Currency: Currency diff --git a/runtime-modules/common/src/lib.rs b/runtime-modules/common/src/lib.rs index b14afebe86..6201b26c0f 100644 --- a/runtime-modules/common/src/lib.rs +++ b/runtime-modules/common/src/lib.rs @@ -24,10 +24,10 @@ pub struct BlockAndTime { /// Gathers current block and time information for the runtime. /// If this function is used inside a config() at genesis the timestamp will be 0 /// because the timestamp is actually produced by validators. -pub fn current_block_time( +pub fn current_block_time( ) -> BlockAndTime { BlockAndTime { block: >::block_number(), - time: >::now(), + time: >::now(), } } diff --git a/runtime-modules/content-working-group/Cargo.toml b/runtime-modules/content-working-group/Cargo.toml index d7066ab24b..dbf5ab8837 100644 --- a/runtime-modules/content-working-group/Cargo.toml +++ b/runtime-modules/content-working-group/Cargo.toml @@ -1,131 +1,48 @@ [package] -name = 'substrate-content-working-group-module' -version = '1.1.0' +name = 'pallet-content-working-group' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +membership = { package = 'pallet-membership', default-features = false, path = '../membership'} +stake = { package = 'pallet-stake', default-features = false, path = '../stake'} +hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'} +minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'} +recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'} +versioned_store = { package = 'pallet-versioned-store', default-features = false, path = '../versioned-store'} +versioned_store_permissions = { package = 'pallet-versioned-store-permissions', default-features = false, path = '../versioned-store-permissions'} +common = { package = 'pallet-common', default-features = false, path = '../common'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + [features] default = ['std'] std = [ - 'sr-primitives/std', - 'srml-support/std', + 'serde', + 'codec/std', + 'sp-std/std', + 'frame-support/std', 'system/std', - 'serde', - 'codec/std', - 'primitives/std', - 'rstd/std', - 'membership/std', - 'forum/std', - 'hiring/std', - 'stake/std', - 'minting/std', + 'sp-arithmetic/std', + 'sp-runtime/std', + 'membership/std', + 'stake/std', + 'hiring/std', + 'minting/std', + 'recurringrewards/std', 'versioned_store/std', 'versioned_store_permissions/std', - 'recurringrewards/std', - 'common/std', + 'common/std', ] - - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.forum] -default_features = false -package = 'substrate-forum-module' -path = '../forum' - -[dependencies.minting] -default_features = false -package = 'substrate-token-mint-module' -path = '../token-minting' - -[dependencies.stake] -default_features = false -package = 'substrate-stake-module' -path = '../stake' - -[dependencies.recurringrewards] -default_features = false -package = 'substrate-recurring-reward-module' -path = '../recurring-reward' - -[dependencies.hiring] -default_features = false -package = 'substrate-hiring-module' -path = '../hiring' - -[dependencies.versioned_store] -default_features = false -package ='substrate-versioned-store' -path = '../versioned-store' - -[dependencies.versioned_store_permissions] -default_features = false -package = 'substrate-versioned-store-permissions-module' -path = '../versioned-store-permissions' - -[dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../membership' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../common' - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.balances] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-balances' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' diff --git a/runtime-modules/content-working-group/src/genesis.rs b/runtime-modules/content-working-group/src/genesis.rs index 5dd1fdfc8e..e4cb8741e3 100644 --- a/runtime-modules/content-working-group/src/genesis.rs +++ b/runtime-modules/content-working-group/src/genesis.rs @@ -1,36 +1,13 @@ #![cfg(test)] use crate::{Trait, *}; -pub use primitives::{map, Blake2Hasher, H256}; -use rstd::prelude::*; +use sp_std::map; -/// DIRTY IMPORT BECAUSE -/// InputValidationLengthConstraint has not been factored out yet!!! use common::constraints::InputValidationLengthConstraint; -/// The way a map (linked_map) is represented in the GenesisConfig produced by decl_storage -//pub type GenesisConfigMap = std::vec::Vec<(K, V)>; - /// Builder of genesis configuration of content working group. pub struct GenesisConfigBuilder { mint_capacity: minting::BalanceOf, - /* - lead_by_id: GenesisConfigMap, Lead>, - next_lead_id: LeadId, - curator_opening_by_id: GenesisConfigMap, CuratorOpening, CuratorApplicationId>>, - next_curator_opening_id: CuratorOpeningId, - curator_application_by_id: GenesisConfigMap, CuratorApplication, T::MemberId, T::ApplicationId>>, - next_curator_application_id: CuratorApplicationId, - channel_by_id: GenesisConfigMap, Channel>>, - next_channel_id: ChannelId, - channel_id_by_handle: GenesisConfigMap, ChannelId>, - curator_by_id: GenesisConfigMap, Curator, CuratorApplicationId, PrincipalId>>, - next_curator_id: CuratorId, - principal_by_id: GenesisConfigMap, Principal, ChannelId>>, - next_principal_id: PrincipalId, - - unstaker_by_stake_id: GenesisConfigMap, CuratorId>>, - */ channel_creation_enabled: bool, channel_handle_constraint: InputValidationLengthConstraint, channel_description_constraint: InputValidationLengthConstraint, @@ -47,20 +24,7 @@ impl GenesisConfigBuilder { self.mint_capacity = capacity; self } - /* - pub fn set_channel_handle_constraint(mut self, constraint: InputValidationLengthConstraint) -> Self { - self.channel_description_constraint = constraint; - self - } - pub fn set_channel_description_constraint(mut self, constraint: InputValidationLengthConstraint) -> Self { - self.channel_description_constraint = constraint; - self - } - pub fn set_channel_creation_enabled(mut self, channel_creation_enabled: bool) -> Self { - self.channel_creation_enabled = channel_creation_enabled; - self - } - */ + pub fn build(self) -> GenesisConfig { GenesisConfig { mint_capacity: self.mint_capacity, @@ -68,7 +32,6 @@ impl GenesisConfigBuilder { next_curator_opening_id: CuratorOpeningId::::default(), curator_application_by_id: map![], //GenesisConfigMap, next_curator_application_id: CuratorApplicationId::::default(), - channel_by_id: map![], //GenesisConfigMap, next_channel_id: ChannelId::::default(), channel_id_by_handle: map![], //GenesisConfigMap, ChannelId>, @@ -78,12 +41,10 @@ impl GenesisConfigBuilder { next_principal_id: PrincipalId::::default(), channel_creation_enabled: self.channel_creation_enabled, unstaker_by_stake_id: map![], //GenesisConfigMap, - channel_handle_constraint: self.channel_handle_constraint, channel_description_constraint: self.channel_description_constraint, curator_application_human_readable_text: self.curator_application_human_readable_text, curator_exit_rationale_text: self.curator_exit_rationale_text, - channel_title_constraint: self.channel_title_constraint, channel_avatar_constraint: self.channel_avatar_constraint, channel_banner_constraint: self.channel_banner_constraint, @@ -101,25 +62,6 @@ impl Default for GenesisConfigBuilder { Self { mint_capacity: minting::BalanceOf::::from(10000), - - /* - current_lead_id: LeadId::::default(), //Option, - lead_by_id: map![], //GenesisConfigMap, - next_lead_id: 0, - curator_opening_by_id: map![], //GenesisConfigMap, - next_curator_opening_id: 0, - curator_application_by_id: map![], //GenesisConfigMap, - next_curator_application_id: 0, - channel_by_id: map![], //GenesisConfigMap, - next_channel_id: 0, - channel_id_by_handle: map![], //GenesisConfigMap, ChannelId>, - curator_by_id: map![], //GenesisConfigMap, - next_curator_id: 0, - principal_by_id: map![], //GenesisConfigMap, - next_principal_id: 0, - - unstaker_by_stake_id: map![], //GenesisConfigMap, - */ channel_creation_enabled: true, channel_handle_constraint: default_constraint.clone(), channel_description_constraint: default_constraint.clone(), diff --git a/runtime-modules/content-working-group/src/lib.rs b/runtime-modules/content-working-group/src/lib.rs index 2054101967..a58a049a45 100755 --- a/runtime-modules/content-working-group/src/lib.rs +++ b/runtime-modules/content-working-group/src/lib.rs @@ -20,15 +20,14 @@ pub mod genesis; use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; -use rstd::borrow::ToOwned; -use rstd::collections::btree_map::BTreeMap; -use rstd::collections::btree_set::BTreeSet; -use rstd::convert::From; -use rstd::prelude::*; -use sr_primitives::traits::{One, Zero}; -use srml_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; -use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure}; -use system::{self, ensure_root, ensure_signed}; +use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use sp_arithmetic::traits::{One, Zero}; +use sp_std::borrow::ToOwned; +use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; +use sp_std::vec; +use sp_std::vec::Vec; +use system::{ensure_root, ensure_signed}; use common::constraints::InputValidationLengthConstraint; @@ -42,8 +41,6 @@ pub trait Trait: + versioned_store_permissions::Trait + membership::Trait { - // + Sized - /// The event type. type Event: From> + Into<::Event>; } @@ -93,6 +90,10 @@ pub type CuratorApplicationIdToCuratorIdMap = BTreeMap = BTreeSet>; +//TODO: Convert errors to the Substrate decl_error! macro. +/// Result with string error message. This exists for backward compatibility purpose. +pub type DispatchResult = Result<(), &'static str>; + /* * MOVE ALL OF THESE OUT TO COMMON LATER */ @@ -718,10 +719,7 @@ pub struct OpeningPolicyCommitment { /// Staking policy for role itself pub role_staking_policy: Option>, - // Slashing terms during application - // pub application_slashing_terms: SlashingTerms, - - // Slashing terms during role, NOT application itself! + /// Slashing terms during role, NOT application itself! pub role_slashing_terms: SlashingTerms, /// When filling an opening: Unstaking period for application stake of successful applicants @@ -769,12 +767,6 @@ impl Default for WorkingGroupUnstaker { // can this be made generic, or does that undermine the whole orhpan rule spirit? pub error: E, @@ -783,7 +775,9 @@ pub struct WrappedError { /// .... macro_rules! ensure_on_wrapped_error { ($call:expr) => {{ - { $call }.map_err(|err| WrappedError { error: err }) + { $call } + .map_err(|err| WrappedError { error: err }) + .map_err(<&str>::from) }}; } @@ -791,7 +785,7 @@ macro_rules! ensure_on_wrapped_error { //derive_from_impl(hiring::BeginAcceptingApplicationsError) //derive_from_impl(hiring::BeginAcceptingApplicationsError) -impl rstd::convert::From> for &str { +impl sp_std::convert::From> for &str { fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::BeginAcceptingApplicationsError::OpeningDoesNotExist => { @@ -804,7 +798,7 @@ impl rstd::convert::From> } } -impl rstd::convert::From> for &str { +impl sp_std::convert::From> for &str { fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::AddOpeningError::OpeningMustActivateInTheFuture => { @@ -833,7 +827,7 @@ impl rstd::convert::From> for &str { } } -impl rstd::convert::From> for &str { +impl sp_std::convert::From> for &str { fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::BeginReviewError::OpeningDoesNotExist => { @@ -846,7 +840,7 @@ impl rstd::convert::From> for &str { } } -impl rstd::convert::From>> for &str { +impl sp_std::convert::From>> for &str { fn from(wrapper: WrappedError>) -> Self { match wrapper.error { hiring::FillOpeningError::::OpeningDoesNotExist => MSG_FULL_CURATOR_OPENING_OPENING_DOES_NOT_EXIST, @@ -884,7 +878,7 @@ impl rstd::convert::From> for &str { +impl sp_std::convert::From> for &str { fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::DeactivateApplicationError::ApplicationDoesNotExist => { @@ -906,7 +900,9 @@ impl rstd::convert::From> for & } } -impl rstd::convert::From> for &str { +impl sp_std::convert::From> + for &str +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { membership::ControllerAccountForMemberCheckFailed::NotMember => { @@ -919,7 +915,7 @@ impl rstd::convert::From> for &str { +impl sp_std::convert::From> for &str { fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::AddApplicationError::OpeningDoesNotExist => { @@ -944,7 +940,7 @@ impl rstd::convert::From> for &str { } } -impl rstd::convert::From> for &str { +impl sp_std::convert::From> for &str { fn from(wrapper: WrappedError) -> Self { match wrapper.error { membership::MemberControllerAccountDidNotSign::UnsignedOrigin => { @@ -974,83 +970,83 @@ decl_storage! { trait Store for Module as ContentWorkingGroup { /// The mint currently funding the rewards for this module. - pub Mint get(mint) : ::MintId; + pub Mint get(fn mint) : ::MintId; /// The current lead. - pub CurrentLeadId get(current_lead_id) : Option>; + pub CurrentLeadId get(fn current_lead_id) : Option>; /// Maps identifier to corresponding lead. - pub LeadById get(lead_by_id): linked_map LeadId => Lead; + pub LeadById get(fn lead_by_id): map hasher(blake2_128_concat) + LeadId => Lead; /// Next identifier for new current lead. - pub NextLeadId get(next_lead_id): LeadId; + pub NextLeadId get(fn next_lead_id): LeadId; /// Maps identifeir to curator opening. - pub CuratorOpeningById get(curator_opening_by_id) config(): linked_map CuratorOpeningId => CuratorOpening, CuratorApplicationId>; + pub CuratorOpeningById get(fn curator_opening_by_id) config(): map hasher(blake2_128_concat) + CuratorOpeningId => CuratorOpening, CuratorApplicationId>; /// Next identifier valuefor new curator opening. - pub NextCuratorOpeningId get(next_curator_opening_id) config(): CuratorOpeningId; + pub NextCuratorOpeningId get(fn next_curator_opening_id) config(): CuratorOpeningId; /// Maps identifier to curator application on opening. - pub CuratorApplicationById get(curator_application_by_id) config(): linked_map CuratorApplicationId => CuratorApplication, T::MemberId, T::ApplicationId>; + pub CuratorApplicationById get(fn curator_application_by_id) config(): map hasher(blake2_128_concat) + CuratorApplicationId => CuratorApplication, T::MemberId, T::ApplicationId>; /// Next identifier value for new curator application. - pub NextCuratorApplicationId get(next_curator_application_id) config(): CuratorApplicationId; + pub NextCuratorApplicationId get(fn next_curator_application_id) config(): CuratorApplicationId; /// Maps identifier to corresponding channel. - pub ChannelById get(channel_by_id) config(): linked_map ChannelId => Channel>; + pub ChannelById get(fn channel_by_id) config(): map hasher(blake2_128_concat) + ChannelId => Channel>; /// Identifier to be used by the next channel introduced. - pub NextChannelId get(next_channel_id) config(): ChannelId; + pub NextChannelId get(fn next_channel_id) config(): ChannelId; /// Maps (unique) channel handle to the corresponding identifier for the channel. /// Mapping is required to allow efficient (O(log N)) on-chain verification that a proposed handle is indeed unique /// at the time it is being proposed. - pub ChannelIdByHandle get(channel_id_by_handle) config(): linked_map Vec => ChannelId; + pub ChannelIdByHandle get(fn channel_id_by_handle) config(): map hasher(blake2_128_concat) + Vec => ChannelId; /// Maps identifier to corresponding curator. - pub CuratorById get(curator_by_id) config(): linked_map CuratorId => Curator, CuratorApplicationId, PrincipalId>; + pub CuratorById get(fn curator_by_id) config(): map hasher(blake2_128_concat) + CuratorId => Curator, CuratorApplicationId, PrincipalId>; /// Next identifier for new curator. - pub NextCuratorId get(next_curator_id) config(): CuratorId; + pub NextCuratorId get(fn next_curator_id) config(): CuratorId; /// Maps identifier to principal. - pub PrincipalById get(principal_by_id) config(): linked_map PrincipalId => Principal, ChannelId>; + pub PrincipalById get(fn principal_by_id) config(): map hasher(blake2_128_concat) + PrincipalId => Principal, ChannelId>; /// Next identifier for - pub NextPrincipalId get(next_principal_id) config(): PrincipalId; + pub NextPrincipalId get(fn next_principal_id) config(): PrincipalId; /// Whether it is currently possible to create a channel via `create_channel` extrinsic. - pub ChannelCreationEnabled get(channel_creation_enabled) config(): bool; + pub ChannelCreationEnabled get(fn channel_creation_enabled) config(): bool; /// Recover curator by the role stake which is currently unstaking. - pub UnstakerByStakeId get(unstaker_by_stake_id) config(): linked_map StakeId => WorkingGroupUnstaker, CuratorId>; - - // Limits - - /// Limits the total number of curators which can be active. - //pub MaxSimultanouslyActiveCurators get(max_simultanously_active_curators) config(): Option; + pub UnstakerByStakeId get(fn unstaker_by_stake_id) config(): map hasher(blake2_128_concat) + StakeId => WorkingGroupUnstaker, CuratorId>; - // Limits the total number of openings which are not yet deactivated. - // pub MaxSimultaneouslyActiveOpenings get(max_simultaneously_active_openings) config(): Option, // Vector length input guards - - pub ChannelHandleConstraint get(channel_handle_constraint) config(): InputValidationLengthConstraint; - pub ChannelTitleConstraint get(channel_title_constraint) config(): InputValidationLengthConstraint; - pub ChannelDescriptionConstraint get(channel_description_constraint) config(): InputValidationLengthConstraint; - pub ChannelAvatarConstraint get(channel_avatar_constraint) config(): InputValidationLengthConstraint; - pub ChannelBannerConstraint get(channel_banner_constraint) config(): InputValidationLengthConstraint; - pub OpeningHumanReadableText get(opening_human_readable_text) config(): InputValidationLengthConstraint; - pub CuratorApplicationHumanReadableText get(curator_application_human_readable_text) config(): InputValidationLengthConstraint; - pub CuratorExitRationaleText get(curator_exit_rationale_text) config(): InputValidationLengthConstraint; + pub ChannelHandleConstraint get(fn channel_handle_constraint) config(): InputValidationLengthConstraint; + pub ChannelTitleConstraint get(fn channel_title_constraint) config(): InputValidationLengthConstraint; + pub ChannelDescriptionConstraint get(fn channel_description_constraint) config(): InputValidationLengthConstraint; + pub ChannelAvatarConstraint get(fn channel_avatar_constraint) config(): InputValidationLengthConstraint; + pub ChannelBannerConstraint get(fn channel_banner_constraint) config(): InputValidationLengthConstraint; + pub OpeningHumanReadableText get(fn opening_human_readable_text) config(): InputValidationLengthConstraint; + pub CuratorApplicationHumanReadableText get(fn curator_application_human_readable_text) config(): InputValidationLengthConstraint; + pub CuratorExitRationaleText get(fn curator_exit_rationale_text) config(): InputValidationLengthConstraint; } add_extra_genesis { config(mint_capacity): minting::BalanceOf; - // config(mint_adjustment): minting::Adjustment, T::BlockNumber> (add serialize/deserialize derivation for type) build(|config: &GenesisConfig| { // create mint - let mint_id = >::add_mint(config.mint_capacity, None).expect("Failed to create a mint for the content working group"); + let mint_id = >::add_mint(config.mint_capacity, None) + .expect("Failed to create a mint for the content working group"); Mint::::put(mint_id); }); } @@ -1075,7 +1071,7 @@ decl_event! { CuratorOpeningAdded(CuratorOpeningId), AcceptedCuratorApplications(CuratorOpeningId), BeganCuratorApplicationReview(CuratorOpeningId), - CuratorOpeningFilled(CuratorOpeningId, CuratorApplicationIdToCuratorIdMap), //BTreeSet), + CuratorOpeningFilled(CuratorOpeningId, CuratorApplicationIdToCuratorIdMap), TerminatedCurator(CuratorId), AppliedOnCuratorOpening(CuratorOpeningId, CuratorApplicationId), CuratorExited(CuratorId), @@ -1101,6 +1097,7 @@ decl_module! { */ /// Create a new channel. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_channel( origin, owner: T::MemberId, @@ -1187,6 +1184,7 @@ decl_module! { /// Notice that working group participants cannot do this. /// Notice that censored or unlisted channel may still be transferred. /// Notice that transfers are unilateral, so new owner cannot block. This may be problematic: https://github.com/Joystream/substrate-runtime-joystream/issues/95 + #[weight = 10_000_000] // TODO: adjust weight pub fn transfer_channel_ownership(origin, channel_id: ChannelId, new_owner: T::MemberId, new_role_account: T::AccountId) { // Ensure channel owner has signed @@ -1211,6 +1209,7 @@ decl_module! { } /// Channel owner updates some channel properties + #[weight = 10_000_000] // TODO: adjust weight pub fn update_channel_as_owner( origin, channel_id: ChannelId, @@ -1268,6 +1267,7 @@ decl_module! { } /// Update channel as a curation actor + #[weight = 10_000_000] // TODO: adjust weight pub fn update_channel_as_curation_actor( origin, curation_actor: CurationActor>, @@ -1297,6 +1297,7 @@ decl_module! { } /// Add an opening for a curator role. + #[weight = 10_000_000] // TODO: adjust weight pub fn add_curator_opening(origin, activate_at: hiring::ActivateOpeningAt, commitment: OpeningPolicyCommitment>, human_readable_text: Vec) { // Ensure lead is set and is origin signer @@ -1344,6 +1345,7 @@ decl_module! { } /// Begin accepting curator applications to an opening that is active. + #[weight = 10_000_000] // TODO: adjust weight pub fn accept_curator_applications(origin, curator_opening_id: CuratorOpeningId) { // Ensure lead is set and is origin signer @@ -1370,6 +1372,7 @@ decl_module! { } /// Begin reviewing, and therefore not accepting new applications. + #[weight = 10_000_000] // TODO: adjust weight pub fn begin_curator_applicant_review(origin, curator_opening_id: CuratorOpeningId) { // Ensure lead is set and is origin signer @@ -1396,6 +1399,7 @@ decl_module! { } /// Fill opening for curator + #[weight = 10_000_000] // TODO: adjust weight pub fn fill_curator_opening( origin, curator_opening_id: CuratorOpeningId, @@ -1414,7 +1418,7 @@ decl_module! { let mint_id = Self::mint(); // Technically this is a bug-check and should not be here. - ensure!(>::exists(mint_id), MSG_FILL_CURATOR_OPENING_MINT_DOES_NOT_EXIST); + ensure!(>::contains_key(mint_id), MSG_FILL_CURATOR_OPENING_MINT_DOES_NOT_EXIST); // Make sure valid parameters are selected for next payment at block number ensure!(policy.next_payment_at_block > >::block_number(), MSG_FILL_CURATOR_OPENING_INVALID_NEXT_PAYMENT_BLOCK); @@ -1555,6 +1559,7 @@ decl_module! { } + #[weight = 10_000_000] // TODO: adjust weight pub fn withdraw_curator_application( origin, curator_application_id: CuratorApplicationId @@ -1591,6 +1596,7 @@ decl_module! { } /// Lead terminate curator application + #[weight = 10_000_000] // TODO: adjust weight pub fn terminate_curator_application( origin, curator_application_id: CuratorApplicationId @@ -1621,6 +1627,7 @@ decl_module! { } /// Apply on a curator opening. + #[weight = 10_000_000] // TODO: adjust weight pub fn apply_on_curator_opening( origin, member_id: T::MemberId, @@ -1709,6 +1716,7 @@ decl_module! { } /// An active curator can update the associated role account. + #[weight = 10_000_000] // TODO: adjust weight pub fn update_curator_role_account( origin, member_id: T::MemberId, @@ -1736,6 +1744,7 @@ decl_module! { /// An active curator can update the reward account associated /// with a set reward relationship. + #[weight = 10_000_000] // TODO: adjust weight pub fn update_curator_reward_account( origin, curator_id: CuratorId, @@ -1767,6 +1776,7 @@ decl_module! { } /// An active curator leaves role + #[weight = 10_000_000] // TODO: adjust weight pub fn leave_curator_role( origin, curator_id: CuratorId, @@ -1788,6 +1798,7 @@ decl_module! { } /// Lead can terminate and active curator + #[weight = 10_000_000] // TODO: adjust weight pub fn terminate_curator_role( origin, curator_id: CuratorId, @@ -1819,6 +1830,7 @@ decl_module! { /// If a value is provided for new_lead it will then set that new lead. /// It is responsibility of the caller to ensure the new lead can be set /// to avoid the lead role being vacant at the end of the call. + #[weight = 10_000_000] // TODO: adjust weight pub fn replace_lead(origin, new_lead: Option<(T::MemberId, T::AccountId)>) { // Ensure root is origin ensure_root(origin)?; @@ -1835,6 +1847,7 @@ decl_module! { } /// Add an opening for a curator role. + #[weight = 10_000_000] // TODO: adjust weight pub fn set_channel_creation_enabled(origin, enabled: bool) { // Ensure lead is set and is origin signer @@ -1856,6 +1869,7 @@ decl_module! { /// both increase and decrease capacity. Although when considering that it may be executed /// by a proposal, given the temporal delay in approving a proposal, it might be more suitable /// than set_mint_capacity? + #[weight = 10_000_000] // TODO: adjust weight pub fn increase_mint_capacity( origin, additional_capacity: minting::BalanceOf @@ -1865,7 +1879,7 @@ decl_module! { let mint_id = Self::mint(); let mint = >::mints(mint_id); // must exist let new_capacity = mint.capacity() + additional_capacity; - >::set_mint_capacity(mint_id, new_capacity)?; + >::set_mint_capacity(mint_id, new_capacity).map_err(<&str>::from)?; Self::deposit_event(RawEvent::MintCapacityIncreased( mint_id, additional_capacity, new_capacity @@ -1873,6 +1887,7 @@ decl_module! { } /// Sets the capacity of the current active mint + #[weight = 10_000_000] // TODO: adjust weight pub fn set_mint_capacity( origin, new_capacity: minting::BalanceOf @@ -1890,7 +1905,7 @@ decl_module! { if new_capacity != current_capacity { // Cannot fail if mint exists - >::set_mint_capacity(mint_id, new_capacity)?; + >::set_mint_capacity(mint_id, new_capacity).map_err(<&str>::from)?; if new_capacity > current_capacity { Self::deposit_event(RawEvent::MintCapacityIncreased( @@ -1902,7 +1917,6 @@ decl_module! { )); } } - } } } @@ -1910,7 +1924,7 @@ decl_module! { impl versioned_store_permissions::CredentialChecker for Module { fn account_has_credential(account: &T::AccountId, id: PrincipalId) -> bool { // Check that principal exists - if !PrincipalById::::exists(&id) { + if !PrincipalById::::contains_key(&id) { return false; } @@ -1950,7 +1964,7 @@ impl versioned_store_permissions::CredentialChecker for Module { impl Module { /// Introduce a lead when one is not currently set. - fn set_lead(member: T::MemberId, role_account: T::AccountId) -> dispatch::Result { + fn set_lead(member: T::MemberId, role_account: T::AccountId) -> DispatchResult { // Ensure there is no current lead ensure!( >::get().is_none(), @@ -1988,7 +2002,7 @@ impl Module { } /// Evict the currently set lead - fn unset_lead() -> dispatch::Result { + fn unset_lead() -> DispatchResult { // Ensure there is a lead set let (lead_id, lead) = Self::ensure_lead_is_set()?; @@ -2039,7 +2053,7 @@ impl Module { } // TODO: convert InputConstraint ensurer routines into macroes - fn ensure_channel_handle_is_valid(handle: &[u8]) -> dispatch::Result { + fn ensure_channel_handle_is_valid(handle: &[u8]) -> DispatchResult { ChannelHandleConstraint::get().ensure_valid( handle.len(), MSG_CHANNEL_HANDLE_TOO_SHORT, @@ -2048,14 +2062,14 @@ impl Module { // Has to not already be occupied ensure!( - !ChannelIdByHandle::::exists(handle), + !ChannelIdByHandle::::contains_key(handle), MSG_CHANNEL_HANDLE_ALREADY_TAKEN ); Ok(()) } - fn ensure_channel_title_is_valid(text_opt: &OptionalText) -> dispatch::Result { + fn ensure_channel_title_is_valid(text_opt: &OptionalText) -> DispatchResult { if let Some(text) = text_opt { ChannelTitleConstraint::get().ensure_valid( text.len(), @@ -2067,7 +2081,7 @@ impl Module { } } - fn ensure_channel_description_is_valid(text_opt: &OptionalText) -> dispatch::Result { + fn ensure_channel_description_is_valid(text_opt: &OptionalText) -> DispatchResult { if let Some(text) = text_opt { ChannelDescriptionConstraint::get().ensure_valid( text.len(), @@ -2079,7 +2093,7 @@ impl Module { } } - fn ensure_channel_avatar_is_valid(text_opt: &OptionalText) -> dispatch::Result { + fn ensure_channel_avatar_is_valid(text_opt: &OptionalText) -> DispatchResult { if let Some(text) = text_opt { ChannelAvatarConstraint::get().ensure_valid( text.len(), @@ -2091,7 +2105,7 @@ impl Module { } } - fn ensure_channel_banner_is_valid(text_opt: &OptionalText) -> dispatch::Result { + fn ensure_channel_banner_is_valid(text_opt: &OptionalText) -> DispatchResult { if let Some(text) = text_opt { ChannelBannerConstraint::get().ensure_valid( text.len(), @@ -2103,7 +2117,7 @@ impl Module { } } - fn ensure_curator_application_text_is_valid(text: &[u8]) -> dispatch::Result { + fn ensure_curator_application_text_is_valid(text: &[u8]) -> DispatchResult { CuratorApplicationHumanReadableText::get().ensure_valid( text.len(), MSG_CURATOR_APPLICATION_TEXT_TOO_SHORT, @@ -2111,7 +2125,7 @@ impl Module { ) } - fn ensure_curator_exit_rationale_text_is_valid(text: &[u8]) -> dispatch::Result { + fn ensure_curator_exit_rationale_text_is_valid(text: &[u8]) -> DispatchResult { CuratorExitRationaleText::get().ensure_valid( text.len(), MSG_CURATOR_EXIT_RATIONALE_TEXT_TOO_SHORT, @@ -2119,7 +2133,7 @@ impl Module { ) } - fn ensure_opening_human_readable_text_is_valid(text: &[u8]) -> dispatch::Result { + fn ensure_opening_human_readable_text_is_valid(text: &[u8]) -> DispatchResult { OpeningHumanReadableText::get().ensure_valid( text.len(), MSG_CHANNEL_DESCRIPTION_TOO_SHORT, @@ -2131,7 +2145,7 @@ impl Module { channel_id: &ChannelId, ) -> Result>, &'static str> { - if ChannelById::::exists(channel_id) { + if ChannelById::::contains_key(channel_id) { let channel = ChannelById::::get(channel_id); Ok(channel) @@ -2198,7 +2212,7 @@ impl Module { &'static str, > { ensure!( - CuratorOpeningById::::exists(curator_opening_id), + CuratorOpeningById::::contains_key(curator_opening_id), MSG_CURATOR_OPENING_DOES_NOT_EXIST ); @@ -2224,7 +2238,7 @@ impl Module { &'static str, > { ensure!( - CuratorById::::exists(curator_id), + CuratorById::::contains_key(curator_id), MSG_CURATOR_DOES_NOT_EXIST ); @@ -2237,7 +2251,7 @@ impl Module { stake_id: &StakeId, ) -> Result, CuratorId>, &'static str> { ensure!( - UnstakerByStakeId::::exists(stake_id), + UnstakerByStakeId::::contains_key(stake_id), MSG_UNSTAKER_DOES_NOT_EXIST ); @@ -2353,7 +2367,7 @@ impl Module { &'static str, > { ensure!( - CuratorApplicationById::::exists(curator_application_id), + CuratorApplicationById::::contains_key(curator_application_id), MSG_CURATOR_APPLICATION_DOES_NOT_EXIST ); @@ -2424,6 +2438,7 @@ impl Module { WithdrawReasons::all(), new_balance, ) + .map_err(<&str>::from) } } else { Ok(()) @@ -2613,7 +2628,7 @@ impl Module { /// to this module. pub fn unstaked(stake_id: StakeId) { // Ignore if unstaked doesn't exist - if !>::exists(stake_id) { + if !>::contains_key(stake_id) { return; } diff --git a/runtime-modules/content-working-group/src/mock.rs b/runtime-modules/content-working-group/src/mock.rs index 3cf92f51c0..79d3b6048d 100644 --- a/runtime-modules/content-working-group/src/mock.rs +++ b/runtime-modules/content-working-group/src/mock.rs @@ -1,18 +1,16 @@ #![cfg(test)] pub use crate::*; -pub use srml_support::traits::Currency; -pub use system; -pub use primitives::{map, Blake2Hasher, H256}; -pub use sr_primitives::{ - testing::{Digest, DigestItem, Header, UintAuthorityId}, - traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, - weights::Weight, - BuildStorage, Perbill, +use frame_support::traits::{OnFinalize, OnInitialize}; +use frame_support::{impl_outer_event, impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, }; - -use srml_support::{impl_outer_event, impl_outer_origin, parameter_types}; +pub use system; pub use common::currency::GovernanceCurrency; pub use hiring; @@ -32,10 +30,6 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); pub const MinimumPeriod: u64 = 5; 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 StakePoolId: [u8; 8] = *b"joystake"; } @@ -56,6 +50,7 @@ impl_outer_event! { versioned_store, membership, balances, + system, lib, } } @@ -80,47 +75,45 @@ pub fn get_last_event_or_panic() -> RawLibTestEvent { } } -type TestAccountId = u64; -type TestBlockNumber = u64; impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; - type Index = u64; - type BlockNumber = TestBlockNumber; type Call = (); + type Index = u64; + type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = TestAccountId; + type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; type Event = TestEvent; type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; } 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 = TestEvent; - type DustRemoval = (); - type TransferPayment = (); + type Event = TestEvent; type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl GovernanceCurrency for Test { @@ -206,7 +199,7 @@ impl TestExternalitiesBuilder { self } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { // Add system let mut t = self .system_config @@ -241,3 +234,15 @@ pub type System = system::Module; pub type Balances = balances::Module; pub type ContentWorkingGroup = Module; pub type Minting = minting::Module; + +// Recommendation from Parity on testing on_finalize +// https://substrate.dev/docs/en/next/development/module/tests +pub 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()); + } +} diff --git a/runtime-modules/content-working-group/src/mod.rs b/runtime-modules/content-working-group/src/mod.rs deleted file mode 100644 index a4ec7a3e90..0000000000 --- a/runtime-modules/content-working-group/src/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod genesis; -pub mod lib; -//pub mod types; - -mod mock; -mod tests; diff --git a/runtime-modules/content-working-group/src/tests.rs b/runtime-modules/content-working-group/src/tests.rs index 96c082ec07..7bb1e9bf15 100644 --- a/runtime-modules/content-working-group/src/tests.rs +++ b/runtime-modules/content-working-group/src/tests.rs @@ -1,20 +1,28 @@ #![cfg(test)] use super::genesis; -use super::mock::{self, *}; -use hiring; -use rstd::collections::btree_map::BTreeMap; -use rstd::collections::btree_set::BTreeSet; -use sr_primitives::traits::One; -use srml_support::{assert_err, assert_ok, StorageLinkedMap, StorageValue}; +use super::mock::*; + +use frame_support::{assert_err, assert_ok, traits::Currency, StorageValue}; +use sp_arithmetic::traits::One; +use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; +use system::RawOrigin; use common::constraints::InputValidationLengthConstraint; +use hiring; #[test] fn create_channel_success() { TestExternalitiesBuilder::::default() .build() .execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + // Add channel creator as member let channel_creator_member_root_and_controller_account = 12312; @@ -171,6 +179,13 @@ fn transfer_channel_ownership_success() { TestExternalitiesBuilder::::default() .build() .execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + // Add channel creator as member let channel_creator_member_root_and_controller_account_1 = 1111; let channel_creator_member_root_and_controller_account_2 = 2222; @@ -242,6 +257,7 @@ impl UpdateChannelAsCurationActorFixture { self.new_verified, self.new_curation_status, ) + .map_err(<&str>::from) } pub fn call_and_assert_success(&self, channel_id: ChannelId) { @@ -284,7 +300,7 @@ impl UpdateChannelAsCurationActorFixture { assert_eq!(event_channel_id, channel_id); // Channel has been updated correctly - assert!(ChannelById::::exists(channel_id)); + assert!(ChannelById::::contains_key(channel_id)); let updated_channel = ChannelById::::get(channel_id); @@ -394,7 +410,7 @@ fn add_curator_opening_success() { // Assert that given opening id has been added, // and has the right properties. - assert!(crate::CuratorOpeningById::::exists( + assert!(crate::CuratorOpeningById::::contains_key( expected_curator_opening_id )); @@ -748,7 +764,7 @@ fn apply_on_curator_opening_success() { ) ); - assert!(CuratorApplicationById::::exists( + assert!(CuratorApplicationById::::contains_key( new_curator_application_id )); @@ -874,6 +890,7 @@ impl UpdateCuratorRoleAccountFixture { self.curator_id, self.new_role_account, ) + .map_err(<&str>::from) } pub fn call_and_assert_success(&self) { @@ -950,6 +967,7 @@ impl UpdateCuratorRewardAccountFixture { self.curator_id, self.new_reward_account, ) + .map_err(<&str>::from) } #[allow(dead_code)] // delete if the method is unnecessary @@ -1016,6 +1034,7 @@ impl LeaveCuratorRoleFixture { self.curator_id, self.rationale_text.clone(), ) + .map_err(<&str>::from) } pub fn call_and_assert_success(&self) { @@ -1046,7 +1065,9 @@ impl LeaveCuratorRoleFixture { // Tracking unstaking let curator_role_stake_id = original_curator.role_stake_profile.unwrap().stake_id; - assert!(UnstakerByStakeId::::exists(curator_role_stake_id)); + assert!(UnstakerByStakeId::::contains_key( + curator_role_stake_id + )); let unstaker = UnstakerByStakeId::::get(curator_role_stake_id); @@ -1089,6 +1110,7 @@ impl TerminateCuratorRoleFixture { self.curator_id, self.rationale_text.clone(), ) + .map_err(<&str>::from) } pub fn call_and_assert_success(&self) { @@ -1119,7 +1141,9 @@ impl TerminateCuratorRoleFixture { // Tracking unstaking let curator_role_stake_id = original_curator.role_stake_profile.unwrap().stake_id; - assert!(UnstakerByStakeId::::exists(curator_role_stake_id)); + assert!(UnstakerByStakeId::::contains_key( + curator_role_stake_id + )); let unstaker = UnstakerByStakeId::::get(curator_role_stake_id); @@ -1161,6 +1185,7 @@ impl SetLeadFixture { self.origin.clone(), Some((self.member_id, self.new_role_account)), ) + .map_err(<&str>::from) } pub fn call_and_assert_success(&self) { @@ -1204,11 +1229,18 @@ fn set_lead_success() { TestExternalitiesBuilder::::default() .build() .execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let member_id = add_member(LEAD_ROOT_AND_CONTROLLER_ACCOUNT, to_vec(LEAD_MEMBER_HANDLE)); SetLeadFixture { - origin: Origin::system(system::RawOrigin::Root), + origin: RawOrigin::Root.into(), member_id, new_role_account: 44444, } @@ -1222,7 +1254,7 @@ struct UnsetLeadFixture { impl UnsetLeadFixture { fn call(&self) -> Result<(), &'static str> { - ContentWorkingGroup::replace_lead(self.origin.clone(), None) + ContentWorkingGroup::replace_lead(self.origin.clone(), None).map_err(<&str>::from) } pub fn call_and_assert_success(&self) { @@ -1261,7 +1293,7 @@ fn unset_lead_success() { let _ = add_member_and_set_as_lead(); UnsetLeadFixture { - origin: Origin::system(system::RawOrigin::Root), + origin: RawOrigin::Root.into(), } .call_and_assert_success(); }); @@ -1311,7 +1343,7 @@ impl UnstakedFixture { ); // Unstaker gone - assert!(!UnstakerByStakeId::::exists(self.stake_id)); + assert!(!UnstakerByStakeId::::contains_key(self.stake_id)); } // pub fn call_and_assert_failed_result(&self, error_message: &'static str) { @@ -1406,39 +1438,6 @@ pub fn to_vec(s: &str) -> Vec { s.as_bytes().to_vec() } -/* - * Setups - */ - -//type TestSeed = u128; - -/* -fn account_from_seed(TestSeed: seed) -> ::AccountId { - -} - -fn vector_from_seed(TestSeed: seed) { - -} -*/ - -/* -static INITIAL_SEED_VALUE: u128 = 0; -static CURRENT_SEED: u128 = INITIAL_SEED_VALUE; - -fn get_current_seed() { - -} - -fn update_seed() { - -} - -fn reset_seed() { - CURRENT_SEED: u128 = INITIAL_SEED_VALUE; -} -*/ - // MOVE THIS LATER WHEN fill_opening is factored out #[derive(Clone)] pub struct FillOpeningApplicantParams { @@ -1568,7 +1567,7 @@ fn add_member_and_apply_on_opening( crate::RawEvent::AppliedOnCuratorOpening(curator_opening_id, new_curator_application_id) ); - assert!(CuratorApplicationById::::exists( + assert!(CuratorApplicationById::::contains_key( new_curator_application_id )); @@ -1718,7 +1717,6 @@ fn setup_and_fill_opening( let applicants_to_hire_iter = applicants.iter().filter(|params| params.hire); let num_applicants_hired = applicants_to_hire_iter.cloned().count(); - //let num_applicants_not_to_hire = (applicants.len() - num_applicants_hired) as usize; let hired_applicant_and_result = setup_opening_in_review .added_members_application_result @@ -1799,7 +1797,7 @@ fn setup_and_fill_opening( let expected_added_principal_id: u64 = (hired_index as u64) + original_next_principal_id; // Curator added - assert!(CuratorById::::exists(expected_added_curator_id)); + assert!(CuratorById::::contains_key(expected_added_curator_id)); let added_curator = CuratorById::::get(expected_added_curator_id); @@ -1848,7 +1846,9 @@ fn setup_and_fill_opening( assert_eq!(expected_curator, added_curator); // Principal added - assert!(PrincipalById::::exists(expected_added_principal_id)); + assert!(PrincipalById::::contains_key( + expected_added_principal_id + )); let added_principal = PrincipalById::::get(expected_added_principal_id); @@ -1978,6 +1978,7 @@ impl CreateChannelFixture { self.banner.clone(), self.publication_status.clone(), ) + .map_err(<&str>::from) } pub fn call_and_assert_error(&self, err_message: &'static str) { @@ -2010,7 +2011,7 @@ impl CreateChannelFixture { // Assert that given channel id has been added, // and has the right properties. - assert!(crate::ChannelById::::exists(channel_id)); + assert!(crate::ChannelById::::contains_key(channel_id)); let created_channel = crate::ChannelById::::get(channel_id); @@ -2044,7 +2045,7 @@ impl CreateChannelFixture { ); // Check that principal actually has been added - assert!(crate::PrincipalById::::exists( + assert!(crate::PrincipalById::::contains_key( created_channel.principal_id )); @@ -2113,15 +2114,18 @@ pub fn set_lead( member_id: ::MemberId, new_role_account: ::AccountId, ) -> LeadId { - // Get controller account - //let lead_member_controller_account = membership::Module::::ensure_membership(member_id).unwrap().controller_account; + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); let expected_lead_id = NextLeadId::::get(); - // Set lead assert_eq!( ContentWorkingGroup::replace_lead( - mock::Origin::system(system::RawOrigin::Root), + RawOrigin::Root.into(), Some((member_id, new_role_account)) ) .unwrap(), @@ -2136,7 +2140,6 @@ pub fn set_lead( expected_lead_id } -// lead_role_account: ::AccountId pub fn add_curator_opening() -> CuratorOpeningId { let activate_at = hiring::ActivateOpeningAt::ExactBlock(34); @@ -2195,6 +2198,13 @@ fn increasing_mint_capacity() { ) .build() .execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let mint_id = ContentWorkingGroup::mint(); let mint = Minting::mints(mint_id); assert_eq!(mint.capacity(), MINT_CAPACITY); @@ -2203,7 +2213,7 @@ fn increasing_mint_capacity() { // Increasing mint capacity let expected_new_capacity = MINT_CAPACITY + increase; assert_ok!(ContentWorkingGroup::increase_mint_capacity( - Origin::ROOT, + RawOrigin::Root.into(), increase )); // Excpected event after increasing @@ -2229,6 +2239,13 @@ fn setting_mint_capacity() { ) .build() .execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let mint_id = ContentWorkingGroup::mint(); let mint = Minting::mints(mint_id); assert_eq!(mint.capacity(), MINT_CAPACITY); @@ -2237,7 +2254,7 @@ fn setting_mint_capacity() { let new_lower_capacity = 10000; let decrease = MINT_CAPACITY - new_lower_capacity; assert_ok!(ContentWorkingGroup::set_mint_capacity( - Origin::ROOT, + RawOrigin::Root.into(), new_lower_capacity )); // Correct event after decreasing @@ -2253,7 +2270,7 @@ fn setting_mint_capacity() { let new_higher_capacity = 25000; let increase = new_higher_capacity - mint.capacity(); assert_ok!(ContentWorkingGroup::set_mint_capacity( - Origin::ROOT, + RawOrigin::Root.into(), new_higher_capacity )); // Excpected event after increasing diff --git a/runtime-modules/forum/Cargo.toml b/runtime-modules/forum/Cargo.toml index c13cf7f3ba..cb6f23ad23 100755 --- a/runtime-modules/forum/Cargo.toml +++ b/runtime-modules/forum/Cargo.toml @@ -1,56 +1,34 @@ [package] -name = 'substrate-forum-module' -version = '1.2.2' +name = 'pallet-forum' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' [dependencies] -hex-literal = '0.1.0' -serde = { version = '1.0.101', optional = true} -serde_derive = { version = '1.0.101', optional = true } -rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] } -# https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -quote = '<=1.0.2' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +common = { package = 'pallet-common', default-features = false, path = '../common'} [dev-dependencies] -runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../common' +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [features] default = ['std'] std = [ 'serde', - 'serde_derive', 'codec/std', - 'rstd/std', - 'runtime-io/std', - 'runtime-primitives/std', - 'srml-support/std', + 'frame-support/std', 'system/std', - 'balances/std', - 'timestamp/std', + 'sp-std/std', + 'sp-arithmetic/std', + 'sp-runtime/std', + 'pallet-timestamp/std', 'common/std', -] +] \ No newline at end of file diff --git a/runtime-modules/forum/src/lib.rs b/runtime-modules/forum/src/lib.rs index 80b4a641c8..b5a5b28377 100755 --- a/runtime-modules/forum/src/lib.rs +++ b/runtime-modules/forum/src/lib.rs @@ -7,14 +7,19 @@ #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "std")] -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; -use rstd::borrow::ToOwned; -use rstd::prelude::*; +//TODO: Convert errors to the Substrate decl_error! macro. +/// Result with string error message. This exists for backward compatibility purpose. +pub type DispatchResult = Result<(), &'static str>; use codec::{Codec, Decode, Encode}; -use runtime_primitives::traits::{MaybeSerialize, Member, One, SimpleArithmetic}; -use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, Parameter}; +use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; +use sp_arithmetic::traits::{BaseArithmetic, One}; +use sp_runtime::traits::{MaybeSerialize, Member}; +use sp_std::borrow::ToOwned; +use sp_std::vec; +use sp_std::vec::Vec; mod mock; mod tests; @@ -256,7 +261,7 @@ impl Category { type CategoryTreePath = Vec>; -pub trait Trait: system::Trait + timestamp::Trait + Sized { +pub trait Trait: system::Trait + pallet_timestamp::Trait + Sized { type Event: From> + Into<::Event>; type MembershipRegistry: ForumUserRegistry; @@ -264,7 +269,7 @@ pub trait Trait: system::Trait + timestamp::Trait + Sized { /// Thread Id type type ThreadId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -274,7 +279,7 @@ pub trait Trait: system::Trait + timestamp::Trait + Sized { /// Post Id type type PostId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -286,59 +291,39 @@ decl_storage! { trait Store for Module as Forum { /// Map category identifier to corresponding category. - pub CategoryById get(category_by_id) config(): map CategoryId => Category; + pub CategoryById get(fn category_by_id) config(): map hasher(blake2_128_concat) + CategoryId => Category; /// Category identifier value to be used for the next Category created. - pub NextCategoryId get(next_category_id) config(): CategoryId; + pub NextCategoryId get(fn next_category_id) config(): CategoryId; /// Map thread identifier to corresponding thread. - pub ThreadById get(thread_by_id) config(): map T::ThreadId => Thread; + pub ThreadById get(fn thread_by_id) config(): map hasher(blake2_128_concat) + T::ThreadId => Thread; /// Thread identifier value to be used for next Thread in threadById. - pub NextThreadId get(next_thread_id) config(): T::ThreadId; + pub NextThreadId get(fn next_thread_id) config(): T::ThreadId; /// Map post identifier to corresponding post. - pub PostById get(post_by_id) config(): map T::PostId => Post; + pub PostById get(fn post_by_id) config(): map hasher(blake2_128_concat) + T::PostId => Post; /// Post identifier value to be used for for next post created. - pub NextPostId get(next_post_id) config(): T::PostId; + pub NextPostId get(fn next_post_id) config(): T::PostId; /// Account of forum sudo. - pub ForumSudo get(forum_sudo) config(): Option; + pub ForumSudo get(fn forum_sudo) config(): Option; /// Input constraints /// These are all forward looking, that is they are enforced on all /// future calls. - pub CategoryTitleConstraint get(category_title_constraint) config(): InputValidationLengthConstraint; - pub CategoryDescriptionConstraint get(category_description_constraint) config(): InputValidationLengthConstraint; - pub ThreadTitleConstraint get(thread_title_constraint) config(): InputValidationLengthConstraint; - pub PostTextConstraint get(post_text_constraint) config(): InputValidationLengthConstraint; - pub ThreadModerationRationaleConstraint get(thread_moderation_rationale_constraint) config(): InputValidationLengthConstraint; - pub PostModerationRationaleConstraint get(post_moderation_rationale_constraint) config(): InputValidationLengthConstraint; + pub CategoryTitleConstraint get(fn category_title_constraint) config(): InputValidationLengthConstraint; + pub CategoryDescriptionConstraint get(fn category_description_constraint) config(): InputValidationLengthConstraint; + pub ThreadTitleConstraint get(fn thread_title_constraint) config(): InputValidationLengthConstraint; + pub PostTextConstraint get(fn post_text_constraint) config(): InputValidationLengthConstraint; + pub ThreadModerationRationaleConstraint get(fn thread_moderation_rationale_constraint) config(): InputValidationLengthConstraint; + pub PostModerationRationaleConstraint get(fn post_moderation_rationale_constraint) config(): InputValidationLengthConstraint; } - /* - JUST GIVING UP ON ALL THIS FOR NOW BECAUSE ITS TAKING TOO LONG - Review : https://github.com/paritytech/polkadot/blob/620b8610431e7b5fdd71ce3e94c3ee0177406dcc/runtime/src/parachains.rs#L123-L141 - - add_extra_genesis { - - // Explain why we need to put this here. - config(initial_forum_sudo) : Option; - - build(| - storage: &mut generator::StorageOverlay, - _: &mut generator::ChildrenStorageOverlay, - config: &GenesisConfig - | { - - - if let Some(account_id) = &config.initial_forum_sudo { - println!("{}: >::put(account_id)", account_id); - as generator::StorageValue<_>>::put(&account_id, storage); - } - }) - } - */ } decl_event!( @@ -383,7 +368,8 @@ decl_module! { fn deposit_event() = default; /// Set forum sudo. - fn set_forum_sudo(origin, new_forum_sudo: Option) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + fn set_forum_sudo(origin, new_forum_sudo: Option) -> DispatchResult { ensure_root(origin)?; /* @@ -408,7 +394,8 @@ decl_module! { } /// Add a new category. - fn create_category(origin, parent: Option, title: Vec, description: Vec) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + fn create_category(origin, parent: Option, title: Vec, description: Vec) -> DispatchResult { // Check that its a valid signature let who = ensure_signed(origin)?; @@ -487,7 +474,8 @@ decl_module! { } /// Update category - fn update_category(origin, category_id: CategoryId, new_archival_status: Option, new_deletion_status: Option) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + fn update_category(origin, category_id: CategoryId, new_archival_status: Option, new_deletion_status: Option) -> DispatchResult { // Check that its a valid signature let who = ensure_signed(origin)?; @@ -550,7 +538,8 @@ decl_module! { } /// Create new thread in category - fn create_thread(origin, category_id: CategoryId, title: Vec, text: Vec) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + fn create_thread(origin, category_id: CategoryId, title: Vec, text: Vec) -> DispatchResult { /* * Update SPEC with new errors, @@ -593,7 +582,8 @@ decl_module! { } /// Moderate thread - fn moderate_thread(origin, thread_id: T::ThreadId, rationale: Vec) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + fn moderate_thread(origin, thread_id: T::ThreadId, rationale: Vec) -> DispatchResult { // Check that its a valid signature let who = ensure_signed(origin)?; @@ -644,7 +634,8 @@ decl_module! { } /// Edit post text - fn add_post(origin, thread_id: T::ThreadId, text: Vec) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + fn add_post(origin, thread_id: T::ThreadId, text: Vec) -> DispatchResult { /* * Update SPEC with new errors, @@ -681,7 +672,8 @@ decl_module! { } /// Edit post text - fn edit_post_text(origin, post_id: T::PostId, new_text: Vec) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + fn edit_post_text(origin, post_id: T::PostId, new_text: Vec) -> DispatchResult { /* Edit spec. - forum member guard missing @@ -728,7 +720,8 @@ decl_module! { } /// Moderate post - fn moderate_post(origin, post_id: T::PostId, rationale: Vec) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + fn moderate_post(origin, post_id: T::PostId, rationale: Vec) -> DispatchResult { // Check that its a valid signature let who = ensure_signed(origin)?; @@ -772,7 +765,7 @@ decl_module! { } impl Module { - fn ensure_category_title_is_valid(title: &[u8]) -> dispatch::Result { + fn ensure_category_title_is_valid(title: &[u8]) -> DispatchResult { CategoryTitleConstraint::get().ensure_valid( title.len(), ERROR_CATEGORY_TITLE_TOO_SHORT, @@ -780,7 +773,7 @@ impl Module { ) } - fn ensure_category_description_is_valid(description: &[u8]) -> dispatch::Result { + fn ensure_category_description_is_valid(description: &[u8]) -> DispatchResult { CategoryDescriptionConstraint::get().ensure_valid( description.len(), ERROR_CATEGORY_DESCRIPTION_TOO_SHORT, @@ -788,7 +781,7 @@ impl Module { ) } - fn ensure_thread_moderation_rationale_is_valid(rationale: &[u8]) -> dispatch::Result { + fn ensure_thread_moderation_rationale_is_valid(rationale: &[u8]) -> DispatchResult { ThreadModerationRationaleConstraint::get().ensure_valid( rationale.len(), ERROR_THREAD_MODERATION_RATIONALE_TOO_SHORT, @@ -796,7 +789,7 @@ impl Module { ) } - fn ensure_thread_title_is_valid(title: &[u8]) -> dispatch::Result { + fn ensure_thread_title_is_valid(title: &[u8]) -> DispatchResult { ThreadTitleConstraint::get().ensure_valid( title.len(), ERROR_THREAD_TITLE_TOO_SHORT, @@ -804,7 +797,7 @@ impl Module { ) } - fn ensure_post_text_is_valid(text: &[u8]) -> dispatch::Result { + fn ensure_post_text_is_valid(text: &[u8]) -> DispatchResult { PostTextConstraint::get().ensure_valid( text.len(), ERROR_POST_TEXT_TOO_SHORT, @@ -812,7 +805,7 @@ impl Module { ) } - fn ensure_post_moderation_rationale_is_valid(rationale: &[u8]) -> dispatch::Result { + fn ensure_post_moderation_rationale_is_valid(rationale: &[u8]) -> DispatchResult { PostModerationRationaleConstraint::get().ensure_valid( rationale.len(), ERROR_POST_MODERATION_RATIONALE_TOO_SHORT, @@ -840,7 +833,7 @@ impl Module { post_id: T::PostId, ) -> Result, &'static str> { - if >::exists(post_id) { + if >::contains_key(post_id) { Ok(>::get(post_id)) } else { Err(ERROR_POST_DOES_NOT_EXIST) @@ -865,7 +858,7 @@ impl Module { fn ensure_thread_exists( thread_id: T::ThreadId, ) -> Result, &'static str> { - if >::exists(thread_id) { + if >::contains_key(thread_id) { Ok(>::get(thread_id)) } else { Err(ERROR_THREAD_DOES_NOT_EXIST) @@ -879,7 +872,7 @@ impl Module { } } - fn ensure_is_forum_sudo(account_id: &T::AccountId) -> dispatch::Result { + fn ensure_is_forum_sudo(account_id: &T::AccountId) -> DispatchResult { let forum_sudo_account = Self::ensure_forum_sudo_set()?; ensure!( @@ -901,7 +894,7 @@ impl Module { } } - fn ensure_catgory_is_mutable(category_id: CategoryId) -> dispatch::Result { + fn ensure_catgory_is_mutable(category_id: CategoryId) -> DispatchResult { let category_tree_path = Self::build_category_tree_path(category_id); Self::ensure_can_mutate_in_path_leaf(&category_tree_path) @@ -913,7 +906,7 @@ impl Module { #[allow(clippy::ptr_arg)] fn ensure_can_mutate_in_path_leaf( category_tree_path: &CategoryTreePath, - ) -> dispatch::Result { + ) -> DispatchResult { // Is parent category directly or indirectly deleted or archived category ensure!( !category_tree_path.iter().any( @@ -930,7 +923,7 @@ impl Module { #[allow(clippy::ptr_arg)] // disable it because of possible frontend API break fn ensure_can_add_subcategory_path_leaf( category_tree_path: &CategoryTreePath, - ) -> dispatch::Result { + ) -> DispatchResult { Self::ensure_can_mutate_in_path_leaf(category_tree_path)?; // Does adding a new category exceed maximum depth @@ -948,7 +941,7 @@ impl Module { category_id: CategoryId, ) -> Result, &'static str> { ensure!( - >::exists(&category_id), + >::contains_key(&category_id), ERROR_CATEGORY_DOES_NOT_EXIST ); @@ -990,7 +983,7 @@ impl Module { // Make recursive call on parent if we are not at root if let Some(child_position_in_parent) = position_in_parent_category_field { - assert!(>::exists( + assert!(>::contains_key( &child_position_in_parent.parent_id )); diff --git a/runtime-modules/forum/src/mock.rs b/runtime-modules/forum/src/mock.rs index 4e2981c63e..ce8e73d3b4 100644 --- a/runtime-modules/forum/src/mock.rs +++ b/runtime-modules/forum/src/mock.rs @@ -3,22 +3,19 @@ use crate::*; use common::BlockAndTime; -use primitives::H256; - -use crate::{GenesisConfig, Module, Trait}; -use runtime_primitives::{ +use frame_support::{impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{impl_outer_origin, parameter_types}; /// Module which has a full Substrate module for /// mocking behaviour of MembershipRegistry pub mod registry { use super::*; - // use srml_support::*; #[derive(Encode, Decode, Default, Clone, PartialEq, Eq)] pub struct Member { @@ -27,9 +24,8 @@ pub mod registry { decl_storage! { trait Store for Module as MockForumUserRegistry { - - pub ForumUserById get(forum_user_by_id) config(): map T::AccountId => Member; - + pub ForumUserById get(fn forum_user_by_id) config(): map hasher(blake2_128_concat) + T::AccountId => Member; } } @@ -45,7 +41,7 @@ pub mod registry { impl ForumUserRegistry for Module { fn get_forum_user(id: &T::AccountId) -> Option> { - if >::exists(id) { + if >::contains_key(id) { let m = >::get(id); Some(ForumUser { id: m.id }) @@ -74,25 +70,33 @@ parameter_types! { } impl system::Trait for Runtime { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - // type WeightMultiplierUpdate = (); type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -168,7 +172,7 @@ pub struct CreateCategoryFixture { pub parent: Option, pub title: Vec, pub description: Vec, - pub result: dispatch::Result, + pub result: DispatchResult, } impl CreateCategoryFixture { @@ -190,7 +194,7 @@ pub struct UpdateCategoryFixture { pub category_id: CategoryId, pub new_archival_status: Option, pub new_deletion_status: Option, - pub result: dispatch::Result, + pub result: DispatchResult, } impl UpdateCategoryFixture { @@ -212,7 +216,7 @@ pub struct CreateThreadFixture { pub category_id: CategoryId, pub title: Vec, pub text: Vec, - pub result: dispatch::Result, + pub result: DispatchResult, } impl CreateThreadFixture { @@ -233,7 +237,7 @@ pub struct CreatePostFixture { pub origin: OriginType, pub thread_id: RuntimeThreadId, pub text: Vec, - pub result: dispatch::Result, + pub result: DispatchResult, } impl CreatePostFixture { @@ -259,7 +263,7 @@ pub fn create_forum_member() -> OriginType { pub fn assert_create_category( forum_sudo: OriginType, parent_category_id: Option, - expected_result: dispatch::Result, + expected_result: DispatchResult, ) { CreateCategoryFixture { origin: forum_sudo, @@ -274,7 +278,7 @@ pub fn assert_create_category( pub fn assert_create_thread( forum_sudo: OriginType, category_id: CategoryId, - expected_result: dispatch::Result, + expected_result: DispatchResult, ) { CreateThreadFixture { origin: forum_sudo, @@ -289,7 +293,7 @@ pub fn assert_create_thread( pub fn assert_create_post( forum_sudo: OriginType, thread_id: RuntimeThreadId, - expected_result: dispatch::Result, + expected_result: DispatchResult, ) { CreatePostFixture { origin: forum_sudo, @@ -353,7 +357,7 @@ pub fn moderate_thread( forum_sudo: OriginType, thread_id: RuntimeThreadId, rationale: Vec, -) -> dispatch::Result { +) -> DispatchResult { TestForumModule::moderate_thread(mock_origin(forum_sudo), thread_id, rationale) } @@ -361,28 +365,28 @@ pub fn moderate_post( forum_sudo: OriginType, post_id: RuntimePostId, rationale: Vec, -) -> dispatch::Result { +) -> DispatchResult { TestForumModule::moderate_post(mock_origin(forum_sudo), post_id, rationale) } -pub fn archive_category(forum_sudo: OriginType, category_id: CategoryId) -> dispatch::Result { +pub fn archive_category(forum_sudo: OriginType, category_id: CategoryId) -> DispatchResult { TestForumModule::update_category(mock_origin(forum_sudo), category_id, Some(true), None) } -pub fn unarchive_category(forum_sudo: OriginType, category_id: CategoryId) -> dispatch::Result { +pub fn unarchive_category(forum_sudo: OriginType, category_id: CategoryId) -> DispatchResult { TestForumModule::update_category(mock_origin(forum_sudo), category_id, Some(false), None) } -pub fn delete_category(forum_sudo: OriginType, category_id: CategoryId) -> dispatch::Result { +pub fn delete_category(forum_sudo: OriginType, category_id: CategoryId) -> DispatchResult { TestForumModule::update_category(mock_origin(forum_sudo), category_id, None, Some(true)) } -pub fn undelete_category(forum_sudo: OriginType, category_id: CategoryId) -> dispatch::Result { +pub fn undelete_category(forum_sudo: OriginType, category_id: CategoryId) -> DispatchResult { TestForumModule::update_category(mock_origin(forum_sudo), category_id, None, Some(false)) } pub fn assert_not_forum_sudo_cannot_update_category( - update_operation: fn(OriginType, CategoryId) -> dispatch::Result, + update_operation: fn(OriginType, CategoryId) -> DispatchResult, ) { let config = default_genesis_config(); let origin = OriginType::Signed(config.forum_sudo); @@ -452,24 +456,26 @@ pub fn default_genesis_config() -> GenesisConfig { pub type RuntimeMap = std::vec::Vec<(K, V)>; pub type RuntimeCategory = Category< ::BlockNumber, - ::Moment, + ::Moment, ::AccountId, >; pub type RuntimeThread = Thread< ::BlockNumber, - ::Moment, + ::Moment, ::AccountId, RuntimeThreadId, >; pub type RuntimePost = Post< ::BlockNumber, - ::Moment, + ::Moment, ::AccountId, RuntimeThreadId, RuntimePostId, >; -pub type RuntimeBlockchainTimestamp = - BlockAndTime<::BlockNumber, ::Moment>; +pub type RuntimeBlockchainTimestamp = BlockAndTime< + ::BlockNumber, + ::Moment, +>; pub type RuntimeThreadId = ::ThreadId; pub type RuntimePostId = ::PostId; @@ -516,7 +522,7 @@ pub fn default_mock_forum_user_registry_genesis_config() -> registry::GenesisCon // NB!: // Wanted to have payload: a: &GenesisConfig // but borrow checker made my life miserabl, so giving up for now. -pub fn build_test_externalities(config: GenesisConfig) -> runtime_io::TestExternalities { +pub fn build_test_externalities(config: GenesisConfig) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime-modules/forum/src/tests.rs b/runtime-modules/forum/src/tests.rs index ab0c3c7814..071b112715 100644 --- a/runtime-modules/forum/src/tests.rs +++ b/runtime-modules/forum/src/tests.rs @@ -3,7 +3,7 @@ use super::*; use crate::mock::*; -use srml_support::{assert_err, assert_ok}; +use frame_support::{assert_err, assert_ok}; /* * NB!: No test checks for event emission!!!! diff --git a/runtime-modules/governance/Cargo.toml b/runtime-modules/governance/Cargo.toml index 40653e9894..cb5572ab53 100644 --- a/runtime-modules/governance/Cargo.toml +++ b/runtime-modules/governance/Cargo.toml @@ -1,100 +1,41 @@ [package] -name = 'substrate-governance-module' -version = '1.0.0' +name = 'pallet-governance' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +membership = { package = 'pallet-membership', default-features = false, path = '../membership'} +minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'} +recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'} +common = { package = 'pallet-common', default-features = false, path = '../common'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + [features] default = ['std'] std = [ - 'sr-primitives/std', - 'srml-support/std', - 'system/std', 'serde', 'codec/std', - 'timestamp/std', - 'primitives/std', - 'rstd/std', - 'common/std', + 'sp-std/std', + 'frame-support/std', + 'system/std', + 'sp-arithmetic/std', + 'sp-runtime/std', + 'pallet-timestamp/std', 'membership/std', 'minting/std', -] - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../common' - -[dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../membership' - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.balances] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-balances' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.minting] -default_features = false -package = 'substrate-token-mint-module' -path = '../token-minting' - -[dependencies.recurringrewards] -default_features = false -package = 'substrate-recurring-reward-module' -path = '../recurring-reward' \ No newline at end of file + 'recurringrewards/std', + 'common/std', +] \ No newline at end of file diff --git a/runtime-modules/governance/src/council.rs b/runtime-modules/governance/src/council.rs index b61045ea30..f391bcd437 100644 --- a/runtime-modules/governance/src/council.rs +++ b/runtime-modules/governance/src/council.rs @@ -1,7 +1,8 @@ -use rstd::prelude::*; -use sr_primitives::traits::{One, Zero}; -use srml_support::{debug, decl_event, decl_module, decl_storage, ensure}; -use system::{self, ensure_root}; +use frame_support::{debug, decl_event, decl_module, decl_storage, ensure}; +use sp_arithmetic::traits::{One, Zero}; +use sp_std::vec; +use sp_std::vec::Vec; +use system::ensure_root; pub use super::election::{self, CouncilElected, Seat, Seats}; pub use common::currency::{BalanceOf, GovernanceCurrency}; @@ -29,28 +30,29 @@ pub trait Trait: system::Trait + recurringrewards::Trait + GovernanceCurrency { decl_storage! { trait Store for Module as Council { - pub ActiveCouncil get(active_council) config(): Seats>; + pub ActiveCouncil get(fn active_council) config(): Seats>; - pub TermEndsAt get(term_ends_at) config() : T::BlockNumber = T::BlockNumber::from(1); + pub TermEndsAt get(fn term_ends_at) config() : T::BlockNumber = T::BlockNumber::from(1); /// The mint that funds council member rewards and spending proposals budget. It is an Option /// because it was introduced in a runtime upgrade. It will be automatically created when /// a successful call to set_council_mint_capacity() is made. - pub CouncilMint get(council_mint) : Option<::MintId>; + pub CouncilMint get(fn council_mint) : Option<::MintId>; /// The reward relationships currently in place. There may not necessarily be a 1-1 correspondance with /// the active council, since there are multiple ways of setting/adding/removing council members, some of which /// do not involve creating a relationship. - pub RewardRelationships get(reward_relationships) : map T::AccountId => T::RewardRelationshipId; + pub RewardRelationships get(fn reward_relationships) : map hasher(blake2_128_concat) + T::AccountId => T::RewardRelationshipId; /// Reward amount paid out at each PayoutInterval - pub AmountPerPayout get(amount_per_payout): minting::BalanceOf; + pub AmountPerPayout get(fn amount_per_payout): minting::BalanceOf; /// Optional interval in blocks on which a reward payout will be made to each council member - pub PayoutInterval get(payout_interval): Option; + pub PayoutInterval get(fn payout_interval): Option; /// How many blocks after the reward is created, the first payout will be made - pub FirstPayoutAfterRewardCreated get(first_payout_after_reward_created): T::BlockNumber; + pub FirstPayoutAfterRewardCreated get(fn first_payout_after_reward_created): T::BlockNumber; } } @@ -128,7 +130,7 @@ impl Module { fn remove_reward_relationships() { for seat in Self::active_council().into_iter() { - if RewardRelationships::::exists(&seat.member) { + if RewardRelationships::::contains_key(&seat.member) { let id = Self::reward_relationships(&seat.member); >::remove_reward_relationship(id); } @@ -165,6 +167,7 @@ decl_module! { /// Existing council rewards are removed and new council members do NOT get any rewards. /// Avoid using this call if possible, will be deprecated. The term of the new council is /// not extended. + #[weight = 10_000_000] // TODO: adjust weight pub fn set_council(origin, accounts: Vec) { ensure_root(origin)?; @@ -189,6 +192,7 @@ decl_module! { } /// Adds a zero staked council member. A member added in this way does not get a recurring reward. + #[weight = 10_000_000] // TODO: adjust weight fn add_council_member(origin, account: T::AccountId) { ensure_root(origin)?; @@ -209,12 +213,13 @@ decl_module! { } /// Remove a single council member and their reward. + #[weight = 10_000_000] // TODO: adjust weight fn remove_council_member(origin, account_to_remove: T::AccountId) { ensure_root(origin)?; ensure!(Self::is_councilor(&account_to_remove), "account is not a councilor"); - if RewardRelationships::::exists(&account_to_remove) { + if RewardRelationships::::contains_key(&account_to_remove) { let relationship_id = Self::reward_relationships(&account_to_remove); >::remove_reward_relationship(relationship_id); } @@ -228,6 +233,7 @@ decl_module! { } /// Set blocknumber when council term will end + #[weight = 10_000_000] // TODO: adjust weight fn set_term_ends_at(origin, ends_at: T::BlockNumber) { ensure_root(origin)?; ensure!(ends_at > >::block_number(), "must set future block number"); @@ -236,28 +242,32 @@ decl_module! { /// Sets the capacity of the the council mint, if it doesn't exist, attempts to /// create a new one. + #[weight = 10_000_000] // TODO: adjust weight pub fn set_council_mint_capacity(origin, capacity: minting::BalanceOf) { ensure_root(origin)?; if let Some(mint_id) = Self::council_mint() { - minting::Module::::set_mint_capacity(mint_id, capacity)?; + minting::Module::::set_mint_capacity(mint_id, capacity).map_err(<&str>::from)?; } else { Self::create_new_council_mint(capacity)?; } } /// Attempts to mint and transfer amount to destination account + #[weight = 10_000_000] // TODO: adjust weight fn spend_from_council_mint(origin, amount: minting::BalanceOf, destination: T::AccountId) { ensure_root(origin)?; if let Some(mint_id) = Self::council_mint() { - minting::Module::::transfer_tokens(mint_id, amount, &destination)?; + minting::Module::::transfer_tokens(mint_id, amount, &destination) + .map_err(<&str>::from)?; } else { - return Err("CouncilHasNoMint") + return Err("CouncilHasNoMint".into()); } } /// Sets the council rewards which is only applied on new council being elected. + #[weight = 10_000_000] // TODO: adjust weight fn set_council_rewards( origin, amount_per_payout: minting::BalanceOf, @@ -282,10 +292,11 @@ decl_module! { mod tests { use super::*; use crate::mock::*; - use srml_support::*; + use crate::DispatchResult; + use frame_support::*; - fn add_council_member_as_root(account: ::AccountId) -> dispatch::Result { - Council::add_council_member(system::RawOrigin::Root.into(), account) + fn add_council_member_as_root(account: ::AccountId) -> DispatchResult { + Council::add_council_member(system::RawOrigin::Root.into(), account).map_err(|e| e.into()) } #[test] @@ -367,9 +378,9 @@ mod tests { assert!(Council::is_councilor(&6)); assert!(Council::is_councilor(&7)); - assert!(RewardRelationships::::exists(&5)); - assert!(RewardRelationships::::exists(&6)); - assert!(RewardRelationships::::exists(&7)); + assert!(RewardRelationships::::contains_key(&5)); + assert!(RewardRelationships::::contains_key(&6)); + assert!(RewardRelationships::::contains_key(&7)); }); } } diff --git a/runtime-modules/governance/src/election.rs b/runtime-modules/governance/src/election.rs index 5e4173d024..66a70e307b 100644 --- a/runtime-modules/governance/src/election.rs +++ b/runtime-modules/governance/src/election.rs @@ -29,17 +29,19 @@ // Clippy linter warning #![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design -use rstd::prelude::*; -use srml_support::traits::{Currency, ReservableCurrency}; -use srml_support::{decl_event, decl_module, decl_storage, dispatch::Result, ensure}; -use system::{self, ensure_root, ensure_signed}; - -use codec::{Decode, Encode}; -use rstd::collections::btree_map::BTreeMap; -use rstd::ops::Add; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use sr_primitives::traits::{Hash, Zero}; + +use codec::{Decode, Encode}; +use frame_support::traits::{Currency, ReservableCurrency}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use sp_arithmetic::traits::Zero; +use sp_runtime::traits::Hash; +use sp_std::collections::btree_map::BTreeMap; +use sp_std::ops::Add; +use sp_std::vec; +use sp_std::vec::Vec; +use system::{ensure_root, ensure_signed}; use super::sealed_vote::SealedVote; use super::stake::Stake; @@ -48,6 +50,8 @@ use super::council; use crate::election_params::ElectionParameters; pub use common::currency::{BalanceOf, GovernanceCurrency}; +use crate::DispatchResult; + pub trait Trait: system::Trait + council::Trait + GovernanceCurrency + membership::Trait { type Event: From> + Into<::Event>; @@ -132,37 +136,40 @@ pub type ElectionStake = Stake>; decl_storage! { trait Store for Module as CouncilElection { // Flag for wether to automatically start an election after a council term ends - AutoStart get(auto_start) config() : bool = true; + AutoStart get(fn auto_start) config() : bool = true; // Current stage if there is an election running - Stage get(stage): Option>; + Stage get(fn stage): Option>; // The election round - Round get(round): u32; + Round get(fn round): u32; - ExistingStakeHolders get(existing_stake_holders): Vec; - TransferableStakes get(transferable_stakes): map T::AccountId => TransferableStake>; + ExistingStakeHolders get(fn existing_stake_holders): Vec; + TransferableStakes get(fn transferable_stakes): map hasher(blake2_128_concat) + T::AccountId => TransferableStake>; - Applicants get(applicants): Vec; - ApplicantStakes get(applicant_stakes): map T::AccountId => ElectionStake; + Applicants get(fn applicants): Vec; + ApplicantStakes get(fn applicant_stakes): map hasher(blake2_128_concat) + T::AccountId => ElectionStake; - Commitments get(commitments): Vec; + Commitments get(fn commitments): Vec; // TODO value type of this map looks scary, is there any way to simplify the notation? - Votes get(votes): map T::Hash => SealedVote, T::Hash, T::AccountId>; + Votes get(fn votes): map hasher(blake2_128_concat) + T::Hash => SealedVote, T::Hash, T::AccountId>; // Current Election Parameters. // Should we replace all the individual values with a single ElectionParameters type? // Having them individually makes it more flexible to add and remove new parameters in future // without dealing with migration issues. - AnnouncingPeriod get(announcing_period): T::BlockNumber; - VotingPeriod get(voting_period): T::BlockNumber; - RevealingPeriod get(revealing_period): T::BlockNumber; - CouncilSize get(council_size): u32; - CandidacyLimit get (candidacy_limit): u32; - MinCouncilStake get(min_council_stake): BalanceOf; - NewTermDuration get(new_term_duration): T::BlockNumber; - MinVotingStake get(min_voting_stake): BalanceOf; + AnnouncingPeriod get(fn announcing_period): T::BlockNumber; + VotingPeriod get(fn voting_period): T::BlockNumber; + RevealingPeriod get(fn revealing_period): T::BlockNumber; + CouncilSize get(fn council_size): u32; + CandidacyLimit get (fn candidacy_limit): u32; + MinCouncilStake get(fn min_council_stake): BalanceOf; + NewTermDuration get(fn new_term_duration): T::BlockNumber; + MinVotingStake get(fn min_voting_stake): BalanceOf; } add_extra_genesis { config(election_parameters): ElectionParameters, T::BlockNumber>; @@ -238,7 +245,7 @@ impl Module { /// Starts an election. Will fail if an election is already running /// Initializes transferable stakes. Assumes election parameters have already been set. - fn start_election(current_council: Seats>) -> Result { + fn start_election(current_council: Seats>) -> DispatchResult { ensure!(!Self::is_election_running(), "election already in progress"); ensure!( Self::existing_stake_holders().is_empty(), @@ -317,7 +324,7 @@ impl Module { Self::move_to_announcing_stage(); } else { // upper limit on applicants that will move to voting stage - let limit = rstd::cmp::max(Self::council_size_usize(), Self::candidacy_limit_usize()); + let limit = sp_std::cmp::max(Self::council_size_usize(), Self::candidacy_limit_usize()); let applicants_to_drop = Self::find_least_staked_applicants(&mut applicants, limit); Self::drop_applicants(applicants_to_drop); @@ -618,7 +625,7 @@ impl Module { for seat in current_council.into_iter() { let Seat { member, stake, .. } = seat; - if >::exists(&member) { + if >::contains_key(&member) { >::mutate(&member, |transferbale_stake| { *transferbale_stake = TransferableStake { seat: transferbale_stake.seat + stake, @@ -640,7 +647,7 @@ impl Module { for backer in seat.backers.into_iter() { let Backer { member, stake, .. } = backer; - if >::exists(&member) { + if >::contains_key(&member) { >::mutate(&member, |transferbale_stake| { *transferbale_stake = TransferableStake { seat: transferbale_stake.seat, @@ -682,7 +689,7 @@ impl Module { } } - fn try_add_applicant(applicant: T::AccountId, stake: BalanceOf) -> Result { + fn try_add_applicant(applicant: T::AccountId, stake: BalanceOf) -> DispatchResult { let mut transferable_stake = >::get(&applicant); let new_stake = Self::new_stake_reusing_transferable(&mut transferable_stake.seat, stake); @@ -700,11 +707,11 @@ impl Module { let applicant_stake = >::get(&applicant); let total_stake = applicant_stake.add(&new_stake); - if >::exists(&applicant) { + if >::contains_key(&applicant) { >::insert(&applicant, transferable_stake); } - if !>::exists(&applicant) { + if !>::contains_key(&applicant) { // insert element at the begining, this gives priority to early applicants // when ordering applicants by stake if stakes are equal >::mutate(|applicants| applicants.insert(0, applicant.clone())); @@ -715,8 +722,15 @@ impl Module { Ok(()) } - fn try_add_vote(voter: T::AccountId, stake: BalanceOf, commitment: T::Hash) -> Result { - ensure!(!>::exists(commitment), "duplicate commitment"); + fn try_add_vote( + voter: T::AccountId, + stake: BalanceOf, + commitment: T::Hash, + ) -> DispatchResult { + ensure!( + !>::contains_key(commitment), + "duplicate commitment" + ); let mut transferable_stake = >::get(&voter); @@ -740,7 +754,7 @@ impl Module { SealedVote::new(voter.clone(), vote_stake, commitment), ); - if >::exists(&voter) { + if >::contains_key(&voter) { >::insert(&voter, transferable_stake); } @@ -752,8 +766,11 @@ impl Module { commitment: T::Hash, vote_for: T::AccountId, salt: Vec, - ) -> Result { - ensure!(>::exists(&commitment), "commitment not found"); + ) -> DispatchResult { + ensure!( + >::contains_key(&commitment), + "commitment not found" + ); let mut sealed_vote = >::get(&commitment); @@ -761,7 +778,7 @@ impl Module { // only voter can reveal their own votes ensure!(sealed_vote.is_owned_by(voter), "only voter can reveal vote"); ensure!( - >::exists(&vote_for), + >::contains_key(&vote_for), "vote for non-applicant not allowed" ); @@ -799,6 +816,7 @@ decl_module! { // Member can apply during announcing stage only. On first call a minimum stake will need to be provided. // Member can make subsequent calls during announcing stage to increase their stake. + #[weight = 10_000_000] // TODO: adjust weight pub fn apply(origin, stake: BalanceOf) { let sender = ensure_signed(origin)?; ensure!(Self::can_participate(&sender), "Only members can apply to be on council"); @@ -813,7 +831,7 @@ decl_module! { ensure!(is_announcing, "election not in announcing stage"); // minimum stake on first attempt to apply - if !>::exists(&sender) { + if !>::contains_key(&sender) { ensure!(stake >= Self::min_council_stake(), "minimum stake must be provided"); } @@ -822,6 +840,7 @@ decl_module! { Self::deposit_event(RawEvent::Applied(sender)); } + #[weight = 10_000_000] // TODO: adjust weight fn vote(origin, commitment: T::Hash, stake: BalanceOf) { let sender = ensure_signed(origin)?; ensure!(Self::can_participate(&sender), "Only members can vote for an applicant"); @@ -840,6 +859,7 @@ decl_module! { Self::deposit_event(RawEvent::Voted(sender, commitment)); } + #[weight = 10_000_000] // TODO: adjust weight fn reveal(origin, commitment: T::Hash, vote: T::AccountId, salt: Vec) { let sender = ensure_signed(origin)?; @@ -858,18 +878,21 @@ decl_module! { Self::deposit_event(RawEvent::Revealed(sender, commitment, vote)); } + #[weight = 10_000_000] // TODO: adjust weight fn set_stage_announcing(origin, ends_at: T::BlockNumber) { ensure_root(origin)?; ensure!(ends_at > >::block_number(), "must end at future block number"); >::put(ElectionStage::Announcing(ends_at)); } + #[weight = 10_000_000] // TODO: adjust weight fn set_stage_revealing(origin, ends_at: T::BlockNumber) { ensure_root(origin)?; ensure!(ends_at > >::block_number(), "must end at future block number"); >::put(ElectionStage::Revealing(ends_at)); } + #[weight = 10_000_000] // TODO: adjust weight fn set_stage_voting(origin, ends_at: T::BlockNumber) { ensure_root(origin)?; ensure!(ends_at > >::block_number(), "must end at future block number"); @@ -881,6 +904,7 @@ decl_module! { /// The call will fail if an election is in progress. If a council is not being elected for some /// reaon after multiple rounds, force_stop_election() can be called to stop elections and followed by /// set_election_parameters(). + #[weight = 10_000_000] // TODO: adjust weight pub fn set_election_parameters(origin, params: ElectionParameters, T::BlockNumber>) { ensure_root(origin)?; ensure!(!Self::is_election_running(), MSG_CANNOT_CHANGE_PARAMS_DURING_ELECTION); @@ -888,6 +912,7 @@ decl_module! { Self::set_verified_election_parameters(params); } + #[weight = 10_000_000] // TODO: adjust weight fn force_stop_election(origin) { ensure_root(origin)?; ensure!(Self::is_election_running(), "only running election can be stopped"); @@ -907,16 +932,17 @@ decl_module! { ); } + #[weight = 10_000_000] // TODO: adjust weight pub fn force_start_election(origin) { ensure_root(origin)?; Self::start_election(>::active_council())?; } + #[weight = 10_000_000] // TODO: adjust weight fn set_auto_start (origin, flag: bool) { ensure_root(origin)?; AutoStart::put(flag); } - } } @@ -933,7 +959,9 @@ mod tests { use super::*; use crate::mock::*; use codec::Encode; - use srml_support::*; + use frame_support::traits::OnFinalize; + use frame_support::{assert_err, assert_ok}; + use system::RawOrigin; #[test] fn election_starts_when_council_term_ends() { @@ -1344,12 +1372,12 @@ mod tests { assert_eq!(Balances::free_balance(&1), 1000); //assert_eq!(Election::applicant_stakes(2), Default::default()); - assert!(!>::exists(2)); + assert!(!>::contains_key(2)); assert_eq!(Election::transferable_stakes(2).seat, 400); assert_eq!(Balances::free_balance(&2), 2300); //assert_eq!(Election::applicant_stakes(3), Default::default()); - assert!(!>::exists(3)); + assert!(!>::contains_key(3)); assert_eq!(Election::transferable_stakes(3).seat, 600); assert_eq!(Balances::free_balance(&3), 3500); }); @@ -1432,7 +1460,7 @@ mod tests { assert!(Election::try_add_vote(20, 1000, commitment).is_err()); assert_eq!(Election::commitments(), vec![]); - assert!(!>::exists(commitment)); + assert!(!>::contains_key(commitment)); assert_eq!(Balances::free_balance(&20), 100); }); } @@ -1634,7 +1662,7 @@ mod tests { pub fn mock_votes( mock: Vec<(u64, u64, u64, u64)>, - ) -> Vec, primitives::H256, u64>> { + ) -> Vec, sp_core::H256, u64>> { let commitment = make_commitment_for_applicant(1, &mut vec![0u8]); mock.into_iter() @@ -1806,7 +1834,7 @@ mod tests { // applicant dropped assert_eq!(Election::applicants(), vec![200, 300]); - assert!(!>::exists(100)); + assert!(!>::contains_key(100)); // and refunded assert_eq!(Election::transferable_stakes(100).seat, 150); @@ -2095,7 +2123,7 @@ mod tests { }; assert_ok!(Election::set_election_parameters( - Origin::ROOT, + RawOrigin::Root.into(), new_parameters )); diff --git a/runtime-modules/governance/src/election_params.rs b/runtime-modules/governance/src/election_params.rs index f34646e608..93d68cc2e8 100644 --- a/runtime-modules/governance/src/election_params.rs +++ b/runtime-modules/governance/src/election_params.rs @@ -1,8 +1,11 @@ -use codec::{Decode, Encode}; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use sr_primitives::traits::Zero; -use srml_support::{dispatch::Result, ensure}; + +use codec::{Decode, Encode}; +use frame_support::ensure; +use sp_arithmetic::traits::Zero; + +use crate::DispatchResult; pub static MSG_PERIOD_CANNOT_BE_ZERO: &str = "PeriodCannotBeZero"; pub static MSG_COUNCIL_SIZE_CANNOT_BE_ZERO: &str = "CouncilSizeCannotBeZero"; @@ -24,20 +27,20 @@ pub struct ElectionParameters { } impl ElectionParameters { - pub fn ensure_valid(&self) -> Result { + pub fn ensure_valid(&self) -> DispatchResult { self.ensure_periods_are_valid()?; self.ensure_council_size_and_candidacy_limit_are_valid()?; Ok(()) } - fn ensure_periods_are_valid(&self) -> Result { + fn ensure_periods_are_valid(&self) -> DispatchResult { ensure!(!self.announcing_period.is_zero(), MSG_PERIOD_CANNOT_BE_ZERO); ensure!(!self.voting_period.is_zero(), MSG_PERIOD_CANNOT_BE_ZERO); ensure!(!self.revealing_period.is_zero(), MSG_PERIOD_CANNOT_BE_ZERO); Ok(()) } - fn ensure_council_size_and_candidacy_limit_are_valid(&self) -> Result { + fn ensure_council_size_and_candidacy_limit_are_valid(&self) -> DispatchResult { ensure!(self.council_size > 0, MSG_COUNCIL_SIZE_CANNOT_BE_ZERO); ensure!( self.council_size <= self.candidacy_limit, diff --git a/runtime-modules/governance/src/lib.rs b/runtime-modules/governance/src/lib.rs index de98f9a5d4..59888022e8 100644 --- a/runtime-modules/governance/src/lib.rs +++ b/runtime-modules/governance/src/lib.rs @@ -9,3 +9,7 @@ mod sealed_vote; mod stake; mod mock; + +//TODO: Convert errors to the Substrate decl_error! macro. +/// Result with string error message. This exists for backward compatibility purpose. +pub type DispatchResult = Result<(), &'static str>; diff --git a/runtime-modules/governance/src/mock.rs b/runtime-modules/governance/src/mock.rs index 4602d49ccd..765d0b3529 100644 --- a/runtime-modules/governance/src/mock.rs +++ b/runtime-modules/governance/src/mock.rs @@ -2,17 +2,15 @@ pub use super::{council, election}; pub use common::currency::GovernanceCurrency; -pub use system; -pub use primitives::{Blake2Hasher, H256}; -pub use sr_primitives::{ - testing::{Digest, DigestItem, Header, UintAuthorityId}, - traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, - weights::Weight, - BuildStorage, Perbill, +use frame_support::{impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, }; - -use srml_support::{impl_outer_origin, parameter_types}; +pub use system; impl_outer_origin! { pub enum Origin for Test {} @@ -30,10 +28,11 @@ parameter_types! { } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -42,12 +41,20 @@ impl system::Trait for Test { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -80,27 +87,14 @@ impl recurringrewards::Trait for Test { } 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; } 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 Event = (); type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl GovernanceCurrency for Test { @@ -111,7 +105,7 @@ impl GovernanceCurrency for Test { // This function basically just builds a genesis storage key/value store according to // our desired mockup. -pub fn initial_test_ext() -> runtime_io::TestExternalities { +pub fn initial_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime-modules/governance/src/sealed_vote.rs b/runtime-modules/governance/src/sealed_vote.rs index 1dfa3ce1f8..8e11e6852b 100644 --- a/runtime-modules/governance/src/sealed_vote.rs +++ b/runtime-modules/governance/src/sealed_vote.rs @@ -1,6 +1,6 @@ use codec::{Decode, Encode}; -use rstd::vec::Vec; -use srml_support::ensure; +use frame_support::ensure; +use sp_std::vec::Vec; #[derive(Clone, Copy, Encode, Decode, Default)] pub struct SealedVote diff --git a/runtime-modules/governance/src/stake.rs b/runtime-modules/governance/src/stake.rs index 9ed29d753f..9afae07672 100644 --- a/runtime-modules/governance/src/stake.rs +++ b/runtime-modules/governance/src/stake.rs @@ -1,11 +1,11 @@ use codec::{Decode, Encode}; -use rstd::cmp::Ordering; -use sr_primitives::traits::SimpleArithmetic; +use sp_arithmetic::traits::BaseArithmetic; +use sp_std::cmp::Ordering; #[derive(Encode, Decode, Clone, Copy, Default, Debug)] pub struct Stake where - Balance: Copy + SimpleArithmetic, + Balance: Copy + BaseArithmetic, { pub new: Balance, pub transferred: Balance, @@ -13,7 +13,7 @@ where impl Stake where - Balance: Copy + SimpleArithmetic, + Balance: Copy + BaseArithmetic, { pub fn total(&self) -> Balance { self.new + self.transferred @@ -27,25 +27,25 @@ where } } -impl PartialOrd for Stake { +impl PartialOrd for Stake { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(&other)) } } -impl Ord for Stake { +impl Ord for Stake { fn cmp(&self, other: &Self) -> Ordering { self.total().cmp(&other.total()) } } -impl PartialEq for Stake { +impl PartialEq for Stake { fn eq(&self, other: &Self) -> bool { self.total() == other.total() } } -impl Eq for Stake {} +impl Eq for Stake {} #[cfg(test)] mod tests { diff --git a/runtime-modules/hiring/Cargo.toml b/runtime-modules/hiring/Cargo.toml index 0cbb91c847..79453af1d3 100755 --- a/runtime-modules/hiring/Cargo.toml +++ b/runtime-modules/hiring/Cargo.toml @@ -1,60 +1,34 @@ [package] -name = 'substrate-hiring-module' -version = '1.0.2' +name = 'pallet-hiring' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' [dependencies] -hex-literal = '0.1.0' -serde = { version = '1.0', optional = true } -serde_derive = { version = '1.0', optional = true } -rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] } -mockall = {version = "0.7.1", optional = true} -# https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -quote = '<=1.0.2' - -[dependencies.stake] -default_features = false -package = 'substrate-stake-module' -path = '../stake' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +stake = { package = 'pallet-stake', default-features = false, path = '../stake'} [dev-dependencies] -runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} mockall = "0.7.1" - +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [features] default = ['std'] -test = ['mockall'] std = [ 'serde', - 'serde_derive', 'codec/std', - 'rstd/std', - 'runtime-io/std', - 'runtime-primitives/std', - 'srml-support/std', + 'sp-std/std', + 'frame-support/std', 'system/std', - 'balances/std', - 'timestamp/std', + 'sp-arithmetic/std', + 'sp-runtime/std', 'stake/std', -] +] \ No newline at end of file diff --git a/runtime-modules/hiring/src/hiring/application.rs b/runtime-modules/hiring/src/hiring/application.rs index c31fce5191..dc7f6b4166 100644 --- a/runtime-modules/hiring/src/hiring/application.rs +++ b/runtime-modules/hiring/src/hiring/application.rs @@ -1,6 +1,6 @@ use codec::{Decode, Encode}; -use rstd::clone::Clone; -use rstd::vec::Vec; +use sp_std::clone::Clone; +use sp_std::vec::Vec; use crate::hiring::StakePurpose; diff --git a/runtime-modules/hiring/src/hiring/opening.rs b/runtime-modules/hiring/src/hiring/opening.rs index f04e796c66..d14e7a3358 100644 --- a/runtime-modules/hiring/src/hiring/opening.rs +++ b/runtime-modules/hiring/src/hiring/opening.rs @@ -1,7 +1,7 @@ -use rstd::clone::Clone; -use rstd::collections::btree_set::BTreeSet; -use rstd::prelude::*; -use rstd::vec::Vec; +use sp_std::clone::Clone; +use sp_std::collections::btree_set::BTreeSet; +use sp_std::prelude::*; +use sp_std::vec::Vec; use codec::{Decode, Encode}; #[cfg(feature = "std")] @@ -191,8 +191,6 @@ pub enum OpeningStage { /// Deactivated at any time for any cause. deactivated_application_count: u32, - // Removed at any time. - //removed_application_count: u32 }, } @@ -401,6 +399,4 @@ pub enum ActivateOpeningAt { pub struct ApplicationRationingPolicy { /// The maximum number of applications that can be on the list at any time. pub max_active_applicants: u32, - // How applicants will be ranked, in order to respect the maximum simultaneous application limit - //pub applicant_ranking: ApplicationRankingPolicy } diff --git a/runtime-modules/hiring/src/lib.rs b/runtime-modules/hiring/src/lib.rs index cbfd7595b6..1ed4839d7c 100755 --- a/runtime-modules/hiring/src/lib.rs +++ b/runtime-modules/hiring/src/lib.rs @@ -18,31 +18,26 @@ // Do not delete! Cannot be uncommented by default, because of Parity decl_module! issue. //#![warn(missing_docs)] -// Test feature dependencies -#[cfg(all(any(test, feature = "test"), not(target_arch = "wasm32")))] +// Test dependencies +#[cfg(all(test, not(target_arch = "wasm32")))] use mockall::predicate::*; -#[cfg(all(any(test, feature = "test"), not(target_arch = "wasm32")))] +#[cfg(all(test, not(target_arch = "wasm32")))] use mockall::*; -use stake::{InitiateUnstakingError, Stake, StakeActionError, StakingError, Trait as StakeTrait}; - use codec::Codec; +use frame_support::storage::IterableStorageMap; +use frame_support::traits::{Currency, Imbalance}; +use frame_support::{decl_module, decl_storage, ensure, Parameter}; +use sp_arithmetic::traits::{BaseArithmetic, One, Zero}; +use sp_runtime::traits::{MaybeSerialize, Member}; +use sp_std::cell::RefCell; +use sp_std::collections::btree_map::BTreeMap; +use sp_std::collections::btree_set::BTreeSet; +use sp_std::iter::Iterator; +use sp_std::rc::Rc; +use sp_std::vec::Vec; -use runtime_primitives::traits::Zero; -use runtime_primitives::traits::{MaybeSerialize, Member, One, SimpleArithmetic}; - -use srml_support::traits::Currency; -use srml_support::{decl_module, decl_storage, ensure, Parameter}; - -use rstd::collections::btree_map::BTreeMap; -use rstd::collections::btree_set::BTreeSet; -use rstd::iter::Iterator; -use rstd::prelude::*; - -use rstd::cell::RefCell; -use rstd::rc::Rc; - -use crate::sr_api_hidden_includes_decl_storage::hidden_include::traits::Imbalance; +use stake::{InitiateUnstakingError, Stake, StakeActionError, StakingError, Trait as StakeTrait}; mod hiring; #[macro_use] @@ -57,7 +52,7 @@ pub trait Trait: system::Trait + stake::Trait + Sized { /// OpeningId type type OpeningId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -67,7 +62,7 @@ pub trait Trait: system::Trait + stake::Trait + Sized { /// ApplicationId type type ApplicationId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -83,21 +78,23 @@ pub trait Trait: system::Trait + stake::Trait + Sized { decl_storage! { trait Store for Module as Hiring { - /// Openings. - pub OpeningById get(opening_by_id): linked_map T::OpeningId => Opening, T::BlockNumber, T::ApplicationId>; + pub OpeningById get(fn opening_by_id): map hasher(blake2_128_concat) + T::OpeningId => Opening, T::BlockNumber, T::ApplicationId>; /// Identifier for next opening to be added. - pub NextOpeningId get(next_opening_id): T::OpeningId; + pub NextOpeningId get(fn next_opening_id): T::OpeningId; /// Applications - pub ApplicationById get(application_by_id): linked_map T::ApplicationId => Application; + pub ApplicationById get(fn application_by_id): map hasher(blake2_128_concat) + T::ApplicationId => Application; /// Identifier for next application to be added. - pub NextApplicationId get(next_application_id): T::ApplicationId; + pub NextApplicationId get(fn next_application_id): T::ApplicationId; /// Internal purpose of given stake, i.e. fro what application, and whether for the role or for the application. - pub ApplicationIdByStakingId get(stake_purpose_by_staking_id): linked_map T::StakeId => T::ApplicationId; + pub ApplicationIdByStakingId get(fn stake_purpose_by_staking_id): map hasher(blake2_128_concat) + T::StakeId => T::ApplicationId; } } @@ -769,14 +766,14 @@ impl Module { /// The stake, with the given id, was unstaked. pub fn unstaked(stake_id: T::StakeId) -> UnstakedResult { // Ignore unstaked - if !>::exists(stake_id) { + if !>::contains_key(stake_id) { return UnstakedResult::StakeIdNonExistent; } // Get application let application_id = >::get(stake_id); - assert!(>::exists(application_id)); + assert!(>::contains_key(application_id)); let application = >::get(application_id); @@ -1005,7 +1002,7 @@ impl Module { Opening, T::BlockNumber, T::ApplicationId>, ), > { - >::enumerate().filter_map(move |(opening_id, opening)| { + >::iter().filter_map(move |(opening_id, opening)| { if let hiring::OpeningStage::WaitingToBegin { begins_at_block } = opening.stage { if begins_at_block == now { Some((opening_id, opening)) @@ -1028,7 +1025,7 @@ impl Module { (BTreeSet, T::BlockNumber, T::BlockNumber), ), > { - >::enumerate().filter_map(move |(opening_id, opening)| { + >::iter().filter_map(move |(opening_id, opening)| { if let hiring::OpeningStage::Active { ref stage, ref applications_added, @@ -1282,7 +1279,7 @@ impl Module { // MUST never already be a key for new stake, false means code is broken. // But should we do panic in runtime? Is there safer way? - assert!(!>::exists(new_stake_id)); + assert!(!>::contains_key(new_stake_id)); >::insert(new_stake_id, application_id); @@ -1476,10 +1473,7 @@ impl Module { */ /// Defines stake module interface -#[cfg_attr( - all(any(test, feature = "test"), not(target_arch = "wasm32")), - automock -)] +#[cfg_attr(all(test, not(target_arch = "wasm32")), automock)] pub trait StakeHandler { /// Adds a new Stake which is NotStaked, created at given block, into stakes map. fn create_stake(&self) -> T::StakeId; @@ -1536,7 +1530,7 @@ impl StakeHandler for HiringStakeHandler { } fn stake_exists(&self, stake_id: T::StakeId) -> bool { - >::exists(stake_id) + >::contains_key(stake_id) } fn get_stake(&self, stake_id: T::StakeId) -> Stake, T::SlashId> { diff --git a/runtime-modules/hiring/src/macroes.rs b/runtime-modules/hiring/src/macroes.rs index 4d4c9726d0..a2cde79fe4 100644 --- a/runtime-modules/hiring/src/macroes.rs +++ b/runtime-modules/hiring/src/macroes.rs @@ -10,7 +10,7 @@ macro_rules! ensure_eq { /// Ensure that a storage map, with a given name, has mapping for the given key value. macro_rules! ensure_map_key { ($map_variable_name:ident , $runtime_trait:tt, $key:expr, $error:expr) => {{ - if <$map_variable_name<$runtime_trait>>::exists($key) { + if <$map_variable_name<$runtime_trait>>::contains_key($key) { let value = <$map_variable_name<$runtime_trait>>::get($key); Ok(value) diff --git a/runtime-modules/hiring/src/mock.rs b/runtime-modules/hiring/src/mock.rs index 27d7f3bfe4..7a24e9e0da 100644 --- a/runtime-modules/hiring/src/mock.rs +++ b/runtime-modules/hiring/src/mock.rs @@ -1,23 +1,21 @@ #![cfg(test)] -use primitives::H256; -use runtime_primitives::{ +use frame_support::{impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{impl_outer_origin, parameter_types}; +use sp_std::cell::{Cell, RefCell}; +use sp_std::rc::Rc; +use std::panic; use crate::hiring::ApplicationDeactivationCause; use crate::{Module, Trait}; use balances; use stake; -use std::cell::Cell; -use std::cell::RefCell; -use std::panic; -use std::rc::Rc; - impl_outer_origin! { pub enum Origin for Test {} } @@ -27,7 +25,6 @@ parameter_types! { pub const MaximumBlockWeight: u32 = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); - pub const MinimumPeriod: u64 = 5; } // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. @@ -35,10 +32,11 @@ parameter_types! { pub struct Test; impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -47,44 +45,36 @@ impl system::Trait for Test { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } parameter_types! { pub const ExistentialDeposit: u32 = 100; - pub const TransferFee: u32 = 0; - pub const CreationFee: u32 = 0; - pub const TransactionBaseFee: u32 = 1; - pub const TransactionByteFee: u32 = 0; pub const StakePoolId: [u8; 8] = *b"joystake"; } 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 Event = (); type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl Trait for Test { type OpeningId = u64; - type ApplicationId = u64; - type ApplicationDeactivatedHandler = TestApplicationDeactivatedHandler; - type StakeHandlerProvider = TestStakeHandlerProvider; } @@ -136,7 +126,9 @@ thread_local! { } // Sets stake handler implementation in hiring module. Mockall frameworks integration -pub(crate) fn set_stake_handler_impl(mock: Rc>>) { +pub(crate) fn set_stake_handler_impl( + mock: Rc>>, +) { // Hiring::staking.mock_safe(move || MockResult::Return(mock.clone())); THREAD_LOCAL_STAKE_HANDLER.with(|f| { *f.borrow_mut() = mock.clone(); @@ -148,7 +140,7 @@ pub(crate) fn test_expectation_and_clear_mock() { set_stake_handler_impl(Rc::new(RefCell::new(crate::HiringStakeHandler {}))); } -pub fn build_test_externalities() -> runtime_io::TestExternalities { +pub fn build_test_externalities() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); @@ -201,3 +193,6 @@ impl TestApplicationDeactivatedHandler { ); } } + +// Test fixtures starting block. +pub(crate) static FIRST_BLOCK_HEIGHT: ::BlockNumber = 0; diff --git a/runtime-modules/hiring/src/test/mod.rs b/runtime-modules/hiring/src/test/mod.rs index bda798dc98..78febb3181 100644 --- a/runtime-modules/hiring/src/test/mod.rs +++ b/runtime-modules/hiring/src/test/mod.rs @@ -8,8 +8,8 @@ use public_api::*; use crate::mock::Test; use crate::*; -use rstd::cell::RefCell; -use rstd::rc::Rc; +use sp_std::cell::RefCell; +use sp_std::rc::Rc; use std::panic; @@ -22,6 +22,6 @@ pub(crate) type Balance = // Debug test object content. Recurring temporary usage - do not delete. #[allow(dead_code)] -pub fn debug_print(obj: T) { +pub fn debug_print(obj: T) { println!("{:?}", obj); } diff --git a/runtime-modules/hiring/src/test/public_api/add_application.rs b/runtime-modules/hiring/src/test/public_api/add_application.rs index 6708c90ac9..25afb9de40 100644 --- a/runtime-modules/hiring/src/test/public_api/add_application.rs +++ b/runtime-modules/hiring/src/test/public_api/add_application.rs @@ -1,6 +1,6 @@ use crate::mock::*; use crate::test::*; -use rstd::collections::btree_map::BTreeMap; +use sp_std::collections::btree_map::BTreeMap; use stake::NegativeImbalance; use crate::test::public_api::*; @@ -66,12 +66,16 @@ impl AddApplicationFixture { // Check next application id has been updated assert_eq!(Hiring::next_application_id(), expected_application_id + 1); // Check application exists - assert!(>::exists(expected_application_id)); + assert!(>::contains_key( + expected_application_id + )); } else { // Check next application id has not been updated assert_eq!(Hiring::next_application_id(), expected_application_id); // Check application does not exist - assert!(!>::exists(expected_application_id)); + assert!(!>::contains_key( + expected_application_id + )); }; //Check application content @@ -115,7 +119,7 @@ impl AddApplicationFixture { let expected_application = Application { opening_id: self.opening_id, application_index_in_opening: expected_application_index_in_opening, - add_to_opening_in_block: 1, + add_to_opening_in_block: 0, active_role_staking_id: expected_active_role_staking_id, active_application_staking_id: expected_active_application_staking_id, stage: ApplicationStage::Active, @@ -166,7 +170,7 @@ impl AddApplicationFixture { let expected_opening = Opening { stage: OpeningStage::Active { stage: ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, }, applications_added: expected_added_apps_in_opening, active_application_count: expected_active_application_count, @@ -289,7 +293,7 @@ fn add_application_succeeds_with_created_application_stake() { let stake = Hiring::staking().get_stake(application_stake_id); let expected_stake = stake::Stake { - created: 1, + created: FIRST_BLOCK_HEIGHT, staking_status: stake::StakingStatus::Staked(stake::StakedState { staked_amount: 100, staked_status: stake::StakedStatus::Normal, diff --git a/runtime-modules/hiring/src/test/public_api/add_opening.rs b/runtime-modules/hiring/src/test/public_api/add_opening.rs index bbbf69df0b..9a10b07190 100644 --- a/runtime-modules/hiring/src/test/public_api/add_opening.rs +++ b/runtime-modules/hiring/src/test/public_api/add_opening.rs @@ -1,4 +1,4 @@ -use crate::mock::{build_test_externalities, Hiring, Test}; +use crate::mock::{build_test_externalities, Hiring, Test, FIRST_BLOCK_HEIGHT}; use crate::test::{BlockNumber, OpeningId}; use crate::StakingAmountLimitMode::Exact; use crate::*; @@ -6,9 +6,8 @@ use crate::{ ActivateOpeningAt, ActiveOpeningStage, AddOpeningError, ApplicationRationingPolicy, Opening, OpeningStage, StakePurpose, StakingPolicy, }; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; -static FIRST_BLOCK_HEIGHT: ::BlockNumber = 1; pub static HUMAN_READABLE_TEXT: &[u8] = b"HUMAN_READABLE_TEXT!!!!"; pub struct AddOpeningFixture { @@ -44,12 +43,12 @@ impl AddOpeningFixture { // Check next opening id has been updated assert_eq!(Hiring::next_opening_id(), expected_opening_id + 1); // Check opening exists - assert!(>::exists(expected_opening_id)); + assert!(>::contains_key(expected_opening_id)); } else { // Check next opening id has not been updated assert_eq!(Hiring::next_opening_id(), expected_opening_id); // Check opening does not exist - assert!(!>::exists(expected_opening_id)); + assert!(!>::contains_key(expected_opening_id)); }; //Check opening content @@ -75,7 +74,7 @@ impl AddOpeningFixture { }; let expected_opening = Opening { - created: FIRST_BLOCK_HEIGHT, + created: mock::FIRST_BLOCK_HEIGHT, stage: expected_opening_stage, max_review_period_length: self.max_review_period_length, application_rationing_policy: self.application_rationing_policy.clone(), diff --git a/runtime-modules/hiring/src/test/public_api/begin_accepting_applications.rs b/runtime-modules/hiring/src/test/public_api/begin_accepting_applications.rs index a660da8203..5602dfa63c 100644 --- a/runtime-modules/hiring/src/test/public_api/begin_accepting_applications.rs +++ b/runtime-modules/hiring/src/test/public_api/begin_accepting_applications.rs @@ -1,6 +1,6 @@ use crate::mock::*; use crate::test::*; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; #[test] fn begin_accepting_applications_fails_with_no_opening() { @@ -42,10 +42,10 @@ fn begin_accepting_applications_succeeds() { let updated_opening = >::get(opening_id); let expected_opening_state = Opening { - created: 1, + created: FIRST_BLOCK_HEIGHT, stage: OpeningStage::Active { stage: ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, }, applications_added: BTreeSet::new(), active_application_count: 0, diff --git a/runtime-modules/hiring/src/test/public_api/begin_review.rs b/runtime-modules/hiring/src/test/public_api/begin_review.rs index 25dc74ad0c..5a5e5d9bfc 100644 --- a/runtime-modules/hiring/src/test/public_api/begin_review.rs +++ b/runtime-modules/hiring/src/test/public_api/begin_review.rs @@ -46,8 +46,8 @@ fn begin_review_succeeds() { let expected_opening_state = old_opening.clone_with_new_active_opening_stage(ActiveOpeningStage::ReviewPeriod { - started_accepting_applicants_at_block: 1, - started_review_period_at_block: 1, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, + started_review_period_at_block: FIRST_BLOCK_HEIGHT, }); assert_eq!(updated_opening, expected_opening_state); diff --git a/runtime-modules/hiring/src/test/public_api/cancel_opening.rs b/runtime-modules/hiring/src/test/public_api/cancel_opening.rs index 19f32b9324..938324e947 100644 --- a/runtime-modules/hiring/src/test/public_api/cancel_opening.rs +++ b/runtime-modules/hiring/src/test/public_api/cancel_opening.rs @@ -2,7 +2,7 @@ use crate::mock::*; use crate::test::*; use crate::test::public_api::*; -use rstd::collections::btree_map::BTreeMap; +use sp_std::collections::btree_map::BTreeMap; /* Not covered: @@ -96,7 +96,7 @@ impl CancelOpeningFixture { started_accepting_applicants_at_block, } => ActiveOpeningStage::Deactivated { cause: OpeningDeactivationCause::CancelledAcceptingApplications, - deactivated_at_block: 1, + deactivated_at_block: FIRST_BLOCK_HEIGHT, started_accepting_applicants_at_block, started_review_period_at_block: None, }, @@ -105,7 +105,7 @@ impl CancelOpeningFixture { started_review_period_at_block, } => ActiveOpeningStage::Deactivated { cause: OpeningDeactivationCause::CancelledInReviewPeriod, - deactivated_at_block: 1, + deactivated_at_block: FIRST_BLOCK_HEIGHT, started_accepting_applicants_at_block, started_review_period_at_block: Some(started_review_period_at_block), }, diff --git a/runtime-modules/hiring/src/test/public_api/deactivate_application.rs b/runtime-modules/hiring/src/test/public_api/deactivate_application.rs index effce30ed4..cd23b06693 100644 --- a/runtime-modules/hiring/src/test/public_api/deactivate_application.rs +++ b/runtime-modules/hiring/src/test/public_api/deactivate_application.rs @@ -67,7 +67,7 @@ impl DeactivateApplicationFixture { { Application { stage: ApplicationStage::Unstaking { - deactivation_initiated: 1, + deactivation_initiated: FIRST_BLOCK_HEIGHT, cause: ApplicationDeactivationCause::External, }, ..old_application_state @@ -75,8 +75,8 @@ impl DeactivateApplicationFixture { } else { Application { stage: ApplicationStage::Inactive { - deactivation_initiated: 1, - deactivated: 1, + deactivation_initiated: FIRST_BLOCK_HEIGHT, + deactivated: FIRST_BLOCK_HEIGHT, cause: ApplicationDeactivationCause::External, }, ..old_application_state @@ -98,7 +98,7 @@ impl DeactivateApplicationFixture { // invalid opening stages are not supported // check for opening existence - if !>::exists(opening_id) { + if !>::contains_key(opening_id) { return; } @@ -131,7 +131,7 @@ impl DeactivateApplicationFixture { let expected_opening = Opening { stage: OpeningStage::Active { stage: ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, }, applications_added, active_application_count: expected_active_application_count, diff --git a/runtime-modules/hiring/src/test/public_api/ensure_can_add_application.rs b/runtime-modules/hiring/src/test/public_api/ensure_can_add_application.rs index b2413ee6a2..5e6f93a587 100644 --- a/runtime-modules/hiring/src/test/public_api/ensure_can_add_application.rs +++ b/runtime-modules/hiring/src/test/public_api/ensure_can_add_application.rs @@ -2,7 +2,7 @@ use crate::mock::*; use crate::test::*; use crate::hiring::*; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; #[test] fn ensure_can_add_application_fails_with_no_opening() { @@ -239,10 +239,10 @@ fn ensure_can_add_application_succeeds() { ensure_can_add_application_result, Ok(DestructuredApplicationCanBeAddedEvaluation { opening: Opening { - created: 1, + created: FIRST_BLOCK_HEIGHT, stage: hiring::OpeningStage::Active { stage: hiring::ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1 + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT }, applications_added: BTreeSet::new(), active_application_count: 0, @@ -266,7 +266,7 @@ fn ensure_can_add_application_succeeds() { human_readable_text: HUMAN_READABLE_TEXT.to_vec() }, active_stage: hiring::ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1 + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT }, applications_added: BTreeSet::new(), active_application_count: 0, diff --git a/runtime-modules/hiring/src/test/public_api/fill_opening.rs b/runtime-modules/hiring/src/test/public_api/fill_opening.rs index 562115b00f..2cf945f7a1 100644 --- a/runtime-modules/hiring/src/test/public_api/fill_opening.rs +++ b/runtime-modules/hiring/src/test/public_api/fill_opening.rs @@ -2,8 +2,8 @@ use crate::mock::*; use crate::test::*; use crate::test::public_api::*; -use rstd::collections::btree_set::BTreeSet; -use rstd::result::Result; +use sp_std::collections::btree_set::BTreeSet; +use sp_std::result::Result; /* Not covered: @@ -89,9 +89,9 @@ impl FillOpeningFixture { // compose expected stage let expected_active_stage = ActiveOpeningStage::Deactivated { cause: OpeningDeactivationCause::Filled, - deactivated_at_block: 1, - started_accepting_applicants_at_block: 1, - started_review_period_at_block: Some(1), + deactivated_at_block: FIRST_BLOCK_HEIGHT, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, + started_review_period_at_block: Some(FIRST_BLOCK_HEIGHT), }; // calculate application counters diff --git a/runtime-modules/hiring/src/test/public_api/mod.rs b/runtime-modules/hiring/src/test/public_api/mod.rs index 9668782285..1faf9f833e 100644 --- a/runtime-modules/hiring/src/test/public_api/mod.rs +++ b/runtime-modules/hiring/src/test/public_api/mod.rs @@ -15,9 +15,9 @@ pub use add_opening::{AddOpeningFixture, HUMAN_READABLE_TEXT}; pub use deactivate_application::DeactivateApplicationFixture; use crate::mock::Test; -use rstd::cell::RefCell; -use rstd::collections::btree_map::BTreeMap; -use rstd::rc::Rc; +use sp_std::cell::RefCell; +use sp_std::collections::btree_map::BTreeMap; +use sp_std::rc::Rc; fn default_mock_for_creating_stake() -> Rc>> { let mut mock = crate::MockStakeHandler::::new(); @@ -25,7 +25,7 @@ fn default_mock_for_creating_stake() -> Rc mock.expect_stake().times(1).returning(|_, _| Ok(())); mock.expect_create_stake().times(1).returning(|| 0); - Rc::new(rstd::cell::RefCell::new(mock)) + Rc::new(sp_std::cell::RefCell::new(mock)) } fn default_mock_for_unstaking() -> Rc>> { diff --git a/runtime-modules/hiring/src/test/public_api/on_finalize.rs b/runtime-modules/hiring/src/test/public_api/on_finalize.rs index 379fd42c09..8b0d4aadcc 100644 --- a/runtime-modules/hiring/src/test/public_api/on_finalize.rs +++ b/runtime-modules/hiring/src/test/public_api/on_finalize.rs @@ -1,7 +1,7 @@ use crate::mock::*; use crate::test::*; -use runtime_primitives::traits::{OnFinalize, OnInitialize}; +use frame_support::traits::{OnFinalize, OnInitialize}; // Recommendation from Parity on testing on_finalize // https://substrate.dev/docs/en/next/development/module/tests diff --git a/runtime-modules/hiring/src/test/public_api/unstaked.rs b/runtime-modules/hiring/src/test/public_api/unstaked.rs index e6f4343d08..8afddf85a9 100644 --- a/runtime-modules/hiring/src/test/public_api/unstaked.rs +++ b/runtime-modules/hiring/src/test/public_api/unstaked.rs @@ -62,7 +62,7 @@ impl UnstakedFixture { { let expected_application_stage = ApplicationStage::Inactive { deactivation_initiated, - deactivated: 1, + deactivated: FIRST_BLOCK_HEIGHT, cause, }; diff --git a/runtime-modules/hiring/src/test/smoke.rs b/runtime-modules/hiring/src/test/smoke.rs index 6ea087a94d..40d05ec229 100644 --- a/runtime-modules/hiring/src/test/smoke.rs +++ b/runtime-modules/hiring/src/test/smoke.rs @@ -1,9 +1,7 @@ use super::*; use crate::mock::*; -static FIRST_BLOCK_HEIGHT: ::BlockNumber = 1; - -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; /** Main hiring workflow: @@ -52,7 +50,7 @@ fn full_hiring_workflow_successful_path() { assert_eq!(Hiring::next_opening_id(), expected_opening_id + 1); // Check that our opening actually was added - assert!(>::exists(expected_opening_id)); + assert!(>::contains_key(expected_opening_id)); let found_opening = Hiring::opening_by_id(expected_opening_id); @@ -90,10 +88,10 @@ fn full_hiring_workflow_successful_path() { let destructured_app_data = ensure_can_add_application_result.unwrap(); let expected = DestructuredApplicationCanBeAddedEvaluation { opening: Opening { - created: 1, + created: FIRST_BLOCK_HEIGHT, stage: OpeningStage::Active { stage: ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, }, applications_added: BTreeSet::new(), active_application_count: 0, @@ -107,7 +105,7 @@ fn full_hiring_workflow_successful_path() { human_readable_text: human_readable_text.clone(), }, active_stage: ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, }, applications_added: BTreeSet::new(), active_application_count: 0, @@ -136,7 +134,7 @@ fn full_hiring_workflow_successful_path() { let new_application_id = app_added.application_id_added; // Check that our application actually was added - assert!(>::exists(new_application_id)); + assert!(>::contains_key(new_application_id)); let new_application = Hiring::application_by_id(new_application_id); @@ -146,7 +144,7 @@ fn full_hiring_workflow_successful_path() { Application { opening_id: 0, application_index_in_opening: 0, - add_to_opening_in_block: 1, + add_to_opening_in_block: FIRST_BLOCK_HEIGHT, active_role_staking_id: None, active_application_staking_id: None, stage: ApplicationStage::Active, @@ -169,11 +167,11 @@ fn full_hiring_workflow_successful_path() { assert_eq!( updated_opening_after_begin_review, Opening { - created: 1, + created: FIRST_BLOCK_HEIGHT, stage: OpeningStage::Active { stage: ActiveOpeningStage::ReviewPeriod { - started_accepting_applicants_at_block: 1, - started_review_period_at_block: 1 + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, + started_review_period_at_block: FIRST_BLOCK_HEIGHT }, applications_added: expected_added_apps_in_opening.clone(), active_application_count: 1, @@ -204,13 +202,13 @@ fn full_hiring_workflow_successful_path() { assert_eq!( updated_opening_fill_opening, Opening { - created: 1, + created: FIRST_BLOCK_HEIGHT, stage: OpeningStage::Active { stage: ActiveOpeningStage::Deactivated { cause: OpeningDeactivationCause::Filled, - deactivated_at_block: 1, - started_accepting_applicants_at_block: 1, - started_review_period_at_block: Some(1) + deactivated_at_block: FIRST_BLOCK_HEIGHT, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, + started_review_period_at_block: Some(FIRST_BLOCK_HEIGHT) }, applications_added: expected_added_apps_in_opening, active_application_count: 0, @@ -234,12 +232,12 @@ fn full_hiring_workflow_successful_path() { Application { opening_id: 0, application_index_in_opening: 0, - add_to_opening_in_block: 1, + add_to_opening_in_block: FIRST_BLOCK_HEIGHT, active_role_staking_id: None, active_application_staking_id: None, stage: ApplicationStage::Inactive { - deactivation_initiated: 1, - deactivated: 1, + deactivation_initiated: FIRST_BLOCK_HEIGHT, + deactivated: FIRST_BLOCK_HEIGHT, cause: ApplicationDeactivationCause::Hired }, human_readable_text: application_readable_text.clone() diff --git a/runtime-modules/hiring/src/test/staking_module/try_to_initiate_application_deactivation.rs b/runtime-modules/hiring/src/test/staking_module/try_to_initiate_application_deactivation.rs index c7069d3106..b2cfc96b1a 100644 --- a/runtime-modules/hiring/src/test/staking_module/try_to_initiate_application_deactivation.rs +++ b/runtime-modules/hiring/src/test/staking_module/try_to_initiate_application_deactivation.rs @@ -56,15 +56,15 @@ impl<'a> TryToInitiateApplicationDeactivationFixture<'a> { let expected_application_state = match result { ApplicationDeactivationInitiationResult::Deactivated => Application { stage: ApplicationStage::Inactive { - deactivation_initiated: 1, - deactivated: 1, + deactivation_initiated: FIRST_BLOCK_HEIGHT, + deactivated: FIRST_BLOCK_HEIGHT, cause: self.cause, }, ..old_application_state }, ApplicationDeactivationInitiationResult::Unstaking => Application { stage: ApplicationStage::Unstaking { - deactivation_initiated: 1, + deactivation_initiated: FIRST_BLOCK_HEIGHT, cause: self.cause, }, ..old_application_state @@ -84,7 +84,7 @@ impl<'a> TryToInitiateApplicationDeactivationFixture<'a> { // invalid opening stages are not supported // check for opening existence - if !>::exists(opening_id) { + if !>::contains_key(opening_id) { return; } @@ -118,7 +118,7 @@ impl<'a> TryToInitiateApplicationDeactivationFixture<'a> { let expected_opening = Opening { stage: OpeningStage::Active { stage: ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1, + started_accepting_applicants_at_block: FIRST_BLOCK_HEIGHT, }, applications_added, active_application_count: expected_active_application_count, diff --git a/runtime-modules/hiring/src/test/staking_module/would_application_get_added.rs b/runtime-modules/hiring/src/test/staking_module/would_application_get_added.rs index 85513c3625..c1122a8407 100644 --- a/runtime-modules/hiring/src/test/staking_module/would_application_get_added.rs +++ b/runtime-modules/hiring/src/test/staking_module/would_application_get_added.rs @@ -108,7 +108,7 @@ fn would_application_get_added_with_too_low_stake_with_mocks() { }), }); - Rc::new(rstd::cell::RefCell::new(mock)) + Rc::new(sp_std::cell::RefCell::new(mock)) }; set_stake_handler_impl(mock.clone()); diff --git a/runtime-modules/membership/Cargo.toml b/runtime-modules/membership/Cargo.toml index b67c46eef5..cd4974634a 100644 --- a/runtime-modules/membership/Cargo.toml +++ b/runtime-modules/membership/Cargo.toml @@ -1,83 +1,35 @@ [package] -name = 'substrate-membership-module' -version = '1.1.0' +name = 'pallet-membership' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +common = { package = 'pallet-common', default-features = false, path = '../common'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + [features] default = ['std'] std = [ - 'sr-primitives/std', - 'srml-support/std', - 'system/std', - 'rstd/std', - 'codec/std', 'serde', - 'timestamp/std', - 'primitives/std', + 'codec/std', + 'frame-support/std', + 'system/std', + 'sp-std/std', + 'sp-arithmetic/std', + 'sp-runtime/std', + 'pallet-timestamp/std', 'common/std', -] - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../common' - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.balances] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-balances' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' \ No newline at end of file +] \ No newline at end of file diff --git a/runtime-modules/membership/src/genesis.rs b/runtime-modules/membership/src/genesis.rs index b871777eb9..1856dbf8c5 100644 --- a/runtime-modules/membership/src/genesis.rs +++ b/runtime-modules/membership/src/genesis.rs @@ -1,7 +1,6 @@ #![cfg(test)] use common::currency::BalanceOf; -use rstd::prelude::*; use crate::{GenesisConfig, Trait}; diff --git a/runtime-modules/membership/src/lib.rs b/runtime-modules/membership/src/lib.rs index 5dc816f941..85f174379a 100644 --- a/runtime-modules/membership/src/lib.rs +++ b/runtime-modules/membership/src/lib.rs @@ -10,21 +10,27 @@ pub(crate) mod mock; mod tests; use codec::{Codec, Decode, Encode}; -use rstd::borrow::ToOwned; -use rstd::prelude::*; -use sr_primitives::traits::{MaybeSerialize, Member, One, SimpleArithmetic}; -use srml_support::traits::Currency; -use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, Parameter}; -use system::{self, ensure_root, ensure_signed}; +use frame_support::traits::Currency; +use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; +use sp_arithmetic::traits::{BaseArithmetic, One}; +use sp_runtime::traits::{MaybeSerialize, Member}; +use sp_std::borrow::ToOwned; +use sp_std::vec; +use sp_std::vec::Vec; +use system::{ensure_root, ensure_signed}; use common::currency::{BalanceOf, GovernanceCurrency}; -pub trait Trait: system::Trait + GovernanceCurrency + timestamp::Trait { +//TODO: Convert errors to the Substrate decl_error! macro. +/// Result with string error message. This exists for backward compatibility purpose. +pub type DispatchResult = Result<(), &'static str>; + +pub trait Trait: system::Trait + GovernanceCurrency + pallet_timestamp::Trait { type Event: From> + Into<::Event>; type MemberId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -33,7 +39,7 @@ pub trait Trait: system::Trait + GovernanceCurrency + timestamp::Trait { type PaidTermId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -42,7 +48,7 @@ pub trait Trait: system::Trait + GovernanceCurrency + timestamp::Trait { type SubscriptionId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -52,7 +58,7 @@ pub trait Trait: system::Trait + GovernanceCurrency + timestamp::Trait { /// Describes the common type for the working group members (workers). type ActorId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -61,10 +67,10 @@ pub trait Trait: system::Trait + GovernanceCurrency + timestamp::Trait { + Ord; } -const FIRST_PAID_TERMS_ID: u32 = 1; +const FIRST_PAID_TERMS_ID: u8 = 1; // Default paid membership terms -pub const DEFAULT_PAID_TERM_ID: u32 = 0; +pub const DEFAULT_PAID_TERM_ID: u8 = 0; // Default user info constraints const DEFAULT_MIN_HANDLE_LENGTH: u32 = 5; @@ -75,7 +81,7 @@ const DEFAULT_MAX_ABOUT_TEXT_LENGTH: u32 = 2048; /// Public membership object alias. pub type Membership = MembershipObject< ::BlockNumber, - ::Moment, + ::Moment, ::PaidTermId, ::SubscriptionId, ::AccountId, @@ -154,27 +160,32 @@ decl_storage! { trait Store for Module as Membership { /// MemberId to assign to next member that is added to the registry, and is also the /// total number of members created. MemberIds start at Zero. - pub NextMemberId get(members_created) : T::MemberId; + pub NextMemberId get(fn members_created) : T::MemberId; /// Mapping of member's id to their membership profile - pub MembershipById get(membership) : map T::MemberId => Membership; + pub MembershipById get(fn membership) : map hasher(blake2_128_concat) + T::MemberId => Membership; /// Mapping of a root account id to vector of member ids it controls. - pub(crate) MemberIdsByRootAccountId : map T::AccountId => Vec; + pub(crate) MemberIdsByRootAccountId : map hasher(blake2_128_concat) + T::AccountId => Vec; /// Mapping of a controller account id to vector of member ids it controls - pub(crate) MemberIdsByControllerAccountId : map T::AccountId => Vec; + pub(crate) MemberIdsByControllerAccountId : map hasher(blake2_128_concat) + T::AccountId => Vec; /// Registered unique handles and their mapping to their owner - pub MemberIdByHandle get(handles) : map Vec => T::MemberId; + pub MemberIdByHandle get(fn handles) : map hasher(blake2_128_concat) + Vec => T::MemberId; /// Next paid membership terms id - pub NextPaidMembershipTermsId get(next_paid_membership_terms_id) : T::PaidTermId = T::PaidTermId::from(FIRST_PAID_TERMS_ID); + pub NextPaidMembershipTermsId get(fn next_paid_membership_terms_id) : + T::PaidTermId = T::PaidTermId::from(FIRST_PAID_TERMS_ID); /// Paid membership terms record // Remember to add _genesis_phantom_data: std::marker::PhantomData{} to membership // genesis config if not providing config() or extra_genesis - pub PaidMembershipTermsById get(paid_membership_terms_by_id) build(|config: &GenesisConfig| { + pub PaidMembershipTermsById get(fn paid_membership_terms_by_id) build(|config: &GenesisConfig| { // This method only gets called when initializing storage, and is // compiled as native code. (Will be called when building `raw` chainspec) // So it can't be relied upon to initialize storage for runtimes updates. @@ -184,22 +195,23 @@ decl_storage! { text: Vec::default(), }; vec![(T::PaidTermId::from(DEFAULT_PAID_TERM_ID), terms)] - }) : map T::PaidTermId => PaidMembershipTerms>; + }) : map hasher(blake2_128_concat) T::PaidTermId => PaidMembershipTerms>; /// Active Paid membership terms - pub ActivePaidMembershipTerms get(active_paid_membership_terms) : Vec = vec![T::PaidTermId::from(DEFAULT_PAID_TERM_ID)]; + pub ActivePaidMembershipTerms get(fn active_paid_membership_terms) : + Vec = vec![T::PaidTermId::from(DEFAULT_PAID_TERM_ID)]; /// Is the platform is accepting new members or not - pub NewMembershipsAllowed get(new_memberships_allowed) : bool = true; + pub NewMembershipsAllowed get(fn new_memberships_allowed) : bool = true; - pub ScreeningAuthority get(screening_authority) : T::AccountId; + pub ScreeningAuthority get(fn screening_authority) : T::AccountId; // User Input Validation parameters - do these really need to be state variables // I don't see a need to adjust these in future? - pub MinHandleLength get(min_handle_length) : u32 = DEFAULT_MIN_HANDLE_LENGTH; - pub MaxHandleLength get(max_handle_length) : u32 = DEFAULT_MAX_HANDLE_LENGTH; - pub MaxAvatarUriLength get(max_avatar_uri_length) : u32 = DEFAULT_MAX_AVATAR_URI_LENGTH; - pub MaxAboutTextLength get(max_about_text_length) : u32 = DEFAULT_MAX_ABOUT_TEXT_LENGTH; + pub MinHandleLength get(fn min_handle_length) : u32 = DEFAULT_MIN_HANDLE_LENGTH; + pub MaxHandleLength get(fn max_handle_length) : u32 = DEFAULT_MAX_HANDLE_LENGTH; + pub MaxAvatarUriLength get(fn max_avatar_uri_length) : u32 = DEFAULT_MAX_AVATAR_URI_LENGTH; + pub MaxAboutTextLength get(fn max_about_text_length) : u32 = DEFAULT_MAX_ABOUT_TEXT_LENGTH; } add_extra_genesis { @@ -238,6 +250,7 @@ decl_module! { fn deposit_event() = default; /// Non-members can buy membership + #[weight = 10_000_000] // TODO: adjust weight pub fn buy_membership( origin, paid_terms_id: T::PaidTermId, @@ -268,6 +281,7 @@ decl_module! { } /// Change member's about text + #[weight = 10_000_000] // TODO: adjust weight pub fn change_member_about_text(origin, member_id: T::MemberId, text: Vec) { let sender = ensure_signed(origin)?; @@ -279,6 +293,7 @@ decl_module! { } /// Change member's avatar + #[weight = 10_000_000] // TODO: adjust weight pub fn change_member_avatar(origin, member_id: T::MemberId, uri: Vec) { let sender = ensure_signed(origin)?; @@ -291,6 +306,7 @@ decl_module! { /// Change member's handle. Will ensure new handle is unique and old one will be available /// for other members to use. + #[weight = 10_000_000] // TODO: adjust weight pub fn change_member_handle(origin, member_id: T::MemberId, handle: Vec) { let sender = ensure_signed(origin)?; @@ -302,6 +318,7 @@ decl_module! { } /// Update member's all or some of handle, avatar and about text. + #[weight = 10_000_000] // TODO: adjust weight pub fn update_membership( origin, member_id: T::MemberId, @@ -326,6 +343,7 @@ decl_module! { } } + #[weight = 10_000_000] // TODO: adjust weight pub fn set_controller_account(origin, member_id: T::MemberId, new_controller_account: T::AccountId) { let sender = ensure_signed(origin)?; @@ -349,6 +367,7 @@ decl_module! { } } + #[weight = 10_000_000] // TODO: adjust weight pub fn set_root_account(origin, member_id: T::MemberId, new_root_account: T::AccountId) { let sender = ensure_signed(origin)?; @@ -371,6 +390,7 @@ decl_module! { } } + #[weight = 10_000_000] // TODO: adjust weight pub fn add_screened_member( origin, new_member_account: T::AccountId, @@ -385,7 +405,7 @@ decl_module! { ensure!(sender == Self::screening_authority(), "not screener"); } else { // no screening authority defined. Cannot accept this request - return Err("no screening authority defined"); + return Err("no screening authority defined".into()); } // make sure we are accepting new memberships @@ -401,6 +421,7 @@ decl_module! { Self::deposit_event(RawEvent::MemberRegistered(member_id, new_member_account)); } + #[weight = 10_000_000] // TODO: adjust weight pub fn set_screening_authority(origin, authority: T::AccountId) { ensure_root(origin)?; >::put(authority); @@ -432,7 +453,7 @@ pub enum MemberRootAccountMismatch { impl Module { /// Provided that the member_id exists return its membership. Returns error otherwise. pub fn ensure_membership(id: T::MemberId) -> Result, &'static str> { - if >::exists(&id) { + if >::contains_key(&id) { Ok(Self::membership(&id)) } else { Err("member profile not found") @@ -444,7 +465,7 @@ impl Module { member_id: &T::MemberId, account: &T::AccountId, ) -> Result, ControllerAccountForMemberCheckFailed> { - if MembershipById::::exists(member_id) { + if MembershipById::::contains_key(member_id) { let membership = MembershipById::::get(member_id); if membership.controller_account == *account { @@ -459,8 +480,8 @@ impl Module { /// Returns true if account is either a member's root or controller account pub fn is_member_account(who: &T::AccountId) -> bool { - >::exists(who) - || >::exists(who) + >::contains_key(who) + || >::contains_key(who) } fn ensure_active_terms_id( @@ -472,7 +493,7 @@ impl Module { "paid terms id not active" ); - if >::exists(terms_id) { + if >::contains_key(terms_id) { Ok(Self::paid_membership_terms_by_id(terms_id)) } else { Err("paid membership term id does not exist") @@ -480,15 +501,15 @@ impl Module { } #[allow(clippy::ptr_arg)] // cannot change to the "&[u8]" suggested by clippy - fn ensure_unique_handle(handle: &Vec) -> dispatch::Result { + fn ensure_unique_handle(handle: &Vec) -> DispatchResult { ensure!( - !>::exists(handle), + !>::contains_key(handle), "handle already registered" ); Ok(()) } - fn validate_handle(handle: &[u8]) -> dispatch::Result { + fn validate_handle(handle: &[u8]) -> DispatchResult { ensure!( handle.len() >= Self::min_handle_length() as usize, "handle too short" @@ -506,7 +527,7 @@ impl Module { text } - fn validate_avatar(uri: &[u8]) -> dispatch::Result { + fn validate_avatar(uri: &[u8]) -> DispatchResult { ensure!( uri.len() <= Self::max_avatar_uri_length() as usize, "avatar uri too long" @@ -547,7 +568,7 @@ impl Module { avatar_uri: user_info.avatar_uri.clone(), about: user_info.about.clone(), registered_at_block: >::block_number(), - registered_at_time: >::now(), + registered_at_time: >::now(), entry: entry_method, suspended: false, subscription: None, @@ -569,7 +590,7 @@ impl Module { new_member_id } - fn _change_member_about_text(id: T::MemberId, text: &[u8]) -> dispatch::Result { + fn _change_member_about_text(id: T::MemberId, text: &[u8]) -> DispatchResult { let mut membership = Self::ensure_membership(id)?; let text = Self::validate_text(text); membership.about = text; @@ -578,7 +599,7 @@ impl Module { Ok(()) } - fn _change_member_avatar(id: T::MemberId, uri: &[u8]) -> dispatch::Result { + fn _change_member_avatar(id: T::MemberId, uri: &[u8]) -> DispatchResult { let mut membership = Self::ensure_membership(id)?; Self::validate_avatar(uri)?; membership.avatar_uri = uri.to_owned(); @@ -587,7 +608,7 @@ impl Module { Ok(()) } - fn _change_member_handle(id: T::MemberId, handle: Vec) -> dispatch::Result { + fn _change_member_handle(id: T::MemberId, handle: Vec) -> DispatchResult { let mut membership = Self::ensure_membership(id)?; Self::validate_handle(&handle)?; Self::ensure_unique_handle(&handle)?; diff --git a/runtime-modules/membership/src/mock.rs b/runtime-modules/membership/src/mock.rs index b6a0186f58..d121d1797e 100644 --- a/runtime-modules/membership/src/mock.rs +++ b/runtime-modules/membership/src/mock.rs @@ -1,19 +1,18 @@ #![cfg(test)] pub use crate::{GenesisConfig, Trait, DEFAULT_PAID_TERM_ID}; -pub use common::currency::GovernanceCurrency; -pub use srml_support::traits::Currency; -pub use system; -pub use primitives::{Blake2Hasher, H256}; -pub use sr_primitives::{ - testing::{Digest, DigestItem, Header, UintAuthorityId}, - traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, - weights::Weight, - BuildStorage, Perbill, +pub use frame_support::traits::Currency; +use frame_support::{impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, }; +pub use system; -use srml_support::{impl_outer_origin, parameter_types}; +pub use common::currency::GovernanceCurrency; impl_outer_origin! { pub enum Origin for Test {} @@ -31,10 +30,11 @@ parameter_types! { } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -43,12 +43,20 @@ impl system::Trait for Test { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -56,27 +64,14 @@ impl timestamp::Trait for Test { 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; } 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 Event = (); type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl GovernanceCurrency for Test { @@ -106,17 +101,11 @@ impl Default for TestExternalitiesBuilder { } impl TestExternalitiesBuilder { - /* - pub fn set_system_config(mut self, system_config: system::GenesisConfig) -> Self { - self.system_config = Some(system_config); - self - } - */ pub fn set_membership_config(mut self, membership_config: GenesisConfig) -> Self { self.membership_config = Some(membership_config); self } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { // Add system let mut t = self .system_config @@ -136,3 +125,4 @@ impl TestExternalitiesBuilder { pub type Balances = balances::Module; pub type Members = crate::Module; +pub type System = system::Module; diff --git a/runtime-modules/membership/src/tests.rs b/runtime-modules/membership/src/tests.rs index 5252fd60ce..1809612c22 100644 --- a/runtime-modules/membership/src/tests.rs +++ b/runtime-modules/membership/src/tests.rs @@ -3,10 +3,10 @@ use super::genesis; use super::mock::*; -use srml_support::*; +use frame_support::*; fn get_membership_by_id(member_id: u32) -> crate::Membership { - if >::exists(member_id) { + if >::contains_key(member_id) { Members::membership(member_id) } else { panic!("member profile not created"); @@ -52,15 +52,16 @@ fn get_bob_info() -> TestUserInfo { const ALICE_ACCOUNT_ID: u64 = 1; -fn buy_default_membership_as_alice() -> dispatch::Result { +fn buy_default_membership_as_alice() -> crate::DispatchResult { let info = get_alice_info(); Members::buy_membership( Origin::signed(ALICE_ACCOUNT_ID), - DEFAULT_PAID_TERM_ID, + DEFAULT_PAID_TERM_ID as u32, info.handle, info.avatar_uri, info.about, ) + .map_err(|err| err.into()) } fn set_alice_free_balance(balance: u64) { @@ -81,12 +82,13 @@ fn initial_state() { ) .build() .execute_with(|| { - let default_terms = - if >::exists(DEFAULT_PAID_TERM_ID) { - Members::paid_membership_terms_by_id(DEFAULT_PAID_TERM_ID) - } else { - panic!("default terms not initialized"); - }; + let default_terms = if >::contains_key( + DEFAULT_PAID_TERM_ID as u32, + ) { + Members::paid_membership_terms_by_id(DEFAULT_PAID_TERM_ID as u32) + } else { + panic!("default terms not initialized"); + }; assert_eq!(default_terms.fee, DEFAULT_FEE); }); diff --git a/runtime-modules/memo/Cargo.toml b/runtime-modules/memo/Cargo.toml index 1ec371433a..2793a6331f 100644 --- a/runtime-modules/memo/Cargo.toml +++ b/runtime-modules/memo/Cargo.toml @@ -1,58 +1,24 @@ [package] -name = 'substrate-memo-module' -version = '1.0.0' +name = 'pallet-memo' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +common = { package = 'pallet-common', default-features = false, path = '../common'} [features] default = ['std'] std = [ - 'sr-primitives/std', - 'srml-support/std', - 'system/std', - 'rstd/std', 'codec/std', - 'serde', + 'sp-arithmetic/std', + 'sp-std/std', + 'frame-support/std', + 'system/std', 'common/std', -] - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../common' \ No newline at end of file +] \ No newline at end of file diff --git a/runtime-modules/memo/src/lib.rs b/runtime-modules/memo/src/lib.rs index 7c3b876ffa..4796472253 100644 --- a/runtime-modules/memo/src/lib.rs +++ b/runtime-modules/memo/src/lib.rs @@ -1,13 +1,13 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use common::currency::GovernanceCurrency; -use rstd::prelude::*; -use sr_primitives::traits::Zero; -use srml_support::traits::Currency; -use srml_support::{decl_event, decl_module, decl_storage, ensure}; +use frame_support::traits::Currency; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use sp_arithmetic::traits::Zero; +use sp_std::vec::Vec; +use system::ensure_signed; -use system::{self, ensure_signed}; +use common::currency::GovernanceCurrency; pub trait Trait: system::Trait + GovernanceCurrency { type Event: From> + Into<::Event>; @@ -17,8 +17,8 @@ pub type MemoText = Vec; decl_storage! { trait Store for Module as Memo { - Memo get(memo) : map T::AccountId => MemoText; - MaxMemoLength get(max_memo_length) : u32 = 4096; + Memo get(fn memo) : map hasher(blake2_128_concat) T::AccountId => MemoText; + MaxMemoLength get(fn max_memo_length) : u32 = 4096; } } @@ -32,6 +32,7 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; + #[weight = 10_000_000] // TODO: adjust weight fn update_memo(origin, memo: MemoText) { let sender = ensure_signed(origin)?; diff --git a/runtime-modules/proposals/codex/Cargo.toml b/runtime-modules/proposals/codex/Cargo.toml index 3e21b4a616..d921ac5136 100644 --- a/runtime-modules/proposals/codex/Cargo.toml +++ b/runtime-modules/proposals/codex/Cargo.toml @@ -1,185 +1,61 @@ [package] -name = 'substrate-proposals-codex-module' -version = '2.1.0' +name = 'pallet-proposals-codex' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +staking = { package = 'pallet-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +membership = { package = 'pallet-membership', default-features = false, path = '../../membership'} +stake = { package = 'pallet-stake', default-features = false, path = '../../stake'} +governance = { package = 'pallet-governance', default-features = false, path = '../../governance'} +hiring = { package = 'pallet-hiring', default-features = false, path = '../../hiring'} +minting = { package = 'pallet-token-mint', default-features = false, path = '../../token-minting'} +working-group = { package = 'pallet-working-group', default-features = false, path = '../../working-group'} +content-working-group = { package = 'pallet-content-working-group', default-features = false, path = '../../content-working-group'} +common = { package = 'pallet-common', default-features = false, path = '../../common'} +proposals-engine = { package = 'pallet-proposals-engine', default-features = false, path = '../engine'} +proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../discussion'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-staking = { package = 'sp-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +recurring-rewards = { package = 'pallet-recurring-reward', default-features = false, path = '../../recurring-reward'} +versioned-store = { package = 'pallet-versioned-store', default-features = false, path = '../../versioned-store'} +versioned-store-permissions = { package = 'pallet-versioned-store-permissions', default-features = false, path = '../../versioned-store-permissions'} + [features] default = ['std'] -no_std = [] std = [ + 'serde', 'codec/std', - 'rstd/std', - 'srml-support/std', - 'primitives/std', - 'sr-primitives/std', + 'sp-std/std', + 'frame-support/std', + 'sp-arithmetic/std', + 'sp-runtime/std', 'system/std', - 'timestamp/std', 'staking/std', - 'serde', - 'proposal_engine/std', - 'proposal_discussion/std', - 'stake/std', + 'pallet-timestamp/std', 'balances/std', 'membership/std', + 'stake/std', 'governance/std', - 'mint/std', - 'common/std', - 'content_working_group/std', - 'working_group/std', 'hiring/std', -] - - -[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 = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.balances] -package = 'srml-balances' -default-features = false -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.staking] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-staking' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.stake] -default_features = false -package = 'substrate-stake-module' -path = '../../stake' - -[dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../../membership' - -[dependencies.governance] -default_features = false -package = 'substrate-governance-module' -path = '../../governance' - -[dependencies.mint] -default_features = false -package = 'substrate-token-mint-module' -path = '../../token-minting' - -[dependencies.proposal_engine] -default_features = false -package = 'substrate-proposals-engine-module' -path = '../engine' - -[dependencies.proposal_discussion] -default_features = false -package = 'substrate-proposals-discussion-module' -path = '../discussion' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../../common' - -[dependencies.content_working_group] -default_features = false -package = 'substrate-content-working-group-module' -path = '../../content-working-group' - -[dependencies.working_group] -default_features = false -package = 'substrate-working-group-module' -path = '../../working-group' - -[dependencies.hiring] -default_features = false -package = 'substrate-hiring-module' -path = '../../hiring' - -[dev-dependencies.versioned_store] -default_features = false -package ='substrate-versioned-store' -path = '../../versioned-store' - -[dependencies.versioned_store] -default_features = false -package ='substrate-versioned-store' -path = '../../versioned-store' - -[dev-dependencies.versioned_store_permissions] -default_features = false -package = 'substrate-versioned-store-permissions-module' -path = '../../versioned-store-permissions' - -[dev-dependencies.recurring_rewards] -default_features = false -package = 'substrate-recurring-reward-module' -path = '../../recurring-reward' - -[dev-dependencies.sr-staking-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-staking-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -# don't rename the dependency it is causing some strange compiler error: -# https://github.com/rust-lang/rust/issues/64450 -[dev-dependencies.srml-staking-reward-curve] -package = 'srml-staking-reward-curve' -git = 'https://github.com/paritytech/substrate.git' -default_features = false -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' \ No newline at end of file + 'minting/std', + 'content-working-group/std', + 'working-group/std', + 'common/std', + 'proposals-engine/std', + 'proposals-discussion/std', +] \ No newline at end of file diff --git a/runtime-modules/proposals/codex/src/lib.rs b/runtime-modules/proposals/codex/src/lib.rs index c957673149..7ecd7289d7 100644 --- a/runtime-modules/proposals/codex/src/lib.rs +++ b/runtime-modules/proposals/codex/src/lib.rs @@ -65,19 +65,19 @@ mod proposal_types; #[cfg(test)] mod tests; +use frame_support::dispatch::DispatchResult; +use frame_support::traits::{Currency, Get}; +use frame_support::{decl_error, decl_module, decl_storage, ensure, print}; +use sp_arithmetic::traits::Zero; +use sp_std::clone::Clone; +use sp_std::str::from_utf8; +use sp_std::vec::Vec; +use system::ensure_root; + use common::origin::ActorOriginValidator; use common::working_group::WorkingGroup; use governance::election_params::ElectionParameters; -use proposal_engine::ProposalParameters; -use rstd::clone::Clone; -use rstd::prelude::*; -use rstd::str::from_utf8; -use rstd::vec::Vec; -use sr_primitives::traits::Zero; -use srml_support::dispatch::DispatchResult; -use srml_support::traits::{Currency, Get}; -use srml_support::{decl_error, decl_module, decl_storage, ensure, print}; -use system::ensure_root; +use proposals_engine::ProposalParameters; pub use crate::proposal_types::{ AddOpeningParameters, FillOpeningParameters, ProposalsConfigParameters, TerminateRoleParameters, @@ -141,8 +141,8 @@ struct CreateProposalParameters { /// 'Proposals codex' substrate module Trait pub trait Trait: system::Trait - + proposal_engine::Trait - + proposal_discussion::Trait + + proposals_engine::Trait + + proposals_discussion::Trait + membership::Trait + governance::election::Trait + content_working_group::Trait @@ -180,7 +180,7 @@ pub type BalanceOfGovernanceCurrency = /// Balance alias for token mint balance from `token mint` module. TODO: replace with BalanceOf pub type BalanceOfMint = - <::Currency as Currency<::AccountId>>::Balance; + <::Currency as Currency<::AccountId>>::Balance; /// Negative imbalance alias for staking pub type NegativeImbalance = @@ -190,7 +190,7 @@ type MemberId = ::MemberId; decl_error! { /// Codex module predefined errors - pub enum Error { + pub enum Error for Module { /// The size of the provided text for text proposal exceeded the limit TextProposalSizeExceeded, @@ -253,155 +253,125 @@ decl_error! { } } -impl From for Error { - fn from(error: system::Error) -> Self { - match error { - system::Error::Other(msg) => Error::Other(msg), - system::Error::RequireRootOrigin => Error::RequireRootOrigin, - _ => Error::Other(error.into()), - } - } -} - -impl From for Error { - fn from(error: proposal_engine::Error) -> Self { - match error { - proposal_engine::Error::Other(msg) => Error::Other(msg), - proposal_engine::Error::RequireRootOrigin => Error::RequireRootOrigin, - _ => Error::Other(error.into()), - } - } -} - -impl From for Error { - fn from(error: proposal_discussion::Error) -> Self { - match error { - proposal_discussion::Error::Other(msg) => Error::Other(msg), - proposal_discussion::Error::RequireRootOrigin => Error::RequireRootOrigin, - _ => Error::Other(error.into()), - } - } -} - // Storage for the proposals codex module decl_storage! { pub trait Store for Module as ProposalCodex{ /// Map proposal id to its discussion thread id pub ThreadIdByProposalId get(fn thread_id_by_proposal_id): - map T::ProposalId => T::ThreadId; + map hasher(blake2_128_concat) T::ProposalId => T::ThreadId; /// Map proposal id to proposal details pub ProposalDetailsByProposalId get(fn proposal_details_by_proposal_id): - map T::ProposalId => ProposalDetailsOf; + map hasher(blake2_128_concat) T::ProposalId => ProposalDetailsOf; /// Voting period for the 'set validator count' proposal - pub SetValidatorCountProposalVotingPeriod get(set_validator_count_proposal_voting_period) + pub SetValidatorCountProposalVotingPeriod get(fn set_validator_count_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'set validator count' proposal - pub SetValidatorCountProposalGracePeriod get(set_validator_count_proposal_grace_period) + pub SetValidatorCountProposalGracePeriod get(fn set_validator_count_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'runtime upgrade' proposal - pub RuntimeUpgradeProposalVotingPeriod get(runtime_upgrade_proposal_voting_period) + pub RuntimeUpgradeProposalVotingPeriod get(fn runtime_upgrade_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'runtime upgrade' proposal - pub RuntimeUpgradeProposalGracePeriod get(runtime_upgrade_proposal_grace_period) + pub RuntimeUpgradeProposalGracePeriod get(fn runtime_upgrade_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'set election parameters' proposal - pub SetElectionParametersProposalVotingPeriod get(set_election_parameters_proposal_voting_period) + pub SetElectionParametersProposalVotingPeriod get(fn set_election_parameters_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'set election parameters' proposal - pub SetElectionParametersProposalGracePeriod get(set_election_parameters_proposal_grace_period) + pub SetElectionParametersProposalGracePeriod get(fn set_election_parameters_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'text' proposal - pub TextProposalVotingPeriod get(text_proposal_voting_period) config(): T::BlockNumber; + pub TextProposalVotingPeriod get(fn text_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'text' proposal - pub TextProposalGracePeriod get(text_proposal_grace_period) config(): T::BlockNumber; + pub TextProposalGracePeriod get(fn text_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'set content working group mint capacity' proposal - pub SetContentWorkingGroupMintCapacityProposalVotingPeriod get(set_content_working_group_mint_capacity_proposal_voting_period) + pub SetContentWorkingGroupMintCapacityProposalVotingPeriod get(fn set_content_working_group_mint_capacity_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'set content working group mint capacity' proposal - pub SetContentWorkingGroupMintCapacityProposalGracePeriod get(set_content_working_group_mint_capacity_proposal_grace_period) + pub SetContentWorkingGroupMintCapacityProposalGracePeriod get(fn set_content_working_group_mint_capacity_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'set lead' proposal - pub SetLeadProposalVotingPeriod get(set_lead_proposal_voting_period) + pub SetLeadProposalVotingPeriod get(fn set_lead_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'set lead' proposal - pub SetLeadProposalGracePeriod get(set_lead_proposal_grace_period) + pub SetLeadProposalGracePeriod get(fn set_lead_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'spending' proposal - pub SpendingProposalVotingPeriod get(spending_proposal_voting_period) config(): T::BlockNumber; + pub SpendingProposalVotingPeriod get(fn spending_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'spending' proposal - pub SpendingProposalGracePeriod get(spending_proposal_grace_period) config(): T::BlockNumber; + pub SpendingProposalGracePeriod get(fn spending_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'add working group opening' proposal - pub AddWorkingGroupOpeningProposalVotingPeriod get(add_working_group_opening_proposal_voting_period) config(): T::BlockNumber; + pub AddWorkingGroupOpeningProposalVotingPeriod get(fn add_working_group_opening_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'add working group opening' proposal - pub AddWorkingGroupOpeningProposalGracePeriod get(add_working_group_opening_proposal_grace_period) config(): T::BlockNumber; + pub AddWorkingGroupOpeningProposalGracePeriod get(fn add_working_group_opening_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'begin review working group leader applications' proposal - pub BeginReviewWorkingGroupLeaderApplicationsProposalVotingPeriod get(begin_review_working_group_leader_applications_proposal_voting_period) config(): T::BlockNumber; + pub BeginReviewWorkingGroupLeaderApplicationsProposalVotingPeriod get(fn begin_review_working_group_leader_applications_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'begin review working group leader applications' proposal - pub BeginReviewWorkingGroupLeaderApplicationsProposalGracePeriod get(begin_review_working_group_leader_applications_proposal_grace_period) config(): T::BlockNumber; + pub BeginReviewWorkingGroupLeaderApplicationsProposalGracePeriod get(fn begin_review_working_group_leader_applications_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'fill working group leader opening' proposal - pub FillWorkingGroupLeaderOpeningProposalVotingPeriod get(fill_working_group_leader_opening_proposal_voting_period) config(): T::BlockNumber; + pub FillWorkingGroupLeaderOpeningProposalVotingPeriod get(fn fill_working_group_leader_opening_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'fill working group leader opening' proposal - pub FillWorkingGroupLeaderOpeningProposalGracePeriod get(fill_working_group_leader_opening_proposal_grace_period) config(): T::BlockNumber; + pub FillWorkingGroupLeaderOpeningProposalGracePeriod get(fn fill_working_group_leader_opening_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'set working group mint capacity' proposal - pub SetWorkingGroupMintCapacityProposalVotingPeriod get(set_working_group_mint_capacity_proposal_voting_period) + pub SetWorkingGroupMintCapacityProposalVotingPeriod get(fn set_working_group_mint_capacity_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'set working group mint capacity' proposal - pub SetWorkingGroupMintCapacityProposalGracePeriod get(set_working_group_mint_capacity_proposal_grace_period) + pub SetWorkingGroupMintCapacityProposalGracePeriod get(fn set_working_group_mint_capacity_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'decrease working group leader stake' proposal - pub DecreaseWorkingGroupLeaderStakeProposalVotingPeriod get(decrease_working_group_leader_stake_proposal_voting_period) + pub DecreaseWorkingGroupLeaderStakeProposalVotingPeriod get(fn decrease_working_group_leader_stake_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'decrease working group leader stake' proposal - pub DecreaseWorkingGroupLeaderStakeProposalGracePeriod get(decrease_working_group_leader_stake_proposal_grace_period) + pub DecreaseWorkingGroupLeaderStakeProposalGracePeriod get(fn decrease_working_group_leader_stake_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'slash working group leader stake' proposal - pub SlashWorkingGroupLeaderStakeProposalVotingPeriod get(slash_working_group_leader_stake_proposal_voting_period) + pub SlashWorkingGroupLeaderStakeProposalVotingPeriod get(fn slash_working_group_leader_stake_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'slash working group leader stake' proposal - pub SlashWorkingGroupLeaderStakeProposalGracePeriod get(slash_working_group_leader_stake_proposal_grace_period) + pub SlashWorkingGroupLeaderStakeProposalGracePeriod get(fn slash_working_group_leader_stake_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'set working group leader reward' proposal - pub SetWorkingGroupLeaderRewardProposalVotingPeriod get(set_working_group_leader_reward_proposal_voting_period) + pub SetWorkingGroupLeaderRewardProposalVotingPeriod get(fn set_working_group_leader_reward_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'set working group leader reward' proposal - pub SetWorkingGroupLeaderRewardProposalGracePeriod get(set_working_group_leader_reward_proposal_grace_period) + pub SetWorkingGroupLeaderRewardProposalGracePeriod get(fn set_working_group_leader_reward_proposal_grace_period) config(): T::BlockNumber; /// Voting period for the 'terminate working group leader role' proposal - pub TerminateWorkingGroupLeaderRoleProposalVotingPeriod get(terminate_working_group_leader_role_proposal_voting_period) + pub TerminateWorkingGroupLeaderRoleProposalVotingPeriod get(fn terminate_working_group_leader_role_proposal_voting_period) config(): T::BlockNumber; /// Grace period for the 'terminate working group leader role' proposal - pub TerminateWorkingGroupLeaderRoleProposalGracePeriod get(terminate_working_group_leader_role_proposal_grace_period) + pub TerminateWorkingGroupLeaderRoleProposalGracePeriod get(fn terminate_working_group_leader_role_proposal_grace_period) config(): T::BlockNumber; } } @@ -410,7 +380,7 @@ decl_module! { /// Proposal codex substrate module Call pub struct Module for enum Call where origin: T::Origin { /// Predefined errors - type Error = Error; + type Error = Error; /// Exports max allowed text proposal length const. const TextProposalMaxLength: u32 = T::TextProposalMaxLength::get(); @@ -419,6 +389,7 @@ decl_module! { const RuntimeUpgradeWasmProposalMaxLength: u32 = T::RuntimeUpgradeWasmProposalMaxLength::get(); /// Create 'Text (signal)' proposal type. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_text_proposal( origin, member_id: MemberId, @@ -427,9 +398,9 @@ decl_module! { stake_balance: Option>, text: Vec, ) { - ensure!(!text.is_empty(), Error::TextProposalIsEmpty); + ensure!(!text.is_empty(), Error::::TextProposalIsEmpty); ensure!(text.len() as u32 <= T::TextProposalMaxLength::get(), - Error::TextProposalSizeExceeded); + Error::::TextProposalSizeExceeded); let proposal_details = ProposalDetails::Text(text); let params = CreateProposalParameters{ @@ -448,6 +419,7 @@ decl_module! { /// Create 'Runtime upgrade' proposal type. Runtime upgrade can be initiated only by /// members from the hardcoded list `RuntimeUpgradeProposalAllowedProposers` + #[weight = 10_000_000] // TODO: adjust weight pub fn create_runtime_upgrade_proposal( origin, member_id: MemberId, @@ -456,9 +428,9 @@ decl_module! { stake_balance: Option>, wasm: Vec, ) { - ensure!(!wasm.is_empty(), Error::RuntimeProposalIsEmpty); + ensure!(!wasm.is_empty(), Error::::RuntimeProposalIsEmpty); ensure!(wasm.len() as u32 <= T::RuntimeUpgradeWasmProposalMaxLength::get(), - Error::RuntimeProposalSizeExceeded); + Error::::RuntimeProposalSizeExceeded); let proposal_details = ProposalDetails::RuntimeUpgrade(wasm); let params = CreateProposalParameters{ @@ -477,6 +449,7 @@ decl_module! { /// Create 'Set election parameters' proposal type. This proposal uses `set_election_parameters()` /// extrinsic from the `governance::election module`. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_set_election_parameters_proposal( origin, member_id: MemberId, @@ -506,6 +479,7 @@ decl_module! { /// Create 'Set content working group mint capacity' proposal type. /// This proposal uses `set_mint_capacity()` extrinsic from the `content-working-group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_set_content_working_group_mint_capacity_proposal( origin, member_id: MemberId, @@ -516,7 +490,7 @@ decl_module! { ) { ensure!( mint_balance <= >::from(CONTENT_WORKING_GROUP_MINT_CAPACITY_MAX_VALUE), - Error::InvalidContentWorkingGroupMintCapacity + Error::::InvalidContentWorkingGroupMintCapacity ); let proposal_details = ProposalDetails::SetContentWorkingGroupMintCapacity(mint_balance); @@ -536,6 +510,7 @@ decl_module! { /// Create 'Spending' proposal type. /// This proposal uses `spend_from_council_mint()` extrinsic from the `governance::council` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_spending_proposal( origin, member_id: MemberId, @@ -545,10 +520,10 @@ decl_module! { balance: BalanceOfMint, destination: T::AccountId, ) { - ensure!(balance != BalanceOfMint::::zero(), Error::InvalidSpendingProposalBalance); + ensure!(balance != BalanceOfMint::::zero(), Error::::InvalidSpendingProposalBalance); ensure!( balance <= >::from(MAX_SPENDING_PROPOSAL_VALUE), - Error::InvalidSpendingProposalBalance + Error::::InvalidSpendingProposalBalance ); let proposal_details = ProposalDetails::Spending(balance, destination); @@ -568,6 +543,7 @@ decl_module! { /// Create 'Set lead' proposal type. /// This proposal uses `replace_lead()` extrinsic from the `content_working_group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_set_lead_proposal( origin, member_id: MemberId, @@ -580,7 +556,7 @@ decl_module! { let account_id = lead.1; ensure!( !>::is_councilor(&account_id), - Error::InvalidSetLeadParameterCannotBeCouncilor + Error::::InvalidSetLeadParameterCannotBeCouncilor ); } let proposal_details = ProposalDetails::SetLead(new_lead); @@ -600,6 +576,7 @@ decl_module! { /// Create 'Evict storage provider' proposal type. /// This proposal uses `set_validator_count()` extrinsic from the Substrate `staking` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_set_validator_count_proposal( origin, member_id: MemberId, @@ -610,12 +587,12 @@ decl_module! { ) { ensure!( new_validator_count >= >::minimum_validator_count(), - Error::InvalidValidatorCount + Error::::InvalidValidatorCount ); ensure!( new_validator_count <= MAX_VALIDATOR_COUNT, - Error::InvalidValidatorCount + Error::::InvalidValidatorCount ); let proposal_details = ProposalDetails::SetValidatorCount(new_validator_count); @@ -635,6 +612,7 @@ decl_module! { /// Create 'Add working group leader opening' proposal type. /// This proposal uses `add_opening()` extrinsic from the Joystream `working group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_add_working_group_leader_opening_proposal( origin, member_id: MemberId, @@ -661,6 +639,7 @@ decl_module! { /// Create 'Begin review working group leader applications' proposal type. /// This proposal uses `begin_applicant_review()` extrinsic from the Joystream `working group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_begin_review_working_group_leader_applications_proposal( origin, member_id: MemberId, @@ -688,6 +667,7 @@ decl_module! { /// Create 'Fill working group leader opening' proposal type. /// This proposal uses `fill_opening()` extrinsic from the Joystream `working group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_fill_working_group_leader_opening_proposal( origin, member_id: MemberId, @@ -719,6 +699,7 @@ decl_module! { /// Create 'Set working group mint capacity' proposal type. /// This proposal uses `set_mint_capacity()` extrinsic from the `working-group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_set_working_group_mint_capacity_proposal( origin, member_id: MemberId, @@ -730,7 +711,7 @@ decl_module! { ) { ensure!( mint_balance <= >::from(WORKING_GROUP_MINT_CAPACITY_MAX_VALUE), - Error::InvalidWorkingGroupMintCapacity + Error::::InvalidWorkingGroupMintCapacity ); let proposal_details = ProposalDetails::SetWorkingGroupMintCapacity(mint_balance, working_group); @@ -750,6 +731,7 @@ decl_module! { /// Create 'decrease working group leader stake' proposal type. /// This proposal uses `decrease_stake()` extrinsic from the `working-group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_decrease_working_group_leader_stake_proposal( origin, member_id: MemberId, @@ -761,7 +743,7 @@ decl_module! { working_group: WorkingGroup, ) { - ensure!(decreasing_stake != Zero::zero(), Error::DecreasingStakeIsZero); + ensure!(decreasing_stake != Zero::zero(), Error::::DecreasingStakeIsZero); let proposal_details = ProposalDetails::DecreaseWorkingGroupLeaderStake( worker_id, @@ -785,6 +767,7 @@ decl_module! { /// Create 'slash working group leader stake' proposal type. /// This proposal uses `slash_stake()` extrinsic from the `working-group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_slash_working_group_leader_stake_proposal( origin, member_id: MemberId, @@ -796,7 +779,7 @@ decl_module! { working_group: WorkingGroup, ) { - ensure!(slashing_stake != Zero::zero(), Error::SlashingStakeIsZero); + ensure!(slashing_stake != Zero::zero(), Error::::SlashingStakeIsZero); let proposal_details = ProposalDetails::SlashWorkingGroupLeaderStake( worker_id, @@ -820,6 +803,7 @@ decl_module! { /// Create 'set working group leader reward' proposal type. /// This proposal uses `update_reward_amount()` extrinsic from the `working-group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_set_working_group_leader_reward_proposal( origin, member_id: MemberId, @@ -853,6 +837,7 @@ decl_module! { /// Create 'terminate working group leader rolw' proposal type. /// This proposal uses `terminate_role()` extrinsic from the `working-group` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_terminate_working_group_leader_role_proposal( origin, member_id: MemberId, @@ -881,6 +866,7 @@ decl_module! { // *************** Extrinsic to execute /// Text proposal extrinsic. Should be used as callable object to pass to the `engine` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn execute_text_proposal( origin, text: Vec, @@ -895,6 +881,7 @@ decl_module! { /// Runtime upgrade proposal extrinsic. /// Should be used as callable object to pass to the `engine` module. + #[weight = 10_000_000] // TODO: adjust weight pub fn execute_runtime_upgrade_proposal( origin, wasm: Vec, @@ -913,28 +900,28 @@ decl_module! { impl Module { // Generic template proposal builder - fn create_proposal(params: CreateProposalParameters) -> DispatchResult { + fn create_proposal(params: CreateProposalParameters) -> DispatchResult { let account_id = T::MembershipOriginValidator::ensure_actor_origin(params.origin, params.member_id)?; - >::ensure_create_proposal_parameters_are_valid( + >::ensure_create_proposal_parameters_are_valid( ¶ms.proposal_parameters, ¶ms.title, ¶ms.description, params.stake_balance, )?; - >::ensure_can_create_thread( + >::ensure_can_create_thread( params.member_id, ¶ms.title, )?; - let discussion_thread_id = >::create_thread( + let discussion_thread_id = >::create_thread( params.member_id, params.title.clone(), )?; - let proposal_id = >::create_proposal( + let proposal_id = >::create_proposal( account_id, params.member_id, params.proposal_parameters, @@ -953,85 +940,85 @@ impl Module { // validates council election parameters for the 'Set election parameters' proposal pub(crate) fn ensure_council_election_parameters_valid( election_parameters: &ElectionParameters, T::BlockNumber>, - ) -> Result<(), Error> { + ) -> DispatchResult { ensure!( election_parameters.council_size >= ELECTION_PARAMETERS_COUNCIL_SIZE_MIN_VALUE, - Error::InvalidCouncilElectionParameterCouncilSize + Error::::InvalidCouncilElectionParameterCouncilSize ); ensure!( election_parameters.council_size <= ELECTION_PARAMETERS_COUNCIL_SIZE_MAX_VALUE, - Error::InvalidCouncilElectionParameterCouncilSize + Error::::InvalidCouncilElectionParameterCouncilSize ); ensure!( election_parameters.candidacy_limit >= ELECTION_PARAMETERS_CANDIDACY_LIMIT_MIN_VALUE, - Error::InvalidCouncilElectionParameterCandidacyLimit + Error::::InvalidCouncilElectionParameterCandidacyLimit ); ensure!( election_parameters.candidacy_limit <= ELECTION_PARAMETERS_CANDIDACY_LIMIT_MAX_VALUE, - Error::InvalidCouncilElectionParameterCandidacyLimit + Error::::InvalidCouncilElectionParameterCandidacyLimit ); ensure!( election_parameters.min_voting_stake >= >::from(ELECTION_PARAMETERS_MIN_STAKE_MIN_VALUE), - Error::InvalidCouncilElectionParameterMinVotingStake + Error::::InvalidCouncilElectionParameterMinVotingStake ); ensure!( election_parameters.min_voting_stake <= >::from(ELECTION_PARAMETERS_MIN_STAKE_MAX_VALUE), - Error::InvalidCouncilElectionParameterMinVotingStake + Error::::InvalidCouncilElectionParameterMinVotingStake ); ensure!( election_parameters.new_term_duration >= T::BlockNumber::from(ELECTION_PARAMETERS_NEW_TERM_DURATION_MIN_VALUE), - Error::InvalidCouncilElectionParameterNewTermDuration + Error::::InvalidCouncilElectionParameterNewTermDuration ); ensure!( election_parameters.new_term_duration <= T::BlockNumber::from(ELECTION_PARAMETERS_NEW_TERM_DURATION_MAX_VALUE), - Error::InvalidCouncilElectionParameterNewTermDuration + Error::::InvalidCouncilElectionParameterNewTermDuration ); ensure!( election_parameters.revealing_period >= T::BlockNumber::from(ELECTION_PARAMETERS_REVEALING_PERIOD_MIN_VALUE), - Error::InvalidCouncilElectionParameterRevealingPeriod + Error::::InvalidCouncilElectionParameterRevealingPeriod ); ensure!( election_parameters.revealing_period <= T::BlockNumber::from(ELECTION_PARAMETERS_REVEALING_PERIOD_MAX_VALUE), - Error::InvalidCouncilElectionParameterRevealingPeriod + Error::::InvalidCouncilElectionParameterRevealingPeriod ); ensure!( election_parameters.voting_period >= T::BlockNumber::from(ELECTION_PARAMETERS_VOTING_PERIOD_MIN_VALUE), - Error::InvalidCouncilElectionParameterVotingPeriod + Error::::InvalidCouncilElectionParameterVotingPeriod ); ensure!( election_parameters.voting_period <= T::BlockNumber::from(ELECTION_PARAMETERS_VOTING_PERIOD_MAX_VALUE), - Error::InvalidCouncilElectionParameterVotingPeriod + Error::::InvalidCouncilElectionParameterVotingPeriod ); ensure!( election_parameters.announcing_period >= T::BlockNumber::from(ELECTION_PARAMETERS_ANNOUNCING_PERIOD_MIN_VALUE), - Error::InvalidCouncilElectionParameterAnnouncingPeriod + Error::::InvalidCouncilElectionParameterAnnouncingPeriod ); ensure!( election_parameters.announcing_period <= T::BlockNumber::from(ELECTION_PARAMETERS_ANNOUNCING_PERIOD_MAX_VALUE), - Error::InvalidCouncilElectionParameterAnnouncingPeriod + Error::::InvalidCouncilElectionParameterAnnouncingPeriod ); ensure!( @@ -1039,7 +1026,7 @@ impl Module { >= >::from( ELECTION_PARAMETERS_MIN_COUNCIL_STAKE_MIN_VALUE ), - Error::InvalidCouncilElectionParameterMinCouncilStake + Error::::InvalidCouncilElectionParameterMinCouncilStake ); ensure!( @@ -1047,7 +1034,7 @@ impl Module { <= >::from( ELECTION_PARAMETERS_MIN_COUNCIL_STAKE_MAX_VALUE ), - Error::InvalidCouncilElectionParameterMinCouncilStake + Error::::InvalidCouncilElectionParameterMinCouncilStake ); Ok(()) diff --git a/runtime-modules/proposals/codex/src/proposal_types/mod.rs b/runtime-modules/proposals/codex/src/proposal_types/mod.rs index 943a5ab6fb..8145cd467c 100644 --- a/runtime-modules/proposals/codex/src/proposal_types/mod.rs +++ b/runtime-modules/proposals/codex/src/proposal_types/mod.rs @@ -3,9 +3,9 @@ pub(crate) mod parameters; use codec::{Decode, Encode}; -use rstd::vec::Vec; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; +use sp_std::vec::Vec; use crate::ElectionParameters; use common::working_group::WorkingGroup; diff --git a/runtime-modules/proposals/codex/src/tests/mock.rs b/runtime-modules/proposals/codex/src/tests/mock.rs index 540f4af846..071e58a4ba 100644 --- a/runtime-modules/proposals/codex/src/tests/mock.rs +++ b/runtime-modules/proposals/codex/src/tests/mock.rs @@ -1,22 +1,20 @@ #![cfg(test)] -// srml_staking_reward_curve::build! - substrate macro produces a warning. -// TODO: remove after post-Rome substrate upgrade -#![allow(array_into_iter)] -use crate::{ProposalDetailsOf, ProposalEncoder}; -pub use primitives::{Blake2Hasher, H256}; -use proposal_engine::VotersParameters; -use sr_primitives::curve::PiecewiseLinear; -pub use sr_primitives::{ - testing::{Digest, DigestItem, Header, UintAuthorityId}, - traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, - weights::Weight, - BuildStorage, DispatchError, Perbill, +use frame_support::{impl_outer_dispatch, impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::curve::PiecewiseLinear; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, }; -use sr_staking_primitives::SessionIndex; -use srml_support::{impl_outer_dispatch, impl_outer_origin, parameter_types}; +use sp_staking::SessionIndex; pub use system; +use crate::{ProposalDetailsOf, ProposalEncoder}; +use proposals_engine::VotersParameters; +use sp_runtime::testing::TestXt; + impl_outer_origin! { pub enum Origin for Test {} } @@ -37,6 +35,8 @@ impl_outer_dispatch! { pub enum Call for Test where origin: Origin { codex::ProposalCodex, proposals::ProposalsEngine, + staking::Staking, + system::System, } } @@ -54,25 +54,14 @@ impl membership::Trait for Test { parameter_types! { pub const ExistentialDeposit: u32 = 0; - pub const TransferFee: u32 = 0; - pub const CreationFee: 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 = (); - type DustRemoval = (); - type TransferPayment = (); + type Event = (); type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl stake::Trait for Test { @@ -91,13 +80,13 @@ parameter_types! { pub const MaxActiveProposalLimit: u32 = 100; } -impl proposal_engine::Trait for Test { +impl proposals_engine::Trait for Test { type Event = (); type ProposerOriginValidator = (); type VoterOriginValidator = (); type TotalVotersCounter = MockVotersParameters; type ProposalId = u32; - type StakeHandlerProvider = proposal_engine::DefaultStakeHandlerProvider; + type StakeHandlerProvider = proposals_engine::DefaultStakeHandlerProvider; type CancellationFee = CancellationFee; type RejectionFee = RejectionFee; type TitleMaxLength = TitleMaxLength; @@ -112,7 +101,7 @@ impl Default for crate::Call { } } -impl mint::Trait for Test { +impl minting::Trait for Test { type Currency = Balances; type MintId = u64; } @@ -137,7 +126,7 @@ parameter_types! { pub const PostLengthLimit: u32 = 2000; } -impl proposal_discussion::Trait for Test { +impl proposals_discussion::Trait for Test { type Event = (); type PostAuthorOriginValidator = (); type ThreadId = u64; @@ -192,7 +181,7 @@ impl hiring::Trait for Test { type StakeHandlerProvider = hiring::Module; } -srml_staking_reward_curve::build! { +pallet_staking_reward_curve::build! { const I_NPOS: PiecewiseLinear<'static> = curve!( min_inflation: 0_025_000, max_inflation: 0_100_000, @@ -209,8 +198,8 @@ parameter_types! { pub const RewardCurve: &'static PiecewiseLinear<'static> = &I_NPOS; } impl staking::Trait for Test { - type Currency = balances::Module; - type Time = timestamp::Module; + type Currency = Balances; + type UnixTime = Timestamp; type CurrencyToVote = (); type RewardRemainder = (); type Event = (); @@ -218,10 +207,29 @@ impl staking::Trait for Test { type Reward = (); type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; + type SlashDeferDuration = (); + type SlashCancelOrigin = system::EnsureRoot; type SessionInterface = Self; type RewardCurve = RewardCurve; + type NextNewSession = (); + type ElectionLookahead = (); + type Call = Call; + type MaxIterations = (); + type MinSolutionScoreBump = (); + type MaxNominatorRewardedPerValidator = (); + type UnsignedPriority = (); } +impl system::offchain::SendTransactionTypes for Test +where + Call: From, +{ + type OverarchingCall = Call; + type Extrinsic = Extrinsic; +} + +pub type Extrinsic = TestXt; + impl staking::SessionInterface for Test { fn disable_validator(_: &u64) -> Result { unimplemented!() @@ -250,10 +258,11 @@ impl ProposalEncoder for () { } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = Call; type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -262,18 +271,26 @@ impl system::Trait for Test { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; } -pub fn initial_test_ext() -> runtime_io::TestExternalities { +pub fn initial_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); @@ -281,6 +298,9 @@ pub fn initial_test_ext() -> runtime_io::TestExternalities { t.into() } +pub type Staking = staking::Module; pub type ProposalCodex = crate::Module; -pub type ProposalsEngine = proposal_engine::Module; +pub type ProposalsEngine = proposals_engine::Module; pub type Balances = balances::Module; +pub type Timestamp = pallet_timestamp::Module; +pub type System = system::Module; diff --git a/runtime-modules/proposals/codex/src/tests/mod.rs b/runtime-modules/proposals/codex/src/tests/mod.rs index df6f3d6128..aa5242c7a9 100644 --- a/runtime-modules/proposals/codex/src/tests/mod.rs +++ b/runtime-modules/proposals/codex/src/tests/mod.rs @@ -1,22 +1,21 @@ mod mock; -use governance::election_params::ElectionParameters; -use srml_support::traits::Currency; -use srml_support::StorageMap; +use frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::storage::StorageMap; +use frame_support::traits::Currency; use system::RawOrigin; -use crate::*; -use crate::{BalanceOf, Error, ProposalDetails}; -use proposal_engine::ProposalParameters; -use srml_support::dispatch::DispatchResult; - -use crate::proposal_types::ProposalsConfigParameters; -pub use mock::*; - use common::working_group::WorkingGroup; +use governance::election_params::ElectionParameters; use hiring::ActivateOpeningAt; +use proposals_engine::ProposalParameters; use working_group::OpeningPolicyCommitment; +use crate::proposal_types::ProposalsConfigParameters; +use crate::*; +use crate::{BalanceOf, Error, ProposalDetails}; +pub use mock::*; + pub(crate) fn increase_total_balance_issuance(balance: u64) { increase_total_balance_issuance_using_account_id(999, balance); } @@ -31,10 +30,10 @@ pub(crate) fn increase_total_balance_issuance_using_account_id(account_id: u64, struct ProposalTestFixture where - InsufficientRightsCall: Fn() -> DispatchResult, - EmptyStakeCall: Fn() -> DispatchResult, - InvalidStakeCall: Fn() -> DispatchResult, - SuccessfulCall: Fn() -> DispatchResult, + InsufficientRightsCall: Fn() -> DispatchResult, + EmptyStakeCall: Fn() -> DispatchResult, + InvalidStakeCall: Fn() -> DispatchResult, + SuccessfulCall: Fn() -> DispatchResult, { insufficient_rights_call: InsufficientRightsCall, empty_stake_call: EmptyStakeCall, @@ -47,24 +46,27 @@ where impl ProposalTestFixture where - InsufficientRightsCall: Fn() -> DispatchResult, - EmptyStakeCall: Fn() -> DispatchResult, - InvalidStakeCall: Fn() -> DispatchResult, - SuccessfulCall: Fn() -> DispatchResult, + InsufficientRightsCall: Fn() -> DispatchResult, + EmptyStakeCall: Fn() -> DispatchResult, + InvalidStakeCall: Fn() -> DispatchResult, + SuccessfulCall: Fn() -> DispatchResult, { fn check_for_invalid_stakes(&self) { - assert_eq!((self.empty_stake_call)(), Err(Error::Other("EmptyStake"))); + assert_eq!( + (self.empty_stake_call)(), + Err(proposals_engine::Error::::EmptyStake.into()) + ); assert_eq!( (self.invalid_stake_call)(), - Err(Error::Other("StakeDiffersFromRequired")) + Err(proposals_engine::Error::::StakeDiffersFromRequired.into()) ); } fn check_call_for_insufficient_rights(&self) { assert_eq!( (self.insufficient_rights_call)(), - Err(Error::Other("RequireSignedOrigin")) + Err(DispatchError::Other("Bad origin")) ); } @@ -163,7 +165,7 @@ fn create_text_proposal_codex_call_fails_with_incorrect_text_size() { None, long_text, ), - Err(Error::TextProposalSizeExceeded) + Err(Error::::TextProposalSizeExceeded.into()) ); assert_eq!( @@ -175,7 +177,7 @@ fn create_text_proposal_codex_call_fails_with_incorrect_text_size() { None, Vec::new(), ), - Err(Error::TextProposalIsEmpty) + Err(Error::::TextProposalIsEmpty.into()) ); }); } @@ -248,7 +250,7 @@ fn create_upgrade_runtime_proposal_codex_call_fails_with_incorrect_wasm_size() { None, long_wasm, ), - Err(Error::RuntimeProposalSizeExceeded) + Err(Error::::RuntimeProposalSizeExceeded.into()) ); assert_eq!( @@ -260,7 +262,7 @@ fn create_upgrade_runtime_proposal_codex_call_fails_with_incorrect_wasm_size() { None, Vec::new(), ), - Err(Error::RuntimeProposalIsEmpty) + Err(Error::::RuntimeProposalIsEmpty.into()) ); }); } @@ -323,7 +325,7 @@ fn create_set_election_parameters_proposal_common_checks_succeed() { fn assert_failed_election_parameters_call( election_parameters: ElectionParameters, - error: Error, + error: DispatchError, ) { assert_eq!( ProposalCodex::create_set_election_parameters_proposal( @@ -360,111 +362,111 @@ fn create_set_election_parameters_call_fails_with_incorrect_parameters() { election_parameters.council_size = 2; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterCouncilSize, + Error::::InvalidCouncilElectionParameterCouncilSize.into(), ); election_parameters.council_size = 21; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterCouncilSize, + Error::::InvalidCouncilElectionParameterCouncilSize.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.candidacy_limit = 22; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterCandidacyLimit, + Error::::InvalidCouncilElectionParameterCandidacyLimit.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.candidacy_limit = 122; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterCandidacyLimit, + Error::::InvalidCouncilElectionParameterCandidacyLimit.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.min_voting_stake = 0; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterMinVotingStake, + Error::::InvalidCouncilElectionParameterMinVotingStake.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.min_voting_stake = 200000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterMinVotingStake, + Error::::InvalidCouncilElectionParameterMinVotingStake.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.new_term_duration = 10000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterNewTermDuration, + Error::::InvalidCouncilElectionParameterNewTermDuration.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.new_term_duration = 500000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterNewTermDuration, + Error::::InvalidCouncilElectionParameterNewTermDuration.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.min_council_stake = 0; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterMinCouncilStake, + Error::::InvalidCouncilElectionParameterMinCouncilStake.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.min_council_stake = 200000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterMinCouncilStake, + Error::::InvalidCouncilElectionParameterMinCouncilStake.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.voting_period = 10000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterVotingPeriod, + Error::::InvalidCouncilElectionParameterVotingPeriod.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.voting_period = 50000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterVotingPeriod, + Error::::InvalidCouncilElectionParameterVotingPeriod.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.revealing_period = 10000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterRevealingPeriod, + Error::::InvalidCouncilElectionParameterRevealingPeriod.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.revealing_period = 50000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterRevealingPeriod, + Error::::InvalidCouncilElectionParameterRevealingPeriod.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.announcing_period = 10000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterAnnouncingPeriod, + Error::::InvalidCouncilElectionParameterAnnouncingPeriod.into(), ); election_parameters = get_valid_election_parameters(); election_parameters.announcing_period = 50000; assert_failed_election_parameters_call( election_parameters, - Error::InvalidCouncilElectionParameterAnnouncingPeriod, + Error::::InvalidCouncilElectionParameterAnnouncingPeriod.into(), ); }); } @@ -483,7 +485,7 @@ fn create_content_working_group_mint_capacity_proposal_fails_with_invalid_parame Some(>::from(50000u32)), (crate::CONTENT_WORKING_GROUP_MINT_CAPACITY_MAX_VALUE + 1) as u64, ), - Err(Error::InvalidContentWorkingGroupMintCapacity) + Err(Error::::InvalidContentWorkingGroupMintCapacity.into()) ); }); } @@ -613,7 +615,7 @@ fn create_spending_proposal_call_fails_with_incorrect_balance() { 0, 2, ), - Err(Error::InvalidSpendingProposalBalance) + Err(Error::::InvalidSpendingProposalBalance.into()) ); assert_eq!( @@ -626,7 +628,7 @@ fn create_spending_proposal_call_fails_with_incorrect_balance() { 2000001, 2, ), - Err(Error::InvalidSpendingProposalBalance) + Err(Error::::InvalidSpendingProposalBalance.into()) ); }); } @@ -652,7 +654,7 @@ fn create_set_lead_proposal_fails_with_proposed_councilor() { Some(>::from(1250u32)), Some((20, lead_account_id)), ), - Err(Error::InvalidSetLeadParameterCannotBeCouncilor) + Err(Error::::InvalidSetLeadParameterCannotBeCouncilor.into()) ); }); } @@ -777,7 +779,7 @@ fn create_set_validator_count_proposal_failed_with_invalid_validator_count() { Some(>::from(500u32)), 3, ), - Err(Error::InvalidValidatorCount) + Err(Error::::InvalidValidatorCount.into()) ); assert_eq!( @@ -789,7 +791,7 @@ fn create_set_validator_count_proposal_failed_with_invalid_validator_count() { Some(>::from(1001u32)), 3, ), - Err(Error::InvalidValidatorCount) + Err(Error::::InvalidValidatorCount.into()) ); }); } @@ -1130,7 +1132,7 @@ fn create_working_group_mint_capacity_proposal_fails_with_invalid_parameters() { (crate::WORKING_GROUP_MINT_CAPACITY_MAX_VALUE + 1) as u64, WorkingGroup::Storage, ), - Err(Error::InvalidWorkingGroupMintCapacity) + Err(Error::::InvalidWorkingGroupMintCapacity.into()) ); }); } @@ -1356,7 +1358,7 @@ fn slash_stake_with_zero_staking_balance_fails() { 0, WorkingGroup::Storage, ), - Err(Error::SlashingStakeIsZero) + Err(Error::::SlashingStakeIsZero.into()) ); }); } @@ -1384,7 +1386,7 @@ fn decrease_stake_with_zero_staking_balance_fails() { 0, WorkingGroup::Storage, ), - Err(Error::DecreasingStakeIsZero) + Err(Error::::DecreasingStakeIsZero.into()) ); }); } diff --git a/runtime-modules/proposals/discussion/Cargo.toml b/runtime-modules/proposals/discussion/Cargo.toml index c5bad3b951..a2bb970833 100644 --- a/runtime-modules/proposals/discussion/Cargo.toml +++ b/runtime-modules/proposals/discussion/Cargo.toml @@ -1,94 +1,33 @@ [package] -name = 'substrate-proposals-discussion-module' -version = '2.0.0' +name = 'pallet-proposals-discussion' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +membership = { package = 'pallet-membership', default-features = false, path = '../../membership'} +common = { package = 'pallet-common', default-features = false, path = '../../common'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + [features] default = ['std'] -no_std = [] std = [ - 'codec/std', - 'rstd/std', - 'srml-support/std', - 'primitives/std', - 'sr-primitives/std', - 'system/std', - 'timestamp/std', - 'serde', + 'serde', + 'codec/std', + 'sp-std/std', + 'frame-support/std', + 'system/std', 'membership/std', 'common/std', -] - -[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 = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../../membership' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../../common' - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.balances] -package = 'srml-balances' -default-features = false -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' \ No newline at end of file +] \ No newline at end of file diff --git a/runtime-modules/proposals/discussion/src/lib.rs b/runtime-modules/proposals/discussion/src/lib.rs index b2ab3fcd39..123cd1cb36 100644 --- a/runtime-modules/proposals/discussion/src/lib.rs +++ b/runtime-modules/proposals/discussion/src/lib.rs @@ -19,19 +19,19 @@ //! ## Usage //! //! ``` -//! use srml_support::{decl_module, dispatch::Result}; +//! use frame_support::decl_module; //! use system::ensure_root; -//! use substrate_proposals_discussion_module::{self as discussions}; +//! use pallet_proposals_discussion::{self as discussions}; //! //! pub trait Trait: discussions::Trait + membership::Trait {} //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn create_discussion(origin, title: Vec, author_id : T::MemberId) -> Result { +//! #[weight = 10_000_000] +//! pub fn create_discussion(origin, title: Vec, author_id : T::MemberId) { //! ensure_root(origin)?; //! >::ensure_can_create_thread(author_id, &title)?; //! >::create_thread(author_id, title)?; -//! Ok(()) //! } //! } //! } @@ -48,16 +48,14 @@ mod tests; mod types; -use rstd::clone::Clone; -use rstd::prelude::*; -use rstd::vec::Vec; -use srml_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; - -use srml_support::traits::Get; -use types::{DiscussionPost, DiscussionThread, ThreadCounter}; +use frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::traits::Get; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; +use sp_std::clone::Clone; +use sp_std::vec::Vec; use common::origin::ActorOriginValidator; -use srml_support::dispatch::DispatchResult; +use types::{DiscussionPost, DiscussionThread, ThreadCounter}; type MemberId = ::MemberId; @@ -113,7 +111,7 @@ pub trait Trait: system::Trait + membership::Trait { decl_error! { /// Discussion module predefined errors - pub enum Error { + pub enum Error for Module { /// Author should match the post creator NotAuthor, @@ -146,29 +144,20 @@ decl_error! { } } -impl From for Error { - fn from(error: system::Error) -> Self { - match error { - system::Error::Other(msg) => Error::Other(msg), - system::Error::RequireRootOrigin => Error::RequireRootOrigin, - _ => Error::Other(error.into()), - } - } -} - // Storage for the proposals discussion module decl_storage! { pub trait Store for Module as ProposalDiscussion { /// Map thread identifier to corresponding thread. - pub ThreadById get(thread_by_id): map T::ThreadId => - DiscussionThread, T::BlockNumber>; + pub ThreadById get(fn thread_by_id): map hasher(blake2_128_concat) + T::ThreadId => DiscussionThread, T::BlockNumber>; /// Count of all threads that have been created. pub ThreadCount get(fn thread_count): u64; /// Map thread id and post id to corresponding post. - pub PostThreadIdByPostId: double_map T::ThreadId, twox_128(T::PostId) => - DiscussionPost, T::BlockNumber, T::ThreadId>; + pub PostThreadIdByPostId: + double_map hasher(blake2_128_concat) T::ThreadId, hasher(blake2_128_concat) T::PostId => + DiscussionPost, T::BlockNumber, T::ThreadId>; /// Count of all posts that have been created. pub PostCount get(fn post_count): u64; @@ -183,7 +172,7 @@ decl_module! { /// 'Proposal discussion' substrate module pub struct Module for enum Call where origin: T::Origin { /// Predefined errors - type Error = Error; + type Error = Error; /// Emits an event. Default substrate implementation. fn deposit_event() = default; @@ -201,6 +190,7 @@ decl_module! { const MaxThreadInARowNumber: u32 = T::MaxThreadInARowNumber::get(); /// Adds a post with author origin check. + #[weight = 10_000_000] // TODO: adjust weight pub fn add_post( origin, post_author_id: MemberId, @@ -211,12 +201,12 @@ decl_module! { origin, post_author_id, )?; - ensure!(>::exists(thread_id), Error::ThreadDoesntExist); + ensure!(>::contains_key(thread_id), Error::::ThreadDoesntExist); - ensure!(!text.is_empty(),Error::EmptyPostProvided); + ensure!(!text.is_empty(),Error::::EmptyPostProvided); ensure!( text.len() as u32 <= T::PostLengthLimit::get(), - Error::PostIsTooLong + Error::::PostIsTooLong ); // mutation @@ -240,6 +230,7 @@ decl_module! { } /// Updates a post with author origin check. Update attempts number is limited. + #[weight = 10_000_000] // TODO: adjust weight pub fn update_post( origin, post_author_id: MemberId, @@ -252,20 +243,20 @@ decl_module! { post_author_id, )?; - ensure!(>::exists(thread_id), Error::ThreadDoesntExist); - ensure!(>::exists(thread_id, post_id), Error::PostDoesntExist); + ensure!(>::contains_key(thread_id), Error::::ThreadDoesntExist); + ensure!(>::contains_key(thread_id, post_id), Error::::PostDoesntExist); - ensure!(!text.is_empty(), Error::EmptyPostProvided); + ensure!(!text.is_empty(), Error::::EmptyPostProvided); ensure!( text.len() as u32 <= T::PostLengthLimit::get(), - Error::PostIsTooLong + Error::::PostIsTooLong ); let post = >::get(&thread_id, &post_id); - ensure!(post.author_id == post_author_id, Error::NotAuthor); + ensure!(post.author_id == post_author_id, Error::::NotAuthor); ensure!(post.edition_number < T::MaxPostEditionNumber::get(), - Error::PostEditionNumberExceeded); + Error::::PostEditionNumberExceeded); let new_post = DiscussionPost { text, @@ -288,7 +279,7 @@ impl Module { pub fn create_thread( thread_author_id: MemberId, title: Vec, - ) -> Result { + ) -> Result { Self::ensure_can_create_thread(thread_author_id, &title)?; let next_thread_count_value = Self::thread_count() + 1; @@ -318,14 +309,11 @@ impl Module { /// Checks: /// - title is valid /// - max thread in a row by the same author - pub fn ensure_can_create_thread( - thread_author_id: MemberId, - title: &[u8], - ) -> DispatchResult { - ensure!(!title.is_empty(), Error::EmptyTitleProvided); + pub fn ensure_can_create_thread(thread_author_id: MemberId, title: &[u8]) -> DispatchResult { + ensure!(!title.is_empty(), Error::::EmptyTitleProvided); ensure!( title.len() as u32 <= T::ThreadTitleLengthLimit::get(), - Error::TitleIsTooLong + Error::::TitleIsTooLong ); // get new 'threads in a row' counter for the author @@ -333,7 +321,7 @@ impl Module { ensure!( current_thread_counter.counter as u32 <= T::MaxThreadInARowNumber::get(), - Error::MaxThreadInARowLimitExceeded + Error::::MaxThreadInARowLimitExceeded ); Ok(()) diff --git a/runtime-modules/proposals/discussion/src/tests/mock.rs b/runtime-modules/proposals/discussion/src/tests/mock.rs index c675d358fb..c4eb636221 100644 --- a/runtime-modules/proposals/discussion/src/tests/mock.rs +++ b/runtime-modules/proposals/discussion/src/tests/mock.rs @@ -2,16 +2,16 @@ pub use system; -pub use primitives::{Blake2Hasher, H256}; -pub use sr_primitives::{ - testing::{Digest, DigestItem, Header, UintAuthorityId}, - traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, - weights::Weight, - BuildStorage, Perbill, +use frame_support::traits::{OnFinalize, OnInitialize}; +use frame_support::{impl_outer_event, impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, }; use crate::ActorOriginValidator; -use srml_support::{impl_outer_event, impl_outer_origin, parameter_types}; impl_outer_origin! { pub enum Origin for Test {} @@ -49,6 +49,7 @@ impl_outer_event! { discussion, balances, membership_mod, + system, } } @@ -60,15 +61,10 @@ parameter_types! { impl balances::Trait for Test { type Balance = u64; - /// What to do if an account's free balance gets zeroed. - type OnFreeBalanceZero = (); - type OnNewAccount = (); - type TransferPayment = (); type DustRemoval = (); type Event = TestEvent; type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl common::currency::GovernanceCurrency for Test { @@ -109,6 +105,7 @@ impl ActorOriginValidator for () { } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; type Call = (); type Index = u64; @@ -121,18 +118,26 @@ impl system::Trait for Test { type Event = TestEvent; type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; } -pub fn initial_test_ext() -> runtime_io::TestExternalities { +pub fn initial_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); @@ -142,3 +147,15 @@ pub fn initial_test_ext() -> runtime_io::TestExternalities { pub type Discussions = crate::Module; pub type System = system::Module; + +// Recommendation from Parity on testing on_finalize +// https://substrate.dev/docs/en/next/development/module/tests +pub 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()); + } +} diff --git a/runtime-modules/proposals/discussion/src/tests/mod.rs b/runtime-modules/proposals/discussion/src/tests/mod.rs index 86254c99d8..9763eb6e8c 100644 --- a/runtime-modules/proposals/discussion/src/tests/mod.rs +++ b/runtime-modules/proposals/discussion/src/tests/mod.rs @@ -1,18 +1,19 @@ mod mock; -use mock::*; - -use crate::*; +use frame_support::dispatch::{DispatchError, DispatchResult}; use system::RawOrigin; use system::{EventRecord, Phase}; +use crate::*; +use mock::*; + 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), + phase: Phase::Initialization, event: TestEvent::discussion(ev.clone()), topics: vec![], }) @@ -34,12 +35,12 @@ struct TestThreadEntry { } fn assert_thread_content(thread_entry: TestThreadEntry, post_entries: Vec) { - assert!(>::exists(thread_entry.thread_id)); + assert!(>::contains_key(thread_entry.thread_id)); let actual_thread = >::get(thread_entry.thread_id); let expected_thread = DiscussionThread { title: thread_entry.title, - created_at: 1, + created_at: 0, author_id: 1, }; assert_eq!(actual_thread, expected_thread); @@ -49,8 +50,8 @@ fn assert_thread_content(thread_entry: TestThreadEntry, post_entries: Vec>::get(thread_entry.thread_id, post_entry.post_id); let expected_post = DiscussionPost { text: post_entry.text, - created_at: 1, - updated_at: 1, + created_at: 0, + updated_at: 0, author_id: 1, thread_id: thread_entry.thread_id, edition_number: post_entry.edition_number, @@ -81,7 +82,7 @@ impl DiscussionFixture { DiscussionFixture { title, ..self } } - fn create_discussion_and_assert(&self, result: Result) -> Option { + fn create_discussion_and_assert(&self, result: Result) -> Option { let create_discussion_result = Discussions::create_thread(self.author_id, self.title.clone()); @@ -133,7 +134,7 @@ impl PostFixture { } } - fn add_post_and_assert(&mut self, result: Result<(), Error>) -> Option { + fn add_post_and_assert(&mut self, result: DispatchResult) -> Option { let add_post_result = Discussions::add_post( self.origin.clone().into(), self.author_id, @@ -150,7 +151,7 @@ impl PostFixture { self.post_id } - fn update_post_with_text_and_assert(&mut self, new_text: Vec, result: Result<(), Error>) { + fn update_post_with_text_and_assert(&mut self, new_text: Vec, result: DispatchResult) { let add_post_result = Discussions::update_post( self.origin.clone().into(), self.author_id, @@ -162,7 +163,7 @@ impl PostFixture { assert_eq!(add_post_result, result); } - fn update_post_and_assert(&mut self, result: Result<(), Error>) { + fn update_post_and_assert(&mut self, result: DispatchResult) { self.update_post_with_text_and_assert(self.text.clone(), result); } } @@ -194,6 +195,13 @@ fn create_post_call_succeeds() { #[test] fn update_post_call_succeeds() { initial_test_ext().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let discussion_fixture = DiscussionFixture::default(); let thread_id = discussion_fixture @@ -230,7 +238,7 @@ fn update_post_call_fails_because_of_post_edition_limit() { post_fixture.update_post_and_assert(Ok(())); } - post_fixture.update_post_and_assert(Err(Error::PostEditionNumberExceeded)); + post_fixture.update_post_and_assert(Err(Error::::PostEditionNumberExceeded.into())); }); } @@ -249,11 +257,11 @@ fn update_post_call_fails_because_of_the_wrong_author() { post_fixture = post_fixture.with_author(2); - post_fixture.update_post_and_assert(Err(Error::Other("Invalid author"))); + post_fixture.update_post_and_assert(Err(DispatchError::Other("Invalid author"))); post_fixture = post_fixture.with_origin(RawOrigin::None).with_author(2); - post_fixture.update_post_and_assert(Err(Error::NotAuthor)); + post_fixture.update_post_and_assert(Err(Error::::NotAuthor.into())); }); } @@ -298,10 +306,11 @@ fn thread_content_check_succeeded() { fn create_discussion_call_with_bad_title_failed() { initial_test_ext().execute_with(|| { let mut discussion_fixture = DiscussionFixture::default().with_title(Vec::new()); - discussion_fixture.create_discussion_and_assert(Err(Error::EmptyTitleProvided)); + discussion_fixture + .create_discussion_and_assert(Err(Error::::EmptyTitleProvided.into())); discussion_fixture = DiscussionFixture::default().with_title([0; 201].to_vec()); - discussion_fixture.create_discussion_and_assert(Err(Error::TitleIsTooLong)); + discussion_fixture.create_discussion_and_assert(Err(Error::::TitleIsTooLong.into())); }); } @@ -314,7 +323,7 @@ fn add_post_call_with_invalid_thread_failed() { .unwrap(); let mut post_fixture = PostFixture::default_for_thread(2); - post_fixture.add_post_and_assert(Err(Error::ThreadDoesntExist)); + post_fixture.add_post_and_assert(Err(Error::::ThreadDoesntExist.into())); }); } @@ -330,7 +339,7 @@ fn update_post_call_with_invalid_post_failed() { post_fixture1.add_post_and_assert(Ok(())).unwrap(); let mut post_fixture2 = post_fixture1.change_post_id(2); - post_fixture2.update_post_and_assert(Err(Error::PostDoesntExist)); + post_fixture2.update_post_and_assert(Err(Error::::PostDoesntExist.into())); }); } @@ -346,7 +355,7 @@ fn update_post_call_with_invalid_thread_failed() { post_fixture1.add_post_and_assert(Ok(())).unwrap(); let mut post_fixture2 = post_fixture1.change_thread_id(2); - post_fixture2.update_post_and_assert(Err(Error::ThreadDoesntExist)); + post_fixture2.update_post_and_assert(Err(Error::::ThreadDoesntExist.into())); }); } @@ -359,11 +368,11 @@ fn add_post_call_with_invalid_text_failed() { .unwrap(); let mut post_fixture1 = PostFixture::default_for_thread(thread_id).with_text(Vec::new()); - post_fixture1.add_post_and_assert(Err(Error::EmptyPostProvided)); + post_fixture1.add_post_and_assert(Err(Error::::EmptyPostProvided.into())); let mut post_fixture2 = PostFixture::default_for_thread(thread_id).with_text([0; 2001].to_vec()); - post_fixture2.add_post_and_assert(Err(Error::PostIsTooLong)); + post_fixture2.add_post_and_assert(Err(Error::::PostIsTooLong.into())); }); } @@ -379,10 +388,10 @@ fn update_post_call_with_invalid_text_failed() { post_fixture1.add_post_and_assert(Ok(())); let mut post_fixture2 = post_fixture1.with_text(Vec::new()); - post_fixture2.update_post_and_assert(Err(Error::EmptyPostProvided)); + post_fixture2.update_post_and_assert(Err(Error::::EmptyPostProvided.into())); let mut post_fixture3 = post_fixture2.with_text([0; 2001].to_vec()); - post_fixture3.update_post_and_assert(Err(Error::PostIsTooLong)); + post_fixture3.update_post_and_assert(Err(Error::::PostIsTooLong.into())); }); } @@ -396,7 +405,8 @@ fn add_discussion_thread_fails_because_of_max_thread_by_same_author_in_a_row_lim .unwrap(); } - discussion_fixture.create_discussion_and_assert(Err(Error::MaxThreadInARowLimitExceeded)); + discussion_fixture + .create_discussion_and_assert(Err(Error::::MaxThreadInARowLimitExceeded.into())); }); } diff --git a/runtime-modules/proposals/discussion/src/types.rs b/runtime-modules/proposals/discussion/src/types.rs index e4b32a3d93..ecaec470fd 100644 --- a/runtime-modules/proposals/discussion/src/types.rs +++ b/runtime-modules/proposals/discussion/src/types.rs @@ -3,8 +3,7 @@ use codec::{Decode, Encode}; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; - -use rstd::prelude::*; +use sp_std::vec::Vec; /// Represents a discussion thread #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] diff --git a/runtime-modules/proposals/engine/Cargo.toml b/runtime-modules/proposals/engine/Cargo.toml index 6c7b2a6e08..23527fca9a 100644 --- a/runtime-modules/proposals/engine/Cargo.toml +++ b/runtime-modules/proposals/engine/Cargo.toml @@ -1,105 +1,40 @@ [package] -name = 'substrate-proposals-engine-module' -version = '2.0.0' +name = 'pallet-proposals-engine' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +membership = { package = 'pallet-membership', default-features = false, path = '../../membership'} +stake = { package = 'pallet-stake', default-features = false, path = '../../stake'} +common = { package = 'pallet-common', default-features = false, path = '../../common'} + +[dev-dependencies] +mockall = "0.7.1" +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + [features] default = ['std'] -no_std = [] std = [ - 'codec/std', - 'rstd/std', - 'srml-support/std', - 'primitives/std', - 'system/std', - 'timestamp/std', - 'serde', - 'stake/std', - 'balances/std', - 'sr-primitives/std', + 'serde', + 'codec/std', + 'sp-std/std', + 'frame-support/std', + 'system/std', + 'pallet-timestamp/std', + 'sp-arithmetic/std', + 'sp-runtime/std', 'membership/std', + 'stake/std', 'common/std', -] - - -[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 = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.balances] -package = 'srml-balances' -default-features = false -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.stake] -default_features = false -package = 'substrate-stake-module' -path = '../../stake' - -[dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../../membership' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../../common' - -[dev-dependencies] -mockall = "0.7.1" - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' +] \ No newline at end of file diff --git a/runtime-modules/proposals/engine/src/lib.rs b/runtime-modules/proposals/engine/src/lib.rs index 37e2a624f0..81936b1e52 100644 --- a/runtime-modules/proposals/engine/src/lib.rs +++ b/runtime-modules/proposals/engine/src/lib.rs @@ -57,23 +57,25 @@ //! ## Usage //! //! ``` -//! use srml_support::{decl_module, dispatch::Result, print}; +//! use frame_support::{decl_module, print}; //! use system::ensure_signed; //! use codec::Encode; -//! use substrate_proposals_engine_module::{self as engine, ProposalParameters}; +//! use pallet_proposals_engine::{self as engine, ProposalParameters}; //! //! pub trait Trait: engine::Trait + membership::Trait {} //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { +//! #[weight = 10_000_000] //! fn executable_proposal(origin) { //! print("executed!"); //! } //! +//! #[weight = 10_000_000] //! pub fn create_spending_proposal( //! origin, //! proposer_id: T::MemberId, -//! ) -> Result { +//! ) { //! let account_id = ensure_signed(origin)?; //! let parameters = ProposalParameters::default(); //! let title = b"Spending proposal".to_vec(); @@ -96,7 +98,6 @@ //! None, //! encoded_proposal_code //! )?; -//! Ok(()) //! } //! } //! } @@ -109,6 +110,7 @@ // Do not delete! Cannot be uncommented by default, because of Parity decl_module! issue. //#![warn(missing_docs)] +use crate::types::ApprovedProposalData; use types::FinalizedProposalData; use types::ProposalStakeManager; pub use types::{ @@ -126,22 +128,24 @@ pub(crate) mod types; mod tests; use codec::Decode; -use rstd::prelude::*; -use sr_primitives::traits::{DispatchResult, Zero}; -use srml_support::traits::{Currency, Get}; -use srml_support::{ +use frame_support::dispatch::{DispatchError, DispatchResult, UnfilteredDispatchable}; +use frame_support::storage::IterableStorageMap; +use frame_support::traits::{Currency, Get}; +use frame_support::{ decl_error, decl_event, decl_module, decl_storage, ensure, print, Parameter, StorageDoubleMap, }; +use sp_arithmetic::traits::Zero; +use sp_std::vec::Vec; use system::{ensure_root, RawOrigin}; -use crate::types::ApprovedProposalData; use common::origin::ActorOriginValidator; -use srml_support::dispatch::Dispatchable; type MemberId = ::MemberId; /// Proposals engine trait. -pub trait Trait: system::Trait + timestamp::Trait + stake::Trait + membership::Trait { +pub trait Trait: + system::Trait + pallet_timestamp::Trait + stake::Trait + membership::Trait +{ /// Engine event type. type Event: From> + Into<::Event>; @@ -180,7 +184,7 @@ pub trait Trait: system::Trait + timestamp::Trait + stake::Trait + membership::T type MaxActiveProposalLimit: Get; /// Proposals executable code. Can be instantiated by external module Call enum members. - type DispatchableCallCode: Parameter + Dispatchable + Default; + type DispatchableCallCode: Parameter + UnfilteredDispatchable + Default; } decl_event!( @@ -216,7 +220,7 @@ decl_event!( decl_error! { /// Engine module predefined errors - pub enum Error { + pub enum Error for Module{ /// Proposal cannot have an empty title" EmptyTitleProvided, @@ -264,43 +268,38 @@ decl_error! { } } -impl From for Error { - fn from(error: system::Error) -> Self { - match error { - system::Error::Other(msg) => Error::Other(msg), - system::Error::RequireRootOrigin => Error::RequireRootOrigin, - _ => Error::Other(error.into()), - } - } -} - // Storage for the proposals engine module decl_storage! { pub trait Store for Module as ProposalEngine{ /// Map proposal by its id. - pub Proposals get(fn proposals): map T::ProposalId => ProposalOf; + pub Proposals get(fn proposals): map hasher(blake2_128_concat) + T::ProposalId => ProposalOf; /// Count of all proposals that have been created. pub ProposalCount get(fn proposal_count): u32; /// Map proposal executable code by proposal id. - pub DispatchableCallCode get(fn proposal_codes): map T::ProposalId => Vec; + pub DispatchableCallCode get(fn proposal_codes): map hasher(blake2_128_concat) + T::ProposalId => Vec; /// Count of active proposals. pub ActiveProposalCount get(fn active_proposal_count): u32; /// Ids of proposals that are open for voting (have not been finalized yet). - pub ActiveProposalIds get(fn active_proposal_ids): linked_map T::ProposalId=> (); + pub ActiveProposalIds get(fn active_proposal_ids): map hasher(blake2_128_concat) + T::ProposalId=> (); /// Ids of proposals that were approved and theirs grace period was not expired. - pub PendingExecutionProposalIds get(fn pending_proposal_ids): linked_map T::ProposalId=> (); + pub PendingExecutionProposalIds get(fn pending_proposal_ids): map hasher(blake2_128_concat) + T::ProposalId=> (); /// Double map for preventing duplicate votes. Should be cleaned after usage. pub VoteExistsByProposalByVoter get(fn vote_by_proposal_by_voter): - double_map T::ProposalId, twox_256(MemberId) => VoteKind; + double_map hasher(blake2_128_concat) T::ProposalId, hasher(blake2_128_concat) MemberId => VoteKind; /// Map proposal id by stake id. Required by StakingEventsHandler callback call - pub StakesProposals get(fn stakes_proposals): map T::StakeId => T::ProposalId; + pub StakesProposals get(fn stakes_proposals): map hasher(blake2_128_concat) + T::StakeId => T::ProposalId; } } @@ -308,7 +307,7 @@ decl_module! { /// 'Proposal engine' substrate module pub struct Module for enum Call where origin: T::Origin { /// Predefined errors - type Error = Error; + type Error = Error; /// Emits an event. Default substrate implementation. fn deposit_event() = default; @@ -329,23 +328,24 @@ decl_module! { const MaxActiveProposalLimit: u32 = T::MaxActiveProposalLimit::get(); /// Vote extrinsic. Conditions: origin must allow votes. + #[weight = 10_000_000] // TODO: adjust weight pub fn vote(origin, voter_id: MemberId, proposal_id: T::ProposalId, vote: VoteKind) { T::VoterOriginValidator::ensure_actor_origin( origin, voter_id, )?; - ensure!(>::exists(proposal_id), Error::ProposalNotFound); + ensure!(>::contains_key(proposal_id), Error::::ProposalNotFound); let mut proposal = Self::proposals(proposal_id); - ensure!(matches!(proposal.status, ProposalStatus::Active{..}), Error::ProposalFinalized); + ensure!(matches!(proposal.status, ProposalStatus::Active{..}), Error::::ProposalFinalized); - let did_not_vote_before = !>::exists( + let did_not_vote_before = !>::contains_key( proposal_id, voter_id, ); - ensure!(did_not_vote_before, Error::AlreadyVoted); + ensure!(did_not_vote_before, Error::::AlreadyVoted); proposal.voting_results.add_vote(vote.clone()); @@ -357,17 +357,18 @@ decl_module! { } /// Cancel a proposal by its original proposer. + #[weight = 10_000_000] // TODO: adjust weight pub fn cancel_proposal(origin, proposer_id: MemberId, proposal_id: T::ProposalId) { T::ProposerOriginValidator::ensure_actor_origin( origin, proposer_id, )?; - ensure!(>::exists(proposal_id), Error::ProposalNotFound); + ensure!(>::contains_key(proposal_id), Error::::ProposalNotFound); let proposal = Self::proposals(proposal_id); - ensure!(proposer_id == proposal.proposer_id, Error::NotAuthor); - ensure!(matches!(proposal.status, ProposalStatus::Active{..}), Error::ProposalFinalized); + ensure!(proposer_id == proposal.proposer_id, Error::::NotAuthor); + ensure!(matches!(proposal.status, ProposalStatus::Active{..}), Error::::ProposalFinalized); // mutation @@ -375,18 +376,19 @@ decl_module! { } /// Veto a proposal. Must be root. + #[weight = 10_000_000] // TODO: adjust weight pub fn veto_proposal(origin, proposal_id: T::ProposalId) { ensure_root(origin)?; - ensure!(>::exists(proposal_id), Error::ProposalNotFound); + ensure!(>::contains_key(proposal_id), Error::::ProposalNotFound); let proposal = Self::proposals(proposal_id); // mutation - if >::exists(proposal_id) { + if >::contains_key(proposal_id) { Self::veto_pending_execution_proposal(proposal_id, proposal); } else { - ensure!(matches!(proposal.status, ProposalStatus::Active{..}), Error::ProposalFinalized); + ensure!(matches!(proposal.status, ProposalStatus::Active{..}), Error::::ProposalFinalized); Self::finalize_proposal(proposal_id, ProposalDecisionStatus::Vetoed); } } @@ -426,7 +428,7 @@ impl Module { description: Vec, stake_balance: Option>, encoded_dispatchable_call_code: Vec, - ) -> Result { + ) -> Result { Self::ensure_create_proposal_parameters_are_valid( ¶meters, &title, @@ -490,32 +492,35 @@ impl Module { title: &[u8], description: &[u8], stake_balance: Option>, - ) -> DispatchResult { - ensure!(!title.is_empty(), Error::EmptyTitleProvided); + ) -> DispatchResult { + ensure!(!title.is_empty(), Error::::EmptyTitleProvided); ensure!( title.len() as u32 <= T::TitleMaxLength::get(), - Error::TitleIsTooLong + Error::::TitleIsTooLong ); - ensure!(!description.is_empty(), Error::EmptyDescriptionProvided); + ensure!( + !description.is_empty(), + Error::::EmptyDescriptionProvided + ); ensure!( description.len() as u32 <= T::DescriptionMaxLength::get(), - Error::DescriptionIsTooLong + Error::::DescriptionIsTooLong ); ensure!( (Self::active_proposal_count()) < T::MaxActiveProposalLimit::get(), - Error::MaxActiveProposalNumberExceeded + Error::::MaxActiveProposalNumberExceeded ); ensure!( parameters.approval_threshold_percentage > 0, - Error::InvalidParameterApprovalThreshold + Error::::InvalidParameterApprovalThreshold ); ensure!( parameters.slashing_threshold_percentage > 0, - Error::InvalidParameterSlashingThreshold + Error::::InvalidParameterSlashingThreshold ); // check stake parameters @@ -523,15 +528,15 @@ impl Module { if let Some(staked_balance) = stake_balance { ensure!( required_stake == staked_balance, - Error::StakeDiffersFromRequired + Error::::StakeDiffersFromRequired ); } else { - return Err(Error::EmptyStake); + return Err(Error::::EmptyStake.into()); } } if stake_balance.is_some() && parameters.required_stake.is_none() { - return Err(Error::StakeShouldBeEmpty); + return Err(Error::::StakeShouldBeEmpty.into()); } Ok(()) @@ -541,10 +546,10 @@ impl Module { /// There can be a lot of invariant breaks in the scope of this proposal. /// Such situations are handled by adding error messages to the log. pub fn refund_proposal_stake(stake_id: T::StakeId, imbalance: NegativeImbalance) { - if >::exists(stake_id) { + if >::contains_key(stake_id) { let proposal_id = Self::stakes_proposals(stake_id); - if >::exists(proposal_id) { + if >::contains_key(proposal_id) { let proposal = Self::proposals(proposal_id); if let ProposalStatus::Active(active_stake_result) = proposal.status { @@ -572,7 +577,7 @@ impl Module { /// Resets voting results for active proposals. /// Possible application includes new council elections. pub fn reset_active_proposals() { - >::enumerate().for_each(|(proposal_id, _)| { + >::iter().for_each(|(proposal_id, _)| { >::mutate(proposal_id, |proposal| { proposal.reset_proposal(); >::remove_prefix(&proposal_id); @@ -592,7 +597,7 @@ impl Module { fn get_finalized_proposals() -> Vec> { // Enumerate active proposals id and gather finalization data. // Skip proposals with unfinished voting. - >::enumerate() + >::iter() .filter_map(|(proposal_id, _)| { // load current proposal let proposal = Self::proposals(proposal_id); @@ -644,10 +649,12 @@ impl Module { let approved_proposal_status = match proposal_code_result { Ok(proposal_code) => { - if let Err(error) = proposal_code.dispatch(T::Origin::from(RawOrigin::Root)) { - ApprovedProposalStatus::failed_execution( - error.into().message.unwrap_or("Dispatch error"), - ) + if let Err(dispatch_error) = + proposal_code.dispatch_bypass_filter(T::Origin::from(RawOrigin::Root)) + { + ApprovedProposalStatus::failed_execution(Self::parse_dispatch_error( + dispatch_error.error, + )) } else { ApprovedProposalStatus::Executed } @@ -756,7 +763,7 @@ impl Module { // Enumerates approved proposals and checks their grace period expiration fn get_approved_proposal_with_expired_grace_period() -> Vec> { - >::enumerate() + >::iter() .filter_map(|(proposal_id, _)| { let proposal = Self::proposals(proposal_id); @@ -793,6 +800,20 @@ impl Module { ActiveProposalCount::put(next_active_proposal_count_value); }; } + + // Parse dispatchable execution result. + fn parse_dispatch_error(error: DispatchError) -> &'static str { + match error { + DispatchError::BadOrigin => error.into(), + DispatchError::Other(msg) => msg, + DispatchError::CannotLookup => error.into(), + DispatchError::Module { + index: _, + error: _, + message: msg, + } => msg.unwrap_or("Dispatch error."), + } + } } // Simplification of the 'FinalizedProposalData' type diff --git a/runtime-modules/proposals/engine/src/tests/mock/balance_manager.rs b/runtime-modules/proposals/engine/src/tests/mock/balance_manager.rs index 6c3cef6be1..9a03ba5961 100644 --- a/runtime-modules/proposals/engine/src/tests/mock/balance_manager.rs +++ b/runtime-modules/proposals/engine/src/tests/mock/balance_manager.rs @@ -1,7 +1,7 @@ #![cfg(test)] -pub use sr_primitives::traits::Zero; -use srml_support::traits::{Currency, Imbalance}; +use frame_support::traits::{Currency, Imbalance}; +pub use sp_arithmetic::traits::Zero; use super::*; diff --git a/runtime-modules/proposals/engine/src/tests/mock/mod.rs b/runtime-modules/proposals/engine/src/tests/mock/mod.rs index e2504f498e..e680cc99ce 100644 --- a/runtime-modules/proposals/engine/src/tests/mock/mod.rs +++ b/runtime-modules/proposals/engine/src/tests/mock/mod.rs @@ -7,14 +7,14 @@ //! #![cfg(test)] -pub use primitives::{Blake2Hasher, H256}; -pub use sr_primitives::{ - testing::{Digest, DigestItem, Header, UintAuthorityId}, - traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize, Zero}, - weights::Weight, - BuildStorage, DispatchError, Perbill, + +use frame_support::{impl_outer_event, impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, }; -use srml_support::{impl_outer_event, impl_outer_origin, parameter_types}; pub use system; mod balance_manager; @@ -46,30 +46,20 @@ impl_outer_event! { balances, engine, membership_mod, + system, } } parameter_types! { pub const ExistentialDeposit: u32 = 0; - pub const TransferFee: u32 = 0; - pub const CreationFee: 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 TransferPayment = (); - type DustRemoval = (); type Event = TestEvent; type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl common::currency::GovernanceCurrency for Test { @@ -149,6 +139,7 @@ parameter_types! { } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; type Call = (); type Index = u64; @@ -161,18 +152,26 @@ impl system::Trait for Test { type Event = TestEvent; type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; } -pub fn initial_test_ext() -> runtime_io::TestExternalities { +pub fn initial_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime-modules/proposals/engine/src/tests/mock/proposals.rs b/runtime-modules/proposals/engine/src/tests/mock/proposals.rs index b8b8cc6675..a875ff44ae 100644 --- a/runtime-modules/proposals/engine/src/tests/mock/proposals.rs +++ b/runtime-modules/proposals/engine/src/tests/mock/proposals.rs @@ -1,16 +1,17 @@ //! Contains executable proposal extrinsic mocks -use rstd::prelude::*; -use rstd::vec::Vec; -use srml_support::decl_module; +use frame_support::decl_module; +use sp_std::vec::Vec; pub trait Trait: system::Trait {} decl_module! { pub struct Module for enum Call where origin: T::Origin { /// Working extrinsic test + #[weight = 10_000_000] pub fn dummy_proposal(_origin, _title: Vec, _description: Vec) {} /// Broken extrinsic test + #[weight = 10_000_000] pub fn faulty_proposal(_origin, _title: Vec, _description: Vec,) { Err("ExecutionFailed")? } diff --git a/runtime-modules/proposals/engine/src/tests/mock/stakes.rs b/runtime-modules/proposals/engine/src/tests/mock/stakes.rs index 188c69c9e7..d63c3d12fa 100644 --- a/runtime-modules/proposals/engine/src/tests/mock/stakes.rs +++ b/runtime-modules/proposals/engine/src/tests/mock/stakes.rs @@ -1,6 +1,6 @@ #![cfg(test)] -use rstd::marker::PhantomData; +use sp_std::marker::PhantomData; use std::cell::RefCell; use std::panic; use std::rc::Rc; diff --git a/runtime-modules/proposals/engine/src/tests/mod.rs b/runtime-modules/proposals/engine/src/tests/mod.rs index 5cdc3ec0e0..97f441865e 100644 --- a/runtime-modules/proposals/engine/src/tests/mod.rs +++ b/runtime-modules/proposals/engine/src/tests/mod.rs @@ -4,14 +4,13 @@ use crate::*; use mock::*; use codec::Encode; -use rstd::rc::Rc; -use sr_primitives::traits::{DispatchResult, OnFinalize, OnInitialize}; -use srml_support::{StorageDoubleMap, StorageMap, StorageValue}; +use frame_support::dispatch::DispatchResult; +use frame_support::traits::{Currency, OnFinalize, OnInitialize}; +use frame_support::{StorageDoubleMap, StorageMap, StorageValue}; +use sp_std::rc::Rc; use system::RawOrigin; use system::{EventRecord, Phase}; -use srml_support::traits::Currency; - pub(crate) fn increase_total_balance_issuance_using_account_id(account_id: u64, balance: u64) { let initial_balance = Balances::total_issuance(); { @@ -132,7 +131,7 @@ impl DummyProposalFixture { } } - fn create_proposal_and_assert(self, result: Result) -> Option { + fn create_proposal_and_assert(self, result: Result) -> Option { let proposal_id_result = ProposalsEngine::create_proposal( self.account_id, self.proposer_id, @@ -174,7 +173,7 @@ impl CancelProposalFixture { } } - fn cancel_and_assert(self, expected_result: DispatchResult) { + fn cancel_and_assert(self, expected_result: DispatchResult) { assert_eq!( ProposalsEngine::cancel_proposal( self.origin.into(), @@ -202,7 +201,7 @@ impl VetoProposalFixture { VetoProposalFixture { origin, ..self } } - fn veto_and_assert(self, expected_result: DispatchResult) { + fn veto_and_assert(self, expected_result: DispatchResult) { assert_eq!( ProposalsEngine::veto_proposal(self.origin.into(), self.proposal_id,), expected_result @@ -230,11 +229,11 @@ impl VoteGenerator { self.vote_and_assert(vote_kind, Ok(())); } - fn vote_and_assert(&mut self, vote_kind: VoteKind, expected_result: DispatchResult) { + fn vote_and_assert(&mut self, vote_kind: VoteKind, expected_result: DispatchResult) { assert_eq!(self.vote(vote_kind.clone()), expected_result); } - fn vote(&mut self, vote_kind: VoteKind) -> DispatchResult { + fn vote(&mut self, vote_kind: VoteKind) -> DispatchResult { if self.auto_increment_voter_id { self.current_account_id += 1; self.current_voter_id += 1; @@ -255,7 +254,7 @@ impl EventFixture { let expected_events = expected_raw_events .iter() .map(|ev| EventRecord { - phase: Phase::ApplyExtrinsic(0), + phase: Phase::Initialization, event: TestEvent::engine(ev.clone()), topics: vec![], }) @@ -307,7 +306,7 @@ fn vote_fails_with_insufficient_rights() { initial_test_ext().execute_with(|| { assert_eq!( ProposalsEngine::vote(system::RawOrigin::None.into(), 1, 1, VoteKind::Approve), - Err(Error::Other("RequireSignedOrigin")) + Err(DispatchError::Other("Bad origin")) ); }); } @@ -338,8 +337,8 @@ fn proposal_execution_succeeds() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, - status: ProposalStatus::approved(ApprovedProposalStatus::Executed, 1), + created_at: 0, + status: ProposalStatus::approved(ApprovedProposalStatus::Executed, 0), title: b"title".to_vec(), description: b"description".to_vec(), voting_results: VotingResults { @@ -387,10 +386,10 @@ fn proposal_execution_failed() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, + created_at: 0, status: ProposalStatus::approved( ApprovedProposalStatus::failed_execution("ExecutionFailed"), - 1 + 0 ), title: b"title".to_vec(), description: b"description".to_vec(), @@ -457,7 +456,7 @@ fn rejected_voting_results_and_remove_proposal_id_from_active_succeeds() { vote_generator.vote_and_assert_ok(VoteKind::Abstain); vote_generator.vote_and_assert_ok(VoteKind::Abstain); - assert!(>::exists(proposal_id)); + assert!(>::contains_key(proposal_id)); // internal active proposal counter check assert_eq!(::get(), 1); @@ -478,9 +477,9 @@ fn rejected_voting_results_and_remove_proposal_id_from_active_succeeds() { assert_eq!( proposal.status, - ProposalStatus::finalized_successfully(ProposalDecisionStatus::Rejected, 1), + ProposalStatus::finalized_successfully(ProposalDecisionStatus::Rejected, 0), ); - assert!(!>::exists(proposal_id)); + assert!(!>::contains_key(proposal_id)); // internal active proposal counter check assert_eq!(::get(), 0); @@ -492,21 +491,22 @@ 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(Error::EmptyTitleProvided.into())); + dummy_proposal.create_proposal_and_assert(Err(Error::::EmptyTitleProvided.into())); dummy_proposal = DummyProposalFixture::default().with_title_and_body(b"title".to_vec(), Vec::new()); - dummy_proposal.create_proposal_and_assert(Err(Error::EmptyDescriptionProvided.into())); + dummy_proposal + .create_proposal_and_assert(Err(Error::::EmptyDescriptionProvided.into())); 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(Error::TitleIsTooLong.into())); + dummy_proposal.create_proposal_and_assert(Err(Error::::TitleIsTooLong.into())); 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(Error::DescriptionIsTooLong.into())); + dummy_proposal.create_proposal_and_assert(Err(Error::::DescriptionIsTooLong.into())); }); } @@ -519,7 +519,10 @@ 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(Error::ProposalFinalized)); + vote_generator.vote_and_assert( + VoteKind::Approve, + Err(Error::::ProposalFinalized.into()), + ); }); } @@ -538,7 +541,10 @@ fn vote_fails_with_not_active_proposal() { 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(Error::ProposalFinalized)); + vote_generator_to_fail.vote_and_assert( + VoteKind::Approve, + Err(Error::::ProposalFinalized.into()), + ); }); } @@ -546,7 +552,10 @@ fn vote_fails_with_not_active_proposal() { 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(Error::ProposalNotFound)); + vote_generator.vote_and_assert( + VoteKind::Approve, + Err(Error::::ProposalNotFound.into()), + ); }); } @@ -560,7 +569,7 @@ fn vote_fails_on_double_voting() { vote_generator.auto_increment_voter_id = false; vote_generator.vote_and_assert_ok(VoteKind::Approve); - vote_generator.vote_and_assert(VoteKind::Approve, Err(Error::AlreadyVoted)); + vote_generator.vote_and_assert(VoteKind::Approve, Err(Error::::AlreadyVoted.into())); }); } @@ -588,8 +597,8 @@ fn cancel_proposal_succeeds() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, - status: ProposalStatus::finalized_successfully(ProposalDecisionStatus::Canceled, 1), + created_at: 0, + status: ProposalStatus::finalized_successfully(ProposalDecisionStatus::Canceled, 0), title: b"title".to_vec(), description: b"description".to_vec(), voting_results: VotingResults::default(), @@ -607,7 +616,7 @@ fn cancel_proposal_fails_with_not_active_proposal() { run_to_block_and_finalize(6); let cancel_proposal = CancelProposalFixture::new(proposal_id); - cancel_proposal.cancel_and_assert(Err(Error::ProposalFinalized)); + cancel_proposal.cancel_and_assert(Err(Error::::ProposalFinalized.into())); }); } @@ -615,7 +624,7 @@ fn cancel_proposal_fails_with_not_active_proposal() { 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(Error::ProposalNotFound)); + cancel_proposal.cancel_and_assert(Err(Error::::ProposalNotFound.into())); }); } @@ -628,7 +637,7 @@ fn cancel_proposal_fails_with_insufficient_rights() { let cancel_proposal = CancelProposalFixture::new(proposal_id) .with_origin(RawOrigin::Signed(2)) .with_proposer(2); - cancel_proposal.cancel_and_assert(Err(Error::NotAuthor)); + cancel_proposal.cancel_and_assert(Err(Error::::NotAuthor.into())); }); } @@ -656,8 +665,8 @@ fn veto_proposal_succeeds() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, - status: ProposalStatus::finalized_successfully(ProposalDecisionStatus::Vetoed, 1), + created_at: 0, + status: ProposalStatus::finalized_successfully(ProposalDecisionStatus::Vetoed, 0), title: b"title".to_vec(), description: b"description".to_vec(), voting_results: VotingResults::default(), @@ -678,7 +687,7 @@ fn veto_proposal_fails_with_not_active_proposal() { run_to_block_and_finalize(6); let veto_proposal = VetoProposalFixture::new(proposal_id); - veto_proposal.veto_and_assert(Err(Error::ProposalFinalized)); + veto_proposal.veto_and_assert(Err(Error::::ProposalFinalized.into())); }); } @@ -686,7 +695,7 @@ fn veto_proposal_fails_with_not_active_proposal() { 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(Error::ProposalNotFound)); + veto_proposal.veto_and_assert(Err(Error::::ProposalNotFound.into())); }); } @@ -697,13 +706,16 @@ fn veto_proposal_fails_with_insufficient_rights() { let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap(); let veto_proposal = VetoProposalFixture::new(proposal_id).with_origin(RawOrigin::Signed(2)); - veto_proposal.veto_and_assert(Err(Error::RequireRootOrigin)); + veto_proposal.veto_and_assert(Err(DispatchError::BadOrigin)); }); } #[test] fn create_proposal_event_emitted() { initial_test_ext().execute_with(|| { + // Events start only from 1 first block. No events on block zero. + run_to_block_and_finalize(1); + let dummy_proposal = DummyProposalFixture::default(); dummy_proposal.create_proposal_and_assert(Ok(1)); @@ -714,6 +726,9 @@ fn create_proposal_event_emitted() { #[test] fn veto_proposal_event_emitted() { initial_test_ext().execute_with(|| { + // Events start only from 1 first block. No events on block zero. + run_to_block_and_finalize(1); + let dummy_proposal = DummyProposalFixture::default(); let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap(); @@ -733,6 +748,9 @@ fn veto_proposal_event_emitted() { #[test] fn cancel_proposal_event_emitted() { initial_test_ext().execute_with(|| { + // Events start only from 1 first block. No events on block zero. + run_to_block_and_finalize(1); + let dummy_proposal = DummyProposalFixture::default(); let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap(); @@ -757,6 +775,9 @@ fn cancel_proposal_event_emitted() { #[test] fn vote_proposal_event_emitted() { initial_test_ext().execute_with(|| { + // Events start only from 1 first block. No events on block zero. + run_to_block_and_finalize(1); + let dummy_proposal = DummyProposalFixture::default(); let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap(); @@ -787,8 +808,8 @@ fn create_proposal_and_expire_it() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, - status: ProposalStatus::finalized_successfully(ProposalDecisionStatus::Expired, 4), + created_at: 0, + status: ProposalStatus::finalized_successfully(ProposalDecisionStatus::Expired, 3), title: b"title".to_vec(), description: b"description".to_vec(), voting_results: VotingResults::default(), @@ -800,7 +821,7 @@ fn create_proposal_and_expire_it() { #[test] fn proposal_execution_postponed_because_of_grace_period() { initial_test_ext().execute_with(|| { - let parameters_fixture = ProposalParametersFixture::default().with_grace_period(2); + let parameters_fixture = ProposalParametersFixture::default().with_grace_period(3); let dummy_proposal = DummyProposalFixture::default().with_parameters(parameters_fixture.params()); @@ -815,10 +836,10 @@ fn proposal_execution_postponed_because_of_grace_period() { run_to_block_and_finalize(1); run_to_block_and_finalize(2); - // check internal cache for proposal_id presense - assert!(>::enumerate() - .find(|(x, _)| *x == proposal_id) - .is_some()); + // check internal cache for proposal_id presence + assert!(>::contains_key( + proposal_id + )); let proposal = >::get(proposal_id); @@ -827,8 +848,8 @@ fn proposal_execution_postponed_because_of_grace_period() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, - status: ProposalStatus::approved(ApprovedProposalStatus::PendingExecution, 1), + created_at: 0, + status: ProposalStatus::approved(ApprovedProposalStatus::PendingExecution, 0), title: b"title".to_vec(), description: b"description".to_vec(), voting_results: VotingResults { @@ -845,7 +866,7 @@ fn proposal_execution_postponed_because_of_grace_period() { #[test] fn proposal_execution_vetoed_successfully_during_the_grace_period() { initial_test_ext().execute_with(|| { - let parameters_fixture = ProposalParametersFixture::default().with_grace_period(2); + let parameters_fixture = ProposalParametersFixture::default().with_grace_period(3); let dummy_proposal = DummyProposalFixture::default().with_parameters(parameters_fixture.params()); @@ -860,10 +881,10 @@ fn proposal_execution_vetoed_successfully_during_the_grace_period() { run_to_block_and_finalize(1); run_to_block_and_finalize(2); - // check internal cache for proposal_id presense - assert!(>::enumerate() - .find(|(x, _)| *x == proposal_id) - .is_some()); + // check internal cache for proposal_id presence + assert!(>::contains_key( + proposal_id + )); let proposal = >::get(proposal_id); @@ -872,8 +893,8 @@ fn proposal_execution_vetoed_successfully_during_the_grace_period() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, - status: ProposalStatus::approved(ApprovedProposalStatus::PendingExecution, 1), + created_at: 0, + status: ProposalStatus::approved(ApprovedProposalStatus::PendingExecution, 0), title: b"title".to_vec(), description: b"description".to_vec(), voting_results: VotingResults { @@ -895,7 +916,7 @@ fn proposal_execution_vetoed_successfully_during_the_grace_period() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, + created_at: 0, status: ProposalStatus::finalized_successfully(ProposalDecisionStatus::Vetoed, 2), title: b"title".to_vec(), description: b"description".to_vec(), @@ -908,17 +929,17 @@ fn proposal_execution_vetoed_successfully_during_the_grace_period() { } ); - // check internal cache for proposal_id presense - assert!(>::enumerate() - .find(|(x, _)| *x == proposal_id) - .is_none()); + // check internal cache for proposal_id absence + assert!(!>::contains_key( + proposal_id + )); }); } #[test] fn proposal_execution_succeeds_after_the_grace_period() { initial_test_ext().execute_with(|| { - let parameters_fixture = ProposalParametersFixture::default().with_grace_period(1); + let parameters_fixture = ProposalParametersFixture::default().with_grace_period(2); let dummy_proposal = DummyProposalFixture::default().with_parameters(parameters_fixture.params()); let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap(); @@ -932,17 +953,17 @@ fn proposal_execution_succeeds_after_the_grace_period() { run_to_block_and_finalize(1); // check internal cache for proposal_id presence - assert!(>::enumerate() - .find(|(x, _)| *x == proposal_id) - .is_some()); + assert!(>::contains_key( + proposal_id + )); let mut proposal = >::get(proposal_id); let mut expected_proposal = Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, - status: ProposalStatus::approved(ApprovedProposalStatus::PendingExecution, 1), + created_at: 0, + status: ProposalStatus::approved(ApprovedProposalStatus::PendingExecution, 0), title: b"title".to_vec(), description: b"description".to_vec(), voting_results: VotingResults { @@ -959,14 +980,14 @@ fn proposal_execution_succeeds_after_the_grace_period() { proposal = >::get(proposal_id); - expected_proposal.status = ProposalStatus::approved(ApprovedProposalStatus::Executed, 1); + expected_proposal.status = ProposalStatus::approved(ApprovedProposalStatus::Executed, 0); assert_eq!(proposal, expected_proposal); - // check internal cache for proposal_id absense - assert!(>::enumerate() - .find(|(x, _)| *x == proposal_id) - .is_none()); + // check internal cache for proposal_id absence + assert!(!>::contains_key( + proposal_id + )); }); } @@ -982,7 +1003,7 @@ fn create_proposal_fails_on_exceeding_max_active_proposals_count() { let dummy_proposal = DummyProposalFixture::default(); dummy_proposal - .create_proposal_and_assert(Err(Error::MaxActiveProposalNumberExceeded.into())); + .create_proposal_and_assert(Err(Error::::MaxActiveProposalNumberExceeded.into())); // internal active proposal counter check assert_eq!(::get(), 100); }); @@ -1004,7 +1025,7 @@ fn voting_internal_cache_exists_after_proposal_finalization() { vote_generator.vote_and_assert_ok(VoteKind::Abstain); // cache exists - assert!(>::exists( + assert!(>::contains_key( proposal_id, 1 )); @@ -1012,7 +1033,7 @@ fn voting_internal_cache_exists_after_proposal_finalization() { run_to_block_and_finalize(2); // cache still exists and is not cleared - assert!(>::exists( + assert!(>::contains_key( proposal_id, 1 )); @@ -1044,7 +1065,7 @@ fn create_dummy_proposal_succeeds_with_stake() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, + created_at: 0, status: ProposalStatus::Active(Some(ActiveStake { stake_id: 0, // valid stake_id source_account_id: 1 @@ -1070,8 +1091,7 @@ fn create_dummy_proposal_fail_with_stake_on_empty_account() { .with_account_id(account_id) .with_stake(required_stake); - dummy_proposal - .create_proposal_and_assert(Err(Error::Other("too few free funds in account"))); + dummy_proposal.create_proposal_and_assert(Err(DispatchError::Other("InsufficientBalance"))); }); } @@ -1084,20 +1104,21 @@ fn create_proposal_fais_with_invalid_stake_parameters() { .with_parameters(parameters_fixture.params()) .with_stake(200); - dummy_proposal.create_proposal_and_assert(Err(Error::StakeShouldBeEmpty.into())); + dummy_proposal.create_proposal_and_assert(Err(Error::::StakeShouldBeEmpty.into())); let parameters_fixture_stake_200 = parameters_fixture.with_required_stake(200); dummy_proposal = DummyProposalFixture::default().with_parameters(parameters_fixture_stake_200.params()); - dummy_proposal.create_proposal_and_assert(Err(Error::EmptyStake.into())); + dummy_proposal.create_proposal_and_assert(Err(Error::::EmptyStake.into())); let parameters_fixture_stake_300 = parameters_fixture.with_required_stake(300); dummy_proposal = DummyProposalFixture::default() .with_parameters(parameters_fixture_stake_300.params()) .with_stake(200); - dummy_proposal.create_proposal_and_assert(Err(Error::StakeDiffersFromRequired.into())); + dummy_proposal + .create_proposal_and_assert(Err(Error::::StakeDiffersFromRequired.into())); }); } @@ -1141,7 +1162,7 @@ fn finalize_expired_proposal_and_check_stake_removing_with_balance_checks_succee let mut expected_proposal = Proposal { parameters, proposer_id: 1, - created_at: 1, + created_at: 0, status: ProposalStatus::Active(Some(ActiveStake { stake_id: 0, source_account_id: 1, @@ -1159,7 +1180,7 @@ fn finalize_expired_proposal_and_check_stake_removing_with_balance_checks_succee expected_proposal.status = ProposalStatus::Finalized(FinalizationData { proposal_status: ProposalDecisionStatus::Expired, - finalized_at: 4, + finalized_at: 3, encoded_unstaking_error_due_to_broken_runtime: None, stake_data_after_unstaking_error: None, }); @@ -1214,7 +1235,7 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() { let mut expected_proposal = Proposal { parameters, proposer_id: 1, - created_at: 1, + created_at: 0, status: ProposalStatus::Active(Some(ActiveStake { stake_id: 0, source_account_id: 1, @@ -1234,7 +1255,7 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() { expected_proposal.status = ProposalStatus::Finalized(FinalizationData { proposal_status: ProposalDecisionStatus::Canceled, - finalized_at: 1, + finalized_at: 0, encoded_unstaking_error_due_to_broken_runtime: None, stake_data_after_unstaking_error: None, }); @@ -1302,7 +1323,7 @@ fn proposal_slashing_succeeds() { vote_generator.vote_and_assert_ok(VoteKind::Slash); vote_generator.vote_and_assert_ok(VoteKind::Slash); - assert!(>::exists(proposal_id)); + assert!(>::contains_key(proposal_id)); run_to_block_and_finalize(2); @@ -1323,11 +1344,11 @@ fn proposal_slashing_succeeds() { ProposalStatus::Finalized(FinalizationData { proposal_status: ProposalDecisionStatus::Slashed, encoded_unstaking_error_due_to_broken_runtime: None, - finalized_at: 1, + finalized_at: 0, stake_data_after_unstaking_error: None, }), ); - assert!(!>::exists(proposal_id)); + assert!(!>::contains_key(proposal_id)); }); } @@ -1377,7 +1398,7 @@ fn finalize_proposal_using_stake_mocks_failed() { Proposal { parameters: parameters_fixture.params(), proposer_id: 1, - created_at: 1, + created_at: 0, status: ProposalStatus::finalized( ProposalDecisionStatus::Expired, Some("Cannot remove stake"), @@ -1385,7 +1406,7 @@ fn finalize_proposal_using_stake_mocks_failed() { stake_id: 1, source_account_id: 1 }), - 4, + 3, ), title: b"title".to_vec(), description: b"description".to_vec(), @@ -1411,15 +1432,17 @@ fn create_proposal_fails_with_invalid_threshold_parameters() { let mut dummy_proposal = DummyProposalFixture::default().with_parameters(parameters); - dummy_proposal - .create_proposal_and_assert(Err(Error::InvalidParameterApprovalThreshold.into())); + dummy_proposal.create_proposal_and_assert(Err( + Error::::InvalidParameterApprovalThreshold.into(), + )); parameters.approval_threshold_percentage = 60; parameters.slashing_threshold_percentage = 0; dummy_proposal = DummyProposalFixture::default().with_parameters(parameters); - dummy_proposal - .create_proposal_and_assert(Err(Error::InvalidParameterSlashingThreshold.into())); + dummy_proposal.create_proposal_and_assert(Err( + Error::::InvalidParameterSlashingThreshold.into(), + )); }); } @@ -1434,7 +1457,7 @@ fn proposal_reset_succeeds() { vote_generator.vote_and_assert_ok(VoteKind::Abstain); vote_generator.vote_and_assert_ok(VoteKind::Slash); - assert!(>::exists(proposal_id)); + assert!(>::contains_key(proposal_id)); assert_eq!( >::get(&proposal_id, &2), VoteKind::Abstain diff --git a/runtime-modules/proposals/engine/src/types/mod.rs b/runtime-modules/proposals/engine/src/types/mod.rs index d6ad1a8c73..ae8dd5d269 100644 --- a/runtime-modules/proposals/engine/src/types/mod.rs +++ b/runtime-modules/proposals/engine/src/types/mod.rs @@ -4,15 +4,15 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; -use rstd::cmp::PartialOrd; -use rstd::ops::Add; -use rstd::prelude::*; - +use frame_support::dispatch::DispatchResult; +use frame_support::traits::Currency; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use sr_primitives::Perbill; -use srml_support::dispatch; -use srml_support::traits::Currency; +use sp_runtime::Perbill; +use sp_std::boxed::Box; +use sp_std::cmp::PartialOrd; +use sp_std::ops::Add; +use sp_std::vec::Vec; mod proposal_statuses; mod stakes; @@ -304,7 +304,7 @@ where /// Proposal executable code wrapper pub trait ProposalExecutable { /// Executes proposal code - fn execute(&self) -> dispatch::Result; + fn execute(&self) -> DispatchResult; } /// Proposal code binary converter diff --git a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs index 4deb8b647d..ad5dfbdf11 100644 --- a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs +++ b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs @@ -1,11 +1,11 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; -use rstd::prelude::*; - -use crate::ActiveStake; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; +use sp_std::vec::Vec; + +use crate::ActiveStake; /// Current status of the proposal #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] diff --git a/runtime-modules/proposals/engine/src/types/stakes.rs b/runtime-modules/proposals/engine/src/types/stakes.rs index 88a378981b..a0fab9df52 100644 --- a/runtime-modules/proposals/engine/src/types/stakes.rs +++ b/runtime-modules/proposals/engine/src/types/stakes.rs @@ -2,10 +2,10 @@ use super::{BalanceOf, CurrencyOf, NegativeImbalance}; use crate::Trait; -use rstd::convert::From; -use rstd::marker::PhantomData; -use rstd::rc::Rc; -use srml_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; +use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; +use sp_std::convert::From; +use sp_std::marker::PhantomData; +use sp_std::rc::Rc; // Mocking dependencies for testing #[cfg(test)] @@ -123,6 +123,7 @@ impl StakeHandler for DefaultStakeHandler { WithdrawReasons::all(), ExistenceRequirement::AllowDeath, ) + .map_err(<&str>::from) } } diff --git a/runtime-modules/recurring-reward/Cargo.toml b/runtime-modules/recurring-reward/Cargo.toml index 10caf40b43..401f4824fb 100755 --- a/runtime-modules/recurring-reward/Cargo.toml +++ b/runtime-modules/recurring-reward/Cargo.toml @@ -1,56 +1,29 @@ [package] -name = 'substrate-recurring-reward-module' -version = '1.0.1' +name = 'pallet-recurring-reward' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' [dependencies] -hex-literal = '0.1.0' -serde = { version = '1.0', optional = true } -serde_derive = { version = '1.0', optional = true } -rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] } -# https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -quote = '<=1.0.2' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.minting] -default_features = false -package = 'substrate-token-mint-module' -path = '../token-minting' +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'} [dev-dependencies] -runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [features] default = ['std'] std = [ - 'serde', - 'serde_derive', 'codec/std', - 'rstd/std', - 'runtime-io/std', - 'runtime-primitives/std', - 'srml-support/std', + 'sp-arithmetic/std', + 'sp-runtime/std', + 'frame-support/std', 'system/std', - 'balances/std', - 'timestamp/std', 'minting/std', ] diff --git a/runtime-modules/recurring-reward/src/lib.rs b/runtime-modules/recurring-reward/src/lib.rs index 946e0b75a3..a9fe50ccda 100755 --- a/runtime-modules/recurring-reward/src/lib.rs +++ b/runtime-modules/recurring-reward/src/lib.rs @@ -7,13 +7,14 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; use codec::{Codec, Decode, Encode}; -use runtime_primitives::traits::{MaybeSerialize, Member, One, SimpleArithmetic, Zero}; -use srml_support::{decl_module, decl_storage, ensure, Parameter}; +use frame_support::storage::IterableStorageMap; +use frame_support::{decl_module, decl_storage, ensure, Parameter}; +use sp_arithmetic::traits::{BaseArithmetic, One, Zero}; +use sp_runtime::traits::{MaybeSerialize, Member}; -use minting::{self, BalanceOf}; +use minting::BalanceOf; mod mock; mod tests; @@ -24,7 +25,7 @@ pub trait Trait: system::Trait + minting::Trait { /// Type of identifier for recipients. type RecipientId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -34,7 +35,7 @@ pub trait Trait: system::Trait + minting::Trait { /// Type for identifier for relationship representing that a recipient recieves recurring reward from a token mint type RewardRelationshipId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -142,13 +143,15 @@ impl as RecurringReward { - Recipients get(recipients): linked_map T::RecipientId => Recipient>; + Recipients get(fn recipients): map hasher(blake2_128_concat) + T::RecipientId => Recipient>; - RecipientsCreated get(recipients_created): T::RecipientId; + RecipientsCreated get(fn recipients_created): T::RecipientId; - pub RewardRelationships get(reward_relationships): linked_map T::RewardRelationshipId => RewardRelationship, T::BlockNumber, T::MintId, T::RecipientId>; + pub RewardRelationships get(fn reward_relationships): map hasher(blake2_128_concat) + T::RewardRelationshipId => RewardRelationship, T::BlockNumber, T::MintId, T::RecipientId>; - RewardRelationshipsCreated get(reward_relationships_created): T::RewardRelationshipId; + RewardRelationshipsCreated get(fn reward_relationships_created): T::RewardRelationshipId; } } @@ -192,7 +195,7 @@ impl Module { RewardsError::RewardSourceNotFound ); ensure!( - >::exists(recipient), + >::contains_key(recipient), RewardsError::RecipientNotFound ); ensure!( @@ -220,7 +223,7 @@ impl Module { /// Removes a relationship from RewardRelashionships and its recipient. pub fn remove_reward_relationship(id: T::RewardRelationshipId) { - if >::exists(&id) { + if >::contains_key(&id) { >::remove(>::take(&id).recipient); } } @@ -282,7 +285,7 @@ impl Module { new_payout_interval: Option>, ) -> Result<(), RewardsError> { ensure!( - >::exists(&id), + >::contains_key(&id), RewardsError::RewardRelationshipNotFound ); @@ -320,8 +323,8 @@ impl Module { Otherwise, analogous steps for failure. */ fn do_payouts(now: T::BlockNumber) { - for (relationship_id, ref mut relationship) in >::enumerate() { - assert!(>::exists(&relationship.recipient)); + for (relationship_id, ref mut relationship) in >::iter() { + assert!(>::contains_key(&relationship.recipient)); let mut recipient = Self::recipients(relationship.recipient); @@ -394,7 +397,7 @@ impl Module { RewardRelationship, T::BlockNumber, T::MintId, T::RecipientId>, (), > { - ensure!(RewardRelationships::::exists(id), ()); + ensure!(RewardRelationships::::contains_key(id), ()); let relationship = RewardRelationships::::get(id); diff --git a/runtime-modules/recurring-reward/src/mock/mod.rs b/runtime-modules/recurring-reward/src/mock/mod.rs index de454a72cc..0f54d38462 100644 --- a/runtime-modules/recurring-reward/src/mock/mod.rs +++ b/runtime-modules/recurring-reward/src/mock/mod.rs @@ -1,18 +1,16 @@ #![cfg(test)] -// use crate::*; use crate::{Module, Trait}; -use primitives::H256; - use balances; +use frame_support::{impl_outer_origin, parameter_types}; use minting; -use runtime_primitives::{ +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{impl_outer_origin, parameter_types}; mod status_handler; pub use status_handler::MockStatusHandler; @@ -33,10 +31,11 @@ parameter_types! { } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -45,34 +44,29 @@ impl system::Trait for Test { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } 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; } 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 Event = (); type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl Trait for Test { @@ -86,7 +80,7 @@ impl minting::Trait for Test { type MintId = u64; } -pub fn build_test_externalities() -> runtime_io::TestExternalities { +pub fn build_test_externalities() -> sp_io::TestExternalities { MockStatusHandler::reset(); let t = system::GenesisConfig::default() diff --git a/runtime-modules/recurring-reward/src/tests.rs b/runtime-modules/recurring-reward/src/tests.rs index 8326682b68..3546602dbd 100644 --- a/runtime-modules/recurring-reward/src/tests.rs +++ b/runtime-modules/recurring-reward/src/tests.rs @@ -2,7 +2,7 @@ use super::*; use crate::mock::*; -use srml_support::traits::Currency; +use frame_support::traits::Currency; fn create_new_mint_with_capacity(capacity: u64) -> u64 { let mint_id = Minting::add_mint(capacity, None).ok().unwrap(); @@ -15,9 +15,9 @@ fn create_new_mint_with_capacity(capacity: u64) -> u64 { fn adding_recipients() { build_test_externalities().execute_with(|| { let next_id = Rewards::recipients_created(); - assert!(!>::exists(&next_id)); + assert!(!>::contains_key(&next_id)); let recipient_id = Rewards::add_recipient(); - assert!(>::exists(&next_id)); + assert!(>::contains_key(&next_id)); assert_eq!(recipient_id, next_id); assert_eq!(Rewards::recipients_created(), next_id + 1); }); @@ -49,7 +49,7 @@ fn adding_relationships() { Rewards::reward_relationships_created(), next_relationship_id + 1 ); - assert!(>::exists(&relationship_id)); + assert!(>::contains_key(&relationship_id)); let relationship = Rewards::reward_relationships(&relationship_id); assert_eq!(relationship.next_payment_at_block, Some(next_payment_at)); assert_eq!(relationship.amount_per_payout, payout); diff --git a/runtime-modules/service-discovery/Cargo.toml b/runtime-modules/service-discovery/Cargo.toml index 2be3b58a24..74251e094a 100644 --- a/runtime-modules/service-discovery/Cargo.toml +++ b/runtime-modules/service-discovery/Cargo.toml @@ -1,112 +1,38 @@ [package] -name = 'substrate-service-discovery-module' -version = '2.0.0' +name = 'pallet-service-discovery' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +membership = { package = 'pallet-membership', default-features = false, path = '../membership'} +stake = { package = 'pallet-stake', default-features = false, path = '../stake'} +hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'} +minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'} +recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'} +common = { package = 'pallet-common', default-features = false, path = '../common'} + [features] default = ['std'] std = [ - 'sr-primitives/std', - 'srml-support/std', - 'system/std', - 'rstd/std', 'serde', - 'codec/std', - 'primitives/std', - 'working-group/std', -] - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../common' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.working-group] -default_features = false -package = 'substrate-working-group-module' -path = '../working-group' - -[dev-dependencies.balances] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-balances' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.recurringrewards] -default_features = false -package = 'substrate-recurring-reward-module' -path = '../recurring-reward' - -[dev-dependencies.hiring] -default_features = false -package = 'substrate-hiring-module' -path = '../hiring' - -[dev-dependencies.stake] -default_features = false -package = 'substrate-stake-module' -path = '../stake' - -[dev-dependencies.minting] -default_features = false -package = 'substrate-token-mint-module' -path = '../token-minting' - -[dev-dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../membership' - -[dev-dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' \ No newline at end of file + 'codec/std', + 'sp-std/std', + 'frame-support/std', + 'system/std', + 'sp-runtime/std', + 'working-group/std', +] \ No newline at end of file diff --git a/runtime-modules/service-discovery/src/lib.rs b/runtime-modules/service-discovery/src/lib.rs index ed5dce3c4a..9e8c54b472 100644 --- a/runtime-modules/service-discovery/src/lib.rs +++ b/runtime-modules/service-discovery/src/lib.rs @@ -10,8 +10,8 @@ //! //! ## Supported extrinsics //! -//! - [set_ipns_id](./struct.Module.html#method.set_ipns_id) - Creates the AccountInfo to save an IPNS identity for the storage provider. -//! - [unset_ipns_id](./struct.Module.html#method.unset_ipns_id) - Deletes the AccountInfo with the IPNS identity for the storage provider. +//! - [set_ipns_id](./struct.Module.html#method.set_ipns_id) - Creates the ServiceProviderRecord to save an IPNS identity for the storage provider. +//! - [unset_ipns_id](./struct.Module.html#method.unset_ipns_id) - Deletes the ServiceProviderRecord with the IPNS identity for the storage provider. //! - [set_default_lifetime](./struct.Module.html#method.set_default_lifetime) - Sets default lifetime for storage providers accounts info. //! - [set_bootstrap_endpoints](./struct.Module.html#method.set_bootstrap_endpoints) - Sets bootstrap endpoints for the Colossus. //! @@ -23,12 +23,12 @@ mod mock; mod tests; use codec::{Decode, Encode}; -use rstd::prelude::*; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use srml_support::{decl_event, decl_module, decl_storage, ensure}; -use system::{self, ensure_root}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use sp_std::vec::Vec; +use system::ensure_root; /* Although there is support for ed25519 keys as the IPNS identity key and we could potentially reuse the same key for the role account and ipns (and make this discovery module obselete) @@ -63,7 +63,7 @@ pub(crate) const DEFAULT_LIFETIME: u32 = MINIMUM_LIFETIME * 24; // 24hr /// Defines the expiration date for the storage provider. #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq)] -pub struct AccountInfo { +pub struct ServiceProviderRecord { /// IPNS Identity. pub identity: IPNSIdentity, /// Block at which information expires. @@ -79,14 +79,14 @@ pub trait Trait: system::Trait + working_group::Trait as Discovery { /// Bootstrap endpoints maintained by root - pub BootstrapEndpoints get(bootstrap_endpoints): Vec; + pub BootstrapEndpoints get(fn bootstrap_endpoints): Vec; - /// Mapping of service providers' storage provider id to their AccountInfo - pub AccountInfoByStorageProviderId get(account_info_by_storage_provider_id): - map StorageProviderId => AccountInfo; + /// Mapping of service providers' storage provider id to their ServiceProviderRecord + pub AccountInfoByStorageProviderId get(fn account_info_by_storage_provider_id): + map hasher(blake2_128_concat) StorageProviderId => ServiceProviderRecord; - /// Lifetime of an AccountInfo record in AccountInfoByAccountId map - pub DefaultLifetime get(default_lifetime) config(): + /// Lifetime of an ServiceProviderRecord record in AccountInfoByAccountId map + pub DefaultLifetime get(fn default_lifetime) config(): T::BlockNumber = T::BlockNumber::from(DEFAULT_LIFETIME); } } @@ -115,8 +115,9 @@ decl_module! { /// Default deposit_event() handler fn deposit_event() = default; - /// Creates the AccountInfo to save an IPNS identity for the storage provider. + /// Creates the ServiceProviderRecord to save an IPNS identity for the storage provider. /// Requires signed storage provider credentials. + #[weight = 10_000_000] // TODO: adjust weight pub fn set_ipns_id( origin, storage_provider_id: StorageProviderId, @@ -130,7 +131,7 @@ decl_module! { // == MUTATION SAFE == // - >::insert(storage_provider_id, AccountInfo { + >::insert(storage_provider_id, ServiceProviderRecord { identity: id.clone(), expires_at: >::block_number() + Self::default_lifetime(), }); @@ -138,14 +139,15 @@ decl_module! { Self::deposit_event(RawEvent::AccountInfoUpdated(storage_provider_id, id)); } - /// Deletes the AccountInfo with the IPNS identity for the storage provider. + /// Deletes the ServiceProviderRecord with the IPNS identity for the storage provider. /// Requires signed storage provider credentials. + #[weight = 10_000_000] // TODO: adjust weight pub fn unset_ipns_id(origin, storage_provider_id: StorageProviderId) { >::ensure_worker_signed(origin, &storage_provider_id)?; // == MUTATION SAFE == - if >::exists(storage_provider_id) { + if >::contains_key(storage_provider_id) { >::remove(storage_provider_id); Self::deposit_event(RawEvent::AccountInfoRemoved(storage_provider_id)); } @@ -154,6 +156,7 @@ decl_module! { // Privileged methods /// Sets default lifetime for storage providers accounts info. Requires root privileges. + #[weight = 10_000_000] // TODO: adjust weight pub fn set_default_lifetime(origin, lifetime: T::BlockNumber) { ensure_root(origin)?; ensure!(lifetime >= T::BlockNumber::from(MINIMUM_LIFETIME), @@ -165,6 +168,7 @@ decl_module! { } /// Sets bootstrap endpoints for the Colossus. Requires root privileges. + #[weight = 10_000_000] // TODO: adjust weight pub fn set_bootstrap_endpoints(origin, endpoints: Vec) { ensure_root(origin)?; @@ -178,7 +182,7 @@ decl_module! { impl Module { /// Verifies that account info for the storage provider is still valid. pub fn is_account_info_expired(storage_provider_id: &StorageProviderId) -> bool { - !>::exists(storage_provider_id) + !>::contains_key(storage_provider_id) || >::block_number() > >::get(storage_provider_id).expires_at } diff --git a/runtime-modules/service-discovery/src/mock.rs b/runtime-modules/service-discovery/src/mock.rs index e0e0df8222..d5dcdadf86 100644 --- a/runtime-modules/service-discovery/src/mock.rs +++ b/runtime-modules/service-discovery/src/mock.rs @@ -2,15 +2,14 @@ pub use crate::*; -pub use primitives::{Blake2Hasher, H256}; -pub use sr_primitives::{ - testing::{Digest, DigestItem, Header, UintAuthorityId}, - traits::{BlakeTwo256, IdentityLookup, OnFinalize}, - BuildStorage, Perbill, +use frame_support::{impl_outer_event, impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, }; -use srml_support::{impl_outer_event, impl_outer_origin, parameter_types}; - // The storage working group instance alias. pub type StorageWorkingGroupInstance = working_group::Instance2; @@ -37,7 +36,8 @@ impl_outer_event! { discovery, balances, membership_mod, - working_group_mod StorageWorkingGroupInstance , + working_group_mod StorageWorkingGroupInstance , + system, } } @@ -52,15 +52,14 @@ parameter_types! { pub const MinimumPeriod: u64 = 5; pub const StakePoolId: [u8; 8] = *b"joystake"; pub const ExistentialDeposit: u32 = 0; - pub const TransferFee: u32 = 0; - pub const CreationFee: u32 = 0; } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -69,9 +68,17 @@ impl system::Trait for Test { type Event = MetaEvent; type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } impl Trait for Test { @@ -112,14 +119,10 @@ impl common::currency::GovernanceCurrency for Test { impl balances::Trait for Test { type Balance = u64; - type OnFreeBalanceZero = (); - type OnNewAccount = (); - type TransferPayment = (); type DustRemoval = (); type Event = MetaEvent; type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl recurringrewards::Trait for Test { @@ -137,13 +140,13 @@ impl working_group::Trait for Test { type MaxWorkerNumberLimit = MaxWorkerNumberLimit; } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; } -pub fn initial_test_ext() -> runtime_io::TestExternalities { +pub fn initial_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime-modules/service-discovery/src/tests.rs b/runtime-modules/service-discovery/src/tests.rs index 906e889c16..969dc51ce2 100644 --- a/runtime-modules/service-discovery/src/tests.rs +++ b/runtime-modules/service-discovery/src/tests.rs @@ -2,8 +2,7 @@ use super::mock::*; -use srml_support::*; -use system::{self, EventRecord, Phase}; +use system::{EventRecord, Phase, RawOrigin}; #[test] fn set_ipns_id() { @@ -22,13 +21,13 @@ fn set_ipns_id() { ) .is_ok()); - assert!(>::exists( + assert!(>::contains_key( &storage_provider_id )); let account_info = Discovery::account_info_by_storage_provider_id(&storage_provider_id); assert_eq!( account_info, - AccountInfo { + ServiceProviderRecord { identity: identity.clone(), expires_at: current_block_number + ttl } @@ -37,7 +36,7 @@ fn set_ipns_id() { assert_eq!( *System::events().last().unwrap(), EventRecord { - phase: Phase::ApplyExtrinsic(0), + phase: Phase::Initialization, event: MetaEvent::discovery(RawEvent::AccountInfoUpdated( storage_provider_id, identity.clone() @@ -55,7 +54,7 @@ fn set_ipns_id() { identity.clone(), ) .is_err()); - assert!(!>::exists( + assert!(!>::contains_key( &invalid_storage_provider_id )); }); @@ -64,17 +63,20 @@ fn set_ipns_id() { #[test] fn unset_ipns_id() { initial_test_ext().execute_with(|| { + let current_block_number = 1000; + System::set_block_number(current_block_number); + let (storage_provider_account_id, storage_provider_id) = hire_storage_provider(); >::insert( &storage_provider_id, - AccountInfo { + ServiceProviderRecord { expires_at: 1000, identity: "alice".as_bytes().to_vec(), }, ); - assert!(>::exists( + assert!(>::contains_key( &storage_provider_account_id )); @@ -83,14 +85,14 @@ fn unset_ipns_id() { storage_provider_id ) .is_ok()); - assert!(!>::exists( + assert!(!>::contains_key( &storage_provider_account_id )); assert_eq!( *System::events().last().unwrap(), EventRecord { - phase: Phase::ApplyExtrinsic(0), + phase: Phase::Initialization, event: MetaEvent::discovery(RawEvent::AccountInfoRemoved(storage_provider_id)), topics: vec![] } @@ -104,7 +106,7 @@ fn unset_ipns_id() { invalid_storage_provider_account_id, ) .is_err()); - assert!(!>::exists( + assert!(!>::contains_key( &invalid_storage_provider_id )); }); @@ -118,7 +120,7 @@ fn is_account_info_expired() { let id = "alice".as_bytes().to_vec(); >::insert( &storage_provider_id, - AccountInfo { + ServiceProviderRecord { expires_at, identity: id.clone(), }, @@ -142,7 +144,7 @@ fn set_default_lifetime() { "" ); assert!( - Discovery::set_default_lifetime(Origin::ROOT, lifetime).is_ok(), + Discovery::set_default_lifetime(RawOrigin::Root.into(), lifetime).is_ok(), "" ); assert_eq!(Discovery::default_lifetime(), lifetime, ""); @@ -151,7 +153,8 @@ fn set_default_lifetime() { let less_than_min_lifetime = ::BlockNumber::from(MINIMUM_LIFETIME - 1); assert!( - Discovery::set_default_lifetime(Origin::ROOT, less_than_min_lifetime).is_err(), + Discovery::set_default_lifetime(RawOrigin::Root.into(), less_than_min_lifetime) + .is_err(), "" ); }); @@ -167,7 +170,7 @@ fn set_bootstrap_endpoints() { "" ); assert!( - Discovery::set_bootstrap_endpoints(Origin::ROOT, endpoints.clone()).is_ok(), + Discovery::set_bootstrap_endpoints(RawOrigin::Root.into(), endpoints.clone()).is_ok(), "" ); assert_eq!(Discovery::bootstrap_endpoints(), endpoints, ""); diff --git a/runtime-modules/stake/Cargo.toml b/runtime-modules/stake/Cargo.toml index d8de052e4c..6fac094f40 100755 --- a/runtime-modules/stake/Cargo.toml +++ b/runtime-modules/stake/Cargo.toml @@ -1,50 +1,30 @@ [package] -name = 'substrate-stake-module' -version = '2.0.0' +name = 'pallet-stake' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' [dependencies] -hex-literal = '0.1.0' -serde = { version = '1.0', optional = true } -serde_derive = { version = '1.0', optional = true } -rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] } -# https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -quote = '<=1.0.2' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [dev-dependencies] -runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [features] default = ['std'] std = [ - 'serde', - 'serde_derive', 'codec/std', - 'rstd/std', - 'runtime-io/std', - 'runtime-primitives/std', - 'srml-support/std', + 'sp-std/std', + 'frame-support/std', 'system/std', - 'balances/std', - 'timestamp/std', -] + 'sp-arithmetic/std', + 'sp-runtime/std', +] \ No newline at end of file diff --git a/runtime-modules/stake/src/lib.rs b/runtime-modules/stake/src/lib.rs index 572175ef3c..85edee31e5 100755 --- a/runtime-modules/stake/src/lib.rs +++ b/runtime-modules/stake/src/lib.rs @@ -1,17 +1,15 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; - use codec::{Codec, Decode, Encode}; -use runtime_primitives::traits::{ - AccountIdConversion, MaybeSerialize, Member, One, SimpleArithmetic, Zero, -}; -use runtime_primitives::ModuleId; -use srml_support::traits::{Currency, ExistenceRequirement, Get, Imbalance, WithdrawReasons}; -use srml_support::{decl_module, decl_storage, ensure, Parameter}; - -use rstd::collections::btree_map::BTreeMap; +use frame_support::storage::IterableStorageMap; +use frame_support::traits::{Currency, ExistenceRequirement, Get, Imbalance, WithdrawReasons}; +use frame_support::{decl_module, decl_storage, ensure, Parameter}; +use sp_arithmetic::traits::{BaseArithmetic, One, Zero}; +use sp_runtime::traits::{AccountIdConversion, MaybeSerialize, Member}; +use sp_runtime::ModuleId; +use sp_std::collections::btree_map::BTreeMap; +use sp_std::prelude::*; mod errors; pub use errors::*; @@ -38,7 +36,7 @@ pub trait Trait: system::Trait + Sized { /// The type used as a stake identifier. type StakeId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -48,7 +46,7 @@ pub trait Trait: system::Trait + Sized { /// The type used as slash identifier. type SlashId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -201,8 +199,8 @@ pub struct StakedState { impl StakedState where - BlockNumber: SimpleArithmetic + Copy, - Balance: SimpleArithmetic + Copy, + BlockNumber: BaseArithmetic + Copy, + Balance: BaseArithmetic + Copy, SlashId: Ord + Copy, { /// Iterates over all ongoing slashes and decrements blocks_remaining_in_active_period_for_slashing of active slashes (advancing the timer). @@ -268,7 +266,7 @@ where /// For all slahes that should be executed, will apply the Slash to the staked amount, and drop it from the ongoing slashes map. /// Returns a vector of the executed slashes outcome: (SlashId, Slashed Amount, Remaining Staked Amount) fn finalize_slashes(&mut self, minimum_balance: Balance) -> Vec<(SlashId, Balance, Balance)> { - let mut finalized_slashes: Vec<(SlashId, Balance, Balance)> = vec![]; + let mut finalized_slashes: Vec<(SlashId, Balance, Balance)> = Vec::new(); for (slash_id, slash) in self.get_slashes_to_finalize().iter() { // apply the slashing and get back actual amount slashed @@ -305,8 +303,8 @@ pub struct Stake { impl Stake where - BlockNumber: Copy + SimpleArithmetic + Zero, - Balance: Copy + SimpleArithmetic, + BlockNumber: Copy + BaseArithmetic + Zero, + Balance: Copy + BaseArithmetic, SlashId: Copy + Ord + Zero + One, { fn new(created_at: BlockNumber) -> Self { @@ -638,7 +636,7 @@ where (did_update, slashed) } - _ => (false, vec![]), + _ => (false, Vec::new()), } } @@ -711,11 +709,12 @@ pub struct SlashImmediateOutcome { decl_storage! { trait Store for Module as StakePool { /// Maps identifiers to a stake. - pub Stakes get(stakes): linked_map T::StakeId => Stake, T::SlashId>; + pub Stakes get(fn stakes): map hasher(blake2_128_concat) + T::StakeId => Stake, T::SlashId>; /// Identifier value for next stake, and count of total stakes created (not necessarily the number of current /// stakes in the Stakes map as stakes can be removed.) - pub StakesCreated get(stakes_created): T::StakeId; + pub StakesCreated get(fn stakes_created): T::StakeId; } } @@ -900,14 +899,11 @@ impl Module { source_account_id: &T::AccountId, value: BalanceOf, ) -> Result, StakeActionError> { - // Compiler error when using macro: cannot infer type for `ErrorType` - // let mut stake = ensure_stake_exists!(T, stake_id, StakeActionError::StakeNotFound)?; - ensure!( - >::exists(stake_id), - StakeActionError::StakeNotFound - ); - - let mut stake = Self::stakes(stake_id); + let mut stake = ensure_stake_exists!( + T, + stake_id, + >::StakeNotFound + )?; let total_staked_amount = stake.increase_stake(value)?; @@ -1141,7 +1137,7 @@ impl Module { /// Finalised slashing results in the staked_balance in the given stake being correspondingly reduced, and the imbalance /// is provided to the slashed() hook in the StakingEventsHandler. fn finalize_slashing_and_unstaking() { - for (stake_id, ref mut stake) in >::enumerate() { + for (stake_id, ref mut stake) in >::iter() { let (updated, slashed, unstaked) = stake.finalize_slashing_and_unstaking(T::Currency::minimum_balance()); diff --git a/runtime-modules/stake/src/macroes.rs b/runtime-modules/stake/src/macroes.rs index 56d76e4787..02ba974a37 100644 --- a/runtime-modules/stake/src/macroes.rs +++ b/runtime-modules/stake/src/macroes.rs @@ -1,7 +1,7 @@ #[macro_export] macro_rules! ensure_map_has_mapping_with_key { ($map_variable_name:ident , $runtime_trait:tt, $key:expr, $error:expr) => {{ - if <$map_variable_name<$runtime_trait>>::exists($key) { + if <$map_variable_name<$runtime_trait>>::contains_key($key) { let value = <$map_variable_name<$runtime_trait>>::get($key); Ok(value) diff --git a/runtime-modules/stake/src/mock.rs b/runtime-modules/stake/src/mock.rs index 44f85398d0..5ce19e87b3 100644 --- a/runtime-modules/stake/src/mock.rs +++ b/runtime-modules/stake/src/mock.rs @@ -1,17 +1,15 @@ #![cfg(test)] use crate::*; - -use primitives::H256; - use crate::{Module, Trait}; use balances; -use runtime_primitives::{ +use frame_support::{impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{impl_outer_origin, parameter_types}; impl_outer_origin! { pub enum Origin for Test {} @@ -25,14 +23,14 @@ parameter_types! { pub const MaximumBlockWeight: u32 = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); - pub const MinimumPeriod: u64 = 5; } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -41,35 +39,30 @@ impl system::Trait for Test { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } parameter_types! { pub const ExistentialDeposit: u32 = 500; - pub const TransferFee: u32 = 5; - pub const CreationFee: u32 = 5; - pub const TransactionBaseFee: u32 = 5; - pub const TransactionByteFee: u32 = 0; pub const StakePoolId: [u8; 8] = *b"joystake"; } 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 Event = (); type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl Trait for Test { @@ -80,7 +73,7 @@ impl Trait for Test { type SlashId = u64; } -pub fn build_test_externalities() -> runtime_io::TestExternalities { +pub fn build_test_externalities() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); @@ -99,17 +92,4 @@ pub mod fixtures { ::SlashId, Slash<::BlockNumber, BalanceOf>, >; - // pub enum StakeInState { - // NotStaked, - // StakedNormal(BalanceOf, OngoingSlashes), - // StakedUnstaking(BalanceOf, OngoingSlashes, ::BlockNumber), - // } - // fn get_next_slash_id() -> SlashId { - // } - // pub fn make_stake(state: StakeInState) -> StakeId { - // let id = StakePool::create_stake(); - // >::mutate(id, |stake| {}); - // id - // } - // fn stake_in_state_to_stake(StakeInState) -> StakedState {} } diff --git a/runtime-modules/stake/src/tests.rs b/runtime-modules/stake/src/tests.rs index daf23d7c49..e46d0181d3 100644 --- a/runtime-modules/stake/src/tests.rs +++ b/runtime-modules/stake/src/tests.rs @@ -2,8 +2,8 @@ use super::*; use crate::mock::*; -use runtime_primitives::traits::OnFinalize; -use srml_support::{assert_err, assert_ok}; +use frame_support::traits::OnFinalize; +use frame_support::{assert_err, assert_ok}; #[test] fn stake_pool_works() { @@ -70,7 +70,7 @@ fn create_stake() { build_test_externalities().execute_with(|| { let stake_id = StakePool::create_stake(); assert_eq!(stake_id, 0); - assert!(>::exists(&stake_id)); + assert!(>::contains_key(&stake_id)); assert_eq!(StakePool::stakes_created(), stake_id + 1); @@ -91,7 +91,7 @@ fn remove_stake_in_not_staked_state() { }, ); assert_ok!(StakePool::remove_stake(&100)); - assert!(!>::exists(&100)); + assert!(!>::contains_key(&100)); // when status is Staked, removing should fail >::insert( @@ -106,7 +106,7 @@ fn remove_stake_in_not_staked_state() { StakePool::remove_stake(&200), StakeActionError::Error(StakingError::AlreadyStaked) ); - assert!(>::exists(&200)); + assert!(>::contains_key(&200)); }); } diff --git a/runtime-modules/storage/Cargo.toml b/runtime-modules/storage/Cargo.toml index a978681e80..e4870b425a 100644 --- a/runtime-modules/storage/Cargo.toml +++ b/runtime-modules/storage/Cargo.toml @@ -1,116 +1,43 @@ [package] -name = 'substrate-storage-module' -version = '2.0.0' +name = 'pallet-storage' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +membership = { package = 'pallet-membership', default-features = false, path = '../membership'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'} +common = { package = 'pallet-common', default-features = false, path = '../common'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +stake = { package = 'pallet-stake', default-features = false, path = '../stake'} +hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'} +minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'} +recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'} + [features] default = ['std'] std = [ - 'sr-primitives/std', - 'srml-support/std', - 'system/std', - 'rstd/std', - 'codec/std', - 'timestamp/std', 'serde', - 'primitives/std', - 'common/std', + 'codec/std', + 'sp-std/std', + 'frame-support/std', + 'system/std', + 'sp-arithmetic/std', + 'sp-runtime/std', 'membership/std', + 'pallet-timestamp/std', 'working-group/std', + 'common/std', ] - - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../membership' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../common' - -[dependencies.working-group] -default_features = false -package = 'substrate-working-group-module' -path = '../working-group' - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.balances] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-balances' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.recurringrewards] -default_features = false -package = 'substrate-recurring-reward-module' -path = '../recurring-reward' - -[dev-dependencies.hiring] -default_features = false -package = 'substrate-hiring-module' -path = '../hiring' - -[dev-dependencies.stake] -default_features = false -package = 'substrate-stake-module' -path = '../stake' - -[dev-dependencies.minting] -default_features = false -package = 'substrate-token-mint-module' -path = '../token-minting' \ No newline at end of file diff --git a/runtime-modules/storage/src/data_directory.rs b/runtime-modules/storage/src/data_directory.rs index 8486c435bb..f39bc5fe9d 100644 --- a/runtime-modules/storage/src/data_directory.rs +++ b/runtime-modules/storage/src/data_directory.rs @@ -22,12 +22,13 @@ //#![warn(missing_docs)] use codec::{Decode, Encode}; -use rstd::collections::btree_map::BTreeMap; -use rstd::prelude::*; -use sr_primitives::traits::{MaybeSerialize, Member}; -use srml_support::traits::Get; -use srml_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; -use system::{self, ensure_root}; +use frame_support::dispatch::DispatchResult; +use frame_support::traits::Get; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; +use sp_runtime::traits::{MaybeSerialize, Member}; +use sp_std::collections::btree_map::BTreeMap; +use sp_std::vec::Vec; +use system::ensure_root; use common::origin::ActorOriginValidator; pub(crate) use common::BlockAndTime; @@ -38,7 +39,7 @@ use crate::{MemberId, StorageProviderId, StorageWorkingGroup, StorageWorkingGrou /// The _Data directory_ main _Trait_. pub trait Trait: - timestamp::Trait + pallet_timestamp::Trait + system::Trait + data_object_type_registry::Trait + membership::Trait @@ -64,7 +65,7 @@ pub trait Trait: decl_error! { /// _Data object storage registry_ module predefined errors. - pub enum Error { + pub enum Error for Module{ /// Content with this ID not found. CidNotFound, @@ -85,25 +86,6 @@ decl_error! { } } -impl From for Error { - fn from(error: system::Error) -> Self { - match error { - system::Error::Other(msg) => Error::Other(msg), - system::Error::RequireRootOrigin => Error::RequireRootOrigin, - _ => Error::Other(error.into()), - } - } -} - -impl From for Error { - fn from(error: working_group::Error) -> Self { - match error { - working_group::Error::Other(msg) => Error::Other(msg), - _ => Error::Other(error.into()), - } - } -} - /// The decision of the storage provider when it acts as liaison. #[derive(Clone, Encode, Decode, PartialEq, Debug)] pub enum LiaisonJudgement { @@ -127,7 +109,7 @@ impl Default for LiaisonJudgement { pub type DataObject = DataObjectInternal< MemberId, ::BlockNumber, - ::Moment, + ::Moment, ::DataObjectTypeId, StorageProviderId, >; @@ -163,11 +145,11 @@ pub type DataObjectsMap = BTreeMap<::ContentId, DataObject>; decl_storage! { trait Store for Module as DataDirectory { /// List of ids known to the system. - pub KnownContentIds get(known_content_ids): Vec = Vec::new(); + pub KnownContentIds get(fn known_content_ids): Vec = Vec::new(); /// Maps data objects by their content id. - pub DataObjectByContentId get(data_object_by_content_id): - map T::ContentId => Option>; + pub DataObjectByContentId get(fn data_object_by_content_id): + map hasher(blake2_128_concat) T::ContentId => Option>; } } @@ -205,13 +187,14 @@ decl_module! { fn deposit_event() = default; /// Predefined errors. - type Error = Error; + type Error = Error; /// Maximum objects allowed per inject_data_objects() transaction const MaxObjectsPerInjection: u32 = T::MaxObjectsPerInjection::get(); /// Adds the content to the system. Member id should match its origin. The created DataObject /// awaits liaison to accept or reject it. + #[weight = 10_000_000] // TODO: adjust weight pub fn add_content( origin, member_id: MemberId, @@ -226,10 +209,10 @@ decl_module! { )?; ensure!(T::IsActiveDataObjectType::is_active_data_object_type(&type_id), - Error::DataObjectTypeMustBeActive); + Error::::DataObjectTypeMustBeActive); - ensure!(!>::exists(content_id), - Error::DataObjectAlreadyAdded); + ensure!(!>::contains_key(content_id), + Error::::DataObjectAlreadyAdded); let liaison = T::StorageProviderHelper::get_random_storage_provider()?; @@ -254,6 +237,7 @@ decl_module! { /// Storage provider accepts a content. Requires signed storage provider account and its id. /// The LiaisonJudgement can be updated, but only by the liaison. + #[weight = 10_000_000] // TODO: adjust weight pub(crate) fn accept_content( origin, storage_provider_id: StorageProviderId, @@ -272,6 +256,7 @@ decl_module! { /// Storage provider rejects a content. Requires signed storage provider account and its id. /// The LiaisonJudgement can be updated, but only by the liaison. + #[weight = 10_000_000] // TODO: adjust weight pub(crate) fn reject_content( origin, storage_provider_id: StorageProviderId, @@ -288,6 +273,7 @@ decl_module! { // Sudo methods /// Removes the content id from the list of known content ids. Requires root privileges. + #[weight = 10_000_000] // TODO: adjust weight fn remove_known_content_id(origin, content_id: T::ContentId) { ensure_root(origin)?; @@ -305,11 +291,12 @@ decl_module! { /// The number of objects that can be added per call is limited to prevent the dispatch /// from causing the block production to fail if it takes too much time to process. /// Existing data objects will be overwritten. + #[weight = 10_000_000] // TODO: adjust weight pub(crate) fn inject_data_objects(origin, objects: DataObjectsMap) { ensure_root(origin)?; // Must provide something to inject - ensure!(objects.len() <= T::MaxObjectsPerInjection::get() as usize, Error::DataObjectsInjectionExceededLimit); + ensure!(objects.len() <= T::MaxObjectsPerInjection::get() as usize, Error::::DataObjectsInjectionExceededLimit); for (id, object) in objects.into_iter() { // append to known content ids @@ -332,11 +319,15 @@ impl Module { storage_provider_id: &StorageProviderId, content_id: T::ContentId, judgement: LiaisonJudgement, - ) -> Result<(), Error> { - let mut data = Self::data_object_by_content_id(&content_id).ok_or(Error::CidNotFound)?; + ) -> DispatchResult { + let mut data = + Self::data_object_by_content_id(&content_id).ok_or(Error::::CidNotFound)?; // Make sure the liaison matches - ensure!(data.liaison == *storage_provider_id, Error::LiaisonRequired); + ensure!( + data.liaison == *storage_provider_id, + Error::::LiaisonRequired + ); data.liaison_judgement = judgement; >::insert(content_id, data); @@ -368,7 +359,7 @@ impl ContentIdExists for Module { fn get_data_object(content_id: &T::ContentId) -> Result, &'static str> { match Self::data_object_by_content_id(*content_id) { Some(data) => Ok(data), - None => Err(Error::LiaisonRequired.into()), + None => Err(Error::::LiaisonRequired.into()), } } } diff --git a/runtime-modules/storage/src/data_object_storage_registry.rs b/runtime-modules/storage/src/data_object_storage_registry.rs index b662db8af6..3c0e36cfef 100644 --- a/runtime-modules/storage/src/data_object_storage_registry.rs +++ b/runtime-modules/storage/src/data_object_storage_registry.rs @@ -23,18 +23,20 @@ //#![warn(missing_docs)] use codec::{Codec, Decode, Encode}; -use rstd::prelude::*; -use sr_primitives::traits::{MaybeSerialize, Member, SimpleArithmetic}; -use srml_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; +use frame_support::dispatch::DispatchResult; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; +use sp_arithmetic::traits::BaseArithmetic; +use sp_runtime::traits::{MaybeSerialize, Member}; +use sp_std::vec::Vec; use crate::data_directory::{self, ContentIdExists}; use crate::{StorageProviderId, StorageWorkingGroup, StorageWorkingGroupInstance}; -const DEFAULT_FIRST_RELATIONSHIP_ID: u32 = 1; +const DEFAULT_FIRST_RELATIONSHIP_ID: u8 = 1; /// The _Data object storage registry_ main _Trait_. pub trait Trait: - timestamp::Trait + pallet_timestamp::Trait + system::Trait + data_directory::Trait + working_group::Trait @@ -45,7 +47,7 @@ pub trait Trait: /// Type for data object storage relationship id type DataObjectStorageRelationshipId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -58,7 +60,7 @@ pub trait Trait: decl_error! { /// _Data object storage registry_ module predefined errors - pub enum Error { + pub enum Error for Module{ /// Content with this ID not found. CidNotFound, @@ -73,25 +75,6 @@ decl_error! { } } -impl From for Error { - fn from(error: system::Error) -> Self { - match error { - system::Error::Other(msg) => Error::Other(msg), - system::Error::RequireRootOrigin => Error::RequireRootOrigin, - _ => Error::Other(error.into()), - } - } -} - -impl From for Error { - fn from(error: working_group::Error) -> Self { - match error { - working_group::Error::Other(msg) => Error::Other(msg), - _ => Error::Other(error.into()), - } - } -} - /// Defines a relationship between the content and the storage provider #[derive(Clone, Encode, Decode, PartialEq, Debug)] pub struct DataObjectStorageRelationship { @@ -109,17 +92,19 @@ decl_storage! { trait Store for Module as DataObjectStorageRegistry { /// Defines first relationship id. - pub FirstRelationshipId get(first_relationship_id) config(first_relationship_id): + pub FirstRelationshipId get(fn first_relationship_id) config(first_relationship_id): T::DataObjectStorageRelationshipId = T::DataObjectStorageRelationshipId::from(DEFAULT_FIRST_RELATIONSHIP_ID); /// Defines next relationship id. - pub NextRelationshipId get(next_relationship_id) build(|config: &GenesisConfig| config.first_relationship_id): T::DataObjectStorageRelationshipId = T::DataObjectStorageRelationshipId::from(DEFAULT_FIRST_RELATIONSHIP_ID); + pub NextRelationshipId get(fn next_relationship_id) build(|config: &GenesisConfig| config.first_relationship_id): T::DataObjectStorageRelationshipId = T::DataObjectStorageRelationshipId::from(DEFAULT_FIRST_RELATIONSHIP_ID); /// Mapping of Data object types - pub Relationships get(relationships): map T::DataObjectStorageRelationshipId => Option>; + pub Relationships get(fn relationships): map hasher(blake2_128_concat) + T::DataObjectStorageRelationshipId => Option>; /// Keeps a list of storage relationships per content id. - pub RelationshipsByContentId get(relationships_by_content_id): map T::ContentId => Vec; + pub RelationshipsByContentId get(fn relationships_by_content_id): map hasher(blake2_128_concat) + T::ContentId => Vec; } } @@ -152,16 +137,17 @@ decl_module! { fn deposit_event() = default; /// Predefined errors. - type Error = Error; + type Error = Error; /// Add storage provider-to-content relationship. The storage provider should be registered /// in the storage working group. + #[weight = 10_000_000] // TODO: adjust weight pub fn add_relationship(origin, storage_provider_id: StorageProviderId, cid: T::ContentId) { // Origin should match storage provider. >::ensure_worker_signed(origin, &storage_provider_id)?; // Content ID must exist - ensure!(T::ContentIdExists::has_content(&cid), Error::CidNotFound); + ensure!(T::ContentIdExists::has_content(&cid), Error::::CidNotFound); // Create new ID, data. let new_id = Self::next_relationship_id(); @@ -194,6 +180,7 @@ decl_module! { /// Activates storage provider-to-content relationship. The storage provider should be registered /// in the storage working group. A storage provider may flip their own ready state, but nobody else. + #[weight = 10_000_000] // TODO: adjust weight pub fn set_relationship_ready( origin, storage_provider_id: StorageProviderId, @@ -204,6 +191,7 @@ decl_module! { /// Deactivates storage provider-to-content relationship. The storage provider should be registered /// in the storage working group. A storage provider may flip their own ready state, but nobody else. + #[weight = 10_000_000] // TODO: adjust weight pub fn unset_relationship_ready( origin, storage_provider_id: StorageProviderId, @@ -220,16 +208,16 @@ impl Module { storage_provider_id: StorageProviderId, id: T::DataObjectStorageRelationshipId, ready: bool, - ) -> Result<(), Error> { + ) -> DispatchResult { >::ensure_worker_signed(origin, &storage_provider_id)?; // For that, we need to fetch the identified DOSR let mut dosr = - Self::relationships(id).ok_or(Error::DataObjectStorageRelationshipNotFound)?; + Self::relationships(id).ok_or(Error::::DataObjectStorageRelationshipNotFound)?; ensure!( dosr.storage_provider_id == storage_provider_id, - Error::OnlyStorageProviderMayClaimReady + Error::::OnlyStorageProviderMayClaimReady ); // Flip to ready diff --git a/runtime-modules/storage/src/data_object_type_registry.rs b/runtime-modules/storage/src/data_object_type_registry.rs index a502c571bc..d544a9c419 100644 --- a/runtime-modules/storage/src/data_object_type_registry.rs +++ b/runtime-modules/storage/src/data_object_type_registry.rs @@ -22,14 +22,18 @@ // Do not delete! Cannot be uncommented by default, because of Parity decl_module! issue. //#![warn(missing_docs)] -use crate::{StorageWorkingGroup, StorageWorkingGroupInstance}; use codec::{Codec, Decode, Encode}; -use rstd::prelude::*; -use sr_primitives::traits::{MaybeSerialize, Member, SimpleArithmetic}; -use srml_support::{decl_error, decl_event, decl_module, decl_storage, Parameter}; +use frame_support::dispatch::DispatchError; +use frame_support::weights::Weight; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, Parameter}; +use sp_arithmetic::traits::BaseArithmetic; +use sp_runtime::traits::{MaybeSerialize, Member}; +use sp_std::vec::Vec; + +use crate::{StorageWorkingGroup, StorageWorkingGroupInstance}; const DEFAULT_TYPE_DESCRIPTION: &str = "Default data object type for audio and video content."; -const DEFAULT_FIRST_DATA_OBJECT_TYPE_ID: u32 = 1; +const DEFAULT_FIRST_DATA_OBJECT_TYPE_ID: u8 = 1; /// The _Data object type registry_ main _Trait_. pub trait Trait: system::Trait + working_group::Trait { @@ -39,7 +43,7 @@ pub trait Trait: system::Trait + working_group::Trait { /// Data Object Type with the given ID not found. DataObjectTypeNotFound, @@ -58,25 +62,6 @@ decl_error! { } } -impl From for Error { - fn from(error: system::Error) -> Self { - match error { - system::Error::Other(msg) => Error::Other(msg), - system::Error::RequireRootOrigin => Error::RequireRootOrigin, - _ => Error::Other(error.into()), - } - } -} - -impl From for Error { - fn from(error: working_group::Error) -> Self { - match error { - working_group::Error::Other(msg) => Error::Other(msg), - _ => Error::Other(error.into()), - } - } -} - /// Contains description and constrains for the data object. #[derive(Clone, Encode, Decode, PartialEq, Debug)] pub struct DataObjectType { @@ -99,15 +84,16 @@ impl Default for DataObjectType { decl_storage! { trait Store for Module as DataObjectTypeRegistry { /// Data object type ids should start at this value. - pub FirstDataObjectTypeId get(first_data_object_type_id) config(first_data_object_type_id): + pub FirstDataObjectTypeId get(fn first_data_object_type_id) config(first_data_object_type_id): T::DataObjectTypeId = T::DataObjectTypeId::from(DEFAULT_FIRST_DATA_OBJECT_TYPE_ID); /// Provides id counter for the data object types. - pub NextDataObjectTypeId get(next_data_object_type_id) build(|config: &GenesisConfig| + pub NextDataObjectTypeId get(fn next_data_object_type_id) build(|config: &GenesisConfig| config.first_data_object_type_id): T::DataObjectTypeId = T::DataObjectTypeId::from(DEFAULT_FIRST_DATA_OBJECT_TYPE_ID); /// Mapping of Data object types. - pub DataObjectTypes get(data_object_types): map T::DataObjectTypeId => Option; + pub DataObjectTypes get(fn data_object_types): map hasher(blake2_128_concat) + T::DataObjectTypeId => Option; } } @@ -134,20 +120,23 @@ decl_module! { fn deposit_event() = default; /// Predefined errors - type Error = Error; + type Error = Error; - fn on_initialize() { + fn on_initialize() -> Weight{ // Create a default data object type if it was not created yet. - if !>::exists(Self::first_data_object_type_id()) { + if !>::contains_key(Self::first_data_object_type_id()) { let do_type: DataObjectType = DataObjectType::default(); let new_type_id = Self::next_data_object_type_id(); >::insert(new_type_id, do_type); >::mutate(|n| { *n += T::DataObjectTypeId::from(1); }); } + + 10_000_000 //TODO: adjust weight } /// Registers the new data object type. Requires leader privileges. + #[weight = 10_000_000] // TODO: adjust weight pub fn register_data_object_type(origin, data_object_type: DataObjectType) { >::ensure_origin_is_active_leader(origin)?; @@ -168,6 +157,7 @@ decl_module! { } /// Updates existing data object type. Requires leader privileges. + #[weight = 10_000_000] // TODO: adjust weight pub fn update_data_object_type(origin, id: T::DataObjectTypeId, data_object_type: DataObjectType) { >::ensure_origin_is_active_leader(origin)?; @@ -186,6 +176,7 @@ decl_module! { } /// Activates existing data object type. Requires leader privileges. + #[weight = 10_000_000] // TODO: adjust weight pub fn activate_data_object_type(origin, id: T::DataObjectTypeId) { >::ensure_origin_is_active_leader(origin)?; @@ -203,6 +194,7 @@ decl_module! { } /// Deactivates existing data object type. Requires leader privileges. + #[weight = 10_000_000] // TODO: adjust weight pub fn deactivate_data_object_type(origin, id: T::DataObjectTypeId) { >::ensure_origin_is_active_leader(origin)?; @@ -222,8 +214,8 @@ decl_module! { } impl Module { - fn ensure_data_object_type(id: T::DataObjectTypeId) -> Result { - Self::data_object_types(&id).ok_or(Error::DataObjectTypeNotFound) + fn ensure_data_object_type(id: T::DataObjectTypeId) -> Result { + Self::data_object_types(&id).ok_or_else(|| Error::::DataObjectTypeNotFound.into()) } } diff --git a/runtime-modules/storage/src/tests/data_directory.rs b/runtime-modules/storage/src/tests/data_directory.rs index f865fddbee..eb6dbbf4a3 100644 --- a/runtime-modules/storage/src/tests/data_directory.rs +++ b/runtime-modules/storage/src/tests/data_directory.rs @@ -1,10 +1,11 @@ #![cfg(test)] -use super::mock::*; -use crate::data_directory::Error; -use rstd::collections::btree_map::BTreeMap; +use frame_support::dispatch::DispatchError; +use sp_std::collections::btree_map::BTreeMap; use system::RawOrigin; +use super::mock::*; + #[test] fn succeed_adding_content() { with_default_mock_builder(|| { @@ -36,13 +37,20 @@ fn add_content_fails_with_invalid_origin() { 0, vec![1, 3, 3, 7], ); - assert_eq!(res, Err(Error::Other("RequireSignedOrigin"))); + assert_eq!(res, Err(DispatchError::Other("Bad origin"))); }); } #[test] fn accept_and_reject_content_fail_with_invalid_storage_provider() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let sender = 1u64; let member_id = 1u64; @@ -72,20 +80,27 @@ fn accept_and_reject_content_fail_with_invalid_storage_provider() { storage_provider_id, content_id, ); - assert_eq!(res, Err(Error::Other("WorkerDoesNotExist"))); + assert_eq!(res, Err(working_group::Error::::WorkerDoesNotExist.into())); let res = TestDataDirectory::reject_content( Origin::signed(storage_provider_account_id), storage_provider_id, content_id, ); - assert_eq!(res, Err(Error::Other("WorkerDoesNotExist"))); + assert_eq!(res, Err(working_group::Error::::WorkerDoesNotExist.into())); }); } #[test] fn accept_content_as_liaison() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let sender = 1u64; let member_id = 1u64; @@ -130,6 +145,13 @@ fn accept_content_as_liaison() { #[test] fn reject_content_as_liaison() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let sender = 1u64; let member_id = 1u64; @@ -199,7 +221,7 @@ fn data_object_injection_works() { let content_id_2 = 2; objects.insert(content_id_2, object.clone()); - let res = TestDataDirectory::inject_data_objects(Origin::ROOT, objects); + let res = TestDataDirectory::inject_data_objects(RawOrigin::Root.into(), objects); assert!(res.is_ok()); assert_eq!( @@ -279,7 +301,7 @@ fn data_object_injection_overwrites_and_removes_duplicate_ids() { objects.insert(content_id_1, object1.clone()); objects.insert(content_id_2, object2.clone()); - let res = TestDataDirectory::inject_data_objects(Origin::ROOT, objects); + let res = TestDataDirectory::inject_data_objects(RawOrigin::Root.into(), objects); assert!(res.is_ok()); assert_eq!( diff --git a/runtime-modules/storage/src/tests/data_object_storage_registry.rs b/runtime-modules/storage/src/tests/data_object_storage_registry.rs index c5bb18cda2..af65cc49ff 100644 --- a/runtime-modules/storage/src/tests/data_object_storage_registry.rs +++ b/runtime-modules/storage/src/tests/data_object_storage_registry.rs @@ -22,7 +22,7 @@ fn add_relationship_fails_with_invalid_authorization() { storage_provider_id, TEST_MOCK_EXISTING_CID, ); - assert_eq!(res, Err(working_group::Error::WorkerDoesNotExist.into())); + assert_eq!(res, Err(working_group::Error::::WorkerDoesNotExist.into())); }); } @@ -44,7 +44,7 @@ fn set_relationship_ready_fails_with_invalid_authorization() { invalid_storage_provider_id, TEST_MOCK_EXISTING_CID, ); - assert_eq!(res, Err(working_group::Error::WorkerDoesNotExist.into())); + assert_eq!(res, Err(working_group::Error::::WorkerDoesNotExist.into())); }); } @@ -66,7 +66,7 @@ fn unset_relationship_ready_fails_with_invalid_authorization() { invalid_storage_provider_id, TEST_MOCK_EXISTING_CID, ); - assert_eq!(res, Err(working_group::Error::WorkerDoesNotExist.into())); + assert_eq!(res, Err(working_group::Error::::WorkerDoesNotExist.into())); }); } @@ -100,6 +100,13 @@ fn test_fail_adding_relationship_with_bad_content() { #[test] fn test_toggle_ready() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let (account_id, storage_provider_id) = hire_storage_provider(); // Create a DOSR let res = TestDataObjectStorageRegistry::add_relationship( diff --git a/runtime-modules/storage/src/tests/data_object_type_registry.rs b/runtime-modules/storage/src/tests/data_object_type_registry.rs index 31f07084bd..da3c0501b5 100644 --- a/runtime-modules/storage/src/tests/data_object_type_registry.rs +++ b/runtime-modules/storage/src/tests/data_object_type_registry.rs @@ -1,8 +1,9 @@ #![cfg(test)] +use frame_support::{StorageMap, StorageValue}; +use system::{EventRecord, Phase, RawOrigin}; + use super::mock::*; -use srml_support::{StorageLinkedMap, StorageValue}; -use system::{self, EventRecord, Phase, RawOrigin}; const DEFAULT_LEADER_ACCOUNT_ID: u64 = 1; const DEFAULT_LEADER_MEMBER_ID: u64 = 1; @@ -73,6 +74,13 @@ fn succeed_register() { #[test] fn activate_data_object_type_fails_with_invalid_lead() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + SetLeadFixture::set_default_lead(); // First register a type @@ -93,13 +101,26 @@ fn activate_data_object_type_fails_with_invalid_lead() { RawOrigin::Signed(invalid_leader_account_id).into(), dot_id, ); - assert_eq!(res, Err(working_group::Error::IsNotLeadAccount.into())); + assert_eq!( + res, + Err( + working_group::Error::::IsNotLeadAccount + .into() + ) + ); }); } #[test] fn deactivate_data_object_type_fails_with_invalid_lead() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + SetLeadFixture::set_default_lead(); // First register a type @@ -120,13 +141,26 @@ fn deactivate_data_object_type_fails_with_invalid_lead() { RawOrigin::Signed(invalid_leader_account_id).into(), dot_id, ); - assert_eq!(res, Err(working_group::Error::IsNotLeadAccount.into())); + assert_eq!( + res, + Err( + working_group::Error::::IsNotLeadAccount + .into() + ) + ); }); } #[test] fn update_data_object_type_fails_with_invalid_lead() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + SetLeadFixture::set_default_lead(); // First register a type @@ -152,13 +186,26 @@ fn update_data_object_type_fails_with_invalid_lead() { dot_id, updated1, ); - assert_eq!(res, Err(working_group::Error::IsNotLeadAccount.into())); + assert_eq!( + res, + Err( + working_group::Error::::IsNotLeadAccount + .into() + ) + ); }); } #[test] fn update_existing() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + SetLeadFixture::set_default_lead(); // First register a type @@ -201,7 +248,7 @@ fn update_existing() { assert_eq!( *System::events().last().unwrap(), EventRecord { - phase: Phase::ApplyExtrinsic(0), + phase: Phase::Initialization, event: MetaEvent::data_object_type_registry( data_object_type_registry::RawEvent::DataObjectTypeUpdated(dot_id) ), @@ -230,6 +277,15 @@ fn register_data_object_type_failed_with_no_lead() { #[test] fn activate_existing() { with_default_mock_builder(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + + let expected_data_object_type_id = TEST_FIRST_DATA_OBJECT_TYPE_ID + 1; // on_initialize() increments the default value. + SetLeadFixture::set_default_lead(); // First register a type @@ -245,10 +301,10 @@ fn activate_existing() { assert_eq!( *System::events().last().unwrap(), EventRecord { - phase: Phase::ApplyExtrinsic(0), + phase: Phase::Initialization, event: MetaEvent::data_object_type_registry( data_object_type_registry::RawEvent::DataObjectTypeRegistered( - TEST_FIRST_DATA_OBJECT_TYPE_ID + expected_data_object_type_id ) ), topics: vec![], @@ -256,23 +312,23 @@ fn activate_existing() { ); // Retrieve, and ensure it's not active. - let data = TestDataObjectTypeRegistry::data_object_types(TEST_FIRST_DATA_OBJECT_TYPE_ID); + let data = TestDataObjectTypeRegistry::data_object_types(expected_data_object_type_id); assert!(data.is_some()); assert!(!data.unwrap().active); // Now activate the data object type let res = TestDataObjectTypeRegistry::activate_data_object_type( RawOrigin::Signed(DEFAULT_LEADER_ACCOUNT_ID).into(), - TEST_FIRST_DATA_OBJECT_TYPE_ID, + expected_data_object_type_id, ); assert!(res.is_ok()); assert_eq!( *System::events().last().unwrap(), EventRecord { - phase: Phase::ApplyExtrinsic(0), + phase: Phase::Initialization, event: MetaEvent::data_object_type_registry( data_object_type_registry::RawEvent::DataObjectTypeUpdated( - TEST_FIRST_DATA_OBJECT_TYPE_ID + expected_data_object_type_id ) ), topics: vec![], @@ -280,17 +336,17 @@ fn activate_existing() { ); // Ensure that the item is actually activated. - let data = TestDataObjectTypeRegistry::data_object_types(TEST_FIRST_DATA_OBJECT_TYPE_ID); + let data = TestDataObjectTypeRegistry::data_object_types(expected_data_object_type_id); assert!(data.is_some()); assert!(data.unwrap().active); // Deactivate again. let res = TestDataObjectTypeRegistry::deactivate_data_object_type( RawOrigin::Signed(DEFAULT_LEADER_ACCOUNT_ID).into(), - TEST_FIRST_DATA_OBJECT_TYPE_ID, + expected_data_object_type_id, ); assert!(res.is_ok()); - let data = TestDataObjectTypeRegistry::data_object_types(TEST_FIRST_DATA_OBJECT_TYPE_ID); + let data = TestDataObjectTypeRegistry::data_object_types(expected_data_object_type_id); assert!(data.is_some()); assert!(!data.unwrap().active); }); diff --git a/runtime-modules/storage/src/tests/mock.rs b/runtime-modules/storage/src/tests/mock.rs index 9f16c5210e..d696438403 100644 --- a/runtime-modules/storage/src/tests/mock.rs +++ b/runtime-modules/storage/src/tests/mock.rs @@ -1,22 +1,21 @@ #![cfg(test)] -pub use crate::{data_directory, data_object_storage_registry, data_object_type_registry}; -pub use common::currency::GovernanceCurrency; -use membership; -pub use system; - -pub use primitives::{Blake2Hasher, H256}; -pub use sr_primitives::{ - testing::{Digest, DigestItem, Header, UintAuthorityId}, - traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, - weights::Weight, - BuildStorage, Perbill, +use frame_support::storage::StorageMap; +use frame_support::traits::{OnFinalize, OnInitialize}; +use frame_support::{impl_outer_event, impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, }; use crate::data_directory::ContentIdExists; use crate::data_object_type_registry::IsActiveDataObjectType; pub use crate::StorageWorkingGroupInstance; -use srml_support::{impl_outer_event, impl_outer_origin, parameter_types, StorageLinkedMap}; +pub use crate::{data_directory, data_object_storage_registry, data_object_type_registry}; +use common::currency::GovernanceCurrency; +use membership; mod working_group_mod { pub use super::StorageWorkingGroupInstance; @@ -39,6 +38,7 @@ impl_outer_event! { balances, members, working_group_mod StorageWorkingGroupInstance , + system, } } @@ -97,10 +97,11 @@ parameter_types! { } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -109,12 +110,20 @@ impl system::Trait for Test { type Event = MetaEvent; type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -122,28 +131,15 @@ impl timestamp::Trait for Test { 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 StakePoolId: [u8; 8] = *b"joystake"; } 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 = MetaEvent; - type DustRemoval = (); - type TransferPayment = (); + type Event = MetaEvent; type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl GovernanceCurrency for Test { @@ -262,7 +258,7 @@ impl ExtBuilder { self.first_metadata_id = first_metadata_id; self } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default() .build_storage::() .unwrap(); @@ -290,10 +286,11 @@ impl ExtBuilder { } } +pub type TestDataObjectType = data_object_type_registry::DataObjectType; + pub type Balances = balances::Module; pub type System = system::Module; pub type TestDataObjectTypeRegistry = data_object_type_registry::Module; -pub type TestDataObjectType = data_object_type_registry::DataObjectType; pub type TestDataDirectory = data_directory::Module; pub type TestDataObjectStorageRegistry = data_object_storage_registry::Module; @@ -325,3 +322,19 @@ pub(crate) fn hire_storage_provider() -> (u64, u32) { (role_account_id, storage_provider_id) } + +// Recommendation from Parity on testing on_finalize +// https://substrate.dev/docs/en/next/development/module/tests +pub fn run_to_block(n: u64) { + while System::block_number() < n { + >::on_finalize(System::block_number()); + >::on_finalize(System::block_number()); + >::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()); + >::on_initialize(System::block_number()); + >::on_initialize(System::block_number()); + } +} diff --git a/runtime-modules/token-minting/Cargo.toml b/runtime-modules/token-minting/Cargo.toml index ec9d8afb97..ac868264d8 100755 --- a/runtime-modules/token-minting/Cargo.toml +++ b/runtime-modules/token-minting/Cargo.toml @@ -1,50 +1,27 @@ [package] -name = 'substrate-token-mint-module' -version = '1.0.1' +name = 'pallet-token-mint' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' [dependencies] -hex-literal = '0.1.0' -serde = { version = '1.0.101', optional = true} -serde_derive = { version = '1.0.101', optional = true } -rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] } -# https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -quote = '<=1.0.2' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [dev-dependencies] -runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [features] default = ['std'] std = [ - 'serde', - 'serde_derive', 'codec/std', - 'rstd/std', - 'runtime-io/std', - 'runtime-primitives/std', - 'srml-support/std', + 'sp-arithmetic/std', + 'sp-runtime/std', + 'frame-support/std', 'system/std', - 'balances/std', - 'timestamp/std', ] diff --git a/runtime-modules/token-minting/src/lib.rs b/runtime-modules/token-minting/src/lib.rs index 1604762b02..a1c31089e8 100755 --- a/runtime-modules/token-minting/src/lib.rs +++ b/runtime-modules/token-minting/src/lib.rs @@ -6,13 +6,12 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(feature = "std")] -use rstd::prelude::*; - use codec::{Codec, Decode, Encode}; -use runtime_primitives::traits::{MaybeSerialize, Member, One, SimpleArithmetic, Zero}; -use srml_support::traits::Currency; -use srml_support::{decl_module, decl_storage, ensure, Parameter}; +use frame_support::storage::IterableStorageMap; +use frame_support::traits::Currency; +use frame_support::{decl_module, decl_storage, ensure, Parameter}; +use sp_arithmetic::traits::{BaseArithmetic, One, Zero}; +use sp_runtime::traits::{MaybeSerialize, Member}; mod mint; mod mock; @@ -27,7 +26,7 @@ pub trait Trait: system::Trait { /// The type used as a mint identifier. type MintId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -107,13 +106,13 @@ pub enum Adjustment { decl_storage! { trait Store for Module as TokenMint { /// Mints - pub Mints get(mints) : linked_map T::MintId => Mint, T::BlockNumber>; + pub Mints get(fn mints) : map hasher(blake2_128_concat) T::MintId => Mint, T::BlockNumber>; /// The number of mints created. - pub MintsCreated get(mints_created): T::MintId; + pub MintsCreated get(fn mints_created): T::MintId; } } - +// pub Account: map hasher(blake2_128_concat) T::AccountId => AccountData; decl_module! { pub struct Module for enum Call where origin: T::Origin { fn on_finalize(now: T::BlockNumber) { @@ -125,7 +124,7 @@ decl_module! { impl Module { fn update_mints(now: T::BlockNumber) { // Are we reading value from storage twice? - for (mint_id, ref mut mint) in >::enumerate() { + for (mint_id, ref mut mint) in >::iter() { if mint.maybe_do_capacity_adjustment(now) { >::insert(&mint_id, mint); } @@ -199,7 +198,10 @@ impl Module { return Ok(()); } - ensure!(>::exists(&mint_id), TransferError::MintNotFound); + ensure!( + >::contains_key(&mint_id), + TransferError::MintNotFound + ); let mut mint = Self::mints(&mint_id); @@ -219,7 +221,10 @@ impl Module { mint_id: T::MintId, capacity: BalanceOf, ) -> Result<(), GeneralError> { - ensure!(>::exists(&mint_id), GeneralError::MintNotFound); + ensure!( + >::contains_key(&mint_id), + GeneralError::MintNotFound + ); >::mutate(&mint_id, |mint| { mint.set_capacity(capacity); @@ -237,11 +242,11 @@ impl Module { capacity_to_transfer: BalanceOf, ) -> Result<(), CapacityTransferError> { ensure!( - >::exists(&source), + >::contains_key(&source), CapacityTransferError::SourceMintNotFound ); ensure!( - >::exists(&destination), + >::contains_key(&destination), CapacityTransferError::DestinationMintNotFound ); @@ -256,7 +261,10 @@ impl Module { /// Returns a mint's capacity if it exists, error otherwise. pub fn get_mint_capacity(mint_id: T::MintId) -> Result, GeneralError> { - ensure!(>::exists(&mint_id), GeneralError::MintNotFound); + ensure!( + >::contains_key(&mint_id), + GeneralError::MintNotFound + ); let mint = Self::mints(&mint_id); Ok(mint.capacity()) @@ -266,7 +274,10 @@ impl Module { pub fn get_mint_next_adjustment( mint_id: T::MintId, ) -> Result, T::BlockNumber>>, GeneralError> { - ensure!(>::exists(&mint_id), GeneralError::MintNotFound); + ensure!( + >::contains_key(&mint_id), + GeneralError::MintNotFound + ); let mint = Self::mints(&mint_id); @@ -275,6 +286,6 @@ impl Module { /// Returns true if a mint exists. pub fn mint_exists(mint_id: T::MintId) -> bool { - >::exists(&mint_id) + >::contains_key(&mint_id) } } diff --git a/runtime-modules/token-minting/src/mint.rs b/runtime-modules/token-minting/src/mint.rs index 9ec438a1bd..e76614925f 100644 --- a/runtime-modules/token-minting/src/mint.rs +++ b/runtime-modules/token-minting/src/mint.rs @@ -1,6 +1,6 @@ use codec::{Decode, Encode}; -use runtime_primitives::traits::{SimpleArithmetic, Zero}; -use srml_support::ensure; +use frame_support::ensure; +use sp_arithmetic::traits::{BaseArithmetic, Zero}; #[derive(Encode, Decode, Copy, Clone, Debug, Eq, PartialEq)] pub enum AdjustCapacityBy { @@ -30,8 +30,8 @@ pub struct NextAdjustment { // We want Default trait on TokenMint so we can use it as value in StorageMap without needing to wrap it in an Option pub struct Mint where - Balance: Copy + SimpleArithmetic + Zero, - BlockNumber: Copy + SimpleArithmetic, + Balance: Copy + BaseArithmetic + Zero, + BlockNumber: Copy + BaseArithmetic, { capacity: Balance, @@ -51,8 +51,8 @@ pub enum MintingError { impl Mint where - Balance: Copy + SimpleArithmetic + Zero, - BlockNumber: Copy + SimpleArithmetic, + Balance: Copy + BaseArithmetic + Zero, + BlockNumber: Copy + BaseArithmetic, { pub fn new( initial_capacity: Balance, diff --git a/runtime-modules/token-minting/src/mock.rs b/runtime-modules/token-minting/src/mock.rs index fb839f9537..591d2589fa 100644 --- a/runtime-modules/token-minting/src/mock.rs +++ b/runtime-modules/token-minting/src/mock.rs @@ -1,17 +1,14 @@ #![cfg(test)] -use crate::*; - -use primitives::H256; - use crate::{Module, Trait}; use balances; -use runtime_primitives::{ +use frame_support::{impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{impl_outer_origin, parameter_types}; impl_outer_origin! { pub enum Origin for Test {} @@ -25,14 +22,14 @@ parameter_types! { pub const MaximumBlockWeight: u32 = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); - pub const MinimumPeriod: u64 = 5; } impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -41,9 +38,17 @@ impl system::Trait for Test { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } parameter_types! { @@ -55,20 +60,11 @@ parameter_types! { } 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 Event = (); type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl Trait for Test { @@ -76,7 +72,7 @@ impl Trait for Test { type MintId = u64; } -pub fn build_test_externalities() -> runtime_io::TestExternalities { +pub fn build_test_externalities() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime-modules/versioned-store-permissions/Cargo.toml b/runtime-modules/versioned-store-permissions/Cargo.toml index f49cbf390a..fc2650bd70 100755 --- a/runtime-modules/versioned-store-permissions/Cargo.toml +++ b/runtime-modules/versioned-store-permissions/Cargo.toml @@ -1,44 +1,31 @@ [package] -name = 'substrate-versioned-store-permissions-module' -version = '1.0.1' +name = 'pallet-versioned-store-permissions' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' [dependencies] -hex-literal = '0.1.0' -serde = { version = '1.0', optional = true } -serde_derive = { version = '1.0', optional = true } -codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] } -rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -timestamp = { package = 'srml-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -# https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -quote = '<=1.0.2' - -[dependencies.versioned-store] -default_features = false -package ='substrate-versioned-store' -path = '../versioned-store' +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +versioned-store = { package = 'pallet-versioned-store', default-features = false, path = '../versioned-store'} [dev-dependencies] -runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [features] default = ['std'] std = [ - 'serde', - 'serde_derive', 'codec/std', - 'rstd/std', - 'runtime-io/std', - 'runtime-primitives/std', - 'srml-support/std', + 'sp-std/std', + 'frame-support/std', 'system/std', - 'timestamp/std', - 'versioned-store/std', -] + 'sp-arithmetic/std', + 'sp-runtime/std', + 'versioned-store/std', +] \ No newline at end of file diff --git a/runtime-modules/versioned-store-permissions/src/constraint.rs b/runtime-modules/versioned-store-permissions/src/constraint.rs index 52e5cfa2cf..2f1c92db7e 100644 --- a/runtime-modules/versioned-store-permissions/src/constraint.rs +++ b/runtime-modules/versioned-store-permissions/src/constraint.rs @@ -1,5 +1,5 @@ use codec::{Decode, Encode}; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; /// Reference to a specific property of a specific class. #[derive(Encode, Decode, Eq, PartialEq, Ord, PartialOrd, Clone, Debug)] diff --git a/runtime-modules/versioned-store-permissions/src/credentials.rs b/runtime-modules/versioned-store-permissions/src/credentials.rs index f31978dd07..1d16a07ee6 100644 --- a/runtime-modules/versioned-store-permissions/src/credentials.rs +++ b/runtime-modules/versioned-store-permissions/src/credentials.rs @@ -1,6 +1,6 @@ use codec::{Decode, Encode}; -use rstd::collections::btree_set::BTreeSet; -use rstd::prelude::*; +use sp_std::collections::btree_set::BTreeSet; +use sp_std::vec::Vec; #[derive(Encode, Decode, Eq, PartialEq, Clone, Debug)] pub struct CredentialSet(BTreeSet); diff --git a/runtime-modules/versioned-store-permissions/src/lib.rs b/runtime-modules/versioned-store-permissions/src/lib.rs index 69ba3d50f2..82e3d7ea34 100755 --- a/runtime-modules/versioned-store-permissions/src/lib.rs +++ b/runtime-modules/versioned-store-permissions/src/lib.rs @@ -2,10 +2,15 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::Codec; -use rstd::collections::btree_map::BTreeMap; -use rstd::prelude::*; -use runtime_primitives::traits::{MaybeSerialize, Member, SimpleArithmetic}; -use srml_support::{decl_module, decl_storage, dispatch, ensure, Parameter}; +use frame_support::{decl_module, decl_storage, ensure, Parameter}; +use sp_arithmetic::traits::BaseArithmetic; +use sp_runtime::traits::{MaybeSerialize, Member}; +use sp_std::collections::btree_map::BTreeMap; +use sp_std::vec::Vec; + +//TODO: Convert errors to the Substrate decl_error! macro. +/// Result with string error message. This exists for backward compatibility purpose. +pub type DispatchResult = Result<(), &'static str>; // EntityId, ClassId -> should be configured on versioned_store::Trait pub use versioned_store::{ClassId, ClassPropertyValue, EntityId, Property, PropertyValue}; @@ -60,13 +65,10 @@ pub type ClassPermissionsType = ClassPermissions::Credential, u16, ::BlockNumber>; pub trait Trait: system::Trait + versioned_store::Trait { - // type Event: ... - // Do we need Events? - /// Type that represents an actor or group of actors in the system. type Credential: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -86,10 +88,12 @@ pub trait Trait: system::Trait + versioned_store::Trait { decl_storage! { trait Store for Module as VersionedStorePermissions { /// ClassPermissions of corresponding Classes in the versioned store - pub ClassPermissionsByClassId get(class_permissions_by_class_id): linked_map ClassId => ClassPermissionsType; + pub ClassPermissionsByClassId get(fn class_permissions_by_class_id): map hasher(blake2_128_concat) + ClassId => ClassPermissionsType; /// Owner of an entity in the versioned store. If it is None then it is owned by the system. - pub EntityMaintainerByEntityId get(entity_maintainer_by_entity_id): linked_map EntityId => Option; + pub EntityMaintainerByEntityId get(fn entity_maintainer_by_entity_id): map hasher(blake2_128_concat) + EntityId => Option; } } @@ -97,11 +101,12 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin { /// Sets the admins for a class + #[weight = 10_000_000] // TODO: adjust weight fn set_class_admins( origin, class_id: ClassId, admins: CredentialSet - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::mutate_class_permissions( @@ -117,13 +122,13 @@ decl_module! { } // Methods for updating concrete permissions - + #[weight = 10_000_000] // TODO: adjust weight fn set_class_entity_permissions( origin, with_credential: Option, class_id: ClassId, entity_permissions: EntityPermissions - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::mutate_class_permissions( @@ -138,12 +143,13 @@ decl_module! { ) } + #[weight = 10_000_000] // TODO: adjust weight fn set_class_entities_can_be_created( origin, with_credential: Option, class_id: ClassId, can_be_created: bool - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::mutate_class_permissions( @@ -158,12 +164,13 @@ decl_module! { ) } + #[weight = 10_000_000] // TODO: adjust weight fn set_class_add_schemas_set( origin, with_credential: Option, class_id: ClassId, credential_set: CredentialSet - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::mutate_class_permissions( @@ -178,12 +185,13 @@ decl_module! { ) } + #[weight = 10_000_000] // TODO: adjust weight fn set_class_create_entities_set( origin, with_credential: Option, class_id: ClassId, credential_set: CredentialSet - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::mutate_class_permissions( @@ -198,12 +206,13 @@ decl_module! { ) } + #[weight = 10_000_000] // TODO: adjust weight fn set_class_reference_constraint( origin, with_credential: Option, class_id: ClassId, constraint: ReferenceConstraint - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::mutate_class_permissions( @@ -224,7 +233,7 @@ decl_module! { // origin, // entity_id: EntityId, // new_maintainer: Option - // ) -> dispatch::Result { + // ) -> DispatchResult { // ensure_root(origin)?; // // ensure entity exists in the versioned store @@ -238,13 +247,13 @@ decl_module! { // } // Permissioned proxy calls to versioned store - + #[weight = 10_000_000] // TODO: adjust weight pub fn create_class( origin, name: Vec, description: Vec, class_permissions: ClassPermissionsType - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; let can_create_class = match raw_origin { @@ -268,21 +277,23 @@ decl_module! { } } + #[weight = 10_000_000] // TODO: adjust weight pub fn create_class_with_default_permissions( origin, name: Vec, description: Vec - ) -> dispatch::Result { + ) -> DispatchResult { Self::create_class(origin, name, description, ClassPermissions::default()) } + #[weight = 10_000_000] // TODO: adjust weight pub fn add_class_schema( origin, with_credential: Option, class_id: ClassId, existing_properties: Vec, new_properties: Vec - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::if_class_permissions_satisfied( @@ -304,16 +315,18 @@ decl_module! { /// Creates a new entity of type class_id. The maintainer is set to be either None if the origin is root, or the provided credential /// associated with signer. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_entity( origin, with_credential: Option, class_id: ClassId - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; let _entity_id = Self::do_create_entity(&raw_origin, with_credential, class_id)?; Ok(()) } + #[weight = 10_000_000] // TODO: adjust weight pub fn add_schema_support_to_entity( origin, with_credential: Option, @@ -321,23 +334,25 @@ decl_module! { entity_id: EntityId, schema_id: u16, // Do not type alias u16!! - u16, property_values: Vec - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::do_add_schema_support_to_entity(&raw_origin, with_credential, as_entity_maintainer, entity_id, schema_id, property_values) } + #[weight = 10_000_000] // TODO: adjust weight pub fn update_entity_property_values( origin, with_credential: Option, as_entity_maintainer: bool, entity_id: EntityId, property_values: Vec - ) -> dispatch::Result { + ) -> DispatchResult { let raw_origin = Self::ensure_root_or_signed(origin)?; Self::do_update_entity_property_values(&raw_origin, with_credential, as_entity_maintainer, entity_id, property_values) } - pub fn transaction(origin, operations: Vec>) -> dispatch::Result { + #[weight = 10_000_000] // TODO: adjust weight + pub fn transaction(origin, operations: Vec>) -> DispatchResult { // This map holds the EntityId of the entity created as a result of executing a CreateEntity Operation // keyed by the indexed of the operation, in the operations vector. let mut entity_created_in_operation: BTreeMap = BTreeMap::new(); @@ -415,7 +430,7 @@ impl Module { as_entity_maintainer: bool, entity_id: EntityId, property_values: Vec, - ) -> dispatch::Result { + ) -> DispatchResult { let class_id = Self::get_class_id_by_entity_id(entity_id)?; Self::ensure_internal_property_values_permitted(class_id, &property_values)?; @@ -448,7 +463,7 @@ impl Module { entity_id: EntityId, schema_id: u16, property_values: Vec, - ) -> dispatch::Result { + ) -> DispatchResult { // class id of the entity being updated let class_id = Self::get_class_id_by_entity_id(entity_id)?; @@ -491,7 +506,7 @@ impl Module { if let Some(entity_id) = as_entity_maintainer { // is entity maintained by system ensure!( - >::exists(entity_id), + >::contains_key(entity_id), "NotEnityMaintainer" ); // ensure entity maintainer matches @@ -522,7 +537,7 @@ impl Module { class_id: ClassId, ) -> Result, &'static str> { ensure!( - >::exists(class_id), + >::contains_key(class_id), "ClassPermissionsNotFoundByClassId" ); Ok(Self::class_permissions_by_class_id(class_id)) @@ -539,11 +554,10 @@ impl Module { class_id: ClassId, // actual mutation to apply. mutate: Mutate, - ) -> dispatch::Result + ) -> DispatchResult where - Predicate: - FnOnce(&ClassPermissionsType, &AccessLevel) -> dispatch::Result, - Mutate: FnOnce(&mut ClassPermissionsType) -> dispatch::Result, + Predicate: FnOnce(&ClassPermissionsType, &AccessLevel) -> DispatchResult, + Mutate: FnOnce(&mut ClassPermissionsType) -> DispatchResult, { let access_level = Self::derive_access_level(raw_origin, with_credential, None)?; let mut class_permissions = Self::ensure_class_permissions(class_id)?; @@ -558,7 +572,7 @@ impl Module { fn is_system( _: &ClassPermissionsType, access_level: &AccessLevel, - ) -> dispatch::Result { + ) -> DispatchResult { if *access_level == AccessLevel::System { Ok(()) } else { @@ -581,8 +595,7 @@ impl Module { callback: Callback, ) -> Result where - Predicate: - FnOnce(&ClassPermissionsType, &AccessLevel) -> dispatch::Result, + Predicate: FnOnce(&ClassPermissionsType, &AccessLevel) -> DispatchResult, Callback: FnOnce( &ClassPermissionsType, &AccessLevel, @@ -599,7 +612,7 @@ impl Module { fn get_class_id_by_entity_id(entity_id: EntityId) -> Result { // use a utility method on versioned_store module ensure!( - versioned_store::EntityById::exists(entity_id), + versioned_store::EntityById::contains_key(entity_id), "EntityNotFound" ); let entity = >::entity_by_id(entity_id); @@ -611,7 +624,7 @@ impl Module { fn ensure_internal_property_values_permitted( source_class_id: ClassId, property_values: &[ClassPropertyValue], - ) -> dispatch::Result { + ) -> DispatchResult { for property_value in property_values.iter() { if let PropertyValue::Internal(ref target_entity_id) = property_value.value { // get the class permissions for target class diff --git a/runtime-modules/versioned-store-permissions/src/mock.rs b/runtime-modules/versioned-store-permissions/src/mock.rs index 750bc16ee7..d2542b4725 100644 --- a/runtime-modules/versioned-store-permissions/src/mock.rs +++ b/runtime-modules/versioned-store-permissions/src/mock.rs @@ -3,13 +3,13 @@ use crate::*; use crate::{Module, Trait}; -use primitives::H256; -use runtime_primitives::{ +use frame_support::{impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{impl_outer_origin, parameter_types}; use versioned_store::InputValidationLengthConstraint; impl_outer_origin! { @@ -28,10 +28,11 @@ parameter_types! { } impl system::Trait for Runtime { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -40,12 +41,20 @@ impl system::Trait for Runtime { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -141,9 +150,7 @@ fn default_versioned_store_genesis_config() -> versioned_store::GenesisConfig { } } -fn build_test_externalities( - config: versioned_store::GenesisConfig, -) -> runtime_io::TestExternalities { +fn build_test_externalities(config: versioned_store::GenesisConfig) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime-modules/versioned-store-permissions/src/operations.rs b/runtime-modules/versioned-store-permissions/src/operations.rs index db020125df..f088a7585e 100644 --- a/runtime-modules/versioned-store-permissions/src/operations.rs +++ b/runtime-modules/versioned-store-permissions/src/operations.rs @@ -1,6 +1,7 @@ use codec::{Decode, Encode}; -use rstd::collections::btree_map::BTreeMap; -use rstd::prelude::*; +use sp_std::collections::btree_map::BTreeMap; +use sp_std::vec; +use sp_std::vec::Vec; use versioned_store::{ClassId, ClassPropertyValue, EntityId, PropertyValue}; #[derive(Encode, Decode, Eq, PartialEq, Clone, Debug)] diff --git a/runtime-modules/versioned-store-permissions/src/permissions.rs b/runtime-modules/versioned-store-permissions/src/permissions.rs index 3d0c3759d6..33afde168f 100644 --- a/runtime-modules/versioned-store-permissions/src/permissions.rs +++ b/runtime-modules/versioned-store-permissions/src/permissions.rs @@ -1,8 +1,8 @@ use codec::{Decode, Encode}; -use srml_support::dispatch; use crate::constraint::*; use crate::credentials::*; +use crate::DispatchResult; /// Permissions for an instance of a Class in the versioned store. #[derive(Encode, Decode, Default, Eq, PartialEq, Clone, Debug)] @@ -48,7 +48,7 @@ where pub fn is_admin( class_permissions: &Self, access_level: &AccessLevel, - ) -> dispatch::Result { + ) -> DispatchResult { match access_level { AccessLevel::System => Ok(()), AccessLevel::Credential(credential) => { @@ -66,7 +66,7 @@ where pub fn can_add_class_schema( class_permissions: &Self, access_level: &AccessLevel, - ) -> dispatch::Result { + ) -> DispatchResult { match access_level { AccessLevel::System => Ok(()), AccessLevel::Credential(credential) => { @@ -84,7 +84,7 @@ where pub fn can_create_entity( class_permissions: &Self, access_level: &AccessLevel, - ) -> dispatch::Result { + ) -> DispatchResult { match access_level { AccessLevel::System => Ok(()), AccessLevel::Credential(credential) => { @@ -104,7 +104,7 @@ where pub fn can_update_entity( class_permissions: &Self, access_level: &AccessLevel, - ) -> dispatch::Result { + ) -> DispatchResult { match access_level { AccessLevel::System => Ok(()), AccessLevel::Credential(credential) => { diff --git a/runtime-modules/versioned-store-permissions/src/tests.rs b/runtime-modules/versioned-store-permissions/src/tests.rs index 07b5fb54ad..a7988dc69b 100644 --- a/runtime-modules/versioned-store-permissions/src/tests.rs +++ b/runtime-modules/versioned-store-permissions/src/tests.rs @@ -2,10 +2,10 @@ use super::*; use crate::mock::*; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; use versioned_store::PropertyType; -use srml_support::{assert_err, assert_ok}; +use frame_support::{assert_err, assert_ok}; fn simple_test_schema() -> Vec { vec![Property { @@ -77,7 +77,7 @@ fn create_class_then_entity_with_default_class_permissions() { let class_id = create_simple_class_with_default_permissions(); - assert!(>::exists(class_id)); + assert!(>::contains_key(class_id)); // default class permissions have empty add_schema acl assert_err!( @@ -94,7 +94,7 @@ fn create_class_then_entity_with_default_class_permissions() { // give members of GROUP_ZERO permission to add schemas let add_schema_set = CredentialSet::from(vec![0]); assert_ok!(Permissions::set_class_add_schemas_set( - Origin::ROOT, + system::RawOrigin::Root.into(), None, class_id, add_schema_set @@ -111,9 +111,15 @@ fn create_class_then_entity_with_default_class_permissions() { // System can always create entities (provided class exists) bypassing any permissions let entity_id_1 = next_entity_id(); - assert_ok!(Permissions::create_entity(Origin::ROOT, None, class_id,)); + assert_ok!(Permissions::create_entity( + system::RawOrigin::Root.into(), + None, + class_id, + )); // entities created by system are "un-owned" - assert!(!>::exists(entity_id_1)); + assert!(!>::contains_key( + entity_id_1 + )); assert_eq!( Permissions::entity_maintainer_by_entity_id(entity_id_1), None @@ -130,7 +136,7 @@ fn create_class_then_entity_with_default_class_permissions() { ); assert_ok!(Permissions::set_class_entities_can_be_created( - Origin::ROOT, + system::RawOrigin::Root.into(), None, class_id, true @@ -148,7 +154,7 @@ fn create_class_then_entity_with_default_class_permissions() { // give members of GROUP_ONE permission to create entities let create_entities_set = CredentialSet::from(vec![1]); assert_ok!(Permissions::set_class_create_entities_set( - Origin::ROOT, + system::RawOrigin::Root.into(), None, class_id, create_entities_set @@ -160,7 +166,9 @@ fn create_class_then_entity_with_default_class_permissions() { Some(1), class_id, )); - assert!(>::exists(entity_id_2)); + assert!(>::contains_key( + entity_id_2 + )); assert_eq!( Permissions::entity_maintainer_by_entity_id(entity_id_2), Some(1) @@ -216,7 +224,7 @@ fn class_permissions_set_admins() { ); assert_err!( Permissions::set_class_admins( - Origin::NONE, //unsigned inherent? + system::RawOrigin::None.into(), //unsigned inherent? class_id, credential_set.clone() ), @@ -225,7 +233,7 @@ fn class_permissions_set_admins() { // root origin can set admins assert_ok!(Permissions::set_class_admins( - Origin::ROOT, + system::RawOrigin::Root.into(), class_id, credential_set.clone() )); @@ -250,7 +258,7 @@ fn class_permissions_set_add_schemas_set() { // root assert_ok!(Permissions::set_class_add_schemas_set( - Origin::ROOT, + system::RawOrigin::Root.into(), None, class_id, credential_set1.clone() @@ -296,7 +304,7 @@ fn class_permissions_set_class_create_entities_set() { // root assert_ok!(Permissions::set_class_create_entities_set( - Origin::ROOT, + system::RawOrigin::Root.into(), None, class_id, credential_set1.clone() @@ -339,7 +347,7 @@ fn class_permissions_set_class_entities_can_be_created() { // root assert_ok!(Permissions::set_class_entities_can_be_created( - Origin::ROOT, + system::RawOrigin::Root.into(), None, class_id, true @@ -387,7 +395,7 @@ fn class_permissions_set_class_entity_permissions() { //root assert_ok!(Permissions::set_class_entity_permissions( - Origin::ROOT, + system::RawOrigin::Root.into(), None, class_id, entity_permissions1.clone() @@ -441,7 +449,7 @@ fn class_permissions_set_class_reference_constraint() { //root assert_ok!(Permissions::set_class_reference_constraint( - Origin::ROOT, + system::RawOrigin::Root.into(), None, class_id, reference_constraint1.clone() @@ -505,7 +513,7 @@ fn batch_transaction_simple() { }]; assert_ok!(Permissions::add_class_schema( - Origin::ROOT, + system::RawOrigin::Root.into(), None, new_class_id, vec![], @@ -564,8 +572,8 @@ fn batch_transaction_simple() { )); // two entities created - assert!(versioned_store::EntityById::exists(entity_id)); - assert!(versioned_store::EntityById::exists(entity_id + 1)); + assert!(versioned_store::EntityById::contains_key(entity_id)); + assert!(versioned_store::EntityById::contains_key(entity_id + 1)); }) } @@ -589,7 +597,7 @@ fn batch_transaction_vector_of_entities() { }]; assert_ok!(Permissions::add_class_schema( - Origin::ROOT, + system::RawOrigin::Root.into(), None, new_class_id, vec![], @@ -645,9 +653,9 @@ fn batch_transaction_vector_of_entities() { )); // three entities created - assert!(versioned_store::EntityById::exists(entity_id)); - assert!(versioned_store::EntityById::exists(entity_id + 1)); - assert!(versioned_store::EntityById::exists(entity_id + 2)); + assert!(versioned_store::EntityById::contains_key(entity_id)); + assert!(versioned_store::EntityById::contains_key(entity_id + 1)); + assert!(versioned_store::EntityById::contains_key(entity_id + 2)); assert_eq!( versioned_store::EntityById::get(entity_id), diff --git a/runtime-modules/versioned-store/Cargo.toml b/runtime-modules/versioned-store/Cargo.toml index 3bae748ff9..83bddd3f22 100755 --- a/runtime-modules/versioned-store/Cargo.toml +++ b/runtime-modules/versioned-store/Cargo.toml @@ -1,50 +1,29 @@ [package] -name = 'substrate-versioned-store' -version = '1.0.1' +name = 'pallet-versioned-store' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' [dependencies] -hex-literal = '0.1.0' -serde = { version = '1.0', optional = true } -serde_derive = { version = '1.0', optional = true } -rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] } -# https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -quote = '<=1.0.2' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [dev-dependencies] -runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} -primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + [features] default = ['std'] std = [ 'serde', - 'serde_derive', 'codec/std', - 'rstd/std', - 'runtime-io/std', - 'runtime-primitives/std', - 'srml-support/std', + 'sp-std/std', + 'frame-support/std', 'system/std', - 'balances/std', - 'timestamp/std', -] +] \ No newline at end of file diff --git a/runtime-modules/versioned-store/src/example.rs b/runtime-modules/versioned-store/src/example.rs index 032d5ff4ab..98fc705f5c 100644 --- a/runtime-modules/versioned-store/src/example.rs +++ b/runtime-modules/versioned-store/src/example.rs @@ -3,7 +3,7 @@ use super::*; use crate::mock::*; -use srml_support::assert_ok; +use frame_support::assert_ok; /// This example uses Class, Properties, Schema and Entity structures /// to describe the Staked podcast channel and its second episode. diff --git a/runtime-modules/versioned-store/src/lib.rs b/runtime-modules/versioned-store/src/lib.rs index 310750080e..f4dd12b126 100755 --- a/runtime-modules/versioned-store/src/lib.rs +++ b/runtime-modules/versioned-store/src/lib.rs @@ -12,17 +12,22 @@ #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "std")] -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; -use rstd::collections::btree_set::BTreeSet; -use rstd::prelude::*; -use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use sp_std::collections::btree_set::BTreeSet; +use sp_std::vec; +use sp_std::vec::Vec; mod example; mod mock; mod tests; +//TODO: Convert errors to the Substrate decl_error! macro. +/// Result with string error message. This exists for backward compatibility purpose. +pub type DispatchResult = Result<(), &'static str>; + // Validation errors // -------------------------------------- @@ -135,7 +140,6 @@ pub struct Entity { /// Values for properties on class that are used by some schema used by this entity! /// Length is no more than Class.properties. pub values: Vec, - // pub deleted: bool, } /// A schema defines what properties describe an entity @@ -253,24 +257,24 @@ decl_storage! { trait Store for Module as VersionedStore { - pub ClassById get(class_by_id) config(): map ClassId => Class; + pub ClassById get(fn class_by_id) config(): map hasher(blake2_128_concat) ClassId => Class; - pub EntityById get(entity_by_id) config(): map EntityId => Entity; + pub EntityById get(fn entity_by_id) config(): map hasher(blake2_128_concat) EntityId => Entity; - pub NextClassId get(next_class_id) config(): ClassId; + pub NextClassId get(fn next_class_id) config(): ClassId; - pub NextEntityId get(next_entity_id) config(): EntityId; + pub NextEntityId get(fn next_entity_id) config(): EntityId; - pub PropertyNameConstraint get(property_name_constraint) + pub PropertyNameConstraint get(fn property_name_constraint) config(): InputValidationLengthConstraint; - pub PropertyDescriptionConstraint get(property_description_constraint) + pub PropertyDescriptionConstraint get(fn property_description_constraint) config(): InputValidationLengthConstraint; - pub ClassNameConstraint get(class_name_constraint) + pub ClassNameConstraint get(fn class_name_constraint) config(): InputValidationLengthConstraint; - pub ClassDescriptionConstraint get(class_description_constraint) + pub ClassDescriptionConstraint get(fn class_description_constraint) config(): InputValidationLengthConstraint; } } @@ -346,7 +350,7 @@ impl Module { // TODO Use BTreeSet for prop unique names when switched to Substrate 2. // There is no support for BTreeSet in Substrate 1 runtime. - // use rstd::collections::btree_set::BTreeSet; + // use sp_std::collections::btree_set::BTreeSet; let mut unique_prop_names = BTreeSet::new(); for prop in class.properties.iter() { unique_prop_names.insert(prop.name.clone()); @@ -375,7 +379,7 @@ impl Module { // Check validity of Internal(ClassId) for new_properties. let has_unknown_internal_id = new_properties.iter().any(|prop| match prop.prop_type { - PropertyType::Internal(other_class_id) => !ClassById::exists(other_class_id), + PropertyType::Internal(other_class_id) => !ClassById::contains_key(other_class_id), _ => false, }); ensure!( @@ -434,7 +438,7 @@ impl Module { entity_id: EntityId, schema_id: u16, property_values: Vec, - ) -> dispatch::Result { + ) -> DispatchResult { Self::ensure_known_entity_id(entity_id)?; let (entity, class) = Self::get_entity_and_class(entity_id); @@ -521,7 +525,7 @@ impl Module { pub fn update_entity_property_values( entity_id: EntityId, new_property_values: Vec, - ) -> dispatch::Result { + ) -> DispatchResult { Self::ensure_known_entity_id(entity_id)?; let (entity, class) = Self::get_entity_and_class(entity_id); @@ -580,7 +584,7 @@ impl Module { } // Commented out for now <- requested by Bedeho. - // pub fn delete_entity(entity_id: EntityId) -> dispatch::Result { + // pub fn delete_entity(entity_id: EntityId) -> DispatchResult { // Self::ensure_known_entity_id(entity_id)?; // let is_deleted = EntityById::get(entity_id).deleted; @@ -597,17 +601,17 @@ impl Module { // Helper functions: // ---------------------------------------------------------------- - pub fn ensure_known_class_id(class_id: ClassId) -> dispatch::Result { - ensure!(ClassById::exists(class_id), ERROR_CLASS_NOT_FOUND); + pub fn ensure_known_class_id(class_id: ClassId) -> DispatchResult { + ensure!(ClassById::contains_key(class_id), ERROR_CLASS_NOT_FOUND); Ok(()) } - pub fn ensure_known_entity_id(entity_id: EntityId) -> dispatch::Result { - ensure!(EntityById::exists(entity_id), ERROR_ENTITY_NOT_FOUND); + pub fn ensure_known_entity_id(entity_id: EntityId) -> DispatchResult { + ensure!(EntityById::contains_key(entity_id), ERROR_ENTITY_NOT_FOUND); Ok(()) } - pub fn ensure_valid_internal_prop(value: PropertyValue, prop: Property) -> dispatch::Result { + pub fn ensure_valid_internal_prop(value: PropertyValue, prop: Property) -> DispatchResult { match (value, prop.prop_type) { (PV::Internal(entity_id), PT::Internal(class_id)) => { Self::ensure_known_class_id(class_id)?; @@ -625,7 +629,7 @@ impl Module { pub fn is_unknown_internal_entity_id(id: PropertyValue) -> bool { if let PropertyValue::Internal(entity_id) = id { - !EntityById::exists(entity_id) + !EntityById::contains_key(entity_id) } else { false } @@ -637,10 +641,7 @@ impl Module { (entity, class) } - pub fn ensure_property_value_is_valid( - value: PropertyValue, - prop: Property, - ) -> dispatch::Result { + pub fn ensure_property_value_is_valid(value: PropertyValue, prop: Property) -> DispatchResult { Self::ensure_prop_value_matches_its_type(value.clone(), prop.clone())?; Self::ensure_valid_internal_prop(value.clone(), prop.clone())?; Self::validate_max_len_if_text_prop(value.clone(), prop.clone())?; @@ -648,14 +649,14 @@ impl Module { Ok(()) } - pub fn validate_max_len_if_text_prop(value: PropertyValue, prop: Property) -> dispatch::Result { + pub fn validate_max_len_if_text_prop(value: PropertyValue, prop: Property) -> DispatchResult { match (value, prop.prop_type) { (PV::Text(text), PT::Text(max_len)) => Self::validate_max_len_of_text(text, max_len), _ => Ok(()), } } - pub fn validate_max_len_of_text(text: Vec, max_len: u16) -> dispatch::Result { + pub fn validate_max_len_of_text(text: Vec, max_len: u16) -> DispatchResult { if text.len() <= max_len as usize { Ok(()) } else { @@ -667,7 +668,7 @@ impl Module { pub fn validate_max_len_if_vec_prop( value: PropertyValue, prop: Property, - ) -> dispatch::Result { + ) -> DispatchResult { fn validate_vec_len(vec: Vec, max_len: u16) -> bool { vec.len() <= max_len as usize @@ -724,7 +725,7 @@ impl Module { pub fn ensure_prop_value_matches_its_type( value: PropertyValue, prop: Property, - ) -> dispatch::Result { + ) -> DispatchResult { if Self::does_prop_value_match_type(value, prop) { Ok(()) } else { @@ -774,7 +775,7 @@ impl Module { } } - pub fn ensure_property_name_is_valid(text: &[u8]) -> dispatch::Result { + pub fn ensure_property_name_is_valid(text: &[u8]) -> DispatchResult { PropertyNameConstraint::get().ensure_valid( text.len(), ERROR_PROPERTY_NAME_TOO_SHORT, @@ -782,7 +783,7 @@ impl Module { ) } - pub fn ensure_property_description_is_valid(text: &[u8]) -> dispatch::Result { + pub fn ensure_property_description_is_valid(text: &[u8]) -> DispatchResult { PropertyDescriptionConstraint::get().ensure_valid( text.len(), ERROR_PROPERTY_DESCRIPTION_TOO_SHORT, @@ -790,7 +791,7 @@ impl Module { ) } - pub fn ensure_class_name_is_valid(text: &[u8]) -> dispatch::Result { + pub fn ensure_class_name_is_valid(text: &[u8]) -> DispatchResult { ClassNameConstraint::get().ensure_valid( text.len(), ERROR_CLASS_NAME_TOO_SHORT, @@ -798,7 +799,7 @@ impl Module { ) } - pub fn ensure_class_description_is_valid(text: &[u8]) -> dispatch::Result { + pub fn ensure_class_description_is_valid(text: &[u8]) -> DispatchResult { ClassDescriptionConstraint::get().ensure_valid( text.len(), ERROR_CLASS_DESCRIPTION_TOO_SHORT, diff --git a/runtime-modules/versioned-store/src/mock.rs b/runtime-modules/versioned-store/src/mock.rs index 5bd79e3691..8d8f2df93f 100644 --- a/runtime-modules/versioned-store/src/mock.rs +++ b/runtime-modules/versioned-store/src/mock.rs @@ -3,13 +3,13 @@ use crate::*; use crate::{GenesisConfig, Module, Trait}; -use primitives::H256; -use runtime_primitives::{ +use frame_support::{assert_err, assert_ok, impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{assert_err, assert_ok, impl_outer_origin, parameter_types}; impl_outer_origin! { pub enum Origin for Runtime {} @@ -27,10 +27,11 @@ parameter_types! { } impl system::Trait for Runtime { + type BaseCallFilter = (); type Origin = Origin; + type Call = (); type Index = u64; type BlockNumber = u64; - type Call = (); type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -39,12 +40,20 @@ impl system::Trait for Runtime { type Event = (); type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -60,15 +69,9 @@ pub const UNKNOWN_ENTITY_ID: EntityId = 222; pub const UNKNOWN_PROP_ID: u16 = 333; -// pub const UNKNOWN_SCHEMA_ID: u16 = 444; - pub const SCHEMA_ID_0: u16 = 0; pub const SCHEMA_ID_1: u16 = 1; -// pub fn generate_text(len: usize) -> Vec { -// vec![b'x'; len] -// } - pub fn good_class_name() -> Vec { b"Name of a class".to_vec() } @@ -206,7 +209,7 @@ pub fn assert_class_schemas(class_id: ClassId, expected_schema_prop_ids: Vec GenesisConfig { } } -fn build_test_externalities(config: GenesisConfig) -> runtime_io::TestExternalities { +fn build_test_externalities(config: GenesisConfig) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default() .build_storage::() .unwrap(); @@ -253,7 +256,5 @@ pub fn with_test_externalities R>(f: F) -> R { build_test_externalities(config).execute_with(f) } -// pub type System = system::Module; - /// Export module on a test runtime pub type TestModule = Module; diff --git a/runtime-modules/versioned-store/src/tests.rs b/runtime-modules/versioned-store/src/tests.rs index 3e2fee162a..506f31007d 100644 --- a/runtime-modules/versioned-store/src/tests.rs +++ b/runtime-modules/versioned-store/src/tests.rs @@ -3,7 +3,7 @@ use super::*; use crate::mock::*; -use srml_support::{assert_err, assert_ok}; +use frame_support::{assert_err, assert_ok}; // Create class // -------------------------------------- diff --git a/runtime-modules/working-group/Cargo.toml b/runtime-modules/working-group/Cargo.toml index 97284ebb61..98bbe23543 100644 --- a/runtime-modules/working-group/Cargo.toml +++ b/runtime-modules/working-group/Cargo.toml @@ -1,111 +1,44 @@ [package] -name = 'substrate-working-group-module' -version = '1.1.0' +name = 'pallet-working-group' +version = '3.0.0' authors = ['Joystream contributors'] edition = '2018' +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +membership = { package = 'pallet-membership', default-features = false, path = '../membership'} +stake = { package = 'pallet-stake', default-features = false, path = '../stake'} +hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'} +minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'} +recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'} +common = { package = 'pallet-common', default-features = false, path = '../common'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + [features] default = ['std'] std = [ - 'sr-primitives/std', - 'srml-support/std', - 'system/std', - 'codec/std', - 'rstd/std', 'serde', - 'hiring/std', - 'stake/std', - 'membership/std', - 'minting/std', - 'recurringrewards/std', - 'common/std', -] - -[dependencies.primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.hiring] -default_features = false -package = 'substrate-hiring-module' -path = '../hiring' - -[dependencies.stake] -default_features = false -package = 'substrate-stake-module' -path = '../stake' - -[dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../membership' - -[dependencies.minting] -default_features = false -package = 'substrate-token-mint-module' -path = '../token-minting' - -[dependencies.recurringrewards] -default_features = false -package = 'substrate-recurring-reward-module' -path = '../recurring-reward' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../common' - -[dev-dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.balances] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-balances' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dev-dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' \ No newline at end of file + 'codec/std', + 'sp-std/std', + 'frame-support/std', + 'system/std', + 'sp-arithmetic/std', + 'sp-runtime/std', + 'membership/std', + 'stake/std', + 'hiring/std', + 'minting/std', + 'recurringrewards/std', + 'common/std', +] \ No newline at end of file diff --git a/runtime-modules/working-group/src/errors.rs b/runtime-modules/working-group/src/errors.rs index 14a5a8d10c..7b5f8c020b 100644 --- a/runtime-modules/working-group/src/errors.rs +++ b/runtime-modules/working-group/src/errors.rs @@ -1,8 +1,11 @@ -use srml_support::decl_error; +#![warn(missing_docs)] + +use crate::{Instance, Module, Trait}; +use frame_support::decl_error; decl_error! { /// Discussion module predefined errors - pub enum Error { + pub enum Error for Module, I: Instance>{ /// Provided stake balance cannot be zero. StakeBalanceCannotBeZero, @@ -299,17 +302,9 @@ decl_error! { /// Invalid OpeningPolicyCommitment parameter (application_rationing_policy): /// max_active_applicants should be non-zero. ApplicationRationingPolicyMaxActiveApplicantsIsZero, - } -} -impl From for Error { - fn from(error: system::Error) -> Self { - match error { - system::Error::Other(msg) => Error::Other(msg), - system::Error::RequireRootOrigin => Error::RequireRootOrigin, - system::Error::RequireSignedOrigin => Error::RequireSignedOrigin, - _ => Error::Other(error.into()), - } + /// Minting error: NextAdjustmentInPast + MintingErrorNextAdjustmentInPast, } } @@ -323,11 +318,19 @@ pub struct WrappedError { #[macro_export] macro_rules! ensure_on_wrapped_error { ($call:expr) => {{ - { $call }.map_err(|err| crate::WrappedError { error: err }) + { $call } + .map_err(|err| crate::WrappedError { error: err }) + .map_err(|err| { + let e: Error = err.into(); + + e + }) }}; } -impl rstd::convert::From> for Error { +impl, I: Instance> + sp_std::convert::From> for Error +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::BeginAcceptingApplicationsError::OpeningDoesNotExist => { @@ -340,7 +343,9 @@ impl rstd::convert::From> } } -impl rstd::convert::From> for Error { +impl, I: Instance> sp_std::convert::From> + for Error +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::AddOpeningError::OpeningMustActivateInTheFuture => { @@ -367,7 +372,9 @@ impl rstd::convert::From> for Error { } } -impl rstd::convert::From> for Error { +impl, I: Instance> sp_std::convert::From> + for Error +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::BeginReviewError::OpeningDoesNotExist => { @@ -380,7 +387,9 @@ impl rstd::convert::From> for Error { } } -impl rstd::convert::From>> for Error { +impl, I: Instance> sp_std::convert::From>> + for Error +{ fn from(wrapper: WrappedError>) -> Self { match wrapper.error { hiring::FillOpeningError::::OpeningDoesNotExist => { @@ -444,7 +453,9 @@ impl rstd::convert::From> for Error { +impl, I: Instance> + sp_std::convert::From> for Error +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::DeactivateApplicationError::ApplicationDoesNotExist => { @@ -466,7 +477,9 @@ impl rstd::convert::From> for E } } -impl rstd::convert::From> for Error { +impl, I: Instance> sp_std::convert::From> + for Error +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { hiring::AddApplicationError::OpeningDoesNotExist => { @@ -491,7 +504,10 @@ impl rstd::convert::From> for Error { } } -impl rstd::convert::From> for Error { +impl, I: Instance> + sp_std::convert::From> + for Error +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { membership::MemberControllerAccountDidNotSign::UnsignedOrigin => { @@ -507,7 +523,9 @@ impl rstd::convert::From> for Error { +impl, I: Instance> sp_std::convert::From> + for Error +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { recurringrewards::RewardsError::NextPaymentNotInFuture => { @@ -526,8 +544,9 @@ impl rstd::convert::From> for Error } } -impl rstd::convert::From>> - for Error +impl, I: Instance> + sp_std::convert::From>> + for Error { fn from(wrapper: WrappedError>) -> Self { match wrapper.error { @@ -554,10 +573,10 @@ impl rstd::convert::From, I: Instance> + sp_std::convert::From< WrappedError>, - > for Error + > for Error { fn from( wrapper: WrappedError>, @@ -586,8 +605,9 @@ impl } } -impl rstd::convert::From>> - for Error +impl, I: Instance> + sp_std::convert::From>> + for Error { fn from(wrapper: WrappedError>) -> Self { match wrapper.error { @@ -607,8 +627,9 @@ impl rstd::convert::From>> - for Error +impl, I: Instance> + sp_std::convert::From>> + for Error { fn from(wrapper: WrappedError>) -> Self { match wrapper.error { @@ -634,8 +655,9 @@ impl rstd::convert::From>> - for Error +impl, I: Instance> + sp_std::convert::From>> + for Error { fn from(wrapper: WrappedError>) -> Self { match wrapper.error { @@ -650,11 +672,13 @@ impl rstd::convert::From> for Error { +impl, I: Instance> sp_std::convert::From> + for Error +{ fn from(wrapper: WrappedError) -> Self { match wrapper.error { minting::GeneralError::MintNotFound => Error::CannotFindMint, - minting::GeneralError::NextAdjustmentInPast => Error::Other("NextAdjustmentInPast"), + minting::GeneralError::NextAdjustmentInPast => Error::MintingErrorNextAdjustmentInPast, } } } diff --git a/runtime-modules/working-group/src/lib.rs b/runtime-modules/working-group/src/lib.rs index 237df79141..d4206a67c5 100644 --- a/runtime-modules/working-group/src/lib.rs +++ b/runtime-modules/working-group/src/lib.rs @@ -52,14 +52,14 @@ mod types; #[macro_use] mod errors; -use rstd::collections::btree_map::BTreeMap; -use rstd::collections::btree_set::BTreeSet; -use rstd::prelude::*; -use rstd::vec::Vec; -use sr_primitives::traits::{Bounded, One, Zero}; -use srml_support::traits::{Currency, ExistenceRequirement, Get, Imbalance, WithdrawReasons}; -use srml_support::{decl_event, decl_module, decl_storage, ensure, print, StorageValue}; - +use frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::storage::IterableStorageMap; +use frame_support::traits::{Currency, ExistenceRequirement, Get, Imbalance, WithdrawReasons}; +use frame_support::{decl_event, decl_module, decl_storage, ensure, print, StorageValue}; +use sp_arithmetic::traits::{Bounded, One, Zero}; +use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; +use sp_std::vec; +use sp_std::vec::Vec; use system::{ensure_root, ensure_signed}; use crate::types::ExitInitiationOrigin; @@ -283,48 +283,51 @@ decl_event!( decl_storage! { trait Store for Module, I: Instance> as WorkingGroup { /// The mint currently funding the rewards for this module. - pub Mint get(mint) : ::MintId; + pub Mint get(fn mint) : ::MintId; /// The current lead. - pub CurrentLead get(current_lead) : Option>; + pub CurrentLead get(fn current_lead) : Option>; /// Next identifier value for new worker opening. - pub NextOpeningId get(next_opening_id): OpeningId; + pub NextOpeningId get(fn next_opening_id): OpeningId; /// Maps identifier to worker opening. - pub OpeningById get(opening_by_id): linked_map OpeningId => OpeningOf; + pub OpeningById get(fn opening_by_id): map hasher(blake2_128_concat) + OpeningId => OpeningOf; /// Opening human readable text length limits - pub OpeningHumanReadableText get(opening_human_readable_text): InputValidationLengthConstraint; + pub OpeningHumanReadableText get(fn opening_human_readable_text): InputValidationLengthConstraint; /// Maps identifier to worker application on opening. - pub ApplicationById get(application_by_id) : linked_map ApplicationId => ApplicationOf; + pub ApplicationById get(fn application_by_id) : map hasher(blake2_128_concat) + ApplicationId => ApplicationOf; /// Next identifier value for new worker application. - pub NextApplicationId get(next_application_id) : ApplicationId; + pub NextApplicationId get(fn next_application_id) : ApplicationId; /// Worker application human readable text length limits - pub WorkerApplicationHumanReadableText get(application_human_readable_text) : InputValidationLengthConstraint; + pub WorkerApplicationHumanReadableText get(fn application_human_readable_text) : InputValidationLengthConstraint; /// Maps identifier to corresponding worker. - pub WorkerById get(worker_by_id) : linked_map WorkerId => WorkerOf; + pub WorkerById get(fn worker_by_id) : map hasher(blake2_128_concat) + WorkerId => WorkerOf; /// Count of active workers. pub ActiveWorkerCount get(fn active_worker_count): u32; /// Next identifier for new worker. - pub NextWorkerId get(next_worker_id) : WorkerId; + pub NextWorkerId get(fn next_worker_id) : WorkerId; /// Worker exit rationale text length limits. - pub WorkerExitRationaleText get(worker_exit_rationale_text) : InputValidationLengthConstraint; + pub WorkerExitRationaleText get(fn worker_exit_rationale_text) : InputValidationLengthConstraint; /// Map member id by hiring application id. /// Required by StakingEventsHandler callback call to refund the balance on unstaking. pub MemberIdByHiringApplicationId get(fn member_id_by_hiring_application_id): - map HiringApplicationId => MemberId; + map hasher(blake2_128_concat) HiringApplicationId => MemberId; } add_extra_genesis { - config(phantom): rstd::marker::PhantomData; + config(phantom): sp_std::marker::PhantomData; config(storage_working_group_mint_capacity): minting::BalanceOf; config(opening_human_readable_text_constraint): InputValidationLengthConstraint; config(worker_application_human_readable_text_constraint): InputValidationLengthConstraint; @@ -346,7 +349,7 @@ decl_module! { fn deposit_event() = default; /// Predefined errors - type Error = Error; + type Error = Error; /// Exports const - max simultaneous active worker number. const MaxWorkerNumberLimit: u32 = T::MaxWorkerNumberLimit::get(); @@ -354,6 +357,7 @@ decl_module! { // ****************** Roles lifecycle ********************** /// Update the associated role account of the active worker/lead. + #[weight = 10_000_000] // TODO: adjust weight pub fn update_role_account( origin, worker_id: WorkerId, @@ -381,6 +385,7 @@ decl_module! { } /// Update the reward account associated with a set reward relationship for the active worker. + #[weight = 10_000_000] // TODO: adjust weight pub fn update_reward_account( origin, worker_id: WorkerId, @@ -412,6 +417,7 @@ decl_module! { /// Update the reward amount associated with a set reward relationship for the active worker. /// Require signed leader origin or the root (to update leader reward amount). + #[weight = 10_000_000] // TODO: adjust weight pub fn update_reward_amount( origin, worker_id: WorkerId, @@ -445,6 +451,7 @@ decl_module! { } /// Leave the role by the active worker. + #[weight = 10_000_000] // TODO: adjust weight pub fn leave_role( origin, worker_id: WorkerId, @@ -467,6 +474,7 @@ decl_module! { /// Terminate the active worker by the lead. /// Require signed leader origin or the root (to terminate the leader role). + #[weight = 10_000_000] // TODO: adjust weight pub fn terminate_role( origin, worker_id: WorkerId, @@ -504,6 +512,7 @@ decl_module! { /// Add an opening for a worker role. /// Require signed leader origin or the root (to add opening for the leader position). + #[weight = 10_000_000] // TODO: adjust weight pub fn add_opening( origin, activate_at: hiring::ActivateOpeningAt, @@ -559,6 +568,7 @@ decl_module! { /// Begin accepting worker applications to an opening that is active. /// Require signed leader origin or the root (to accept applications for the leader position). + #[weight = 10_000_000] // TODO: adjust weight pub fn accept_applications(origin, opening_id: OpeningId) { // Ensure opening exists in this working group // NB: Even though call to hiring module will have implicit check for @@ -585,6 +595,7 @@ decl_module! { } /// Apply on a worker opening. + #[weight = 10_000_000] // TODO: adjust weight pub fn apply_on_opening( origin, member_id: T::MemberId, @@ -604,7 +615,7 @@ decl_module! { ensure!( membership::Module::::ensure_member_controller_account(&source_account, &member_id).is_ok() || membership::Module::::ensure_member_root_account(&source_account, &member_id).is_ok(), - Error::OriginIsNeitherMemberControllerOrRoot + Error::::OriginIsNeitherMemberControllerOrRoot ); // Ensure worker opening exists @@ -615,7 +626,7 @@ decl_module! { vec![&opt_role_stake_balance, &opt_application_stake_balance], &source_account ) - .map_err(|_| Error::InsufficientBalanceToApply)?; + .map_err(|_| Error::::InsufficientBalanceToApply)?; // Ensure application text is valid Self::ensure_application_text_is_valid(&human_readable_text)?; @@ -679,6 +690,7 @@ decl_module! { } /// Withdraw the worker application. Can be done by the worker itself only. + #[weight = 10_000_000] // TODO: adjust weight pub fn withdraw_application( origin, application_id: ApplicationId @@ -692,7 +704,7 @@ decl_module! { // Ensure that signer is applicant role account ensure!( signer_account == application.role_account_id, - Error::OriginIsNotApplicant + Error::::OriginIsNotApplicant ); // @@ -714,6 +726,7 @@ decl_module! { } /// Terminate the worker application. Can be done by the lead only. + #[weight = 10_000_000] // TODO: adjust weight pub fn terminate_application( origin, application_id: ApplicationId @@ -745,6 +758,7 @@ decl_module! { /// Begin reviewing, and therefore not accepting new applications. /// Require signed leader origin or the root (to begin review applications for the leader position). + #[weight = 10_000_000] // TODO: adjust weight pub fn begin_applicant_review(origin, opening_id: OpeningId) { // Ensure opening exists // NB: Even though call to hiring modul will have implicit check for @@ -770,6 +784,7 @@ decl_module! { /// Fill opening for worker/lead. /// Require signed leader origin or the root (to fill opening for the leader position). + #[weight = 10_000_000] // TODO: adjust weight pub fn fill_opening( origin, opening_id: OpeningId, @@ -786,12 +801,12 @@ decl_module! { ensure!( potential_worker_number <= T::MaxWorkerNumberLimit::get(), - Error::MaxActiveWorkerNumberExceeded + Error::::MaxActiveWorkerNumberExceeded ); // Cannot hire a lead when another leader exists. if matches!(opening.opening_type, OpeningType::Leader) { - ensure!(!>::exists(), Error::CannotHireLeaderWhenLeaderExists); + ensure!(!>::exists(), Error::::CannotHireLeaderWhenLeaderExists); } // Ensure a mint exists if lead is providing a reward for positions being filled @@ -802,7 +817,7 @@ decl_module! { // Make sure valid parameters are selected for next payment at block number ensure!(policy.next_payment_at_block > >::block_number(), - Error::FillOpeningInvalidNextPaymentBlock); + Error::::FillOpeningInvalidNextPaymentBlock); // The verified reward settings to use Some((mint_id, policy)) @@ -828,7 +843,7 @@ decl_module! { ensure!( number_of_successful_applications == num_provided_successful_application_ids, - Error::SuccessfulWorkerApplicationDoesNotExist + Error::::SuccessfulWorkerApplicationDoesNotExist ); // Attempt to fill opening @@ -839,7 +854,7 @@ decl_module! { // Check for a single application for a leader. if matches!(opening.opening_type, OpeningType::Leader) { - ensure!(successful_application_ids.len() == 1, Error::CannotHireMultipleLeaders); + ensure!(successful_application_ids.len() == 1, Error::::CannotHireMultipleLeaders); } // NB: Combined ensure check and mutation in hiring module @@ -873,6 +888,7 @@ decl_module! { /// Slashes the worker stake, demands a leader origin. No limits, no actions on zero stake. /// If slashing balance greater than the existing stake - stake is slashed to zero. /// Require signed leader origin or the root (to slash the leader stake). + #[weight = 10_000_000] // TODO: adjust weight pub fn slash_stake(origin, worker_id: WorkerId, balance: BalanceOf) { // Ensure lead is set or it is the council terminating the leader. Self::ensure_origin_for_leader(origin, worker_id)?; @@ -880,9 +896,9 @@ decl_module! { // Ensuring worker actually exists. let worker = Self::ensure_worker_exists(&worker_id)?; - ensure!(balance != >::zero(), Error::StakeBalanceCannotBeZero); + ensure!(balance != >::zero(), Error::::StakeBalanceCannotBeZero); - let stake_profile = worker.role_stake_profile.ok_or(Error::NoWorkerStakeProfile)?; + let stake_profile = worker.role_stake_profile.ok_or(Error::::NoWorkerStakeProfile)?; // // == MUTATION SAFE == @@ -903,15 +919,16 @@ decl_module! { /// Decreases the worker/lead stake and returns the remainder to the worker role_account_id. /// Can be decreased to zero, no actions on zero stake. /// Require signed leader origin or the root (to decrease the leader stake). + #[weight = 10_000_000] // TODO: adjust weight pub fn decrease_stake(origin, worker_id: WorkerId, balance: BalanceOf) { // Ensure lead is set or it is the council terminating the leader. Self::ensure_origin_for_leader(origin, worker_id)?; let worker = Self::ensure_worker_exists(&worker_id)?; - ensure!(balance != >::zero(), Error::StakeBalanceCannotBeZero); + ensure!(balance != >::zero(), Error::::StakeBalanceCannotBeZero); - let stake_profile = worker.role_stake_profile.ok_or(Error::NoWorkerStakeProfile)?; + let stake_profile = worker.role_stake_profile.ok_or(Error::::NoWorkerStakeProfile)?; // // == MUTATION SAFE == @@ -931,13 +948,14 @@ decl_module! { /// Increases the worker/lead stake, demands a worker origin. Transfers tokens from the worker /// role_account_id to the stake. No limits on the stake. + #[weight = 10_000_000] // TODO: adjust weight pub fn increase_stake(origin, worker_id: WorkerId, balance: BalanceOf) { // Checks worker origin, worker existence let worker = Self::ensure_worker_signed(origin, &worker_id)?; - ensure!(balance != >::zero(), Error::StakeBalanceCannotBeZero); + ensure!(balance != >::zero(), Error::::StakeBalanceCannotBeZero); - let stake_profile = worker.role_stake_profile.ok_or(Error::NoWorkerStakeProfile)?; + let stake_profile = worker.role_stake_profile.ok_or(Error::::NoWorkerStakeProfile)?; // // == MUTATION SAFE == @@ -956,6 +974,7 @@ decl_module! { } /// Sets the capacity to enable working group budget. Requires root origin. + #[weight = 10_000_000] // TODO: adjust weight pub fn set_mint_capacity( origin, new_capacity: minting::BalanceOf @@ -965,7 +984,7 @@ decl_module! { let mint_id = Self::mint(); // Technically this is a bug-check and should not be here. - ensure!(>::exists(mint_id), Error::CannotFindMint); + ensure!(>::contains_key(mint_id), Error::::CannotFindMint); // Mint must exist - it is set at genesis or migration. let mint = >::mints(mint_id); @@ -992,9 +1011,9 @@ decl_module! { impl, I: Instance> Module { fn ensure_opening_policy_commitment_is_valid( policy_commitment: &OpeningPolicyCommitment>, - ) -> Result<(), Error> { + ) -> Result<(), Error> { // Helper function. Ensures that unstaking period is None or non-zero. - fn check_unstaking_period( + fn check_unstaking_period( unstaking_period: Option, error: Error, ) -> Result<(), Error> { @@ -1005,7 +1024,7 @@ impl, I: Instance> Module { } // Helper function. Ensures that unstaking period is None or non-zero in the staking_policy. - fn check_staking_policy( + fn check_staking_policy( staking_policy: Option>, crowded_out_unstaking_period_error: Error, review_period_unstaking_period_error: Error, @@ -1028,49 +1047,49 @@ impl, I: Instance> Module { // Check all fill_opening unstaking periods. check_unstaking_period( policy_commitment.fill_opening_failed_applicant_role_stake_unstaking_period, - Error::FillOpeningFailedApplicantRoleStakeUnstakingPeriodIsZero, + Error::::FillOpeningFailedApplicantRoleStakeUnstakingPeriodIsZero, )?; check_unstaking_period( policy_commitment.fill_opening_failed_applicant_application_stake_unstaking_period, - Error::FillOpeningFailedApplicantApplicationStakeUnstakingPeriodIsZero, + Error::::FillOpeningFailedApplicantApplicationStakeUnstakingPeriodIsZero, )?; check_unstaking_period( policy_commitment.fill_opening_successful_applicant_application_stake_unstaking_period, - Error::FillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriodIsZero, + Error::::FillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriodIsZero, )?; check_unstaking_period( policy_commitment.exit_role_stake_unstaking_period, - Error::ExitRoleStakeUnstakingPeriodIsZero, + Error::::ExitRoleStakeUnstakingPeriodIsZero, )?; check_unstaking_period( policy_commitment.exit_role_application_stake_unstaking_period, - Error::ExitRoleApplicationStakeUnstakingPeriodIsZero, + Error::::ExitRoleApplicationStakeUnstakingPeriodIsZero, )?; check_unstaking_period( policy_commitment.terminate_role_stake_unstaking_period, - Error::TerminateRoleStakeUnstakingPeriodIsZero, + Error::::TerminateRoleStakeUnstakingPeriodIsZero, )?; check_unstaking_period( policy_commitment.terminate_application_stake_unstaking_period, - Error::TerminateApplicationStakeUnstakingPeriodIsZero, + Error::::TerminateApplicationStakeUnstakingPeriodIsZero, )?; check_staking_policy( policy_commitment.role_staking_policy.clone(), - Error::RoleStakingPolicyCrowdedOutUnstakingPeriodIsZero, - Error::RoleStakingPolicyReviewPeriodUnstakingPeriodIsZero, + Error::::RoleStakingPolicyCrowdedOutUnstakingPeriodIsZero, + Error::::RoleStakingPolicyReviewPeriodUnstakingPeriodIsZero, )?; check_staking_policy( policy_commitment.application_staking_policy.clone(), - Error::ApplicationStakingPolicyCrowdedOutUnstakingPeriodIsZero, - Error::ApplicationStakingPolicyReviewPeriodUnstakingPeriodIsZero, + Error::::ApplicationStakingPolicyCrowdedOutUnstakingPeriodIsZero, + Error::::ApplicationStakingPolicyReviewPeriodUnstakingPeriodIsZero, )?; if let Some(application_rationing_policy) = @@ -1078,7 +1097,7 @@ impl, I: Instance> Module { { ensure!( application_rationing_policy.max_active_applicants > 0, - Error::ApplicationRationingPolicyMaxActiveApplicantsIsZero + Error::::ApplicationRationingPolicyMaxActiveApplicantsIsZero ); } @@ -1088,7 +1107,7 @@ impl, I: Instance> Module { fn ensure_origin_for_opening_type( origin: T::Origin, opening_type: OpeningType, - ) -> Result<(), Error> { + ) -> DispatchResult { match opening_type { OpeningType::Worker => { // Ensure lead is set and is origin signer. @@ -1104,7 +1123,7 @@ impl, I: Instance> Module { fn ensure_origin_for_leader( origin: T::Origin, worker_id: WorkerId, - ) -> Result { + ) -> Result { let leader_worker_id = Self::ensure_lead_is_set()?; let (worker_opening_type, exit_origin) = if leader_worker_id == worker_id { @@ -1118,51 +1137,51 @@ impl, I: Instance> Module { Ok(exit_origin) } - fn ensure_lead_is_set() -> Result, Error> { + fn ensure_lead_is_set() -> Result, Error> { let leader_worker_id = Self::current_lead(); if let Some(leader_worker_id) = leader_worker_id { Ok(leader_worker_id) } else { - Err(Error::CurrentLeadNotSet) + Err(Error::::CurrentLeadNotSet) } } // Checks that provided lead account id belongs to the current working group leader - fn ensure_is_lead_account(lead_account_id: T::AccountId) -> Result<(), Error> { + fn ensure_is_lead_account(lead_account_id: T::AccountId) -> DispatchResult { let leader_worker_id = Self::ensure_lead_is_set()?; let leader = Self::worker_by_id(leader_worker_id); if leader.role_account_id != lead_account_id { - return Err(Error::IsNotLeadAccount); + return Err(Error::::IsNotLeadAccount.into()); } Ok(()) } - fn ensure_opening_human_readable_text_is_valid(text: &[u8]) -> Result<(), Error> { + fn ensure_opening_human_readable_text_is_valid(text: &[u8]) -> DispatchResult { >::get() .ensure_valid( text.len(), - Error::OpeningTextTooShort.into(), - Error::OpeningTextTooLong.into(), + Error::::OpeningTextTooShort.into(), + Error::::OpeningTextTooLong.into(), ) - .map_err(|e| e.into()) + .map_err(|e| DispatchError::Other(e)) } /// Ensures origin is signed by the leader. - pub fn ensure_origin_is_active_leader(origin: T::Origin) -> Result<(), Error> { + pub fn ensure_origin_is_active_leader(origin: T::Origin) -> DispatchResult { // Ensure is signed let signer = ensure_signed(origin)?; Self::ensure_is_lead_account(signer) } - fn ensure_opening_exists(opening_id: &OpeningId) -> Result, Error> { + fn ensure_opening_exists(opening_id: &OpeningId) -> Result, Error> { ensure!( - OpeningById::::exists(opening_id), - Error::OpeningDoesNotExist + OpeningById::::contains_key(opening_id), + Error::::OpeningDoesNotExist ); let opening = OpeningById::::get(opening_id); @@ -1175,7 +1194,7 @@ impl, I: Instance> Module { fn ensure_member_has_no_active_application_on_opening( applications: ApplicationIdSet, member_id: T::MemberId, - ) -> Result<(), Error> { + ) -> Result<(), Error> { for application_id in applications { let application = ApplicationById::::get(application_id); // Look for application by the member for the opening @@ -1186,21 +1205,21 @@ impl, I: Instance> Module { let application = >::get(application.hiring_application_id); // Return error if application is in active stage if application.stage == hiring::ApplicationStage::Active { - return Err(Error::MemberHasActiveApplicationOnOpening); + return Err(Error::::MemberHasActiveApplicationOnOpening); } } // Member does not have any active applications to the opening Ok(()) } - fn ensure_application_text_is_valid(text: &[u8]) -> Result<(), Error> { + fn ensure_application_text_is_valid(text: &[u8]) -> DispatchResult { >::get() .ensure_valid( text.len(), - Error::WorkerApplicationTextTooShort.into(), - Error::WorkerApplicationTextTooLong.into(), + Error::::WorkerApplicationTextTooShort.into(), + Error::::WorkerApplicationTextTooLong.into(), ) - .map_err(|e| e.into()) + .map_err(|e| DispatchError::Other(e)) } // CRITICAL: @@ -1213,7 +1232,7 @@ impl, I: Instance> Module { fn ensure_can_make_stake_imbalance( opt_balances: Vec<&Option>>, source_account: &T::AccountId, - ) -> Result<(), Error> { + ) -> DispatchResult { let zero_balance = as Zero>::zero(); // Total amount to be staked @@ -1228,7 +1247,7 @@ impl, I: Instance> Module { if total_amount > zero_balance { // Ensure that if CurrencyOf::::free_balance(source_account) < total_amount { - Err(Error::InsufficientBalanceToCoverStake) + Err(Error::::InsufficientBalanceToCoverStake.into()) } else { let new_balance = CurrencyOf::::free_balance(source_account) - total_amount; @@ -1238,7 +1257,6 @@ impl, I: Instance> Module { WithdrawReasons::all(), new_balance, ) - .map_err(|e| Error::Other(e)) } } else { Ok(()) @@ -1247,10 +1265,10 @@ impl, I: Instance> Module { fn ensure_application_exists( application_id: &ApplicationId, - ) -> Result, Error> { + ) -> Result, Error> { ensure!( - ApplicationById::::exists(application_id), - Error::WorkerApplicationDoesNotExist + ApplicationById::::contains_key(application_id), + Error::::WorkerApplicationDoesNotExist ); let application = ApplicationById::::get(application_id); @@ -1264,7 +1282,7 @@ impl, I: Instance> Module { pub fn ensure_worker_signed( origin: T::Origin, worker_id: &WorkerId, - ) -> Result, Error> { + ) -> Result, DispatchError> { // Ensure that it is signed let signer_account = ensure_signed(origin)?; @@ -1274,16 +1292,16 @@ impl, I: Instance> Module { // Ensure that signer is actually role account of worker ensure!( signer_account == worker.role_account_id, - Error::SignerIsNotWorkerRoleAccount + Error::::SignerIsNotWorkerRoleAccount ); Ok(worker) } - fn ensure_worker_exists(worker_id: &WorkerId) -> Result, Error> { + fn ensure_worker_exists(worker_id: &WorkerId) -> Result, Error> { ensure!( - WorkerById::::exists(worker_id), - Error::WorkerDoesNotExist + WorkerById::::contains_key(worker_id), + Error::::WorkerDoesNotExist ); let worker = WorkerById::::get(worker_id); @@ -1293,22 +1311,22 @@ impl, I: Instance> Module { fn ensure_worker_has_recurring_reward( worker: &WorkerOf, - ) -> Result { + ) -> Result> { if let Some(relationship_id) = worker.reward_relationship { Ok(relationship_id) } else { - Err(Error::WorkerHasNoReward) + Err(Error::::WorkerHasNoReward) } } - fn ensure_worker_exit_rationale_text_is_valid(text: &[u8]) -> Result<(), Error> { + fn ensure_worker_exit_rationale_text_is_valid(text: &[u8]) -> DispatchResult { Self::worker_exit_rationale_text() .ensure_valid( text.len(), - Error::WorkerExitRationaleTextTooShort.into(), - Error::WorkerExitRationaleTextTooLong.into(), + Error::::WorkerExitRationaleTextTooShort.into(), + Error::::WorkerExitRationaleTextTooLong.into(), ) - .map_err(|e| e.into()) + .map_err(|e| DispatchError::Other(e)) } } @@ -1323,21 +1341,21 @@ impl, I: Instance> Module { stake_id: StakeId, imbalance: NegativeImbalance, ) -> NegativeImbalance { - if !hiring::ApplicationIdByStakingId::::exists(stake_id) { + if !hiring::ApplicationIdByStakingId::::contains_key(stake_id) { print("Working group broken invariant: no stake id in the hiring module."); return imbalance; } let hiring_application_id = hiring::ApplicationIdByStakingId::::get(stake_id); - if !MemberIdByHiringApplicationId::::exists(hiring_application_id) { + if !MemberIdByHiringApplicationId::::contains_key(hiring_application_id) { // Stake is not related to the working group module. return imbalance; } let member_id = Module::::member_id_by_hiring_application_id(hiring_application_id); - if membership::MembershipById::::exists(member_id) { + if membership::MembershipById::::contains_key(member_id) { let member_profile = membership::MembershipById::::get(member_id); let refunding_result = CurrencyOf::::resolve_into_existing( &member_profile.controller_account, @@ -1361,7 +1379,7 @@ impl, I: Instance> Module { pub fn get_regular_worker_ids() -> Vec> { let lead_worker_id = Self::current_lead(); - >::enumerate() + >::iter() .filter_map(|(worker_id, _)| { // Filter the leader worker id if the leader is set. lead_worker_id @@ -1402,13 +1420,13 @@ impl, I: Instance> Module { worker: &WorkerOf, exit_initiation_origin: &ExitInitiationOrigin, rationale_text: &[u8], - ) -> Result<(), Error> { + ) -> Result<(), Error> { // Stop any possible recurring rewards if let Some(reward_relationship_id) = worker.reward_relationship { // Attempt to deactivate recurringrewards::Module::::try_to_deactivate_relationship(reward_relationship_id) - .map_err(|_| Error::RelationshipMustExist)?; + .map_err(|_| Error::::RelationshipMustExist)?; }; // else: Did not deactivate, there was no reward relationship! // Unstake if stake profile exists @@ -1457,7 +1475,8 @@ impl, I: Instance> Module { Ok(()) } - fn initialize_working_group( + // Initialize working group constraints and mint. + pub(crate) fn initialize_working_group( opening_human_readable_text_constraint: InputValidationLengthConstraint, worker_application_human_readable_text_constraint: InputValidationLengthConstraint, worker_exit_rationale_text_constraint: InputValidationLengthConstraint, diff --git a/runtime-modules/working-group/src/tests/fixtures.rs b/runtime-modules/working-group/src/tests/fixtures.rs index 7187b2efbc..f95f96e3c8 100644 --- a/runtime-modules/working-group/src/tests/fixtures.rs +++ b/runtime-modules/working-group/src/tests/fixtures.rs @@ -1,3 +1,8 @@ +use frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::storage::{StorageMap, StorageValue}; +use std::collections::BTreeSet; +use system::{EventRecord, Phase, RawOrigin}; + use super::mock::{ Balances, Membership, System, Test, TestEvent, TestWorkingGroup, TestWorkingGroupInstance, }; @@ -6,12 +11,8 @@ use crate::types::{ Application, Opening, OpeningPolicyCommitment, OpeningType, RewardPolicy, RoleStakeProfile, Worker, }; -use crate::Error; use crate::RawEvent; use common::constraints::InputValidationLengthConstraint; -use srml_support::{StorageLinkedMap, StorageValue}; -use std::collections::BTreeSet; -use system::{EventRecord, Phase, RawOrigin}; pub struct IncreaseWorkerStakeFixture { origin: RawOrigin, @@ -38,7 +39,7 @@ impl IncreaseWorkerStakeFixture { Self { balance, ..self } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let stake_id = 0; let old_stake = >::stakes(stake_id); let old_balance = Balances::free_balance(&self.account_id); @@ -103,7 +104,7 @@ impl TerminateWorkerRoleFixture { } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { >::put(self.constraint.clone()); let actual_result = TestWorkingGroup::terminate_role( @@ -117,7 +118,9 @@ impl TerminateWorkerRoleFixture { if actual_result.is_ok() { if actual_result.is_ok() { assert!( - !>::exists(self.worker_id) + !>::contains_key( + self.worker_id + ) ); } } @@ -140,7 +143,7 @@ impl LeaveWorkerRoleFixture { Self { origin, ..self } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let rationale_text = b"rationale_text".to_vec(); let actual_result = TestWorkingGroup::leave_role( self.origin.clone().into(), @@ -150,7 +153,9 @@ impl LeaveWorkerRoleFixture { assert_eq!(actual_result, expected_result); if actual_result.is_ok() { - assert!(!>::exists(self.worker_id)); + assert!( + !>::contains_key(self.worker_id) + ); } } } @@ -175,7 +180,7 @@ impl UpdateWorkerRewardAmountFixture { Self { origin, ..self } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let actual_result = TestWorkingGroup::update_reward_amount( self.origin.clone().into(), self.worker_id, @@ -212,7 +217,7 @@ impl UpdateWorkerRewardAccountFixture { Self { origin, ..self } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let actual_result = TestWorkingGroup::update_reward_account( self.origin.clone().into(), self.worker_id, @@ -250,7 +255,7 @@ impl UpdateWorkerRoleAccountFixture { Self { origin, ..self } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let actual_result = TestWorkingGroup::update_role_account( self.origin.clone().into(), self.worker_id, @@ -306,7 +311,7 @@ impl FillWorkerOpeningFixture { } } - pub fn call(&self) -> Result { + pub fn call(&self) -> Result { let saved_worker_next_id = TestWorkingGroup::next_worker_id(); TestWorkingGroup::fill_opening( self.origin.clone().into(), @@ -318,7 +323,7 @@ impl FillWorkerOpeningFixture { Ok(saved_worker_next_id) } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) -> u64 { + pub fn call_and_assert(&self, expected_result: DispatchResult) -> u64 { let saved_worker_next_id = TestWorkingGroup::next_worker_id(); let actual_result = self.call().map(|_| ()); assert_eq!(actual_result.clone(), expected_result); @@ -379,7 +384,7 @@ impl BeginReviewWorkerApplicationsFixture { pub fn with_origin(self, origin: RawOrigin) -> Self { Self { origin, ..self } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let actual_result = TestWorkingGroup::begin_applicant_review(self.origin.clone().into(), self.opening_id); assert_eq!(actual_result, expected_result); @@ -407,7 +412,7 @@ impl TerminateApplicationFixture { worker_application_id: application_id, } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let actual_result = TestWorkingGroup::terminate_application( self.origin.clone().into(), self.worker_application_id, @@ -436,7 +441,7 @@ impl WithdrawApplicationFixture { worker_application_id: application_id, } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let actual_result = TestWorkingGroup::withdraw_application( self.origin.clone().into(), self.worker_application_id, @@ -447,11 +452,11 @@ impl WithdrawApplicationFixture { pub fn increase_total_balance_issuance_using_account_id(account_id: u64, balance: u64) { let _ = - >::deposit_creating(&account_id, balance); + >::deposit_creating(&account_id, balance); } pub fn get_balance(account_id: u64) -> u64 { - >::total_balance(&account_id) + >::total_balance(&account_id) } pub fn setup_members(count: u8) { @@ -524,7 +529,7 @@ impl ApplyOnWorkerOpeningFixture { } } - pub fn call(&self) -> Result { + pub fn call(&self) -> Result { let saved_application_next_id = TestWorkingGroup::next_application_id(); TestWorkingGroup::apply_on_opening( self.origin.clone().into(), @@ -538,7 +543,7 @@ impl ApplyOnWorkerOpeningFixture { Ok(saved_application_next_id) } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) -> u64 { + pub fn call_and_assert(&self, expected_result: DispatchResult) -> u64 { let saved_application_next_id = TestWorkingGroup::next_application_id(); let actual_result = self.call().map(|_| ()); @@ -583,7 +588,7 @@ impl AcceptWorkerApplicationsFixture { } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let actual_result = TestWorkingGroup::accept_applications(self.origin.clone().into(), self.opening_id); assert_eq!(actual_result, expected_result); @@ -698,7 +703,7 @@ impl AddWorkerOpeningFixture { } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) -> u64 { + pub fn call_and_assert(&self, expected_result: DispatchResult) -> u64 { let saved_opening_next_id = TestWorkingGroup::next_opening_id(); let actual_result = self.call().map(|_| ()); @@ -726,7 +731,7 @@ impl AddWorkerOpeningFixture { saved_opening_next_id } - pub fn call(&self) -> Result { + pub fn call(&self) -> Result { let saved_opening_next_id = TestWorkingGroup::next_opening_id(); TestWorkingGroup::add_opening( self.origin.clone().into(), @@ -787,7 +792,7 @@ impl EventFixture { pub fn assert_last_global_event(expected_event: TestEvent) { let expected_event = EventRecord { - phase: Phase::ApplyExtrinsic(0), + phase: Phase::Initialization, event: expected_event, topics: vec![], }; @@ -824,7 +829,7 @@ impl DecreaseWorkerStakeFixture { Self { balance, ..self } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let stake_id = 0; let old_balance = Balances::free_balance(&self.account_id); let old_stake = >::stakes(stake_id); @@ -900,7 +905,7 @@ impl SlashWorkerStakeFixture { Self { balance, ..self } } - pub fn call_and_assert(&self, expected_result: Result<(), Error>) { + pub fn call_and_assert(&self, expected_result: DispatchResult) { let stake_id = 0; let old_balance = Balances::free_balance(&self.account_id); let old_stake = >::stakes(stake_id); diff --git a/runtime-modules/working-group/src/tests/hiring_workflow.rs b/runtime-modules/working-group/src/tests/hiring_workflow.rs index da5c6126b5..f290655922 100644 --- a/runtime-modules/working-group/src/tests/hiring_workflow.rs +++ b/runtime-modules/working-group/src/tests/hiring_workflow.rs @@ -1,12 +1,13 @@ +use frame_support::dispatch::{DispatchError, DispatchResult}; +use system::RawOrigin; + use crate::tests::fixtures::{ create_mint, increase_total_balance_issuance_using_account_id, set_mint_id, setup_members, AddWorkerOpeningFixture, ApplyOnWorkerOpeningFixture, BeginReviewWorkerApplicationsFixture, FillWorkerOpeningFixture, SetLeadFixture, }; use crate::tests::mock::TestWorkingGroup; -use crate::Error; use crate::{OpeningPolicyCommitment, OpeningType, RewardPolicy}; -use system::RawOrigin; #[derive(Clone)] struct HiringWorkflowApplication { @@ -18,7 +19,7 @@ struct HiringWorkflowApplication { pub struct HiringWorkflow { opening_type: OpeningType, - expected_result: Result<(), Error>, + expected_result: DispatchResult, role_stake: Option, applications: Vec, setup_environment: bool, @@ -39,7 +40,7 @@ impl Default for HiringWorkflow { } impl HiringWorkflow { - pub fn expect(self, result: Result<(), Error>) -> Self { + pub fn expect(self, result: DispatchResult) -> Self { Self { expected_result: result, ..self @@ -131,7 +132,7 @@ impl HiringWorkflow { result.ok() } - fn fill_worker_position(&self) -> Result { + fn fill_worker_position(&self) -> Result { let origin = match self.opening_type { OpeningType::Leader => RawOrigin::Root, OpeningType::Worker => { diff --git a/runtime-modules/working-group/src/tests/mock.rs b/runtime-modules/working-group/src/tests/mock.rs index 7a23316da1..7dafeb183e 100644 --- a/runtime-modules/working-group/src/tests/mock.rs +++ b/runtime-modules/working-group/src/tests/mock.rs @@ -1,18 +1,20 @@ -use crate::{BalanceOf, Module, NegativeImbalance, Trait}; -use common::constraints::InputValidationLengthConstraint; -use primitives::H256; -use sr_primitives::{ +use frame_support::storage::StorageMap; +use frame_support::traits::{OnFinalize, OnInitialize}; +use frame_support::{impl_outer_event, impl_outer_origin, parameter_types}; +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{ - impl_outer_event, impl_outer_origin, parameter_types, StorageLinkedMap, StorageMap, -}; use std::marker::PhantomData; +use system; + +use crate::{BalanceOf, Module, NegativeImbalance, Trait}; +use common::constraints::InputValidationLengthConstraint; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test {} } mod working_group { @@ -29,6 +31,7 @@ impl_outer_event! { balances, working_group TestWorkingGroupInstance , membership_mod, + system, } } @@ -40,8 +43,6 @@ parameter_types! { pub const MinimumPeriod: u64 = 5; pub const StakePoolId: [u8; 8] = *b"joystake"; pub const ExistentialDeposit: u32 = 0; - pub const TransferFee: u32 = 0; - pub const CreationFee: u32 = 0; } // Workaround for https://github.com/rust-lang/rust/issues/26925 - remove when sorted. @@ -49,6 +50,7 @@ parameter_types! { pub struct Test; impl system::Trait for Test { + type BaseCallFilter = (); type Origin = Origin; type Call = (); type Index = u64; @@ -61,9 +63,17 @@ impl system::Trait for Test { type Event = TestEvent; type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); + type AccountData = balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } impl hiring::Trait for Test { @@ -98,7 +108,7 @@ impl common::currency::GovernanceCurrency for Test { type Currency = Balances; } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -106,14 +116,10 @@ impl timestamp::Trait for Test { impl balances::Trait for Test { type Balance = u64; - type OnFreeBalanceZero = (); - type OnNewAccount = (); - type TransferPayment = (); type DustRemoval = (); type Event = TestEvent; type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; } impl recurringrewards::Trait for Test { @@ -143,7 +149,7 @@ pub(crate) const WORKING_GROUP_MINT_CAPACITY: u64 = 40000; pub(crate) const WORKING_GROUP_CONSTRAINT_MIN: u16 = 1; pub(crate) const WORKING_GROUP_CONSTRAINT_DIFF: u16 = 40; -pub fn build_test_externalities() -> runtime_io::TestExternalities { +pub fn build_test_externalities() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default() .build_storage::() .unwrap(); @@ -184,13 +190,13 @@ impl> stake::StakingEve remaining_imbalance: NegativeImbalance, ) -> NegativeImbalance { // Stake not related to a staked role managed by the hiring module. - if !hiring::ApplicationIdByStakingId::::exists(*stake_id) { + if !hiring::ApplicationIdByStakingId::::contains_key(*stake_id) { return remaining_imbalance; } let hiring_application_id = hiring::ApplicationIdByStakingId::::get(*stake_id); - if crate::MemberIdByHiringApplicationId::::exists( + if crate::MemberIdByHiringApplicationId::::contains_key( hiring_application_id, ) { return >::refund_working_group_stake( @@ -213,3 +219,15 @@ impl> stake::StakingEve remaining_imbalance } } + +// Recommendation from Parity on testing on_finalize +// https://substrate.dev/docs/en/next/development/module/tests +pub 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()); + } +} diff --git a/runtime-modules/working-group/src/tests/mod.rs b/runtime-modules/working-group/src/tests/mod.rs index fe32fd189b..6589ae04fb 100644 --- a/runtime-modules/working-group/src/tests/mod.rs +++ b/runtime-modules/working-group/src/tests/mod.rs @@ -2,19 +2,20 @@ mod fixtures; mod hiring_workflow; mod mock; +use frame_support::dispatch::DispatchError; +use frame_support::storage::{StorageMap, StorageValue}; +use std::collections::BTreeMap; +use system::RawOrigin; + +use crate::tests::hiring_workflow::HiringWorkflow; use crate::types::{OpeningPolicyCommitment, OpeningType, RewardPolicy}; use crate::{Error, RawEvent, Worker}; use common::constraints::InputValidationLengthConstraint; +use fixtures::*; use mock::{ - build_test_externalities, Test, TestWorkingGroup, TestWorkingGroupInstance, + build_test_externalities, run_to_block, Test, TestWorkingGroup, TestWorkingGroupInstance, WORKING_GROUP_CONSTRAINT_DIFF, WORKING_GROUP_CONSTRAINT_MIN, WORKING_GROUP_MINT_CAPACITY, }; -use srml_support::{StorageLinkedMap, StorageValue}; -use std::collections::BTreeMap; -use system::RawOrigin; - -use crate::tests::hiring_workflow::HiringWorkflow; -use fixtures::*; #[test] fn hire_lead_succeeds() { @@ -37,7 +38,9 @@ fn hire_lead_fails_with_existing_lead() { .disable_setup_environment() .with_opening_type(OpeningType::Leader) .add_application(b"leader_handle".to_vec()) - .expect(Err(Error::CannotHireLeaderWhenLeaderExists)); + .expect(Err( + Error::::CannotHireLeaderWhenLeaderExists.into(), + )); hiring_workflow.execute(); }); @@ -50,7 +53,9 @@ fn hire_lead_fails_multiple_applications() { .with_opening_type(OpeningType::Leader) .add_application_with_origin(b"leader_handle".to_vec(), RawOrigin::Signed(1), 1) .add_application_with_origin(b"leader_handle2".to_vec(), RawOrigin::Signed(2), 2) - .expect(Err(Error::CannotHireMultipleLeaders)); + .expect(Err( + Error::::CannotHireMultipleLeaders.into(), + )); hiring_workflow.execute(); }); @@ -67,7 +72,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture.call_and_assert(Err( - Error::FillOpeningFailedApplicantRoleStakeUnstakingPeriodIsZero, + Error::::FillOpeningFailedApplicantRoleStakeUnstakingPeriodIsZero.into(), )); let add_opening_fixture = @@ -76,7 +81,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture.call_and_assert(Err( - Error::FillOpeningFailedApplicantApplicationStakeUnstakingPeriodIsZero, + Error::::FillOpeningFailedApplicantApplicationStakeUnstakingPeriodIsZero.into(), )); let add_opening_fixture = @@ -85,7 +90,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture.call_and_assert(Err( - Error::FillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriodIsZero, + Error::::FillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriodIsZero.into(), )); let add_opening_fixture = @@ -93,7 +98,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { exit_role_stake_unstaking_period: Some(0), ..OpeningPolicyCommitment::default() }); - add_opening_fixture.call_and_assert(Err(Error::ExitRoleStakeUnstakingPeriodIsZero)); + add_opening_fixture.call_and_assert(Err(Error::::ExitRoleStakeUnstakingPeriodIsZero.into())); let add_opening_fixture = AddWorkerOpeningFixture::default().with_policy_commitment(OpeningPolicyCommitment { @@ -101,14 +106,14 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture - .call_and_assert(Err(Error::ExitRoleApplicationStakeUnstakingPeriodIsZero)); + .call_and_assert(Err(Error::::ExitRoleApplicationStakeUnstakingPeriodIsZero.into())); let add_opening_fixture = AddWorkerOpeningFixture::default().with_policy_commitment(OpeningPolicyCommitment { terminate_role_stake_unstaking_period: Some(0), ..OpeningPolicyCommitment::default() }); - add_opening_fixture.call_and_assert(Err(Error::TerminateRoleStakeUnstakingPeriodIsZero)); + add_opening_fixture.call_and_assert(Err(Error::::TerminateRoleStakeUnstakingPeriodIsZero.into())); let add_opening_fixture = AddWorkerOpeningFixture::default().with_policy_commitment(OpeningPolicyCommitment { @@ -116,7 +121,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture - .call_and_assert(Err(Error::TerminateApplicationStakeUnstakingPeriodIsZero)); + .call_and_assert(Err(Error::::TerminateApplicationStakeUnstakingPeriodIsZero.into())); let add_opening_fixture = AddWorkerOpeningFixture::default().with_policy_commitment(OpeningPolicyCommitment { @@ -127,7 +132,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture - .call_and_assert(Err(Error::RoleStakingPolicyCrowdedOutUnstakingPeriodIsZero)); + .call_and_assert(Err(Error::::RoleStakingPolicyCrowdedOutUnstakingPeriodIsZero.into())); let add_opening_fixture = AddWorkerOpeningFixture::default().with_policy_commitment(OpeningPolicyCommitment { @@ -138,7 +143,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture.call_and_assert(Err( - Error::RoleStakingPolicyReviewPeriodUnstakingPeriodIsZero, + Error::::RoleStakingPolicyReviewPeriodUnstakingPeriodIsZero.into(), )); let add_opening_fixture = @@ -150,7 +155,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture.call_and_assert(Err( - Error::ApplicationStakingPolicyCrowdedOutUnstakingPeriodIsZero, + Error::::ApplicationStakingPolicyCrowdedOutUnstakingPeriodIsZero.into(), )); let add_opening_fixture = @@ -162,7 +167,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture.call_and_assert(Err( - Error::ApplicationStakingPolicyReviewPeriodUnstakingPeriodIsZero, + Error::::ApplicationStakingPolicyReviewPeriodUnstakingPeriodIsZero.into(), )); let add_opening_fixture = @@ -173,7 +178,7 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { ..OpeningPolicyCommitment::default() }); add_opening_fixture.call_and_assert(Err( - Error::ApplicationRationingPolicyMaxActiveApplicantsIsZero, + Error::::ApplicationRationingPolicyMaxActiveApplicantsIsZero.into(), )); }); } @@ -181,6 +186,13 @@ fn add_opening_fails_with_incorrect_unstaking_periods() { #[test] fn add_opening_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + HireLeadFixture::default().hire_lead(); let add_opening_fixture = AddWorkerOpeningFixture::default(); @@ -199,7 +211,7 @@ fn add_leader_opening_succeeds_fails_with_incorrect_origin_for_opening_type() { let add_opening_fixture = AddWorkerOpeningFixture::default().with_opening_type(OpeningType::Leader); - add_opening_fixture.call_and_assert(Err(Error::RequireRootOrigin)); + add_opening_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -221,7 +233,9 @@ fn add_opening_fails_with_lead_is_not_set() { build_test_externalities().execute_with(|| { let add_opening_fixture = AddWorkerOpeningFixture::default(); - add_opening_fixture.call_and_assert(Err(Error::CurrentLeadNotSet)); + add_opening_fixture.call_and_assert(Err( + Error::::CurrentLeadNotSet.into(), + )); }); } @@ -239,12 +253,12 @@ fn add_opening_fails_with_invalid_human_readable_text() { let add_opening_fixture = AddWorkerOpeningFixture::default().with_text(Vec::new()); - add_opening_fixture.call_and_assert(Err(Error::Other("OpeningTextTooShort"))); + add_opening_fixture.call_and_assert(Err(DispatchError::Other("OpeningTextTooShort"))); let add_opening_fixture = AddWorkerOpeningFixture::default().with_text(b"Long text".to_vec()); - add_opening_fixture.call_and_assert(Err(Error::Other("OpeningTextTooLong"))); + add_opening_fixture.call_and_assert(Err(DispatchError::Other("OpeningTextTooLong"))); }); } @@ -256,13 +270,22 @@ fn add_opening_fails_with_hiring_error() { let add_opening_fixture = AddWorkerOpeningFixture::default() .with_activate_at(hiring::ActivateOpeningAt::ExactBlock(0)); - add_opening_fixture.call_and_assert(Err(Error::AddWorkerOpeningActivatesInThePast)); + add_opening_fixture.call_and_assert(Err( + Error::::AddWorkerOpeningActivatesInThePast.into(), + )); }); } #[test] fn accept_applications_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + HireLeadFixture::default().hire_lead(); let add_opening_fixture = AddWorkerOpeningFixture::default() @@ -290,7 +313,7 @@ fn accept_applications_fails_for_invalid_opening_type() { let accept_applications_fixture = AcceptWorkerApplicationsFixture::default_for_opening_id(opening_id); - accept_applications_fixture.call_and_assert(Err(Error::RequireRootOrigin)); + accept_applications_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -305,7 +328,7 @@ fn accept_applications_fails_with_hiring_error() { let accept_applications_fixture = AcceptWorkerApplicationsFixture::default_for_opening_id(opening_id); accept_applications_fixture.call_and_assert(Err( - Error::AcceptWorkerApplicationsOpeningIsNotWaitingToBegin, + Error::::AcceptWorkerApplicationsOpeningIsNotWaitingToBegin.into(), )); }); } @@ -322,7 +345,9 @@ fn accept_applications_fails_with_not_lead() { let accept_applications_fixture = AcceptWorkerApplicationsFixture::default_for_opening_id(opening_id); - accept_applications_fixture.call_and_assert(Err(Error::IsNotLeadAccount)); + accept_applications_fixture.call_and_assert(Err( + Error::::IsNotLeadAccount.into(), + )); }); } @@ -335,13 +360,22 @@ fn accept_applications_fails_with_no_opening() { let accept_applications_fixture = AcceptWorkerApplicationsFixture::default_for_opening_id(opening_id); - accept_applications_fixture.call_and_assert(Err(Error::OpeningDoesNotExist)); + accept_applications_fixture.call_and_assert(Err( + Error::::OpeningDoesNotExist.into(), + )); }); } #[test] fn apply_on_opening_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + HireLeadFixture::default().hire_lead(); let add_opening_fixture = AddWorkerOpeningFixture::default(); @@ -367,7 +401,9 @@ fn apply_on_opening_fails_with_no_opening() { let apply_on_opening_fixture = ApplyOnWorkerOpeningFixture::default_for_opening_id(opening_id); - apply_on_opening_fixture.call_and_assert(Err(Error::OpeningDoesNotExist)); + apply_on_opening_fixture.call_and_assert(Err( + Error::::OpeningDoesNotExist.into(), + )); }); } @@ -382,7 +418,9 @@ fn apply_on_opening_fails_with_not_set_members() { let apply_on_opening_fixture = ApplyOnWorkerOpeningFixture::default_for_opening_id(opening_id) .with_origin(RawOrigin::Signed(55), 55); - apply_on_opening_fixture.call_and_assert(Err(Error::OriginIsNeitherMemberControllerOrRoot)); + apply_on_opening_fixture.call_and_assert(Err( + Error::::OriginIsNeitherMemberControllerOrRoot.into(), + )); }); } @@ -398,8 +436,10 @@ fn apply_on_opening_fails_with_hiring_error() { let apply_on_opening_fixture = ApplyOnWorkerOpeningFixture::default_for_opening_id(opening_id) .with_application_stake(100); - apply_on_opening_fixture - .call_and_assert(Err(Error::AddWorkerOpeningStakeProvidedWhenRedundant)); + apply_on_opening_fixture.call_and_assert(Err( + Error::::AddWorkerOpeningStakeProvidedWhenRedundant + .into(), + )); }); } @@ -424,7 +464,9 @@ fn apply_on_opening_fails_with_invalid_application_stake() { ApplyOnWorkerOpeningFixture::default_for_opening_id(opening_id) .with_origin(RawOrigin::Signed(2), 2) .with_application_stake(stake); - apply_on_opening_fixture.call_and_assert(Err(Error::InsufficientBalanceToApply)); + apply_on_opening_fixture.call_and_assert(Err( + Error::::InsufficientBalanceToApply.into(), + )); }); } @@ -444,8 +486,10 @@ fn add_opening_fails_with_invalid_zero_application_stake() { }), ..OpeningPolicyCommitment::default() }); - add_opening_fixture - .call_and_assert(Err(Error::AddWorkerOpeningApplicationStakeCannotBeZero)); + add_opening_fixture.call_and_assert(Err( + Error::::AddWorkerOpeningApplicationStakeCannotBeZero + .into(), + )); }); } @@ -470,7 +514,9 @@ fn apply_on_opening_fails_with_invalid_role_stake() { ApplyOnWorkerOpeningFixture::default_for_opening_id(opening_id) .with_role_stake(Some(stake)) .with_origin(RawOrigin::Signed(2), 2); - apply_on_opening_fixture.call_and_assert(Err(Error::InsufficientBalanceToApply)); + apply_on_opening_fixture.call_and_assert(Err( + Error::::InsufficientBalanceToApply.into(), + )); }); } @@ -492,12 +538,13 @@ fn apply_on_opening_fails_with_invalid_text() { let apply_on_opening_fixture = ApplyOnWorkerOpeningFixture::default_for_opening_id(opening_id).with_text(Vec::new()); apply_on_opening_fixture - .call_and_assert(Err(Error::Other("WorkerApplicationTextTooShort"))); + .call_and_assert(Err(DispatchError::Other("WorkerApplicationTextTooShort"))); let apply_on_opening_fixture = ApplyOnWorkerOpeningFixture::default_for_opening_id(opening_id) .with_text(b"Long text".to_vec()); - apply_on_opening_fixture.call_and_assert(Err(Error::Other("WorkerApplicationTextTooLong"))); + apply_on_opening_fixture + .call_and_assert(Err(DispatchError::Other("WorkerApplicationTextTooLong"))); }); } @@ -513,13 +560,22 @@ fn apply_on_opening_fails_with_already_active_application() { ApplyOnWorkerOpeningFixture::default_for_opening_id(opening_id); apply_on_opening_fixture.call_and_assert(Ok(())); - apply_on_opening_fixture.call_and_assert(Err(Error::MemberHasActiveApplicationOnOpening)); + apply_on_opening_fixture.call_and_assert(Err( + Error::::MemberHasActiveApplicationOnOpening.into(), + )); }); } #[test] fn withdraw_worker_application_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + HireLeadFixture::default().hire_lead(); let add_opening_fixture = AddWorkerOpeningFixture::default(); @@ -544,7 +600,9 @@ fn withdraw_worker_application_fails_invalid_application_id() { let withdraw_application_fixture = WithdrawApplicationFixture::default_for_application_id(invalid_application_id); - withdraw_application_fixture.call_and_assert(Err(Error::WorkerApplicationDoesNotExist)); + withdraw_application_fixture.call_and_assert(Err( + Error::::WorkerApplicationDoesNotExist.into(), + )); }); } @@ -563,7 +621,7 @@ fn withdraw_worker_application_fails_invalid_origin() { let withdraw_application_fixture = WithdrawApplicationFixture::default_for_application_id(application_id) .with_origin(RawOrigin::None); - withdraw_application_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + withdraw_application_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -583,7 +641,9 @@ fn withdraw_worker_application_fails_with_invalid_application_author() { let withdraw_application_fixture = WithdrawApplicationFixture::default_for_application_id(application_id) .with_signer(invalid_author_account_id); - withdraw_application_fixture.call_and_assert(Err(Error::OriginIsNotApplicant)); + withdraw_application_fixture.call_and_assert(Err( + Error::::OriginIsNotApplicant.into(), + )); }); } @@ -602,14 +662,23 @@ fn withdraw_worker_application_fails_with_hiring_error() { let withdraw_application_fixture = WithdrawApplicationFixture::default_for_application_id(application_id); withdraw_application_fixture.call_and_assert(Ok(())); - withdraw_application_fixture - .call_and_assert(Err(Error::WithdrawWorkerApplicationApplicationNotActive)); + withdraw_application_fixture.call_and_assert(Err( + Error::::WithdrawWorkerApplicationApplicationNotActive + .into(), + )); }); } #[test] fn terminate_worker_application_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + HireLeadFixture::default().hire_lead(); let add_opening_fixture = AddWorkerOpeningFixture::default(); @@ -643,7 +712,9 @@ fn terminate_worker_application_fails_with_invalid_application_author() { let terminate_application_fixture = TerminateApplicationFixture::default_for_application_id(application_id) .with_signer(invalid_author_account_id); - terminate_application_fixture.call_and_assert(Err(Error::IsNotLeadAccount)); + terminate_application_fixture.call_and_assert(Err( + Error::::IsNotLeadAccount.into(), + )); }); } @@ -662,7 +733,7 @@ fn terminate_worker_application_fails_invalid_origin() { let terminate_application_fixture = TerminateApplicationFixture::default_for_application_id(application_id) .with_origin(RawOrigin::None); - terminate_application_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + terminate_application_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -675,7 +746,9 @@ fn terminate_worker_application_fails_invalid_application_id() { let terminate_application_fixture = TerminateApplicationFixture::default_for_application_id(invalid_application_id); - terminate_application_fixture.call_and_assert(Err(Error::WorkerApplicationDoesNotExist)); + terminate_application_fixture.call_and_assert(Err( + Error::::WorkerApplicationDoesNotExist.into(), + )); }); } @@ -694,14 +767,23 @@ fn terminate_worker_application_fails_with_hiring_error() { let terminate_application_fixture = TerminateApplicationFixture::default_for_application_id(application_id); terminate_application_fixture.call_and_assert(Ok(())); - terminate_application_fixture - .call_and_assert(Err(Error::WithdrawWorkerApplicationApplicationNotActive)); + terminate_application_fixture.call_and_assert(Err( + Error::::WithdrawWorkerApplicationApplicationNotActive + .into(), + )); }); } #[test] fn begin_review_worker_applications_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + HireLeadFixture::default().hire_lead(); let add_opening_fixture = AddWorkerOpeningFixture::default(); @@ -727,7 +809,7 @@ fn begin_review_worker_applications_fails_with_invalid_origin_for_opening_type() let begin_review_worker_applications_fixture = BeginReviewWorkerApplicationsFixture::default_for_opening_id(opening_id); - begin_review_worker_applications_fixture.call_and_assert(Err(Error::RequireRootOrigin)); + begin_review_worker_applications_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -743,7 +825,11 @@ fn begin_review_worker_applications_fails_with_not_a_lead() { let begin_review_worker_applications_fixture = BeginReviewWorkerApplicationsFixture::default_for_opening_id(opening_id); - begin_review_worker_applications_fixture.call_and_assert(Err(Error::IsNotLeadAccount)); + begin_review_worker_applications_fixture.call_and_assert(Err(Error::< + Test, + TestWorkingGroupInstance, + >::IsNotLeadAccount + .into())); }); } @@ -756,7 +842,11 @@ fn begin_review_worker_applications_fails_with_invalid_opening() { let begin_review_worker_applications_fixture = BeginReviewWorkerApplicationsFixture::default_for_opening_id(invalid_opening_id); - begin_review_worker_applications_fixture.call_and_assert(Err(Error::OpeningDoesNotExist)); + begin_review_worker_applications_fixture.call_and_assert(Err(Error::< + Test, + TestWorkingGroupInstance, + >::OpeningDoesNotExist + .into())); }); } @@ -772,7 +862,7 @@ fn begin_review_worker_applications_with_hiring_error() { BeginReviewWorkerApplicationsFixture::default_for_opening_id(opening_id); begin_review_worker_applications_fixture.call_and_assert(Ok(())); begin_review_worker_applications_fixture.call_and_assert(Err( - Error::BeginWorkerApplicantReviewOpeningOpeningIsNotWaitingToBegin, + Error::::BeginWorkerApplicantReviewOpeningOpeningIsNotWaitingToBegin.into(), )); }); } @@ -788,13 +878,20 @@ fn begin_review_worker_applications_fails_with_invalid_origin() { let begin_review_worker_applications_fixture = BeginReviewWorkerApplicationsFixture::default_for_opening_id(opening_id) .with_origin(RawOrigin::None); - begin_review_worker_applications_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + begin_review_worker_applications_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } #[test] fn fill_opening_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + HireLeadFixture::default().hire_lead(); increase_total_balance_issuance_using_account_id(1, 10000); @@ -880,7 +977,7 @@ fn fill_opening_fails_with_invalid_origin_for_opening_type() { next_payment_at_block: 20, payout_interval: None, }); - fill_opening_fixture.call_and_assert(Err(Error::RequireRootOrigin)); + fill_opening_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -895,7 +992,7 @@ fn fill_opening_fails_with_invalid_origin() { let fill_opening_fixture = FillWorkerOpeningFixture::default_for_ids(opening_id, Vec::new()) .with_origin(RawOrigin::None); - fill_opening_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + fill_opening_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -911,7 +1008,9 @@ fn fill_opening_fails_with_not_a_lead() { let fill_opening_fixture = FillWorkerOpeningFixture::default_for_ids(opening_id, Vec::new()); - fill_opening_fixture.call_and_assert(Err(Error::IsNotLeadAccount)); + fill_opening_fixture.call_and_assert(Err( + Error::::IsNotLeadAccount.into(), + )); }); } @@ -924,7 +1023,9 @@ fn fill_opening_fails_with_invalid_opening() { let fill_opening_fixture = FillWorkerOpeningFixture::default_for_ids(invalid_opening_id, Vec::new()); - fill_opening_fixture.call_and_assert(Err(Error::OpeningDoesNotExist)); + fill_opening_fixture.call_and_assert(Err( + Error::::OpeningDoesNotExist.into(), + )); }); } @@ -949,7 +1050,9 @@ fn fill_opening_fails_with_invalid_application_list() { opening_id, vec![application_id, invalid_application_id], ); - fill_opening_fixture.call_and_assert(Err(Error::SuccessfulWorkerApplicationDoesNotExist)); + fill_opening_fixture.call_and_assert(Err( + Error::::SuccessfulWorkerApplicationDoesNotExist.into(), + )); }); } @@ -963,8 +1066,10 @@ fn fill_opening_fails_with_invalid_application_with_hiring_error() { let fill_opening_fixture = FillWorkerOpeningFixture::default_for_ids(opening_id, Vec::new()); - fill_opening_fixture - .call_and_assert(Err(Error::FullWorkerOpeningOpeningNotInReviewPeriodStage)); + fill_opening_fixture.call_and_assert(Err( + Error::::FullWorkerOpeningOpeningNotInReviewPeriodStage + .into(), + )); }); } @@ -999,6 +1104,13 @@ fn fill_opening_fails_with_invalid_reward_policy() { #[test] fn update_worker_role_account_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let new_account_id = 10; let worker_id = fill_default_worker_position(); @@ -1047,13 +1159,22 @@ fn update_worker_role_account_fails_with_invalid_origin() { UpdateWorkerRoleAccountFixture::default_with_ids(worker_id, 1) .with_origin(RawOrigin::None); - update_worker_account_fixture.call_and_assert(Err(Error::MembershipUnsignedOrigin)); + update_worker_account_fixture.call_and_assert(Err( + Error::::MembershipUnsignedOrigin.into(), + )); }); } #[test] fn update_worker_reward_account_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let worker_id = fill_default_worker_position(); let new_role_account = 22; @@ -1094,7 +1215,7 @@ fn update_worker_reward_account_fails_with_invalid_origin() { let update_worker_account_fixture = UpdateWorkerRewardAccountFixture::default_with_ids(1, 1).with_origin(RawOrigin::None); - update_worker_account_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + update_worker_account_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1109,7 +1230,9 @@ fn update_worker_reward_account_fails_with_invalid_origin_signed_account() { UpdateWorkerRewardAccountFixture::default_with_ids(worker_id, worker.role_account_id) .with_origin(RawOrigin::Signed(invalid_role_account)); - update_worker_account_fixture.call_and_assert(Err(Error::SignerIsNotWorkerRoleAccount)); + update_worker_account_fixture.call_and_assert(Err( + Error::::SignerIsNotWorkerRoleAccount.into(), + )); }); } @@ -1125,7 +1248,9 @@ fn update_worker_reward_account_fails_with_invalid_worker_id() { new_reward_account, ); - update_worker_account_fixture.call_and_assert(Err(Error::WorkerDoesNotExist)); + update_worker_account_fixture.call_and_assert(Err( + Error::::WorkerDoesNotExist.into(), + )); }); } @@ -1139,13 +1264,22 @@ fn update_worker_reward_account_fails_with_no_recurring_reward() { let update_worker_account_fixture = UpdateWorkerRewardAccountFixture::default_with_ids(worker_id, new_reward_account); - update_worker_account_fixture.call_and_assert(Err(Error::WorkerHasNoReward)); + update_worker_account_fixture.call_and_assert(Err( + Error::::WorkerHasNoReward.into(), + )); }); } #[test] fn update_worker_reward_amount_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let worker_id = fill_default_worker_position(); let update_worker_amount_fixture = @@ -1187,7 +1321,7 @@ fn update_worker_reward_amount_fails_with_invalid_origin() { UpdateWorkerRewardAmountFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::None); - update_worker_amount_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + update_worker_amount_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1200,7 +1334,7 @@ fn update_worker_reward_amount_fails_with_invalid_origin_for_leader() { UpdateWorkerRewardAmountFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::None); - update_worker_amount_fixture.call_and_assert(Err(Error::RequireRootOrigin)); + update_worker_amount_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1213,7 +1347,9 @@ fn update_worker_reward_amount_fails_with_invalid_origin_signed_account() { UpdateWorkerRewardAmountFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::Signed(2)); - update_worker_amount_fixture.call_and_assert(Err(Error::IsNotLeadAccount)); + update_worker_amount_fixture.call_and_assert(Err( + Error::::IsNotLeadAccount.into(), + )); }); } @@ -1226,7 +1362,9 @@ fn update_worker_reward_amount_fails_with_invalid_worker_id() { let update_worker_amount_fixture = UpdateWorkerRewardAmountFixture::default_for_worker_id(invalid_worker_id); - update_worker_amount_fixture.call_and_assert(Err(Error::WorkerDoesNotExist)); + update_worker_amount_fixture.call_and_assert(Err( + Error::::WorkerDoesNotExist.into(), + )); }); } @@ -1238,7 +1376,9 @@ fn update_worker_reward_amount_fails_with_no_recurring_reward() { let update_worker_amount_fixture = UpdateWorkerRewardAmountFixture::default_for_worker_id(worker_id); - update_worker_amount_fixture.call_and_assert(Err(Error::WorkerHasNoReward)); + update_worker_amount_fixture.call_and_assert(Err( + Error::::WorkerHasNoReward.into(), + )); }); } @@ -1299,6 +1439,13 @@ fn fill_worker_position( #[test] fn leave_worker_role_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let worker_id = fill_default_worker_position(); let leave_worker_role_fixture = LeaveWorkerRoleFixture::default_for_worker_id(worker_id); @@ -1335,7 +1482,7 @@ fn leave_worker_role_fails_with_invalid_origin() { let leave_worker_role_fixture = LeaveWorkerRoleFixture::default_for_worker_id(1).with_origin(RawOrigin::None); - leave_worker_role_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + leave_worker_role_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1347,7 +1494,9 @@ fn leave_worker_role_fails_with_invalid_origin_signed_account() { let leave_worker_role_fixture = LeaveWorkerRoleFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::Signed(2)); - leave_worker_role_fixture.call_and_assert(Err(Error::SignerIsNotWorkerRoleAccount)); + leave_worker_role_fixture.call_and_assert(Err( + Error::::SignerIsNotWorkerRoleAccount.into(), + )); }); } @@ -1360,7 +1509,9 @@ fn leave_worker_role_fails_with_invalid_worker_id() { let leave_worker_role_fixture = LeaveWorkerRoleFixture::default_for_worker_id(invalid_worker_id); - leave_worker_role_fixture.call_and_assert(Err(Error::WorkerDoesNotExist)); + leave_worker_role_fixture.call_and_assert(Err( + Error::::WorkerDoesNotExist.into(), + )); }); } @@ -1376,13 +1527,22 @@ fn leave_worker_role_fails_with_invalid_recurring_reward_relationships() { let leave_worker_role_fixture = LeaveWorkerRoleFixture::default_for_worker_id(worker_id); - leave_worker_role_fixture.call_and_assert(Err(Error::RelationshipMustExist)); + leave_worker_role_fixture.call_and_assert(Err( + Error::::RelationshipMustExist.into(), + )); }); } #[test] fn leave_worker_role_succeeds_with_stakes() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let worker_id = fill_worker_position_with_stake(100); let leave_worker_role_fixture = LeaveWorkerRoleFixture::default_for_worker_id(worker_id); @@ -1399,6 +1559,13 @@ fn leave_worker_role_succeeds_with_stakes() { #[test] fn terminate_worker_role_succeeds_with_stakes() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let total_balance = 10000; let stake_balance = 100; @@ -1514,6 +1681,13 @@ fn terminate_worker_role_succeeds_with_slashing() { #[test] fn terminate_worker_role_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + HireLeadFixture::default().hire_lead(); let worker_id = HiringWorkflow::default() @@ -1537,6 +1711,13 @@ fn terminate_worker_role_succeeds() { #[test] fn fire_leader_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let worker_id = HireLeadFixture::default().hire_lead(); let terminate_worker_role_fixture = @@ -1568,13 +1749,13 @@ fn terminate_worker_role_fails_with_invalid_text() { let terminate_worker_role_fixture = TerminateWorkerRoleFixture::default_for_worker_id(worker_id).with_text(Vec::new()); terminate_worker_role_fixture - .call_and_assert(Err(Error::Other("WorkerExitRationaleTextTooShort"))); + .call_and_assert(Err(DispatchError::Other("WorkerExitRationaleTextTooShort"))); let terminate_worker_role_fixture = TerminateWorkerRoleFixture::default_for_worker_id(worker_id) .with_text(b"MSG_WORKER_EXIT_RATIONALE_TEXT_TOO_LONG".to_vec()); terminate_worker_role_fixture - .call_and_assert(Err(Error::Other("WorkerExitRationaleTextTooLong"))); + .call_and_assert(Err(DispatchError::Other("WorkerExitRationaleTextTooLong"))); }); } @@ -1588,7 +1769,9 @@ fn terminate_worker_role_fails_with_unset_lead() { let terminate_worker_role_fixture = TerminateWorkerRoleFixture::default_for_worker_id(worker_id); - terminate_worker_role_fixture.call_and_assert(Err(Error::CurrentLeadNotSet)); + terminate_worker_role_fixture.call_and_assert(Err( + Error::::CurrentLeadNotSet.into(), + )); }); } @@ -1607,7 +1790,7 @@ fn terminate_worker_role_fails_with_invalid_origin() { TerminateWorkerRoleFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::None); - terminate_worker_role_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + terminate_worker_role_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1620,13 +1803,20 @@ fn fire_leader_fails_with_invalid_origin() { TerminateWorkerRoleFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::None); - terminate_worker_role_fixture.call_and_assert(Err(Error::RequireRootOrigin)); + terminate_worker_role_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } #[test] fn increase_worker_stake_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let worker_id = fill_worker_position_with_stake(100); let increase_stake_fixture = IncreaseWorkerStakeFixture::default_for_worker_id(worker_id); @@ -1655,7 +1845,7 @@ fn increase_worker_stake_fails_with_invalid_origin() { let increase_stake_fixture = IncreaseWorkerStakeFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::None); - increase_stake_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + increase_stake_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1667,7 +1857,9 @@ fn increase_worker_stake_fails_with_zero_balance() { let increase_stake_fixture = IncreaseWorkerStakeFixture::default_for_worker_id(worker_id).with_balance(0); - increase_stake_fixture.call_and_assert(Err(Error::StakeBalanceCannotBeZero)); + increase_stake_fixture.call_and_assert(Err( + Error::::StakeBalanceCannotBeZero.into(), + )); }); } @@ -1679,7 +1871,9 @@ fn increase_worker_stake_fails_with_invalid_worker_id() { let increase_stake_fixture = IncreaseWorkerStakeFixture::default_for_worker_id(invalid_worker_id); - increase_stake_fixture.call_and_assert(Err(Error::WorkerDoesNotExist)); + increase_stake_fixture.call_and_assert(Err( + Error::::WorkerDoesNotExist.into(), + )); }); } @@ -1691,8 +1885,10 @@ fn increase_worker_stake_fails_with_invalid_balance() { let increase_stake_fixture = IncreaseWorkerStakeFixture::default_for_worker_id(worker_id) .with_balance(invalid_balance); - increase_stake_fixture - .call_and_assert(Err(Error::StakingErrorInsufficientBalanceInSourceAccount)); + increase_stake_fixture.call_and_assert(Err( + Error::::StakingErrorInsufficientBalanceInSourceAccount + .into(), + )); }); } @@ -1703,13 +1899,22 @@ fn increase_worker_stake_fails_with_no_stake_profile() { let increase_stake_fixture = IncreaseWorkerStakeFixture::default_for_worker_id(worker_id); - increase_stake_fixture.call_and_assert(Err(Error::NoWorkerStakeProfile)); + increase_stake_fixture.call_and_assert(Err( + Error::::NoWorkerStakeProfile.into(), + )); }); } #[test] fn decrease_worker_stake_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let worker_id = fill_worker_position_with_stake(100); let decrease_stake_fixture = DecreaseWorkerStakeFixture::default_for_worker_id(worker_id); @@ -1741,7 +1946,7 @@ fn decrease_worker_stake_fails_with_invalid_origin() { let decrease_stake_fixture = DecreaseWorkerStakeFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::None); - decrease_stake_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + decrease_stake_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1752,7 +1957,7 @@ fn decrease_worker_stake_fails_with_invalid_origin_for_leader() { let decrease_stake_fixture = DecreaseWorkerStakeFixture::default_for_worker_id(worker_id) .with_origin(RawOrigin::None); - decrease_stake_fixture.call_and_assert(Err(Error::RequireRootOrigin)); + decrease_stake_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1764,7 +1969,9 @@ fn decrease_worker_stake_fails_with_zero_balance() { let decrease_stake_fixture = DecreaseWorkerStakeFixture::default_for_worker_id(worker_id).with_balance(0); - decrease_stake_fixture.call_and_assert(Err(Error::StakeBalanceCannotBeZero)); + decrease_stake_fixture.call_and_assert(Err( + Error::::StakeBalanceCannotBeZero.into(), + )); }); } @@ -1777,7 +1984,9 @@ fn decrease_worker_stake_fails_with_invalid_worker_id() { let decrease_stake_fixture = DecreaseWorkerStakeFixture::default_for_worker_id(invalid_worker_id); - decrease_stake_fixture.call_and_assert(Err(Error::WorkerDoesNotExist)); + decrease_stake_fixture.call_and_assert(Err( + Error::::WorkerDoesNotExist.into(), + )); }); } @@ -1789,7 +1998,9 @@ fn decrease_worker_stake_fails_with_invalid_balance() { let decrease_stake_fixture = DecreaseWorkerStakeFixture::default_for_worker_id(worker_id) .with_balance(invalid_balance); - decrease_stake_fixture.call_and_assert(Err(Error::StakingErrorInsufficientStake)); + decrease_stake_fixture.call_and_assert(Err( + Error::::StakingErrorInsufficientStake.into(), + )); }); } @@ -1800,7 +2011,9 @@ fn decrease_worker_stake_fails_with_no_stake_profile() { let decrease_stake_fixture = DecreaseWorkerStakeFixture::default_for_worker_id(worker_id); - decrease_stake_fixture.call_and_assert(Err(Error::NoWorkerStakeProfile)); + decrease_stake_fixture.call_and_assert(Err( + Error::::NoWorkerStakeProfile.into(), + )); }); } @@ -1812,13 +2025,22 @@ fn decrease_worker_stake_fails_with_not_set_lead() { let decrease_stake_fixture = DecreaseWorkerStakeFixture::default_for_worker_id(invalid_worker_id); - decrease_stake_fixture.call_and_assert(Err(Error::CurrentLeadNotSet)); + decrease_stake_fixture.call_and_assert(Err( + Error::::CurrentLeadNotSet.into(), + )); }); } #[test] fn slash_worker_stake_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let worker_id = fill_worker_position_with_stake(100); let slash_stake_fixture = SlashWorkerStakeFixture::default_for_worker_id(worker_id); @@ -1832,6 +2054,13 @@ fn slash_worker_stake_succeeds() { #[test] fn slash_leader_stake_succeeds() { build_test_externalities().execute_with(|| { + /* + Events are not emitted on block 0. + So any dispatchable calls made during genesis block formation will have no events emitted. + https://substrate.dev/recipes/2-appetizers/4-events.html + */ + run_to_block(1); + let leader_worker_id = HiringWorkflow::default() .with_role_stake(Some(100)) .with_opening_type(OpeningType::Leader) @@ -1857,7 +2086,7 @@ fn slash_worker_stake_fails_with_invalid_origin() { let slash_stake_fixture = SlashWorkerStakeFixture::default_for_worker_id(invalid_worker_id) .with_origin(RawOrigin::None); - slash_stake_fixture.call_and_assert(Err(Error::RequireSignedOrigin)); + slash_stake_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1869,7 +2098,7 @@ fn slash_leader_stake_fails_with_invalid_origin() { let slash_stake_fixture = SlashWorkerStakeFixture::default_for_worker_id(worker_id).with_origin(RawOrigin::None); - slash_stake_fixture.call_and_assert(Err(Error::RequireRootOrigin)); + slash_stake_fixture.call_and_assert(Err(DispatchError::BadOrigin)); }); } @@ -1881,7 +2110,9 @@ fn slash_worker_stake_fails_with_zero_balance() { let slash_stake_fixture = SlashWorkerStakeFixture::default_for_worker_id(worker_id).with_balance(0); - slash_stake_fixture.call_and_assert(Err(Error::StakeBalanceCannotBeZero)); + slash_stake_fixture.call_and_assert(Err( + Error::::StakeBalanceCannotBeZero.into(), + )); }); } @@ -1893,7 +2124,9 @@ fn slash_worker_stake_fails_with_invalid_worker_id() { let slash_stake_fixture = SlashWorkerStakeFixture::default_for_worker_id(invalid_worker_id); - slash_stake_fixture.call_and_assert(Err(Error::WorkerDoesNotExist)); + slash_stake_fixture.call_and_assert(Err( + Error::::WorkerDoesNotExist.into(), + )); }); } @@ -1904,7 +2137,9 @@ fn slash_worker_stake_fails_with_no_stake_profile() { let slash_stake_fixture = SlashWorkerStakeFixture::default_for_worker_id(worker_id); - slash_stake_fixture.call_and_assert(Err(Error::NoWorkerStakeProfile)); + slash_stake_fixture.call_and_assert(Err( + Error::::NoWorkerStakeProfile.into(), + )); }); } @@ -1915,7 +2150,9 @@ fn slash_worker_stake_fails_with_not_set_lead() { let slash_stake_fixture = SlashWorkerStakeFixture::default_for_worker_id(invalid_worker_id); - slash_stake_fixture.call_and_assert(Err(Error::CurrentLeadNotSet)); + slash_stake_fixture.call_and_assert(Err( + Error::::CurrentLeadNotSet.into(), + )); }); } @@ -1969,7 +2206,10 @@ fn set_working_group_mint_capacity_fails_with_mint_not_found() { >::put(5); // random mint id let result = TestWorkingGroup::set_mint_capacity(RawOrigin::Root.into(), capacity); - assert_eq!(result, Err(Error::CannotFindMint)); + assert_eq!( + result, + Err(Error::::CannotFindMint.into()) + ); }); } @@ -1979,7 +2219,7 @@ fn set_working_group_mint_capacity_fails_with_invalid_origin() { let capacity = 15000; let result = TestWorkingGroup::set_mint_capacity(RawOrigin::None.into(), capacity); - assert_eq!(result, Err(Error::RequireRootOrigin)); + assert_eq!(result, Err(DispatchError::BadOrigin)); }); } @@ -1988,7 +2228,7 @@ fn ensure_setting_genesis_working_group_mint_succeeds() { build_test_externalities().execute_with(|| { let mint_id = TestWorkingGroup::mint(); - assert!(minting::Mints::::exists(mint_id)); + assert!(minting::Mints::::contains_key(mint_id)); let mint = >::mints(mint_id); assert_eq!(mint.capacity(), WORKING_GROUP_MINT_CAPACITY); @@ -2062,7 +2302,9 @@ fn adding_too_much_workers_fails_with_single_application_out_of_limit() { let hiring_workflow = HiringWorkflow::default() .disable_setup_environment() .add_default_application() - .expect(Err(Error::MaxActiveWorkerNumberExceeded)); + .expect(Err( + Error::::MaxActiveWorkerNumberExceeded.into(), + )); hiring_workflow.execute() }); @@ -2079,7 +2321,9 @@ fn fill_opening_cannot_hire_more_workers_using_several_applicationst_han_allows_ .disable_setup_environment() .add_application_with_origin(b"Some1".to_vec(), RawOrigin::Signed(2), 2) .add_application_with_origin(b"Some2".to_vec(), RawOrigin::Signed(3), 3) - .expect(Err(Error::MaxActiveWorkerNumberExceeded)); + .expect(Err( + Error::::MaxActiveWorkerNumberExceeded.into(), + )); hiring_workflow.execute() }); diff --git a/runtime-modules/working-group/src/types.rs b/runtime-modules/working-group/src/types.rs index e1052c1f07..ca342651f0 100644 --- a/runtime-modules/working-group/src/types.rs +++ b/runtime-modules/working-group/src/types.rs @@ -1,7 +1,7 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 2c4864d731..4c68a0f426 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -4,372 +4,168 @@ edition = '2018' name = 'joystream-node-runtime' # Follow convention: https://github.com/Joystream/substrate-runtime-joystream/issues/1 # {Authoring}.{Spec}.{Impl} of the RuntimeVersion -version = '6.21.0' +version = '7.0.0' + +[dependencies] +# Third-party dependencies +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } + +# Substrate primitives +sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-offchain = { package = 'sp-offchain', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-authority-discovery = { package = 'sp-authority-discovery', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-consensus-babe = { package = 'sp-consensus-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-transaction-pool = { package = 'sp-transaction-pool', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-session = { package = 'sp-session', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-block-builder = { package = 'sp-block-builder', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-api = { package = 'sp-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-version = { package = 'sp-version', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-staking = { package = 'sp-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +sp-application-crypto = { package = 'sp-application-crypto', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + +# Frame +frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-executive = { package = 'frame-executive', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +frame-system-rpc-runtime-api = { package = 'frame-system-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + +# Pallets +pallet-grandpa = { package = 'pallet-grandpa', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-babe = { package = 'pallet-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-transaction-payment = { package = 'pallet-transaction-payment', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-transaction-payment-rpc-runtime-api = { package = 'pallet-transaction-payment-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-authorship = { package = 'pallet-authorship', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-session = { package = 'pallet-session', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-offences = { package = 'pallet-offences', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-finality-tracker = { package = 'pallet-finality-tracker', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-randomness-collective-flip = { package = 'pallet-randomness-collective-flip', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-authority-discovery = { package = 'pallet-authority-discovery', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-sudo = { package = 'pallet-sudo', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-staking = { package = 'pallet-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-im-online = { package = 'pallet-im-online', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-collective = { package = 'pallet-collective', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + +# Benchmarking +frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', default-features = false, optional = true } +frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', default-features = false, optional = true } +pallet-offences-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', default-features = false, optional = true } +pallet-session-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', default-features = false, optional = true } + +# Joystream +common = { package = 'pallet-common', default-features = false, path = '../runtime-modules/common'} +memo = { package = 'pallet-memo', default-features = false, path = '../runtime-modules/memo'} +forum = { package = 'pallet-forum', default-features = false, path = '../runtime-modules/forum'} +membership = { package = 'pallet-membership', default-features = false, path = '../runtime-modules/membership'} +stake = { package = 'pallet-stake', default-features = false, path = '../runtime-modules/stake'} +governance = { package = 'pallet-governance', default-features = false, path = '../runtime-modules/governance'} +hiring = { package = 'pallet-hiring', default-features = false, path = '../runtime-modules/hiring'} +minting = { package = 'pallet-token-mint', default-features = false, path = '../runtime-modules/token-minting'} +recurring-rewards = { package = 'pallet-recurring-reward', default-features = false, path = '../runtime-modules/recurring-reward'} +working-group = { package = 'pallet-working-group', default-features = false, path = '../runtime-modules/working-group'} +content-working-group = { package = 'pallet-content-working-group', default-features = false, path = '../runtime-modules/content-working-group'} +versioned-store = { package = 'pallet-versioned-store', default-features = false, path = '../runtime-modules/versioned-store'} +versioned-store-permissions = { package = 'pallet-versioned-store-permissions', default-features = false, path = '../runtime-modules/versioned-store-permissions'} +storage = { package = 'pallet-storage', default-features = false, path = '../runtime-modules/storage'} +service-discovery = { package = 'pallet-service-discovery', default-features = false, path = '../runtime-modules/service-discovery'} +proposals-engine = { package = 'pallet-proposals-engine', default-features = false, path = '../runtime-modules/proposals/engine'} +proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../runtime-modules/proposals/discussion'} +proposals-codex = { package = 'pallet-proposals-codex', default-features = false, path = '../runtime-modules/proposals/codex'} + +[dev-dependencies] +sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} + +[build-dependencies] +wasm-builder-runner = { package = "substrate-wasm-builder-runner", git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } [features] default = ['std'] no_std = [] std = [ - 'authority-discovery-primitives/std', - 'authority-discovery/std', - 'authorship/std', - 'finality-tracker/std', - 'im-online/std', - 'session/std', - 'offences/std', - 'sr-staking-primitives/std', - 'staking/std', + # Third-party dependencies + 'serde', 'codec/std', - 'substrate-client/std', - 'rstd/std', - 'runtime-io/std', - 'srml-support/std', - 'balances/std', - 'babe/std', - 'babe-primitives/std', - 'executive/std', - 'indices/std', - 'grandpa/std', - 'primitives/std', - 'sr-primitives/std', + + # Substrate primitives + 'sp-std/std', + 'sp-core/std', + 'sp-api/std', + 'sp-version/std', + 'sp-runtime/std', + 'sp-arithmetic/std', + 'sp-offchain/std', + 'sp-authority-discovery/std', + 'sp-consensus-babe/std', + 'sp-transaction-pool/std', + 'sp-block-builder/std', + 'sp-session/std', + 'sp-staking/std', + 'sp-application-crypto/std', + + # Frame + 'frame-support/std', + 'frame-executive/std', + 'frame-system-rpc-runtime-api/std', 'system/std', - 'timestamp/std', - 'sudo/std', - 'version/std', - 'serde', - 'safe-mix/std', - 'offchain-primitives/std', - 'substrate-session/std', - 'transaction-payment/std', - 'randomness-collective-flip/std', - 'system-rpc-runtime-api/std', + + # Pallets + 'pallet-timestamp/std', + 'pallet-balances/std', + 'pallet-transaction-payment/std', + 'pallet-transaction-payment-rpc-runtime-api/std', + 'pallet-grandpa/std', + 'pallet-babe/std', + 'pallet-session/std', + 'pallet-finality-tracker/std', + 'pallet-authority-discovery/std', + 'pallet-authorship/std', + 'pallet-randomness-collective-flip/std', + 'pallet-staking/std', +# 'pallet-staking-reward-curve/std', // don't have 'std' features + 'pallet-sudo/std', + 'pallet-im-online/std', + 'pallet-collective/std', + 'pallet-offences/std', + + # Joystream + 'common/std', + 'memo/std', 'forum/std', - 'minting/std', - 'recurringrewards/std', + 'membership/std', 'stake/std', - 'hiring/std', - 'versioned_store/std', - 'versioned_store_permissions/std', - 'common/std', - 'content_working_group/std', 'governance/std', - 'membership/std', - 'memo/std', - 'service_discovery/std', - 'storage/std', - 'proposals_engine/std', - 'proposals_discussion/std', - 'proposals_codex/std', + 'hiring/std', + 'minting/std', + 'recurring-rewards/std', 'working-group/std', + 'content-working-group/std', + 'versioned-store/std', + 'versioned-store-permissions/std', + 'storage/std', + 'service-discovery/std', + 'proposals-engine/std', + 'proposals-discussion/std', + 'proposals-codex/std', +] +runtime-benchmarks = [ + "system/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", + "pallet-im-online/runtime-benchmarks", + "pallet-staking/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "frame-benchmarking", + "frame-system-benchmarking", + "pallet-offences-benchmarking", + "pallet-session-benchmarking", ] -# [dependencies] -# # https://users.rust-lang.org/t/failure-derive-compilation-error/39062 -# quote = '<=1.0.2' - -[dependencies.babe] -default-features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-babe' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.babe-primitives] -default-features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-consensus-babe-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.balances] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-balances' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-client] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-client' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '1.0.0' - -[dependencies.executive] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-executive' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.grandpa] -default-features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-grandpa' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.indices] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-indices' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.offchain-primitives] -default-features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-offchain-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.rstd] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-std' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.runtime-io] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-io' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.safe-mix] -default-features = false -version = '1.0' - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.sr-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-session] -default-features = false -git = 'https://github.com/paritytech/substrate.git' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.sudo] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-sudo' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.srml-support] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-support' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-system' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.timestamp] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-timestamp' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.version] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-version' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.authority-discovery-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-authority-discovery-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.authority-discovery] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-authority-discovery' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.authorship] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-authorship' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.finality-tracker] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-finality-tracker' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.im-online] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-im-online' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.session] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-session' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.offences] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-offences' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.sr-staking-primitives] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'sr-staking-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.staking] -default_features = false -git = 'https://github.com/paritytech/substrate.git' -package = 'srml-staking' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.transaction-payment] -package = "srml-transaction-payment" -git = 'https://github.com/paritytech/substrate.git' -default_features = false -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.randomness-collective-flip] -package = "srml-randomness-collective-flip" -git = 'https://github.com/paritytech/substrate.git' -default_features = false -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.system-rpc-runtime-api] -package = "srml-system-rpc-runtime-api" -git = 'https://github.com/paritytech/substrate.git' -default_features = false -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -# don't rename the dependency it is causing some strange compiler error: -# https://github.com/rust-lang/rust/issues/64450 -[dependencies.srml-staking-reward-curve] -package = 'srml-staking-reward-curve' -git = 'https://github.com/paritytech/substrate.git' -default_features = false -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[build-dependencies.wasm-builder-runner] -package = 'substrate-wasm-builder-runner' -version = '1.0.5' - -[dependencies.forum] -default_features = false -package = 'substrate-forum-module' -path = '../runtime-modules/forum' - -[dependencies.minting] -default_features = false -package = 'substrate-token-mint-module' -path = '../runtime-modules/token-minting' - -[dependencies.stake] -default_features = false -package = 'substrate-stake-module' -path = '../runtime-modules/stake' - -[dependencies.recurringrewards] -default_features = false -package = 'substrate-recurring-reward-module' -path = '../runtime-modules/recurring-reward' - -[dependencies.hiring] -default_features = false -package = 'substrate-hiring-module' -path = '../runtime-modules/hiring' - -[dependencies.versioned_store] -default_features = false -package ='substrate-versioned-store' -path = '../runtime-modules/versioned-store' - -[dependencies.versioned_store_permissions] -default_features = false -package = 'substrate-versioned-store-permissions-module' -path = '../runtime-modules/versioned-store-permissions' - -[dependencies.common] -default_features = false -package = 'substrate-common-module' -path = '../runtime-modules/common' -version = '1.0.0' - -[dependencies.content_working_group] -default_features = false -package = 'substrate-content-working-group-module' -path = '../runtime-modules/content-working-group' -version = '1.0.0' - -[dependencies.governance] -default_features = false -package = 'substrate-governance-module' -path = '../runtime-modules/governance' -version = '1.0.0' - -[dependencies.membership] -default_features = false -package = 'substrate-membership-module' -path = '../runtime-modules/membership' -version = '1.0.0' - -[dependencies.memo] -default_features = false -package = 'substrate-memo-module' -path = '../runtime-modules/memo' -version = '1.0.0' - -[dependencies.service_discovery] -default_features = false -package = 'substrate-service-discovery-module' -path = '../runtime-modules/service-discovery' -version = '2.0.0' - -[dependencies.storage] -default_features = false -package = 'substrate-storage-module' -path = '../runtime-modules/storage' -version = '2.0.0' - -[dependencies.proposals_engine] -default_features = false -package = 'substrate-proposals-engine-module' -path = '../runtime-modules/proposals/engine' -version = '2.0.0' - -[dependencies.proposals_discussion] -default_features = false -package = 'substrate-proposals-discussion-module' -path = '../runtime-modules/proposals/discussion' -version = '2.0.0' - -[dependencies.proposals_codex] -default_features = false -package = 'substrate-proposals-codex-module' -path = '../runtime-modules/proposals/codex' -version = '2.0.0' -[dependencies.working-group] -default_features = false -package = 'substrate-working-group-module' -path = '../runtime-modules/working-group' -version = '1.0.0' \ No newline at end of file diff --git a/runtime/build.rs b/runtime/build.rs index 828f0ef5c2..269bd9dd1b 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use std::{env, process::Command, string::String}; -use wasm_builder_runner::{WasmBuilder, WasmBuilderSource}; +use wasm_builder_runner::WasmBuilder; fn main() { if !in_real_cargo_environment() { @@ -23,17 +23,11 @@ fn main() { println!("Building DUMMY Wasm binary"); } - let file_name = "wasm_binary.rs"; - let wasm_builder_source = WasmBuilderSource::Crates("1.0.9"); - // This instructs LLD to export __heap_base as a global variable, which is used by the - // external memory allocator. - let default_rust_flags = "-Clink-arg=--export=__heap_base"; - WasmBuilder::new() .with_current_project() - .with_wasm_builder_source(wasm_builder_source) - .append_to_rust_flags(default_rust_flags) - .set_file_name(file_name) + .with_wasm_builder_from_crates("1.0.11") + .export_heap_base() + .import_memory() .build() } diff --git a/runtime/src/constants.rs b/runtime/src/constants.rs new file mode 100644 index 0000000000..b6c32ae829 --- /dev/null +++ b/runtime/src/constants.rs @@ -0,0 +1,49 @@ +use crate::{BlockNumber, Moment}; + +/// Constants for Babe. + +/// Since BABE is probabilistic this is the average expected block time that +/// we are targetting. Blocks will be produced at a minimum duration defined +/// by `SLOT_DURATION`, but some slots will not be allocated to any +/// authority and hence no block will be produced. We expect to have this +/// block time on average following the defined slot duration and the value +/// of `c` configured for BABE (where `1 - c` represents the probability of +/// a slot being empty). +/// This value is only used indirectly to define the unit constants below +/// that are expressed in blocks. The rest of the code should use +/// `SLOT_DURATION` instead (like the timestamp module for calculating the +/// minimum period). +/// +pub const MILLISECS_PER_BLOCK: Moment = 6000; +pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000; + +pub const SLOT_DURATION: Moment = 6000; + +pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES; +pub const EPOCH_DURATION_IN_SLOTS: u64 = { + const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64; + + (EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64 +}; + +// These time units are defined in number of blocks. +pub const MINUTES: BlockNumber = 60 / (SECS_PER_BLOCK as BlockNumber); +pub const HOURS: BlockNumber = MINUTES * 60; +pub const DAYS: BlockNumber = HOURS * 24; + +// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. +pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); + +/// Tests only +#[cfg(any(feature = "std", test))] +pub mod currency { + use crate::primitives::Balance; + + pub const MILLICENTS: Balance = 1_000_000_000; + pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. + pub const DOLLARS: Balance = 100 * CENTS; + + pub const fn deposit(items: u32, bytes: u32) -> Balance { + items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS + } +} diff --git a/runtime/src/integration/content_working_group.rs b/runtime/src/integration/content_working_group.rs index a7b5747cea..653db28ca6 100644 --- a/runtime/src/integration/content_working_group.rs +++ b/runtime/src/integration/content_working_group.rs @@ -1,7 +1,7 @@ use crate::{AccountId, Credential, Runtime}; -use srml_support::traits::{Currency, Imbalance}; -use srml_support::{parameter_types, StorageLinkedMap, StorageMap}; +use frame_support::traits::{Currency, Imbalance}; +use frame_support::{parameter_types, IterableStorageMap, StorageMap}; parameter_types! { pub const CurrentLeadCredential: Credential = 0; @@ -29,7 +29,7 @@ impl versioned_store_permissions::CredentialChecker for ContentWorkingG credential if credential == AnyActiveCuratorCredential::get() => { // Look for a Curator with a matching role account for (_principal_id, principal) in - >::enumerate() + >::iter() { if let content_working_group::Principal::Curator(curator_id) = principal { let curator = @@ -48,7 +48,7 @@ impl versioned_store_permissions::CredentialChecker for ContentWorkingG credential if credential == AnyActiveChannelOwnerCredential::get() => { // Look for a ChannelOwner with a matching role account for (_principal_id, principal) in - >::enumerate() + >::iter() { if let content_working_group::Principal::ChannelOwner(channel_id) = principal { let channel = @@ -80,14 +80,14 @@ impl stake::StakingEventsHandler for ContentWorkingGroupStakingEventHan _unstaked_amount: stake::BalanceOf, remaining_imbalance: stake::NegativeImbalance, ) -> stake::NegativeImbalance { - if !hiring::ApplicationIdByStakingId::::exists(stake_id) { + if !hiring::ApplicationIdByStakingId::::contains_key(stake_id) { // Stake not related to a staked role managed by the hiring module return remaining_imbalance; } let application_id = hiring::ApplicationIdByStakingId::::get(stake_id); - if !content_working_group::CuratorApplicationById::::exists(application_id) { + if !content_working_group::CuratorApplicationById::::contains_key(application_id) { // Stake not for a Curator return remaining_imbalance; } @@ -97,7 +97,7 @@ impl stake::StakingEventsHandler for ContentWorkingGroupStakingEventHan hiring::Module::::unstaked(*stake_id); // Only notify working group module if non instantaneous unstaking occured - if content_working_group::UnstakerByStakeId::::exists(stake_id) { + if content_working_group::UnstakerByStakeId::::contains_key(stake_id) { content_working_group::Module::::unstaked(*stake_id); } diff --git a/runtime/src/integration/forum.rs b/runtime/src/integration/forum.rs new file mode 100644 index 0000000000..87814b251f --- /dev/null +++ b/runtime/src/integration/forum.rs @@ -0,0 +1,31 @@ +/* + * Forum module integration + * + * ForumUserRegistry could have been implemented directly on + * the membership module, and likewise ForumUser on Profile, + * however this approach is more loosely coupled. + * + * Further exploration required to decide what the long + * run convention should be. + */ + +use crate::{AccountId, Runtime}; + +/// Shim registry which will proxy ForumUserRegistry behaviour to the members module +pub struct ShimMembershipRegistry {} + +impl forum::ForumUserRegistry for ShimMembershipRegistry { + fn get_forum_user(id: &AccountId) -> Option> { + if membership::Module::::is_member_account(id) { + // For now we don't retrieve the members profile since it is not used for anything, + // but in the future we may need it to read out more + // information possibly required to construct a + // ForumUser. + + // Now convert member profile to a forum user + Some(forum::ForumUser { id: id.clone() }) + } else { + None + } + } +} diff --git a/runtime/src/integration/mod.rs b/runtime/src/integration/mod.rs index 5da2dec9a7..35774a7c6c 100644 --- a/runtime/src/integration/mod.rs +++ b/runtime/src/integration/mod.rs @@ -1,4 +1,7 @@ pub mod content_working_group; +pub mod forum; pub mod proposals; pub mod storage; +pub mod transactions; +pub mod versioned_store_permissions; pub mod working_group; diff --git a/runtime/src/integration/proposals/council_origin_validator.rs b/runtime/src/integration/proposals/council_origin_validator.rs index 5231d62f99..9b5a79cb14 100644 --- a/runtime/src/integration/proposals/council_origin_validator.rs +++ b/runtime/src/integration/proposals/council_origin_validator.rs @@ -1,6 +1,6 @@ #![warn(missing_docs)] -use rstd::marker::PhantomData; +use sp_std::marker::PhantomData; use common::origin::ActorOriginValidator; use proposals_engine::VotersParameters; @@ -46,12 +46,12 @@ mod tests { use crate::Runtime; use common::origin::ActorOriginValidator; use proposals_engine::VotersParameters; - use sr_primitives::AccountId32; + use sp_runtime::AccountId32; use system::RawOrigin; type Council = governance::council::Module; - fn initial_test_ext() -> runtime_io::TestExternalities { + fn initial_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime/src/integration/proposals/membership_origin_validator.rs b/runtime/src/integration/proposals/membership_origin_validator.rs index dd21b6141e..1d8205f3bc 100644 --- a/runtime/src/integration/proposals/membership_origin_validator.rs +++ b/runtime/src/integration/proposals/membership_origin_validator.rs @@ -1,6 +1,6 @@ #![warn(missing_docs)] -use rstd::marker::PhantomData; +use sp_std::marker::PhantomData; use common::origin::ActorOriginValidator; use system::ensure_signed; @@ -47,12 +47,12 @@ mod tests { use super::MembershipOriginValidator; use crate::Runtime; use common::origin::ActorOriginValidator; - use sr_primitives::AccountId32; + use sp_runtime::AccountId32; use system::RawOrigin; type Membership = membership::Module; - fn initial_test_ext() -> runtime_io::TestExternalities { + fn initial_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime/src/integration/proposals/proposal_encoder.rs b/runtime/src/integration/proposals/proposal_encoder.rs index f54ab2908b..d924d95aa4 100644 --- a/runtime/src/integration/proposals/proposal_encoder.rs +++ b/runtime/src/integration/proposals/proposal_encoder.rs @@ -4,10 +4,10 @@ use proposals_codex::{ProposalDetails, ProposalDetailsOf, ProposalEncoder}; use working_group::OpeningType; use codec::Encode; -use rstd::collections::btree_set::BTreeSet; -use rstd::marker::PhantomData; -use rstd::vec::Vec; -use srml_support::print; +use frame_support::print; +use sp_std::collections::btree_set::BTreeSet; +use sp_std::marker::PhantomData; +use sp_std::vec::Vec; // The macro binds working group outer-level Call with the provided inner-level working group // extrinsic call. Outer-call is defined by the provided WorkingGroup param expression. @@ -46,9 +46,9 @@ impl ProposalEncoder for ExtrinsicProposalEncoder { ProposalDetails::SetLead(new_lead) => { Call::ContentWorkingGroup(content_working_group::Call::replace_lead(new_lead)) } - ProposalDetails::SetValidatorCount(new_validator_count) => { - Call::Staking(staking::Call::set_validator_count(new_validator_count)) - } + ProposalDetails::SetValidatorCount(new_validator_count) => Call::Staking( + pallet_staking::Call::set_validator_count(new_validator_count), + ), ProposalDetails::RuntimeUpgrade(wasm_code) => Call::ProposalsCodex( proposals_codex::Call::execute_runtime_upgrade_proposal(wasm_code), ), diff --git a/runtime/src/integration/proposals/staking_events_handler.rs b/runtime/src/integration/proposals/staking_events_handler.rs index 8adbbb0843..202181e0d7 100644 --- a/runtime/src/integration/proposals/staking_events_handler.rs +++ b/runtime/src/integration/proposals/staking_events_handler.rs @@ -1,8 +1,8 @@ #![warn(missing_docs)] -use rstd::marker::PhantomData; -use srml_support::traits::{Currency, Imbalance}; -use srml_support::StorageMap; +use frame_support::traits::{Currency, Imbalance}; +use frame_support::StorageMap; +use sp_std::marker::PhantomData; // Balance alias type BalanceOf = @@ -27,7 +27,7 @@ impl stake::StakingEventsHandler _unstaked_amount: BalanceOf, remaining_imbalance: NegativeImbalance, ) -> NegativeImbalance { - if >::exists(id) { + if >::contains_key(id) { >::refund_proposal_stake(*id, remaining_imbalance); return >::zero(); // imbalance was consumed diff --git a/runtime/src/integration/storage.rs b/runtime/src/integration/storage.rs index 794543e987..5ca1aff99c 100644 --- a/runtime/src/integration/storage.rs +++ b/runtime/src/integration/storage.rs @@ -1,5 +1,5 @@ -use rstd::vec::Vec; -use srml_support::traits::Randomness; +use frame_support::traits::Randomness; +use sp_std::vec::Vec; use crate::{ActorId, Runtime}; diff --git a/runtime/src/integration/transactions.rs b/runtime/src/integration/transactions.rs new file mode 100644 index 0000000000..865e09bd2f --- /dev/null +++ b/runtime/src/integration/transactions.rs @@ -0,0 +1,69 @@ +use codec::Encode; +use frame_support::debug; +use frame_support::weights::{WeightToFeeCoefficients, WeightToFeePolynomial}; +use sp_runtime::generic; +use sp_runtime::generic::SignedPayload; +use sp_runtime::SaturatedConversion; + +use crate::{AccountId, Balance, BlockHashCount, Index, SignedExtra, UncheckedExtrinsic}; +use crate::{Call, Runtime, System}; + +/// Stub for zero transaction weights. +pub struct NoWeights; +impl WeightToFeePolynomial for NoWeights { + type Balance = Balance; + + fn polynomial() -> WeightToFeeCoefficients { + Default::default() + } + + fn calc(_weight: &u64) -> Self::Balance { + Default::default() + } +} + +/// 'Create transaction' default implementation. +pub(crate) fn create_transaction< + C: system::offchain::AppCrypto< + ::Public, + ::Signature, + >, +>( + call: Call, + public: <::Signature as sp_runtime::traits::Verify>::Signer, + account: AccountId, + nonce: Index, +) -> Option<( + Call, + ::SignaturePayload, +)> { + // take the biggest period possible. + let period = BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let current_block = System::block_number() + .saturated_into::() + // The `System::block_number` is initialized with `n+1`, + // so the actual block number is `n`. + .saturating_sub(1); + let tip = 0; + let extra: SignedExtra = ( + system::CheckSpecVersion::::new(), + system::CheckTxVersion::::new(), + system::CheckGenesis::::new(), + system::CheckEra::::from(generic::Era::mortal(period, current_block)), + system::CheckNonce::::from(nonce), + system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(tip), + pallet_grandpa::ValidateEquivocationReport::::new(), + ); + let raw_payload = SignedPayload::new(call, extra) + .map_err(|e| { + debug::warn!("Unable to create signed payload: {:?}", e); + }) + .ok()?; + let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?; + let (call, extra, _) = raw_payload.deconstruct(); + Some((call, (account, signature, extra))) +} diff --git a/runtime/src/integration/versioned_store_permissions.rs b/runtime/src/integration/versioned_store_permissions.rs new file mode 100644 index 0000000000..38408306fb --- /dev/null +++ b/runtime/src/integration/versioned_store_permissions.rs @@ -0,0 +1,50 @@ +use crate::{AccountId, Runtime}; +use frame_support::{StorageMap, StorageValue}; + +// Credential Checker that gives the sudo key holder all credentials +pub struct SudoKeyHasAllCredentials {} +impl versioned_store_permissions::CredentialChecker for SudoKeyHasAllCredentials { + fn account_has_credential( + account: &AccountId, + _credential: ::Credential, + ) -> bool { + >::key() == *account + } +} + +// Allow sudo key holder permission to create classes +pub struct SudoKeyCanCreateClasses {} +impl versioned_store_permissions::CreateClassPermissionsChecker + for SudoKeyCanCreateClasses +{ + fn account_can_create_class_permissions(account: &AccountId) -> bool { + >::key() == *account + } +} + +pub struct ContentLeadOrSudoKeyCanCreateClasses {} +impl versioned_store_permissions::CreateClassPermissionsChecker + for ContentLeadOrSudoKeyCanCreateClasses +{ + fn account_can_create_class_permissions(account: &AccountId) -> bool { + ContentLeadCanCreateClasses::account_can_create_class_permissions(account) + || SudoKeyCanCreateClasses::account_can_create_class_permissions(account) + } +} + +// Allow content working group lead to create classes in content directory +pub struct ContentLeadCanCreateClasses {} +impl versioned_store_permissions::CreateClassPermissionsChecker + for ContentLeadCanCreateClasses +{ + fn account_can_create_class_permissions(account: &AccountId) -> bool { + // get current lead id + let maybe_current_lead_id = content_working_group::CurrentLeadId::::get(); + if let Some(lead_id) = maybe_current_lead_id { + let lead = content_working_group::LeadById::::get(lead_id); + lead.role_account == *account + } else { + false + } + } +} diff --git a/runtime/src/integration/working_group.rs b/runtime/src/integration/working_group.rs index 84d97e80f4..8c11350845 100644 --- a/runtime/src/integration/working_group.rs +++ b/runtime/src/integration/working_group.rs @@ -1,5 +1,5 @@ -use rstd::marker::PhantomData; -use srml_support::{StorageLinkedMap, StorageMap}; +use frame_support::StorageMap; +use sp_std::marker::PhantomData; use crate::StorageWorkingGroupInstance; use stake::{BalanceOf, NegativeImbalance}; @@ -18,13 +18,13 @@ impl> remaining_imbalance: NegativeImbalance, ) -> NegativeImbalance { // Stake not related to a staked role managed by the hiring module. - if !hiring::ApplicationIdByStakingId::::exists(*stake_id) { + if !hiring::ApplicationIdByStakingId::::contains_key(*stake_id) { return remaining_imbalance; } let hiring_application_id = hiring::ApplicationIdByStakingId::::get(*stake_id); - if working_group::MemberIdByHiringApplicationId::::exists( + if working_group::MemberIdByHiringApplicationId::::contains_key( hiring_application_id, ) { return >::refund_working_group_stake( diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 1bb6d3fda1..b8fc167ab5 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -3,12 +3,9 @@ #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] -// srml_staking_reward_curve::build! - substrate macro produces a warning. -// TODO: remove after post-Rome substrate upgrade -#![allow(array_into_iter)] - -// Runtime integration tests -mod tests; +//Substrate internal issues. +#![allow(clippy::large_enum_variant)] +#![allow(clippy::unnecessary_mut_passed)] // Make the WASM binary available. // This is required only by the node build. @@ -16,190 +13,67 @@ mod tests; #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +mod constants; mod integration; - -use authority_discovery_primitives::{ - AuthorityId as EncodedAuthorityId, Signature as EncodedSignature, -}; -use babe_primitives::{AuthorityId as BabeId, AuthoritySignature as BabeSignature}; -use codec::{Decode, Encode}; -use grandpa::fg_primitives; -use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; -use im_online::sr25519::AuthorityId as ImOnlineId; -use primitives::OpaqueMetadata; -use rstd::prelude::*; -use sr_primitives::curve::PiecewiseLinear; -use sr_primitives::traits::{ - BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, StaticLookup, Verify, +mod primitives; +mod runtime_api; +#[cfg(test)] +mod tests; // Runtime integration tests + +use frame_support::traits::KeyOwnerProofSystem; +use frame_support::weights::{ + constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, + Weight, }; -use sr_primitives::weights::Weight; -use sr_primitives::{ - create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity, - ApplyResult, MultiSignature, -}; -use substrate_client::{ - block_builder::api::{self as block_builder_api, CheckInherentsResult, InherentData}, - impl_runtime_apis, runtime_api as client_api, -}; -use system::offchain::TransactionSubmitter; +use frame_support::{construct_runtime, parameter_types}; +use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use pallet_session::historical as pallet_session_historical; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_core::crypto::KeyTypeId; +use sp_runtime::curve::PiecewiseLinear; +use sp_runtime::traits::{BlakeTwo256, Block as BlockT, IdentityLookup, OpaqueKeys, Saturating}; +use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, Perbill}; +use sp_std::boxed::Box; +use sp_std::vec::Vec; #[cfg(feature = "std")] -use version::NativeVersion; -use version::RuntimeVersion; +use sp_version::NativeVersion; +use sp_version::RuntimeVersion; +use system::EnsureRoot; -// A few exports that help ease life for downstream crates. -pub use balances::Call as BalancesCall; -#[cfg(any(feature = "std", test))] -pub use sr_primitives::BuildStorage; -pub use sr_primitives::{Perbill, Permill}; - -pub use srml_support::{ - construct_runtime, parameter_types, traits::Currency, traits::Imbalance, traits::Randomness, - StorageLinkedMap, StorageMap, StorageValue, -}; -pub use staking::StakerStatus; -pub use timestamp::Call as TimestampCall; +pub use constants::*; +pub use primitives::*; +pub use runtime_api::*; use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator}; -pub use proposals_codex::ProposalsConfigParameters; +use content_working_group as content_wg; +use governance::{council, election}; +use storage::{data_directory, data_object_storage_registry, data_object_type_registry}; + +// Node dependencies pub use common; pub use forum; -pub use working_group; - pub use governance::election_params::ElectionParameters; -use governance::{council, election}; -use storage::{data_directory, data_object_storage_registry, data_object_type_registry}; +#[cfg(any(feature = "std", test))] +pub use pallet_balances::Call as BalancesCall; +pub use pallet_staking::StakerStatus; +pub use proposals_codex::ProposalsConfigParameters; pub use versioned_store; - -pub use content_working_group as content_wg; -mod migration; - -/// Alias for ContentId, used in various places. -pub type ContentId = primitives::H256; - -/// An index to a block. -pub type BlockNumber = u32; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - -/// The type for looking up accounts. We don't expect more than 4 billion of them, but you -/// never know... -pub type AccountIndex = u32; - -/// Balance of an account. -pub type Balance = u128; - -/// Index of a transaction in the chain. -pub type Index = u32; - -/// A hash of some data used by the chain. -pub type Hash = primitives::H256; - -/// Digest item type. -pub type DigestItem = generic::DigestItem; - -/// Moment type -pub type Moment = u64; - -/// Credential type -pub type Credential = u64; - -/// Represents a thread identifier for both Forum and Proposals Discussion -/// -/// Note: Both modules expose type names ThreadId and PostId (which are defined on their Trait) and -/// used in state storage and dispatchable method's argument types, -/// and are therefore part of the public API/metadata of the runtime. -/// In the currenlty version the polkadot-js/api that is used and is compatible with the runtime, -/// the type registry has flat namespace and its not possible -/// to register identically named types from different modules, separately. And so we MUST configure -/// the underlying types to be identicaly to avoid issues with encoding/decoding these types on the client side. -pub type ThreadId = u64; - -/// Represents a post identifier for both Forum and Proposals Discussion -/// -/// See the Note about ThreadId -pub type PostId = u64; - -/// Represent an actor in membership group, which is the same in the working groups. -pub type ActorId = u64; - -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core datastructures. -pub mod opaque { - use super::*; - - pub use sr_primitives::OpaqueExtrinsic as UncheckedExtrinsic; - - /// Opaque block header type. - pub type Header = generic::Header; - /// Opaque block type. - pub type Block = generic::Block; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId; - - pub type SessionHandlers = (Grandpa, Babe, ImOnline); - - impl_opaque_keys! { - pub struct SessionKeys { - pub grandpa: Grandpa, - pub babe: Babe, - pub im_online: ImOnline, - } - } -} +pub use working_group; /// This runtime version. pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("joystream-node"), impl_name: create_runtime_str!("joystream-node"), - authoring_version: 6, - spec_version: 21, + authoring_version: 7, + spec_version: 0, impl_version: 0, - apis: RUNTIME_API_VERSIONS, + apis: crate::runtime_api::EXPORTED_RUNTIME_API_VERSIONS, + transaction_version: 1, }; -/// Constants for Babe. - -/// Since BABE is probabilistic this is the average expected block time that -/// we are targetting. Blocks will be produced at a minimum duration defined -/// by `SLOT_DURATION`, but some slots will not be allocated to any -/// authority and hence no block will be produced. We expect to have this -/// block time on average following the defined slot duration and the value -/// of `c` configured for BABE (where `1 - c` represents the probability of -/// a slot being empty). -/// This value is only used indirectly to define the unit constants below -/// that are expressed in blocks. The rest of the code should use -/// `SLOT_DURATION` instead (like the timestamp module for calculating the -/// minimum period). -/// -pub const MILLISECS_PER_BLOCK: Moment = 6000; -pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000; - -pub const SLOT_DURATION: Moment = 6000; - -pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES; -pub const EPOCH_DURATION_IN_SLOTS: u64 = { - const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64; - - (EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64 -}; - -// These time units are defined in number of blocks. -pub const MINUTES: BlockNumber = 60 / (SECS_PER_BLOCK as BlockNumber); -pub const HOURS: BlockNumber = MINUTES * 60; -pub const DAYS: BlockNumber = HOURS * 24; - -// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. -pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); - -/// The version infromation used to identify this runtime when compiled natively. +/// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { NativeVersion { @@ -210,42 +84,44 @@ pub fn native_version() -> NativeVersion { parameter_types! { pub const BlockHashCount: BlockNumber = 250; - pub const MaximumBlockWeight: Weight = 1_000_000_000; + /// We allow for 2 seconds of compute with a 6 second average block time. + pub const MaximumBlockWeight: Weight = 2 * frame_support::weights::constants::WEIGHT_PER_SECOND; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; pub const Version: RuntimeVersion = VERSION; + /// Assume 10% of weight for average on_initialize calls. + pub MaximumExtrinsicWeight: Weight = + AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT) + * MaximumBlockWeight::get(); } +const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10); +// TODO: adjust weight impl system::Trait for Runtime { - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; - /// The aggregated dispatch type that is available for extrinsics. + type BaseCallFilter = (); + type Origin = Origin; type Call = Call; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = Indices; - /// The index type for storing how many extrinsics an account has signed. type Index = Index; - /// The index type for blocks. type BlockNumber = BlockNumber; - /// The type for hashing blocks and tries. type Hash = Hash; - /// The hashing algorithm used. type Hashing = BlakeTwo256; - /// The header type. + type AccountId = AccountId; + type Lookup = IdentityLookup; type Header = generic::Header; - /// The ubiquitous event type. type Event = Event; - /// The ubiquitous origin type. - type Origin = Origin; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). type BlockHashCount = BlockHashCount; - /// Maximum weight of each block. With a default weight system of 1byte == 1weight, 4mb is ok. type MaximumBlockWeight = MaximumBlockWeight; - /// Maximum size of all encoded transactions (in bytes) that are allowed in one block. + type DbWeight = RocksDbWeight; + type BlockExecutionWeight = BlockExecutionWeight; + type ExtrinsicBaseWeight = ExtrinsicBaseWeight; + type MaximumExtrinsicWeight = MaximumExtrinsicWeight; type MaximumBlockLength = MaximumBlockLength; - /// Portion of the block weight that is available to all normal transactions. type AvailableBlockRatio = AvailableBlockRatio; type Version = Version; + type ModuleToIndex = ModuleToIndex; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } parameter_types! { @@ -253,34 +129,68 @@ parameter_types! { pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; } -impl babe::Trait for Runtime { +impl pallet_babe::Trait for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; - type EpochChangeTrigger = babe::ExternalTrigger; + type EpochChangeTrigger = pallet_babe::ExternalTrigger; } -impl grandpa::Trait for Runtime { +impl pallet_grandpa::Trait for Runtime { type Event = Event; + type Call = Call; + type KeyOwnerProof = + >::Proof; + + type KeyOwnerIdentification = >::IdentificationTuple; + + type KeyOwnerProofSystem = Historical; + + type HandleEquivocation = pallet_grandpa::EquivocationHandler< + Self::KeyOwnerIdentification, + primitives::report::ReporterAppCrypto, + Runtime, + Offences, + >; } -impl indices::Trait for Runtime { - /// The type for recording indexing into the account enumeration. If this ever overflows, there - /// will be problems! - type AccountIndex = u32; - /// Use the standard means of resolving an index hint from an id. - type ResolveHint = indices::SimpleResolveHint; - /// Determine whether an account is dead. - type IsDeadAccount = Balances; - /// The ubiquitous event type. - type Event = Event; +impl system::offchain::CreateSignedTransaction for Runtime +where + Call: From, +{ + fn create_transaction>( + call: Call, + public: ::Signer, + account: AccountId, + nonce: Index, + ) -> Option<( + Call, + ::SignaturePayload, + )> { + integration::transactions::create_transaction::(call, public, account, nonce) + } +} + +impl system::offchain::SigningTypes for Runtime { + type Public = ::Signer; + type Signature = Signature; +} + +impl system::offchain::SendTransactionTypes for Runtime +where + Call: From, +{ + type Extrinsic = UncheckedExtrinsic; + type OverarchingCall = Call; } parameter_types! { pub const MinimumPeriod: Moment = SLOT_DURATION / 2; } -impl timestamp::Trait for Runtime { - /// A timestamp: milliseconds since the unix epoch. +impl pallet_timestamp::Trait for Runtime { type Moment = Moment; type OnTimestampSet = Babe; type MinimumPeriod = MinimumPeriod; @@ -290,63 +200,53 @@ parameter_types! { pub const ExistentialDeposit: u128 = 0; pub const TransferFee: u128 = 0; pub const CreationFee: u128 = 0; - pub const TransactionBaseFee: u128 = 1; - pub const TransactionByteFee: u128 = 0; pub const InitialMembersBalance: u32 = 2000; } -impl balances::Trait for Runtime { - /// The type for recording an account's balance. +impl pallet_balances::Trait for Runtime { type Balance = Balance; - /// What to do if an account's free balance gets zeroed. - type OnFreeBalanceZero = (Staking, Session); - /// What to do if a new account is created. - type OnNewAccount = (); // Indices; // disable use of Indices feature - /// The ubiquitous event type. - type Event = Event; - type DustRemoval = (); - type TransferPayment = (); + type Event = Event; type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + type AccountStore = System; +} + +parameter_types! { + pub const TransactionByteFee: Balance = 0; // TODO: adjust fee } -impl transaction_payment::Trait for Runtime { +impl pallet_transaction_payment::Trait for Runtime { type Currency = Balances; type OnTransactionPayment = (); - type TransactionBaseFee = TransactionBaseFee; type TransactionByteFee = TransactionByteFee; - type WeightToFee = (); - type FeeMultiplierUpdate = (); + type WeightToFee = integration::transactions::NoWeights; // TODO: adjust weight + type FeeMultiplierUpdate = (); // TODO: adjust fee } -impl sudo::Trait for Runtime { +impl pallet_sudo::Trait for Runtime { type Event = Event; - type Proposal = Call; + type Call = Call; } parameter_types! { pub const UncleGenerations: BlockNumber = 5; } -impl authorship::Trait for Runtime { - type FindAuthor = session::FindAccountFromAuthorIndex; +impl pallet_authorship::Trait for Runtime { + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; type UncleGenerations = UncleGenerations; type FilterUncle = (); type EventHandler = Staking; } -type SessionHandlers = (Grandpa, Babe, ImOnline); - impl_opaque_keys! { pub struct SessionKeys { pub grandpa: Grandpa, pub babe: Babe, pub im_online: ImOnline, + pub authority_discovery: AuthorityDiscovery, } } - // NOTE: `SessionHandler` and `SessionKeys` are co-dependent: One key will be used for each handler. // The number and order of items in `SessionHandler` *MUST* be the same number and order of keys in // `SessionKeys`. @@ -356,24 +256,24 @@ parameter_types! { pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); } -impl session::Trait for Runtime { - type OnSessionEnding = Staking; - type SessionHandler = SessionHandlers; - type ShouldEndSession = Babe; +impl pallet_session::Trait for Runtime { type Event = Event; - type Keys = SessionKeys; type ValidatorId = AccountId; - type ValidatorIdOf = staking::StashOf; - type SelectInitialValidators = Staking; + type ValidatorIdOf = pallet_staking::StashOf; + type ShouldEndSession = Babe; + type NextSessionRotation = Babe; + type SessionManager = pallet_session::historical::NoteHistoricalRoot; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; type DisabledValidatorsThreshold = DisabledValidatorsThreshold; } -impl session::historical::Trait for Runtime { - type FullIdentification = staking::Exposure; - type FullIdentificationOf = staking::ExposureOf; +impl pallet_session::historical::Trait for Runtime { + type FullIdentification = pallet_staking::Exposure; + type FullIdentificationOf = pallet_staking::ExposureOf; } -srml_staking_reward_curve::build! { +pallet_staking_reward_curve::build! { const REWARD_CURVE: PiecewiseLinear<'static> = curve!( min_inflation: 0_025_000, max_inflation: 0_300_000, @@ -385,56 +285,74 @@ srml_staking_reward_curve::build! { } parameter_types! { - pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6; - pub const BondingDuration: staking::EraIndex = 24; + pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _; + pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); + /// We prioritize im-online heartbeats over election solution submission. + pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; +} + +parameter_types! { + pub const SessionsPerEra: sp_staking::SessionIndex = 6; + pub const BondingDuration: pallet_staking::EraIndex = 24; + pub const SlashDeferDuration: pallet_staking::EraIndex = 6; // 1/4 the bonding duration. pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; + pub const MaxNominatorRewardedPerValidator: u32 = 64; + pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4; + pub const MaxIterations: u32 = 10; + // 0.05%. The higher the value, the more strict solution acceptance becomes. + pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); } -impl staking::Trait for Runtime { +impl pallet_staking::Trait for Runtime { type Currency = Balances; - type Time = Timestamp; + type UnixTime = Timestamp; type CurrencyToVote = common::currency::CurrencyToVoteHandler; - type RewardRemainder = (); + type RewardRemainder = (); // Could be Treasury. type Event = Event; - type Slash = (); // where to send the slashed funds. - type Reward = (); // rewards are minted from the void + type Slash = (); // Where to send the slashed funds. Could be Treasury. + type Reward = (); // Rewards are minted from the void. type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; + type SlashDeferDuration = SlashDeferDuration; + type SlashCancelOrigin = EnsureRoot; // Requires sudo. Parity recommends: a super-majority of the council can cancel the slash. type SessionInterface = Self; type RewardCurve = RewardCurve; + type NextNewSession = Session; + type ElectionLookahead = MaxIterations; + type Call = Call; + type MaxIterations = MaxIterations; + type MinSolutionScoreBump = MinSolutionScoreBump; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type UnsignedPriority = StakingUnsignedPriority; } -type SubmitTransaction = TransactionSubmitter; - -parameter_types! { - pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _; -} - -impl im_online::Trait for Runtime { +impl pallet_im_online::Trait for Runtime { type AuthorityId = ImOnlineId; - type Call = Call; type Event = Event; - type SubmitTransaction = SubmitTransaction; - type ReportUnresponsiveness = Offences; type SessionDuration = SessionDuration; + type ReportUnresponsiveness = Offences; + type UnsignedPriority = ImOnlineUnsignedPriority; +} + +parameter_types! { + pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get(); } -impl offences::Trait for Runtime { +impl pallet_offences::Trait for Runtime { type Event = Event; - type IdentificationTuple = session::historical::IdentificationTuple; + type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; + type WeightSoftLimit = OffencesWeightSoftLimit; } -impl authority_discovery::Trait for Runtime { - type AuthorityId = BabeId; -} +impl pallet_authority_discovery::Trait for Runtime {} parameter_types! { pub const WindowSize: BlockNumber = 101; pub const ReportLatency: BlockNumber = 1000; } -impl finality_tracker::Trait for Runtime { +impl pallet_finality_tracker::Trait for Runtime { type OnFinalizationStalled = Grandpa; type WindowSize = WindowSize; type ReportLatency = ReportLatency; @@ -448,57 +366,10 @@ impl versioned_store_permissions::Trait for Runtime { type Credential = Credential; type CredentialChecker = ( integration::content_working_group::ContentWorkingGroupCredentials, - SudoKeyHasAllCredentials, + integration::versioned_store_permissions::SudoKeyHasAllCredentials, ); - type CreateClassPermissionsChecker = ContentLeadOrSudoKeyCanCreateClasses; -} - -// Credential Checker that gives the sudo key holder all credentials -pub struct SudoKeyHasAllCredentials {} -impl versioned_store_permissions::CredentialChecker for SudoKeyHasAllCredentials { - fn account_has_credential( - account: &AccountId, - _credential: ::Credential, - ) -> bool { - >::key() == *account - } -} - -// Allow sudo key holder permission to create classes -pub struct SudoKeyCanCreateClasses {} -impl versioned_store_permissions::CreateClassPermissionsChecker - for SudoKeyCanCreateClasses -{ - fn account_can_create_class_permissions(account: &AccountId) -> bool { - >::key() == *account - } -} - -pub struct ContentLeadOrSudoKeyCanCreateClasses {} -impl versioned_store_permissions::CreateClassPermissionsChecker - for ContentLeadOrSudoKeyCanCreateClasses -{ - fn account_can_create_class_permissions(account: &AccountId) -> bool { - ContentLeadCanCreateClasses::account_can_create_class_permissions(account) - || SudoKeyCanCreateClasses::account_can_create_class_permissions(account) - } -} - -// Allow content working group lead to create classes in content directory -pub struct ContentLeadCanCreateClasses {} -impl versioned_store_permissions::CreateClassPermissionsChecker - for ContentLeadCanCreateClasses -{ - fn account_can_create_class_permissions(account: &AccountId) -> bool { - // get current lead id - let maybe_current_lead_id = content_wg::CurrentLeadId::::get(); - if let Some(lead_id) = maybe_current_lead_id { - let lead = content_wg::LeadById::::get(lead_id); - lead.role_account == *account - } else { - false - } - } + type CreateClassPermissionsChecker = + integration::versioned_store_permissions::ContentLeadOrSudoKeyCanCreateClasses; } impl hiring::Trait for Runtime { @@ -513,7 +384,7 @@ impl minting::Trait for Runtime { type MintId = u64; } -impl recurringrewards::Trait for Runtime { +impl recurring_rewards::Trait for Runtime { type PayoutStatusHandler = (); // TODO - deal with successful and failed payouts type RecipientId = u64; type RewardRelationshipId = u64; @@ -542,7 +413,7 @@ impl content_wg::Trait for Runtime { } impl common::currency::GovernanceCurrency for Runtime { - type Currency = balances::Module; + type Currency = pallet_balances::Module; } impl governance::election::Trait for Runtime { @@ -591,46 +462,13 @@ impl membership::Trait for Runtime { type ActorId = ActorId; } -/* - * Forum module integration - * - * ForumUserRegistry could have been implemented directly on - * the membership module, and likewise ForumUser on Profile, - * however this approach is more loosely coupled. - * - * Further exploration required to decide what the long - * run convention should be. - */ - -/// Shim registry which will proxy ForumUserRegistry behaviour to the members module -pub struct ShimMembershipRegistry {} - -impl forum::ForumUserRegistry for ShimMembershipRegistry { - fn get_forum_user(id: &AccountId) -> Option> { - if membership::Module::::is_member_account(id) { - // For now we don't retreive the members profile since it is not used for anything, - // but in the future we may need it to read out more - // information possibly required to construct a - // ForumUser. - - // Now convert member profile to a forum user - Some(forum::ForumUser { id: id.clone() }) - } else { - None - } - } -} - impl forum::Trait for Runtime { type Event = Event; - type MembershipRegistry = ShimMembershipRegistry; + type MembershipRegistry = integration::forum::ShimMembershipRegistry; type ThreadId = ThreadId; type PostId = PostId; } -impl migration::Trait for Runtime { - type Event = Event; -} // The storage working group instance alias. pub type StorageWorkingGroupInstance = working_group::Instance2; @@ -705,6 +543,30 @@ impl proposals_codex::Trait for Runtime { type ProposalEncoder = ExtrinsicProposalEncoder; } +parameter_types! { + pub const TombstoneDeposit: Balance = 1; // TODO: adjust fee + pub const RentByteFee: Balance = 1; // TODO: adjust fee + pub const RentDepositOffset: Balance = 0; // no rent deposit + pub const SurchargeReward: Balance = 0; // no reward +} + +/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know +/// the specifics of the runtime. They can then be made to be agnostic over specific formats +/// of data like extrinsics, allowing for them to continue syncing the network through upgrades +/// to even the core datastructures. +pub mod opaque { + use super::*; + + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; + + /// Opaque block header type. + pub type Header = generic::Header; + /// Opaque block type. + pub type Block = generic::Block; + /// Opaque block identifier type. + pub type BlockId = generic::BlockId; +} + construct_runtime!( pub enum Runtime where Block = Block, @@ -712,24 +574,23 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { // Substrate - System: system::{Module, Call, Storage, Config, Event}, - Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, - Timestamp: timestamp::{Module, Call, Storage, Inherent}, - Authorship: authorship::{Module, Call, Storage, Inherent}, - Indices: indices, - Balances: balances, - TransactionPayment: transaction_payment::{Module, Storage}, - Staking: staking::{default, OfflineWorker}, - Session: session::{Module, Call, Storage, Event, Config}, - FinalityTracker: finality_tracker::{Module, Call, Inherent}, - Grandpa: grandpa::{Module, Call, Storage, Config, Event}, - ImOnline: im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, - AuthorityDiscovery: authority_discovery::{Module, Call, Config}, - Offences: offences::{Module, Call, Storage, Event}, - RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage}, - Sudo: sudo, + System: system::{Module, Call, Storage, Config, Event}, + Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, + Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, + Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, + Balances: pallet_balances::{Module, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Module, Storage}, + Staking: pallet_staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, + Session: pallet_session::{Module, Call, Storage, Event, Config}, + Historical: pallet_session_historical::{Module}, + FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent}, + Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, + ImOnline: pallet_im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, + AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config}, + Offences: pallet_offences::{Module, Call, Storage, Event}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, + Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, // Joystream - Migration: migration::{Module, Call, Storage, Event, Config}, CouncilElection: election::{Module, Call, Storage, Event, Config}, Council: council::{Module, Call, Storage, Event, Config}, Memo: memo::{Module, Call, Storage, Event}, @@ -739,7 +600,7 @@ construct_runtime!( VersionedStorePermissions: versioned_store_permissions::{Module, Call, Storage}, Stake: stake::{Module, Call, Storage}, Minting: minting::{Module, Call, Storage}, - RecurringRewards: recurringrewards::{Module, Call, Storage}, + RecurringRewards: recurring_rewards::{Module, Call, Storage}, Hiring: hiring::{Module, Call, Storage}, ContentWorkingGroup: content_wg::{Module, Call, Storage, Event, Config}, // --- Storage @@ -750,158 +611,9 @@ construct_runtime!( // --- Proposals ProposalsEngine: proposals_engine::{Module, Call, Storage, Event}, ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event}, - ProposalsCodex: proposals_codex::{Module, Call, Storage, Error, Config}, + ProposalsCodex: proposals_codex::{Module, Call, Storage, Config}, // --- Working groups // reserved for the future use: ForumWorkingGroup: working_group::::{Module, Call, Storage, Event}, - StorageWorkingGroup: working_group::::{Module, Call, Storage, Config, Error, Event}, + StorageWorkingGroup: working_group::::{Module, Call, Storage, Config, Event}, } ); - -/// The address format for describing accounts. -pub type Address = ::Source; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; -/// Block type as expected by this runtime. -pub type Block = generic::Block; -/// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; -/// BlockId type as expected by this runtime. -pub type BlockId = generic::BlockId; -/// The SignedExtension to the basic transaction logic. -pub type SignedExtra = ( - system::CheckVersion, - system::CheckGenesis, - system::CheckEra, - system::CheckNonce, - system::CheckWeight, - transaction_payment::ChargeTransactionPayment, -); -/// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; -/// Executive: handles dispatch to the various modules. -pub type Executive = - executive::Executive, Runtime, AllModules>; - -impl_runtime_apis! { - impl client_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block) - } - - fn initialize_block(header: &::Header) { - Executive::initialize_block(header) - } - } - - impl client_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - Runtime::metadata().into() - } - } - - impl block_builder_api::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult { - data.check_extrinsics(&block) - } - - fn random_seed() -> ::Hash { - RandomnessCollectiveFlip::random_seed() - } - } - - impl client_api::TaggedTransactionQueue for Runtime { - fn validate_transaction(tx: ::Extrinsic) -> TransactionValidity { - Executive::validate_transaction(tx) - } - } - - impl offchain_primitives::OffchainWorkerApi for Runtime { - fn offchain_worker(number: NumberFor) { - Executive::offchain_worker(number) - } - } - - impl fg_primitives::GrandpaApi for Runtime { - fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { - Grandpa::grandpa_authorities() - } - } - - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { - // The choice of `c` parameter (where `1 - c` represents the - // probability of a slot being empty), is done in accordance to the - // slot duration and expected target block time, for safely - // resisting network delays of maximum two seconds. - // - babe_primitives::BabeConfiguration { - slot_duration: Babe::slot_duration(), - epoch_length: EpochDuration::get(), - c: PRIMARY_PROBABILITY, - genesis_authorities: Babe::authorities(), - randomness: Babe::randomness(), - secondary_slots: true, - } - } - } - - impl authority_discovery_primitives::AuthorityDiscoveryApi for Runtime { - fn authorities() -> Vec { - AuthorityDiscovery::authorities().into_iter() - .map(|id| id.encode()) - .map(EncodedAuthorityId) - .collect() - } - - fn sign(payload: &Vec) -> Option<(EncodedSignature, EncodedAuthorityId)> { - AuthorityDiscovery::sign(payload).map(|(sig, id)| { - (EncodedSignature(sig.encode()), EncodedAuthorityId(id.encode())) - }) - } - - fn verify(payload: &Vec, signature: &EncodedSignature, authority_id: &EncodedAuthorityId) -> bool { - let signature = match BabeSignature::decode(&mut &signature.0[..]) { - Ok(s) => s, - _ => return false, - }; - - let authority_id = match BabeId::decode(&mut &authority_id.0[..]) { - Ok(id) => id, - _ => return false, - }; - - AuthorityDiscovery::verify(payload, signature, authority_id) - } - } - - impl system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { - System::account_nonce(account) - } - } - - impl substrate_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s).expect("Seed is an utf8 string")); - opaque::SessionKeys::generate(seed) - } - } -} diff --git a/runtime/src/migration.rs b/runtime/src/migration.rs deleted file mode 100644 index 71560daded..0000000000 --- a/runtime/src/migration.rs +++ /dev/null @@ -1,131 +0,0 @@ -// Clippy linter warning -#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design - -use crate::VERSION; -use proposals_codex::ProposalsConfigParameters; -use rstd::prelude::*; -use sr_primitives::{ - print, - traits::{One, Zero}, -}; -use srml_support::{debug, decl_event, decl_module, decl_storage}; - -impl Module { - /// This method is called from on_initialize() when a runtime upgrade is detected. This - /// happens when the runtime spec version is found to be higher than the stored value. - /// Important to note this method should be carefully maintained, because it runs on every runtime - /// upgrade. - fn runtime_upgraded() { - debug::print!("Running runtime upgraded handler"); - - // Add initialization of modules introduced in new runtime release. Typically this - // would be any new storage values that need an initial value which would not - // have been initialized with config() or build() chainspec construction mechanism. - // Other tasks like resetting values, migrating values etc. - - Self::initialize_storage_working_group_mint(); - Self::initialize_storage_working_group_text_constraints(); - Self::clear_storage_data(); - - proposals_codex::Module::::set_config_values(ProposalsConfigParameters::default()); - } -} - -pub trait Trait: - system::Trait - + minting::Trait - + proposals_codex::Trait - + working_group::Trait - + storage::data_directory::Trait - + storage::data_object_storage_registry::Trait -{ - type Event: From> + Into<::Event>; -} - -decl_storage! { - trait Store for Module as Migration { - /// Records at what runtime spec version the store was initialized. At genesis this will be - /// initialized to Some(VERSION.spec_version). It is an Option because the first time the module - /// was introduced was as a runtime upgrade and type was never changed. - /// When the runtime is upgraded the spec version be updated. - pub SpecVersion get(spec_version) build(|_config: &GenesisConfig| { - VERSION.spec_version - }) : Option; - } -} - -decl_event! { - pub enum Event where ::BlockNumber { - Migrated(BlockNumber, u32), - } -} - -decl_module! { - pub struct Module for enum Call where origin: T::Origin { - fn deposit_event() = default; - - fn on_initialize(_now: T::BlockNumber) { - if Self::spec_version().map_or(true, |spec_version| VERSION.spec_version > spec_version) { - // Mark store version with current version of the runtime - SpecVersion::put(VERSION.spec_version); - - // Run migrations and store initializers - Self::runtime_upgraded(); - - Self::deposit_event(RawEvent::Migrated( - >::block_number(), - VERSION.spec_version, - )); - } - } - } -} - -impl Module { - fn initialize_storage_working_group_mint() { - let mint_id_result = >::add_mint(>::zero(), None); - - if let Ok(mint_id) = mint_id_result { - >::put(mint_id); - } else { - print("Failed to create a mint for the storage working group"); - } - } - - fn initialize_storage_working_group_text_constraints() { - >::put( - working_group::default_text_constraint(), - ); - >::put( - working_group::default_text_constraint(), - ); - >::put( - working_group::default_text_constraint(), - ); - } - - fn clear_storage_data() { - // Clear storage data object registry data. - for id in >::known_content_ids() { - >::remove(id); - } - - let mut potential_id = ::DataObjectStorageRelationshipId::zero(); - while potential_id - < storage::data_object_storage_registry::Module::::next_relationship_id() - { - >::remove(&potential_id); - - potential_id += ::DataObjectStorageRelationshipId::one(); - } - - storage::data_object_storage_registry::NextRelationshipId::::kill(); - - // Clear storage data directory data. - for id in >::known_content_ids() { - >::remove(id); - } - - >::kill(); - } -} diff --git a/runtime/src/primitives.rs b/runtime/src/primitives.rs new file mode 100644 index 0000000000..99ea7258e3 --- /dev/null +++ b/runtime/src/primitives.rs @@ -0,0 +1,95 @@ +//! Low-level types used throughout the Substrate code. + +#![warn(missing_docs)] + +#![cfg_attr(not(feature = "std"), no_std)] + +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + MultiSignature, +}; + +/// Priority for a transaction. Additive. Higher is better. +pub type TransactionPriority = u64; + +/// Alias for ContentId, used in various places. +pub type ContentId = sp_core::H256; + +/// An index to a block. +pub type BlockNumber = u32; + +/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. +pub type Signature = MultiSignature; + +/// Some way of identifying an account on the chain. We intentionally make it equivalent +/// to the public key of our transaction signing scheme. +pub type AccountId = <::Signer as IdentifyAccount>::AccountId; + +/// The type for looking up accounts. We don't expect more than 4 billion of them, but you +/// never know... +pub type AccountIndex = u32; + +/// Balance of an account. +pub type Balance = u128; + +/// Index of a transaction in the chain. +pub type Index = u32; + +/// A hash of some data used by the chain. +pub type Hash = sp_core::H256; + +/// Moment type +pub type Moment = u64; + +/// Credential type +pub type Credential = u64; + +/// Represents a thread identifier for both Forum and Proposals Discussion +/// +/// Note: Both modules expose type names ThreadId and PostId (which are defined on their Trait) and +/// used in state storage and dispatchable method's argument types, +/// and are therefore part of the public API/metadata of the runtime. +/// In the current version the polkadot-js/api that is used and is compatible with the runtime, +/// the type registry has flat namespace and its not possible +/// to register identically named types from different modules, separately. And so we MUST configure +/// the underlying types to be identicaly to avoid issues with encoding/decoding these types on the client side. +pub type ThreadId = u64; + +/// Represents a post identifier for both Forum and Proposals Discussion +/// +/// See the Note about ThreadId +pub type PostId = u64; + +/// Represent an actor in membership group, which is the same in the working groups. +pub type ActorId = u64; + +/// App-specific crypto used for reporting equivocation/misbehavior in BABE and +/// GRANDPA. Any rewards for misbehavior reporting will be paid out to this +/// account. +pub mod report { + use super::{Signature, Verify}; + use sp_core::crypto::{key_types, KeyTypeId}; + use system::offchain::AppCrypto; + + /// Key type for the reporting module. Used for reporting BABE and GRANDPA + /// equivocations. + pub const KEY_TYPE: KeyTypeId = key_types::REPORTING; + + mod app { + use sp_application_crypto::{app_crypto, sr25519}; + app_crypto!(sr25519, super::KEY_TYPE); + } + + /// Identity of the equivocation/misbehavior reporter. + pub type ReporterId = app::Public; + + /// An `AppCrypto` type to allow submitting signed transactions using the reporting + /// application key as signer. + pub struct ReporterAppCrypto; + + impl AppCrypto<::Signer, Signature> for ReporterAppCrypto { + type RuntimeAppPublic = ReporterId; + type GenericSignature = sp_core::sr25519::Signature; + type GenericPublic = sp_core::sr25519::Public; + } +} diff --git a/runtime/src/runtime_api.rs b/runtime/src/runtime_api.rs new file mode 100644 index 0000000000..acb9c4e015 --- /dev/null +++ b/runtime/src/runtime_api.rs @@ -0,0 +1,204 @@ +use frame_support::inherent::{CheckInherentsResult, InherentData}; +use frame_support::traits::{KeyOwnerProofSystem, Randomness}; +use frame_support::unsigned::{TransactionSource, TransactionValidity}; +use pallet_grandpa::fg_primitives; +use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; +use sp_api::impl_runtime_apis; +use sp_core::crypto::KeyTypeId; +use sp_core::OpaqueMetadata; +use sp_runtime::traits::{BlakeTwo256, Block as BlockT, NumberFor}; +use sp_runtime::{generic, ApplyExtrinsicResult}; +use sp_std::vec::Vec; + +use crate::constants::PRIMARY_PROBABILITY; +use crate::{ + AccountId, AuthorityDiscoveryId, Balance, BlockNumber, EpochDuration, GrandpaAuthorityList, + GrandpaId, Hash, Index, RuntimeVersion, Signature, VERSION, +}; +use crate::{ + AllModules, AuthorityDiscovery, Babe, Call, Grandpa, Historical, InherentDataExt, + RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment, +}; + +/// The SignedExtension to the basic transaction logic. +pub type SignedExtra = ( + system::CheckSpecVersion, + system::CheckTxVersion, + system::CheckGenesis, + system::CheckEra, + system::CheckNonce, + system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, + pallet_grandpa::ValidateEquivocationReport, +); + +/// Digest item type. +pub type DigestItem = generic::DigestItem; + +/// Block header type as expected by this runtime. +pub type Header = generic::Header; + +/// Block type as expected by this runtime. +pub type Block = generic::Block; + +/// A Block signed with a Justification +pub type SignedBlock = generic::SignedBlock; + +/// BlockId type as expected by this runtime. +pub type BlockId = generic::BlockId; + +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + +/// Executive: handles dispatch to the various modules. +pub type Executive = + frame_executive::Executive, Runtime, AllModules>; + +/// Export of the private const generated within the macro. +pub const EXPORTED_RUNTIME_API_VERSIONS: sp_version::ApisVec = RUNTIME_API_VERSIONS; + +impl_runtime_apis! { + impl sp_api::Core for Runtime { + fn version() -> RuntimeVersion { + VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + Runtime::metadata().into() + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> ::Header { + Executive::finalize_block() + } + + fn inherent_extrinsics(data: InherentData) -> Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult { + data.check_extrinsics(&block) + } + + fn random_seed() -> ::Hash { + RandomnessCollectiveFlip::random_seed() + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx) + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) + } + } + + impl fg_primitives::GrandpaApi for Runtime { + fn grandpa_authorities() -> GrandpaAuthorityList { + Grandpa::grandpa_authorities() + } + + fn submit_report_equivocation_extrinsic( + equivocation_proof: fg_primitives::EquivocationProof< + ::Hash, + NumberFor, + >, + key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, + ) -> Option<()> { + let key_owner_proof = key_owner_proof.decode()?; + + Grandpa::submit_report_equivocation_extrinsic( + equivocation_proof, + key_owner_proof, + ) + } + + fn generate_key_ownership_proof( + _set_id: fg_primitives::SetId, + authority_id: GrandpaId, + ) -> Option { + use codec::Encode; + + Historical::prove((fg_primitives::KEY_TYPE, authority_id)) + .map(|p| p.encode()) + .map(fg_primitives::OpaqueKeyOwnershipProof::new) + } + } + + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::BabeGenesisConfiguration { + // The choice of `c` parameter (where `1 - c` represents the + // probability of a slot being empty), is done in accordance to the + // slot duration and expected target block time, for safely + // resisting network delays of maximum two seconds. + // + sp_consensus_babe::BabeGenesisConfiguration { + slot_duration: Babe::slot_duration(), + epoch_length: EpochDuration::get(), + c: PRIMARY_PROBABILITY, + genesis_authorities: Babe::authorities(), + randomness: Babe::randomness(), + allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, + } + } + + fn current_epoch_start() -> sp_consensus_babe::SlotNumber { + Babe::current_epoch_start() + } + } + + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { + fn authorities() -> Vec { + AuthorityDiscovery::authorities() + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Index { + System::account_nonce(account) + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< + Block, + Balance, + UncheckedExtrinsic, + > for Runtime { + fn query_info(uxt: UncheckedExtrinsic, len: u32) -> RuntimeDispatchInfo { + TransactionPayment::query_info(uxt, len) + } + } + + impl sp_session::SessionKeys for Runtime { + fn generate_session_keys(seed: Option>) -> Vec { + SessionKeys::generate(seed) + } + fn decode_session_keys( + encoded: Vec, + ) -> Option, KeyTypeId)>> { + SessionKeys::decode_into_raw_public_keys(&encoded) + } + } +} diff --git a/runtime/src/tests/mod.rs b/runtime/src/tests/mod.rs index 9475fa2452..7ac7f75e8c 100644 --- a/runtime/src/tests/mod.rs +++ b/runtime/src/tests/mod.rs @@ -5,7 +5,7 @@ mod proposals_integration; mod storage_integration; -pub(crate) fn initial_test_ext() -> runtime_io::TestExternalities { +pub(crate) fn initial_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/runtime/src/tests/proposals_integration/mod.rs b/runtime/src/tests/proposals_integration/mod.rs index 3ac9a560b1..44ab718938 100644 --- a/runtime/src/tests/proposals_integration/mod.rs +++ b/runtime/src/tests/proposals_integration/mod.rs @@ -4,26 +4,27 @@ mod working_group_proposals; -use crate::{BlockNumber, ElectionParameters, ProposalCancellationFee, Runtime}; +use crate::{BlockNumber, ProposalCancellationFee, Runtime}; use codec::Encode; +use governance::election_params::ElectionParameters; use membership; use proposals_engine::{ - ActiveStake, ApprovedProposalStatus, BalanceOf, Error, FinalizationData, Proposal, + ActiveStake, ApprovedProposalStatus, BalanceOf, FinalizationData, Proposal, ProposalDecisionStatus, ProposalParameters, ProposalStatus, VoteKind, VotersParameters, VotingResults, }; -use sr_primitives::traits::{DispatchResult, OnFinalize, OnInitialize}; -use sr_primitives::AccountId32; -use srml_support::traits::Currency; -use srml_support::{StorageLinkedMap, StorageValue}; +use frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::traits::{Currency, OnFinalize, OnInitialize}; +use frame_support::{StorageMap, StorageValue}; +use sp_runtime::AccountId32; use system::RawOrigin; use super::initial_test_ext; use crate::CouncilManager; -pub type Balances = balances::Module; +pub type Balances = pallet_balances::Module; pub type System = system::Module; pub type Membership = membership::Module; pub type ProposalsEngine = proposals_engine::Module; @@ -75,7 +76,7 @@ pub(crate) fn increase_total_balance_issuance_using_account_id( account_id: AccountId32, balance: u128, ) { - type Balances = balances::Module; + type Balances = pallet_balances::Module; let initial_balance = Balances::total_issuance(); { let _ = ::Currency::deposit_creating(&account_id, balance); @@ -119,11 +120,11 @@ impl VoteGenerator { self.vote_and_assert(vote_kind, Ok(())); } - fn vote_and_assert(&mut self, vote_kind: VoteKind, expected_result: DispatchResult) { + fn vote_and_assert(&mut self, vote_kind: VoteKind, expected_result: DispatchResult) { assert_eq!(self.vote(vote_kind.clone()), expected_result); } - fn vote(&mut self, vote_kind: VoteKind) -> DispatchResult { + fn vote(&mut self, vote_kind: VoteKind) -> DispatchResult { if self.auto_increment_voter_id { self.current_account_id_seed += 1; self.current_voter_id += 1; @@ -211,7 +212,7 @@ impl DummyProposalFixture { } } - fn create_proposal_and_assert(self, result: Result) -> Option { + fn create_proposal_and_assert(self, result: Result) -> Option { let proposal_id_result = ProposalsEngine::create_proposal( self.account_id, self.proposer_id, @@ -250,7 +251,7 @@ impl CancelProposalFixture { } } - fn cancel_and_assert(self, expected_result: DispatchResult) { + fn cancel_and_assert(self, expected_result: DispatchResult) { assert_eq!( ProposalsEngine::cancel_proposal( self.origin.into(), @@ -308,7 +309,7 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() { let mut expected_proposal = Proposal { parameters, proposer_id: member_id, - created_at: 1, + created_at: 0, status: ProposalStatus::Active(Some(ActiveStake { stake_id: 0, source_account_id: account_id.clone(), @@ -329,7 +330,7 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() { expected_proposal.status = ProposalStatus::Finalized(FinalizationData { proposal_status: ProposalDecisionStatus::Canceled, - finalized_at: 1, + finalized_at: 0, encoded_unstaking_error_due_to_broken_runtime: None, stake_data_after_unstaking_error: None, }); @@ -359,9 +360,7 @@ fn proposal_reset_succeeds() { vote_generator.vote_and_assert_ok(VoteKind::Abstain); vote_generator.vote_and_assert_ok(VoteKind::Slash); - assert!(>::exists( - proposal_id - )); + assert!(>::contains_key(proposal_id)); // check let proposal = ProposalsEngine::proposals(proposal_id); @@ -443,7 +442,7 @@ fn elect_single_councilor() { struct CodexProposalTestFixture where - SuccessfulCall: Fn() -> DispatchResult, + SuccessfulCall: Fn() -> DispatchResult, { successful_call: SuccessfulCall, member_id: u64, @@ -454,7 +453,7 @@ where impl CodexProposalTestFixture where - SuccessfulCall: Fn() -> DispatchResult, + SuccessfulCall: Fn() -> DispatchResult, { fn default_for_call(call: SuccessfulCall) -> Self { Self { @@ -500,7 +499,7 @@ where impl CodexProposalTestFixture where - SuccessfulCall: Fn() -> DispatchResult, + SuccessfulCall: Fn() -> DispatchResult, { fn call_extrinsic_and_assert(&self) { let account_id: [u8; 32] = [self.member_id as u8; 32]; @@ -530,7 +529,7 @@ where Proposal { status: ProposalStatus::approved( ApprovedProposalStatus::Executed, - self.run_to_block - 1 + self.run_to_block - 2 ), title: b"title".to_vec(), description: b"body".to_vec(), @@ -618,17 +617,12 @@ fn spending_proposal_execution_succeeds() { }) .with_member_id(member_id as u64); - assert_eq!( - Balances::free_balance::(target_account_id.clone().into()), - 0 - ); + let converted_account_id: AccountId32 = target_account_id.clone().into(); + assert_eq!(Balances::free_balance(converted_account_id.clone()), 0); codex_extrinsic_test_fixture.call_extrinsic_and_assert(); - assert_eq!( - Balances::free_balance::(target_account_id.into()), - new_balance - ); + assert_eq!(Balances::free_balance(converted_account_id), new_balance); }); } @@ -703,7 +697,7 @@ fn set_validator_count_proposal_execution_succeeds() { let account_id: [u8; 32] = [member_id; 32]; let new_validator_count = 8; - assert_eq!(::get(), 0); + assert_eq!(::get(), 0); let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| { ProposalCodex::create_set_validator_count_proposal( @@ -717,6 +711,6 @@ fn set_validator_count_proposal_execution_succeeds() { }); codex_extrinsic_test_fixture.call_extrinsic_and_assert(); - assert_eq!(::get(), new_validator_count); + assert_eq!(::get(), new_validator_count); }); } diff --git a/runtime/src/tests/proposals_integration/working_group_proposals.rs b/runtime/src/tests/proposals_integration/working_group_proposals.rs index 9ea6f53e05..b6c04ebe45 100644 --- a/runtime/src/tests/proposals_integration/working_group_proposals.rs +++ b/runtime/src/tests/proposals_integration/working_group_proposals.rs @@ -1,6 +1,5 @@ use super::*; -use srml_support::StorageLinkedMap; use system::RawOrigin; use common::working_group::WorkingGroup; @@ -9,7 +8,7 @@ use proposals_codex::AddOpeningParameters; use working_group::{OpeningPolicyCommitment, RewardPolicy}; use crate::{Balance, BlockNumber, StorageWorkingGroupInstance}; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; type StorageWorkingGroup = working_group::Module; @@ -23,14 +22,14 @@ fn add_opening( sequence_number: u32, // action sequence number to align with other actions ) -> u64 { let expected_proposal_id = sequence_number; - let run_to_block = sequence_number + 1; + let run_to_block = sequence_number * 2; let opening_id = StorageWorkingGroup::next_opening_id(); assert!(!>::exists(opening_id)); + >>::contains_key(opening_id)); let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| { ProposalCodex::create_add_working_group_leader_opening_proposal( @@ -64,7 +63,7 @@ fn begin_review_applications( sequence_number: u32, // action sequence number to align with other actions ) { let expected_proposal_id = sequence_number; - let run_to_block = sequence_number + 1; + let run_to_block = sequence_number * 2; let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| { ProposalCodex::create_begin_review_working_group_leader_applications_proposal( @@ -93,7 +92,7 @@ fn fill_opening( sequence_number: u32, // action sequence number to align with other actions ) { let expected_proposal_id = sequence_number; - let run_to_block = sequence_number + 1; + let run_to_block = sequence_number * 2; let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| { ProposalCodex::create_fill_working_group_leader_opening_proposal( @@ -133,7 +132,7 @@ fn decrease_stake( sequence_number: u32, // action sequence number to align with other actions ) { let expected_proposal_id = sequence_number; - let run_to_block = sequence_number + 1; + let run_to_block = sequence_number * 2; let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| { ProposalCodex::create_decrease_working_group_leader_stake_proposal( @@ -162,7 +161,7 @@ fn slash_stake( sequence_number: u32, // action sequence number to align with other actions ) { let expected_proposal_id = sequence_number; - let run_to_block = sequence_number + 1; + let run_to_block = sequence_number * 2; let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| { ProposalCodex::create_slash_working_group_leader_stake_proposal( @@ -191,7 +190,7 @@ fn set_reward( sequence_number: u32, // action sequence number to align with other actions ) { let expected_proposal_id = sequence_number; - let run_to_block = sequence_number + 1; + let run_to_block = sequence_number * 2; let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| { ProposalCodex::create_set_working_group_leader_reward_proposal( @@ -220,7 +219,7 @@ fn set_mint_capacity( setup_environment: bool, ) { let expected_proposal_id = sequence_number; - let run_to_block = sequence_number + 1; + let run_to_block = sequence_number * 2; let mint_id_result = >::add_mint(0, None); @@ -254,7 +253,7 @@ fn terminate_role( sequence_number: u32, // action sequence number to align with other actions ) { let expected_proposal_id = sequence_number; - let run_to_block = sequence_number + 1; + let run_to_block = sequence_number * 2; let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| { ProposalCodex::create_terminate_working_group_leader_role_proposal( @@ -289,7 +288,7 @@ fn create_add_working_group_leader_opening_proposal_execution_succeeds() { assert!(!>::exists(next_opening_id)); + >>::contains_key(next_opening_id)); let opening_id = add_opening( member_id, @@ -306,7 +305,7 @@ fn create_add_working_group_leader_opening_proposal_execution_succeeds() { assert!(>::exists(opening_id)); + >>::contains_key(opening_id)); }); } @@ -331,7 +330,7 @@ fn create_begin_review_working_group_leader_applications_proposal_execution_succ hiring_opening.stage, hiring::OpeningStage::Active { stage: hiring::ActiveOpeningStage::AcceptingApplications { - started_accepting_applicants_at_block: 1 + started_accepting_applicants_at_block: 0 }, applications_added: BTreeSet::new(), active_application_count: 0, @@ -347,7 +346,7 @@ fn create_begin_review_working_group_leader_applications_proposal_execution_succ hiring_opening.stage, hiring::OpeningStage::Active { stage: hiring::ActiveOpeningStage::ReviewPeriod { - started_accepting_applicants_at_block: 1, + started_accepting_applicants_at_block: 0, started_review_period_at_block: 2, }, applications_added: BTreeSet::new(), @@ -462,7 +461,7 @@ fn create_decrease_group_leader_stake_proposal_execution_succeeds() { let leader_worker_id = StorageWorkingGroup::current_lead().unwrap(); let stake_id = 1; - let old_balance = Balances::free_balance::<&AccountId32>(&account_id.into()); + let old_balance = Balances::free_balance(&account_id.into()); let old_stake = >::stakes(stake_id); assert_eq!(get_stake_balance(old_stake), stake_amount); @@ -476,7 +475,7 @@ fn create_decrease_group_leader_stake_proposal_execution_succeeds() { 4, ); - let new_balance = Balances::free_balance::<&AccountId32>(&account_id.into()); + let new_balance = Balances::free_balance(&account_id.into()); let new_stake = >::stakes(stake_id); assert_eq!( @@ -543,7 +542,7 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() { let leader_worker_id = StorageWorkingGroup::current_lead().unwrap(); let stake_id = 1; - let old_balance = Balances::free_balance::<&AccountId32>(&account_id.into()); + let old_balance = Balances::free_balance(&account_id.into()); let old_stake = >::stakes(stake_id); assert_eq!(get_stake_balance(old_stake), stake_amount); @@ -557,7 +556,7 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() { 4, ); - let new_balance = Balances::free_balance::<&AccountId32>(&account_id.into()); + let new_balance = Balances::free_balance(&account_id.into()); let new_stake = >::stakes(stake_id); assert_eq!( @@ -653,7 +652,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() { let worker = StorageWorkingGroup::worker_by_id(leader_worker_id); let relationship_id = worker.reward_relationship.unwrap(); - let relationship = recurringrewards::RewardRelationships::::get(relationship_id); + let relationship = recurring_rewards::RewardRelationships::::get(relationship_id); assert_eq!(relationship.amount_per_payout, old_reward_amount); let new_reward_amount = 999; @@ -665,7 +664,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() { 5, ); - let relationship = recurringrewards::RewardRelationships::::get(relationship_id); + let relationship = recurring_rewards::RewardRelationships::::get(relationship_id); assert_eq!(relationship.amount_per_payout, new_reward_amount); }); } @@ -735,7 +734,7 @@ fn create_terminate_group_leader_role_proposal_execution_succeeds() { let leader_worker_id = StorageWorkingGroup::current_lead().unwrap(); let stake_id = 1; - let old_balance = Balances::free_balance::<&AccountId32>(&account_id.into()); + let old_balance = Balances::free_balance(&account_id.into()); let old_stake = >::stakes(stake_id); assert_eq!(get_stake_balance(old_stake), stake_amount); @@ -744,7 +743,7 @@ fn create_terminate_group_leader_role_proposal_execution_succeeds() { assert!(StorageWorkingGroup::current_lead().is_none()); - let new_balance = Balances::free_balance::<&AccountId32>(&account_id.into()); + let new_balance = Balances::free_balance(&account_id.into()); let new_stake = >::stakes(stake_id); assert_eq!(new_stake.staking_status, stake::StakingStatus::NotStaked); @@ -817,7 +816,7 @@ fn create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds( let leader_worker_id = StorageWorkingGroup::current_lead().unwrap(); let stake_id = 1; - let old_balance = Balances::free_balance::<&AccountId32>(&account_id.into()); + let old_balance = Balances::free_balance(&account_id.into()); let old_stake = >::stakes(stake_id); assert_eq!(get_stake_balance(old_stake), stake_amount); @@ -826,7 +825,7 @@ fn create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds( assert!(StorageWorkingGroup::current_lead().is_none()); - let new_balance = Balances::free_balance::<&AccountId32>(&account_id.into()); + let new_balance = Balances::free_balance(&account_id.into()); let new_stake = >::stakes(stake_id); assert_eq!(new_stake.staking_status, stake::StakingStatus::NotStaked); diff --git a/runtime/src/tests/storage_integration.rs b/runtime/src/tests/storage_integration.rs index 1cd5f4eb69..3d3e9093f4 100644 --- a/runtime/src/tests/storage_integration.rs +++ b/runtime/src/tests/storage_integration.rs @@ -2,12 +2,14 @@ use super::initial_test_ext; use crate::integration::storage::StorageProviderHelper; use crate::Runtime; -use srml_support::{StorageLinkedMap, StorageMap}; +use frame_support::StorageMap; use working_group::{Instance2, Worker}; #[test] fn storage_provider_helper_succeeds() { initial_test_ext().execute_with(|| { + // Bug in random module requires move the initial block number. + >::set_block_number(1); // Error - no workers. let random_provider_result = >::get_random_storage_provider(); assert!(random_provider_result.is_err()); - let account_info = service_discovery::AccountInfo{ + let account_info = service_discovery::ServiceProviderRecord{ identity: Vec::new(), expires_at: 1000 }; diff --git a/utils/chain-spec-builder/Cargo.toml b/utils/chain-spec-builder/Cargo.toml index 408e4a98d7..fc42405500 100644 --- a/utils/chain-spec-builder/Cargo.toml +++ b/utils/chain-spec-builder/Cargo.toml @@ -1,30 +1,17 @@ [package] -name = "chain-spec-builder" -version = "2.1.0" -authors = ["Parity Technologies "] -edition = "2018" -build = "build.rs" -license = "GPL-3.0" -homepage = "https://substrate.dev" -repository = "https://github.com/paritytech/substrate/" +authors = ['Joystream contributors'] +build = 'build.rs' +edition = '2018' +name = 'chain-spec-builder' +version = '3.0.0' [dependencies] ansi_term = "0.12.1" rand = "0.7.2" -structopt = "0.3.5" +structopt = "0.3.8" +sc-keystore = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-telemetry = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-chain-spec = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-core = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } joystream-node = { path = "../../node" } -[dependencies.sr-keystore] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-keystore' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.sr-primitives] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-primitives' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' - -[dependencies.substrate-telemetry] -git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-telemetry' -rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' diff --git a/utils/chain-spec-builder/src/main.rs b/utils/chain-spec-builder/src/main.rs index a50b97c657..0c3abaef60 100644 --- a/utils/chain-spec-builder/src/main.rs +++ b/utils/chain-spec-builder/src/main.rs @@ -27,14 +27,15 @@ use joystream_node::{ chain_spec::{self, chain_spec_properties, AccountId}, proposals_config, }; -use sr_keystore::Store as Keystore; -use sr_primitives::{ +use sc_chain_spec::ChainType; +use sc_keystore::Store as Keystore; +use sc_telemetry::TelemetryEndpoints; +use sp_core::{ crypto::{Public, Ss58Codec}, sr25519, traits::BareCryptoStore, }; -use substrate_telemetry::TelemetryEndpoints; const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; /// A utility to easily create a testnet chain spec definition with a given set @@ -134,26 +135,22 @@ fn generate_chain_spec( // "/dns4/tesnet.joystream.org/tcp/30333/p2p/QmaTTdEF6YVCtynSjsXmGPSGcEesAahoZ8pmcCmmBwSE7S", // )]; + let telemetry_endpoints = TelemetryEndpoints::new(vec![(STAGING_TELEMETRY_URL.to_string(), 0)]) + .map_err(|err| format!("Failed to create telemetry endpoints: {:?}", err))?; + let chain_spec = chain_spec::ChainSpec::from_genesis( "Joystream Testnet", "joy_testnet", + ChainType::Development, move || genesis_constructor(&authority_seeds, &endowed_accounts, &sudo_account), - // below can be manually modified in chainspec file, they don't affect genesis state - // but we set some default values here for convenience. vec![], - Some(TelemetryEndpoints::new(vec![( - STAGING_TELEMETRY_URL.to_string(), - 0, - )])), - // protocol_id + Some(telemetry_endpoints), Some(&*"/joy/testnet/0"), - // Properties Some(chain_spec_properties()), - // Extensions - None, // Default::default(), + None, ); - chain_spec.to_json(false).map_err(|err| err) + chain_spec.as_json(false).map_err(|err| err) } fn generate_authority_keys_and_store(seeds: &[String], keystore_path: &Path) -> Result<(), String> { @@ -161,7 +158,7 @@ fn generate_authority_keys_and_store(seeds: &[String], keystore_path: &Path) -> let keystore = Keystore::open(keystore_path.join(format!("auth-{}", n)), None) .map_err(|err| err.to_string())?; - let (_, _, grandpa, babe, im_online) = chain_spec::get_authority_keys_from_seed(seed); + let (_, _, grandpa, babe, im_online, _) = chain_spec::get_authority_keys_from_seed(seed); let insert_key = |key_type, public| { keystore @@ -170,17 +167,11 @@ fn generate_authority_keys_and_store(seeds: &[String], keystore_path: &Path) -> .map_err(|_| format!("Failed to insert key: {}", grandpa)) }; - insert_key(sr_primitives::crypto::key_types::BABE, babe.as_slice())?; + insert_key(sp_core::crypto::key_types::BABE, babe.as_slice())?; - insert_key( - sr_primitives::crypto::key_types::GRANDPA, - grandpa.as_slice(), - )?; + insert_key(sp_core::crypto::key_types::GRANDPA, grandpa.as_slice())?; - insert_key( - sr_primitives::crypto::key_types::IM_ONLINE, - im_online.as_slice(), - )?; + insert_key(sp_core::crypto::key_types::IM_ONLINE, im_online.as_slice())?; } Ok(())