From bc0dd14a19833e8f1f6ad73fc22b89245d21e085 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 14 Jul 2020 14:32:46 +0300 Subject: [PATCH 01/56] Upgrade pallet token-mint to the latest Substrate version. --- Cargo.lock | 852 ++++++++++++++++++++-- Cargo.toml | 2 +- runtime-modules/token-minting/Cargo.toml | 49 +- runtime-modules/token-minting/src/lib.rs | 44 +- runtime-modules/token-minting/src/mint.rs | 12 +- runtime-modules/token-minting/src/mock.rs | 38 +- 6 files changed, 859 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f358b40c0a..39efc4c9f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,15 @@ # 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 = "adler32" version = "1.0.4" @@ -681,6 +691,17 @@ dependencies = [ "syn 0.15.44", ] +[[package]] +name = "derive_more" +version = "0.99.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298998b1cf6b5b2c8a7b023dfd45821825ce3ba8a8af55c921a0e734e4653f76" +dependencies = [ + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.17", +] + [[package]] name = "difference" version = "2.0.0" @@ -872,6 +893,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "fixed-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" +dependencies = [ + "byteorder 1.3.4", + "rand 0.7.3", + "rustc-hex", + "static_assertions", +] + [[package]] name = "fixedbitset" version = "0.1.9" @@ -922,6 +955,91 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9" +[[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 1.4.0", + "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 1.0.10", + "quote 1.0.3", + "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 1.0.10", + "quote 1.0.3", + "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 1.0.10", + "quote 1.0.3", + "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 = "fs-swap" version = "0.2.4" @@ -1552,6 +1670,15 @@ 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" @@ -1913,7 +2040,7 @@ dependencies = [ "tokio-codec", "tokio-executor", "tokio-io", - "wasm-timer", + "wasm-timer 0.1.3", ] [[package]] @@ -1948,7 +2075,7 @@ dependencies = [ "unsigned-varint 0.2.3", "untrusted", "void", - "wasm-timer", + "wasm-timer 0.1.3", "zeroize 1.1.0", ] @@ -2022,7 +2149,7 @@ dependencies = [ "tokio-codec", "tokio-io", "unsigned-varint 0.2.3", - "wasm-timer", + "wasm-timer 0.1.3", ] [[package]] @@ -2050,7 +2177,7 @@ dependencies = [ "uint", "unsigned-varint 0.2.3", "void", - "wasm-timer", + "wasm-timer 0.1.3", ] [[package]] @@ -2073,7 +2200,7 @@ dependencies = [ "tokio-reactor", "tokio-udp", "void", - "wasm-timer", + "wasm-timer 0.1.3", ] [[package]] @@ -2129,7 +2256,7 @@ dependencies = [ "rand 0.7.3", "tokio-io", "void", - "wasm-timer", + "wasm-timer 0.1.3", ] [[package]] @@ -2174,7 +2301,7 @@ dependencies = [ "twofish", "untrusted", "wasm-bindgen", - "wasm-bindgen-futures", + "wasm-bindgen-futures 0.3.27", "web-sys", ] @@ -2189,7 +2316,7 @@ dependencies = [ "smallvec 0.6.13", "tokio-io", "void", - "wasm-timer", + "wasm-timer 0.1.3", ] [[package]] @@ -2233,7 +2360,7 @@ dependencies = [ "parity-send-wrapper", "tokio-io", "wasm-bindgen", - "wasm-bindgen-futures", + "wasm-bindgen-futures 0.3.27", ] [[package]] @@ -2416,7 +2543,19 @@ dependencies = [ "ahash", "hash-db", "hashbrown 0.6.3", - "parity-util-mem", + "parity-util-mem 0.2.1", +] + +[[package]] +name = "memory-db" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb2999ff7a65d5a1d72172f6d51fa2ea03024b51aee709ba5ff81c3c629a2410" +dependencies = [ + "ahash", + "hash-db", + "hashbrown 0.6.3", + "parity-util-mem 0.6.1", ] [[package]] @@ -2437,6 +2576,18 @@ dependencies = [ "zeroize 1.1.0", ] +[[package]] +name = "merlin" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" +dependencies = [ + "byteorder 1.3.4", + "keccak", + "rand_core 0.5.1", + "zeroize 1.1.0", +] + [[package]] name = "miniz_oxide" version = "0.3.6" @@ -2707,6 +2858,15 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" +[[package]] +name = "once_cell" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" +dependencies = [ + "parking_lot 0.10.0", +] + [[package]] name = "opaque-debug" version = "0.2.3" @@ -2722,6 +2882,18 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "pallet-balances" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-runtime", + "sp-std", +] + [[package]] name = "parity-bytes" version = "0.1.0" @@ -2795,9 +2967,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329c8f7f4244ddb5c37c103641027a76c530e65e8e4b8240b29f81ea40508b17" +checksum = "a74f02beb35d47e0706155c9eac554b50c671e0d868fe8296bcdf44a9a4847bf" dependencies = [ "arrayvec 0.5.1", "bitvec", @@ -2835,12 +3007,43 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "parity-util-mem" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6e2583649a3ca84894d1d71da249abcfda54d5aca24733d72ca10d0f02361c" +dependencies = [ + "cfg-if", + "impl-trait-for-tuples", + "parity-util-mem-derive", + "parking_lot 0.10.0", + "primitive-types 0.7.1", + "winapi 0.3.8", +] + +[[package]] +name = "parity-util-mem-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" +dependencies = [ + "proc-macro2 1.0.10", + "syn 1.0.17", + "synstructure", +] + [[package]] name = "parity-wasm" version = "0.40.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" +[[package]] +name = "parity-wasm" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" + [[package]] name = "parking_lot" version = "0.6.4" @@ -2960,7 +3163,7 @@ dependencies = [ "cloudabi", "libc", "redox_syscall", - "smallvec 1.2.0", + "smallvec 1.4.1", "winapi 0.3.8", ] @@ -3082,7 +3285,19 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4336f4f5d5524fa60bcbd6fe626f9223d8142a50e7053e979acdf0da41ab975" dependencies = [ - "fixed-hash", + "fixed-hash 0.5.2", + "impl-codec", + "impl-serde 0.3.0", + "uint", +] + +[[package]] +name = "primitive-types" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dedac218327b6b55fff5ef05f63ce5127024e1a36342836da7e92cbfac4531" +dependencies = [ + "fixed-hash 0.6.1", "impl-codec", "impl-serde 0.3.0", "uint", @@ -3172,7 +3387,7 @@ checksum = "eb788126ea840817128183f8f603dce02cb7aea25c2a0b764359d8e20010702e" dependencies = [ "bytes 0.4.12", "heck", - "itertools", + "itertools 0.8.2", "log", "multimap", "petgraph", @@ -3189,7 +3404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e7dc378b94ac374644181a2247cebf59a6ec1c88b49ac77f3a94b86b79d0e11" dependencies = [ "failure", - "itertools", + "itertools 0.8.2", "proc-macro2 0.4.30", "quote 0.6.13", "syn 0.15.44", @@ -3291,7 +3506,7 @@ dependencies = [ "rand_isaac", "rand_jitter", "rand_os", - "rand_pcg", + "rand_pcg 0.1.2", "rand_xorshift", "winapi 0.3.8", ] @@ -3307,6 +3522,7 @@ dependencies = [ "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc 0.2.0", + "rand_pcg 0.2.1", ] [[package]] @@ -3415,6 +3631,15 @@ dependencies = [ "rand_core 0.4.2", ] +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + [[package]] name = "rand_xorshift" version = "0.1.1" @@ -3463,6 +3688,26 @@ version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +[[package]] +name = "ref-cast" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "745c1787167ddae5569661d5ffb8b25ae5fedbf46717eaa92d652221cec72623" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144" +dependencies = [ + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.17", +] + [[package]] name = "regex" version = "1.3.6" @@ -3490,6 +3735,27 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "rental" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8545debe98b2b139fb04cad8618b530e9b07c152d99a5de83c860b877d67847f" +dependencies = [ + "rental-impl", + "stable_deref_trait", +] + +[[package]] +name = "rental-impl" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" +dependencies = [ + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.17", +] + [[package]] name = "ring" version = "0.16.12" @@ -3531,6 +3797,12 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -3593,7 +3865,7 @@ checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3" dependencies = [ "curve25519-dalek 1.2.3", "failure", - "merlin", + "merlin 1.3.0", "rand 0.6.5", "rand_core 0.4.2", "rand_os", @@ -3602,6 +3874,24 @@ dependencies = [ "zeroize 0.9.3", ] +[[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 2.0.0", + "getrandom", + "merlin 2.0.0", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2", + "subtle 2.2.2", + "zeroize 1.1.0", +] + [[package]] name = "scopeguard" version = "0.3.3" @@ -3801,9 +4091,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" [[package]] name = "snow" @@ -3838,6 +4128,311 @@ dependencies = [ "tokio-io", ] +[[package]] +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", + "sp-api-proc-macro", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-version", +] + +[[package]] +name = "sp-api-proc-macro" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "blake2-rfc", + "proc-macro-crate", + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.17", +] + +[[package]] +name = "sp-application-crypto" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-arithmetic" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +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", + "derive_more 0.99.9", + "ed25519-dalek 1.0.0-pre.3", + "futures 0.3.4", + "hash-db", + "hash256-std-hasher", + "hex 0.4.2", + "impl-serde 0.3.0", + "lazy_static", + "libsecp256k1", + "log", + "merlin 2.0.0", + "num-traits", + "parity-scale-codec", + "parity-util-mem 0.6.1", + "parking_lot 0.10.0", + "primitive-types 0.7.1", + "rand 0.7.3", + "regex", + "schnorrkel 0.9.1", + "serde", + "sha2", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "substrate-bip39 0.4.1", + "tiny-bip39 0.7.3", + "tiny-keccak 2.0.2", + "twox-hash", + "wasmi 0.6.2", + "zeroize 1.1.0", +] + +[[package]] +name = "sp-debug-derive" +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", + "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 = [ + "environmental", + "parity-scale-codec", + "sp-std", + "sp-storage", +] + +[[package]] +name = "sp-inherents" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more 0.99.9", + "parity-scale-codec", + "parking_lot 0.10.0", + "sp-core", + "sp-std", +] + +[[package]] +name = "sp-io" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "futures 0.3.4", + "hash-db", + "libsecp256k1", + "log", + "parity-scale-codec", + "parking_lot 0.10.0", + "sp-core", + "sp-externalities", + "sp-runtime-interface", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "sp-wasm-interface", +] + +[[package]] +name = "sp-panic-handler" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "backtrace", + "log", +] + +[[package]] +name = "sp-runtime" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "parity-util-mem 0.6.1", + "paste", + "rand 0.7.3", + "serde", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-inherents", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-runtime-interface" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "primitive-types 0.7.1", + "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 = [ + "Inflector", + "proc-macro-crate", + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.17", +] + +[[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", + "parity-scale-codec", + "parking_lot 0.10.0", + "rand 0.7.3", + "smallvec 1.4.1", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-trie", + "trie-db 0.21.0", + "trie-root 0.16.0", +] + +[[package]] +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 = [ + "impl-serde 0.2.3", + "ref-cast", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-timestamp" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-api", + "sp-inherents", + "sp-runtime", + "sp-std", + "wasm-timer 0.2.4", +] + +[[package]] +name = "sp-tracing" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "log", + "rental", + "tracing", +] + +[[package]] +name = "sp-trie" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "hash-db", + "memory-db 0.21.0", + "parity-scale-codec", + "sp-core", + "sp-std", + "trie-db 0.21.0", + "trie-root 0.16.0", +] + +[[package]] +name = "sp-version" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "impl-serde 0.2.3", + "parity-scale-codec", + "serde", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-wasm-interface" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-std", + "wasmi 0.6.2", +] + [[package]] name = "spin" version = "0.5.2" @@ -3884,7 +4479,7 @@ dependencies = [ "substrate-primitives", "substrate-state-machine", "substrate-trie", - "tiny-keccak", + "tiny-keccak 1.5.0", ] [[package]] @@ -4457,7 +5052,19 @@ checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" dependencies = [ "hmac", "pbkdf2", - "schnorrkel", + "schnorrkel 0.8.5", + "sha2", +] + +[[package]] +name = "substrate-bip39" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c004e8166d6e0aa3a9d5fa673e5b7098ff25f930de1013a21341988151e681bb" +dependencies = [ + "hmac", + "pbkdf2", + "schnorrkel 0.9.1", "sha2", ] @@ -4600,7 +5207,7 @@ dependencies = [ "futures-preview", "futures-timer", "log", - "merlin", + "merlin 1.3.0", "num-bigint", "num-rational", "num-traits", @@ -4608,7 +5215,7 @@ dependencies = [ "parking_lot 0.9.0", "pdqselect", "rand 0.7.3", - "schnorrkel", + "schnorrkel 0.8.5", "sr-io", "sr-primitives", "sr-version", @@ -4633,7 +5240,7 @@ version = "2.0.0" source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" dependencies = [ "parity-scale-codec", - "schnorrkel", + "schnorrkel 0.8.5", "sr-primitives", "sr-std", "substrate-application-crypto", @@ -4737,7 +5344,7 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", - "parity-wasm", + "parity-wasm 0.40.3", "parking_lot 0.9.0", "sr-io", "sr-version", @@ -4747,8 +5354,8 @@ dependencies = [ "substrate-serializer", "substrate-trie", "substrate-wasm-interface", - "tiny-keccak", - "wasmi", + "tiny-keccak 1.5.0", + "wasmi 0.5.1", ] [[package]] @@ -4757,7 +5364,7 @@ version = "2.0.0" source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" dependencies = [ "environmental", - "primitive-types", + "primitive-types 0.6.2", "sr-std", "substrate-primitives-storage", ] @@ -5074,22 +5681,22 @@ dependencies = [ "num-traits", "parity-scale-codec", "parking_lot 0.9.0", - "primitive-types", + "primitive-types 0.6.2", "rand 0.7.3", "regex", "rustc-hex", - "schnorrkel", + "schnorrkel 0.8.5", "serde", "sha2", "sr-std", - "substrate-bip39", + "substrate-bip39 0.3.1", "substrate-debug-derive", "substrate-externalities", "substrate-primitives-storage", - "tiny-bip39", - "tiny-keccak", + "tiny-bip39 0.6.2", + "tiny-keccak 1.5.0", "twox-hash", - "wasmi", + "wasmi 0.5.1", "zeroize 0.10.1", ] @@ -5399,8 +6006,8 @@ dependencies = [ "substrate-panic-handler", "substrate-primitives", "substrate-trie", - "trie-db", - "trie-root", + "trie-db 0.15.2", + "trie-root 0.15.2", ] [[package]] @@ -5452,20 +6059,16 @@ dependencies = [ name = "substrate-token-mint-module" version = "1.0.1" dependencies = [ - "hex-literal 0.1.4", + "frame-support", + "frame-system", + "pallet-balances", "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-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-timestamp", ] [[package]] @@ -5504,12 +6107,12 @@ version = "2.0.0" source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" dependencies = [ "hash-db", - "memory-db", + "memory-db 0.15.3", "parity-scale-codec", "sr-std", "substrate-primitives", - "trie-db", - "trie-root", + "trie-db 0.15.2", + "trie-root 0.15.2", ] [[package]] @@ -5563,7 +6166,7 @@ name = "substrate-wasm-interface" version = "2.0.0" source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" dependencies = [ - "wasmi", + "wasmi 0.5.1", ] [[package]] @@ -5744,6 +6347,22 @@ dependencies = [ "sha2", ] +[[package]] +name = "tiny-bip39" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" +dependencies = [ + "failure", + "hmac", + "once_cell 1.4.0", + "pbkdf2", + "rand 0.7.3", + "rustc-hash", + "sha2", + "unicode-normalization", +] + [[package]] name = "tiny-keccak" version = "1.5.0" @@ -5753,6 +6372,15 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tokio" version = "0.1.22" @@ -5981,6 +6609,37 @@ dependencies = [ "serde", ] +[[package]] +name = "tracing" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e2a2de6b0d5cbb13fc21193a2296888eaab62b6044479aafb3c54c01c29fcd" +dependencies = [ + "cfg-if", + "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 1.0.10", + "quote 1.0.3", + "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" @@ -6000,6 +6659,19 @@ dependencies = [ "rand 0.6.5", ] +[[package]] +name = "trie-db" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb230c24c741993b04cfccbabb45acff6f6480c5f00d3ed8794ea43db3a9d727" +dependencies = [ + "hash-db", + "hashbrown 0.6.3", + "log", + "rustc-hex", + "smallvec 1.4.1", +] + [[package]] name = "trie-root" version = "0.15.2" @@ -6009,6 +6681,15 @@ dependencies = [ "hash-db", ] +[[package]] +name = "trie-root" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "652931506d2c1244d7217a70b99f56718a7b4161b37f04e7cd868072a99f68cd" +dependencies = [ + "hash-db", +] + [[package]] name = "try-lock" version = "0.2.2" @@ -6043,9 +6724,9 @@ 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", "crunchy", @@ -6077,7 +6758,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]] @@ -6243,6 +6924,18 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7add542ea1ac7fdaa9dc25e031a6af33b7d63376292bd24140c637d00d1c312a" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.60" @@ -6286,6 +6979,22 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasm-timer" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "324c5e65a08699c9c4334ba136597ab22b85dccd4b65dd1e36ccf8f723a95b54" +dependencies = [ + "futures 0.3.4", + "js-sys", + "parking_lot 0.9.0", + "pin-utils", + "send_wrapper", + "wasm-bindgen", + "wasm-bindgen-futures 0.4.10", + "web-sys", +] + [[package]] name = "wasmi" version = "0.5.1" @@ -6296,8 +7005,22 @@ dependencies = [ "memory_units", "num-rational", "num-traits", - "parity-wasm", - "wasmi-validation", + "parity-wasm 0.40.3", + "wasmi-validation 0.2.0", +] + +[[package]] +name = "wasmi" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" +dependencies = [ + "libc", + "memory_units", + "num-rational", + "num-traits", + "parity-wasm 0.41.0", + "wasmi-validation 0.3.0", ] [[package]] @@ -6306,7 +7029,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" dependencies = [ - "parity-wasm", + "parity-wasm 0.40.3", +] + +[[package]] +name = "wasmi-validation" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" +dependencies = [ + "parity-wasm 0.41.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 2db388f05e..5636eae212 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ members = [ "runtime-modules/service-discovery", "runtime-modules/stake", "runtime-modules/storage", - "runtime-modules/token-minting", +# "runtime-modules/token-minting", "runtime-modules/versioned-store", "runtime-modules/versioned-store-permissions", "runtime-modules/working-group", diff --git a/runtime-modules/token-minting/Cargo.toml b/runtime-modules/token-minting/Cargo.toml index ec9d8afb97..e079aa0359 100755 --- a/runtime-modules/token-minting/Cargo.toml +++ b/runtime-modules/token-minting/Cargo.toml @@ -1,50 +1,31 @@ [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'] } +rstd = { 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'} +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'} +timestamp = { package = 'sp-timestamp', 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..e3ee546d6b 100755 --- a/runtime-modules/token-minting/src/lib.rs +++ b/runtime-modules/token-minting/src/lib.rs @@ -10,9 +10,11 @@ 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 +29,7 @@ pub trait Trait: system::Trait { /// The type used as a mint identifier. type MintId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -107,13 +109,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 +127,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 +201,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 +224,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 +245,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 +264,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 +277,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 +289,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 588fad8388..564b1fac69 100644 --- a/runtime-modules/token-minting/src/mock.rs +++ b/runtime-modules/token-minting/src/mock.rs @@ -2,16 +2,15 @@ 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 {} @@ -29,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; @@ -41,35 +41,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; - pub const InitialMembersBalance: u64 = 2000; } 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 { @@ -77,7 +71,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(); From d8bc65997abffe308e416646a9b909aa0e60800e Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 15 Jul 2020 18:17:15 +0300 Subject: [PATCH 02/56] runtime: Upgrade recurring reward module. --- Cargo.lock | 7108 +++-------------- Cargo.toml | 40 +- runtime-modules/recurring-reward/Cargo.toml | 56 +- runtime-modules/recurring-reward/src/lib.rs | 34 +- .../recurring-reward/src/mock/mod.rs | 34 +- runtime-modules/recurring-reward/src/tests.rs | 8 +- 6 files changed, 1007 insertions(+), 6273 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 39efc4c9f1..9b3b11413c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,46 +10,6 @@ dependencies = [ "regex", ] -[[package]] -name = "adler32" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" - -[[package]] -name = "aes-ctr" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" -dependencies = [ - "aes-soft", - "aesni", - "ctr", - "stream-cipher", -] - -[[package]] -name = "aes-soft" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" -dependencies = [ - "block-cipher-trait", - "byteorder 1.3.4", - "opaque-debug", -] - -[[package]] -name = "aesni" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -dependencies = [ - "block-cipher-trait", - "opaque-debug", - "stream-cipher", -] - [[package]] name = "ahash" version = "0.2.18" @@ -68,42 +28,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi 0.3.8", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.8", -] - -[[package]] -name = "app_dirs" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" -dependencies = [ - "ole32-sys", - "shell32-sys", - "winapi 0.2.8", - "xdg", -] - -[[package]] -name = "arc-swap" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d663a8e9a99154b5fb793032533f6328da35e23aac63d5c152279aa8ba356825" - [[package]] name = "arrayref" version = "0.3.6" @@ -125,36 +49,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" -[[package]] -name = "asn1_der" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fce6b6a0ffdafebd82c87e79e3f40e8d2c523e5fea5566ff6b90509bf98d638" -dependencies = [ - "asn1_der_derive", -] - -[[package]] -name = "asn1_der_derive" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" -dependencies = [ - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi 0.3.8", -] - [[package]] name = "autocfg" version = "0.1.7" @@ -195,37 +89,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder 1.3.4", -] - -[[package]] -name = "bindgen" -version = "0.47.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df683a55b54b41d5ea8ebfaebb5aa7e6b84e3f3006a78f010dadc9ca88469260" -dependencies = [ - "bitflags", - "cexpr", - "cfg-if", - "clang-sys", - "clap", - "env_logger 0.6.2", - "hashbrown 0.1.8", - "lazy_static", - "log", - "peeking_take_while", - "proc-macro2 0.4.30", - "quote 0.6.13", - "regex", - "which", -] - [[package]] name = "bitflags" version = "1.2.1" @@ -248,18 +111,6 @@ dependencies = [ "radium", ] -[[package]] -name = "blake2" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" -dependencies = [ - "byte-tools", - "crypto-mac", - "digest", - "opaque-debug", -] - [[package]] name = "blake2-rfc" version = "0.2.18" @@ -278,16 +129,7 @@ checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ "block-padding", "byte-tools", - "byteorder 1.3.4", - "generic-array", -] - -[[package]] -name = "block-cipher-trait" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" -dependencies = [ + "byteorder", "generic-array", ] @@ -300,27 +142,6 @@ dependencies = [ "byte-tools", ] -[[package]] -name = "bs58" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95ee6bba9d950218b6cc910cf62bc9e0a171d0f4537e3627b0f54d08549b188" - -[[package]] -name = "bs58" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" - -[[package]] -name = "bstr" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" -dependencies = [ - "memchr", -] - [[package]] name = "bumpalo" version = "3.2.1" @@ -339,58 +160,17 @@ 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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder 1.3.4", - "either", - "iovec", -] - -[[package]] -name = "bytes" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" - -[[package]] -name = "c_linked_list" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" - [[package]] name = "cc" version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" -dependencies = [ - "jobserver", -] - -[[package]] -name = "cexpr" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" -dependencies = [ - "nom", -] [[package]] name = "cfg-if" @@ -398,56 +178,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -[[package]] -name = "chain-spec-builder" -version = "2.0.0-alpha.3" -dependencies = [ - "ansi_term 0.12.1", - "joystream-node", - "rand 0.7.3", - "structopt", - "substrate-keystore", - "substrate-primitives", - "substrate-telemetry", -] - -[[package]] -name = "chrono" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" -dependencies = [ - "num-integer", - "num-traits", - "time", -] - -[[package]] -name = "clang-sys" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef0c1bcf2e99c649104bd7a7012d8f8802684400e03db0ec0af48583c6fa0e4" -dependencies = [ - "glob", - "libc", - "libloading", -] - -[[package]] -name = "clap" -version = "2.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -dependencies = [ - "ansi_term 0.11.0", - "atty", - "bitflags", - "strsim", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clear_on_drop" version = "0.2.3" @@ -473,7 +203,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]] @@ -483,7 +213,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]] @@ -493,6111 +223,1494 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] -name = "crc32fast" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-channel" -version = "0.3.9" +name = "crunchy" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" -dependencies = [ - "crossbeam-utils 0.6.6", -] +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crypto-mac" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "crossbeam-epoch", - "crossbeam-utils 0.7.2", - "maybe-uninit", + "generic-array", + "subtle 1.0.0", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.2" +name = "curve25519-dalek" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" dependencies = [ - "autocfg 1.0.0", - "cfg-if", - "crossbeam-utils 0.7.2", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard 1.1.0", + "byteorder", + "digest", + "rand_core", + "subtle 2.2.2", + "zeroize", ] [[package]] -name = "crossbeam-queue" -version = "0.2.1" +name = "derive_more" +version = "0.99.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" +checksum = "298998b1cf6b5b2c8a7b023dfd45821825ce3ba8a8af55c921a0e734e4653f76" dependencies = [ - "cfg-if", - "crossbeam-utils 0.7.2", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "crossbeam-utils" -version = "0.6.6" +name = "digest" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "cfg-if", - "lazy_static", + "generic-array", ] [[package]] -name = "crossbeam-utils" -version = "0.7.2" +name = "ed25519-dalek" +version = "1.0.0-pre.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" dependencies = [ - "autocfg 1.0.0", - "cfg-if", - "lazy_static", + "clear_on_drop", + "curve25519-dalek", + "rand", + "sha2", ] [[package]] -name = "crunchy" -version = "0.2.2" +name = "either" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] -name = "crypto-mac" -version = "0.7.0" +name = "environmental" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array", - "subtle 1.0.0", -] +checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" [[package]] -name = "ct-logs" -version = "0.6.0" +name = "failure" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3686f5fa27dbc1d76c751300376e167c5a43387f44bb451fd1c24776e49113" +checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" dependencies = [ - "sct", + "backtrace", + "failure_derive", ] [[package]] -name = "ctr" -version = "0.3.2" +name = "failure_derive" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" +checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" dependencies = [ - "block-cipher-trait", - "stream-cipher", + "proc-macro2", + "quote", + "syn", + "synstructure", ] [[package]] -name = "ctrlc" -version = "3.1.4" +name = "fake-simd" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4ba686dff9fa4c1c9636ce1010b0cf98ceb421361b0bb3d6faeec43bd217a7" -dependencies = [ - "nix", - "winapi 0.3.8", -] +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] -name = "cuckoofilter" -version = "0.3.2" +name = "fixed-hash" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" +checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" dependencies = [ - "byteorder 0.5.3", - "rand 0.3.23", + "byteorder", + "rand", + "rustc-hex", + "static_assertions", ] [[package]] -name = "curve25519-dalek" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" +name = "frame-metadata" +version = "11.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "byteorder 1.3.4", - "clear_on_drop", - "digest", - "rand_core 0.3.1", - "subtle 2.2.2", + "parity-scale-codec", + "serde", + "sp-core", + "sp-std", ] [[package]] -name = "curve25519-dalek" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" +name = "frame-support" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "byteorder 1.3.4", - "digest", - "rand_core 0.5.1", - "subtle 2.2.2", - "zeroize 1.1.0", + "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 = "data-encoding" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c0346158a19b3627234e15596f5e465c360fcdb97d817bcb255e0510f5a788" - -[[package]] -name = "derivative" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eae4d76b7cefedd1b4f8cc24378b2fbd1ac1b66e3bbebe8e2192d3be81cb355" +name = "frame-support-procedural" +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", - "syn 1.0.17", + "frame-support-procedural-tools", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "derive_more" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" +name = "frame-support-procedural-tools" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "rustc_version", - "syn 0.15.44", + "frame-support-procedural-tools-derive", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "derive_more" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" +name = "frame-support-procedural-tools-derive" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "lazy_static", - "proc-macro2 0.4.30", - "quote 0.6.13", - "regex", - "rustc_version", - "syn 0.15.44", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "derive_more" -version = "0.99.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298998b1cf6b5b2c8a7b023dfd45821825ce3ba8a8af55c921a0e734e4653f76" +name = "frame-system" +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", - "syn 1.0.17", + "frame-support", + "impl-trait-for-tuples", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-version", ] [[package]] -name = "difference" -version = "2.0.0" +name = "futures" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" +checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] [[package]] -name = "digest" -version = "0.8.1" +name = "futures-channel" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" dependencies = [ - "generic-array", + "futures-core", + "futures-sink", ] [[package]] -name = "dns-parser" -version = "0.8.0" +name = "futures-core" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" -dependencies = [ - "byteorder 1.3.4", - "quick-error", -] +checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" [[package]] -name = "doc-comment" -version = "0.3.3" +name = "futures-executor" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] [[package]] -name = "downcast" -version = "0.10.0" +name = "futures-io" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" +checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" [[package]] -name = "ed25519-dalek" -version = "0.9.1" +name = "futures-macro" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d07e8b8a8386c3b89a7a4b329fdfa4cb545de2545e9e2ebbc3dd3929253e426" +checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" dependencies = [ - "clear_on_drop", - "curve25519-dalek 1.2.3", - "failure", - "rand 0.6.5", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "ed25519-dalek" -version = "1.0.0-pre.3" +name = "futures-sink" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" -dependencies = [ - "clear_on_drop", - "curve25519-dalek 2.0.0", - "rand 0.7.3", - "sha2", -] +checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6" [[package]] -name = "either" -version = "1.5.3" +name = "futures-task" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" [[package]] -name = "elastic-array" -version = "0.10.3" +name = "futures-util" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" +checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" dependencies = [ - "heapsize", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", ] [[package]] -name = "env_logger" -version = "0.6.2" +name = "generic-array" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "typenum", ] [[package]] -name = "env_logger" -version = "0.7.1" +name = "getrandom" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "cfg-if", + "libc", + "wasi", ] [[package]] -name = "environmental" -version = "1.1.1" +name = "hash-db" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" [[package]] -name = "erased-serde" -version = "0.3.11" +name = "hash256-std-hasher" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88b6d1705e16a4d62e05ea61cc0496c2bd190f4fa8e5c1f11ce747be6bcf3d1" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" dependencies = [ - "serde", + "crunchy", ] [[package]] -name = "exit-future" -version = "0.1.4" +name = "hashbrown" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8013f441e38e31c670e7f34ec8f1d5d3a2bd9d303c1ff83976ca886005e8f48" +checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" dependencies = [ - "futures 0.1.29", - "parking_lot 0.7.1", + "ahash", + "autocfg 0.1.7", ] [[package]] -name = "failure" -version = "0.1.7" +name = "hermit-abi" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" +checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" dependencies = [ - "backtrace", - "failure_derive", + "libc", ] [[package]] -name = "failure_derive" -version = "0.1.7" +name = "hex" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" +checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" + +[[package]] +name = "hmac" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", - "synstructure", + "crypto-mac", + "digest", ] [[package]] -name = "fake-simd" -version = "0.1.2" +name = "hmac-drbg" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" +dependencies = [ + "digest", + "generic-array", + "hmac", +] [[package]] -name = "fdlimit" -version = "0.1.4" +name = "impl-codec" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da54a593b34c71b889ee45f5b5bb900c74148c5f7f8c6a9479ee7899f69603c" +checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" dependencies = [ - "libc", + "parity-scale-codec", ] [[package]] -name = "finality-grandpa" -version = "0.9.1" +name = "impl-serde" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34754852da8d86bc509715292c73140a5b678656d0b16132acd6737bdb5fd5f8" +checksum = "58e3cae7e99c7ff5a995da2cf78dd0a5383740eda71d98cf7b1910c301ac69b8" dependencies = [ - "futures 0.1.29", - "hashbrown 0.6.3", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", + "serde", ] [[package]] -name = "fixed-hash" -version = "0.5.2" +name = "impl-serde" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3367952ceb191f4ab95dd5685dc163ac539e36202f9fcfd0cb22f9f9c542fefc" +checksum = "5bbe9ea9b182f0fb1cabbd61f4ff9b7b7b9197955e95a7e4c27de5055eb29ff8" dependencies = [ - "byteorder 1.3.4", - "libc", - "rand 0.7.3", - "rustc-hex", - "static_assertions", + "serde", ] [[package]] -name = "fixed-hash" -version = "0.6.1" +name = "impl-trait-for-tuples" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" +checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" dependencies = [ - "byteorder 1.3.4", - "rand 0.7.3", - "rustc-hex", - "static_assertions", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "fixedbitset" -version = "0.1.9" +name = "integer-sqrt" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" +checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" [[package]] -name = "flate2" -version = "1.0.14" +name = "itertools" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" dependencies = [ - "cfg-if", - "crc32fast", - "futures 0.1.29", - "libc", - "libz-sys", - "miniz_oxide", - "tokio-io", + "either", ] [[package]] -name = "float-cmp" -version = "0.6.0" +name = "js-sys" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62c4f1b81918835a8c6a484a397775fff5953fe83529afd51b05f5c6a6617d" +checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" dependencies = [ - "num-traits", + "wasm-bindgen", ] [[package]] -name = "fnv" -version = "1.0.6" +name = "keccak" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" [[package]] -name = "fork-tree" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "fragile" -version = "0.3.0" +name = "lazy_static" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[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", -] +name = "libc" +version = "0.2.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" [[package]] -name = "frame-support" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +name = "libsecp256k1" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" dependencies = [ - "bitmask", - "frame-metadata", - "frame-support-procedural", - "impl-trait-for-tuples", - "log", - "once_cell 1.4.0", - "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", + "arrayref", + "crunchy", + "digest", + "hmac-drbg", + "rand", + "sha2", + "subtle 2.2.2", + "typenum", ] [[package]] -name = "frame-support-procedural" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +name = "lock_api" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" dependencies = [ - "frame-support-procedural-tools", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "scopeguard", ] [[package]] -name = "frame-support-procedural-tools" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" dependencies = [ - "frame-support-procedural-tools-derive", - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "cfg-if", ] [[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 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[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", -] +name = "memchr" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] -name = "fs-swap" -version = "0.2.4" +name = "memory-db" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921d332c89b3b61a826de38c61ee5b6e02c56806cade1b0e5d81bd71f57a71bb" +checksum = "fb2999ff7a65d5a1d72172f6d51fa2ea03024b51aee709ba5ff81c3c629a2410" dependencies = [ - "lazy_static", - "libc", - "libloading", - "winapi 0.3.8", + "ahash", + "hash-db", + "hashbrown", + "parity-util-mem", ] [[package]] -name = "fuchsia-cprng" -version = "0.1.1" +name = "memory_units" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" [[package]] -name = "fuchsia-zircon" -version = "0.3.3" +name = "merlin" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" dependencies = [ - "bitflags", - "fuchsia-zircon-sys", + "byteorder", + "keccak", + "rand_core", + "zeroize", ] [[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" +name = "nodrop" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" [[package]] -name = "futures" -version = "0.1.29" +name = "num-bigint" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg 1.0.0", + "num-integer", + "num-traits", +] [[package]] -name = "futures" -version = "0.3.4" +name = "num-integer" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" +checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", + "autocfg 1.0.0", + "num-traits", ] [[package]] -name = "futures-channel" -version = "0.3.4" +name = "num-rational" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" +checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ - "futures-core", - "futures-sink", + "autocfg 1.0.0", + "num-bigint", + "num-integer", + "num-traits", ] [[package]] -name = "futures-channel-preview" -version = "0.3.0-alpha.19" +name = "num-traits" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a" +checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" dependencies = [ - "futures-core-preview", - "futures-sink-preview", + "autocfg 1.0.0", ] [[package]] -name = "futures-core" -version = "0.3.4" +name = "num_cpus" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" +checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" +dependencies = [ + "hermit-abi", + "libc", +] [[package]] -name = "futures-core-preview" -version = "0.3.0-alpha.19" +name = "once_cell" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a" +checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" +dependencies = [ + "parking_lot 0.10.0", +] [[package]] -name = "futures-cpupool" -version = "0.1.8" +name = "opaque-debug" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "pallet-balances" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "futures 0.1.29", - "num_cpus", + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-runtime", + "sp-std", ] [[package]] -name = "futures-executor" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" +name = "pallet-recurring-reward" +version = "3.0.0" dependencies = [ - "futures-core", - "futures-task", - "futures-util", - "num_cpus", + "frame-support", + "frame-system", + "pallet-balances", + "pallet-token-mint", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-timestamp", ] [[package]] -name = "futures-executor-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75236e88bd9fe88e5e8bfcd175b665d0528fe03ca4c5207fabc028c8f9d93e98" +name = "pallet-token-mint" +version = "3.0.0" dependencies = [ - "futures-core-preview", - "futures-util-preview", - "num_cpus", + "frame-support", + "frame-system", + "pallet-balances", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-timestamp", ] [[package]] -name = "futures-io" -version = "0.3.4" +name = "parity-scale-codec" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" +checksum = "a74f02beb35d47e0706155c9eac554b50c671e0d868fe8296bcdf44a9a4847bf" +dependencies = [ + "arrayvec 0.5.1", + "bitvec", + "byte-slice-cast", + "parity-scale-codec-derive", + "serde", +] [[package]] -name = "futures-io-preview" -version = "0.3.0-alpha.19" +name = "parity-scale-codec-derive" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4914ae450db1921a56c91bde97a27846287d062087d4a652efc09bb3a01ebda" +checksum = "5a0ec292e92e8ec7c58e576adacc1e3f399c597c8f263c42f18420abe58e7245" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] [[package]] -name = "futures-macro" -version = "0.3.4" +name = "parity-util-mem" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" +checksum = "2c6e2583649a3ca84894d1d71da249abcfda54d5aca24733d72ca10d0f02361c" dependencies = [ - "proc-macro-hack 0.5.15", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "cfg-if", + "impl-trait-for-tuples", + "parity-util-mem-derive", + "parking_lot 0.10.0", + "primitive-types", + "winapi", ] [[package]] -name = "futures-preview" -version = "0.3.0-alpha.19" +name = "parity-util-mem-derive" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1dce2a0267ada5c6ff75a8ba864b4e679a9e2aa44262af7a3b5516d530d76e" +checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ - "futures-channel-preview", - "futures-core-preview", - "futures-executor-preview", - "futures-io-preview", - "futures-sink-preview", - "futures-util-preview", + "proc-macro2", + "syn", + "synstructure", ] [[package]] -name = "futures-sink" -version = "0.3.4" +name = "parity-wasm" +version = "0.41.0" 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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" +checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" [[package]] -name = "futures-timer" -version = "0.4.0" +name = "parking_lot" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878f1d2fc31355fa02ed2372e741b0c17e58373341e6a122569b4623a14a7d33" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" dependencies = [ - "futures-core-preview", - "futures-util-preview", - "pin-utils", + "lock_api", + "parking_lot_core 0.6.2", + "rustc_version", ] [[package]] -name = "futures-util" -version = "0.3.4" +name = "parking_lot" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" +checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-utils", - "proc-macro-hack 0.5.15", - "proc-macro-nested", - "slab", + "lock_api", + "parking_lot_core 0.7.0", ] [[package]] -name = "futures-util-preview" -version = "0.3.0-alpha.19" +name = "parking_lot_core" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" dependencies = [ - "futures 0.1.29", - "futures-channel-preview", - "futures-core-preview", - "futures-io-preview", - "futures-sink-preview", - "memchr", - "pin-utils", - "slab", + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "rustc_version", + "smallvec 0.6.13", + "winapi", ] [[package]] -name = "gcc" -version = "0.3.55" +name = "parking_lot_core" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "smallvec 1.4.1", + "winapi", +] [[package]] -name = "generic-array" -version = "0.12.3" +name = "paste" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "ab4fb1930692d1b6a9cfabdde3d06ea0a7d186518e2f4d67660d8970e2fa647a" dependencies = [ - "typenum", + "paste-impl", + "proc-macro-hack", ] [[package]] -name = "get_if_addrs" -version = "0.5.3" +name = "paste-impl" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" +checksum = "a62486e111e571b1e93b710b61e8f493c0013be39629b714cb166bdb06aa5a8a" dependencies = [ - "c_linked_list", - "get_if_addrs-sys", - "libc", - "winapi 0.2.8", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "get_if_addrs-sys" -version = "0.1.1" +name = "pbkdf2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" +checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" dependencies = [ - "gcc", - "libc", + "byteorder", + "crypto-mac", ] [[package]] -name = "getrandom" -version = "0.1.14" +name = "pin-utils" +version = "0.1.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] +checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" [[package]] -name = "glob" -version = "0.2.11" +name = "ppv-lite86" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" [[package]] -name = "globset" -version = "0.4.5" +name = "primitive-types" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" +checksum = "d3dedac218327b6b55fff5ef05f63ce5127024e1a36342836da7e92cbfac4531" dependencies = [ - "aho-corasick", - "bstr", - "fnv", - "log", - "regex", + "fixed-hash", + "impl-codec", + "impl-serde 0.3.0", + "uint", ] [[package]] -name = "h2" -version = "0.1.26" +name = "proc-macro-crate" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" +checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" dependencies = [ - "byteorder 1.3.4", - "bytes 0.4.12", - "fnv", - "futures 0.1.29", - "http", - "indexmap", - "log", - "slab", - "string", - "tokio-io", + "toml", ] [[package]] -name = "hash-db" -version = "0.15.2" +name = "proc-macro-hack" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" +checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" [[package]] -name = "hash256-std-hasher" -version = "0.15.2" +name = "proc-macro-nested" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" + +[[package]] +name = "proc-macro2" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ - "crunchy", + "unicode-xid", ] [[package]] -name = "hashbrown" -version = "0.1.8" +name = "quote" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" +checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ - "byteorder 1.3.4", - "scopeguard 0.3.3", + "proc-macro2", ] [[package]] -name = "hashbrown" -version = "0.6.3" +name = "radium" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "ahash", - "autocfg 0.1.7", + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", + "rand_pcg", ] [[package]] -name = "heapsize" -version = "0.4.2" +name = "rand_chacha" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ - "winapi 0.3.8", + "ppv-lite86", + "rand_core", ] [[package]] -name = "heck" -version = "0.3.1" +name = "rand_core" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "unicode-segmentation", + "getrandom", ] [[package]] -name = "hermit-abi" -version = "0.1.10" +name = "rand_hc" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "libc", + "rand_core", ] [[package]] -name = "hex" -version = "0.3.2" +name = "rand_pcg" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core", +] [[package]] -name = "hex" -version = "0.4.2" +name = "redox_syscall" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" [[package]] -name = "hex-literal" -version = "0.1.4" +name = "ref-cast" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc2928beef125e519d69ae1baa8c37ea2e0d3848545217f6db0179c5eb1d639" +checksum = "745c1787167ddae5569661d5ffb8b25ae5fedbf46717eaa92d652221cec72623" dependencies = [ - "hex-literal-impl 0.1.2", - "proc-macro-hack 0.4.2", + "ref-cast-impl", ] [[package]] -name = "hex-literal" -version = "0.2.1" +name = "ref-cast-impl" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" +checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144" dependencies = [ - "hex-literal-impl 0.2.1", - "proc-macro-hack 0.5.15", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "hex-literal-impl" -version = "0.1.2" +name = "regex" +version = "1.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520870c3213943eb8d7803e80180d12a6c7ceb4ae74602544529d1643dc4ddda" +checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" dependencies = [ - "proc-macro-hack 0.4.2", + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", ] [[package]] -name = "hex-literal-impl" -version = "0.2.1" +name = "regex-syntax" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" -dependencies = [ - "proc-macro-hack 0.5.15", -] +checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" [[package]] -name = "hmac" -version = "0.7.1" +name = "rental" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +checksum = "8545debe98b2b139fb04cad8618b530e9b07c152d99a5de83c860b877d67847f" dependencies = [ - "crypto-mac", - "digest", + "rental-impl", + "stable_deref_trait", ] [[package]] -name = "hmac-drbg" -version = "0.2.0" +name = "rental-impl" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" +checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" dependencies = [ - "digest", - "generic-array", - "hmac", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "http" -version = "0.1.21" +name = "rustc-demangle" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" -dependencies = [ - "bytes 0.4.12", - "fnv", - "itoa", -] +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" [[package]] -name = "http-body" -version = "0.1.0" +name = "rustc-hash" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "http", - "tokio-buf", -] +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] -name = "httparse" -version = "1.3.4" +name = "rustc-hex" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] -name = "humantime" -version = "1.3.0" +name = "rustc_version" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "quick-error", + "semver", ] [[package]] -name = "hyper" -version = "0.12.35" +name = "schnorrkel" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "futures-cpupool", - "h2", - "http", - "http-body", - "httparse", - "iovec", - "itoa", - "log", - "net2", - "rustc_version", - "time", - "tokio", - "tokio-buf", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "want", + "arrayref", + "arrayvec 0.5.1", + "curve25519-dalek", + "getrandom", + "merlin", + "rand", + "rand_core", + "sha2", + "subtle 2.2.2", + "zeroize", ] [[package]] -name = "hyper-rustls" -version = "0.17.1" +name = "scopeguard" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719d85c7df4a7f309a77d145340a063ea929dcb2e025bae46a80345cffec2952" -dependencies = [ - "bytes 0.4.12", - "ct-logs", - "futures 0.1.29", - "hyper", - "rustls", - "tokio-io", - "tokio-rustls", - "webpki", - "webpki-roots 0.17.0", -] +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] -name = "idna" -version = "0.1.5" +name = "semver" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", + "semver-parser", ] [[package]] -name = "idna" -version = "0.2.0" +name = "semver-parser" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "impl-codec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" -dependencies = [ - "parity-scale-codec", -] +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] -name = "impl-serde" -version = "0.2.3" +name = "send_wrapper" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e3cae7e99c7ff5a995da2cf78dd0a5383740eda71d98cf7b1910c301ac69b8" -dependencies = [ - "serde", -] +checksum = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" [[package]] -name = "impl-serde" -version = "0.3.0" +name = "serde" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bbe9ea9b182f0fb1cabbd61f4ff9b7b7b9197955e95a7e4c27de5055eb29ff8" +checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" dependencies = [ - "serde", + "serde_derive", ] [[package]] -name = "impl-trait-for-tuples" -version = "0.1.3" +name = "serde_derive" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" +checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "indexmap" -version = "1.3.2" +name = "sha2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" dependencies = [ - "autocfg 1.0.0", + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", ] [[package]] -name = "integer-sqrt" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" - -[[package]] -name = "interleaved-ordered" -version = "0.1.1" +name = "slab" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] -name = "iovec" -version = "0.1.4" +name = "smallvec" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" dependencies = [ - "libc", + "maybe-uninit", ] [[package]] -name = "ipnet" -version = "2.3.0" +name = "smallvec" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" +checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" [[package]] -name = "itertools" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +name = "sp-api" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "either", + "hash-db", + "parity-scale-codec", + "sp-api-proc-macro", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-version", ] [[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +name = "sp-api-proc-macro" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "either", + "blake2-rfc", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "itoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +name = "sp-application-crypto" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-std", +] [[package]] -name = "jobserver" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +name = "sp-arithmetic" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "libc", + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "serde", + "sp-debug-derive", + "sp-std", ] [[package]] -name = "joystream-node" -version = "2.6.0" +name = "sp-core" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "ctrlc", - "derive_more 0.14.1", - "exit-future", - "futures 0.1.29", - "hex 0.4.2", - "hex-literal 0.2.1", - "joystream-node-runtime", - "jsonrpc-core 13.2.0", - "libp2p", + "base58", + "blake2-rfc", + "byteorder", + "derive_more", + "ed25519-dalek", + "futures", + "hash-db", + "hash256-std-hasher", + "hex", + "impl-serde 0.3.0", + "lazy_static", + "libsecp256k1", "log", + "merlin", + "num-traits", "parity-scale-codec", - "parking_lot 0.9.0", - "rand 0.7.3", + "parity-util-mem", + "parking_lot 0.10.0", + "primitive-types", + "rand", + "regex", + "schnorrkel", "serde", - "serde_json", - "sr-io", - "sr-primitives", - "srml-im-online", - "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", -] - -[[package]] -name = "joystream-node-runtime" -version = "6.20.0" + "sha2", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "substrate-bip39", + "tiny-bip39", + "tiny-keccak", + "twox-hash", + "wasmi", + "zeroize", +] + +[[package]] +name = "sp-debug-derive" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-externalities" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "environmental", "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", - "substrate-wasm-builder-runner", - "substrate-working-group-module", + "sp-std", + "sp-storage", ] [[package]] -name = "js-sys" -version = "0.3.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" +name = "sp-inherents" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "wasm-bindgen", + "derive_more", + "parity-scale-codec", + "parking_lot 0.10.0", + "sp-core", + "sp-std", ] [[package]] -name = "jsonrpc-client-transports" -version = "14.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a9ae166c4d1f702d297cd76d4b55758ace80272ffc6dbb139fdc1bf810de40b" +name = "sp-io" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "failure", - "futures 0.1.29", - "jsonrpc-core 14.0.5", - "jsonrpc-pubsub", + "futures", + "hash-db", + "libsecp256k1", "log", - "serde", - "serde_json", - "url 1.7.2", + "parity-scale-codec", + "parking_lot 0.10.0", + "sp-core", + "sp-externalities", + "sp-runtime-interface", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "sp-wasm-interface", ] [[package]] -name = "jsonrpc-core" -version = "13.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d767c183a7e58618a609499d359ce3820700b3ebb4823a18c343b4a2a41a0d" +name = "sp-panic-handler" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "futures 0.1.29", + "backtrace", "log", - "serde", - "serde_derive", - "serde_json", ] [[package]] -name = "jsonrpc-core" -version = "14.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe3b688648f1ef5d5072229e2d672ecb92cbff7d1c79bcf3fd5898f3f3df0970" +name = "sp-runtime" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "futures 0.1.29", + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", "log", + "parity-scale-codec", + "parity-util-mem", + "paste", + "rand", "serde", - "serde_derive", - "serde_json", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-inherents", + "sp-io", + "sp-std", ] [[package]] -name = "jsonrpc-core-client" -version = "14.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080dc110be17701097df238fad3c816d4a478a1899dfbcf8ec8957dd40ec7304" +name = "sp-runtime-interface" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "jsonrpc-client-transports", + "parity-scale-codec", + "primitive-types", + "sp-externalities", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-tracing", + "sp-wasm-interface", + "static_assertions", ] [[package]] -name = "jsonrpc-derive" -version = "14.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8609af8f63b626e8e211f52441fcdb6ec54f1a446606b10d5c89ae9bf8a20058" +name = "sp-runtime-interface-proc-macro" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "Inflector", "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "jsonrpc-http-server" -version = "14.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816d63997ea45d3634608edbef83ddb35e661f7c0b27b5b72f237e321f0e9807" +name = "sp-state-machine" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hyper", - "jsonrpc-core 14.0.5", - "jsonrpc-server-utils", + "hash-db", + "itertools", "log", - "net2", + "num-traits", + "parity-scale-codec", "parking_lot 0.10.0", - "unicase", + "rand", + "smallvec 1.4.1", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-trie", + "trie-db", + "trie-root", ] [[package]] -name = "jsonrpc-pubsub" -version = "14.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b31c9b90731276fdd24d896f31bb10aecf2e5151733364ae81123186643d939" +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 = [ - "jsonrpc-core 14.0.5", - "log", - "parking_lot 0.10.0", + "impl-serde 0.2.3", + "ref-cast", "serde", + "sp-debug-derive", + "sp-std", ] [[package]] -name = "jsonrpc-server-utils" -version = "14.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b7635e618a0edbbe0d2a2bbbc69874277c49383fcf6c3c0414491cfb517d22" +name = "sp-timestamp" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "bytes 0.4.12", - "globset", - "jsonrpc-core 14.0.5", - "lazy_static", - "log", - "tokio", - "tokio-codec", - "unicase", + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-api", + "sp-inherents", + "sp-runtime", + "sp-std", + "wasm-timer", ] [[package]] -name = "jsonrpc-ws-server" -version = "14.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94e5773b2ae66e0e02c80775ce6bbba6f15d5bb47c14ec36a36fcf94f8df851" -dependencies = [ - "jsonrpc-core 14.0.5", - "jsonrpc-server-utils", - "log", - "parking_lot 0.10.0", - "slab", - "ws", -] - -[[package]] -name = "keccak" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "kvdb" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" -dependencies = [ - "elastic-array", - "parity-bytes", -] - -[[package]] -name = "kvdb-memorydb" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" -dependencies = [ - "kvdb", - "parking_lot 0.6.4", -] - -[[package]] -name = "kvdb-rocksdb" -version = "0.1.4" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" -dependencies = [ - "elastic-array", - "fs-swap", - "interleaved-ordered", - "kvdb", - "log", - "num_cpus", - "parking_lot 0.6.4", - "regex", - "rocksdb", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" - -[[package]] -name = "libc" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" - -[[package]] -name = "libloading" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -dependencies = [ - "cc", - "winapi 0.3.8", -] - -[[package]] -name = "libp2p" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b4674c6738fdd8b1cf7104dd046abcef78dc932fe25f8eb40f3a8e71341717d" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "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", - "wasm-timer 0.1.3", -] - -[[package]] -name = "libp2p-core" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01efc769c392d0d8863a7160d266f9b9f794968554f87490c8af4aa34ccaa94f" -dependencies = [ - "asn1_der", - "bs58 0.3.0", - "bytes 0.4.12", - "ed25519-dalek 1.0.0-pre.3", - "failure", - "fnv", - "futures 0.1.29", - "lazy_static", - "libsecp256k1", - "log", - "multistream-select", - "parity-multiaddr 0.6.0", - "parity-multihash 0.2.3", - "parking_lot 0.9.0", - "protobuf", - "quick-error", - "rand 0.7.3", - "ring", - "rw-stream-sink", - "sha2", - "smallvec 0.6.13", - "tokio-executor", - "tokio-io", - "unsigned-varint 0.2.3", - "untrusted", - "void", - "wasm-timer 0.1.3", - "zeroize 1.1.0", -] - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b0bf5d37692ac90e2bffa436bec26c0b0def6c0cab7ea85ff67a353d58aaa" -dependencies = [ - "flate2", - "futures 0.1.29", - "libp2p-core", - "tokio-io", -] - -[[package]] -name = "libp2p-dns" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3175fb0fc9016c95c8517a297bbdb5fb6bfbd5665bacd2eb23495d1cbdeb033" -dependencies = [ - "futures 0.1.29", - "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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c087bcd044a6f67a994573a92a109487a902a31555e4e63bcc4ae144c45594fe" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "libp2p-core", - "libp2p-swarm", - "log", - "parity-multiaddr 0.6.0", - "protobuf", - "smallvec 0.6.13", - "tokio-codec", - "tokio-io", - "unsigned-varint 0.2.3", - "wasm-timer 0.1.3", -] - -[[package]] -name = "libp2p-kad" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcaf76a5b33b6c0203e85d450ae1855cae6860dc82eb0174ac1fee8bf68f7af5" -dependencies = [ - "arrayvec 0.5.1", - "bytes 0.4.12", - "either", - "fnv", - "futures 0.1.29", - "libp2p-core", - "libp2p-swarm", - "log", - "parity-multiaddr 0.6.0", - "parity-multihash 0.2.3", - "protobuf", - "rand 0.7.3", - "sha2", - "smallvec 0.6.13", - "tokio-codec", - "tokio-io", - "uint", - "unsigned-varint 0.2.3", - "void", - "wasm-timer 0.1.3", -] - -[[package]] -name = "libp2p-mdns" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4c2e225a7dfc571c3ad77a0a5ecccc9537afe42d72289ac9f19768567cd677d" -dependencies = [ - "data-encoding", - "dns-parser", - "futures 0.1.29", - "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", - "void", - "wasm-timer 0.1.3", -] - -[[package]] -name = "libp2p-mplex" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2fe584816d993dc0f893396521a3c93191d78a6f28a892b150baa714a12c3e5" -dependencies = [ - "bytes 0.4.12", - "fnv", - "futures 0.1.29", - "libp2p-core", - "log", - "parking_lot 0.8.0", - "tokio-codec", - "tokio-io", - "unsigned-varint 0.2.3", -] - -[[package]] -name = "libp2p-noise" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50494fcba7cdab08390d72b3cb9d2c72fcf178e6a0c1043855ab259d818b972" -dependencies = [ - "bytes 0.4.12", - "curve25519-dalek 1.2.3", - "futures 0.1.29", - "lazy_static", - "libp2p-core", - "log", - "protobuf", - "rand 0.7.3", - "ring", - "snow", - "tokio-io", - "x25519-dalek", - "zeroize 1.1.0", -] - -[[package]] -name = "libp2p-ping" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b975ad345eb9bb29ddc64670664a50a8ab3e66e28357abb0f83cfc0a9ca2d78" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "libp2p-core", - "libp2p-swarm", - "log", - "parity-multiaddr 0.6.0", - "rand 0.7.3", - "tokio-io", - "void", - "wasm-timer 0.1.3", -] - -[[package]] -name = "libp2p-plaintext" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f07be6983e1c00e8f6a5676da54ed3a8cae7fb50f1fb6ea163414613ca656cc" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "libp2p-core", - "log", - "protobuf", - "rw-stream-sink", - "tokio-io", - "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 0.3.27", - "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 0.1.3", -] - -[[package]] -name = "libp2p-tcp" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234a7093d05651ab5630db926a4a42ca8978a65bab8c27c2ce2b66b200c76989" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "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", -] - -[[package]] -name = "libp2p-wasm-ext" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7b8f2bd81fb356e81352d4513856bc21215ecf91502aa1f55b6449642a9acf" -dependencies = [ - "futures 0.1.29", - "js-sys", - "libp2p-core", - "parity-send-wrapper", - "tokio-io", - "wasm-bindgen", - "wasm-bindgen-futures 0.3.27", -] - -[[package]] -name = "libp2p-websocket" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d74d4fc229ad7e8d1a973178786bdcd5dadbdd7b9822c4477c8687df6f82f66" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "libp2p-core", - "log", - "rw-stream-sink", - "soketto", - "tokio-codec", - "tokio-io", - "tokio-rustls", - "url 2.1.1", - "webpki-roots 0.18.0", -] - -[[package]] -name = "libp2p-yamux" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1913eb7dd6eb5515957b6f1770296f6921968db87bc9b985f0e974b6657e1003" -dependencies = [ - "futures 0.1.29", - "libp2p-core", - "log", - "tokio-io", - "yamux", -] - -[[package]] -name = "librocksdb-sys" -version = "5.18.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19778314deaa7048f2ea7d07b8aa12e1c227acebe975a37eeab6d2f8c74e41b" -dependencies = [ - "bindgen", - "cc", - "glob", - "libc", -] - -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" -dependencies = [ - "arrayref", - "crunchy", - "digest", - "hmac-drbg", - "rand 0.7.3", - "sha2", - "subtle 2.2.2", - "typenum", -] - -[[package]] -name = "libz-sys" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" - -[[package]] -name = "linked_hash_set" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7c91c4c7bbeb4f2f7c4e5be11e6a05bd6830bc37249c47ce1ad86ad453ff9c" -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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" -dependencies = [ - "scopeguard 1.1.0", -] - -[[package]] -name = "lock_api" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" -dependencies = [ - "scopeguard 1.1.0", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" -dependencies = [ - "proc-macro2 1.0.10", - "syn 1.0.17", - "synstructure", -] - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" - -[[package]] -name = "memoffset" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" -dependencies = [ - "autocfg 1.0.0", -] - -[[package]] -name = "memory-db" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dabfe0a8c69954ae3bcfc5fc14260a85fb80e1bf9f86a155f668d10a67e93dd" -dependencies = [ - "ahash", - "hash-db", - "hashbrown 0.6.3", - "parity-util-mem 0.2.1", -] - -[[package]] -name = "memory-db" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2999ff7a65d5a1d72172f6d51fa2ea03024b51aee709ba5ff81c3c629a2410" -dependencies = [ - "ahash", - "hash-db", - "hashbrown 0.6.3", - "parity-util-mem 0.6.1", -] - -[[package]] -name = "memory_units" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" - -[[package]] -name = "merlin" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" -dependencies = [ - "byteorder 1.3.4", - "keccak", - "rand_core 0.4.2", - "zeroize 1.1.0", -] - -[[package]] -name = "merlin" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" -dependencies = [ - "byteorder 1.3.4", - "keccak", - "rand_core 0.5.1", - "zeroize 1.1.0", -] - -[[package]] -name = "miniz_oxide" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" -dependencies = [ - "adler32", -] - -[[package]] -name = "mio" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" -dependencies = [ - "cfg-if", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-extras" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" -dependencies = [ - "lazycell", - "log", - "mio", - "slab", -] - -[[package]] -name = "mio-uds" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" -dependencies = [ - "iovec", - "libc", - "mio", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "mockall" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b95a7e7cfbce0e99ebbf5356a085d3b5e320a7ef300f77cd50a7148aa362e7c2" -dependencies = [ - "cfg-if", - "downcast", - "fragile", - "lazy_static", - "mockall_derive", - "predicates", - "predicates-tree", -] - -[[package]] -name = "mockall_derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5a615a1ad92048ad5d9633251edb7492b8abc057d7a679a9898476aef173935" -dependencies = [ - "cfg-if", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "multimap" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04b9f127583ed176e163fb9ec6f3e793b87e21deedd5734a69386a18a0151" - -[[package]] -name = "multistream-select" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc3ef54aab1b2e37e911bcb99e376dbe4c1e0710afcdb8428608e4f993b39c47" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", - "smallvec 0.6.13", - "tokio-io", - "unsigned-varint 0.2.3", -] - -[[package]] -name = "names" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" -dependencies = [ - "rand 0.3.23", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -dependencies = [ - "cfg-if", - "libc", - "winapi 0.3.8", -] - -[[package]] -name = "nix" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" -dependencies = [ - "bitflags", - "cc", - "cfg-if", - "libc", - "void", -] - -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "nohash-hasher" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721a2bf1c26159ebf17e0a980bc4ce61f4b2fec5ec3b42d42fddd7a84a9e538f" - -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -dependencies = [ - "memchr", - "version_check 0.1.5", -] - -[[package]] -name = "normalize-line-endings" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg 1.0.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" -dependencies = [ - "autocfg 1.0.0", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg 1.0.0", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -dependencies = [ - "autocfg 1.0.0", -] - -[[package]] -name = "num_cpus" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" -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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "once_cell" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" -dependencies = [ - "parking_lot 0.7.1", -] - -[[package]] -name = "once_cell" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" - -[[package]] -name = "once_cell" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" -dependencies = [ - "parking_lot 0.10.0", -] - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "owning_ref" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] - -[[package]] -name = "pallet-balances" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "sp-runtime", - "sp-std", -] - -[[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" -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", - "serde", - "unsigned-varint 0.2.3", - "url 1.7.2", -] - -[[package]] -name = "parity-multiaddr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82afcb7461eae5d122543d8be1c57d306ed89af2d6ff7f8b0f5a3cc8f7e511bc" -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", -] - -[[package]] -name = "parity-multihash" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3" -dependencies = [ - "blake2", - "bytes 0.4.12", - "rand 0.6.5", - "sha-1", - "sha2", - "sha3", - "unsigned-varint 0.2.3", -] - -[[package]] -name = "parity-multihash" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a1cd2ba02391b81367bec529fb209019d718684fdc8ad6a712c2b536e46f775" -dependencies = [ - "blake2", - "bytes 0.5.4", - "rand 0.7.3", - "sha-1", - "sha2", - "sha3", - "unsigned-varint 0.3.2", -] - -[[package]] -name = "parity-scale-codec" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74f02beb35d47e0706155c9eac554b50c671e0d868fe8296bcdf44a9a4847bf" -dependencies = [ - "arrayvec 0.5.1", - "bitvec", - "byte-slice-cast", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0ec292e92e8ec7c58e576adacc1e3f399c597c8f263c42f18420abe58e7245" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - -[[package]] -name = "parity-util-mem" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" -dependencies = [ - "cfg-if", - "malloc_size_of_derive", - "winapi 0.3.8", -] - -[[package]] -name = "parity-util-mem" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6e2583649a3ca84894d1d71da249abcfda54d5aca24733d72ca10d0f02361c" -dependencies = [ - "cfg-if", - "impl-trait-for-tuples", - "parity-util-mem-derive", - "parking_lot 0.10.0", - "primitive-types 0.7.1", - "winapi 0.3.8", -] - -[[package]] -name = "parity-util-mem-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" -dependencies = [ - "proc-macro2 1.0.10", - "syn 1.0.17", - "synstructure", -] - -[[package]] -name = "parity-wasm" -version = "0.40.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" - -[[package]] -name = "parity-wasm" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" - -[[package]] -name = "parking_lot" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.3.1", -] - -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.4.0", -] - -[[package]] -name = "parking_lot" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" -dependencies = [ - "lock_api 0.2.0", - "parking_lot_core 0.5.0", - "rustc_version", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.3", - "parking_lot_core 0.6.2", - "rustc_version", -] - -[[package]] -name = "parking_lot" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" -dependencies = [ - "lock_api 0.3.3", - "parking_lot_core 0.7.0", -] - -[[package]] -name = "parking_lot_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" -dependencies = [ - "libc", - "rand 0.5.6", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -dependencies = [ - "libc", - "rand 0.6.5", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "rand 0.6.5", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "smallvec 1.4.1", - "winapi 0.3.8", -] - -[[package]] -name = "paste" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4fb1930692d1b6a9cfabdde3d06ea0a7d186518e2f4d67660d8970e2fa647a" -dependencies = [ - "paste-impl", - "proc-macro-hack 0.5.15", -] - -[[package]] -name = "paste-impl" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62486e111e571b1e93b710b61e8f493c0013be39629b714cb166bdb06aa5a8a" -dependencies = [ - "proc-macro-hack 0.5.15", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "pbkdf2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" -dependencies = [ - "byteorder 1.3.4", - "crypto-mac", -] - -[[package]] -name = "pdqselect" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec91767ecc0a0bbe558ce8c9da33c068066c57ecc8bb8477ef8c1ad3ef77c27" - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "petgraph" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" -dependencies = [ - "fixedbitset", -] - -[[package]] -name = "pin-utils" -version = "0.1.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" - -[[package]] -name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" - -[[package]] -name = "predicates" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030" -dependencies = [ - "difference", - "float-cmp", - "normalize-line-endings", - "predicates-core", - "regex", -] - -[[package]] -name = "predicates-core" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" - -[[package]] -name = "predicates-tree" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" -dependencies = [ - "predicates-core", - "treeline", -] - -[[package]] -name = "primitive-types" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4336f4f5d5524fa60bcbd6fe626f9223d8142a50e7053e979acdf0da41ab975" -dependencies = [ - "fixed-hash 0.5.2", - "impl-codec", - "impl-serde 0.3.0", - "uint", -] - -[[package]] -name = "primitive-types" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dedac218327b6b55fff5ef05f63ce5127024e1a36342836da7e92cbfac4531" -dependencies = [ - "fixed-hash 0.6.1", - "impl-codec", - "impl-serde 0.3.0", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" -dependencies = [ - "toml", -] - -[[package]] -name = "proc-macro-error" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "proc-macro-hack" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463bf29e7f11344e58c9e01f171470ab15c925c6822ad75028cc1c0e1d1eb63b" -dependencies = [ - "proc-macro-hack-impl", -] - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" -dependencies = [ - "unicode-xid 0.2.0", -] - -[[package]] -name = "prost" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d14b1c185652833d24aaad41c5832b0be5616a590227c1fbff57c616754b23" -dependencies = [ - "byteorder 1.3.4", - "bytes 0.4.12", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb788126ea840817128183f8f603dce02cb7aea25c2a0b764359d8e20010702e" -dependencies = [ - "bytes 0.4.12", - "heck", - "itertools 0.8.2", - "log", - "multimap", - "petgraph", - "prost", - "prost-types", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e7dc378b94ac374644181a2247cebf59a6ec1c88b49ac77f3a94b86b79d0e11" -dependencies = [ - "failure", - "itertools 0.8.2", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "prost-types" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de482a366941c8d56d19b650fac09ca08508f2a696119ee7513ad590c8bac6f" -dependencies = [ - "bytes 0.4.12", - "prost", -] - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" -dependencies = [ - "proc-macro2 1.0.10", -] - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -dependencies = [ - "libc", - "rand 0.4.6", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi 0.3.8", -] - -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.8", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg 0.1.2", - "rand_xorshift", - "winapi 0.3.8", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", - "rand_pcg 0.2.1", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.8", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.8", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rayon" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" -dependencies = [ - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.7.0" -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", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "ref-cast" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745c1787167ddae5569661d5ffb8b25ae5fedbf46717eaa92d652221cec72623" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "regex" -version = "1.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local 1.0.1", -] - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -dependencies = [ - "winapi 0.3.8", -] - -[[package]] -name = "rental" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8545debe98b2b139fb04cad8618b530e9b07c152d99a5de83c860b877d67847f" -dependencies = [ - "rental-impl", - "stable_deref_trait", -] - -[[package]] -name = "rental-impl" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "ring" -version = "0.16.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" -dependencies = [ - "cc", - "lazy_static", - "libc", - "spin", - "untrusted", - "web-sys", - "winapi 0.3.8", -] - -[[package]] -name = "rocksdb" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1651697fefd273bfb4fd69466cc2a9d20de557a0213b97233b22b5e95924b5e" -dependencies = [ - "libc", - "librocksdb-sys", -] - -[[package]] -name = "rpassword" -version = "4.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99371657d3c8e4d816fb6221db98fa408242b0b53bac08f8676a41f8554fe99f" -dependencies = [ - "libc", - "winapi 0.3.8", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "rustls" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" -dependencies = [ - "base64", - "log", - "ring", - "sct", - "webpki", -] - -[[package]] -name = "rw-stream-sink" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "tokio-io", -] - -[[package]] -name = "ryu" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" - -[[package]] -name = "safe-mix" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" -dependencies = [ - "rustc_version", -] - -[[package]] -name = "schnorrkel" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3" -dependencies = [ - "curve25519-dalek 1.2.3", - "failure", - "merlin 1.3.0", - "rand 0.6.5", - "rand_core 0.4.2", - "rand_os", - "sha2", - "subtle 2.2.2", - "zeroize 0.9.3", -] - -[[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 2.0.0", - "getrandom", - "merlin 2.0.0", - "rand 0.7.3", - "rand_core 0.5.1", - "sha2", - "subtle 2.2.2", - "zeroize 1.1.0", -] - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" - -[[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 = "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 = "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 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "serde_json" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -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 = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "sha3" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" -dependencies = [ - "block-buffer", - "byte-tools", - "digest", - "keccak", - "opaque-debug", -] - -[[package]] -name = "shell32-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -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 = [ - "erased-serde", -] - -[[package]] -name = "slog-async" -version = "2.3.0" -source = "git+https://github.com/paritytech/slog-async#0329dc74feb3afe93d0cd2533a472b7ceab44aaf" -dependencies = [ - "crossbeam-channel", - "slog", - "take_mut", - "thread_local 0.3.6", -] - -[[package]] -name = "slog-json" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" -dependencies = [ - "chrono", - "erased-serde", - "serde", - "serde_json", - "slog", -] - -[[package]] -name = "slog-scope" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c44c89dd8b0ae4537d1ae318353eaf7840b4869c536e31c41e963d1ea523ee6" -dependencies = [ - "arc-swap", - "lazy_static", - "slog", -] - -[[package]] -name = "slog_derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eff3b513cf2e0d1a60e1aba152dc72bedc5b05585722bb3cebd7bcb1e31b98f" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "smallvec" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" - -[[package]] -name = "snow" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb767eee7d257ba202f0b9b08673bc13b22281632ef45267b19f13100accd2f" -dependencies = [ - "arrayref", - "rand_core 0.5.1", - "ring", - "rustc_version", - "subtle 2.2.2", -] - -[[package]] -name = "soketto" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bceb1a3a15232d013d9a3b7cac9e5ce8e2313f348f01d4bc1097e5e53aa07095" -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", -] - -[[package]] -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", - "sp-api-proc-macro", - "sp-core", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-version", -] - -[[package]] -name = "sp-api-proc-macro" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "blake2-rfc", - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "sp-application-crypto" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-std", -] - -[[package]] -name = "sp-arithmetic" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "serde", - "sp-debug-derive", - "sp-std", -] - -[[package]] -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", - "derive_more 0.99.9", - "ed25519-dalek 1.0.0-pre.3", - "futures 0.3.4", - "hash-db", - "hash256-std-hasher", - "hex 0.4.2", - "impl-serde 0.3.0", - "lazy_static", - "libsecp256k1", - "log", - "merlin 2.0.0", - "num-traits", - "parity-scale-codec", - "parity-util-mem 0.6.1", - "parking_lot 0.10.0", - "primitive-types 0.7.1", - "rand 0.7.3", - "regex", - "schnorrkel 0.9.1", - "serde", - "sha2", - "sp-debug-derive", - "sp-externalities", - "sp-runtime-interface", - "sp-std", - "sp-storage", - "substrate-bip39 0.4.1", - "tiny-bip39 0.7.3", - "tiny-keccak 2.0.2", - "twox-hash", - "wasmi 0.6.2", - "zeroize 1.1.0", -] - -[[package]] -name = "sp-debug-derive" -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", - "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 = [ - "environmental", - "parity-scale-codec", - "sp-std", - "sp-storage", -] - -[[package]] -name = "sp-inherents" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "derive_more 0.99.9", - "parity-scale-codec", - "parking_lot 0.10.0", - "sp-core", - "sp-std", -] - -[[package]] -name = "sp-io" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "futures 0.3.4", - "hash-db", - "libsecp256k1", - "log", - "parity-scale-codec", - "parking_lot 0.10.0", - "sp-core", - "sp-externalities", - "sp-runtime-interface", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-trie", - "sp-wasm-interface", -] - -[[package]] -name = "sp-panic-handler" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "backtrace", - "log", -] - -[[package]] -name = "sp-runtime" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "either", - "hash256-std-hasher", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "parity-util-mem 0.6.1", - "paste", - "rand 0.7.3", - "serde", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", - "sp-inherents", - "sp-io", - "sp-std", -] - -[[package]] -name = "sp-runtime-interface" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "parity-scale-codec", - "primitive-types 0.7.1", - "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 = [ - "Inflector", - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[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", - "parity-scale-codec", - "parking_lot 0.10.0", - "rand 0.7.3", - "smallvec 1.4.1", - "sp-core", - "sp-externalities", - "sp-panic-handler", - "sp-trie", - "trie-db 0.21.0", - "trie-root 0.16.0", -] - -[[package]] -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 = [ - "impl-serde 0.2.3", - "ref-cast", - "serde", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "sp-timestamp" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sp-api", - "sp-inherents", - "sp-runtime", - "sp-std", - "wasm-timer 0.2.4", -] - -[[package]] -name = "sp-tracing" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "log", - "rental", - "tracing", -] - -[[package]] -name = "sp-trie" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "hash-db", - "memory-db 0.21.0", - "parity-scale-codec", - "sp-core", - "sp-std", - "trie-db 0.21.0", - "trie-root 0.16.0", -] - -[[package]] -name = "sp-version" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "impl-serde 0.2.3", - "parity-scale-codec", - "serde", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-wasm-interface" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sp-std", - "wasmi 0.6.2", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "sr-api-macros" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "blake2-rfc", - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "sr-arithmetic" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "serde", - "sr-std", - "substrate-debug-derive", -] - -[[package]] -name = "sr-io" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "hash-db", - "libsecp256k1", - "log", - "parity-scale-codec", - "rustc_version", - "sr-std", - "substrate-externalities", - "substrate-primitives", - "substrate-state-machine", - "substrate-trie", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "sr-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "paste", - "rand 0.7.3", - "serde", - "sr-arithmetic", - "sr-io", - "sr-std", - "substrate-application-crypto", - "substrate-primitives", -] - -[[package]] -name = "sr-staking-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "sr-std" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "rustc_version", -] - -[[package]] -name = "sr-version" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "impl-serde 0.2.3", - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", -] - -[[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", -] - -[[package]] -name = "srml-authorship" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-inherents", - "substrate-primitives", -] - -[[package]] -name = "srml-babe" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "srml-balances" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-keyring", -] - -[[package]] -name = "srml-executive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", -] - -[[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", -] - -[[package]] -name = "srml-grandpa" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "srml-im-online" -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-staking-primitives", - "sr-std", - "srml-authorship", - "srml-session", - "srml-support", - "srml-system", - "substrate-application-crypto", - "substrate-primitives", -] - -[[package]] -name = "srml-indices" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-keyring", - "substrate-primitives", -] - -[[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", -] - -[[package]] -name = "srml-offences" -version = "1.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", -] - -[[package]] -name = "srml-randomness-collective-flip" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "safe-mix", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", -] - -[[package]] -name = "srml-session" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-trie", -] - -[[package]] -name = "srml-staking" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-staking-primitives", - "sr-std", - "srml-authorship", - "srml-session", - "srml-support", - "srml-system", - "substrate-keyring", - "substrate-phragmen", -] - -[[package]] -name = "srml-staking-reward-curve" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "srml-sudo" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", -] - -[[package]] -name = "srml-support" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "bitmask", - "impl-trait-for-tuples", - "log", - "once_cell 0.2.4", - "parity-scale-codec", - "paste", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-metadata", - "srml-support-procedural", - "substrate-inherents", - "substrate-primitives", -] - -[[package]] -name = "srml-support-procedural" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "sr-api-macros", - "srml-support-procedural-tools", - "syn 1.0.17", -] - -[[package]] -name = "srml-support-procedural-tools" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "srml-support-procedural-tools-derive", - "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" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "srml-system" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "safe-mix", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "sr-version", - "srml-support", - "substrate-primitives", -] - -[[package]] -name = "srml-system-rpc-runtime-api" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "substrate-client", -] - -[[package]] -name = "srml-timestamp" -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", -] - -[[package]] -name = "srml-transaction-payment" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "srml-transaction-payment-rpc-runtime-api", -] - -[[package]] -name = "srml-transaction-payment-rpc-runtime-api" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "substrate-client", -] - -[[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 = "stream-cipher" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" -dependencies = [ - "generic-array", -] - -[[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.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b3a3e93f5ad553c38b3301c8a0a0cec829a36783f6a0c467fc4bf553a5f5bf" -dependencies = [ - "clap", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea692d40005b3ceba90a9fe7a78fa8d4b82b0ce627eebbffc329aab850f3410e" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "strum" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f" - -[[package]] -name = "strum_macros" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e" -dependencies = [ - "heck", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "substrate-application-crypto" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-std", - "substrate-primitives", -] - -[[package]] -name = "substrate-authority-discovery" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "bytes 0.4.12", - "derive_more 0.15.0", - "futures-preview", - "futures-timer", - "libp2p", - "log", - "parity-scale-codec", - "prost", - "prost-build", - "serde_json", - "sr-primitives", - "substrate-authority-discovery-primitives", - "substrate-client", - "substrate-network", - "substrate-primitives", -] - -[[package]] -name = "substrate-authority-discovery-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "sr-primitives", - "sr-std", - "substrate-client", -] - -[[package]] -name = "substrate-basic-authorship" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "futures-preview", - "log", - "parity-scale-codec", - "sr-primitives", - "substrate-client", - "substrate-consensus-common", - "substrate-inherents", - "substrate-primitives", - "substrate-telemetry", - "substrate-transaction-pool", -] - -[[package]] -name = "substrate-bip39" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" -dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel 0.8.5", - "sha2", -] - -[[package]] -name = "substrate-bip39" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c004e8166d6e0aa3a9d5fa673e5b7098ff25f930de1013a21341988151e681bb" -dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel 0.9.1", - "sha2", -] - -[[package]] -name = "substrate-chain-spec" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "impl-trait-for-tuples", - "serde", - "serde_json", - "sr-primitives", - "substrate-chain-spec-derive", - "substrate-network", - "substrate-primitives", - "substrate-telemetry", -] - -[[package]] -name = "substrate-chain-spec-derive" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] -name = "substrate-cli" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "ansi_term 0.12.1", - "app_dirs", - "atty", - "clap", - "derive_more 0.15.0", - "env_logger 0.7.1", - "exit-future", - "fdlimit", - "futures 0.1.29", - "futures-preview", - "lazy_static", - "log", - "names", - "regex", - "rpassword", - "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", -] - -[[package]] -name = "substrate-client" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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" -dependencies = [ - "hash-db", - "kvdb", - "kvdb-memorydb", - "kvdb-rocksdb", - "linked-hash-map", - "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", -] - -[[package]] -name = "substrate-common-module" -version = "1.2.0" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "srml-support", - "srml-system", - "srml-timestamp", -] - -[[package]] -name = "substrate-consensus-babe" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "derive_more 0.15.0", - "fork-tree", - "futures 0.1.29", - "futures-preview", - "futures-timer", - "log", - "merlin 1.3.0", - "num-bigint", - "num-rational", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", - "pdqselect", - "rand 0.7.3", - "schnorrkel 0.8.5", - "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" -dependencies = [ - "parity-scale-codec", - "schnorrkel 0.8.5", - "sr-primitives", - "sr-std", - "substrate-application-crypto", - "substrate-client", - "substrate-consensus-slots", -] - -[[package]] -name = "substrate-consensus-common" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "substrate-consensus-slots" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "substrate-consensus-uncles" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "log", - "sr-primitives", - "srml-authorship", - "substrate-client", - "substrate-consensus-common", - "substrate-inherents", - "substrate-primitives", -] - -[[package]] -name = "substrate-content-working-group-module" -version = "1.0.1" -dependencies = [ - "parity-scale-codec", - "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", -] - -[[package]] -name = "substrate-executor" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "derive_more 0.15.0", - "lazy_static", - "libsecp256k1", - "log", - "parity-scale-codec", - "parity-wasm 0.40.3", - "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 1.5.0", - "wasmi 0.5.1", -] - -[[package]] -name = "substrate-externalities" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "environmental", - "primitive-types 0.6.2", - "sr-std", - "substrate-primitives-storage", -] - -[[package]] -name = "substrate-finality-grandpa" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "substrate-finality-grandpa-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "substrate-application-crypto", - "substrate-client", -] - -[[package]] -name = "substrate-forum-module" -version = "1.2.2" -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", -] - -[[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" -dependencies = [ - "lru-cache", - "parking_lot 0.9.0", - "sr-primitives", -] - -[[package]] -name = "substrate-hiring-module" -version = "1.0.2" -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", -] - -[[package]] -name = "substrate-inherents" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "substrate-keyring" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "lazy_static", - "sr-primitives", - "strum", - "strum_macros", - "substrate-primitives", -] - -[[package]] -name = "substrate-keystore" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "substrate-membership-module" -version = "1.0.1" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-io", - "sr-primitives", - "sr-std", - "srml-balances", - "srml-support", - "srml-system", - "srml-timestamp", - "substrate-common-module", - "substrate-primitives", -] - -[[package]] -name = "substrate-memo-module" -version = "1.0.0" -dependencies = [ - "parity-scale-codec", - "serde", - "sr-primitives", - "sr-std", - "srml-support", - "srml-system", - "substrate-common-module", -] - -[[package]] -name = "substrate-network" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "substrate-offchain" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "substrate-offchain-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "sr-primitives", - "substrate-client", -] - -[[package]] -name = "substrate-panic-handler" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "backtrace", - "log", -] - -[[package]] -name = "substrate-peerset" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "futures-preview", - "libp2p", - "linked-hash-map", - "log", - "lru-cache", - "serde_json", -] - -[[package]] -name = "substrate-phragmen" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "serde", - "sr-primitives", - "sr-std", -] - -[[package]] -name = "substrate-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "base58", - "blake2-rfc", - "byteorder 1.3.4", - "ed25519-dalek 0.9.1", - "hash-db", - "hash256-std-hasher", - "hex 0.4.2", - "impl-serde 0.2.3", - "lazy_static", - "libsecp256k1", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", - "primitive-types 0.6.2", - "rand 0.7.3", - "regex", - "rustc-hex", - "schnorrkel 0.8.5", - "serde", - "sha2", - "sr-std", - "substrate-bip39 0.3.1", - "substrate-debug-derive", - "substrate-externalities", - "substrate-primitives-storage", - "tiny-bip39 0.6.2", - "tiny-keccak 1.5.0", - "twox-hash", - "wasmi 0.5.1", - "zeroize 0.10.1", -] - -[[package]] -name = "substrate-primitives-storage" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "impl-serde 0.2.3", - "serde", - "sr-std", - "substrate-debug-derive", -] - -[[package]] -name = "substrate-proposals-codex-module" -version = "2.1.0" -dependencies = [ - "num_enum", - "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" -dependencies = [ - "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", -] - -[[package]] -name = "substrate-proposals-engine-module" -version = "2.0.0" -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", -] - -[[package]] -name = "substrate-recurring-reward-module" -version = "1.0.1" -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", - "substrate-token-mint-module", -] - -[[package]] -name = "substrate-rpc" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "futures-preview", - "hash-db", - "jsonrpc-core 14.0.5", - "jsonrpc-pubsub", - "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", -] - -[[package]] -name = "substrate-rpc-api" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -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", -] - -[[package]] -name = "substrate-rpc-primitives" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "serde", - "substrate-primitives", -] - -[[package]] -name = "substrate-rpc-servers" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "jsonrpc-core 14.0.5", - "jsonrpc-http-server", - "jsonrpc-pubsub", - "jsonrpc-ws-server", - "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" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] -name = "substrate-service" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "derive_more 0.15.0", - "exit-future", - "futures 0.1.29", - "futures-preview", - "lazy_static", - "log", - "parity-multiaddr 0.5.0", - "parity-scale-codec", - "parking_lot 0.9.0", - "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", -] - -[[package]] -name = "substrate-service-discovery-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-session" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "sr-primitives", - "sr-std", - "substrate-client", - "substrate-primitives", -] - -[[package]] -name = "substrate-stake-module" -version = "2.0.0" -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", -] - -[[package]] -name = "substrate-state-db" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "log", - "parity-scale-codec", - "parking_lot 0.9.0", - "substrate-primitives", -] - -[[package]] -name = "substrate-state-machine" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "hash-db", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", - "rand 0.7.3", - "substrate-externalities", - "substrate-panic-handler", - "substrate-primitives", - "substrate-trie", - "trie-db 0.15.2", - "trie-root 0.15.2", -] - -[[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" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "futures-preview", - "futures-timer", - "libp2p", - "log", - "parking_lot 0.9.0", - "rand 0.7.3", - "serde", - "slog", - "slog-async", - "slog-json", - "slog-scope", - "tokio-io", - "void", -] - -[[package]] -name = "substrate-token-mint-module" -version = "1.0.1" -dependencies = [ - "frame-support", - "frame-system", - "pallet-balances", - "parity-scale-codec", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "substrate-transaction-graph" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "derive_more 0.15.0", - "futures-preview", - "log", - "parking_lot 0.9.0", - "serde", - "sr-primitives", - "substrate-primitives", -] - -[[package]] -name = "substrate-transaction-pool" -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 0.3.4", "log", - "parity-scale-codec", - "parking_lot 0.9.0", - "sr-primitives", - "substrate-client", - "substrate-primitives", - "substrate-transaction-graph", + "rental", + "tracing", ] [[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 0.15.3", - "parity-scale-codec", - "sr-std", - "substrate-primitives", - "trie-db 0.15.2", - "trie-root 0.15.2", -] - -[[package]] -name = "substrate-versioned-store" -version = "1.0.1" -dependencies = [ - "hex-literal 0.1.4", + "memory-db", "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-core", + "sp-std", + "trie-db", + "trie-root", ] [[package]] -name = "substrate-versioned-store-permissions-module" -version = "1.0.1" +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-support", - "srml-support-procedural", - "srml-system", - "srml-timestamp", - "substrate-primitives", - "substrate-versioned-store", -] - -[[package]] -name = "substrate-wasm-builder-runner" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30c70de7e7d5fd404fe26db1e7a4d6b553e2760b1ac490f249c04a960c483b8" - -[[package]] -name = "substrate-wasm-interface" -version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb08535c49a12320af7facfd555ce05cce2e8" -dependencies = [ - "wasmi 0.5.1", + "sp-runtime", + "sp-std", ] [[package]] -name = "substrate-working-group-module" -version = "1.1.0" +name = "sp-wasm-interface" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "impl-trait-for-tuples", "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", -] - -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - -[[package]] -name = "subtle" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "unicode-xid 0.2.0", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", - "unicode-xid 0.2.0", -] - -[[package]] -name = "sysinfo" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f4b2468c629cffba39c0a4425849ab3cdb03d9dfacba69684609aea04d08ff9" -dependencies = [ - "cfg-if", - "doc-comment", - "libc", - "rayon", - "winapi 0.3.8", + "sp-std", + "wasmi", ] [[package]] -name = "take_mut" -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" +name = "stable_deref_trait" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -dependencies = [ - "cfg-if", - "libc", - "rand 0.7.3", - "redox_syscall", - "remove_dir_all", - "winapi 0.3.8", -] +checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" [[package]] -name = "termcolor" +name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "threadpool" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" -dependencies = [ - "num_cpus", -] - -[[package]] -name = "time" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -dependencies = [ - "libc", - "redox_syscall", - "winapi 0.3.8", -] - -[[package]] -name = "tiny-bip39" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" -dependencies = [ - "failure", - "hashbrown 0.1.8", - "hmac", - "once_cell 0.1.8", - "pbkdf2", - "rand 0.6.5", - "sha2", -] +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "tiny-bip39" -version = "0.7.3" +name = "substrate-bip39" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" +checksum = "c004e8166d6e0aa3a9d5fa673e5b7098ff25f930de1013a21341988151e681bb" dependencies = [ - "failure", "hmac", - "once_cell 1.4.0", "pbkdf2", - "rand 0.7.3", - "rustc-hash", + "schnorrkel", "sha2", - "unicode-normalization", -] - -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "mio", - "num_cpus", - "tokio-codec", - "tokio-current-thread", - "tokio-executor", - "tokio-fs", - "tokio-io", - "tokio-reactor", - "tokio-sync", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "tokio-udp", - "tokio-uds", -] - -[[package]] -name = "tokio-buf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" -dependencies = [ - "bytes 0.4.12", - "either", - "futures 0.1.29", -] - -[[package]] -name = "tokio-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "tokio-io", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.29", - "tokio-executor", -] - -[[package]] -name = "tokio-dns-unofficial" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c65483db54eb91b4ef3a9389a3364558590faf30ce473141707c0e16fda975" -dependencies = [ - "futures 0.1.29", - "futures-cpupool", - "lazy_static", - "tokio", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.29", -] - -[[package]] -name = "tokio-fs" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" -dependencies = [ - "futures 0.1.29", - "tokio-io", - "tokio-threadpool", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", -] - -[[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", - "futures 0.1.29", - "lazy_static", - "log", - "mio", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", ] [[package]] -name = "tokio-rustls" -version = "0.10.3" +name = "subtle" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d7cf08f990090abd6c6a73cab46fed62f85e8aef8b99e4b918a9f4a637f0676" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "iovec", - "rustls", - "tokio-io", - "webpki", -] +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] -name = "tokio-sync" -version = "0.1.8" +name = "subtle" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures 0.1.29", -] +checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" [[package]] -name = "tokio-tcp" -version = "0.1.4" +name = "syn" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" +checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "iovec", - "mio", - "tokio-io", - "tokio-reactor", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] -name = "tokio-threadpool" -version = "0.1.18" +name = "synstructure" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" +checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils 0.7.2", - "futures 0.1.29", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", + "proc-macro2", + "quote", + "syn", + "unicode-xid", ] [[package]] -name = "tokio-timer" -version = "0.2.13" +name = "thread_local" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.29", - "slab", - "tokio-executor", + "lazy_static", ] [[package]] -name = "tokio-udp" -version = "0.1.6" +name = "tiny-bip39" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" +checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", - "mio", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "failure", + "hmac", + "once_cell", + "pbkdf2", + "rand", + "rustc-hash", + "sha2", + "unicode-normalization", ] [[package]] -name = "tokio-uds" -version = "0.2.6" +name = "tiny-keccak" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "iovec", - "libc", - "log", - "mio", - "mio-uds", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "crunchy", ] [[package]] @@ -6626,9 +1739,9 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -6640,25 +1753,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "treeline" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" - -[[package]] -name = "trie-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" -dependencies = [ - "elastic-array", - "hash-db", - "hashbrown 0.6.3", - "log", - "rand 0.6.5", -] - [[package]] name = "trie-db" version = "0.21.0" @@ -6666,21 +1760,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb230c24c741993b04cfccbabb45acff6f6480c5f00d3ed8794ea43db3a9d727" dependencies = [ "hash-db", - "hashbrown 0.6.3", + "hashbrown", "log", "rustc-hex", "smallvec 1.4.1", ] -[[package]] -name = "trie-root" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" -dependencies = [ - "hash-db", -] - [[package]] name = "trie-root" version = "0.16.0" @@ -6690,30 +1775,13 @@ 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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -dependencies = [ - "block-cipher-trait", - "byteorder 1.3.4", - "opaque-debug", -] - [[package]] name = "twox-hash" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" dependencies = [ - "rand 0.7.3", + "rand", ] [[package]] @@ -6728,30 +1796,12 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "173cd16430c206dc1a430af8a89a0e9c076cf15cb42b4aedb10e8cc8fee73681" dependencies = [ - "byteorder 1.3.4", + "byteorder", "crunchy", "rustc-hex", "static_assertions", ] -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check 0.9.1", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] - [[package]] name = "unicode-normalization" version = "0.1.12" @@ -6761,125 +1811,12 @@ dependencies = [ "smallvec 1.4.1", ] -[[package]] -name = "unicode-segmentation" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" - -[[package]] -name = "unicode-width" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -[[package]] -name = "unsigned-varint" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f0023a96687fe169081e8adce3f65e3874426b7886e9234d490af2dc077959" -dependencies = [ - "bytes 0.4.12", - "tokio-codec", -] - -[[package]] -name = "unsigned-varint" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f38e01ad4b98f042e166c1bf9a13f9873a99d79eaa171ce7ca81e6dd0f895d8a" - -[[package]] -name = "untrusted" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" - -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - -[[package]] -name = "url" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" -dependencies = [ - "idna 0.2.0", - "matches", - "percent-encoding 2.1.0", -] - -[[package]] -name = "vcpkg" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" - -[[package]] -name = "version_check" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "want" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" -dependencies = [ - "futures 0.1.29", - "log", - "try-lock", -] - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -6905,25 +1842,12 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2", + "quote", + "syn", "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" -dependencies = [ - "cfg-if", - "futures 0.1.29", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-futures" version = "0.4.10" @@ -6942,7 +1866,7 @@ version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" dependencies = [ - "quote 1.0.3", + "quote", "wasm-bindgen-macro-support", ] @@ -6952,9 +1876,9 @@ 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", - "syn 1.0.17", + "proc-macro2", + "quote", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6965,50 +1889,22 @@ version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" -[[package]] -name = "wasm-timer" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa3e01d234bb71760e685cfafa5e2c96f8ad877c161a721646356651069e26ac" -dependencies = [ - "futures 0.1.29", - "js-sys", - "send_wrapper", - "tokio-timer", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-timer" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "324c5e65a08699c9c4334ba136597ab22b85dccd4b65dd1e36ccf8f723a95b54" dependencies = [ - "futures 0.3.4", + "futures", "js-sys", "parking_lot 0.9.0", "pin-utils", "send_wrapper", "wasm-bindgen", - "wasm-bindgen-futures 0.4.10", + "wasm-bindgen-futures", "web-sys", ] -[[package]] -name = "wasmi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31d26deb2d9a37e6cfed420edce3ed604eab49735ba89035e13c98f9a528313" -dependencies = [ - "libc", - "memory_units", - "num-rational", - "num-traits", - "parity-wasm 0.40.3", - "wasmi-validation 0.2.0", -] - [[package]] name = "wasmi" version = "0.6.2" @@ -7019,17 +1915,8 @@ dependencies = [ "memory_units", "num-rational", "num-traits", - "parity-wasm 0.41.0", - "wasmi-validation 0.3.0", -] - -[[package]] -name = "wasmi-validation" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" -dependencies = [ - "parity-wasm 0.40.3", + "parity-wasm", + "wasmi-validation", ] [[package]] @@ -7038,7 +1925,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" dependencies = [ - "parity-wasm 0.41.0", + "parity-wasm", ] [[package]] @@ -7051,50 +1938,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b" -dependencies = [ - "webpki", -] - -[[package]] -name = "webpki-roots" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cd5736df7f12a964a5067a12c62fa38e1bd8080aff1f80bc29be7c80d19ab4" -dependencies = [ - "webpki", -] - -[[package]] -name = "which" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" -dependencies = [ - "failure", - "libc", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.8" @@ -7105,107 +1948,18 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e" -dependencies = [ - "winapi 0.3.8", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "ws" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51a2c47b5798ccc774ffb93ff536aec7c4275d722fd9c740c83cdd1af1f2d94" -dependencies = [ - "byteorder 1.3.4", - "bytes 0.4.12", - "httparse", - "log", - "mio", - "mio-extras", - "rand 0.7.3", - "sha-1", - "slab", - "url 2.1.1", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "x25519-dalek" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" -dependencies = [ - "clear_on_drop", - "curve25519-dalek 1.2.3", - "rand_core 0.3.1", -] - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2758f29014c1cb7a6e74c1b1160ac8c8203be342d35b73462fc6a13cc6385423" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", - "nohash-hasher", - "parking_lot 0.9.0", - "quick-error", - "rand 0.7.3", - "tokio-codec", - "tokio-io", -] - -[[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" @@ -7221,8 +1975,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", - "syn 1.0.17", + "proc-macro2", + "quote", + "syn", "synstructure", ] diff --git a/Cargo.toml b/Cargo.toml index 5636eae212..03fd3162be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,26 +1,26 @@ [workspace] members = [ - "runtime", - "runtime-modules/proposals/engine", - "runtime-modules/proposals/codex", - "runtime-modules/proposals/discussion", - "runtime-modules/common", - "runtime-modules/content-working-group", - "runtime-modules/forum", - "runtime-modules/governance", - "runtime-modules/hiring", - "runtime-modules/membership", - "runtime-modules/memo", +# "runtime", +# "runtime-modules/proposals/engine", +# "runtime-modules/proposals/codex", +# "runtime-modules/proposals/discussion", +# "runtime-modules/common", +# "runtime-modules/content-working-group", +# "runtime-modules/forum", +# "runtime-modules/governance", +# "runtime-modules/hiring", +# "runtime-modules/membership", +# "runtime-modules/memo", "runtime-modules/recurring-reward", - "runtime-modules/service-discovery", - "runtime-modules/stake", - "runtime-modules/storage", -# "runtime-modules/token-minting", - "runtime-modules/versioned-store", - "runtime-modules/versioned-store-permissions", - "runtime-modules/working-group", - "node", - "utils/chain-spec-builder/" +# "runtime-modules/service-discovery", +# "runtime-modules/stake", +# "runtime-modules/storage", + "runtime-modules/token-minting", +# "runtime-modules/versioned-store", +# "runtime-modules/versioned-store-permissions", +# "runtime-modules/working-group", +# "node", +# "utils/chain-spec-builder/" ] [profile.release] diff --git a/runtime-modules/recurring-reward/Cargo.toml b/runtime-modules/recurring-reward/Cargo.toml index 10caf40b43..14ab1dd4b3 100755 --- a/runtime-modules/recurring-reward/Cargo.toml +++ b/runtime-modules/recurring-reward/Cargo.toml @@ -1,56 +1,34 @@ [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'] } +rstd = { 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'} +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'} +timestamp = { package = 'sp-timestamp', 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..7f52863f0c 100755 --- a/runtime-modules/recurring-reward/src/lib.rs +++ b/runtime-modules/recurring-reward/src/lib.rs @@ -7,11 +7,13 @@ // 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 rstd::prelude::*; +use sp_arithmetic::traits::{BaseArithmetic, One, Zero}; +use sp_runtime::traits::{MaybeSerialize, Member}; use minting::{self, BalanceOf}; @@ -24,7 +26,7 @@ pub trait Trait: system::Trait + minting::Trait { /// Type of identifier for recipients. type RecipientId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -34,7 +36,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 +144,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 +196,7 @@ impl Module { RewardsError::RewardSourceNotFound ); ensure!( - >::exists(recipient), + >::contains_key(recipient), RewardsError::RecipientNotFound ); ensure!( @@ -220,7 +224,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 +286,7 @@ impl Module { new_payout_interval: Option>, ) -> Result<(), RewardsError> { ensure!( - >::exists(&id), + >::contains_key(&id), RewardsError::RewardRelationshipNotFound ); @@ -320,8 +324,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 +398,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 667880d07c..72a5a82acb 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,9 +44,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! { @@ -60,20 +67,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 { @@ -87,7 +85,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); From e1010a0adb6b7f25a8ed3a2fc2e72dc44b67c120 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 15 Jul 2020 18:34:39 +0300 Subject: [PATCH 03/56] =?UTF-8?q?runtime:=20Upgrade=20=E2=80=98common?= =?UTF-8?q?=E2=80=99=20pallet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 308 +++++++++++++++++++++++-- Cargo.toml | 2 +- runtime-modules/common/Cargo.toml | 58 ++--- runtime-modules/common/src/currency.rs | 4 +- 4 files changed, 308 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b3b11413c..4debf0c214 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,26 @@ 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", +] + +[[package]] +name = "approx" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +dependencies = [ + "num-traits", +] + [[package]] name = "arrayref" version = "0.3.6" @@ -246,7 +266,7 @@ checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" dependencies = [ "byteorder", "digest", - "rand_core", + "rand_core 0.5.1", "subtle 2.2.2", "zeroize", ] @@ -279,7 +299,7 @@ checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" dependencies = [ "clear_on_drop", "curve25519-dalek", - "rand", + "rand 0.7.3", "sha2", ] @@ -330,11 +350,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" dependencies = [ "byteorder", - "rand", + "rand 0.7.3", "rustc-hex", "static_assertions", ] +[[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-metadata" version = "11.0.0-rc4" @@ -420,6 +457,12 @@ dependencies = [ "sp-version", ] +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + [[package]] name = "futures" version = "0.3.4" @@ -673,6 +716,12 @@ version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" +[[package]] +name = "libm" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" + [[package]] name = "libsecp256k1" version = "0.3.5" @@ -683,12 +732,23 @@ dependencies = [ "crunchy", "digest", "hmac-drbg", - "rand", + "rand 0.7.3", "sha2", "subtle 2.2.2", "typenum", ] +[[package]] +name = "linregress" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9290cf6f928576eeb9c096c6fad9d8d452a0a1a70a2bbffa6e36064eedc0aac9" +dependencies = [ + "failure", + "nalgebra", + "statrs", +] + [[package]] name = "lock_api" version = "0.3.3" @@ -707,6 +767,15 @@ dependencies = [ "cfg-if", ] +[[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" @@ -745,10 +814,27 @@ checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" dependencies = [ "byteorder", "keccak", - "rand_core", + "rand_core 0.5.1", "zeroize", ] +[[package]] +name = "nalgebra" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaa9fddbc34c8c35dd2108515587b8ce0cab396f17977b8c738568e4edb521a2" +dependencies = [ + "alga", + "approx", + "generic-array", + "matrixmultiply", + "num-complex", + "num-rational", + "num-traits", + "rand 0.6.5", + "typenum", +] + [[package]] name = "nodrop" version = "0.1.14" @@ -766,6 +852,16 @@ dependencies = [ "num-traits", ] +[[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", +] + [[package]] name = "num-integer" version = "0.1.42" @@ -795,6 +891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" dependencies = [ "autocfg 1.0.0", + "libm", ] [[package]] @@ -834,6 +931,19 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-common" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-runtime", +] + [[package]] name = "pallet-recurring-reward" version = "3.0.0" @@ -851,6 +961,23 @@ dependencies = [ "sp-timestamp", ] +[[package]] +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-runtime", + "sp-std", + "sp-timestamp", +] + [[package]] name = "pallet-token-mint" version = "3.0.0" @@ -1074,6 +1201,38 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" +[[package]] +name = "rand" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "winapi", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.7", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg 0.1.2", + "rand_xorshift", + "winapi", +] + [[package]] name = "rand" version = "0.7.3" @@ -1082,10 +1241,20 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", - "rand_chacha", - "rand_core", - "rand_hc", - "rand_pcg", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", + "rand_pcg 0.2.1", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.3.1", ] [[package]] @@ -1095,9 +1264,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", ] +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + [[package]] name = "rand_core" version = "0.5.1" @@ -1107,13 +1291,66 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.4.2", ] [[package]] @@ -1122,7 +1359,31 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", ] [[package]] @@ -1228,8 +1489,8 @@ dependencies = [ "curve25519-dalek", "getrandom", "merlin", - "rand", - "rand_core", + "rand 0.7.3", + "rand_core 0.5.1", "sha2", "subtle 2.2.2", "zeroize", @@ -1391,7 +1652,7 @@ dependencies = [ "parity-util-mem", "parking_lot 0.10.0", "primitive-types", - "rand", + "rand 0.7.3", "regex", "schnorrkel", "serde", @@ -1484,7 +1745,7 @@ dependencies = [ "parity-scale-codec", "parity-util-mem", "paste", - "rand", + "rand 0.7.3", "serde", "sp-application-crypto", "sp-arithmetic", @@ -1532,7 +1793,7 @@ dependencies = [ "num-traits", "parity-scale-codec", "parking_lot 0.10.0", - "rand", + "rand 0.7.3", "smallvec 1.4.1", "sp-core", "sp-externalities", @@ -1632,6 +1893,15 @@ 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 = "substrate-bip39" version = "0.4.1" @@ -1698,7 +1968,7 @@ dependencies = [ "hmac", "once_cell", "pbkdf2", - "rand", + "rand 0.7.3", "rustc-hash", "sha2", "unicode-normalization", @@ -1781,7 +2051,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" dependencies = [ - "rand", + "rand 0.7.3", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 03fd3162be..0bd1c03f5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ # "runtime-modules/proposals/engine", # "runtime-modules/proposals/codex", # "runtime-modules/proposals/discussion", -# "runtime-modules/common", + "runtime-modules/common", # "runtime-modules/content-working-group", # "runtime-modules/forum", # "runtime-modules/governance", diff --git a/runtime-modules/common/Cargo.toml b/runtime-modules/common/Cargo.toml index df598a6ca8..2c6901698e 100644 --- a/runtime-modules/common/Cargo.toml +++ b/runtime-modules/common/Cargo.toml @@ -1,52 +1,26 @@ [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 } +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'} +sp-arithmetic = { package = 'sp-arithmetic', 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'} +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-runtime/std', + 'sp-arithmetic/std', + 'frame-support/std', 'system/std', 'timestamp/std', - 'codec/std', - 'serde' ] - - -[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 From f4e964a0761d6653265328f09290fa698a52c15c Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 16 Jul 2020 13:40:02 +0300 Subject: [PATCH 04/56] =?UTF-8?q?runtime:=20Upgrade=20the=20=E2=80=98memo?= =?UTF-8?q?=E2=80=99=20pallet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 12 +++++++ Cargo.toml | 2 +- runtime-modules/memo/Cargo.toml | 62 ++++++++------------------------- runtime-modules/memo/src/lib.rs | 15 ++++---- 4 files changed, 35 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4debf0c214..f967353704 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -944,6 +944,18 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-memo" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-common", + "parity-scale-codec", + "sp-arithmetic", + "sp-runtime", +] + [[package]] name = "pallet-recurring-reward" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index 0bd1c03f5a..e940f04e93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ members = [ # "runtime-modules/governance", # "runtime-modules/hiring", # "runtime-modules/membership", -# "runtime-modules/memo", + "runtime-modules/memo", "runtime-modules/recurring-reward", # "runtime-modules/service-discovery", # "runtime-modules/stake", diff --git a/runtime-modules/memo/Cargo.toml b/runtime-modules/memo/Cargo.toml index 1ec371433a..5ac2c07788 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-runtime = { package = 'sp-runtime', 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'} +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-runtime/std', + 'sp-arithmetic/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..b8327cc555 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 system::{self, ensure_signed}; +use frame_support::traits::Currency; +use frame_support::{decl_module, decl_storage, decl_event, ensure}; +use sp_arithmetic::traits::{Zero}; + 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 system::{self, ensure_signed}; 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] fn update_memo(origin, memo: MemoText) { let sender = ensure_signed(origin)?; From 45cb5c0c10356abb3076e606e313db75929ca92c Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 16 Jul 2020 13:43:17 +0300 Subject: [PATCH 05/56] =?UTF-8?q?runtime:=20Add=20=E2=80=98adjust=20weight?= =?UTF-8?q?=E2=80=99=20comment.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime-modules/memo/src/lib.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/runtime-modules/memo/src/lib.rs b/runtime-modules/memo/src/lib.rs index b8327cc555..7c831a0a00 100644 --- a/runtime-modules/memo/src/lib.rs +++ b/runtime-modules/memo/src/lib.rs @@ -1,14 +1,13 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use system::{self, ensure_signed}; use frame_support::traits::Currency; -use frame_support::{decl_module, decl_storage, decl_event, ensure}; -use sp_arithmetic::traits::{Zero}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use sp_arithmetic::traits::Zero; +use system::{self, ensure_signed}; use common::currency::GovernanceCurrency; - pub trait Trait: system::Trait + GovernanceCurrency { type Event: From> + Into<::Event>; } @@ -32,7 +31,7 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; - #[weight = 10_000_000] + #[weight = 10_000_000] // TODO: adjust weight fn update_memo(origin, memo: MemoText) { let sender = ensure_signed(origin)?; From d19453ad6370230c5a888c47ce20502b7694bde9 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 16 Jul 2020 14:47:38 +0300 Subject: [PATCH 06/56] =?UTF-8?q?runtime:=20Upgrace=20=E2=80=98version-sto?= =?UTF-8?q?re=E2=80=99=20pallet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 19 ++++-- Cargo.toml | 2 +- runtime-modules/versioned-store/Cargo.toml | 49 ++++---------- .../versioned-store/src/example.rs | 2 +- runtime-modules/versioned-store/src/lib.rs | 67 +++++++++---------- runtime-modules/versioned-store/src/mock.rs | 29 ++++---- runtime-modules/versioned-store/src/tests.rs | 2 +- 7 files changed, 79 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f967353704..fa3d4dcc15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -940,7 +940,6 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "serde", - "sp-arithmetic", "sp-runtime", ] @@ -953,7 +952,6 @@ dependencies = [ "pallet-common", "parity-scale-codec", "sp-arithmetic", - "sp-runtime", ] [[package]] @@ -969,8 +967,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", - "sp-timestamp", ] [[package]] @@ -1002,8 +998,21 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", +] + +[[package]] +name = "pallet-versioned-store" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", "sp-std", - "sp-timestamp", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e940f04e93..d3e6e338e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ members = [ # "runtime-modules/stake", # "runtime-modules/storage", "runtime-modules/token-minting", -# "runtime-modules/versioned-store", + "runtime-modules/versioned-store", # "runtime-modules/versioned-store-permissions", # "runtime-modules/working-group", # "node", diff --git a/runtime-modules/versioned-store/Cargo.toml b/runtime-modules/versioned-store/Cargo.toml index 3bae748ff9..71730a1cc3 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'] } +rstd = { 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'} +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', + '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..9d76e9928c 100755 --- a/runtime-modules/versioned-store/src/lib.rs +++ b/runtime-modules/versioned-store/src/lib.rs @@ -12,17 +12,20 @@ #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "std")] -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; use rstd::collections::btree_set::BTreeSet; -use rstd::prelude::*; -use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure}; 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 +138,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 +255,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; } } @@ -375,7 +377,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 +436,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 +523,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 +582,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 +599,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 +627,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 +639,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 +647,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 +666,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 +723,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 +773,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 +781,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 +789,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 +797,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..29fc62a307 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,9 +40,17 @@ 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 { @@ -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 // -------------------------------------- From 580566aab111cdf27a6ad01382915b9e86cc3575 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 16 Jul 2020 14:48:03 +0300 Subject: [PATCH 07/56] runtime: Clear pallets dependencies. --- runtime-modules/common/Cargo.toml | 4 +--- runtime-modules/memo/Cargo.toml | 2 -- runtime-modules/recurring-reward/Cargo.toml | 5 ----- runtime-modules/recurring-reward/src/lib.rs | 1 - runtime-modules/token-minting/Cargo.toml | 4 ---- runtime-modules/token-minting/src/lib.rs | 3 --- runtime-modules/token-minting/src/mock.rs | 2 -- 7 files changed, 1 insertion(+), 20 deletions(-) diff --git a/runtime-modules/common/Cargo.toml b/runtime-modules/common/Cargo.toml index 2c6901698e..ede768bb87 100644 --- a/runtime-modules/common/Cargo.toml +++ b/runtime-modules/common/Cargo.toml @@ -5,10 +5,9 @@ authors = ['Joystream contributors'] edition = '2018' [dependencies] -serde = { version = "1.0.101", optional = true } +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'} -sp-arithmetic = { package = 'sp-arithmetic', 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'} timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -19,7 +18,6 @@ std = [ 'serde', 'codec/std', 'sp-runtime/std', - 'sp-arithmetic/std', 'frame-support/std', 'system/std', 'timestamp/std', diff --git a/runtime-modules/memo/Cargo.toml b/runtime-modules/memo/Cargo.toml index 5ac2c07788..5179cde23e 100644 --- a/runtime-modules/memo/Cargo.toml +++ b/runtime-modules/memo/Cargo.toml @@ -6,7 +6,6 @@ edition = '2018' [dependencies] 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'} sp-arithmetic = { package = 'sp-arithmetic', 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'} @@ -16,7 +15,6 @@ common = { package = 'pallet-common', default-features = false, path = '../commo default = ['std'] std = [ 'codec/std', - 'sp-runtime/std', 'sp-arithmetic/std', 'frame-support/std', 'system/std', diff --git a/runtime-modules/recurring-reward/Cargo.toml b/runtime-modules/recurring-reward/Cargo.toml index 14ab1dd4b3..401f4824fb 100755 --- a/runtime-modules/recurring-reward/Cargo.toml +++ b/runtime-modules/recurring-reward/Cargo.toml @@ -6,12 +6,10 @@ edition = '2018' [dependencies] codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } -rstd = { 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'} 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'} -timestamp = { package = 'sp-timestamp', 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] @@ -19,16 +17,13 @@ sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com 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 = [ 'codec/std', - 'rstd/std', 'sp-arithmetic/std', 'sp-runtime/std', 'frame-support/std', 'system/std', - 'timestamp/std', 'minting/std', ] diff --git a/runtime-modules/recurring-reward/src/lib.rs b/runtime-modules/recurring-reward/src/lib.rs index 7f52863f0c..ebdc157407 100755 --- a/runtime-modules/recurring-reward/src/lib.rs +++ b/runtime-modules/recurring-reward/src/lib.rs @@ -11,7 +11,6 @@ use codec::{Codec, Decode, Encode}; use frame_support::storage::IterableStorageMap; use frame_support::{decl_module, decl_storage, ensure, Parameter}; -use rstd::prelude::*; use sp_arithmetic::traits::{BaseArithmetic, One, Zero}; use sp_runtime::traits::{MaybeSerialize, Member}; diff --git a/runtime-modules/token-minting/Cargo.toml b/runtime-modules/token-minting/Cargo.toml index e079aa0359..ac868264d8 100755 --- a/runtime-modules/token-minting/Cargo.toml +++ b/runtime-modules/token-minting/Cargo.toml @@ -6,12 +6,10 @@ edition = '2018' [dependencies] codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } -rstd = { 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'} 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'} -timestamp = { package = 'sp-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} [dev-dependencies] sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -22,10 +20,8 @@ balances = { package = 'pallet-balances', default-features = false, git = 'https default = ['std'] std = [ 'codec/std', - 'rstd/std', 'sp-arithmetic/std', 'sp-runtime/std', 'frame-support/std', 'system/std', - 'timestamp/std', ] diff --git a/runtime-modules/token-minting/src/lib.rs b/runtime-modules/token-minting/src/lib.rs index e3ee546d6b..a1c31089e8 100755 --- a/runtime-modules/token-minting/src/lib.rs +++ b/runtime-modules/token-minting/src/lib.rs @@ -6,9 +6,6 @@ // 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 frame_support::storage::IterableStorageMap; use frame_support::traits::Currency; diff --git a/runtime-modules/token-minting/src/mock.rs b/runtime-modules/token-minting/src/mock.rs index 564b1fac69..3998648c9b 100644 --- a/runtime-modules/token-minting/src/mock.rs +++ b/runtime-modules/token-minting/src/mock.rs @@ -1,7 +1,5 @@ #![cfg(test)] -use crate::*; - use crate::{Module, Trait}; use balances; use frame_support::{impl_outer_origin, parameter_types}; From 14970f376dec7a6ec0131a8b18d8556b69dcb2cd Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 16 Jul 2020 15:17:43 +0300 Subject: [PATCH 08/56] =?UTF-8?q?runtime:=20Upgrade=20the=20=E2=80=98versi?= =?UTF-8?q?oned-store-permissions=E2=80=99=20pallet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 16 ++++ Cargo.toml | 2 +- .../versioned-store-permissions/Cargo.toml | 47 ++++------ .../src/credentials.rs | 1 - .../versioned-store-permissions/src/lib.rs | 88 +++++++++++-------- .../versioned-store-permissions/src/mock.rs | 21 +++-- .../src/operations.rs | 1 - .../src/permissions.rs | 10 +-- .../versioned-store-permissions/src/tests.rs | 52 ++++++----- 9 files changed, 133 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa3d4dcc15..4f38d4e6bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1015,6 +1015,22 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-versioned-store-permissions" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-timestamp", + "pallet-versioned-store", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "parity-scale-codec" version = "1.3.1" diff --git a/Cargo.toml b/Cargo.toml index d3e6e338e6..160ce76646 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ # "runtime-modules/storage", "runtime-modules/token-minting", "runtime-modules/versioned-store", -# "runtime-modules/versioned-store-permissions", + "runtime-modules/versioned-store-permissions", # "runtime-modules/working-group", # "node", # "utils/chain-spec-builder/" diff --git a/runtime-modules/versioned-store-permissions/Cargo.toml b/runtime-modules/versioned-store-permissions/Cargo.toml index f49cbf390a..b973cf2178 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'] } +rstd = { 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'} +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', + '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/credentials.rs b/runtime-modules/versioned-store-permissions/src/credentials.rs index f31978dd07..bf3dbcc36e 100644 --- a/runtime-modules/versioned-store-permissions/src/credentials.rs +++ b/runtime-modules/versioned-store-permissions/src/credentials.rs @@ -1,6 +1,5 @@ use codec::{Decode, Encode}; use rstd::collections::btree_set::BTreeSet; -use rstd::prelude::*; #[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..8dbcfa07c4 100755 --- a/runtime-modules/versioned-store-permissions/src/lib.rs +++ b/runtime-modules/versioned-store-permissions/src/lib.rs @@ -2,10 +2,14 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::Codec; +use frame_support::{decl_module, decl_storage, ensure, Parameter}; 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 sp_arithmetic::traits::BaseArithmetic; +use sp_runtime::traits::{MaybeSerialize, Member}; + +//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 +64,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 +87,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 +100,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 +121,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 +142,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 +163,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 +184,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 +205,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 +232,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 +246,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 +276,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 +314,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 +333,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 +429,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 +462,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 +505,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 +536,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 +553,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 +571,7 @@ impl Module { fn is_system( _: &ClassPermissionsType, access_level: &AccessLevel, - ) -> dispatch::Result { + ) -> DispatchResult { if *access_level == AccessLevel::System { Ok(()) } else { @@ -581,8 +594,7 @@ impl Module { callback: Callback, ) -> Result where - Predicate: - FnOnce(&ClassPermissionsType, &AccessLevel) -> dispatch::Result, + Predicate: FnOnce(&ClassPermissionsType, &AccessLevel) -> DispatchResult, Callback: FnOnce( &ClassPermissionsType, &AccessLevel, @@ -599,7 +611,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 +623,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..7ff0c4b840 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,9 +41,17 @@ 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 { @@ -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..88b28b9fde 100644 --- a/runtime-modules/versioned-store-permissions/src/operations.rs +++ b/runtime-modules/versioned-store-permissions/src/operations.rs @@ -1,6 +1,5 @@ use codec::{Decode, Encode}; use rstd::collections::btree_map::BTreeMap; -use rstd::prelude::*; 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..6e785f7523 100644 --- a/runtime-modules/versioned-store-permissions/src/tests.rs +++ b/runtime-modules/versioned-store-permissions/src/tests.rs @@ -5,7 +5,7 @@ use crate::mock::*; use rstd::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), From 5daaca2d6442196c17925bbd3ab7b753b9d346a3 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 16 Jul 2020 18:28:47 +0300 Subject: [PATCH 09/56] =?UTF-8?q?runtime:=20Upgrade=20the=20=E2=80=98stake?= =?UTF-8?q?=E2=80=99=20pallet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 16 ++++++ Cargo.toml | 2 +- .../recurring-reward/src/mock/mod.rs | 5 -- runtime-modules/stake/Cargo.toml | 52 ++++++------------- runtime-modules/stake/src/lib.rs | 52 +++++++++---------- runtime-modules/stake/src/macroes.rs | 2 +- runtime-modules/stake/src/mock.rs | 51 ++++++------------ runtime-modules/stake/src/tests.rs | 10 ++-- runtime-modules/token-minting/src/mock.rs | 1 - 9 files changed, 79 insertions(+), 112 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f38d4e6bb..368ac04259 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -969,6 +969,22 @@ dependencies = [ "sp-runtime", ] +[[package]] +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 = "pallet-timestamp" version = "2.0.0-rc4" diff --git a/Cargo.toml b/Cargo.toml index 160ce76646..9d8021fa4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ members = [ "runtime-modules/memo", "runtime-modules/recurring-reward", # "runtime-modules/service-discovery", -# "runtime-modules/stake", + "runtime-modules/stake", # "runtime-modules/storage", "runtime-modules/token-minting", "runtime-modules/versioned-store", diff --git a/runtime-modules/recurring-reward/src/mock/mod.rs b/runtime-modules/recurring-reward/src/mock/mod.rs index 72a5a82acb..0f54d38462 100644 --- a/runtime-modules/recurring-reward/src/mock/mod.rs +++ b/runtime-modules/recurring-reward/src/mock/mod.rs @@ -59,11 +59,6 @@ impl system::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 InitialMembersBalance: u64 = 2000; } impl balances::Trait for Test { diff --git a/runtime-modules/stake/Cargo.toml b/runtime-modules/stake/Cargo.toml index d8de052e4c..74b3605d21 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'] } +rstd = { 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'} +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', + '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..e98dd8467f 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 frame_support::storage::IterableStorageMap; +use frame_support::traits::{Currency, ExistenceRequirement, Get, Imbalance, WithdrawReasons}; +use frame_support::{decl_module, decl_storage, ensure, Parameter}; use rstd::collections::btree_map::BTreeMap; +use rstd::prelude::*; +use sp_arithmetic::traits::{BaseArithmetic, One, Zero}; +use sp_runtime::traits::{AccountIdConversion, MaybeSerialize, Member}; +use sp_runtime::ModuleId; 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..77e69866cd 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 {} @@ -29,10 +27,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; @@ -41,35 +40,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 +74,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 +93,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/token-minting/src/mock.rs b/runtime-modules/token-minting/src/mock.rs index 3998648c9b..025a5e47b8 100644 --- a/runtime-modules/token-minting/src/mock.rs +++ b/runtime-modules/token-minting/src/mock.rs @@ -22,7 +22,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; } impl system::Trait for Test { From 654fa04ab5c73179ffecf0b9e24708363daf3c6a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 16 Jul 2020 19:23:22 +0300 Subject: [PATCH 10/56] =?UTF-8?q?runtime:=20Upgrade=20the=20=E2=80=98hirin?= =?UTF-8?q?g=E2=80=99=20pallet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 113 ++++++++++++++++++ Cargo.toml | 2 +- runtime-modules/hiring/Cargo.toml | 60 +++------- runtime-modules/hiring/src/hiring/opening.rs | 4 - runtime-modules/hiring/src/lib.rs | 61 +++++----- runtime-modules/hiring/src/macroes.rs | 2 +- runtime-modules/hiring/src/mock.rs | 52 ++++---- .../src/test/public_api/add_application.rs | 14 ++- .../hiring/src/test/public_api/add_opening.rs | 9 +- .../begin_accepting_applications.rs | 4 +- .../src/test/public_api/begin_review.rs | 4 +- .../src/test/public_api/cancel_opening.rs | 4 +- .../test/public_api/deactivate_application.rs | 10 +- .../public_api/ensure_can_add_application.rs | 6 +- .../src/test/public_api/fill_opening.rs | 6 +- .../hiring/src/test/public_api/on_finalize.rs | 2 +- .../hiring/src/test/public_api/unstaked.rs | 2 +- runtime-modules/hiring/src/test/smoke.rs | 34 +++--- ...ry_to_initiate_application_deactivation.rs | 10 +- runtime-modules/stake/src/mock.rs | 1 - 20 files changed, 234 insertions(+), 166 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 368ac04259..e22425d6e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -282,6 +282,12 @@ dependencies = [ "syn", ] +[[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" @@ -291,6 +297,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "downcast" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" + [[package]] name = "ed25519-dalek" version = "1.0.0-pre.3" @@ -355,6 +367,21 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "float-cmp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da62c4f1b81918835a8c6a484a397775fff5953fe83529afd51b05f5c6a6617d" +dependencies = [ + "num-traits", +] + +[[package]] +name = "fragile" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9" + [[package]] name = "frame-benchmarking" version = "2.0.0-rc4" @@ -818,6 +845,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "mockall" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95a7e7cfbce0e99ebbf5356a085d3b5e320a7ef300f77cd50a7148aa362e7c2" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5a615a1ad92048ad5d9633251edb7492b8abc057d7a679a9898476aef173935" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "nalgebra" version = "0.18.1" @@ -841,6 +895,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "num-bigint" version = "0.2.6" @@ -943,6 +1003,24 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-hiring" +version = "3.0.0" +dependencies = [ + "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 = "pallet-memo" version = "3.0.0" @@ -1197,6 +1275,35 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +[[package]] +name = "predicates" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030" +dependencies = [ + "difference", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" + +[[package]] +name = "predicates-tree" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +dependencies = [ + "predicates-core", + "treeline", +] + [[package]] name = "primitive-types" version = "0.7.1" @@ -2076,6 +2183,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "treeline" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" + [[package]] name = "trie-db" version = "0.21.0" diff --git a/Cargo.toml b/Cargo.toml index 9d8021fa4f..f5ebb2a93d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ # "runtime-modules/content-working-group", # "runtime-modules/forum", # "runtime-modules/governance", -# "runtime-modules/hiring", + "runtime-modules/hiring", # "runtime-modules/membership", "runtime-modules/memo", "runtime-modules/recurring-reward", diff --git a/runtime-modules/hiring/Cargo.toml b/runtime-modules/hiring/Cargo.toml index 6fa631e827..43e49d5961 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.6.0", 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'] } +rstd = { 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.6.0" - +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', + '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/opening.rs b/runtime-modules/hiring/src/hiring/opening.rs index f04e796c66..bca1047b0e 100644 --- a/runtime-modules/hiring/src/hiring/opening.rs +++ b/runtime-modules/hiring/src/hiring/opening.rs @@ -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..c09eab0792 100755 --- a/runtime-modules/hiring/src/lib.rs +++ b/runtime-modules/hiring/src/lib.rs @@ -18,31 +18,25 @@ // 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 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 frame_support::storage::IterableStorageMap; +use frame_support::traits::{Currency, Imbalance}; +use frame_support::{decl_module, decl_storage, ensure, Parameter}; +use rstd::cell::RefCell; 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 sp_arithmetic::traits::{BaseArithmetic, One, Zero}; +use sp_runtime::traits::{MaybeSerialize, Member}; -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 +51,7 @@ pub trait Trait: system::Trait + stake::Trait + Sized { /// OpeningId type type OpeningId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -67,7 +61,7 @@ pub trait Trait: system::Trait + stake::Trait + Sized { /// ApplicationId type type ApplicationId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -83,21 +77,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 +765,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 +1001,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 +1024,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 +1278,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 +1472,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 +1529,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 480c79f4c7..7f260bda9a 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 rstd::cell::{Cell, RefCell}; +use rstd::rc::Rc; +use sp_core::H256; +use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -use srml_support::{impl_outer_origin, parameter_types}; +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,45 +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 InitialMembersBalance: u64 = 2000; 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; } @@ -149,7 +138,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(); @@ -202,3 +191,6 @@ impl TestApplicationDeactivatedHandler { ); } } + +// Test fixtures starting block. +pub(crate) static FIRST_BLOCK_HEIGHT: ::BlockNumber = 0; 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..1df06bd3b3 100644 --- a/runtime-modules/hiring/src/test/public_api/add_application.rs +++ b/runtime-modules/hiring/src/test/public_api/add_application.rs @@ -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..e3cbf2d01f 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::*; @@ -8,7 +8,6 @@ use crate::{ }; use rstd::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..ba226fde0f 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 @@ -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..04deac8f54 100644 --- a/runtime-modules/hiring/src/test/public_api/cancel_opening.rs +++ b/runtime-modules/hiring/src/test/public_api/cancel_opening.rs @@ -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..78ccfba5b1 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 @@ -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..f2cc62427d 100644 --- a/runtime-modules/hiring/src/test/public_api/fill_opening.rs +++ b/runtime-modules/hiring/src/test/public_api/fill_opening.rs @@ -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/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..c8c5ebfe19 100644 --- a/runtime-modules/hiring/src/test/smoke.rs +++ b/runtime-modules/hiring/src/test/smoke.rs @@ -1,8 +1,6 @@ use super::*; use crate::mock::*; -static FIRST_BLOCK_HEIGHT: ::BlockNumber = 1; - use rstd::collections::btree_set::BTreeSet; /** @@ -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/stake/src/mock.rs b/runtime-modules/stake/src/mock.rs index 77e69866cd..5ce19e87b3 100644 --- a/runtime-modules/stake/src/mock.rs +++ b/runtime-modules/stake/src/mock.rs @@ -23,7 +23,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; } impl system::Trait for Test { From acd378a6802f6fc576570a33df557a733987ea6b Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 20 Jul 2020 19:01:04 +0300 Subject: [PATCH 11/56] runtime: Upgrade the memberhip pallet. --- Cargo.lock | 30 ++++++-- Cargo.toml | 2 +- runtime-modules/membership/Cargo.toml | 98 +++++++------------------ runtime-modules/membership/src/lib.rs | 95 ++++++++++++++---------- runtime-modules/membership/src/mock.rs | 61 ++++++++------- runtime-modules/membership/src/tests.rs | 22 +++--- 6 files changed, 148 insertions(+), 160 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e22425d6e3..13c2ede796 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,9 +378,9 @@ dependencies = [ [[package]] name = "fragile" -version = "0.3.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9" +checksum = "69a039c3498dc930fe810151a34ba0c1c70b02b8625035592e74432f678591f2" [[package]] name = "frame-benchmarking" @@ -847,9 +847,9 @@ dependencies = [ [[package]] name = "mockall" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b95a7e7cfbce0e99ebbf5356a085d3b5e320a7ef300f77cd50a7148aa362e7c2" +checksum = "256489d4d106cd2bc9e98ed0337402db0044de0621745d5d9eb70a14295ff77b" dependencies = [ "cfg-if", "downcast", @@ -862,9 +862,9 @@ dependencies = [ [[package]] name = "mockall_derive" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5a615a1ad92048ad5d9633251edb7492b8abc057d7a679a9898476aef173935" +checksum = "826e14e8643cb12103b56efb963e5f9640b69b0f7bdcc460002092df4b0e959f" dependencies = [ "cfg-if", "proc-macro2", @@ -1021,6 +1021,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-membership" +version = "3.0.0" +dependencies = [ + "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 = "pallet-memo" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index f5ebb2a93d..a0ab514644 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ # "runtime-modules/forum", # "runtime-modules/governance", "runtime-modules/hiring", -# "runtime-modules/membership", + "runtime-modules/membership", "runtime-modules/memo", "runtime-modules/recurring-reward", # "runtime-modules/service-discovery", diff --git a/runtime-modules/membership/Cargo.toml b/runtime-modules/membership/Cargo.toml index b67c46eef5..e3707decec 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'] } +rstd = { 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'} +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', + 'codec/std', + 'rstd/std', + 'frame-support/std', + 'system/std', + 'sp-arithmetic/std', + 'sp-runtime/std', 'timestamp/std', - 'primitives/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/lib.rs b/runtime-modules/membership/src/lib.rs index 5dc816f941..967fe00cde 100644 --- a/runtime-modules/membership/src/lib.rs +++ b/runtime-modules/membership/src/lib.rs @@ -10,21 +10,25 @@ pub(crate) mod mock; mod tests; use codec::{Codec, Decode, Encode}; +use frame_support::traits::Currency; +use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; 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 sp_arithmetic::traits::{BaseArithmetic, One}; +use sp_runtime::traits::{MaybeSerialize, Member}; use system::{self, ensure_root, ensure_signed}; use common::currency::{BalanceOf, GovernanceCurrency}; +//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 + timestamp::Trait { type Event: From> + Into<::Event>; type MemberId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -33,7 +37,7 @@ pub trait Trait: system::Trait + GovernanceCurrency + timestamp::Trait { type PaidTermId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -42,7 +46,7 @@ pub trait Trait: system::Trait + GovernanceCurrency + timestamp::Trait { type SubscriptionId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -52,7 +56,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 +65,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; @@ -154,27 +158,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 +193,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 +248,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 +279,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 +291,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 +304,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 +316,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 +341,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 +365,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 +388,7 @@ decl_module! { } } + #[weight = 10_000_000] // TODO: adjust weight pub fn add_screened_member( origin, new_member_account: T::AccountId, @@ -385,7 +403,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 +419,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 +451,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 +463,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 +478,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 +491,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 +499,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 +525,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" @@ -569,7 +588,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 +597,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 +606,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..4d630a57b2 100644 --- a/runtime-modules/membership/src/mock.rs +++ b/runtime-modules/membership/src/mock.rs @@ -2,19 +2,25 @@ pub use crate::{GenesisConfig, Trait, DEFAULT_PAID_TERM_ID}; pub use common::currency::GovernanceCurrency; -pub use srml_support::traits::Currency; +pub use frame_support::traits::Currency; +use frame_support::{impl_outer_origin, parameter_types}; 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 primitives::{Blake2Hasher, H256}; +// pub use sr_primitives::{ +// testing::{Digest, DigestItem, Header, UintAuthorityId}, +// traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize}, +// weights::Weight, +// BuildStorage, Perbill, +// }; + +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 {} } @@ -31,10 +37,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,9 +50,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 = (); } impl timestamp::Trait for Test { @@ -56,27 +71,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 +108,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 +132,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); }); From 76e5b2b2d6aeba51b6957982729e608b41a20f84 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 20 Jul 2020 19:01:43 +0300 Subject: [PATCH 12/56] =?UTF-8?q?runtime:=20Update=20the=20=E2=80=98mockal?= =?UTF-8?q?l=E2=80=99=20dependency.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime-modules/hiring/Cargo.toml | 2 +- runtime-modules/proposals/engine/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime-modules/hiring/Cargo.toml b/runtime-modules/hiring/Cargo.toml index 43e49d5961..9bc13958b6 100755 --- a/runtime-modules/hiring/Cargo.toml +++ b/runtime-modules/hiring/Cargo.toml @@ -15,7 +15,7 @@ sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https:// stake = { package = 'pallet-stake', default-features = false, path = '../stake'} [dev-dependencies] -mockall = "0.6.0" +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'} diff --git a/runtime-modules/proposals/engine/Cargo.toml b/runtime-modules/proposals/engine/Cargo.toml index 552887ccda..6c7b2a6e08 100644 --- a/runtime-modules/proposals/engine/Cargo.toml +++ b/runtime-modules/proposals/engine/Cargo.toml @@ -96,7 +96,7 @@ package = 'substrate-common-module' path = '../../common' [dev-dependencies] -mockall = "0.6.0" +mockall = "0.7.1" [dev-dependencies.runtime-io] default_features = false From ee13b237f0b5a8a8c32868a25d7e0935721ad331 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 20 Jul 2020 19:28:57 +0300 Subject: [PATCH 13/56] runtime: Remove unused dependencies in the membership pallet. --- Cargo.lock | 1 - runtime-modules/membership/Cargo.toml | 2 -- runtime-modules/membership/src/genesis.rs | 1 - runtime-modules/membership/src/lib.rs | 1 - runtime-modules/membership/src/mock.rs | 15 ++++----------- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13c2ede796..42fa55e9e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1036,7 +1036,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", ] [[package]] diff --git a/runtime-modules/membership/Cargo.toml b/runtime-modules/membership/Cargo.toml index e3707decec..f5521592ed 100644 --- a/runtime-modules/membership/Cargo.toml +++ b/runtime-modules/membership/Cargo.toml @@ -7,7 +7,6 @@ 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'] } -rstd = { 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'} @@ -25,7 +24,6 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', 'frame-support/std', 'system/std', 'sp-arithmetic/std', 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 967fe00cde..7e9e96ccdf 100644 --- a/runtime-modules/membership/src/lib.rs +++ b/runtime-modules/membership/src/lib.rs @@ -12,7 +12,6 @@ mod tests; use codec::{Codec, Decode, Encode}; use frame_support::traits::Currency; use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; -use rstd::borrow::ToOwned; use sp_arithmetic::traits::{BaseArithmetic, One}; use sp_runtime::traits::{MaybeSerialize, Member}; use system::{self, ensure_root, ensure_signed}; diff --git a/runtime-modules/membership/src/mock.rs b/runtime-modules/membership/src/mock.rs index 4d630a57b2..53a86ffdcf 100644 --- a/runtime-modules/membership/src/mock.rs +++ b/runtime-modules/membership/src/mock.rs @@ -1,25 +1,18 @@ #![cfg(test)] pub use crate::{GenesisConfig, Trait, DEFAULT_PAID_TERM_ID}; -pub use common::currency::GovernanceCurrency; + pub use frame_support::traits::Currency; use frame_support::{impl_outer_origin, parameter_types}; -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 sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; +pub use system; + +pub use common::currency::GovernanceCurrency; impl_outer_origin! { pub enum Origin for Test {} From 11d0e82ffbfe20026b2e58113c3fbe96f39995a2 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 21 Jul 2020 13:35:54 +0300 Subject: [PATCH 14/56] runtime: Upgrade forum pallet. --- Cargo.lock | 16 ++++ Cargo.toml | 2 +- runtime-modules/forum/Cargo.toml | 56 ++++---------- runtime-modules/forum/src/lib.rs | 120 +++++++++++++---------------- runtime-modules/forum/src/mock.rs | 58 +++++++------- runtime-modules/forum/src/tests.rs | 2 +- 6 files changed, 120 insertions(+), 134 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42fa55e9e0..01c1074efd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1003,6 +1003,22 @@ dependencies = [ "sp-runtime", ] +[[package]] +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", +] + [[package]] name = "pallet-hiring" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index a0ab514644..7427e787be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ # "runtime-modules/proposals/discussion", "runtime-modules/common", # "runtime-modules/content-working-group", -# "runtime-modules/forum", + "runtime-modules/forum", # "runtime-modules/governance", "runtime-modules/hiring", "runtime-modules/membership", diff --git a/runtime-modules/forum/Cargo.toml b/runtime-modules/forum/Cargo.toml index c13cf7f3ba..7d44aaa710 100755 --- a/runtime-modules/forum/Cargo.toml +++ b/runtime-modules/forum/Cargo.toml @@ -1,56 +1,32 @@ [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'} +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', + 'sp-arithmetic/std', + 'sp-runtime/std', '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..517291621c 100755 --- a/runtime-modules/forum/src/lib.rs +++ b/runtime-modules/forum/src/lib.rs @@ -7,14 +7,16 @@ #![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}; mod mock; mod tests; @@ -264,7 +266,7 @@ pub trait Trait: system::Trait + timestamp::Trait + Sized { /// Thread Id type type ThreadId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -274,7 +276,7 @@ pub trait Trait: system::Trait + timestamp::Trait + Sized { /// Post Id type type PostId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -286,59 +288,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 +365,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 +391,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 +471,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 +535,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 +579,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 +631,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 +669,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 +717,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 +762,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 +770,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 +778,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 +786,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 +794,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 +802,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 +830,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 +855,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 +869,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 +891,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 +903,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 +920,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 +938,7 @@ impl Module { category_id: CategoryId, ) -> Result, &'static str> { ensure!( - >::exists(&category_id), + >::contains_key(&category_id), ERROR_CATEGORY_DOES_NOT_EXIST ); @@ -990,7 +980,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..cef68390db 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,22 +70,30 @@ 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 { @@ -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); @@ -516,7 +520,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!!!! From 0a3edf3f8d28db15e42731f55d242866ddd97bbc Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 21 Jul 2020 14:56:16 +0300 Subject: [PATCH 15/56] runtime: Upgrade governance pallet. --- Cargo.lock | 21 ++++ Cargo.toml | 2 +- runtime-modules/governance/Cargo.toml | 117 +++++------------- runtime-modules/governance/src/council.rs | 51 ++++---- runtime-modules/governance/src/election.rs | 116 ++++++++++------- .../governance/src/election_params.rs | 15 ++- runtime-modules/governance/src/lib.rs | 4 + runtime-modules/governance/src/mock.rs | 46 +++---- runtime-modules/governance/src/sealed_vote.rs | 2 +- runtime-modules/governance/src/stake.rs | 14 +-- 10 files changed, 193 insertions(+), 195 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 01c1074efd..03583a0e6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1019,6 +1019,27 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-governance" +version = "3.0.0" +dependencies = [ + "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 = "pallet-hiring" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index 7427e787be..065ee15979 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ "runtime-modules/common", # "runtime-modules/content-working-group", "runtime-modules/forum", -# "runtime-modules/governance", + "runtime-modules/governance", "runtime-modules/hiring", "runtime-modules/membership", "runtime-modules/memo", diff --git a/runtime-modules/governance/Cargo.toml b/runtime-modules/governance/Cargo.toml index 40653e9894..3e71d6b4b5 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'] } +rstd = { 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'} +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', + 'frame-support/std', + 'system/std', + 'sp-arithmetic/std', + 'sp-runtime/std', + '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..9327c4604c 100644 --- a/runtime-modules/governance/src/council.rs +++ b/runtime-modules/governance/src/council.rs @@ -1,6 +1,5 @@ -use rstd::prelude::*; -use sr_primitives::traits::{One, Zero}; -use srml_support::{debug, decl_event, decl_module, decl_storage, ensure}; +use frame_support::{debug, decl_event, decl_module, decl_storage, ensure}; +use sp_arithmetic::traits::{One, Zero}; use system::{self, ensure_root}; pub use super::election::{self, CouncilElected, Seat, Seats}; @@ -29,28 +28,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 +128,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 +165,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 +190,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 +211,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 +231,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 +240,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 +290,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 +376,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..832aef6e65 100644 --- a/runtime-modules/governance/src/election.rs +++ b/runtime-modules/governance/src/election.rs @@ -29,17 +29,17 @@ // 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}; +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; +use frame_support::traits::{Currency, ReservableCurrency}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; use rstd::collections::btree_map::BTreeMap; use rstd::ops::Add; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; -use sr_primitives::traits::{Hash, Zero}; +use sp_arithmetic::traits::Zero; +use sp_runtime::traits::Hash; +use system::{self, ensure_root, ensure_signed}; use super::sealed_vote::SealedVote; use super::stake::Stake; @@ -48,6 +48,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 +134,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 +243,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(), @@ -618,7 +623,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 +645,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 +687,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 +705,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 +720,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 +752,7 @@ impl Module { SealedVote::new(voter.clone(), vote_stake, commitment), ); - if >::exists(&voter) { + if >::contains_key(&voter) { >::insert(&voter, transferable_stake); } @@ -752,8 +764,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 +776,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 +814,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 +829,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 +838,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 +857,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 +876,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 +902,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 +910,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 +930,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 +957,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 +1370,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 +1458,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 +1660,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 +1832,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 +2121,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..58b33c623a 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,9 +41,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 = (); } impl timestamp::Trait for Test { @@ -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..b8ee99fb8f 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 frame_support::ensure; use rstd::vec::Vec; -use srml_support::ensure; #[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..e165c5fae2 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; #[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 { From 04439934aff98d421a02932ac1b52408c3f85bf5 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 22 Jul 2020 11:39:45 +0300 Subject: [PATCH 16/56] runtime: Upgrade the content-working group pallet. --- Cargo.lock | 25 +++ Cargo.toml | 2 +- .../content-working-group/Cargo.toml | 157 ++++------------ .../content-working-group/src/genesis.rs | 62 +------ .../content-working-group/src/lib.rs | 168 ++++++++++-------- .../content-working-group/src/mock.rs | 67 +++---- .../content-working-group/src/mod.rs | 6 - .../content-working-group/src/tests.rs | 139 ++++++++------- 8 files changed, 268 insertions(+), 358 deletions(-) delete mode 100644 runtime-modules/content-working-group/src/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 03583a0e6a..b888bf022f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1003,6 +1003,31 @@ dependencies = [ "sp-runtime", ] +[[package]] +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 = "pallet-forum" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index 065ee15979..3c64462e46 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = [ # "runtime-modules/proposals/codex", # "runtime-modules/proposals/discussion", "runtime-modules/common", -# "runtime-modules/content-working-group", + "runtime-modules/content-working-group", "runtime-modules/forum", "runtime-modules/governance", "runtime-modules/hiring", diff --git a/runtime-modules/content-working-group/Cargo.toml b/runtime-modules/content-working-group/Cargo.toml index d7066ab24b..c267857cf3 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'] } +rstd = { 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'} +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', + 'rstd/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..b1fc85e741 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 rstd::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..05a39595fe 100755 --- a/runtime-modules/content-working-group/src/lib.rs +++ b/runtime-modules/content-working-group/src/lib.rs @@ -20,14 +20,10 @@ 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 frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; +use sp_arithmetic::traits::{One, Zero}; use system::{self, ensure_root, ensure_signed}; use common::constraints::InputValidationLengthConstraint; @@ -42,8 +38,6 @@ pub trait Trait: + versioned_store_permissions::Trait + membership::Trait { - // + Sized - /// The event type. type Event: From> + Into<::Event>; } @@ -93,6 +87,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 +716,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 +764,6 @@ impl Default for WorkingGroupUnstaker { // can this be made generic, or does that undermine the whole orhpan rule spirit? pub error: E, @@ -783,7 +772,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) }}; } @@ -974,83 +965,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 +1066,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 +1092,7 @@ decl_module! { */ /// Create a new channel. + #[weight = 10_000_000] // TODO: adjust weight pub fn create_channel( origin, owner: T::MemberId, @@ -1187,6 +1179,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 +1204,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 +1262,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 +1292,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 +1340,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 +1367,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 +1394,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 +1413,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 +1554,7 @@ decl_module! { } + #[weight = 10_000_000] // TODO: adjust weight pub fn withdraw_curator_application( origin, curator_application_id: CuratorApplicationId @@ -1591,6 +1591,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 +1622,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 +1711,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 +1739,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 +1771,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 +1793,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 +1825,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 +1842,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 +1864,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 +1874,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 +1882,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 +1900,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 +1912,6 @@ decl_module! { )); } } - } } } @@ -1910,7 +1919,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 +1959,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 +1997,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 +2048,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 +2057,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 +2076,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 +2088,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 +2100,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 +2112,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 +2120,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 +2128,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 +2140,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 +2207,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 +2233,7 @@ impl Module { &'static str, > { ensure!( - CuratorById::::exists(curator_id), + CuratorById::::contains_key(curator_id), MSG_CURATOR_DOES_NOT_EXIST ); @@ -2237,7 +2246,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 +2362,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 +2433,7 @@ impl Module { WithdrawReasons::all(), new_balance, ) + .map_err(<&str>::from) } } else { Ok(()) @@ -2613,7 +2623,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..ff8193a20e 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,24 +75,31 @@ 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 { @@ -107,20 +109,11 @@ impl timestamp::Trait for Test { } 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..866d76732c 100644 --- a/runtime-modules/content-working-group/src/tests.rs +++ b/runtime-modules/content-working-group/src/tests.rs @@ -2,19 +2,27 @@ 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 frame_support::{assert_err, assert_ok, traits::Currency, StorageValue}; +use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; +use sp_arithmetic::traits::One; +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 From 5663eeff6c9239575a23537803172c4783cabc4e Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 22 Jul 2020 12:49:08 +0300 Subject: [PATCH 17/56] runtime: Convert working-group lib and errors. --- Cargo.lock | 23 +++ Cargo.toml | 2 +- runtime-modules/working-group/Cargo.toml | 137 ++++--------- runtime-modules/working-group/src/errors.rs | 90 +++++---- runtime-modules/working-group/src/lib.rs | 203 +++++++++++--------- 5 files changed, 226 insertions(+), 229 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b888bf022f..48eec2aef0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1204,6 +1204,29 @@ dependencies = [ "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 = "parity-scale-codec" version = "1.3.1" diff --git a/Cargo.toml b/Cargo.toml index 3c64462e46..794c6794b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ members = [ "runtime-modules/token-minting", "runtime-modules/versioned-store", "runtime-modules/versioned-store-permissions", -# "runtime-modules/working-group", + "runtime-modules/working-group", # "node", # "utils/chain-spec-builder/" ] diff --git a/runtime-modules/working-group/Cargo.toml b/runtime-modules/working-group/Cargo.toml index 97284ebb61..3b5c3f4935 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'] } +rstd = { 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'} +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', + 'serde', '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 + '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..7a17a5af35 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> + rstd::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> rstd::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> rstd::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> rstd::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> rstd::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> rstd::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> + rstd::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> rstd::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> + rstd::convert::From>> + for Error { fn from(wrapper: WrappedError>) -> Self { match wrapper.error { @@ -554,10 +573,10 @@ impl rstd::convert::From, I: Instance> rstd::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> + rstd::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> + rstd::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> + rstd::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> rstd::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..00b0161950 100644 --- a/runtime-modules/working-group/src/lib.rs +++ b/runtime-modules/working-group/src/lib.rs @@ -52,14 +52,13 @@ mod types; #[macro_use] mod errors; -use rstd::collections::btree_map::BTreeMap; -use rstd::collections::btree_set::BTreeSet; -use rstd::prelude::*; +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 rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; 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 sp_arithmetic::traits::{Bounded, One, Zero}; use system::{ensure_root, ensure_signed}; use crate::types::ExitInitiationOrigin; @@ -283,45 +282,48 @@ 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; @@ -346,7 +348,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 +356,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 +384,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 +416,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 +450,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 +473,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 +511,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 +567,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 +594,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 +614,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 +625,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 +689,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 +703,7 @@ decl_module! { // Ensure that signer is applicant role account ensure!( signer_account == application.role_account_id, - Error::OriginIsNotApplicant + Error::::OriginIsNotApplicant ); // @@ -714,6 +725,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 +757,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 +783,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 +800,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 +816,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 +842,7 @@ decl_module! { ensure!( number_of_successful_applications == num_provided_successful_application_ids, - Error::SuccessfulWorkerApplicationDoesNotExist + Error::::SuccessfulWorkerApplicationDoesNotExist ); // Attempt to fill opening @@ -839,7 +853,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 +887,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 +895,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 +918,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 +947,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 +973,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 +983,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 +1010,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 +1023,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 +1046,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 +1096,7 @@ impl, I: Instance> Module { { ensure!( application_rationing_policy.max_active_applicants > 0, - Error::ApplicationRationingPolicyMaxActiveApplicantsIsZero + Error::::ApplicationRationingPolicyMaxActiveApplicantsIsZero ); } @@ -1088,7 +1106,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 +1122,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 +1136,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 +1193,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 +1204,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 +1231,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 +1246,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 +1256,6 @@ impl, I: Instance> Module { WithdrawReasons::all(), new_balance, ) - .map_err(|e| Error::Other(e)) } } else { Ok(()) @@ -1247,10 +1264,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 +1281,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 +1291,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 +1310,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 +1340,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 +1378,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 +1419,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 From d2f8283529ac95d51452f4c84d7d5d1f6f951d17 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 22 Jul 2020 14:09:08 +0300 Subject: [PATCH 18/56] runtime: Upgrade working-group pallet tests. --- .../working-group/src/tests/fixtures.rs | 59 +-- .../src/tests/hiring_workflow.rs | 11 +- .../working-group/src/tests/mock.rs | 54 ++- .../working-group/src/tests/mod.rs | 456 ++++++++++++++---- 4 files changed, 424 insertions(+), 156 deletions(-) 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..4a7984d590 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 { @@ -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() }); From 1b734fb8e30e5339ffac2a1403316c669b307cd4 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 22 Jul 2020 15:27:07 +0300 Subject: [PATCH 19/56] =?UTF-8?q?runtime:=20Upgrade=20the=20=E2=80=98stora?= =?UTF-8?q?ge=E2=80=99=20pallet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 24 +++ Cargo.toml | 2 +- runtime-modules/storage/Cargo.toml | 137 ++++-------------- runtime-modules/storage/src/data_directory.rs | 62 ++++---- .../src/data_object_storage_registry.rs | 55 +++---- .../storage/src/data_object_type_registry.rs | 59 ++++---- .../storage/src/tests/data_directory.rs | 36 ++++- .../src/tests/data_object_storage_registry.rs | 13 +- .../src/tests/data_object_type_registry.rs | 86 +++++++++-- runtime-modules/storage/src/tests/mock.rs | 73 ++++++---- 10 files changed, 282 insertions(+), 265 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 48eec2aef0..950fbb65ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1142,6 +1142,30 @@ dependencies = [ "sp-std", ] +[[package]] +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 = "pallet-timestamp" version = "2.0.0-rc4" diff --git a/Cargo.toml b/Cargo.toml index 794c6794b5..a425c5d967 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ members = [ "runtime-modules/recurring-reward", # "runtime-modules/service-discovery", "runtime-modules/stake", -# "runtime-modules/storage", + "runtime-modules/storage", "runtime-modules/token-minting", "runtime-modules/versioned-store", "runtime-modules/versioned-store-permissions", diff --git a/runtime-modules/storage/Cargo.toml b/runtime-modules/storage/Cargo.toml index a978681e80..096ad14ec5 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'] } +rstd = { 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'} +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', + 'rstd/std', + 'frame-support/std', + 'system/std', + 'sp-arithmetic/std', + 'sp-runtime/std', 'membership/std', + '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..b310f6e746 100644 --- a/runtime-modules/storage/src/data_directory.rs +++ b/runtime-modules/storage/src/data_directory.rs @@ -22,11 +22,11 @@ //#![warn(missing_docs)] use codec::{Decode, Encode}; +use frame_support::dispatch::DispatchResult; +use frame_support::traits::Get; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; 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 sp_runtime::traits::{MaybeSerialize, Member}; use system::{self, ensure_root}; use common::origin::ActorOriginValidator; @@ -64,7 +64,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 +85,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 { @@ -163,11 +144,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 +186,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 +208,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 +236,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 +255,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 +272,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 +290,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 +318,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 +358,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..3d0cf7df9e 100644 --- a/runtime-modules/storage/src/data_object_storage_registry.rs +++ b/runtime-modules/storage/src/data_object_storage_registry.rs @@ -23,14 +23,15 @@ //#![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 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: @@ -45,7 +46,7 @@ pub trait Trait: /// Type for data object storage relationship id type DataObjectStorageRelationshipId: Parameter + Member - + SimpleArithmetic + + BaseArithmetic + Codec + Default + Copy @@ -58,7 +59,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 +74,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 +91,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 +136,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 +179,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 +190,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 +207,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..6972a64ffc 100644 --- a/runtime-modules/storage/src/data_object_type_registry.rs +++ b/runtime-modules/storage/src/data_object_type_registry.rs @@ -22,14 +22,17 @@ // 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 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 +42,7 @@ pub trait Trait: system::Trait + working_group::Trait { /// Data Object Type with the given ID not found. DataObjectTypeNotFound, @@ -58,25 +61,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 +83,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 +119,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 +156,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 +175,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 +193,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 +213,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..5cc5df24b2 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 frame_support::dispatch::DispatchError; use rstd::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..1cb0c60cba 100644 --- a/runtime-modules/storage/src/tests/data_object_type_registry.rs +++ b/runtime-modules/storage/src/tests/data_object_type_registry.rs @@ -1,9 +1,10 @@ #![cfg(test)] -use super::mock::*; -use srml_support::{StorageLinkedMap, StorageValue}; +use frame_support::{StorageMap, StorageValue}; use system::{self, EventRecord, Phase, RawOrigin}; +use super::mock::*; + const DEFAULT_LEADER_ACCOUNT_ID: u64 = 1; const DEFAULT_LEADER_MEMBER_ID: u64 = 1; const DEFAULT_LEADER_WORKER_ID: u32 = 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..eb37f592ac 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,9 +110,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 timestamp::Trait for Test { @@ -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()); + } +} From 60d672d296eeb8cdac221938b930c244b422bd36 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 22 Jul 2020 18:15:45 +0300 Subject: [PATCH 20/56] =?UTF-8?q?runtime:=20Upgrade=20=E2=80=98service-dis?= =?UTF-8?q?covery=E2=80=99=20pallet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 22 +++ Cargo.toml | 2 +- runtime-modules/service-discovery/Cargo.toml | 132 ++++-------------- runtime-modules/service-discovery/src/lib.rs | 21 +-- runtime-modules/service-discovery/src/mock.rs | 37 ++--- .../service-discovery/src/tests.rs | 27 ++-- 6 files changed, 98 insertions(+), 143 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 950fbb65ad..0bca6f8698 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1126,6 +1126,28 @@ dependencies = [ "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", +] + [[package]] name = "pallet-stake" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index a425c5d967..6d40c4c926 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ "runtime-modules/membership", "runtime-modules/memo", "runtime-modules/recurring-reward", -# "runtime-modules/service-discovery", + "runtime-modules/service-discovery", "runtime-modules/stake", "runtime-modules/storage", "runtime-modules/token-minting", diff --git a/runtime-modules/service-discovery/Cargo.toml b/runtime-modules/service-discovery/Cargo.toml index 2be3b58a24..17de6aea0d 100644 --- a/runtime-modules/service-discovery/Cargo.toml +++ b/runtime-modules/service-discovery/Cargo.toml @@ -1,112 +1,36 @@ [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'] } +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'} +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', + '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..d9237cc387 100644 --- a/runtime-modules/service-discovery/src/lib.rs +++ b/runtime-modules/service-discovery/src/lib.rs @@ -23,12 +23,11 @@ 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 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) @@ -79,14 +78,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; + pub AccountInfoByStorageProviderId get(fn account_info_by_storage_provider_id): + map hasher(blake2_128_concat) StorageProviderId => AccountInfo; /// Lifetime of an AccountInfo record in AccountInfoByAccountId map - pub DefaultLifetime get(default_lifetime) config(): + pub DefaultLifetime get(fn default_lifetime) config(): T::BlockNumber = T::BlockNumber::from(DEFAULT_LIFETIME); } } @@ -117,6 +116,7 @@ decl_module! { /// Creates the AccountInfo 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, @@ -140,12 +140,13 @@ decl_module! { /// Deletes the AccountInfo 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 +155,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 +167,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 +181,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..5cb94d7b15 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 { @@ -143,7 +146,7 @@ impl timestamp::Trait for Test { 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..9982943527 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,7 +21,7 @@ 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); @@ -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,6 +63,9 @@ 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( @@ -74,7 +76,7 @@ fn unset_ipns_id() { }, ); - 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 )); }); @@ -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, ""); From 37a9008bdb8119fb600ea8ed4b5220255c1a880b Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 22 Jul 2020 18:20:43 +0300 Subject: [PATCH 21/56] =?UTF-8?q?runtime:=20Remove=20=E2=80=98*=E2=80=99?= =?UTF-8?q?=20reference=20from=20the=20=E2=80=98use=E2=80=99=20clauses.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime-modules/content-working-group/src/lib.rs | 2 +- runtime-modules/content-working-group/src/tests.rs | 2 +- runtime-modules/governance/src/council.rs | 2 +- runtime-modules/governance/src/election.rs | 2 +- runtime-modules/membership/src/lib.rs | 2 +- runtime-modules/memo/src/lib.rs | 2 +- runtime-modules/recurring-reward/src/lib.rs | 2 +- runtime-modules/storage/src/data_directory.rs | 2 +- runtime-modules/storage/src/tests/data_object_type_registry.rs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime-modules/content-working-group/src/lib.rs b/runtime-modules/content-working-group/src/lib.rs index 05a39595fe..1165725d04 100755 --- a/runtime-modules/content-working-group/src/lib.rs +++ b/runtime-modules/content-working-group/src/lib.rs @@ -24,7 +24,7 @@ use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use sp_arithmetic::traits::{One, Zero}; -use system::{self, ensure_root, ensure_signed}; +use system::{ensure_root, ensure_signed}; use common::constraints::InputValidationLengthConstraint; diff --git a/runtime-modules/content-working-group/src/tests.rs b/runtime-modules/content-working-group/src/tests.rs index 866d76732c..521d5cde42 100644 --- a/runtime-modules/content-working-group/src/tests.rs +++ b/runtime-modules/content-working-group/src/tests.rs @@ -1,7 +1,7 @@ #![cfg(test)] use super::genesis; -use super::mock::{self, *}; +use super::mock::*; use frame_support::{assert_err, assert_ok, traits::Currency, StorageValue}; use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; diff --git a/runtime-modules/governance/src/council.rs b/runtime-modules/governance/src/council.rs index 9327c4604c..be6421b419 100644 --- a/runtime-modules/governance/src/council.rs +++ b/runtime-modules/governance/src/council.rs @@ -1,6 +1,6 @@ use frame_support::{debug, decl_event, decl_module, decl_storage, ensure}; use sp_arithmetic::traits::{One, Zero}; -use system::{self, ensure_root}; +use system::ensure_root; pub use super::election::{self, CouncilElected, Seat, Seats}; pub use common::currency::{BalanceOf, GovernanceCurrency}; diff --git a/runtime-modules/governance/src/election.rs b/runtime-modules/governance/src/election.rs index 832aef6e65..beb4b5f0ae 100644 --- a/runtime-modules/governance/src/election.rs +++ b/runtime-modules/governance/src/election.rs @@ -39,7 +39,7 @@ use rstd::collections::btree_map::BTreeMap; use rstd::ops::Add; use sp_arithmetic::traits::Zero; use sp_runtime::traits::Hash; -use system::{self, ensure_root, ensure_signed}; +use system::{ensure_root, ensure_signed}; use super::sealed_vote::SealedVote; use super::stake::Stake; diff --git a/runtime-modules/membership/src/lib.rs b/runtime-modules/membership/src/lib.rs index 7e9e96ccdf..145a62c2da 100644 --- a/runtime-modules/membership/src/lib.rs +++ b/runtime-modules/membership/src/lib.rs @@ -14,7 +14,7 @@ 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 system::{self, ensure_root, ensure_signed}; +use system::{ensure_root, ensure_signed}; use common::currency::{BalanceOf, GovernanceCurrency}; diff --git a/runtime-modules/memo/src/lib.rs b/runtime-modules/memo/src/lib.rs index 7c831a0a00..c1b62e9719 100644 --- a/runtime-modules/memo/src/lib.rs +++ b/runtime-modules/memo/src/lib.rs @@ -4,7 +4,7 @@ use frame_support::traits::Currency; use frame_support::{decl_event, decl_module, decl_storage, ensure}; use sp_arithmetic::traits::Zero; -use system::{self, ensure_signed}; +use system::ensure_signed; use common::currency::GovernanceCurrency; diff --git a/runtime-modules/recurring-reward/src/lib.rs b/runtime-modules/recurring-reward/src/lib.rs index ebdc157407..a9fe50ccda 100755 --- a/runtime-modules/recurring-reward/src/lib.rs +++ b/runtime-modules/recurring-reward/src/lib.rs @@ -14,7 +14,7 @@ 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; diff --git a/runtime-modules/storage/src/data_directory.rs b/runtime-modules/storage/src/data_directory.rs index b310f6e746..222abd12ab 100644 --- a/runtime-modules/storage/src/data_directory.rs +++ b/runtime-modules/storage/src/data_directory.rs @@ -27,7 +27,7 @@ use frame_support::traits::Get; use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; use rstd::collections::btree_map::BTreeMap; use sp_runtime::traits::{MaybeSerialize, Member}; -use system::{self, ensure_root}; +use system::ensure_root; use common::origin::ActorOriginValidator; pub(crate) use common::BlockAndTime; 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 1cb0c60cba..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,7 +1,7 @@ #![cfg(test)] use frame_support::{StorageMap, StorageValue}; -use system::{self, EventRecord, Phase, RawOrigin}; +use system::{EventRecord, Phase, RawOrigin}; use super::mock::*; From 8977b6207311e3fad934ef9b750ae66e2d6fb0f4 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 23 Jul 2020 12:38:10 +0300 Subject: [PATCH 22/56] runtime: Upgrade proposals engine pallet (without tests). --- Cargo.lock | 55 ++++++++ Cargo.toml | 2 +- runtime-modules/proposals/engine/Cargo.toml | 119 ++++------------ runtime-modules/proposals/engine/src/lib.rs | 132 ++++++++++-------- .../proposals/engine/src/types/mod.rs | 9 +- .../proposals/engine/src/types/stakes.rs | 3 +- 6 files changed, 168 insertions(+), 152 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bca6f8698..0f712be88d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -271,6 +271,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "derivative" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive_more" version = "0.99.9" @@ -964,6 +975,28 @@ dependencies = [ "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", + "quote", + "syn", +] + [[package]] name = "once_cell" version = "1.4.0" @@ -1111,6 +1144,28 @@ dependencies = [ "sp-arithmetic", ] +[[package]] +name = "pallet-proposals-engine" +version = "3.0.0" +dependencies = [ + "frame-support", + "frame-system", + "mockall", + "num_enum", + "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 = "pallet-recurring-reward" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index 6d40c4c926..a5847b16b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = [ # "runtime", -# "runtime-modules/proposals/engine", + "runtime-modules/proposals/engine", # "runtime-modules/proposals/codex", # "runtime-modules/proposals/discussion", "runtime-modules/common", diff --git a/runtime-modules/proposals/engine/Cargo.toml b/runtime-modules/proposals/engine/Cargo.toml index 6c7b2a6e08..7aefdf443e 100644 --- a/runtime-modules/proposals/engine/Cargo.toml +++ b/runtime-modules/proposals/engine/Cargo.toml @@ -1,105 +1,46 @@ [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'] } +rstd = { 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'} +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', + 'rstd/std', + 'frame-support/std', + 'system/std', + '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' diff --git a/runtime-modules/proposals/engine/src/lib.rs b/runtime-modules/proposals/engine/src/lib.rs index 37e2a624f0..ecd53ed2d6 100644 --- a/runtime-modules/proposals/engine/src/lib.rs +++ b/runtime-modules/proposals/engine/src/lib.rs @@ -109,6 +109,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,17 +127,17 @@ 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, Dispatchable}; +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 rstd::prelude::*; +use sp_arithmetic::traits::Zero; use system::{ensure_root, RawOrigin}; -use crate::types::ApprovedProposalData; use common::origin::ActorOriginValidator; -use srml_support::dispatch::Dispatchable; type MemberId = ::MemberId; @@ -180,7 +181,9 @@ 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 + + Dispatchable + + Default; } decl_event!( @@ -216,7 +219,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 +267,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 +306,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 +327,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 +356,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 +375,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 +427,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 +491,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 +527,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 +545,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 +576,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 +596,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 +648,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(T::Origin::from(RawOrigin::Root)) + { + ApprovedProposalStatus::failed_execution(Self::parse_dispatch_error( + dispatch_error.error, + )) } else { ApprovedProposalStatus::Executed } @@ -756,7 +762,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 +799,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/types/mod.rs b/runtime-modules/proposals/engine/src/types/mod.rs index d6ad1a8c73..a202fe6e91 100644 --- a/runtime-modules/proposals/engine/src/types/mod.rs +++ b/runtime-modules/proposals/engine/src/types/mod.rs @@ -6,13 +6,12 @@ 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; mod proposal_statuses; mod stakes; @@ -304,7 +303,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/stakes.rs b/runtime-modules/proposals/engine/src/types/stakes.rs index 88a378981b..dfe1743bb0 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 frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; use rstd::convert::From; use rstd::marker::PhantomData; use rstd::rc::Rc; -use srml_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; // Mocking dependencies for testing #[cfg(test)] @@ -123,6 +123,7 @@ impl StakeHandler for DefaultStakeHandler { WithdrawReasons::all(), ExistenceRequirement::AllowDeath, ) + .map_err(<&str>::from) } } From 3ea62179252f507564e2fc3a23e5d68d161bf8b5 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 23 Jul 2020 13:48:00 +0300 Subject: [PATCH 23/56] runtime: Upgrade proposals engine pallet - restore tests. --- Cargo.lock | 34 --- runtime-modules/proposals/engine/Cargo.toml | 4 - runtime-modules/proposals/engine/src/lib.rs | 18 +- .../engine/src/tests/mock/balance_manager.rs | 4 +- .../proposals/engine/src/tests/mock/mod.rs | 39 ++-- .../engine/src/tests/mock/proposals.rs | 5 +- .../proposals/engine/src/tests/mod.rs | 205 ++++++++++-------- .../engine/src/types/proposal_statuses.rs | 1 - 8 files changed, 146 insertions(+), 164 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f712be88d..96e84bb0c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -271,17 +271,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "derivative" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "derive_more" version = "0.99.9" @@ -975,28 +964,6 @@ dependencies = [ "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", - "quote", - "syn", -] - [[package]] name = "once_cell" version = "1.4.0" @@ -1151,7 +1118,6 @@ dependencies = [ "frame-support", "frame-system", "mockall", - "num_enum", "pallet-balances", "pallet-common", "pallet-membership", diff --git a/runtime-modules/proposals/engine/Cargo.toml b/runtime-modules/proposals/engine/Cargo.toml index 7aefdf443e..4ccb551f73 100644 --- a/runtime-modules/proposals/engine/Cargo.toml +++ b/runtime-modules/proposals/engine/Cargo.toml @@ -39,8 +39,4 @@ std = [ 'common/std', ] -[dependencies.num_enum] -default_features = false -version = "0.4.2" - diff --git a/runtime-modules/proposals/engine/src/lib.rs b/runtime-modules/proposals/engine/src/lib.rs index ecd53ed2d6..f23b6079d9 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(()) //! } //! } //! } @@ -127,13 +128,12 @@ pub(crate) mod types; mod tests; use codec::Decode; -use frame_support::dispatch::{DispatchError, DispatchResult, Dispatchable}; +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 rstd::prelude::*; use sp_arithmetic::traits::Zero; use system::{ensure_root, RawOrigin}; @@ -181,9 +181,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!( @@ -649,7 +647,7 @@ impl Module { let approved_proposal_status = match proposal_code_result { Ok(proposal_code) => { if let Err(dispatch_error) = - proposal_code.dispatch(T::Origin::from(RawOrigin::Root)) + proposal_code.dispatch_bypass_filter(T::Origin::from(RawOrigin::Root)) { ApprovedProposalStatus::failed_execution(Self::parse_dispatch_error( dispatch_error.error, 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..39af79f61f 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,9 +152,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 timestamp::Trait for Test { @@ -172,7 +171,7 @@ impl timestamp::Trait for Test { 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..45fe1f9234 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 frame_support::decl_module; use rstd::vec::Vec; -use srml_support::decl_module; 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/mod.rs b/runtime-modules/proposals/engine/src/tests/mod.rs index 5cdc3ec0e0..b330d4c0cd 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 frame_support::dispatch::DispatchResult; +use frame_support::traits::{Currency, OnFinalize, OnInitialize}; +use frame_support::{StorageDoubleMap, StorageMap, StorageValue}; use rstd::rc::Rc; -use sr_primitives::traits::{DispatchResult, OnFinalize, OnInitialize}; -use srml_support::{StorageDoubleMap, StorageMap, StorageValue}; 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/proposal_statuses.rs b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs index 4deb8b647d..577011f679 100644 --- a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs +++ b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs @@ -1,7 +1,6 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; -use rstd::prelude::*; use crate::ActiveStake; #[cfg(feature = "std")] From aa8d5ed4e078f34ed92820f8c975c690550d23ed Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 23 Jul 2020 14:26:54 +0300 Subject: [PATCH 24/56] runtime: Upgrade the discussion pallet. --- Cargo.lock | 18 +++ Cargo.toml | 2 +- .../proposals/discussion/Cargo.toml | 109 ++++-------------- .../proposals/discussion/src/lib.rs | 74 +++++------- .../proposals/discussion/src/tests/mock.rs | 45 +++++--- .../proposals/discussion/src/tests/mod.rs | 60 ++++++---- .../proposals/discussion/src/types.rs | 2 - 7 files changed, 140 insertions(+), 170 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96e84bb0c0..e58fe2bf46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1111,6 +1111,24 @@ dependencies = [ "sp-arithmetic", ] +[[package]] +name = "pallet-proposals-discussion" +version = "3.0.0" +dependencies = [ + "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 = "pallet-proposals-engine" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index a5847b16b7..8f4fef46d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [ # "runtime", "runtime-modules/proposals/engine", # "runtime-modules/proposals/codex", -# "runtime-modules/proposals/discussion", + "runtime-modules/proposals/discussion", "runtime-modules/common", "runtime-modules/content-working-group", "runtime-modules/forum", diff --git a/runtime-modules/proposals/discussion/Cargo.toml b/runtime-modules/proposals/discussion/Cargo.toml index c5bad3b951..448516431e 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'] } +rstd = { 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'} +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', + 'rstd/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..cae76e55ac 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 frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::traits::Get; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; 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 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..3f47d7bc44 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,9 +118,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 timestamp::Trait for Test { @@ -132,7 +137,7 @@ impl timestamp::Trait for Test { 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..cbcc65ccf1 100644 --- a/runtime-modules/proposals/discussion/src/types.rs +++ b/runtime-modules/proposals/discussion/src/types.rs @@ -4,8 +4,6 @@ use codec::{Decode, Encode}; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use rstd::prelude::*; - /// Represents a discussion thread #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] #[derive(Encode, Decode, Default, Clone, PartialEq, Eq)] From 08f7a20bacbac14a1144ddb43a2e9713fea02dd0 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 23 Jul 2020 20:20:18 +0300 Subject: [PATCH 25/56] runtime: Upgrade codex pallet. --- Cargo.lock | 158 +++++++++++++ Cargo.toml | 2 +- runtime-modules/proposals/codex/Cargo.toml | 216 ++++-------------- runtime-modules/proposals/codex/src/lib.rs | 209 ++++++++--------- .../proposals/codex/src/tests/mock.rs | 117 +++++++--- .../proposals/codex/src/tests/mod.rs | 106 ++++----- 6 files changed, 437 insertions(+), 371 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e58fe2bf46..209c90f3f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -979,14 +979,31 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "pallet-authorship" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-authorship", + "sp-inherents", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-balances" 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", + "serde", "sp-runtime", "sp-std", ] @@ -1111,6 +1128,39 @@ dependencies = [ "sp-arithmetic", ] +[[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 = "pallet-proposals-discussion" version = "3.0.0" @@ -1187,6 +1237,26 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-session" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "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 = "pallet-stake" version = "3.0.0" @@ -1203,6 +1273,37 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-staking" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "serde", + "sp-application-crypto", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-staking", + "sp-std", + "static_assertions", +] + +[[package]] +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", + "syn", +] + [[package]] name = "pallet-storage" version = "3.0.0" @@ -1975,6 +2076,17 @@ dependencies = [ "sp-std", ] +[[package]] +name = "sp-authorship" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-inherents", + "sp-runtime", + "sp-std", +] + [[package]] name = "sp-core" version = "2.0.0-rc4" @@ -2071,6 +2183,29 @@ dependencies = [ "sp-wasm-interface", ] +[[package]] +name = "sp-npos-elections" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-npos-elections-compact", + "sp-std", +] + +[[package]] +name = "sp-npos-elections-compact" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sp-panic-handler" version = "2.0.0-rc4" @@ -2129,6 +2264,29 @@ dependencies = [ "syn", ] +[[package]] +name = "sp-session" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-core", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +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" diff --git a/Cargo.toml b/Cargo.toml index 8f4fef46d7..087e9f5ffc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = [ # "runtime", "runtime-modules/proposals/engine", -# "runtime-modules/proposals/codex", + "runtime-modules/proposals/codex", "runtime-modules/proposals/discussion", "runtime-modules/common", "runtime-modules/content-working-group", diff --git a/runtime-modules/proposals/codex/Cargo.toml b/runtime-modules/proposals/codex/Cargo.toml index 3e21b4a616..5ad25de8ae 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'] } +rstd = { 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'} +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', + 'frame-support/std', + 'sp-arithmetic/std', + 'sp-runtime/std', 'system/std', - 'timestamp/std', 'staking/std', - 'serde', - 'proposal_engine/std', - 'proposal_discussion/std', - 'stake/std', + '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 15f63cebf5..6c6c63cd82 100644 --- a/runtime-modules/proposals/codex/src/lib.rs +++ b/runtime-modules/proposals/codex/src/lib.rs @@ -65,20 +65,20 @@ mod proposal_types; #[cfg(test)] mod tests; -use common::origin::ActorOriginValidator; -use common::working_group::WorkingGroup; -use governance::election_params::ElectionParameters; -use proposal_engine::ProposalParameters; +use frame_support::dispatch::DispatchResult; +use frame_support::traits::{Currency, Get}; +use frame_support::{decl_error, decl_module, decl_storage, ensure, print}; 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 sp_arithmetic::traits::Zero; use system::ensure_root; +use common::origin::ActorOriginValidator; +use common::working_group::WorkingGroup; +use governance::election_params::ElectionParameters; +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/tests/mock.rs b/runtime-modules/proposals/codex/src/tests/mock.rs index 540f4af846..1b09acd3b2 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,52 @@ 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; + +/* + type Currency = Balances; + type UnixTime = Timestamp; + type CurrencyToVote = CurrencyToVoteHandler; + type RewardRemainder = RewardRemainderMock; + type Event = MetaEvent; + type Slash = (); + type Reward = (); + type SessionsPerEra = SessionsPerEra; + type SlashDeferDuration = SlashDeferDuration; + type SlashCancelOrigin = frame_system::EnsureRoot; + type BondingDuration = BondingDuration; + type SessionInterface = Self; + type RewardCurve = RewardCurve; + type NextNewSession = Session; + type ElectionLookahead = ElectionLookahead; + type Call = Call; + type MaxIterations = MaxIterations; + type MinSolutionScoreBump = MinSolutionScoreBump; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type UnsignedPriority = UnsignedPriority; +*/ + impl staking::SessionInterface for Test { fn disable_validator(_: &u64) -> Result { unimplemented!() @@ -250,10 +281,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,9 +294,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 = (); } impl timestamp::Trait for Test { @@ -273,7 +313,7 @@ impl timestamp::Trait for Test { 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 +321,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 = 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 ff010cc2a9..e5c5c49676 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()) ); }); } @@ -1066,7 +1068,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()) ); }); } @@ -1292,7 +1294,7 @@ fn slash_stake_with_zero_staking_balance_fails() { 0, WorkingGroup::Storage, ), - Err(Error::SlashingStakeIsZero) + Err(Error::::SlashingStakeIsZero.into()) ); }); } @@ -1320,7 +1322,7 @@ fn decrease_stake_with_zero_staking_balance_fails() { 0, WorkingGroup::Storage, ), - Err(Error::DecreasingStakeIsZero) + Err(Error::::DecreasingStakeIsZero.into()) ); }); } From 25143d23f3b86b21358fc3a75217e5ecca4418e3 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 24 Jul 2020 15:10:18 +0300 Subject: [PATCH 26/56] runtime: Upgrade the runtime crate (successful compilation). --- Cargo.lock | 1491 ++++++++++++++++- Cargo.toml | 2 +- runtime/Cargo.toml | 596 +++---- .../src/integration/content_working_group.rs | 14 +- .../integration/proposals/proposal_encoder.rs | 8 +- .../proposals/staking_events_handler.rs | 6 +- runtime/src/integration/storage.rs | 2 +- runtime/src/integration/working_group.rs | 6 +- runtime/src/lib.rs | 513 ++++-- runtime/src/migration.rs | 71 +- 10 files changed, 2082 insertions(+), 627 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 209c90f3f2..5f83e1abf6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,6 +39,12 @@ dependencies = [ "num-traits", ] +[[package]] +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" @@ -69,6 +75,61 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +[[package]] +name = "asn1_der" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fce6b6a0ffdafebd82c87e79e3f40e8d2c523e5fea5566ff6b90509bf98d638" +dependencies = [ + "asn1_der_derive", +] + +[[package]] +name = "asn1_der_derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" +dependencies = [ + "quote", + "syn", +] + +[[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 = "autocfg" version = "0.1.7" @@ -141,6 +202,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" @@ -162,6 +245,26 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "broadcaster" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c972e21e0d055a36cf73e4daae870941fe7a8abcd5ac3396aab9e4c126bd87" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "futures-util", + "parking_lot 0.10.0", + "slab", +] + +[[package]] +name = "bs58" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" + [[package]] name = "bumpalo" version = "3.2.1" @@ -186,6 +289,12 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + [[package]] name = "cc" version = "1.0.50" @@ -242,6 +351,53 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "crossbeam-channel" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg 1.0.0", + "cfg-if", + "crossbeam-utils", + "lazy_static", + "maybe-uninit", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg 1.0.0", + "cfg-if", + "lazy_static", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -271,6 +427,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "data-encoding" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72aa14c04dfae8dd7d8a2b1cb7ca2152618cd01336dbfe704b8dcbf8d41dbd69" + [[package]] name = "derive_more" version = "0.99.9" @@ -355,6 +517,21 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "finality-grandpa" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8feb87a63249689640ac9c011742c33139204e3c134293d3054022276869133b" +dependencies = [ + "either", + "futures", + "futures-timer 2.0.2", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot 0.9.0", +] + [[package]] name = "fixed-hash" version = "0.6.1" @@ -367,6 +544,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "fixedbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" + [[package]] name = "float-cmp" version = "0.6.0" @@ -376,6 +559,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "fragile" version = "1.0.0" @@ -399,6 +588,20 @@ dependencies = [ "sp-std", ] +[[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", + "sp-io", + "sp-runtime", + "sp-std", + "sp-tracing", +] + [[package]] name = "frame-metadata" version = "11.0.0-rc4" @@ -484,12 +687,37 @@ dependencies = [ "sp-version", ] +[[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 = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + [[package]] name = "futures" version = "0.3.4" @@ -563,6 +791,18 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" +[[package]] +name = "futures-timer" +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 = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + [[package]] name = "futures-util" version = "0.3.4" @@ -602,6 +842,25 @@ dependencies = [ "wasi", ] +[[package]] +name = "h2" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hash-db" version = "0.15.2" @@ -627,6 +886,24 @@ dependencies = [ "autocfg 0.1.7", ] +[[package]] +name = "hashbrown" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +dependencies = [ + "autocfg 1.0.0", +] + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "hermit-abi" version = "0.1.10" @@ -663,6 +940,67 @@ dependencies = [ "hmac", ] +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "hyper" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e68a8dd9716185d9e64ea473ea6ef63529252e3e27623295a0378a19665d5eb" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project", + "time", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "impl-codec" version = "0.4.2" @@ -701,12 +1039,40 @@ dependencies = [ "syn", ] +[[package]] +name = "indexmap" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" +dependencies = [ + "autocfg 1.0.0", + "hashbrown 0.8.1", +] + [[package]] name = "integer-sqrt" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itertools" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.9.0" @@ -716,6 +1082,74 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + +[[package]] +name = "joystream-node-runtime" +version = "7.0.0" +dependencies = [ + "frame-executive", + "frame-support", + "frame-system", + "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-indices", + "pallet-membership", + "pallet-memo", + "pallet-offences", + "pallet-proposals-codex", + "pallet-proposals-discussion", + "pallet-proposals-engine", + "pallet-randomness-collective-flip", + "pallet-recurring-reward", + "pallet-service-discovery", + "pallet-session", + "pallet-stake", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-storage", + "pallet-sudo", + "pallet-timestamp", + "pallet-token-mint", + "pallet-transaction-payment", + "pallet-versioned-store", + "pallet-versioned-store-permissions", + "pallet-working-group", + "parity-scale-codec", + "serde", + "sp-api", + "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", +] + [[package]] name = "js-sys" version = "0.3.37" @@ -731,6 +1165,25 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "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 = "lazy_static" version = "1.4.0" @@ -749,6 +1202,85 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" +[[package]] +name = "libp2p" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "057eba5432d3e740e313c6e13c9153d0cb76b4f71bfc2e5242ae5bdb7d41af67" +dependencies = [ + "bytes", + "futures", + "lazy_static", + "libp2p-core", + "libp2p-core-derive", + "libp2p-swarm", + "multihash", + "parity-multiaddr", + "parking_lot 0.10.0", + "pin-project", + "smallvec 1.4.1", + "wasm-timer", +] + +[[package]] +name = "libp2p-core" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a0387b930c3d4c2533dc4893c1e0394185ddcc019846121b1b27491e45a2c08" +dependencies = [ + "asn1_der", + "bs58", + "ed25519-dalek", + "either", + "fnv", + "futures", + "futures-timer 3.0.2", + "lazy_static", + "libsecp256k1", + "log", + "multihash", + "multistream-select", + "parity-multiaddr", + "parking_lot 0.10.0", + "pin-project", + "prost", + "prost-build", + "rand 0.7.3", + "ring", + "rw-stream-sink", + "sha2", + "smallvec 1.4.1", + "thiserror", + "unsigned-varint 0.4.0", + "void", + "zeroize", +] + +[[package]] +name = "libp2p-core-derive" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09548626b737ed64080fde595e06ce1117795b8b9fc4d2629fa36561c583171" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "libp2p-swarm" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce53ff4d127cf8b39adf84dbd381ca32d49bd85788cee08e6669da2495993930" +dependencies = [ + "futures", + "libp2p-core", + "log", + "rand 0.7.3", + "smallvec 1.4.1", + "void", + "wasm-timer", +] + [[package]] name = "libsecp256k1" version = "0.3.5" @@ -794,6 +1326,21 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0609345ddee5badacf857d4f547e0e5a2e987db77085c24cd887f73573a04237" +dependencies = [ + "hashbrown 0.6.3", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + [[package]] name = "matrixmultiply" version = "0.2.3" @@ -815,6 +1362,15 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +[[package]] +name = "memoffset" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" +dependencies = [ + "autocfg 1.0.0", +] + [[package]] name = "memory-db" version = "0.21.0" @@ -823,7 +1379,7 @@ checksum = "fb2999ff7a65d5a1d72172f6d51fa2ea03024b51aee709ba5ff81c3c629a2410" dependencies = [ "ahash", "hash-db", - "hashbrown", + "hashbrown 0.6.3", "parity-util-mem", ] @@ -845,6 +1401,48 @@ dependencies = [ "zeroize", ] +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +dependencies = [ + "cfg-if", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-uds" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +dependencies = [ + "iovec", + "libc", + "mio", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + [[package]] name = "mockall" version = "0.7.1" @@ -872,6 +1470,41 @@ dependencies = [ "syn", ] +[[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", + "sha-1", + "sha2", + "sha3", + "unsigned-varint 0.3.3", +] + +[[package]] +name = "multimap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8883adfde9756c1d30b0f519c9b8c502a94b41ac62f696453c37c7fc0a958ce" + +[[package]] +name = "multistream-select" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9157e87afbc2ef0d84cc0345423d715f445edde00141c93721c162de35a05e5" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec 1.4.1", + "unsigned-varint 0.4.0", +] + [[package]] name = "nalgebra" version = "0.18.1" @@ -889,6 +1522,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "net2" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.8", +] + [[package]] name = "nodrop" version = "0.1.14" @@ -979,6 +1623,22 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "pallet-authority-discovery" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "pallet-session", + "parity-scale-codec", + "serde", + "sp-application-crypto", + "sp-authority-discovery", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-authorship" version = "2.0.0-rc4" @@ -994,6 +1654,28 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-babe" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "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 = "pallet-balances" version = "2.0.0-rc4" @@ -1008,6 +1690,21 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-collective" +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-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-common" version = "3.0.0" @@ -1045,6 +1742,22 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-finality-tracker" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "serde", + "sp-finality-tracker", + "sp-inherents", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-forum" version = "3.0.0" @@ -1082,6 +1795,26 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-grandpa" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "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 = "pallet-hiring" version = "3.0.0" @@ -1093,9 +1826,44 @@ dependencies = [ "pallet-stake", "parity-scale-codec", "serde", - "sp-arithmetic", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-im-online" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "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 = "pallet-indices" +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-core", "sp-io", + "sp-keyring", "sp-runtime", "sp-std", ] @@ -1128,6 +1896,20 @@ dependencies = [ "sp-arithmetic", ] +[[package]] +name = "pallet-offences" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "parity-scale-codec", + "sp-runtime", + "sp-staking", + "sp-std", +] + [[package]] name = "pallet-proposals-codex" version = "3.0.0" @@ -1200,6 +1982,19 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-randomness-collective-flip" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "safe-mix", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-recurring-reward" version = "3.0.0" @@ -1328,6 +2123,20 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-sudo" +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", +] + [[package]] name = "pallet-timestamp" version = "2.0.0-rc4" @@ -1359,6 +2168,32 @@ dependencies = [ "sp-runtime", ] +[[package]] +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", + "smallvec 1.4.1", + "sp-runtime", + "sp-std", +] + +[[package]] +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", + "sp-api", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-versioned-store" version = "3.0.0" @@ -1413,6 +2248,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "parity-multiaddr" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc20af3143a62c16e7c9e92ea5c6ae49f7d271d97d4d8fe73afc28f0514a3d0f" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint 0.4.0", + "url", +] + [[package]] name = "parity-scale-codec" version = "1.3.1" @@ -1449,7 +2302,7 @@ dependencies = [ "parity-util-mem-derive", "parking_lot 0.10.0", "primitive-types", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1502,7 +2355,7 @@ dependencies = [ "redox_syscall", "rustc_version", "smallvec 0.6.13", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1516,7 +2369,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec 1.4.1", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1551,6 +2404,48 @@ dependencies = [ "crypto-mac", ] +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" + [[package]] name = "pin-utils" version = "0.1.0-alpha.4" @@ -1634,6 +2529,77 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "prometheus" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0575e258dab62268e7236d7307caa38848acbda7ec7ab87bd9093791e999d20" +dependencies = [ + "cfg-if", + "fnv", + "lazy_static", + "protobuf", + "spin", + "thiserror", +] + +[[package]] +name = "prost" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce49aefe0a6144a45de32927c77bd2859a5f7677b55f220ae5b744e87389c212" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26" +dependencies = [ + "bytes", + "heck", + "itertools 0.8.2", + "log", + "multimap", + "petgraph", + "prost", + "prost-types", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72" +dependencies = [ + "anyhow", + "itertools 0.8.2", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1834f67c0697c001304b75be76f67add9c89742eda3a085ad8ee0bb38c3417aa" +dependencies = [ + "bytes", + "prost", +] + +[[package]] +name = "protobuf" +version = "2.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d883f78645c21b7281d21305181aa1f4dd9e9363e7cf2566c93121552cff003e" + [[package]] name = "quote" version = "1.0.3" @@ -1659,7 +2625,7 @@ dependencies = [ "fuchsia-cprng", "libc", "rand_core 0.3.1", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1678,7 +2644,7 @@ dependencies = [ "rand_os", "rand_pcg 0.1.2", "rand_xorshift", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1774,7 +2740,7 @@ checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" dependencies = [ "libc", "rand_core 0.4.2", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1788,7 +2754,7 @@ dependencies = [ "libc", "rand_core 0.4.2", "rdrand", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1878,6 +2844,15 @@ version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "rental" version = "0.5.5" @@ -1899,6 +2874,20 @@ dependencies = [ "syn", ] +[[package]] +name = "ring" +version = "0.16.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" +dependencies = [ + "cc", + "libc", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.8", +] + [[package]] name = "rustc-demangle" version = "0.1.16" @@ -1926,6 +2915,26 @@ dependencies = [ "semver", ] +[[package]] +name = "rw-stream-sink" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + +[[package]] +name = "safe-mix" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" +dependencies = [ + "rustc_version", +] + [[package]] name = "schnorrkel" version = "0.9.1" @@ -1991,6 +3000,18 @@ dependencies = [ "syn", ] +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + [[package]] name = "sha2" version = "0.8.1" @@ -2003,6 +3024,19 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sha3" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" +dependencies = [ + "block-buffer", + "byte-tools", + "digest", + "keccak", + "opaque-debug", +] + [[package]] name = "slab" version = "0.4.2" @@ -2031,58 +3065,152 @@ source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478 dependencies = [ "hash-db", "parity-scale-codec", - "sp-api-proc-macro", - "sp-core", + "sp-api-proc-macro", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-version", +] + +[[package]] +name = "sp-api-proc-macro" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "blake2-rfc", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-application-crypto" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-arithmetic" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-authority-discovery" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-application-crypto", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-authorship" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-inherents", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-block-builder" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-inherents", "sp-runtime", - "sp-state-machine", "sp-std", - "sp-version", ] [[package]] -name = "sp-api-proc-macro" +name = "sp-blockchain" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "blake2-rfc", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", + "derive_more", + "log", + "lru", + "parity-scale-codec", + "parking_lot 0.10.0", + "sp-block-builder", + "sp-consensus", + "sp-runtime", + "sp-state-machine", ] [[package]] -name = "sp-application-crypto" -version = "2.0.0-rc4" +name = "sp-consensus" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "derive_more", + "futures", + "futures-timer 3.0.2", + "libp2p", + "log", "parity-scale-codec", + "parking_lot 0.10.0", "serde", "sp-core", - "sp-io", + "sp-inherents", + "sp-runtime", + "sp-state-machine", "sp-std", + "sp-utils", + "sp-version", + "substrate-prometheus-endpoint", + "wasm-timer", ] [[package]] -name = "sp-arithmetic" -version = "2.0.0-rc4" +name = "sp-consensus-babe" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "integer-sqrt", - "num-traits", + "merlin", "parity-scale-codec", - "serde", - "sp-debug-derive", + "sp-api", + "sp-application-crypto", + "sp-consensus", + "sp-consensus-vrf", + "sp-core", + "sp-inherents", + "sp-runtime", "sp-std", + "sp-timestamp", ] [[package]] -name = "sp-authorship" -version = "2.0.0-rc4" +name = "sp-consensus-vrf" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "parity-scale-codec", - "sp-inherents", + "schnorrkel", + "sp-core", "sp-runtime", "sp-std", ] @@ -2150,6 +3278,32 @@ dependencies = [ "sp-storage", ] +[[package]] +name = "sp-finality-grandpa" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "finality-grandpa", + "log", + "parity-scale-codec", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-finality-tracker" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-inherents", + "sp-std", +] + [[package]] name = "sp-inherents" version = "2.0.0-rc4" @@ -2183,6 +3337,17 @@ dependencies = [ "sp-wasm-interface", ] +[[package]] +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" @@ -2206,6 +3371,16 @@ dependencies = [ "syn", ] +[[package]] +name = "sp-offchain" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "sp-api", + "sp-core", + "sp-runtime", +] + [[package]] name = "sp-panic-handler" version = "2.0.0-rc4" @@ -2293,7 +3468,7 @@ version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "hash-db", - "itertools", + "itertools 0.9.0", "log", "num-traits", "parity-scale-codec", @@ -2349,6 +3524,22 @@ dependencies = [ "tracing", ] +[[package]] +name = "sp-transaction-pool" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "futures", + "log", + "parity-scale-codec", + "serde", + "sp-api", + "sp-blockchain", + "sp-runtime", + "sp-utils", +] + [[package]] name = "sp-trie" version = "2.0.0-rc4" @@ -2363,6 +3554,18 @@ dependencies = [ "trie-root", ] +[[package]] +name = "sp-utils" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "futures", + "futures-core", + "futures-timer 3.0.2", + "lazy_static", + "prometheus", +] + [[package]] name = "sp-version" version = "2.0.0-rc4" @@ -2386,6 +3589,12 @@ dependencies = [ "wasmi", ] +[[package]] +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" @@ -2407,6 +3616,27 @@ dependencies = [ "rand 0.5.6", ] +[[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", + "syn", +] + [[package]] name = "substrate-bip39" version = "0.4.1" @@ -2419,6 +3649,25 @@ dependencies = [ "sha2", ] +[[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", + "log", + "prometheus", + "tokio", +] + +[[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" @@ -2454,6 +3703,40 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if", + "libc", + "rand 0.7.3", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.8", +] + +[[package]] +name = "thiserror" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +dependencies = [ + "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", + "syn", +] + [[package]] name = "thread_local" version = "1.0.1" @@ -2463,6 +3746,17 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +dependencies = [ + "libc", + "redox_syscall", + "winapi 0.3.8", +] + [[package]] name = "tiny-bip39" version = "0.7.3" @@ -2488,6 +3782,33 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tokio" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "memchr", + "pin-project-lite", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.6" @@ -2497,6 +3818,12 @@ 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" @@ -2504,6 +3831,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2e2a2de6b0d5cbb13fc21193a2296888eaab62b6044479aafb3c54c01c29fcd" dependencies = [ "cfg-if", + "log", "tracing-attributes", "tracing-core", ] @@ -2541,7 +3869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb230c24c741993b04cfccbabb45acff6f6480c5f00d3ed8794ea43db3a9d727" dependencies = [ "hash-db", - "hashbrown", + "hashbrown 0.6.3", "log", "rustc-hex", "smallvec 1.4.1", @@ -2556,6 +3884,12 @@ dependencies = [ "hash-db", ] +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + [[package]] name = "twox-hash" version = "1.5.0" @@ -2583,6 +3917,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + [[package]] name = "unicode-normalization" version = "0.1.12" @@ -2592,12 +3935,63 @@ dependencies = [ "smallvec 1.4.1", ] +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +[[package]] +name = "unsigned-varint" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67332660eb59a6f1eb24ff1220c9e8d01738a8503c6002e30bcfe4bd9f2b4a9" + +[[package]] +name = "unsigned-varint" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "669d776983b692a906c881fcd0cfb34271a48e197e4d6cb8df32b05bfc3d3fa5" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +dependencies = [ + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[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" @@ -2719,6 +4113,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +dependencies = [ + "libc", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + [[package]] name = "winapi" version = "0.3.8" @@ -2729,6 +4138,12 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -2741,6 +4156,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "zeroize" version = "1.1.0" diff --git a/Cargo.toml b/Cargo.toml index 087e9f5ffc..7ed7a3c361 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = [ -# "runtime", + "runtime", "runtime-modules/proposals/engine", "runtime-modules/proposals/codex", "runtime-modules/proposals/discussion", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 026e080aed..e8c813c4d0 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -4,372 +4,282 @@ 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.20.0' +version = '7.0.0' + +[dependencies] +serde = { version = "1.0.101", optional = true, features = ["derive"] } +codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } +rstd = { 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'} +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'} +sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +#node-primitives = { package = 'node-primitives', 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-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-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'} +pallet-grandpa = { package = 'pallet-grandpa', 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'} +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-indices = { package = 'pallet-indices', 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-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'} + + +system = { package = 'frame-system', 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'} +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'} + +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'} + +[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', - 'codec/std', - 'substrate-client/std', +# 'authority-discovery-primitives/std', +# 'authority-discovery/std', +# 'authorship/std', +# 'finality-tracker/std', +# 'im-online/std', +# 'session/std', +# 'offences/std', +# 'sr-staking-primitives/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', + 'sp-io/std', + 'sp-core/std', + 'frame-support/std', + 'frame-system-rpc-runtime-api/std', + 'sp-authority-discovery/std', + 'sp-consensus-babe/std', + 'sp-block-builder/std', + 'sp-transaction-pool/std', + 'sp-offchain/std', + # 'node-primitives/std', + 'pallet-grandpa/std', + 'pallet-babe/std', + 'pallet-im-online/std', + 'pallet-indices/std', + 'pallet-authority-discovery/std', + 'pallet-collective/std', +# 'babe/std', +# 'babe-primitives/std', +# 'executive/std', +# 'indices/std', +# 'grandpa/std', +# 'primitives/std', +# 'sr-primitives/std', +# 'version/std', +# 'safe-mix/std', +# 'offchain-primitives/std', +# 'substrate-session/std', +# 'transaction-payment/std', +# 'randomness-collective-flip/std', +# 'system-rpc-runtime-api/std', + + + 'serde', + 'codec/std', + + 'pallet-staking/std', + 'pallet-balances/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', + 'pallet-sudo/std', + 'forum/std', 'minting/std', - 'recurringrewards/std', + 'recurring-rewards/std', 'stake/std', 'hiring/std', - 'versioned_store/std', - 'versioned_store_permissions/std', + 'versioned-store/std', + 'versioned-store-permissions/std', 'common/std', - 'content_working_group/std', + 'content-working-group/std', 'governance/std', 'membership/std', 'memo/std', - 'service_discovery/std', + 'service-discovery/std', 'storage/std', - 'proposals_engine/std', - 'proposals_discussion/std', - 'proposals_codex/std', + 'proposals-engine/std', + 'proposals-discussion/std', + 'proposals-codex/std', 'working-group/std', ] -# [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.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.substrate-client] +#default_features = false +#git = 'https://github.com/paritytech/substrate.git' +#package = 'substrate-client' +#rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' +# +#[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.safe-mix] +#default-features = false +#version = '1.0' +# +#[dependencies.substrate-session] +#default-features = false +#git = 'https://github.com/paritytech/substrate.git' +#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' +# -[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/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/proposals/proposal_encoder.rs b/runtime/src/integration/proposals/proposal_encoder.rs index f54ab2908b..0c61b778d1 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 frame_support::print; use rstd::collections::btree_set::BTreeSet; use rstd::marker::PhantomData; use rstd::vec::Vec; -use srml_support::print; // 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..32d1c81589 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 frame_support::traits::{Currency, Imbalance}; +use frame_support::StorageMap; use rstd::marker::PhantomData; -use srml_support::traits::{Currency, Imbalance}; -use srml_support::StorageMap; // 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..d92e0bf370 100644 --- a/runtime/src/integration/storage.rs +++ b/runtime/src/integration/storage.rs @@ -1,5 +1,5 @@ +use frame_support::traits::Randomness; use rstd::vec::Vec; -use srml_support::traits::Randomness; use crate::{ActorId, Runtime}; diff --git a/runtime/src/integration/working_group.rs b/runtime/src/integration/working_group.rs index 84d97e80f4..873ee4589f 100644 --- a/runtime/src/integration/working_group.rs +++ b/runtime/src/integration/working_group.rs @@ -1,5 +1,5 @@ +use frame_support::StorageMap; use rstd::marker::PhantomData; -use srml_support::{StorageLinkedMap, StorageMap}; 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 24257b1173..333cdad76f 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. @@ -17,65 +14,46 @@ mod tests; include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod integration; - -use authority_discovery_primitives::{ - AuthorityId as EncodedAuthorityId, Signature as EncodedSignature, +mod migration; +#[cfg(test)] +mod tests; // Runtime integration tests + +use frame_support::inherent::{CheckInherentsResult, InherentData}; +use frame_support::traits::KeyOwnerProofSystem; +use frame_support::weights::{IdentityFee, Weight}; +use frame_support::{ + construct_runtime, parameter_types, traits::Randomness, StorageMap, StorageValue, }; -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::{ +use pallet_grandpa::fg_primitives; +use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use sp_api::impl_runtime_apis; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_core::crypto::KeyTypeId; +use sp_core::OpaqueMetadata; +use sp_runtime::curve::PiecewiseLinear; +use sp_runtime::traits::{ BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, StaticLookup, Verify, }; -use sr_primitives::weights::Weight; -use sr_primitives::{ +use sp_runtime::transaction_validity::TransactionSource; +#[cfg(any(feature = "std", test))] +use sp_runtime::Perbill; +use sp_runtime::{ 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, + ApplyExtrinsicResult, MultiSignature, }; -use system::offchain::TransactionSubmitter; #[cfg(feature = "std")] -use version::NativeVersion; -use version::RuntimeVersion; - -// 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; +use sp_version::{NativeVersion, RuntimeVersion}; +use system::EnsureRoot; use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator}; -pub use proposals_codex::ProposalsConfigParameters; -pub use common; -pub use forum; -pub use working_group; - -pub use governance::election_params::ElectionParameters; +use content_working_group as content_wg; use governance::{council, election}; use storage::{data_directory, data_object_storage_registry, data_object_type_registry}; -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; +pub type ContentId = sp_core::H256; /// An index to a block. pub type BlockNumber = u32; @@ -98,7 +76,7 @@ pub type Balance = u128; pub type Index = u32; /// A hash of some data used by the chain. -pub type Hash = primitives::H256; +pub type Hash = sp_core::H256; /// Digest item type. pub type DigestItem = generic::DigestItem; @@ -135,7 +113,7 @@ pub type ActorId = u64; pub mod opaque { use super::*; - pub use sr_primitives::OpaqueExtrinsic as UncheckedExtrinsic; + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; /// Opaque block header type. pub type Header = generic::Header; @@ -163,6 +141,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_version: 20, impl_version: 0, apis: RUNTIME_API_VERSIONS, + transaction_version: 0, //TODO ?? }; /// Constants for Babe. @@ -246,32 +225,111 @@ impl system::Trait for Runtime { /// Portion of the block weight that is available to all normal transactions. type AvailableBlockRatio = AvailableBlockRatio; type Version = Version; + //TODO + type BaseCallFilter = (); + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); + type ModuleToIndex = (); + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); } +/* + type BaseCallFilter = (); + type Origin = Origin; + type Call = Call; + type Index = Index; + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = Indices; + type Header = generic::Header; + type Event = Event; + type BlockHashCount = BlockHashCount; + type MaximumBlockWeight = MaximumBlockWeight; + type DbWeight = RocksDbWeight; + type BlockExecutionWeight = BlockExecutionWeight; + type ExtrinsicBaseWeight = ExtrinsicBaseWeight; + type MaximumExtrinsicWeight = MaximumExtrinsicWeight; + type MaximumBlockLength = MaximumBlockLength; + type AvailableBlockRatio = AvailableBlockRatio; + type Version = Version; + type ModuleToIndex = ModuleToIndex; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); +*/ + parameter_types! { pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64; 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; + + //toDO + type Call = Call; + type KeyOwnerProofSystem = (); + + type KeyOwnerProof = + >::Proof; + + type KeyOwnerIdentification = >::IdentificationTuple; + + type HandleEquivocation = (); +} + +/* + type KeyOwnerProofSystem = Historical; + + type KeyOwnerProof = + >::Proof; + + type KeyOwnerIdentification = >::IdentificationTuple; + + type HandleEquivocation = pallet_grandpa::EquivocationHandler< + Self::KeyOwnerIdentification, + node_primitives::report::ReporterAppCrypto, + Runtime, + Offences, + >; + +*/ + +impl system::offchain::SendTransactionTypes for Runtime +where + Call: From, +{ + type Extrinsic = UncheckedExtrinsic; + type OverarchingCall = Call; } -impl indices::Trait for Runtime { +impl pallet_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 ResolveHint = pallet_indices::SimpleResolveHint; + type Currency = Balances; + //toDO + type Deposit = (); type Event = Event; } @@ -295,43 +353,44 @@ parameter_types! { pub const InitialMembersBalance: u32 = 2000; } -impl balances::Trait for Runtime { +impl pallet_balances::Trait for Runtime { /// The type for recording an account's balance. 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. + // /// 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 TransferPayment = (); type ExistentialDeposit = ExistentialDeposit; - type TransferFee = TransferFee; - type CreationFee = CreationFee; + // type TransferFee = TransferFee; + // type CreationFee = CreationFee; + type AccountStore = System; } -impl transaction_payment::Trait for Runtime { +impl pallet_transaction_payment::Trait for Runtime { type Currency = Balances; type OnTransactionPayment = (); - type TransactionBaseFee = TransactionBaseFee; + // type TransactionBaseFee = TransactionBaseFee; type TransactionByteFee = TransactionByteFee; - type WeightToFee = (); + type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); } -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; @@ -356,24 +415,38 @@ parameter_types! { pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); } -impl session::Trait for Runtime { - type OnSessionEnding = Staking; +/* +type Event = Event; +type ValidatorId = ::AccountId; +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 pallet_session::Trait for Runtime { + // type OnSessionEnding = Staking; type SessionHandler = SessionHandlers; type ShouldEndSession = Babe; type Event = Event; type Keys = SessionKeys; type ValidatorId = AccountId; - type ValidatorIdOf = staking::StashOf; - type SelectInitialValidators = Staking; + type ValidatorIdOf = pallet_staking::StashOf; + // type SelectInitialValidators = Staking; type DisabledValidatorsThreshold = DisabledValidatorsThreshold; + //TODO + type NextSessionRotation = (); + type SessionManager = (); } -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,14 +458,41 @@ srml_staking_reward_curve::build! { } parameter_types! { - pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6; - pub const BondingDuration: staking::EraIndex = 24; + pub const SessionsPerEra: sp_staking::SessionIndex = 6; + pub const BondingDuration: pallet_staking::EraIndex = 24; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; } -impl staking::Trait for Runtime { +/* type Currency = Balances; - type Time = Timestamp; + type UnixTime = Timestamp; + type CurrencyToVote = CurrencyToVoteHandler; + type RewardRemainder = Treasury; + type Event = Event; + type Slash = Treasury; // send the slashed funds to the treasury. + type Reward = (); // rewards are minted from the void + type SessionsPerEra = SessionsPerEra; + type BondingDuration = BondingDuration; + type SlashDeferDuration = SlashDeferDuration; + /// A super-majority of the council can cancel the slash. + type SlashCancelOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective> + >; + type SessionInterface = Self; + type RewardCurve = RewardCurve; + type NextNewSession = Session; + type ElectionLookahead = ElectionLookahead; + type Call = Call; + type MaxIterations = MaxIterations; + type MinSolutionScoreBump = MinSolutionScoreBump; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type UnsignedPriority = StakingUnsignedPriority; +*/ +impl pallet_staking::Trait for Runtime { + type Currency = Balances; + type UnixTime = Timestamp; type CurrencyToVote = common::currency::CurrencyToVoteHandler; type RewardRemainder = (); type Event = Event; @@ -400,41 +500,56 @@ impl staking::Trait for Runtime { type Reward = (); // rewards are minted from the void type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; + // TODO + type SlashDeferDuration = (); + type SlashCancelOrigin = EnsureRoot; type SessionInterface = Self; type RewardCurve = RewardCurve; + type NextNewSession = (); + type ElectionLookahead = (); + type Call = Call; + type MaxIterations = (); + type MinSolutionScoreBump = (); + type MaxNominatorRewardedPerValidator = (); + type UnsignedPriority = (); } -type SubmitTransaction = TransactionSubmitter; +//type SubmitTransaction = TransactionSubmitter; parameter_types! { pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _; } -impl im_online::Trait for Runtime { +/* + type AuthorityId = ImOnlineId; + type Event = Event; + type SessionDuration = SessionDuration; + type ReportUnresponsiveness = Offences; + type UnsignedPriority = ImOnlineUnsignedPriority; +*/ +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 UnsignedPriority = (); //ImOnlineUnsignedPriority; } -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; @@ -460,7 +575,7 @@ impl versioned_store_permissions::CredentialChecker for SudoKeyHasAllCr account: &AccountId, _credential: ::Credential, ) -> bool { - >::key() == *account + >::key() == *account } } @@ -470,7 +585,7 @@ impl versioned_store_permissions::CreateClassPermissionsChecker for SudoKeyCanCreateClasses { fn account_can_create_class_permissions(account: &AccountId) -> bool { - >::key() == *account + >::key() == *account } } @@ -513,7 +628,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 +657,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 { @@ -712,22 +827,22 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { // Substrate - System: system::{Module, Call, Storage, Config, Event}, - Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, + System: system::{Module, Call, Storage, Config, Event}, + Babe: pallet_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, + Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, + Indices: pallet_indices::{Module, Call, Storage, Config, Event}, + 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}, + 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}, @@ -739,7 +854,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,10 +865,10 @@ 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}, } ); @@ -769,23 +884,35 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( - system::CheckVersion, + system::CheckSpecVersion, + system::CheckTxVersion, system::CheckGenesis, system::CheckEra, system::CheckNonce, system::CheckWeight, - transaction_payment::ChargeTransactionPayment, + pallet_transaction_payment::ChargeTransactionPayment, ); + +/* + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, + pallet_grandpa::ValidateEquivocationReport, +*/ /// 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>; + frame_executive::Executive, Runtime, AllModules>; impl_runtime_apis! { - impl client_api::Core for Runtime { + impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { VERSION } @@ -799,14 +926,14 @@ impl_runtime_apis! { } } - impl client_api::Metadata for Runtime { + impl sp_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { Runtime::metadata().into() } } - impl block_builder_api::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyResult { + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } @@ -827,81 +954,129 @@ impl_runtime_apis! { } } - impl client_api::TaggedTransactionQueue for Runtime { - fn validate_transaction(tx: ::Extrinsic) -> TransactionValidity { - Executive::validate_transaction(tx) + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx) } } - impl offchain_primitives::OffchainWorkerApi for Runtime { - fn offchain_worker(number: NumberFor) { - Executive::offchain_worker(number) + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) } } - +//TODO impl fg_primitives::GrandpaApi for Runtime { - fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { + 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<()> { + None + } + + fn generate_key_ownership_proof( + _set_id: fg_primitives::SetId, + _authority_id: GrandpaId, + ) -> Option { + // NOTE: this is the only implementation possible since we've + // defined our key owner proof type as a bottom type (i.e. a type + // with no values). + None + } } - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { + 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. // - babe_primitives::BabeConfiguration { + sp_consensus_babe::BabeGenesisConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), c: PRIMARY_PROBABILITY, genesis_authorities: Babe::authorities(), randomness: Babe::randomness(), - secondary_slots: true, + allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, + //secondary_slots: true, //TODO + /* + 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, + */ } } - } - impl authority_discovery_primitives::AuthorityDiscoveryApi for Runtime { - fn authorities() -> Vec { - AuthorityDiscovery::authorities().into_iter() - .map(|id| id.encode()) - .map(EncodedAuthorityId) - .collect() + fn current_epoch_start() -> sp_consensus_babe::SlotNumber { + Babe::current_epoch_start() } + } - fn sign(payload: &Vec) -> Option<(EncodedSignature, EncodedAuthorityId)> { - AuthorityDiscovery::sign(payload).map(|(sig, id)| { - (EncodedSignature(sig.encode()), EncodedAuthorityId(id.encode())) - }) + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { + // fn authorities() -> Vec { + // AuthorityDiscovery::authorities().into_iter() + // .map(|id| id.encode()) + // .map(EncodedAuthorityId) + // .collect() + // } + fn authorities() -> Vec { + AuthorityDiscovery::authorities() } - 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) - } + // 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 { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { fn account_nonce(account: AccountId) -> Index { System::account_nonce(account) } } - impl substrate_session::SessionKeys for Runtime { + impl sp_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) + SessionKeys::generate(seed) + } + // 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) + // } + + fn decode_session_keys( + encoded: Vec, + ) -> Option, KeyTypeId)>> { + SessionKeys::decode_into_raw_public_keys(&encoded) } } } diff --git a/runtime/src/migration.rs b/runtime/src/migration.rs index 540028e0fc..64e527b541 100644 --- a/runtime/src/migration.rs +++ b/runtime/src/migration.rs @@ -2,12 +2,8 @@ #![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design use crate::VERSION; -use rstd::prelude::*; -use sr_primitives::{ - print, - traits::{One, Zero}, -}; -use srml_support::{debug, decl_event, decl_module, decl_storage}; +use frame_support::weights::Weight; +use frame_support::{debug, decl_event, decl_module, decl_storage}; impl Module { /// This method is called from on_initialize() when a runtime upgrade is detected. This @@ -21,12 +17,6 @@ impl Module { // 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_default_config_values(); } } @@ -47,8 +37,8 @@ decl_storage! { /// 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 + pub SpecVersion get(fn spec_version) build(|_config: &GenesisConfig| { + Some(VERSION.spec_version) }) : Option; } } @@ -63,7 +53,7 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; - fn on_initialize(_now: T::BlockNumber) { + fn on_initialize(_now: T::BlockNumber) -> Weight { 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); @@ -76,55 +66,10 @@ decl_module! { 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(); + 10_000_000 // TODO adjust weight } - - storage::data_object_storage_registry::NextRelationshipId::::kill(); - - // Clear storage data directory data. - for id in >::known_content_ids() { - >::remove(id); - } - - >::kill(); } } + +impl Module {} From d87f5c3890b7874e71779a8d4fe8eb5ee6ca129d Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 24 Jul 2020 15:36:47 +0300 Subject: [PATCH 27/56] runtime: Refactor runtime Cargo.toml --- Cargo.lock | 4 + runtime/Cargo.toml | 248 ++++++++++----------------------------------- 2 files changed, 60 insertions(+), 192 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f83e1abf6..da5f94566f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -596,6 +596,7 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec", + "serde", "sp-io", "sp-runtime", "sp-std", @@ -1905,6 +1906,7 @@ dependencies = [ "frame-system", "pallet-balances", "parity-scale-codec", + "serde", "sp-runtime", "sp-staking", "sp-std", @@ -2177,6 +2179,7 @@ dependencies = [ "frame-system", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", + "serde", "smallvec 1.4.1", "sp-runtime", "sp-std", @@ -2189,6 +2192,7 @@ source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478 dependencies = [ "frame-support", "parity-scale-codec", + "serde", "sp-api", "sp-runtime", "sp-std", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index e8c813c4d0..6219c86f06 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -7,14 +7,13 @@ name = 'joystream-node-runtime' 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 rstd = { 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'} -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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} -#node-primitives = { package = 'node-primitives', 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-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -23,11 +22,19 @@ sp-authority-discovery = { package = 'sp-authority-discovery', default-features 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'} -pallet-grandpa = { package = 'pallet-grandpa', 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'} + +# 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-indices = { package = 'pallet-indices', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -38,9 +45,6 @@ pallet-offences = { package = 'pallet-offences', default-features = false, git = 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'} - - -system = { package = 'frame-system', 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'} timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -48,6 +52,7 @@ pallet-balances = { package = 'pallet-balances', default-features = false, git = 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'} +# 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'} @@ -70,216 +75,75 @@ proposals-codex = { package = 'pallet-proposals-codex', default-features = false [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', -# 'substrate-client/std', + # Third-party dependencies + 'serde', + 'codec/std', + + # Substrate primitives 'rstd/std', 'sp-io/std', 'sp-core/std', - 'frame-support/std', - 'frame-system-rpc-runtime-api/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-block-builder/std', 'sp-transaction-pool/std', - 'sp-offchain/std', - # 'node-primitives/std', + 'sp-block-builder/std', + 'sp-session/std', + 'sp-staking/std', + + # Frame + 'frame-support/std', + 'frame-executive/std', + 'frame-system-rpc-runtime-api/std', + 'system/std', + + # Pallets + 'timestamp/std', + 'pallet-balances/std', + 'pallet-transaction-payment/std', 'pallet-grandpa/std', 'pallet-babe/std', - 'pallet-im-online/std', - 'pallet-indices/std', + 'pallet-session/std', + 'pallet-finality-tracker/std', 'pallet-authority-discovery/std', - 'pallet-collective/std', -# 'babe/std', -# 'babe-primitives/std', -# 'executive/std', -# 'indices/std', -# 'grandpa/std', -# 'primitives/std', -# 'sr-primitives/std', -# 'version/std', -# 'safe-mix/std', -# 'offchain-primitives/std', -# 'substrate-session/std', -# 'transaction-payment/std', -# 'randomness-collective-flip/std', -# 'system-rpc-runtime-api/std', - - - 'serde', - 'codec/std', - + 'pallet-authorship/std', + 'pallet-randomness-collective-flip/std', 'pallet-staking/std', - 'pallet-balances/std', - 'system/std', - 'timestamp/std', +# 'pallet-staking-reward-curve/std', // don't have 'std' features 'pallet-sudo/std', + 'pallet-indices/std', + 'pallet-im-online/std', + 'pallet-collective/std', + 'pallet-offences/std', + # Joystream + 'common/std', + 'memo/std', 'forum/std', - 'minting/std', - 'recurring-rewards/std', + 'membership/std', 'stake/std', + 'governance/std', 'hiring/std', + 'minting/std', + 'recurring-rewards/std', + 'working-group/std', + 'content-working-group/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', + 'service-discovery/std', 'proposals-engine/std', 'proposals-discussion/std', 'proposals-codex/std', - 'working-group/std', ] -#[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.substrate-client] -#default_features = false -#git = 'https://github.com/paritytech/substrate.git' -#package = 'substrate-client' -#rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8' -# -#[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.safe-mix] -#default-features = false -#version = '1.0' -# -#[dependencies.substrate-session] -#default-features = false -#git = 'https://github.com/paritytech/substrate.git' -#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' -# - - - - From a6ce0324eff5bb8938e842386c9fcb84cbbc0227 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 27 Jul 2020 01:10:59 +0300 Subject: [PATCH 28/56] runtime: Migrate runtime tests. --- Cargo.lock | 4 ++++ runtime-modules/content-working-group/src/lib.rs | 3 +++ runtime-modules/forum/Cargo.toml | 2 ++ runtime-modules/forum/src/lib.rs | 3 +++ runtime-modules/governance/src/council.rs | 2 ++ runtime-modules/governance/src/election.rs | 2 ++ runtime-modules/hiring/src/lib.rs | 1 + runtime-modules/membership/Cargo.toml | 2 ++ runtime-modules/membership/src/lib.rs | 3 +++ runtime-modules/memo/Cargo.toml | 2 ++ runtime-modules/memo/src/lib.rs | 1 + runtime-modules/proposals/discussion/src/types.rs | 1 + runtime-modules/proposals/engine/src/lib.rs | 1 + runtime-modules/proposals/engine/src/types/mod.rs | 3 ++- .../proposals/engine/src/types/proposal_statuses.rs | 5 +++-- runtime-modules/service-discovery/Cargo.toml | 2 ++ runtime-modules/service-discovery/src/lib.rs | 1 + runtime-modules/storage/src/data_directory.rs | 1 + .../storage/src/data_object_storage_registry.rs | 1 + .../storage/src/data_object_type_registry.rs | 1 + .../versioned-store-permissions/src/credentials.rs | 1 + .../versioned-store-permissions/src/lib.rs | 1 + .../versioned-store-permissions/src/operations.rs | 2 ++ runtime-modules/versioned-store/src/lib.rs | 2 ++ runtime-modules/working-group/src/lib.rs | 1 + runtime/Cargo.toml | 5 +++-- .../proposals/council_origin_validator.rs | 2 +- .../proposals/membership_origin_validator.rs | 4 ++-- runtime/src/lib.rs | 6 ++++-- runtime/src/tests/mod.rs | 2 +- runtime/src/tests/proposals_integration/mod.rs | 12 +++++++----- .../proposals_integration/working_group_proposals.rs | 1 - 32 files changed, 63 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da5f94566f..35611f7242 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1773,6 +1773,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-std", ] [[package]] @@ -1884,6 +1885,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-std", ] [[package]] @@ -1895,6 +1897,7 @@ dependencies = [ "pallet-common", "parity-scale-codec", "sp-arithmetic", + "sp-std", ] [[package]] @@ -2032,6 +2035,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-std", ] [[package]] diff --git a/runtime-modules/content-working-group/src/lib.rs b/runtime-modules/content-working-group/src/lib.rs index 1165725d04..b61df7cf87 100755 --- a/runtime-modules/content-working-group/src/lib.rs +++ b/runtime-modules/content-working-group/src/lib.rs @@ -23,6 +23,9 @@ use codec::{Decode, Encode}; use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; +use rstd::vec; +use rstd::vec::Vec; +use rstd::borrow::ToOwned; use sp_arithmetic::traits::{One, Zero}; use system::{ensure_root, ensure_signed}; diff --git a/runtime-modules/forum/Cargo.toml b/runtime-modules/forum/Cargo.toml index 7d44aaa710..d8b53b7b70 100755 --- a/runtime-modules/forum/Cargo.toml +++ b/runtime-modules/forum/Cargo.toml @@ -11,6 +11,7 @@ frame-support = { package = 'frame-support', default-features = false, git = 'ht 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'} +rstd = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} 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'} @@ -25,6 +26,7 @@ std = [ 'codec/std', 'frame-support/std', 'system/std', + 'rstd/std', 'sp-arithmetic/std', 'sp-runtime/std', 'timestamp/std', diff --git a/runtime-modules/forum/src/lib.rs b/runtime-modules/forum/src/lib.rs index 517291621c..44058dfacd 100755 --- a/runtime-modules/forum/src/lib.rs +++ b/runtime-modules/forum/src/lib.rs @@ -17,6 +17,9 @@ use codec::{Codec, Decode, Encode}; use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; use sp_arithmetic::traits::{BaseArithmetic, One}; use sp_runtime::traits::{MaybeSerialize, Member}; +use rstd::vec; +use rstd::vec::Vec; +use rstd::borrow::ToOwned; mod mock; mod tests; diff --git a/runtime-modules/governance/src/council.rs b/runtime-modules/governance/src/council.rs index be6421b419..5cd22564a6 100644 --- a/runtime-modules/governance/src/council.rs +++ b/runtime-modules/governance/src/council.rs @@ -1,6 +1,8 @@ use frame_support::{debug, decl_event, decl_module, decl_storage, ensure}; use sp_arithmetic::traits::{One, Zero}; use system::ensure_root; +use rstd::vec; +use rstd::vec::Vec; pub use super::election::{self, CouncilElected, Seat, Seats}; pub use common::currency::{BalanceOf, GovernanceCurrency}; diff --git a/runtime-modules/governance/src/election.rs b/runtime-modules/governance/src/election.rs index beb4b5f0ae..227bcc39a9 100644 --- a/runtime-modules/governance/src/election.rs +++ b/runtime-modules/governance/src/election.rs @@ -37,6 +37,8 @@ use frame_support::traits::{Currency, ReservableCurrency}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; use rstd::collections::btree_map::BTreeMap; use rstd::ops::Add; +use rstd::vec; +use rstd::vec::Vec; use sp_arithmetic::traits::Zero; use sp_runtime::traits::Hash; use system::{ensure_root, ensure_signed}; diff --git a/runtime-modules/hiring/src/lib.rs b/runtime-modules/hiring/src/lib.rs index c09eab0792..d5940fe334 100755 --- a/runtime-modules/hiring/src/lib.rs +++ b/runtime-modules/hiring/src/lib.rs @@ -33,6 +33,7 @@ use rstd::collections::btree_map::BTreeMap; use rstd::collections::btree_set::BTreeSet; use rstd::iter::Iterator; use rstd::rc::Rc; +use rstd::vec::Vec; use sp_arithmetic::traits::{BaseArithmetic, One, Zero}; use sp_runtime::traits::{MaybeSerialize, Member}; diff --git a/runtime-modules/membership/Cargo.toml b/runtime-modules/membership/Cargo.toml index f5521592ed..24e5e85ef0 100644 --- a/runtime-modules/membership/Cargo.toml +++ b/runtime-modules/membership/Cargo.toml @@ -7,6 +7,7 @@ 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'] } +rstd = { 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'} @@ -26,6 +27,7 @@ std = [ 'codec/std', 'frame-support/std', 'system/std', + 'rstd/std', 'sp-arithmetic/std', 'sp-runtime/std', 'timestamp/std', diff --git a/runtime-modules/membership/src/lib.rs b/runtime-modules/membership/src/lib.rs index 145a62c2da..4a5b3dcfea 100644 --- a/runtime-modules/membership/src/lib.rs +++ b/runtime-modules/membership/src/lib.rs @@ -15,6 +15,9 @@ use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; use sp_arithmetic::traits::{BaseArithmetic, One}; use sp_runtime::traits::{MaybeSerialize, Member}; use system::{ensure_root, ensure_signed}; +use rstd::vec; +use rstd::vec::Vec; +use rstd::borrow::ToOwned; use common::currency::{BalanceOf, GovernanceCurrency}; diff --git a/runtime-modules/memo/Cargo.toml b/runtime-modules/memo/Cargo.toml index 5179cde23e..738ed7ac2c 100644 --- a/runtime-modules/memo/Cargo.toml +++ b/runtime-modules/memo/Cargo.toml @@ -7,6 +7,7 @@ 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'} +rstd = { 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'} @@ -16,6 +17,7 @@ default = ['std'] std = [ 'codec/std', 'sp-arithmetic/std', + 'rstd/std', 'frame-support/std', 'system/std', 'common/std', diff --git a/runtime-modules/memo/src/lib.rs b/runtime-modules/memo/src/lib.rs index c1b62e9719..c2ffff1153 100644 --- a/runtime-modules/memo/src/lib.rs +++ b/runtime-modules/memo/src/lib.rs @@ -4,6 +4,7 @@ use frame_support::traits::Currency; use frame_support::{decl_event, decl_module, decl_storage, ensure}; use sp_arithmetic::traits::Zero; +use rstd::vec::Vec; use system::ensure_signed; use common::currency::GovernanceCurrency; diff --git a/runtime-modules/proposals/discussion/src/types.rs b/runtime-modules/proposals/discussion/src/types.rs index cbcc65ccf1..aa2a5dbdd4 100644 --- a/runtime-modules/proposals/discussion/src/types.rs +++ b/runtime-modules/proposals/discussion/src/types.rs @@ -3,6 +3,7 @@ use codec::{Decode, Encode}; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; +use rstd::vec::Vec; /// Represents a discussion thread #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] diff --git a/runtime-modules/proposals/engine/src/lib.rs b/runtime-modules/proposals/engine/src/lib.rs index f23b6079d9..99b7b03044 100644 --- a/runtime-modules/proposals/engine/src/lib.rs +++ b/runtime-modules/proposals/engine/src/lib.rs @@ -136,6 +136,7 @@ use frame_support::{ }; use sp_arithmetic::traits::Zero; use system::{ensure_root, RawOrigin}; +use rstd::vec::Vec; use common::origin::ActorOriginValidator; diff --git a/runtime-modules/proposals/engine/src/types/mod.rs b/runtime-modules/proposals/engine/src/types/mod.rs index a202fe6e91..bf81b373f1 100644 --- a/runtime-modules/proposals/engine/src/types/mod.rs +++ b/runtime-modules/proposals/engine/src/types/mod.rs @@ -6,7 +6,8 @@ use codec::{Decode, Encode}; use rstd::cmp::PartialOrd; use rstd::ops::Add; - +use rstd::vec::Vec; +use rstd::boxed::Box; use frame_support::dispatch::DispatchResult; use frame_support::traits::Currency; #[cfg(feature = "std")] diff --git a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs index 577011f679..53452dc88f 100644 --- a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs +++ b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs @@ -1,10 +1,11 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; - -use crate::ActiveStake; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; +use rstd::vec::Vec; + +use crate::ActiveStake; /// Current status of the proposal #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] diff --git a/runtime-modules/service-discovery/Cargo.toml b/runtime-modules/service-discovery/Cargo.toml index 17de6aea0d..637c76c0a5 100644 --- a/runtime-modules/service-discovery/Cargo.toml +++ b/runtime-modules/service-discovery/Cargo.toml @@ -7,6 +7,7 @@ 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'] } +rstd = { 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'} @@ -29,6 +30,7 @@ default = ['std'] std = [ 'serde', 'codec/std', + 'rstd/std', 'frame-support/std', 'system/std', 'sp-runtime/std', diff --git a/runtime-modules/service-discovery/src/lib.rs b/runtime-modules/service-discovery/src/lib.rs index d9237cc387..3757289895 100644 --- a/runtime-modules/service-discovery/src/lib.rs +++ b/runtime-modules/service-discovery/src/lib.rs @@ -27,6 +27,7 @@ use codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use rstd::vec::Vec; use system::ensure_root; /* Although there is support for ed25519 keys as the IPNS identity key and we could potentially diff --git a/runtime-modules/storage/src/data_directory.rs b/runtime-modules/storage/src/data_directory.rs index 222abd12ab..138df13a45 100644 --- a/runtime-modules/storage/src/data_directory.rs +++ b/runtime-modules/storage/src/data_directory.rs @@ -26,6 +26,7 @@ use frame_support::dispatch::DispatchResult; use frame_support::traits::Get; use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; use rstd::collections::btree_map::BTreeMap; +use rstd::vec::Vec; use sp_runtime::traits::{MaybeSerialize, Member}; use system::ensure_root; diff --git a/runtime-modules/storage/src/data_object_storage_registry.rs b/runtime-modules/storage/src/data_object_storage_registry.rs index 3d0cf7df9e..a32f483a1a 100644 --- a/runtime-modules/storage/src/data_object_storage_registry.rs +++ b/runtime-modules/storage/src/data_object_storage_registry.rs @@ -27,6 +27,7 @@ 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 rstd::vec::Vec; use crate::data_directory::{self, ContentIdExists}; use crate::{StorageProviderId, StorageWorkingGroup, StorageWorkingGroupInstance}; diff --git a/runtime-modules/storage/src/data_object_type_registry.rs b/runtime-modules/storage/src/data_object_type_registry.rs index 6972a64ffc..02954e6687 100644 --- a/runtime-modules/storage/src/data_object_type_registry.rs +++ b/runtime-modules/storage/src/data_object_type_registry.rs @@ -28,6 +28,7 @@ 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 rstd::vec::Vec; use crate::{StorageWorkingGroup, StorageWorkingGroupInstance}; diff --git a/runtime-modules/versioned-store-permissions/src/credentials.rs b/runtime-modules/versioned-store-permissions/src/credentials.rs index bf3dbcc36e..bd5d2f9bac 100644 --- a/runtime-modules/versioned-store-permissions/src/credentials.rs +++ b/runtime-modules/versioned-store-permissions/src/credentials.rs @@ -1,5 +1,6 @@ use codec::{Decode, Encode}; use rstd::collections::btree_set::BTreeSet; +use rstd::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 8dbcfa07c4..60a85c65e0 100755 --- a/runtime-modules/versioned-store-permissions/src/lib.rs +++ b/runtime-modules/versioned-store-permissions/src/lib.rs @@ -4,6 +4,7 @@ use codec::Codec; use frame_support::{decl_module, decl_storage, ensure, Parameter}; use rstd::collections::btree_map::BTreeMap; +use rstd::vec::Vec; use sp_arithmetic::traits::BaseArithmetic; use sp_runtime::traits::{MaybeSerialize, Member}; diff --git a/runtime-modules/versioned-store-permissions/src/operations.rs b/runtime-modules/versioned-store-permissions/src/operations.rs index 88b28b9fde..c6b7f77fb5 100644 --- a/runtime-modules/versioned-store-permissions/src/operations.rs +++ b/runtime-modules/versioned-store-permissions/src/operations.rs @@ -1,5 +1,7 @@ use codec::{Decode, Encode}; use rstd::collections::btree_map::BTreeMap; +use rstd::vec; +use rstd::vec::Vec; use versioned_store::{ClassId, ClassPropertyValue, EntityId, PropertyValue}; #[derive(Encode, Decode, Eq, PartialEq, Clone, Debug)] diff --git a/runtime-modules/versioned-store/src/lib.rs b/runtime-modules/versioned-store/src/lib.rs index 9d76e9928c..d03c208e7c 100755 --- a/runtime-modules/versioned-store/src/lib.rs +++ b/runtime-modules/versioned-store/src/lib.rs @@ -17,6 +17,8 @@ use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; use rstd::collections::btree_set::BTreeSet; +use rstd::vec; +use rstd::vec::Vec; mod example; mod mock; diff --git a/runtime-modules/working-group/src/lib.rs b/runtime-modules/working-group/src/lib.rs index 00b0161950..0ae6512db7 100644 --- a/runtime-modules/working-group/src/lib.rs +++ b/runtime-modules/working-group/src/lib.rs @@ -58,6 +58,7 @@ use frame_support::traits::{Currency, ExistenceRequirement, Get, Imbalance, With use frame_support::{decl_event, decl_module, decl_storage, ensure, print, StorageValue}; use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use rstd::vec::Vec; +use rstd::vec; use sp_arithmetic::traits::{Bounded, One, Zero}; use system::{ensure_root, ensure_signed}; diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 6219c86f06..f5e5648935 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -16,7 +16,6 @@ rstd = { package = 'sp-std', default-features = false, git = 'https://github.com 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-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-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'} @@ -72,6 +71,9 @@ proposals-engine = { package = 'pallet-proposals-engine', default-features = fal 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' } @@ -85,7 +87,6 @@ std = [ # Substrate primitives 'rstd/std', - 'sp-io/std', 'sp-core/std', 'sp-api/std', 'sp-version/std', diff --git a/runtime/src/integration/proposals/council_origin_validator.rs b/runtime/src/integration/proposals/council_origin_validator.rs index 5231d62f99..0f0e254c10 100644 --- a/runtime/src/integration/proposals/council_origin_validator.rs +++ b/runtime/src/integration/proposals/council_origin_validator.rs @@ -46,7 +46,7 @@ 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; diff --git a/runtime/src/integration/proposals/membership_origin_validator.rs b/runtime/src/integration/proposals/membership_origin_validator.rs index dd21b6141e..100d63046b 100644 --- a/runtime/src/integration/proposals/membership_origin_validator.rs +++ b/runtime/src/integration/proposals/membership_origin_validator.rs @@ -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/lib.rs b/runtime/src/lib.rs index 333cdad76f..3d16fd0806 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -30,20 +30,22 @@ use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::crypto::KeyTypeId; +use rstd::vec::Vec; +use rstd::boxed::Box; use sp_core::OpaqueMetadata; use sp_runtime::curve::PiecewiseLinear; use sp_runtime::traits::{ BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, StaticLookup, Verify, }; use sp_runtime::transaction_validity::TransactionSource; -#[cfg(any(feature = "std", test))] use sp_runtime::Perbill; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity, ApplyExtrinsicResult, MultiSignature, }; #[cfg(feature = "std")] -use sp_version::{NativeVersion, RuntimeVersion}; +use sp_version::{NativeVersion}; +use sp_version::{RuntimeVersion}; use system::EnsureRoot; use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator}; 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..220f7ddd1c 100644 --- a/runtime/src/tests/proposals_integration/mod.rs +++ b/runtime/src/tests/proposals_integration/mod.rs @@ -4,7 +4,8 @@ mod working_group_proposals; -use crate::{BlockNumber, ElectionParameters, ProposalCancellationFee, Runtime}; +use crate::{BlockNumber, ProposalCancellationFee, Runtime}; +use governance::election_params::ElectionParameters; use codec::Encode; use membership; use proposals_engine::{ @@ -13,10 +14,11 @@ use proposals_engine::{ 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::{DispatchResult}; +use sp_runtime::traits::{OnFinalize, OnInitialize}; +use sp_runtime::AccountId32; +use frame_support::traits::Currency; +use frame_support::{IterableStorageMap, StorageValue}; use system::RawOrigin; use super::initial_test_ext; diff --git a/runtime/src/tests/proposals_integration/working_group_proposals.rs b/runtime/src/tests/proposals_integration/working_group_proposals.rs index 9ea6f53e05..196e681a3a 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; From 68394727fa01a38d4eed124f851f1fe89e466269 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 28 Jul 2020 14:25:17 +0300 Subject: [PATCH 29/56] runtime: Restore tests. --- .../content-working-group/src/lib.rs | 2 +- runtime-modules/forum/src/lib.rs | 6 +-- runtime-modules/governance/src/council.rs | 4 +- runtime-modules/membership/src/lib.rs | 6 +-- runtime-modules/memo/src/lib.rs | 2 +- .../proposals/discussion/src/types.rs | 2 +- runtime-modules/proposals/engine/src/lib.rs | 2 +- .../proposals/engine/src/types/mod.rs | 6 +-- .../engine/src/types/proposal_statuses.rs | 2 +- .../src/data_object_storage_registry.rs | 2 +- .../storage/src/data_object_type_registry.rs | 2 +- runtime-modules/working-group/src/lib.rs | 2 +- .../proposals/council_origin_validator.rs | 2 +- runtime/src/lib.rs | 8 ++-- .../src/tests/proposals_integration/mod.rs | 48 ++++++++----------- .../working_group_proposals.rs | 26 +++++----- runtime/src/tests/storage_integration.rs | 2 +- 17 files changed, 58 insertions(+), 66 deletions(-) diff --git a/runtime-modules/content-working-group/src/lib.rs b/runtime-modules/content-working-group/src/lib.rs index b61df7cf87..efefa20cea 100755 --- a/runtime-modules/content-working-group/src/lib.rs +++ b/runtime-modules/content-working-group/src/lib.rs @@ -22,10 +22,10 @@ use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; +use rstd::borrow::ToOwned; use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use rstd::vec; use rstd::vec::Vec; -use rstd::borrow::ToOwned; use sp_arithmetic::traits::{One, Zero}; use system::{ensure_root, ensure_signed}; diff --git a/runtime-modules/forum/src/lib.rs b/runtime-modules/forum/src/lib.rs index 44058dfacd..4ccaba21bb 100755 --- a/runtime-modules/forum/src/lib.rs +++ b/runtime-modules/forum/src/lib.rs @@ -15,11 +15,11 @@ pub type DispatchResult = Result<(), &'static str>; use codec::{Codec, Decode, Encode}; use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; -use sp_arithmetic::traits::{BaseArithmetic, One}; -use sp_runtime::traits::{MaybeSerialize, Member}; +use rstd::borrow::ToOwned; use rstd::vec; use rstd::vec::Vec; -use rstd::borrow::ToOwned; +use sp_arithmetic::traits::{BaseArithmetic, One}; +use sp_runtime::traits::{MaybeSerialize, Member}; mod mock; mod tests; diff --git a/runtime-modules/governance/src/council.rs b/runtime-modules/governance/src/council.rs index 5cd22564a6..208e94a2fc 100644 --- a/runtime-modules/governance/src/council.rs +++ b/runtime-modules/governance/src/council.rs @@ -1,8 +1,8 @@ use frame_support::{debug, decl_event, decl_module, decl_storage, ensure}; -use sp_arithmetic::traits::{One, Zero}; -use system::ensure_root; use rstd::vec; use rstd::vec::Vec; +use sp_arithmetic::traits::{One, Zero}; +use system::ensure_root; pub use super::election::{self, CouncilElected, Seat, Seats}; pub use common::currency::{BalanceOf, GovernanceCurrency}; diff --git a/runtime-modules/membership/src/lib.rs b/runtime-modules/membership/src/lib.rs index 4a5b3dcfea..70d2744f82 100644 --- a/runtime-modules/membership/src/lib.rs +++ b/runtime-modules/membership/src/lib.rs @@ -12,12 +12,12 @@ mod tests; use codec::{Codec, Decode, Encode}; use frame_support::traits::Currency; use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; +use rstd::borrow::ToOwned; +use rstd::vec; +use rstd::vec::Vec; use sp_arithmetic::traits::{BaseArithmetic, One}; use sp_runtime::traits::{MaybeSerialize, Member}; use system::{ensure_root, ensure_signed}; -use rstd::vec; -use rstd::vec::Vec; -use rstd::borrow::ToOwned; use common::currency::{BalanceOf, GovernanceCurrency}; diff --git a/runtime-modules/memo/src/lib.rs b/runtime-modules/memo/src/lib.rs index c2ffff1153..45c9bf2f1d 100644 --- a/runtime-modules/memo/src/lib.rs +++ b/runtime-modules/memo/src/lib.rs @@ -3,8 +3,8 @@ use frame_support::traits::Currency; use frame_support::{decl_event, decl_module, decl_storage, ensure}; -use sp_arithmetic::traits::Zero; use rstd::vec::Vec; +use sp_arithmetic::traits::Zero; use system::ensure_signed; use common::currency::GovernanceCurrency; diff --git a/runtime-modules/proposals/discussion/src/types.rs b/runtime-modules/proposals/discussion/src/types.rs index aa2a5dbdd4..1f90a85d2c 100644 --- a/runtime-modules/proposals/discussion/src/types.rs +++ b/runtime-modules/proposals/discussion/src/types.rs @@ -1,9 +1,9 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; +use rstd::vec::Vec; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use rstd::vec::Vec; /// Represents a discussion thread #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] diff --git a/runtime-modules/proposals/engine/src/lib.rs b/runtime-modules/proposals/engine/src/lib.rs index 99b7b03044..3efc357a8d 100644 --- a/runtime-modules/proposals/engine/src/lib.rs +++ b/runtime-modules/proposals/engine/src/lib.rs @@ -134,9 +134,9 @@ use frame_support::traits::{Currency, Get}; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, ensure, print, Parameter, StorageDoubleMap, }; +use rstd::vec::Vec; use sp_arithmetic::traits::Zero; use system::{ensure_root, RawOrigin}; -use rstd::vec::Vec; use common::origin::ActorOriginValidator; diff --git a/runtime-modules/proposals/engine/src/types/mod.rs b/runtime-modules/proposals/engine/src/types/mod.rs index bf81b373f1..5e4c403c26 100644 --- a/runtime-modules/proposals/engine/src/types/mod.rs +++ b/runtime-modules/proposals/engine/src/types/mod.rs @@ -4,12 +4,12 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; +use frame_support::dispatch::DispatchResult; +use frame_support::traits::Currency; +use rstd::boxed::Box; use rstd::cmp::PartialOrd; use rstd::ops::Add; use rstd::vec::Vec; -use rstd::boxed::Box; -use frame_support::dispatch::DispatchResult; -use frame_support::traits::Currency; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::Perbill; diff --git a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs index 53452dc88f..6499d584d6 100644 --- a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs +++ b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs @@ -1,9 +1,9 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; +use rstd::vec::Vec; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use rstd::vec::Vec; use crate::ActiveStake; diff --git a/runtime-modules/storage/src/data_object_storage_registry.rs b/runtime-modules/storage/src/data_object_storage_registry.rs index a32f483a1a..d5fd96f108 100644 --- a/runtime-modules/storage/src/data_object_storage_registry.rs +++ b/runtime-modules/storage/src/data_object_storage_registry.rs @@ -25,9 +25,9 @@ use codec::{Codec, Decode, Encode}; use frame_support::dispatch::DispatchResult; use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; +use rstd::vec::Vec; use sp_arithmetic::traits::BaseArithmetic; use sp_runtime::traits::{MaybeSerialize, Member}; -use rstd::vec::Vec; use crate::data_directory::{self, ContentIdExists}; use crate::{StorageProviderId, StorageWorkingGroup, StorageWorkingGroupInstance}; diff --git a/runtime-modules/storage/src/data_object_type_registry.rs b/runtime-modules/storage/src/data_object_type_registry.rs index 02954e6687..a3c14d881b 100644 --- a/runtime-modules/storage/src/data_object_type_registry.rs +++ b/runtime-modules/storage/src/data_object_type_registry.rs @@ -26,9 +26,9 @@ use codec::{Codec, Decode, Encode}; use frame_support::dispatch::DispatchError; use frame_support::weights::Weight; use frame_support::{decl_error, decl_event, decl_module, decl_storage, Parameter}; +use rstd::vec::Vec; use sp_arithmetic::traits::BaseArithmetic; use sp_runtime::traits::{MaybeSerialize, Member}; -use rstd::vec::Vec; use crate::{StorageWorkingGroup, StorageWorkingGroupInstance}; diff --git a/runtime-modules/working-group/src/lib.rs b/runtime-modules/working-group/src/lib.rs index 0ae6512db7..51d5b18de8 100644 --- a/runtime-modules/working-group/src/lib.rs +++ b/runtime-modules/working-group/src/lib.rs @@ -57,8 +57,8 @@ 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 rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; -use rstd::vec::Vec; use rstd::vec; +use rstd::vec::Vec; use sp_arithmetic::traits::{Bounded, One, Zero}; use system::{ensure_root, ensure_signed}; diff --git a/runtime/src/integration/proposals/council_origin_validator.rs b/runtime/src/integration/proposals/council_origin_validator.rs index 0f0e254c10..0522141ee5 100644 --- a/runtime/src/integration/proposals/council_origin_validator.rs +++ b/runtime/src/integration/proposals/council_origin_validator.rs @@ -51,7 +51,7 @@ mod tests { 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/lib.rs b/runtime/src/lib.rs index 3d16fd0806..2001ead12f 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -27,11 +27,11 @@ use frame_support::{ use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use rstd::boxed::Box; +use rstd::vec::Vec; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::crypto::KeyTypeId; -use rstd::vec::Vec; -use rstd::boxed::Box; use sp_core::OpaqueMetadata; use sp_runtime::curve::PiecewiseLinear; use sp_runtime::traits::{ @@ -44,8 +44,8 @@ use sp_runtime::{ ApplyExtrinsicResult, MultiSignature, }; #[cfg(feature = "std")] -use sp_version::{NativeVersion}; -use sp_version::{RuntimeVersion}; +use sp_version::NativeVersion; +use sp_version::RuntimeVersion; use system::EnsureRoot; use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator}; diff --git a/runtime/src/tests/proposals_integration/mod.rs b/runtime/src/tests/proposals_integration/mod.rs index 220f7ddd1c..d98878852b 100644 --- a/runtime/src/tests/proposals_integration/mod.rs +++ b/runtime/src/tests/proposals_integration/mod.rs @@ -5,27 +5,26 @@ mod working_group_proposals; use crate::{BlockNumber, ProposalCancellationFee, Runtime}; -use governance::election_params::ElectionParameters; 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 frame_support::dispatch::{DispatchResult}; -use sp_runtime::traits::{OnFinalize, OnInitialize}; +use frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::traits::{Currency, OnFinalize, OnInitialize}; +use frame_support::{StorageMap, StorageValue}; use sp_runtime::AccountId32; -use frame_support::traits::Currency; -use frame_support::{IterableStorageMap, StorageValue}; 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; @@ -77,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); @@ -121,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; @@ -213,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, @@ -252,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(), @@ -361,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); @@ -445,7 +442,7 @@ fn elect_single_councilor() { struct CodexProposalTestFixture where - SuccessfulCall: Fn() -> DispatchResult, + SuccessfulCall: Fn() -> DispatchResult, { successful_call: SuccessfulCall, member_id: u64, @@ -456,7 +453,7 @@ where impl CodexProposalTestFixture where - SuccessfulCall: Fn() -> DispatchResult, + SuccessfulCall: Fn() -> DispatchResult, { fn default_for_call(call: SuccessfulCall) -> Self { Self { @@ -502,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]; @@ -620,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); }); } @@ -705,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( @@ -719,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 196e681a3a..1a1071e718 100644 --- a/runtime/src/tests/proposals_integration/working_group_proposals.rs +++ b/runtime/src/tests/proposals_integration/working_group_proposals.rs @@ -29,7 +29,7 @@ fn add_opening( 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( @@ -288,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, @@ -305,7 +305,7 @@ fn create_add_working_group_leader_opening_proposal_execution_succeeds() { assert!(>::exists(opening_id)); + >>::contains_key(opening_id)); }); } @@ -461,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); @@ -475,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!( @@ -542,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); @@ -556,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!( @@ -652,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; @@ -664,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); }); } @@ -734,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); @@ -743,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); @@ -816,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); @@ -825,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..5b16fedc37 100644 --- a/runtime/src/tests/storage_integration.rs +++ b/runtime/src/tests/storage_integration.rs @@ -2,7 +2,7 @@ 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] From 75873ec9cc837ef14994ae2e87a94d7262654714 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 28 Jul 2020 15:34:21 +0300 Subject: [PATCH 30/56] runtime: Fix broken tests. --- .../src/tests/proposals_integration/mod.rs | 6 +++--- .../working_group_proposals.rs | 20 +++++++++---------- runtime/src/tests/storage_integration.rs | 2 ++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/runtime/src/tests/proposals_integration/mod.rs b/runtime/src/tests/proposals_integration/mod.rs index d98878852b..44ab718938 100644 --- a/runtime/src/tests/proposals_integration/mod.rs +++ b/runtime/src/tests/proposals_integration/mod.rs @@ -309,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(), @@ -330,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, }); @@ -529,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(), diff --git a/runtime/src/tests/proposals_integration/working_group_proposals.rs b/runtime/src/tests/proposals_integration/working_group_proposals.rs index 1a1071e718..fa18eab7a0 100644 --- a/runtime/src/tests/proposals_integration/working_group_proposals.rs +++ b/runtime/src/tests/proposals_integration/working_group_proposals.rs @@ -22,7 +22,7 @@ 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(); @@ -63,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( @@ -92,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( @@ -132,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( @@ -161,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( @@ -190,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( @@ -219,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); @@ -253,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( @@ -330,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, @@ -346,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(), diff --git a/runtime/src/tests/storage_integration.rs b/runtime/src/tests/storage_integration.rs index 5b16fedc37..22cb0bd36a 100644 --- a/runtime/src/tests/storage_integration.rs +++ b/runtime/src/tests/storage_integration.rs @@ -8,6 +8,8 @@ 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 = Date: Tue, 28 Jul 2020 20:28:50 +0300 Subject: [PATCH 31/56] runtime: Update runtime pallet dependencies. --- Cargo.lock | 1 + runtime/Cargo.toml | 2 + runtime/src/lib.rs | 218 ++++++++++++++++----------------------------- 3 files changed, 79 insertions(+), 142 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35611f7242..529c9b939c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1129,6 +1129,7 @@ dependencies = [ "pallet-timestamp", "pallet-token-mint", "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", "pallet-versioned-store", "pallet-versioned-store-permissions", "pallet-working-group", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index f5e5648935..8c0d9e2501 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -38,6 +38,7 @@ pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default pallet-babe = { package = 'pallet-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} pallet-indices = { package = 'pallet-indices', 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'} @@ -110,6 +111,7 @@ std = [ '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', diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2001ead12f..698c1b47a4 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -27,6 +27,9 @@ use frame_support::{ use pallet_grandpa::fg_primitives; 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 pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; +use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use rstd::boxed::Box; use rstd::vec::Vec; use sp_api::impl_runtime_apis; @@ -37,11 +40,10 @@ use sp_runtime::curve::PiecewiseLinear; use sp_runtime::traits::{ BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, StaticLookup, Verify, }; -use sp_runtime::transaction_validity::TransactionSource; -use sp_runtime::Perbill; +use sp_runtime::transaction_validity::{TransactionSource, TransactionValidity}; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity, - ApplyExtrinsicResult, MultiSignature, + create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, + MultiSignature, Perbill, Perquintill, }; #[cfg(feature = "std")] use sp_version::NativeVersion; @@ -54,6 +56,9 @@ use content_working_group as content_wg; use governance::{council, election}; use storage::{data_directory, data_object_storage_registry, data_object_type_registry}; +/// 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; @@ -117,13 +122,9 @@ pub mod opaque { 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; - pub type SessionHandlers = (Grandpa, Babe, ImOnline); impl_opaque_keys! { @@ -180,7 +181,7 @@ 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 { @@ -191,7 +192,8 @@ 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; @@ -340,7 +342,6 @@ parameter_types! { } impl timestamp::Trait for Runtime { - /// A timestamp: milliseconds since the unix epoch. type Moment = Moment; type OnTimestampSet = Babe; type MinimumPeriod = MinimumPeriod; @@ -350,8 +351,6 @@ 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; } @@ -373,13 +372,20 @@ impl pallet_balances::Trait for Runtime { type AccountStore = System; } +parameter_types! { + pub const TransactionByteFee: Balance = 1; // TODO: adjust fee + pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); + pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000); + pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128); +} + impl pallet_transaction_payment::Trait for Runtime { type Currency = Balances; type OnTransactionPayment = (); - // type TransactionBaseFee = TransactionBaseFee; type TransactionByteFee = TransactionByteFee; - type WeightToFee = IdentityFee; - type FeeMultiplierUpdate = (); + type WeightToFee = IdentityFee; // TODO: adjust weight + type FeeMultiplierUpdate = + TargetedFeeAdjustment; } impl pallet_sudo::Trait for Runtime { @@ -417,30 +423,16 @@ parameter_types! { pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); } -/* -type Event = Event; -type ValidatorId = ::AccountId; -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 pallet_session::Trait for Runtime { - // type OnSessionEnding = Staking; - type SessionHandler = SessionHandlers; - type ShouldEndSession = Babe; type Event = Event; - type Keys = SessionKeys; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; - // type SelectInitialValidators = Staking; + type ShouldEndSession = Babe; + type NextSessionRotation = Babe; + type SessionManager = pallet_session::historical::NoteHistoricalRoot; + type SessionHandler = SessionHandlers; + type Keys = SessionKeys; type DisabledValidatorsThreshold = DisabledValidatorsThreshold; - //TODO - type NextSessionRotation = (); - type SessionManager = (); } impl pallet_session::historical::Trait for Runtime { @@ -459,82 +451,56 @@ pallet_staking_reward_curve::build! { ); } +parameter_types! { + 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 pallet_staking::Trait for Runtime { type Currency = Balances; type UnixTime = Timestamp; - type CurrencyToVote = CurrencyToVoteHandler; - type RewardRemainder = Treasury; + type CurrencyToVote = common::currency::CurrencyToVoteHandler; + type RewardRemainder = (); // Could be Treasury. type Event = Event; - type Slash = Treasury; // send the slashed funds to the treasury. - 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; - /// A super-majority of the council can cancel the slash. - type SlashCancelOrigin = EnsureOneOf< - AccountId, - EnsureRoot, - pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective> - >; + 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 = ElectionLookahead; + type ElectionLookahead = MaxIterations; type Call = Call; type MaxIterations = MaxIterations; type MinSolutionScoreBump = MinSolutionScoreBump; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; type UnsignedPriority = StakingUnsignedPriority; -*/ -impl pallet_staking::Trait for Runtime { - type Currency = Balances; - type UnixTime = Timestamp; - type CurrencyToVote = common::currency::CurrencyToVoteHandler; - type RewardRemainder = (); - type Event = Event; - type Slash = (); // where to send the slashed funds. - type Reward = (); // rewards are minted from the void - type SessionsPerEra = SessionsPerEra; - type BondingDuration = BondingDuration; - // TODO - type SlashDeferDuration = (); - type SlashCancelOrigin = EnsureRoot; - type SessionInterface = Self; - type RewardCurve = RewardCurve; - type NextNewSession = (); - type ElectionLookahead = (); - type Call = Call; - type MaxIterations = (); - type MinSolutionScoreBump = (); - type MaxNominatorRewardedPerValidator = (); - type UnsignedPriority = (); } //type SubmitTransaction = TransactionSubmitter; -parameter_types! { - pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _; -} - -/* +impl pallet_im_online::Trait for Runtime { type AuthorityId = ImOnlineId; type Event = Event; type SessionDuration = SessionDuration; type ReportUnresponsiveness = Offences; type UnsignedPriority = ImOnlineUnsignedPriority; -*/ -impl pallet_im_online::Trait for Runtime { - type AuthorityId = ImOnlineId; - type Event = Event; - type ReportUnresponsiveness = Offences; - type SessionDuration = SessionDuration; - type UnsignedPriority = (); //ImOnlineUnsignedPriority; } impl pallet_offences::Trait for Runtime { @@ -838,6 +804,7 @@ construct_runtime!( 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}, @@ -893,18 +860,9 @@ pub type SignedExtra = ( system::CheckNonce, system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, + pallet_grandpa::ValidateEquivocationReport, ); -/* - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, - pallet_grandpa::ValidateEquivocationReport, -*/ /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Extrinsic type that has already been checked. @@ -970,30 +928,36 @@ impl_runtime_apis! { Executive::offchain_worker(header) } } -//TODO + impl fg_primitives::GrandpaApi for Runtime { fn grandpa_authorities() -> GrandpaAuthorityList { Grandpa::grandpa_authorities() } fn submit_report_equivocation_extrinsic( - _equivocation_proof: fg_primitives::EquivocationProof< + equivocation_proof: fg_primitives::EquivocationProof< ::Hash, NumberFor, >, - _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, + key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { - None + 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, + authority_id: GrandpaId, ) -> Option { - // NOTE: this is the only implementation possible since we've - // defined our key owner proof type as a bottom type (i.e. a type - // with no values). - None + use codec::Encode; + + Historical::prove((fg_primitives::KEY_TYPE, authority_id)) + .map(|p| p.encode()) + .map(fg_primitives::OpaqueKeyOwnershipProof::new) } } @@ -1011,15 +975,6 @@ impl_runtime_apis! { genesis_authorities: Babe::authorities(), randomness: Babe::randomness(), allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, - //secondary_slots: true, //TODO - /* - 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, - */ } } @@ -1029,35 +984,9 @@ impl_runtime_apis! { } impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { - // fn authorities() -> Vec { - // AuthorityDiscovery::authorities().into_iter() - // .map(|id| id.encode()) - // .map(EncodedAuthorityId) - // .collect() - // } fn authorities() -> Vec { AuthorityDiscovery::authorities() } - - // 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 frame_system_rpc_runtime_api::AccountNonceApi for Runtime { @@ -1070,15 +999,20 @@ impl_runtime_apis! { fn generate_session_keys(seed: Option>) -> Vec { SessionKeys::generate(seed) } - // 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) - // } - - fn decode_session_keys( + fn decode_session_keys( encoded: Vec, ) -> Option, KeyTypeId)>> { SessionKeys::decode_into_raw_public_keys(&encoded) } } + + 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) + } + } } From 5f30bebeca4df01d04239c8dabe1c71940c3af72 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 28 Jul 2020 20:33:32 +0300 Subject: [PATCH 32/56] runtime: Rename rstd to sp_std. --- .../content-working-group/Cargo.toml | 4 +-- .../content-working-group/src/genesis.rs | 2 +- .../content-working-group/src/lib.rs | 26 ++++++++-------- .../content-working-group/src/tests.rs | 2 +- runtime-modules/forum/Cargo.toml | 4 +-- runtime-modules/forum/src/lib.rs | 6 ++-- runtime-modules/governance/Cargo.toml | 4 +-- runtime-modules/governance/src/council.rs | 4 +-- runtime-modules/governance/src/election.rs | 10 +++---- runtime-modules/governance/src/sealed_vote.rs | 2 +- runtime-modules/governance/src/stake.rs | 2 +- runtime-modules/hiring/Cargo.toml | 4 +-- .../hiring/src/hiring/application.rs | 4 +-- runtime-modules/hiring/src/hiring/opening.rs | 8 ++--- runtime-modules/hiring/src/lib.rs | 12 ++++---- runtime-modules/hiring/src/mock.rs | 8 +++-- runtime-modules/hiring/src/test/mod.rs | 6 ++-- .../src/test/public_api/add_application.rs | 2 +- .../hiring/src/test/public_api/add_opening.rs | 2 +- .../begin_accepting_applications.rs | 2 +- .../src/test/public_api/cancel_opening.rs | 2 +- .../public_api/ensure_can_add_application.rs | 2 +- .../src/test/public_api/fill_opening.rs | 4 +-- .../hiring/src/test/public_api/mod.rs | 8 ++--- runtime-modules/hiring/src/test/smoke.rs | 2 +- .../would_application_get_added.rs | 2 +- runtime-modules/membership/Cargo.toml | 4 +-- runtime-modules/membership/src/lib.rs | 6 ++-- runtime-modules/memo/Cargo.toml | 4 +-- runtime-modules/memo/src/lib.rs | 2 +- runtime-modules/proposals/codex/Cargo.toml | 4 +-- runtime-modules/proposals/codex/src/lib.rs | 6 ++-- .../proposals/codex/src/proposal_types/mod.rs | 2 +- .../proposals/discussion/Cargo.toml | 4 +-- .../proposals/discussion/src/lib.rs | 4 +-- .../proposals/discussion/src/types.rs | 2 +- runtime-modules/proposals/engine/Cargo.toml | 4 +-- runtime-modules/proposals/engine/src/lib.rs | 2 +- .../engine/src/tests/mock/proposals.rs | 2 +- .../proposals/engine/src/tests/mock/stakes.rs | 2 +- .../proposals/engine/src/tests/mod.rs | 2 +- .../proposals/engine/src/types/mod.rs | 8 ++--- .../engine/src/types/proposal_statuses.rs | 2 +- .../proposals/engine/src/types/stakes.rs | 6 ++-- runtime-modules/service-discovery/Cargo.toml | 4 +-- runtime-modules/service-discovery/src/lib.rs | 2 +- runtime-modules/stake/Cargo.toml | 4 +-- runtime-modules/stake/src/lib.rs | 4 +-- runtime-modules/storage/Cargo.toml | 4 +-- runtime-modules/storage/src/data_directory.rs | 4 +-- .../src/data_object_storage_registry.rs | 2 +- .../storage/src/data_object_type_registry.rs | 2 +- .../storage/src/tests/data_directory.rs | 2 +- .../versioned-store-permissions/Cargo.toml | 4 +-- .../src/constraint.rs | 2 +- .../src/credentials.rs | 4 +-- .../versioned-store-permissions/src/lib.rs | 4 +-- .../src/operations.rs | 6 ++-- .../versioned-store-permissions/src/tests.rs | 2 +- runtime-modules/versioned-store/Cargo.toml | 4 +-- runtime-modules/versioned-store/src/lib.rs | 8 ++--- runtime-modules/working-group/Cargo.toml | 4 +-- runtime-modules/working-group/src/errors.rs | 30 +++++++++---------- runtime-modules/working-group/src/lib.rs | 8 ++--- runtime-modules/working-group/src/types.rs | 2 +- runtime/Cargo.toml | 4 +-- .../proposals/council_origin_validator.rs | 2 +- .../proposals/membership_origin_validator.rs | 2 +- .../integration/proposals/proposal_encoder.rs | 6 ++-- .../proposals/staking_events_handler.rs | 2 +- runtime/src/integration/storage.rs | 2 +- runtime/src/integration/working_group.rs | 2 +- runtime/src/lib.rs | 4 +-- .../working_group_proposals.rs | 2 +- 74 files changed, 168 insertions(+), 164 deletions(-) diff --git a/runtime-modules/content-working-group/Cargo.toml b/runtime-modules/content-working-group/Cargo.toml index c267857cf3..1ef8c44241 100644 --- a/runtime-modules/content-working-group/Cargo.toml +++ b/runtime-modules/content-working-group/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -32,7 +32,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'sp-arithmetic/std', diff --git a/runtime-modules/content-working-group/src/genesis.rs b/runtime-modules/content-working-group/src/genesis.rs index b1fc85e741..e4cb8741e3 100644 --- a/runtime-modules/content-working-group/src/genesis.rs +++ b/runtime-modules/content-working-group/src/genesis.rs @@ -1,7 +1,7 @@ #![cfg(test)] use crate::{Trait, *}; -use rstd::map; +use sp_std::map; use common::constraints::InputValidationLengthConstraint; diff --git a/runtime-modules/content-working-group/src/lib.rs b/runtime-modules/content-working-group/src/lib.rs index efefa20cea..a58a049a45 100755 --- a/runtime-modules/content-working-group/src/lib.rs +++ b/runtime-modules/content-working-group/src/lib.rs @@ -22,11 +22,11 @@ use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; -use rstd::borrow::ToOwned; -use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; -use rstd::vec; -use rstd::vec::Vec; 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; @@ -785,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 => { @@ -798,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 => { @@ -827,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 => { @@ -840,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, @@ -878,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 => { @@ -900,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 => { @@ -913,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 => { @@ -938,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 => { diff --git a/runtime-modules/content-working-group/src/tests.rs b/runtime-modules/content-working-group/src/tests.rs index 521d5cde42..7bb1e9bf15 100644 --- a/runtime-modules/content-working-group/src/tests.rs +++ b/runtime-modules/content-working-group/src/tests.rs @@ -4,8 +4,8 @@ use super::genesis; use super::mock::*; use frame_support::{assert_err, assert_ok, traits::Currency, StorageValue}; -use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use sp_arithmetic::traits::One; +use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use system::RawOrigin; use common::constraints::InputValidationLengthConstraint; diff --git a/runtime-modules/forum/Cargo.toml b/runtime-modules/forum/Cargo.toml index d8b53b7b70..6f8ce7e160 100755 --- a/runtime-modules/forum/Cargo.toml +++ b/runtime-modules/forum/Cargo.toml @@ -11,7 +11,7 @@ frame-support = { package = 'frame-support', default-features = false, git = 'ht 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'} -rstd = { package = 'sp-std', 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'} 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'} @@ -26,7 +26,7 @@ std = [ 'codec/std', 'frame-support/std', 'system/std', - 'rstd/std', + 'sp-std/std', 'sp-arithmetic/std', 'sp-runtime/std', 'timestamp/std', diff --git a/runtime-modules/forum/src/lib.rs b/runtime-modules/forum/src/lib.rs index 4ccaba21bb..9c5386a86b 100755 --- a/runtime-modules/forum/src/lib.rs +++ b/runtime-modules/forum/src/lib.rs @@ -15,11 +15,11 @@ pub type DispatchResult = Result<(), &'static str>; use codec::{Codec, Decode, Encode}; use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; -use rstd::borrow::ToOwned; -use rstd::vec; -use rstd::vec::Vec; 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; diff --git a/runtime-modules/governance/Cargo.toml b/runtime-modules/governance/Cargo.toml index 3e71d6b4b5..b027e1e6db 100644 --- a/runtime-modules/governance/Cargo.toml +++ b/runtime-modules/governance/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -28,7 +28,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'sp-arithmetic/std', diff --git a/runtime-modules/governance/src/council.rs b/runtime-modules/governance/src/council.rs index 208e94a2fc..f391bcd437 100644 --- a/runtime-modules/governance/src/council.rs +++ b/runtime-modules/governance/src/council.rs @@ -1,7 +1,7 @@ use frame_support::{debug, decl_event, decl_module, decl_storage, ensure}; -use rstd::vec; -use rstd::vec::Vec; 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}; diff --git a/runtime-modules/governance/src/election.rs b/runtime-modules/governance/src/election.rs index 227bcc39a9..66a70e307b 100644 --- a/runtime-modules/governance/src/election.rs +++ b/runtime-modules/governance/src/election.rs @@ -35,12 +35,12 @@ use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; use frame_support::traits::{Currency, ReservableCurrency}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; -use rstd::collections::btree_map::BTreeMap; -use rstd::ops::Add; -use rstd::vec; -use rstd::vec::Vec; 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; @@ -324,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); diff --git a/runtime-modules/governance/src/sealed_vote.rs b/runtime-modules/governance/src/sealed_vote.rs index b8ee99fb8f..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 frame_support::ensure; -use rstd::vec::Vec; +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 e165c5fae2..9afae07672 100644 --- a/runtime-modules/governance/src/stake.rs +++ b/runtime-modules/governance/src/stake.rs @@ -1,6 +1,6 @@ use codec::{Decode, Encode}; -use rstd::cmp::Ordering; use sp_arithmetic::traits::BaseArithmetic; +use sp_std::cmp::Ordering; #[derive(Encode, Decode, Clone, Copy, Default, Debug)] pub struct Stake diff --git a/runtime-modules/hiring/Cargo.toml b/runtime-modules/hiring/Cargo.toml index 9bc13958b6..79453af1d3 100755 --- a/runtime-modules/hiring/Cargo.toml +++ b/runtime-modules/hiring/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -25,7 +25,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'sp-arithmetic/std', 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 bca1047b0e..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")] diff --git a/runtime-modules/hiring/src/lib.rs b/runtime-modules/hiring/src/lib.rs index d5940fe334..1ed4839d7c 100755 --- a/runtime-modules/hiring/src/lib.rs +++ b/runtime-modules/hiring/src/lib.rs @@ -28,14 +28,14 @@ use codec::Codec; use frame_support::storage::IterableStorageMap; use frame_support::traits::{Currency, Imbalance}; use frame_support::{decl_module, decl_storage, ensure, Parameter}; -use rstd::cell::RefCell; -use rstd::collections::btree_map::BTreeMap; -use rstd::collections::btree_set::BTreeSet; -use rstd::iter::Iterator; -use rstd::rc::Rc; -use rstd::vec::Vec; 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 stake::{InitiateUnstakingError, Stake, StakeActionError, StakingError, Trait as StakeTrait}; diff --git a/runtime-modules/hiring/src/mock.rs b/runtime-modules/hiring/src/mock.rs index 7f260bda9a..7a24e9e0da 100644 --- a/runtime-modules/hiring/src/mock.rs +++ b/runtime-modules/hiring/src/mock.rs @@ -1,14 +1,14 @@ #![cfg(test)] use frame_support::{impl_outer_origin, parameter_types}; -use rstd::cell::{Cell, RefCell}; -use rstd::rc::Rc; use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; +use sp_std::cell::{Cell, RefCell}; +use sp_std::rc::Rc; use std::panic; use crate::hiring::ApplicationDeactivationCause; @@ -126,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(); 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 1df06bd3b3..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::*; 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 e3cbf2d01f..9a10b07190 100644 --- a/runtime-modules/hiring/src/test/public_api/add_opening.rs +++ b/runtime-modules/hiring/src/test/public_api/add_opening.rs @@ -6,7 +6,7 @@ use crate::{ ActivateOpeningAt, ActiveOpeningStage, AddOpeningError, ApplicationRationingPolicy, Opening, OpeningStage, StakePurpose, StakingPolicy, }; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; pub static HUMAN_READABLE_TEXT: &[u8] = b"HUMAN_READABLE_TEXT!!!!"; 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 ba226fde0f..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() { 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 04deac8f54..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: 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 78ccfba5b1..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() { 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 f2cc62427d..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: 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/smoke.rs b/runtime-modules/hiring/src/test/smoke.rs index c8c5ebfe19..40d05ec229 100644 --- a/runtime-modules/hiring/src/test/smoke.rs +++ b/runtime-modules/hiring/src/test/smoke.rs @@ -1,7 +1,7 @@ use super::*; use crate::mock::*; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; /** Main hiring workflow: 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 24e5e85ef0..247c242c4e 100644 --- a/runtime-modules/membership/Cargo.toml +++ b/runtime-modules/membership/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -27,7 +27,7 @@ std = [ 'codec/std', 'frame-support/std', 'system/std', - 'rstd/std', + 'sp-std/std', 'sp-arithmetic/std', 'sp-runtime/std', 'timestamp/std', diff --git a/runtime-modules/membership/src/lib.rs b/runtime-modules/membership/src/lib.rs index 70d2744f82..8302752f13 100644 --- a/runtime-modules/membership/src/lib.rs +++ b/runtime-modules/membership/src/lib.rs @@ -12,11 +12,11 @@ mod tests; use codec::{Codec, Decode, Encode}; use frame_support::traits::Currency; use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; -use rstd::borrow::ToOwned; -use rstd::vec; -use rstd::vec::Vec; 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}; diff --git a/runtime-modules/memo/Cargo.toml b/runtime-modules/memo/Cargo.toml index 738ed7ac2c..2793a6331f 100644 --- a/runtime-modules/memo/Cargo.toml +++ b/runtime-modules/memo/Cargo.toml @@ -7,7 +7,7 @@ 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'} -rstd = { package = 'sp-std', 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'} @@ -17,7 +17,7 @@ default = ['std'] std = [ 'codec/std', 'sp-arithmetic/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'common/std', diff --git a/runtime-modules/memo/src/lib.rs b/runtime-modules/memo/src/lib.rs index 45c9bf2f1d..4796472253 100644 --- a/runtime-modules/memo/src/lib.rs +++ b/runtime-modules/memo/src/lib.rs @@ -3,8 +3,8 @@ use frame_support::traits::Currency; use frame_support::{decl_event, decl_module, decl_storage, ensure}; -use rstd::vec::Vec; use sp_arithmetic::traits::Zero; +use sp_std::vec::Vec; use system::ensure_signed; use common::currency::GovernanceCurrency; diff --git a/runtime-modules/proposals/codex/Cargo.toml b/runtime-modules/proposals/codex/Cargo.toml index 5ad25de8ae..1d804fa094 100644 --- a/runtime-modules/proposals/codex/Cargo.toml +++ b/runtime-modules/proposals/codex/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} 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'} @@ -40,7 +40,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'sp-arithmetic/std', 'sp-runtime/std', diff --git a/runtime-modules/proposals/codex/src/lib.rs b/runtime-modules/proposals/codex/src/lib.rs index 6c6c63cd82..fd0527c919 100644 --- a/runtime-modules/proposals/codex/src/lib.rs +++ b/runtime-modules/proposals/codex/src/lib.rs @@ -68,10 +68,10 @@ 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 rstd::clone::Clone; -use rstd::str::from_utf8; -use rstd::vec::Vec; 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; diff --git a/runtime-modules/proposals/codex/src/proposal_types/mod.rs b/runtime-modules/proposals/codex/src/proposal_types/mod.rs index 35804b65b2..b5229baf83 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/discussion/Cargo.toml b/runtime-modules/proposals/discussion/Cargo.toml index 448516431e..c89452e152 100644 --- a/runtime-modules/proposals/discussion/Cargo.toml +++ b/runtime-modules/proposals/discussion/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} membership = { package = 'pallet-membership', default-features = false, path = '../../membership'} @@ -25,7 +25,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'membership/std', diff --git a/runtime-modules/proposals/discussion/src/lib.rs b/runtime-modules/proposals/discussion/src/lib.rs index cae76e55ac..123cd1cb36 100644 --- a/runtime-modules/proposals/discussion/src/lib.rs +++ b/runtime-modules/proposals/discussion/src/lib.rs @@ -51,8 +51,8 @@ mod types; 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 rstd::clone::Clone; -use rstd::vec::Vec; +use sp_std::clone::Clone; +use sp_std::vec::Vec; use common::origin::ActorOriginValidator; use types::{DiscussionPost, DiscussionThread, ThreadCounter}; diff --git a/runtime-modules/proposals/discussion/src/types.rs b/runtime-modules/proposals/discussion/src/types.rs index 1f90a85d2c..ecaec470fd 100644 --- a/runtime-modules/proposals/discussion/src/types.rs +++ b/runtime-modules/proposals/discussion/src/types.rs @@ -1,9 +1,9 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; -use rstd::vec::Vec; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; +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 4ccb551f73..31ff2d96ef 100644 --- a/runtime-modules/proposals/engine/Cargo.toml +++ b/runtime-modules/proposals/engine/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -28,7 +28,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'timestamp/std', diff --git a/runtime-modules/proposals/engine/src/lib.rs b/runtime-modules/proposals/engine/src/lib.rs index 3efc357a8d..d1e0cf1667 100644 --- a/runtime-modules/proposals/engine/src/lib.rs +++ b/runtime-modules/proposals/engine/src/lib.rs @@ -134,8 +134,8 @@ use frame_support::traits::{Currency, Get}; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, ensure, print, Parameter, StorageDoubleMap, }; -use rstd::vec::Vec; use sp_arithmetic::traits::Zero; +use sp_std::vec::Vec; use system::{ensure_root, RawOrigin}; use common::origin::ActorOriginValidator; diff --git a/runtime-modules/proposals/engine/src/tests/mock/proposals.rs b/runtime-modules/proposals/engine/src/tests/mock/proposals.rs index 45fe1f9234..a875ff44ae 100644 --- a/runtime-modules/proposals/engine/src/tests/mock/proposals.rs +++ b/runtime-modules/proposals/engine/src/tests/mock/proposals.rs @@ -1,7 +1,7 @@ //! Contains executable proposal extrinsic mocks use frame_support::decl_module; -use rstd::vec::Vec; +use sp_std::vec::Vec; pub trait Trait: system::Trait {} decl_module! { 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 b330d4c0cd..97f441865e 100644 --- a/runtime-modules/proposals/engine/src/tests/mod.rs +++ b/runtime-modules/proposals/engine/src/tests/mod.rs @@ -7,7 +7,7 @@ use codec::Encode; use frame_support::dispatch::DispatchResult; use frame_support::traits::{Currency, OnFinalize, OnInitialize}; use frame_support::{StorageDoubleMap, StorageMap, StorageValue}; -use rstd::rc::Rc; +use sp_std::rc::Rc; use system::RawOrigin; use system::{EventRecord, Phase}; diff --git a/runtime-modules/proposals/engine/src/types/mod.rs b/runtime-modules/proposals/engine/src/types/mod.rs index 5e4c403c26..ae8dd5d269 100644 --- a/runtime-modules/proposals/engine/src/types/mod.rs +++ b/runtime-modules/proposals/engine/src/types/mod.rs @@ -6,13 +6,13 @@ use codec::{Decode, Encode}; use frame_support::dispatch::DispatchResult; use frame_support::traits::Currency; -use rstd::boxed::Box; -use rstd::cmp::PartialOrd; -use rstd::ops::Add; -use rstd::vec::Vec; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; 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; diff --git a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs index 6499d584d6..ad5dfbdf11 100644 --- a/runtime-modules/proposals/engine/src/types/proposal_statuses.rs +++ b/runtime-modules/proposals/engine/src/types/proposal_statuses.rs @@ -1,9 +1,9 @@ #![warn(missing_docs)] use codec::{Decode, Encode}; -use rstd::vec::Vec; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; +use sp_std::vec::Vec; use crate::ActiveStake; diff --git a/runtime-modules/proposals/engine/src/types/stakes.rs b/runtime-modules/proposals/engine/src/types/stakes.rs index dfe1743bb0..a0fab9df52 100644 --- a/runtime-modules/proposals/engine/src/types/stakes.rs +++ b/runtime-modules/proposals/engine/src/types/stakes.rs @@ -3,9 +3,9 @@ use super::{BalanceOf, CurrencyOf, NegativeImbalance}; use crate::Trait; use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons}; -use rstd::convert::From; -use rstd::marker::PhantomData; -use rstd::rc::Rc; +use sp_std::convert::From; +use sp_std::marker::PhantomData; +use sp_std::rc::Rc; // Mocking dependencies for testing #[cfg(test)] diff --git a/runtime-modules/service-discovery/Cargo.toml b/runtime-modules/service-discovery/Cargo.toml index 637c76c0a5..852b7d68ac 100644 --- a/runtime-modules/service-discovery/Cargo.toml +++ b/runtime-modules/service-discovery/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -30,7 +30,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'sp-runtime/std', diff --git a/runtime-modules/service-discovery/src/lib.rs b/runtime-modules/service-discovery/src/lib.rs index 3757289895..09afda67da 100644 --- a/runtime-modules/service-discovery/src/lib.rs +++ b/runtime-modules/service-discovery/src/lib.rs @@ -27,7 +27,7 @@ use codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; -use rstd::vec::Vec; +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 diff --git a/runtime-modules/stake/Cargo.toml b/runtime-modules/stake/Cargo.toml index 74b3605d21..456a4434ae 100755 --- a/runtime-modules/stake/Cargo.toml +++ b/runtime-modules/stake/Cargo.toml @@ -6,7 +6,7 @@ edition = '2018' [dependencies] codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } -rstd = { package = 'sp-std', 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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -22,7 +22,7 @@ balances = { package = 'pallet-balances', default-features = false, git = 'https default = ['std'] std = [ 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'sp-arithmetic/std', diff --git a/runtime-modules/stake/src/lib.rs b/runtime-modules/stake/src/lib.rs index e98dd8467f..85edee31e5 100755 --- a/runtime-modules/stake/src/lib.rs +++ b/runtime-modules/stake/src/lib.rs @@ -5,11 +5,11 @@ use codec::{Codec, Decode, Encode}; use frame_support::storage::IterableStorageMap; use frame_support::traits::{Currency, ExistenceRequirement, Get, Imbalance, WithdrawReasons}; use frame_support::{decl_module, decl_storage, ensure, Parameter}; -use rstd::collections::btree_map::BTreeMap; -use rstd::prelude::*; 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::*; diff --git a/runtime-modules/storage/Cargo.toml b/runtime-modules/storage/Cargo.toml index 096ad14ec5..84c5b35aea 100644 --- a/runtime-modules/storage/Cargo.toml +++ b/runtime-modules/storage/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -31,7 +31,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'sp-arithmetic/std', diff --git a/runtime-modules/storage/src/data_directory.rs b/runtime-modules/storage/src/data_directory.rs index 138df13a45..777f5896f5 100644 --- a/runtime-modules/storage/src/data_directory.rs +++ b/runtime-modules/storage/src/data_directory.rs @@ -25,9 +25,9 @@ use codec::{Decode, Encode}; use frame_support::dispatch::DispatchResult; use frame_support::traits::Get; use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; -use rstd::collections::btree_map::BTreeMap; -use rstd::vec::Vec; 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; diff --git a/runtime-modules/storage/src/data_object_storage_registry.rs b/runtime-modules/storage/src/data_object_storage_registry.rs index d5fd96f108..d5d36a6255 100644 --- a/runtime-modules/storage/src/data_object_storage_registry.rs +++ b/runtime-modules/storage/src/data_object_storage_registry.rs @@ -25,9 +25,9 @@ use codec::{Codec, Decode, Encode}; use frame_support::dispatch::DispatchResult; use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter}; -use rstd::vec::Vec; 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}; diff --git a/runtime-modules/storage/src/data_object_type_registry.rs b/runtime-modules/storage/src/data_object_type_registry.rs index a3c14d881b..d544a9c419 100644 --- a/runtime-modules/storage/src/data_object_type_registry.rs +++ b/runtime-modules/storage/src/data_object_type_registry.rs @@ -26,9 +26,9 @@ use codec::{Codec, Decode, Encode}; use frame_support::dispatch::DispatchError; use frame_support::weights::Weight; use frame_support::{decl_error, decl_event, decl_module, decl_storage, Parameter}; -use rstd::vec::Vec; use sp_arithmetic::traits::BaseArithmetic; use sp_runtime::traits::{MaybeSerialize, Member}; +use sp_std::vec::Vec; use crate::{StorageWorkingGroup, StorageWorkingGroupInstance}; diff --git a/runtime-modules/storage/src/tests/data_directory.rs b/runtime-modules/storage/src/tests/data_directory.rs index 5cc5df24b2..eb6dbbf4a3 100644 --- a/runtime-modules/storage/src/tests/data_directory.rs +++ b/runtime-modules/storage/src/tests/data_directory.rs @@ -1,7 +1,7 @@ #![cfg(test)] use frame_support::dispatch::DispatchError; -use rstd::collections::btree_map::BTreeMap; +use sp_std::collections::btree_map::BTreeMap; use system::RawOrigin; use super::mock::*; diff --git a/runtime-modules/versioned-store-permissions/Cargo.toml b/runtime-modules/versioned-store-permissions/Cargo.toml index b973cf2178..6dc4d68565 100755 --- a/runtime-modules/versioned-store-permissions/Cargo.toml +++ b/runtime-modules/versioned-store-permissions/Cargo.toml @@ -6,7 +6,7 @@ edition = '2018' [dependencies] codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] } -rstd = { package = 'sp-std', 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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -22,7 +22,7 @@ timestamp = { package = 'pallet-timestamp', default-features = false, git = 'htt default = ['std'] std = [ 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'sp-arithmetic/std', 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 bd5d2f9bac..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::vec::Vec; +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 60a85c65e0..82e3d7ea34 100755 --- a/runtime-modules/versioned-store-permissions/src/lib.rs +++ b/runtime-modules/versioned-store-permissions/src/lib.rs @@ -3,10 +3,10 @@ use codec::Codec; use frame_support::{decl_module, decl_storage, ensure, Parameter}; -use rstd::collections::btree_map::BTreeMap; -use rstd::vec::Vec; 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. diff --git a/runtime-modules/versioned-store-permissions/src/operations.rs b/runtime-modules/versioned-store-permissions/src/operations.rs index c6b7f77fb5..f088a7585e 100644 --- a/runtime-modules/versioned-store-permissions/src/operations.rs +++ b/runtime-modules/versioned-store-permissions/src/operations.rs @@ -1,7 +1,7 @@ use codec::{Decode, Encode}; -use rstd::collections::btree_map::BTreeMap; -use rstd::vec; -use rstd::vec::Vec; +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/tests.rs b/runtime-modules/versioned-store-permissions/src/tests.rs index 6e785f7523..a7988dc69b 100644 --- a/runtime-modules/versioned-store-permissions/src/tests.rs +++ b/runtime-modules/versioned-store-permissions/src/tests.rs @@ -2,7 +2,7 @@ use super::*; use crate::mock::*; -use rstd::collections::btree_set::BTreeSet; +use sp_std::collections::btree_set::BTreeSet; use versioned_store::PropertyType; use frame_support::{assert_err, assert_ok}; diff --git a/runtime-modules/versioned-store/Cargo.toml b/runtime-modules/versioned-store/Cargo.toml index 71730a1cc3..85e611fc20 100755 --- a/runtime-modules/versioned-store/Cargo.toml +++ b/runtime-modules/versioned-store/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} @@ -23,7 +23,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', ] \ No newline at end of file diff --git a/runtime-modules/versioned-store/src/lib.rs b/runtime-modules/versioned-store/src/lib.rs index d03c208e7c..f4dd12b126 100755 --- a/runtime-modules/versioned-store/src/lib.rs +++ b/runtime-modules/versioned-store/src/lib.rs @@ -16,9 +16,9 @@ use serde::{Deserialize, Serialize}; use codec::{Decode, Encode}; use frame_support::{decl_event, decl_module, decl_storage, ensure}; -use rstd::collections::btree_set::BTreeSet; -use rstd::vec; -use rstd::vec::Vec; +use sp_std::collections::btree_set::BTreeSet; +use sp_std::vec; +use sp_std::vec::Vec; mod example; mod mock; @@ -350,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()); diff --git a/runtime-modules/working-group/Cargo.toml b/runtime-modules/working-group/Cargo.toml index 3b5c3f4935..039acd5726 100644 --- a/runtime-modules/working-group/Cargo.toml +++ b/runtime-modules/working-group/Cargo.toml @@ -7,7 +7,7 @@ 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'] } -rstd = { package = 'sp-std', 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'} sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} @@ -30,7 +30,7 @@ default = ['std'] std = [ 'serde', 'codec/std', - 'rstd/std', + 'sp-std/std', 'frame-support/std', 'system/std', 'sp-arithmetic/std', diff --git a/runtime-modules/working-group/src/errors.rs b/runtime-modules/working-group/src/errors.rs index 7a17a5af35..7b5f8c020b 100644 --- a/runtime-modules/working-group/src/errors.rs +++ b/runtime-modules/working-group/src/errors.rs @@ -329,7 +329,7 @@ macro_rules! ensure_on_wrapped_error { } impl, I: Instance> - rstd::convert::From> for Error + sp_std::convert::From> for Error { fn from(wrapper: WrappedError) -> Self { match wrapper.error { @@ -343,7 +343,7 @@ impl, I: Instance> } } -impl, I: Instance> rstd::convert::From> +impl, I: Instance> sp_std::convert::From> for Error { fn from(wrapper: WrappedError) -> Self { @@ -372,7 +372,7 @@ impl, I: Instance> rstd::convert::From, I: Instance> rstd::convert::From> +impl, I: Instance> sp_std::convert::From> for Error { fn from(wrapper: WrappedError) -> Self { @@ -387,7 +387,7 @@ impl, I: Instance> rstd::convert::From, I: Instance> rstd::convert::From>> +impl, I: Instance> sp_std::convert::From>> for Error { fn from(wrapper: WrappedError>) -> Self { @@ -453,8 +453,8 @@ impl, I: Instance> rstd::convert::From, I: Instance> rstd::convert::From> - for Error +impl, I: Instance> + sp_std::convert::From> for Error { fn from(wrapper: WrappedError) -> Self { match wrapper.error { @@ -477,7 +477,7 @@ impl, I: Instance> rstd::convert::From, I: Instance> rstd::convert::From> +impl, I: Instance> sp_std::convert::From> for Error { fn from(wrapper: WrappedError) -> Self { @@ -505,7 +505,7 @@ impl, I: Instance> rstd::convert::From, I: Instance> - rstd::convert::From> + sp_std::convert::From> for Error { fn from(wrapper: WrappedError) -> Self { @@ -523,7 +523,7 @@ impl, I: Instance> } } -impl, I: Instance> rstd::convert::From> +impl, I: Instance> sp_std::convert::From> for Error { fn from(wrapper: WrappedError) -> Self { @@ -545,7 +545,7 @@ impl, I: Instance> rstd::convert::From, I: Instance> - rstd::convert::From>> + sp_std::convert::From>> for Error { fn from(wrapper: WrappedError>) -> Self { @@ -574,7 +574,7 @@ impl, I: Instance> } impl, I: Instance> - rstd::convert::From< + sp_std::convert::From< WrappedError>, > for Error { @@ -606,7 +606,7 @@ impl, I: Instance> } impl, I: Instance> - rstd::convert::From>> + sp_std::convert::From>> for Error { fn from(wrapper: WrappedError>) -> Self { @@ -628,7 +628,7 @@ impl, I: Instance> } impl, I: Instance> - rstd::convert::From>> + sp_std::convert::From>> for Error { fn from(wrapper: WrappedError>) -> Self { @@ -656,7 +656,7 @@ impl, I: Instance> } impl, I: Instance> - rstd::convert::From>> + sp_std::convert::From>> for Error { fn from(wrapper: WrappedError>) -> Self { @@ -672,7 +672,7 @@ impl, I: Instance> } } -impl, I: Instance> rstd::convert::From> +impl, I: Instance> sp_std::convert::From> for Error { fn from(wrapper: WrappedError) -> Self { diff --git a/runtime-modules/working-group/src/lib.rs b/runtime-modules/working-group/src/lib.rs index 51d5b18de8..e057b7a575 100644 --- a/runtime-modules/working-group/src/lib.rs +++ b/runtime-modules/working-group/src/lib.rs @@ -56,10 +56,10 @@ 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 rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; -use rstd::vec; -use rstd::vec::Vec; 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; @@ -327,7 +327,7 @@ decl_storage! { 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; 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 8c0d9e2501..1593899c7f 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -12,7 +12,7 @@ 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 -rstd = { package = 'sp-std', 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'} 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'} @@ -87,7 +87,7 @@ std = [ 'codec/std', # Substrate primitives - 'rstd/std', + 'sp-std/std', 'sp-core/std', 'sp-api/std', 'sp-version/std', diff --git a/runtime/src/integration/proposals/council_origin_validator.rs b/runtime/src/integration/proposals/council_origin_validator.rs index 0522141ee5..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; diff --git a/runtime/src/integration/proposals/membership_origin_validator.rs b/runtime/src/integration/proposals/membership_origin_validator.rs index 100d63046b..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; diff --git a/runtime/src/integration/proposals/proposal_encoder.rs b/runtime/src/integration/proposals/proposal_encoder.rs index 0c61b778d1..d924d95aa4 100644 --- a/runtime/src/integration/proposals/proposal_encoder.rs +++ b/runtime/src/integration/proposals/proposal_encoder.rs @@ -5,9 +5,9 @@ use working_group::OpeningType; use codec::Encode; use frame_support::print; -use rstd::collections::btree_set::BTreeSet; -use rstd::marker::PhantomData; -use rstd::vec::Vec; +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. diff --git a/runtime/src/integration/proposals/staking_events_handler.rs b/runtime/src/integration/proposals/staking_events_handler.rs index 32d1c81589..202181e0d7 100644 --- a/runtime/src/integration/proposals/staking_events_handler.rs +++ b/runtime/src/integration/proposals/staking_events_handler.rs @@ -2,7 +2,7 @@ use frame_support::traits::{Currency, Imbalance}; use frame_support::StorageMap; -use rstd::marker::PhantomData; +use sp_std::marker::PhantomData; // Balance alias type BalanceOf = diff --git a/runtime/src/integration/storage.rs b/runtime/src/integration/storage.rs index d92e0bf370..5ca1aff99c 100644 --- a/runtime/src/integration/storage.rs +++ b/runtime/src/integration/storage.rs @@ -1,5 +1,5 @@ use frame_support::traits::Randomness; -use rstd::vec::Vec; +use sp_std::vec::Vec; use crate::{ActorId, Runtime}; diff --git a/runtime/src/integration/working_group.rs b/runtime/src/integration/working_group.rs index 873ee4589f..8c11350845 100644 --- a/runtime/src/integration/working_group.rs +++ b/runtime/src/integration/working_group.rs @@ -1,5 +1,5 @@ use frame_support::StorageMap; -use rstd::marker::PhantomData; +use sp_std::marker::PhantomData; use crate::StorageWorkingGroupInstance; use stake::{BalanceOf, NegativeImbalance}; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 698c1b47a4..8be36ed4ed 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -30,8 +30,6 @@ use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; -use rstd::boxed::Box; -use rstd::vec::Vec; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::crypto::KeyTypeId; @@ -45,6 +43,8 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, MultiSignature, Perbill, Perquintill, }; +use sp_std::boxed::Box; +use sp_std::vec::Vec; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; diff --git a/runtime/src/tests/proposals_integration/working_group_proposals.rs b/runtime/src/tests/proposals_integration/working_group_proposals.rs index fa18eab7a0..b6c04ebe45 100644 --- a/runtime/src/tests/proposals_integration/working_group_proposals.rs +++ b/runtime/src/tests/proposals_integration/working_group_proposals.rs @@ -8,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; From e5f775975ba1db19ef76074d61fe6dab833ea530 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 28 Jul 2020 20:42:09 +0300 Subject: [PATCH 33/56] runtime: Rename timestamp to pallet_timestamp --- runtime-modules/common/Cargo.toml | 4 ++-- runtime-modules/common/src/lib.rs | 4 ++-- runtime-modules/content-working-group/Cargo.toml | 2 +- runtime-modules/content-working-group/src/mock.rs | 2 +- runtime-modules/forum/Cargo.toml | 4 ++-- runtime-modules/forum/src/lib.rs | 2 +- runtime-modules/forum/src/mock.rs | 10 +++++----- runtime-modules/governance/Cargo.toml | 4 ++-- runtime-modules/governance/src/mock.rs | 2 +- runtime-modules/membership/Cargo.toml | 4 ++-- runtime-modules/membership/src/lib.rs | 6 +++--- runtime-modules/membership/src/mock.rs | 2 +- runtime-modules/proposals/codex/Cargo.toml | 4 ++-- runtime-modules/proposals/codex/src/tests/mock.rs | 4 ++-- runtime-modules/proposals/discussion/Cargo.toml | 2 +- runtime-modules/proposals/discussion/src/tests/mock.rs | 2 +- runtime-modules/proposals/engine/Cargo.toml | 4 ++-- runtime-modules/proposals/engine/src/lib.rs | 2 +- runtime-modules/proposals/engine/src/tests/mock/mod.rs | 2 +- runtime-modules/service-discovery/Cargo.toml | 2 +- runtime-modules/service-discovery/src/mock.rs | 2 +- runtime-modules/stake/Cargo.toml | 2 +- runtime-modules/storage/Cargo.toml | 4 ++-- runtime-modules/storage/src/data_directory.rs | 4 ++-- .../storage/src/data_object_storage_registry.rs | 2 +- runtime-modules/storage/src/tests/mock.rs | 2 +- runtime-modules/versioned-store-permissions/Cargo.toml | 2 +- .../versioned-store-permissions/src/mock.rs | 2 +- runtime-modules/versioned-store/Cargo.toml | 2 +- runtime-modules/versioned-store/src/mock.rs | 2 +- runtime-modules/working-group/Cargo.toml | 2 +- runtime-modules/working-group/src/tests/mock.rs | 2 +- runtime/Cargo.toml | 4 ++-- runtime/src/lib.rs | 4 ++-- 34 files changed, 52 insertions(+), 52 deletions(-) diff --git a/runtime-modules/common/Cargo.toml b/runtime-modules/common/Cargo.toml index ede768bb87..b4c98bd9a7 100644 --- a/runtime-modules/common/Cargo.toml +++ b/runtime-modules/common/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = 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'} -timestamp = { package = 'pallet-timestamp', 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'] @@ -20,5 +20,5 @@ std = [ 'sp-runtime/std', 'frame-support/std', 'system/std', - 'timestamp/std', + 'pallet-timestamp/std', ] 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 1ef8c44241..dbf5ab8837 100644 --- a/runtime-modules/content-working-group/Cargo.toml +++ b/runtime-modules/content-working-group/Cargo.toml @@ -25,7 +25,7 @@ common = { package = 'pallet-common', default-features = false, path = '../commo 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'} -timestamp = { package = 'pallet-timestamp', 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'] diff --git a/runtime-modules/content-working-group/src/mock.rs b/runtime-modules/content-working-group/src/mock.rs index ff8193a20e..79d3b6048d 100644 --- a/runtime-modules/content-working-group/src/mock.rs +++ b/runtime-modules/content-working-group/src/mock.rs @@ -102,7 +102,7 @@ impl system::Trait for Test { type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; diff --git a/runtime-modules/forum/Cargo.toml b/runtime-modules/forum/Cargo.toml index 6f8ce7e160..cb6f23ad23 100755 --- a/runtime-modules/forum/Cargo.toml +++ b/runtime-modules/forum/Cargo.toml @@ -12,7 +12,7 @@ system = { package = 'frame-system', default-features = false, git = 'https://gi 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'} -timestamp = { package = 'pallet-timestamp', 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] @@ -29,6 +29,6 @@ std = [ 'sp-std/std', 'sp-arithmetic/std', 'sp-runtime/std', - 'timestamp/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 9c5386a86b..b5a5b28377 100755 --- a/runtime-modules/forum/src/lib.rs +++ b/runtime-modules/forum/src/lib.rs @@ -261,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; diff --git a/runtime-modules/forum/src/mock.rs b/runtime-modules/forum/src/mock.rs index cef68390db..57a506ecc9 100644 --- a/runtime-modules/forum/src/mock.rs +++ b/runtime-modules/forum/src/mock.rs @@ -96,7 +96,7 @@ impl system::Trait for Runtime { type OnKilledAccount = (); } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -456,24 +456,24 @@ 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>; + BlockAndTime<::BlockNumber, ::Moment>; pub type RuntimeThreadId = ::ThreadId; pub type RuntimePostId = ::PostId; diff --git a/runtime-modules/governance/Cargo.toml b/runtime-modules/governance/Cargo.toml index b027e1e6db..cb5572ab53 100644 --- a/runtime-modules/governance/Cargo.toml +++ b/runtime-modules/governance/Cargo.toml @@ -12,7 +12,7 @@ frame-support = { package = 'frame-support', default-features = false, git = 'ht 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'} -timestamp = { package = 'pallet-timestamp', 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'} @@ -33,7 +33,7 @@ std = [ 'system/std', 'sp-arithmetic/std', 'sp-runtime/std', - 'timestamp/std', + 'pallet-timestamp/std', 'membership/std', 'minting/std', 'recurringrewards/std', diff --git a/runtime-modules/governance/src/mock.rs b/runtime-modules/governance/src/mock.rs index 58b33c623a..765d0b3529 100644 --- a/runtime-modules/governance/src/mock.rs +++ b/runtime-modules/governance/src/mock.rs @@ -54,7 +54,7 @@ impl system::Trait for Test { type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; diff --git a/runtime-modules/membership/Cargo.toml b/runtime-modules/membership/Cargo.toml index 247c242c4e..cd4974634a 100644 --- a/runtime-modules/membership/Cargo.toml +++ b/runtime-modules/membership/Cargo.toml @@ -12,7 +12,7 @@ frame-support = { package = 'frame-support', default-features = false, git = 'ht 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'} -timestamp = { package = 'pallet-timestamp', 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] @@ -30,6 +30,6 @@ std = [ 'sp-std/std', 'sp-arithmetic/std', 'sp-runtime/std', - 'timestamp/std', + 'pallet-timestamp/std', 'common/std', ] \ No newline at end of file diff --git a/runtime-modules/membership/src/lib.rs b/runtime-modules/membership/src/lib.rs index 8302752f13..85f174379a 100644 --- a/runtime-modules/membership/src/lib.rs +++ b/runtime-modules/membership/src/lib.rs @@ -25,7 +25,7 @@ use common::currency::{BalanceOf, GovernanceCurrency}; /// Result with string error message. This exists for backward compatibility purpose. pub type DispatchResult = Result<(), &'static str>; -pub trait Trait: system::Trait + GovernanceCurrency + timestamp::Trait { +pub trait Trait: system::Trait + GovernanceCurrency + pallet_timestamp::Trait { type Event: From> + Into<::Event>; type MemberId: Parameter @@ -81,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, @@ -568,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, diff --git a/runtime-modules/membership/src/mock.rs b/runtime-modules/membership/src/mock.rs index 53a86ffdcf..d121d1797e 100644 --- a/runtime-modules/membership/src/mock.rs +++ b/runtime-modules/membership/src/mock.rs @@ -56,7 +56,7 @@ impl system::Trait for Test { type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; diff --git a/runtime-modules/proposals/codex/Cargo.toml b/runtime-modules/proposals/codex/Cargo.toml index 1d804fa094..d921ac5136 100644 --- a/runtime-modules/proposals/codex/Cargo.toml +++ b/runtime-modules/proposals/codex/Cargo.toml @@ -13,7 +13,7 @@ sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'ht 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'} -timestamp = { package = 'pallet-timestamp', 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'} @@ -46,7 +46,7 @@ std = [ 'sp-runtime/std', 'system/std', 'staking/std', - 'timestamp/std', + 'pallet-timestamp/std', 'balances/std', 'membership/std', 'stake/std', diff --git a/runtime-modules/proposals/codex/src/tests/mock.rs b/runtime-modules/proposals/codex/src/tests/mock.rs index 1b09acd3b2..ccef3b3a10 100644 --- a/runtime-modules/proposals/codex/src/tests/mock.rs +++ b/runtime-modules/proposals/codex/src/tests/mock.rs @@ -307,7 +307,7 @@ impl system::Trait for Test { type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -325,5 +325,5 @@ pub type Staking = staking::Module; pub type ProposalCodex = crate::Module; pub type ProposalsEngine = proposals_engine::Module; pub type Balances = balances::Module; -pub type Timestamp = timestamp::Module; +pub type Timestamp = pallet_timestamp::Module; pub type System = system::Module; diff --git a/runtime-modules/proposals/discussion/Cargo.toml b/runtime-modules/proposals/discussion/Cargo.toml index c89452e152..a2bb970833 100644 --- a/runtime-modules/proposals/discussion/Cargo.toml +++ b/runtime-modules/proposals/discussion/Cargo.toml @@ -17,7 +17,7 @@ common = { package = 'pallet-common', default-features = false, path = '../../co 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'} -timestamp = { package = 'pallet-timestamp', 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] diff --git a/runtime-modules/proposals/discussion/src/tests/mock.rs b/runtime-modules/proposals/discussion/src/tests/mock.rs index 3f47d7bc44..c4eb636221 100644 --- a/runtime-modules/proposals/discussion/src/tests/mock.rs +++ b/runtime-modules/proposals/discussion/src/tests/mock.rs @@ -131,7 +131,7 @@ impl system::Trait for Test { type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; diff --git a/runtime-modules/proposals/engine/Cargo.toml b/runtime-modules/proposals/engine/Cargo.toml index 31ff2d96ef..ac1c8551e2 100644 --- a/runtime-modules/proposals/engine/Cargo.toml +++ b/runtime-modules/proposals/engine/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = 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'} -timestamp = { package = 'pallet-timestamp', 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'} @@ -31,7 +31,7 @@ std = [ 'sp-std/std', 'frame-support/std', 'system/std', - 'timestamp/std', + 'pallet-timestamp/std', 'sp-arithmetic/std', 'sp-runtime/std', 'membership/std', diff --git a/runtime-modules/proposals/engine/src/lib.rs b/runtime-modules/proposals/engine/src/lib.rs index d1e0cf1667..282f242fb9 100644 --- a/runtime-modules/proposals/engine/src/lib.rs +++ b/runtime-modules/proposals/engine/src/lib.rs @@ -143,7 +143,7 @@ use common::origin::ActorOriginValidator; 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>; diff --git a/runtime-modules/proposals/engine/src/tests/mock/mod.rs b/runtime-modules/proposals/engine/src/tests/mock/mod.rs index 39af79f61f..e680cc99ce 100644 --- a/runtime-modules/proposals/engine/src/tests/mock/mod.rs +++ b/runtime-modules/proposals/engine/src/tests/mock/mod.rs @@ -165,7 +165,7 @@ impl system::Trait for Test { type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; diff --git a/runtime-modules/service-discovery/Cargo.toml b/runtime-modules/service-discovery/Cargo.toml index 852b7d68ac..74251e094a 100644 --- a/runtime-modules/service-discovery/Cargo.toml +++ b/runtime-modules/service-discovery/Cargo.toml @@ -16,7 +16,7 @@ working-group = { package = 'pallet-working-group', default-features = false, pa [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'} -timestamp = { package = 'pallet-timestamp', 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'} diff --git a/runtime-modules/service-discovery/src/mock.rs b/runtime-modules/service-discovery/src/mock.rs index 5cb94d7b15..d5dcdadf86 100644 --- a/runtime-modules/service-discovery/src/mock.rs +++ b/runtime-modules/service-discovery/src/mock.rs @@ -140,7 +140,7 @@ 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; diff --git a/runtime-modules/stake/Cargo.toml b/runtime-modules/stake/Cargo.toml index 456a4434ae..6fac094f40 100755 --- a/runtime-modules/stake/Cargo.toml +++ b/runtime-modules/stake/Cargo.toml @@ -15,7 +15,7 @@ sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https:// [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'} -timestamp = { package = 'pallet-timestamp', 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] diff --git a/runtime-modules/storage/Cargo.toml b/runtime-modules/storage/Cargo.toml index 84c5b35aea..e4870b425a 100644 --- a/runtime-modules/storage/Cargo.toml +++ b/runtime-modules/storage/Cargo.toml @@ -13,7 +13,7 @@ system = { package = 'frame-system', default-features = false, git = 'https://gi 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'} -timestamp = { package = 'pallet-timestamp', 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'} working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'} common = { package = 'pallet-common', default-features = false, path = '../common'} @@ -37,7 +37,7 @@ std = [ 'sp-arithmetic/std', 'sp-runtime/std', 'membership/std', - 'timestamp/std', + 'pallet-timestamp/std', 'working-group/std', 'common/std', ] diff --git a/runtime-modules/storage/src/data_directory.rs b/runtime-modules/storage/src/data_directory.rs index 777f5896f5..f39bc5fe9d 100644 --- a/runtime-modules/storage/src/data_directory.rs +++ b/runtime-modules/storage/src/data_directory.rs @@ -39,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 @@ -109,7 +109,7 @@ impl Default for LiaisonJudgement { pub type DataObject = DataObjectInternal< MemberId, ::BlockNumber, - ::Moment, + ::Moment, ::DataObjectTypeId, StorageProviderId, >; diff --git a/runtime-modules/storage/src/data_object_storage_registry.rs b/runtime-modules/storage/src/data_object_storage_registry.rs index d5d36a6255..3c0e36cfef 100644 --- a/runtime-modules/storage/src/data_object_storage_registry.rs +++ b/runtime-modules/storage/src/data_object_storage_registry.rs @@ -36,7 +36,7 @@ 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 diff --git a/runtime-modules/storage/src/tests/mock.rs b/runtime-modules/storage/src/tests/mock.rs index eb37f592ac..d696438403 100644 --- a/runtime-modules/storage/src/tests/mock.rs +++ b/runtime-modules/storage/src/tests/mock.rs @@ -123,7 +123,7 @@ impl system::Trait for Test { type OnKilledAccount = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; diff --git a/runtime-modules/versioned-store-permissions/Cargo.toml b/runtime-modules/versioned-store-permissions/Cargo.toml index 6dc4d68565..fc2650bd70 100755 --- a/runtime-modules/versioned-store-permissions/Cargo.toml +++ b/runtime-modules/versioned-store-permissions/Cargo.toml @@ -16,7 +16,7 @@ versioned-store = { package = 'pallet-versioned-store', default-features = false [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'} -timestamp = { package = 'pallet-timestamp', 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'] diff --git a/runtime-modules/versioned-store-permissions/src/mock.rs b/runtime-modules/versioned-store-permissions/src/mock.rs index 7ff0c4b840..d2542b4725 100644 --- a/runtime-modules/versioned-store-permissions/src/mock.rs +++ b/runtime-modules/versioned-store-permissions/src/mock.rs @@ -54,7 +54,7 @@ impl system::Trait for Runtime { type OnKilledAccount = (); } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; diff --git a/runtime-modules/versioned-store/Cargo.toml b/runtime-modules/versioned-store/Cargo.toml index 85e611fc20..83bddd3f22 100755 --- a/runtime-modules/versioned-store/Cargo.toml +++ b/runtime-modules/versioned-store/Cargo.toml @@ -15,7 +15,7 @@ system = { package = 'frame-system', default-features = false, git = 'https://gi 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'} -timestamp = { package = 'pallet-timestamp', 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] diff --git a/runtime-modules/versioned-store/src/mock.rs b/runtime-modules/versioned-store/src/mock.rs index 29fc62a307..8d8f2df93f 100644 --- a/runtime-modules/versioned-store/src/mock.rs +++ b/runtime-modules/versioned-store/src/mock.rs @@ -53,7 +53,7 @@ impl system::Trait for Runtime { type OnKilledAccount = (); } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; diff --git a/runtime-modules/working-group/Cargo.toml b/runtime-modules/working-group/Cargo.toml index 039acd5726..98bbe23543 100644 --- a/runtime-modules/working-group/Cargo.toml +++ b/runtime-modules/working-group/Cargo.toml @@ -23,7 +23,7 @@ common = { package = 'pallet-common', default-features = false, path = '../commo 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'} -timestamp = { package = 'pallet-timestamp', 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'] diff --git a/runtime-modules/working-group/src/tests/mock.rs b/runtime-modules/working-group/src/tests/mock.rs index 4a7984d590..7dafeb183e 100644 --- a/runtime-modules/working-group/src/tests/mock.rs +++ b/runtime-modules/working-group/src/tests/mock.rs @@ -108,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; diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 1593899c7f..91f76455c3 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -47,7 +47,7 @@ pallet-randomness-collective-flip = { package = 'pallet-randomness-collective-fl 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'} -timestamp = { package = 'pallet-timestamp', 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'} @@ -108,7 +108,7 @@ std = [ 'system/std', # Pallets - 'timestamp/std', + 'pallet-timestamp/std', 'pallet-balances/std', 'pallet-transaction-payment/std', 'pallet-transaction-payment-rpc-runtime-api/std', diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 8be36ed4ed..76e958e204 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -341,7 +341,7 @@ parameter_types! { pub const MinimumPeriod: Moment = SLOT_DURATION / 2; } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { type Moment = Moment; type OnTimestampSet = Babe; type MinimumPeriod = MinimumPeriod; @@ -797,7 +797,7 @@ construct_runtime!( // Substrate System: system::{Module, Call, Storage, Config, Event}, Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, - Timestamp: timestamp::{Module, Call, Storage, Inherent}, + Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, Indices: pallet_indices::{Module, Call, Storage, Config, Event}, Balances: pallet_balances::{Module, Call, Storage, Config, Event}, From 02faae04f80c906845914c2bcac885601a402311 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 29 Jul 2020 12:04:44 +0300 Subject: [PATCH 34/56] runtime: Apply rust fmt. --- runtime-modules/forum/src/mock.rs | 6 ++++-- runtime-modules/proposals/engine/src/lib.rs | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime-modules/forum/src/mock.rs b/runtime-modules/forum/src/mock.rs index 57a506ecc9..ce8e73d3b4 100644 --- a/runtime-modules/forum/src/mock.rs +++ b/runtime-modules/forum/src/mock.rs @@ -472,8 +472,10 @@ pub type RuntimePost = Post< RuntimeThreadId, RuntimePostId, >; -pub type RuntimeBlockchainTimestamp = - BlockAndTime<::BlockNumber, ::Moment>; +pub type RuntimeBlockchainTimestamp = BlockAndTime< + ::BlockNumber, + ::Moment, +>; pub type RuntimeThreadId = ::ThreadId; pub type RuntimePostId = ::PostId; diff --git a/runtime-modules/proposals/engine/src/lib.rs b/runtime-modules/proposals/engine/src/lib.rs index 282f242fb9..81936b1e52 100644 --- a/runtime-modules/proposals/engine/src/lib.rs +++ b/runtime-modules/proposals/engine/src/lib.rs @@ -143,7 +143,9 @@ use common::origin::ActorOriginValidator; type MemberId = ::MemberId; /// Proposals engine trait. -pub trait Trait: system::Trait + pallet_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>; From e7c5ea0cda92f102e52b0c6bbc27fda50d833aff Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 29 Jul 2020 12:15:51 +0300 Subject: [PATCH 35/56] runtime: Move out the integration logic outside the runtime lib.rs --- runtime/src/integration/forum.rs | 31 ++++++++ runtime/src/integration/mod.rs | 2 + runtime/src/integration/versioned_store.rs | 50 ++++++++++++ runtime/src/lib.rs | 89 ++-------------------- 4 files changed, 88 insertions(+), 84 deletions(-) create mode 100644 runtime/src/integration/forum.rs create mode 100644 runtime/src/integration/versioned_store.rs 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..3560d1e5c8 100644 --- a/runtime/src/integration/mod.rs +++ b/runtime/src/integration/mod.rs @@ -1,4 +1,6 @@ pub mod content_working_group; +pub mod forum; pub mod proposals; pub mod storage; +pub mod versioned_store; pub mod working_group; diff --git a/runtime/src/integration/versioned_store.rs b/runtime/src/integration/versioned_store.rs new file mode 100644 index 0000000000..38408306fb --- /dev/null +++ b/runtime/src/integration/versioned_store.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/lib.rs b/runtime/src/lib.rs index 76e958e204..2484146b87 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -21,9 +21,7 @@ mod tests; // Runtime integration tests use frame_support::inherent::{CheckInherentsResult, InherentData}; use frame_support::traits::KeyOwnerProofSystem; use frame_support::weights::{IdentityFee, Weight}; -use frame_support::{ - construct_runtime, parameter_types, traits::Randomness, StorageMap, StorageValue, -}; +use frame_support::{construct_runtime, parameter_types, traits::Randomness}; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; @@ -531,57 +529,10 @@ impl versioned_store_permissions::Trait for Runtime { type Credential = Credential; type CredentialChecker = ( integration::content_working_group::ContentWorkingGroupCredentials, - SudoKeyHasAllCredentials, + integration::versioned_store::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::ContentLeadOrSudoKeyCanCreateClasses; } impl hiring::Trait for Runtime { @@ -674,39 +625,9 @@ 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; } From 6396810db9e24ecbbc64b9819d7bce888222cfe5 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 29 Jul 2020 14:23:23 +0300 Subject: [PATCH 36/56] runtime: Update runtime dependencies. --- Cargo.lock | 13 ++ runtime/Cargo.toml | 2 + runtime/src/integration/mod.rs | 2 +- ...tore.rs => versioned_store_permissions.rs} | 0 runtime/src/lib.rs | 183 ++++++++---------- 5 files changed, 102 insertions(+), 98 deletions(-) rename runtime/src/integration/{versioned_store.rs => versioned_store_permissions.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index 529c9b939c..375db18f04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1097,6 +1097,7 @@ dependencies = [ "frame-support", "frame-system", "frame-system-rpc-runtime-api", + "node-primitives", "pallet-authority-discovery", "pallet-authorship", "pallet-babe", @@ -1535,6 +1536,18 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "node-primitives" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-system", + "parity-scale-codec", + "sp-application-crypto", + "sp-core", + "sp-runtime", +] + [[package]] name = "nodrop" version = "0.1.14" diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 91f76455c3..6aabcf1749 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -25,6 +25,7 @@ sp-block-builder = { package = 'sp-block-builder', default-features = false, git 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'} +node-primitives = { package = 'node-primitives', 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'} @@ -100,6 +101,7 @@ std = [ 'sp-block-builder/std', 'sp-session/std', 'sp-staking/std', + 'node-primitives/std', # Frame 'frame-support/std', diff --git a/runtime/src/integration/mod.rs b/runtime/src/integration/mod.rs index 3560d1e5c8..592b56f838 100644 --- a/runtime/src/integration/mod.rs +++ b/runtime/src/integration/mod.rs @@ -2,5 +2,5 @@ pub mod content_working_group; pub mod forum; pub mod proposals; pub mod storage; -pub mod versioned_store; +pub mod versioned_store_permissions; pub mod working_group; diff --git a/runtime/src/integration/versioned_store.rs b/runtime/src/integration/versioned_store_permissions.rs similarity index 100% rename from runtime/src/integration/versioned_store.rs rename to runtime/src/integration/versioned_store_permissions.rs diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2484146b87..ffd592fb01 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -18,10 +18,14 @@ mod migration; #[cfg(test)] mod tests; // Runtime integration tests +use codec::Encode; use frame_support::inherent::{CheckInherentsResult, InherentData}; use frame_support::traits::KeyOwnerProofSystem; -use frame_support::weights::{IdentityFee, Weight}; -use frame_support::{construct_runtime, parameter_types, traits::Randomness}; +use frame_support::weights::{ + constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, + IdentityFee, Weight, +}; +use frame_support::{construct_runtime, debug, parameter_types, traits::Randomness}; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; @@ -33,13 +37,14 @@ use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::crypto::KeyTypeId; use sp_core::OpaqueMetadata; use sp_runtime::curve::PiecewiseLinear; +use sp_runtime::generic::SignedPayload; use sp_runtime::traits::{ - BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, StaticLookup, Verify, + BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, Saturating, StaticLookup, Verify, }; use sp_runtime::transaction_validity::{TransactionSource, TransactionValidity}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, - MultiSignature, Perbill, Perquintill, + MultiSignature, Perbill, Perquintill, SaturatedConversion, }; use sp_std::boxed::Box; use sp_std::vec::Vec; @@ -83,9 +88,6 @@ pub type Index = u32; /// A hash of some data used by the chain. pub type Hash = sp_core::H256; -/// Digest item type. -pub type DigestItem = generic::DigestItem; - /// Moment type pub type Moment = u64; @@ -97,7 +99,7 @@ pub type Credential = u64; /// 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, +/// 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. @@ -114,7 +116,7 @@ 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. +/// to even the core data structures. pub mod opaque { use super::*; @@ -138,11 +140,11 @@ pub mod opaque { pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("joystream-node"), impl_name: create_runtime_str!("joystream-node"), - authoring_version: 6, - spec_version: 20, + authoring_version: 7, + spec_version: 0, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 0, //TODO ?? + transaction_version: 1, }; /// Constants for Babe. @@ -195,51 +197,15 @@ parameter_types! { 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 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 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 MaximumBlockLength = MaximumBlockLength; - /// Portion of the block weight that is available to all normal transactions. - type AvailableBlockRatio = AvailableBlockRatio; - type Version = Version; - //TODO - type BaseCallFilter = (); - type DbWeight = (); - type BlockExecutionWeight = (); - type ExtrinsicBaseWeight = (); - type MaximumExtrinsicWeight = (); - type ModuleToIndex = (); - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); -} - -/* type BaseCallFilter = (); type Origin = Origin; type Call = Call; @@ -264,7 +230,7 @@ impl system::Trait for Runtime { type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); -*/ +} parameter_types! { pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64; @@ -279,11 +245,7 @@ impl pallet_babe::Trait for Runtime { impl pallet_grandpa::Trait for Runtime { type Event = Event; - - //toDO type Call = Call; - type KeyOwnerProofSystem = (); - type KeyOwnerProof = >::Proof; @@ -292,28 +254,66 @@ impl pallet_grandpa::Trait for Runtime { GrandpaId, )>>::IdentificationTuple; - type HandleEquivocation = (); -} - -/* type KeyOwnerProofSystem = Historical; - type KeyOwnerProof = - >::Proof; - - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleEquivocation = pallet_grandpa::EquivocationHandler< Self::KeyOwnerIdentification, node_primitives::report::ReporterAppCrypto, Runtime, Offences, >; +} + +impl system::offchain::CreateSignedTransaction for Runtime +where + Call: From, +{ + fn create_transaction>( + call: Call, + public: ::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 address = Indices::unlookup(account); + let (call, extra, _) = raw_payload.deconstruct(); + Some((call, (address, signature, extra))) + } +} -*/ +impl system::offchain::SigningTypes for Runtime { + type Public = ::Signer; + type Signature = Signature; +} impl system::offchain::SendTransactionTypes for Runtime where @@ -323,15 +323,14 @@ where type OverarchingCall = Call; } +parameter_types! { + pub const IndexDeposit: Balance = 0; // no minimum deposit +} + impl pallet_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 = pallet_indices::SimpleResolveHint; + type AccountIndex = AccountIndex; type Currency = Balances; - //toDO - type Deposit = (); + type Deposit = IndexDeposit; type Event = Event; } @@ -353,20 +352,10 @@ parameter_types! { } impl pallet_balances::Trait for Runtime { - /// The type for recording an account's balance. 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; } @@ -491,8 +480,6 @@ impl pallet_staking::Trait for Runtime { type UnsignedPriority = StakingUnsignedPriority; } -//type SubmitTransaction = TransactionSubmitter; - impl pallet_im_online::Trait for Runtime { type AuthorityId = ImOnlineId; type Event = Event; @@ -501,11 +488,15 @@ impl pallet_im_online::Trait for Runtime { type UnsignedPriority = ImOnlineUnsignedPriority; } +parameter_types! { + pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get(); +} + impl pallet_offences::Trait for Runtime { type Event = Event; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; - type WeightSoftLimit = (); //OffencesWeightSoftLimit; + type WeightSoftLimit = OffencesWeightSoftLimit; } impl pallet_authority_discovery::Trait for Runtime {} @@ -529,10 +520,10 @@ impl versioned_store_permissions::Trait for Runtime { type Credential = Credential; type CredentialChecker = ( integration::content_working_group::ContentWorkingGroupCredentials, - integration::versioned_store::SudoKeyHasAllCredentials, + integration::versioned_store_permissions::SudoKeyHasAllCredentials, ); type CreateClassPermissionsChecker = - integration::versioned_store::ContentLeadOrSudoKeyCanCreateClasses; + integration::versioned_store_permissions::ContentLeadOrSudoKeyCanCreateClasses; } impl hiring::Trait for Runtime { @@ -786,8 +777,6 @@ pub type SignedExtra = ( /// 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 = frame_executive::Executive, Runtime, AllModules>; From 519587ec569cef5bed62a1621b36ef969c17bfb0 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 3 Aug 2020 12:39:10 +0300 Subject: [PATCH 37/56] node: Upgrade to the Substrate 2.0.0-rc4 --- Cargo.lock | 4955 +++++++++++++++++++++++++++++++----- Cargo.toml | 2 +- node/Cargo.toml | 370 ++- node/bin/main.rs | 25 +- node/src/chain_spec.rs | 118 +- node/src/cli.rs | 170 +- node/src/command.rs | 104 + node/src/lib.rs | 4 + node/src/members_config.rs | 14 +- node/src/node_executor.rs | 10 + node/src/node_rpc.rs | 193 ++ node/src/service.rs | 828 ++++-- runtime/Cargo.toml | 10 +- runtime/src/lib.rs | 260 +- runtime/src/primitives.rs | 92 + 15 files changed, 5760 insertions(+), 1395 deletions(-) create mode 100644 node/src/command.rs create mode 100644 node/src/node_executor.rs create mode 100644 node/src/node_rpc.rs create mode 100644 runtime/src/primitives.rs diff --git a/Cargo.lock b/Cargo.lock index 375db18f04..dc44112197 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,6 +10,72 @@ dependencies = [ "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.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d" + +[[package]] +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 = "f7001367fde4c768a19d1029f0a8be5abd9308e1119846d5bd9ad26297b8faf5" +dependencies = [ + "aes-soft", + "aesni", + "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.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4925647ee64e5056cf231608957ce7c81e12d6d6e316b9ce1404778cc1d35fa7" +dependencies = [ + "block-cipher", + "byteorder", + "opaque-debug 0.2.3", +] + +[[package]] +name = "aesni" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050d39b0b7688b3a3254394c3e30a9d66c41dcf9b05b0e2dbdc623f6505d264" +dependencies = [ + "block-cipher", + "opaque-debug 0.2.3", +] + [[package]] name = "ahash" version = "0.2.18" @@ -36,7 +102,25 @@ checksum = "4f823d037a7ec6ea2197046bafd4ae150e6bc36f9ca347404f46a46823fa84f2" dependencies = [ "approx", "num-complex", - "num-traits", + "num-traits 0.2.11", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.8", ] [[package]] @@ -51,9 +135,15 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" dependencies = [ - "num-traits", + "num-traits 0.2.11", ] +[[package]] +name = "arc-swap" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" + [[package]] name = "arrayref" version = "0.3.6" @@ -90,10 +180,16 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" dependencies = [ - "quote", - "syn", + "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" @@ -130,6 +226,29 @@ dependencies = [ "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.8", +] + [[package]] name = "autocfg" version = "0.1.7" @@ -170,6 +289,36 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + +[[package]] +name = "bindgen" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c72a978d268b1d70b0e963217e60fdabd9523a941457a6c42a7315d15c7e89e5" +dependencies = [ + "bitflags", + "cexpr", + "cfg-if", + "clang-sys", + "clap", + "env_logger", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote 1.0.7", + "regex", + "rustc-hash", + "shlex", + "which", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -192,6 +341,31 @@ dependencies = [ "radium", ] +[[package]] +name = "blake2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" +dependencies = [ + "byte-tools", + "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]] name = "blake2-rfc" version = "0.2.18" @@ -233,7 +407,25 @@ dependencies = [ "block-padding", "byte-tools", "byteorder", - "generic-array", + "generic-array 0.12.3", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.3", +] + +[[package]] +name = "block-cipher" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa136449e765dc7faa244561ccae839c394048667929af599b5d931ebe7b7f10" +dependencies = [ + "generic-array 0.14.3", ] [[package]] @@ -255,7 +447,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "parking_lot 0.10.0", + "parking_lot 0.10.2", "slab", ] @@ -265,6 +457,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" +[[package]] +name = "bstr" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" +dependencies = [ + "memchr", +] + [[package]] name = "bumpalo" version = "3.2.1" @@ -289,17 +490,46 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "either", + "iovec", +] + [[package]] name = "bytes" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +[[package]] +name = "c_linked_list" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +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.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" +dependencies = [ + "nom", +] [[package]] name = "cfg-if" @@ -307,6 +537,68 @@ 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 = "chrono" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" +dependencies = [ + "js-sys", + "num-integer", + "num-traits 0.2.11", + "time", + "wasm-bindgen", +] + +[[package]] +name = "clang-sys" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "2.33.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" +dependencies = [ + "ansi_term 0.11.0", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + [[package]] name = "clear_on_drop" version = "0.2.3" @@ -325,6 +617,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" @@ -351,6 +663,37 @@ 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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.4.3" @@ -387,6 +730,17 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "crossbeam-queue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "maybe-uninit", +] + [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -410,10 +764,29 @@ 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 = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.3", + "subtle 2.2.2", +] + +[[package]] +name = "ct-logs" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d3686f5fa27dbc1d76c751300376e167c5a43387f44bb451fd1c24776e49113" +dependencies = [ + "sct", +] + [[package]] name = "curve25519-dalek" version = "2.0.0" @@ -421,7 +794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" dependencies = [ "byteorder", - "digest", + "digest 0.8.1", "rand_core 0.5.1", "subtle 2.2.2", "zeroize", @@ -440,8 +813,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "298998b1cf6b5b2c8a7b023dfd45821825ce3ba8a8af55c921a0e734e4653f76" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -456,39 +829,127 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array", + "generic-array 0.12.3", ] [[package]] -name = "downcast" -version = "0.10.0" +name = "digest" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.3", +] [[package]] -name = "ed25519-dalek" -version = "1.0.0-pre.3" +name = "directories" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" +checksum = "551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c" dependencies = [ - "clear_on_drop", - "curve25519-dalek", - "rand 0.7.3", - "sha2", + "cfg-if", + "dirs-sys", ] [[package]] -name = "either" -version = "1.5.3" +name = "dirs-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" +dependencies = [ + "libc", + "redox_users", + "winapi 0.3.8", +] + +[[package]] +name = "dns-parser" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" +dependencies = [ + "byteorder", + "quick-error", +] + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "downcast" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" + +[[package]] +name = "ed25519-dalek" +version = "1.0.0-pre.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" +dependencies = [ + "clear_on_drop", + "curve25519-dalek", + "rand 0.7.3", + "sha2 0.8.1", +] + +[[package]] +name = "either" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +[[package]] +name = "enum-primitive-derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2b90e520ec62c1864c8c78d637acbfe8baf5f63240f2fb8165b8325c07812dd" +dependencies = [ + "num-traits 0.1.43", + "quote 0.3.15", + "syn 0.11.11", +] + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "environmental" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" +[[package]] +name = "erased-serde" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ca8b296792113e1500fd935ae487be6e00ce318952a6880555554824d6ebf38" +dependencies = [ + "serde", +] + +[[package]] +name = "exit-future" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" +dependencies = [ + "futures 0.3.4", +] + [[package]] name = "failure" version = "0.1.7" @@ -506,8 +967,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", "synstructure", ] @@ -517,6 +978,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "fdlimit" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da54a593b34c71b889ee45f5b5bb900c74148c5f7f8c6a9479ee7899f69603c" +dependencies = [ + "libc", +] + [[package]] name = "finality-grandpa" version = "0.12.3" @@ -524,10 +994,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8feb87a63249689640ac9c011742c33139204e3c134293d3054022276869133b" dependencies = [ "either", - "futures", + "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", ] @@ -550,13 +1020,26 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +[[package]] +name = "flate2" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e" +dependencies = [ + "cfg-if", + "crc32fast", + "libc", + "libz-sys", + "miniz_oxide", +] + [[package]] name = "float-cmp" 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]] @@ -565,6 +1048,14 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "fork-tree" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", +] + [[package]] name = "fragile" version = "1.0.0" @@ -588,6 +1079,24 @@ dependencies = [ "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" @@ -646,8 +1155,8 @@ source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478 dependencies = [ "frame-support-procedural-tools", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -658,8 +1167,8 @@ dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -668,8 +1177,8 @@ version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -697,6 +1206,18 @@ dependencies = [ "sp-api", ] +[[package]] +name = "fs-swap" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "921d332c89b3b61a826de38c61ee5b6e02c56806cade1b0e5d81bd71f57a71bb" +dependencies = [ + "lazy_static", + "libc", + "libloading", + "winapi 0.3.8", +] + [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -719,6 +1240,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "futures" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" + [[package]] name = "futures" version = "0.3.4" @@ -744,12 +1271,53 @@ dependencies = [ "futures-sink", ] +[[package]] +name = "futures-channel-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a" +dependencies = [ + "futures-core-preview", +] + [[package]] name = "futures-core" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" +[[package]] +name = "futures-core-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a" + +[[package]] +name = "futures-cpupool" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +dependencies = [ + "futures 0.1.29", + "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" @@ -776,8 +1344,8 @@ checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" dependencies = [ "proc-macro-hack", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -803,6 +1371,10 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +dependencies = [ + "gloo-timers", + "send_wrapper 0.4.0", +] [[package]] name = "futures-util" @@ -810,6 +1382,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", @@ -823,6 +1396,48 @@ dependencies = [ "slab", ] +[[package]] +name = "futures-util-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" +dependencies = [ + "futures-channel-preview", + "futures-core-preview", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" + [[package]] name = "generic-array" version = "0.12.3" @@ -832,6 +1447,38 @@ 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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" +dependencies = [ + "c_linked_list", + "get_if_addrs-sys", + "libc", + "winapi 0.2.8", +] + +[[package]] +name = "get_if_addrs-sys" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" +dependencies = [ + "gcc", + "libc", +] + [[package]] name = "getrandom" version = "0.1.14" @@ -841,6 +1488,66 @@ 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.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "globset" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "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", + "bytes 0.4.12", + "fnv", + "futures 0.1.29", + "http 0.1.21", + "indexmap", + "log", + "slab", + "string", + "tokio-io", ] [[package]] @@ -849,15 +1556,15 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.1", "indexmap", "slab", - "tokio", + "tokio 0.2.22", "tokio-util", "tracing", ] @@ -920,14 +1627,33 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +[[package]] +name = "hex-literal" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" +dependencies = [ + "hex-literal-impl", + "proc-macro-hack", +] + +[[package]] +name = "hex-literal-impl" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "853f769599eb31de176303197b7ba4973299c38c7a7604a6bc88c3eef05b9b46" +dependencies = [ + "proc-macro-hack", +] + [[package]] name = "hmac" 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]] @@ -936,59 +1662,151 @@ 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", ] +[[package]] +name = "http" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" +dependencies = [ + "bytes 0.4.12", + "fnv", + "itoa", +] + [[package]] name = "http" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "itoa", ] [[package]] name = "http-body" -version = "0.3.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" dependencies = [ - "bytes", - "http", + "bytes 0.4.12", + "futures 0.1.29", + "http 0.1.21", + "tokio-buf", ] [[package]] -name = "httparse" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "hyper" +version = "0.12.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "futures-cpupool", + "h2 0.1.26", + "http 0.1.21", + "http-body 0.1.0", + "httparse", + "iovec", + "itoa", + "log", + "net2", + "rustc_version", + "time", + "tokio 0.1.22", + "tokio-buf", + "tokio-executor 0.1.10", + "tokio-io", + "tokio-reactor", + "tokio-tcp", + "tokio-threadpool", + "tokio-timer", + "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", + "bytes 0.5.6", "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.2.6", + "http 0.2.1", + "http-body 0.3.1", "httparse", "itoa", "pin-project", + "socket2", "time", - "tokio", + "tokio 0.2.22", "tower-service", "tracing", - "want", + "want 0.3.0", +] + +[[package]] +name = "hyper-rustls" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac965ea399ec3a25ac7d13b8affd4b8f39325cca00858ddf5eb29b79e6b14b08" +dependencies = [ + "bytes 0.5.6", + "ct-logs", + "futures-util", + "hyper 0.13.7", + "log", + "rustls", + "rustls-native-certs", + "tokio 0.2.22", + "tokio-rustls", + "webpki", +] + +[[package]] +name = "idna" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -1036,8 +1854,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -1056,6 +1874,16 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" +[[package]] +name = "intervalier" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64fa110ec7b8f493f416eed552740d10e7030ad5f63b2308f82c9608ec2df275" +dependencies = [ + "futures 0.3.4", + "futures-timer 2.0.2", +] + [[package]] name = "iovec" version = "0.1.4" @@ -1065,6 +1893,18 @@ 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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" + [[package]] name = "itertools" version = "0.8.2" @@ -1089,6 +1929,92 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +[[package]] +name = "jobserver" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +dependencies = [ + "libc", +] + +[[package]] +name = "joystream-node" +version = "3.0.0" +dependencies = [ + "frame-benchmarking", + "frame-benchmarking-cli", + "frame-support", + "frame-system", + "futures 0.3.4", + "hex-literal", + "joystream-node-runtime", + "jsonrpc-core", + "log", + "node-inspect", + "pallet-authority-discovery", + "pallet-balances", + "pallet-contracts", + "pallet-contracts-rpc", + "pallet-grandpa", + "pallet-im-online", + "pallet-indices", + "pallet-staking", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc", + "parity-scale-codec", + "parking_lot 0.10.2", + "rand 0.7.3", + "sc-authority-discovery", + "sc-basic-authorship", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-client-db", + "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-offchain", + "sc-rpc", + "sc-rpc-api", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "serde", + "serde_json", + "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-io", + "sp-keyring", + "sp-runtime", + "sp-timestamp", + "sp-transaction-pool", + "structopt", + "substrate-browser-utils", + "substrate-frame-rpc-system", + "tokio 0.1.22", + "tracing", + "vergen", + "wasm-bindgen", + "wasm-bindgen-futures", +] + [[package]] name = "joystream-node-runtime" version = "7.0.0" @@ -1097,7 +2023,6 @@ dependencies = [ "frame-support", "frame-system", "frame-system-rpc-runtime-api", - "node-primitives", "pallet-authority-discovery", "pallet-authorship", "pallet-babe", @@ -1105,6 +2030,9 @@ dependencies = [ "pallet-collective", "pallet-common", "pallet-content-working-group", + "pallet-contracts", + "pallet-contracts-primitives", + "pallet-contracts-rpc-runtime-api", "pallet-finality-tracker", "pallet-forum", "pallet-governance", @@ -1137,6 +2065,7 @@ dependencies = [ "parity-scale-codec", "serde", "sp-api", + "sp-application-crypto", "sp-arithmetic", "sp-authority-discovery", "sp-block-builder", @@ -1162,6 +2091,128 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpc-client-transports" +version = "14.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecbdaacc17243168d9d1fa6b2bd7556a27e1e60a621d8a2a6e590ae2b145d158" +dependencies = [ + "failure", + "futures 0.1.29", + "jsonrpc-core", + "jsonrpc-pubsub", + "log", + "serde", + "serde_json", + "url 1.7.2", +] + +[[package]] +name = "jsonrpc-core" +version = "14.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0747307121ffb9703afd93afbd0fb4f854c38fb873f2c8b90e0e902f27c7b62" +dependencies = [ + "futures 0.1.29", + "log", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "jsonrpc-core-client" +version = "14.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34221123bc79b66279a3fde2d3363553835b43092d629b34f2e760c44dc94713" +dependencies = [ + "jsonrpc-client-transports", +] + +[[package]] +name = "jsonrpc-derive" +version = "14.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fadf6945e227246825a583514534d864554e9f23d80b3c77d034b10983db5ef" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "jsonrpc-http-server" +version = "14.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da906d682799df05754480dac1b9e70ec92e12c19ebafd2662a5ea1c9fd6522" +dependencies = [ + "hyper 0.12.35", + "jsonrpc-core", + "jsonrpc-server-utils", + "log", + "net2", + "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.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d44f5602a11d657946aac09357956d2841299ed422035edf140c552cb057986" +dependencies = [ + "jsonrpc-core", + "log", + "parking_lot 0.10.2", + "rand 0.7.3", + "serde", +] + +[[package]] +name = "jsonrpc-server-utils" +version = "14.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56cbfb462e7f902e21121d9f0d1c2b77b2c5b642e1a4e8f4ebfa2e15b94402bb" +dependencies = [ + "bytes 0.4.12", + "globset", + "jsonrpc-core", + "lazy_static", + "log", + "tokio 0.1.22", + "tokio-codec", + "unicase", +] + +[[package]] +name = "jsonrpc-ws-server" +version = "14.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903d3109fe7c4acb932b567e1e607e0f524ed04741b09fb0e61841bc40a022fc" +dependencies = [ + "jsonrpc-core", + "jsonrpc-server-utils", + "log", + "parking_lot 0.10.2", + "slab", + "ws", +] + [[package]] name = "keccak" version = "0.1.0" @@ -1187,17 +2238,107 @@ dependencies = [ "log", ] +[[package]] +name = "kvdb" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e763b2a9b500ba47948061d1e8bc3b5f03a8a1f067dbcf822a4d2c84d2b54a3a" +dependencies = [ + "parity-util-mem", + "smallvec 1.4.1", +] + +[[package]] +name = "kvdb-memorydb" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73027d5e228de6f503b5b7335d530404fc26230a6ae3e09b33ec6e45408509a4" +dependencies = [ + "kvdb", + "parity-util-mem", + "parking_lot 0.10.2", +] + +[[package]] +name = "kvdb-rocksdb" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84384eca250c7ff67877eda5336f28a86586aaee24acb945643590671f6bfce1" +dependencies = [ + "fs-swap", + "kvdb", + "log", + "num_cpus", + "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]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 = "3286f09f7d4926fc486334f28d8d2e6ebe4f7f9994494b6dab27ddfad2c9b11b" + +[[package]] +name = "libloading" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" +checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +dependencies = [ + "cc", + "winapi 0.3.8", +] [[package]] name = "libm" @@ -1211,15 +2352,26 @@ version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "057eba5432d3e740e313c6e13c9153d0cb76b4f71bfc2e5242ae5bdb7d41af67" dependencies = [ - "bytes", - "futures", + "bytes 0.5.6", + "futures 0.3.4", "lazy_static", "libp2p-core", "libp2p-core-derive", + "libp2p-dns", + "libp2p-identify", + "libp2p-kad", + "libp2p-mdns", + "libp2p-mplex", + "libp2p-noise", + "libp2p-ping", "libp2p-swarm", + "libp2p-tcp", + "libp2p-wasm-ext", + "libp2p-websocket", + "libp2p-yamux", "multihash", - "parity-multiaddr", - "parking_lot 0.10.0", + "parity-multiaddr 0.9.1", + "parking_lot 0.10.2", "pin-project", "smallvec 1.4.1", "wasm-timer", @@ -1236,22 +2388,22 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures", + "futures 0.3.4", "futures-timer 3.0.2", "lazy_static", "libsecp256k1", "log", "multihash", "multistream-select", - "parity-multiaddr", - "parking_lot 0.10.0", + "parity-multiaddr 0.9.1", + "parking_lot 0.10.2", "pin-project", "prost", "prost-build", "rand 0.7.3", "ring", "rw-stream-sink", - "sha2", + "sha2 0.8.1", "smallvec 1.4.1", "thiserror", "unsigned-varint 0.4.0", @@ -1265,57 +2417,288 @@ version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f09548626b737ed64080fde595e06ce1117795b8b9fc4d2629fa36561c583171" dependencies = [ - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "libp2p-swarm" -version = "0.19.1" +name = "libp2p-dns" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce53ff4d127cf8b39adf84dbd381ca32d49bd85788cee08e6669da2495993930" +checksum = "3cc186d9a941fd0207cf8f08ef225a735e2d7296258f570155e525f6ee732f87" dependencies = [ - "futures", + "futures 0.3.4", "libp2p-core", "log", - "rand 0.7.3", - "smallvec 1.4.1", - "void", - "wasm-timer", ] [[package]] -name = "libsecp256k1" -version = "0.3.5" +name = "libp2p-identify" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" +checksum = "62f76075b170d908bae616f550ade410d9d27c013fa69042551dbfc757c7c094" dependencies = [ - "arrayref", - "crunchy", - "digest", - "hmac-drbg", - "rand 0.7.3", - "sha2", - "subtle 2.2.2", - "typenum", + "futures 0.3.4", + "libp2p-core", + "libp2p-swarm", + "log", + "prost", + "prost-build", + "smallvec 1.4.1", + "wasm-timer", ] [[package]] -name = "linregress" -version = "0.1.7" +name = "libp2p-kad" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9290cf6f928576eeb9c096c6fad9d8d452a0a1a70a2bbffa6e36064eedc0aac9" +checksum = "41d6c1d5100973527ae70d82687465b17049c1b717a7964de38b8e65000878ff" dependencies = [ - "failure", - "nalgebra", + "arrayvec 0.5.1", + "bytes 0.5.6", + "either", + "fnv", + "futures 0.3.4", + "futures_codec 0.3.4", + "libp2p-core", + "libp2p-swarm", + "log", + "multihash", + "prost", + "prost-build", + "rand 0.7.3", + "sha2 0.8.1", + "smallvec 1.4.1", + "uint", + "unsigned-varint 0.3.3", + "void", + "wasm-timer", +] + +[[package]] +name = "libp2p-mdns" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f55b2d4b80986e5bf158270ab23268ec0e7f644ece5436fbaabc5155472f357" +dependencies = [ + "async-std", + "data-encoding", + "dns-parser", + "either", + "futures 0.3.4", + "lazy_static", + "libp2p-core", + "libp2p-swarm", + "log", + "net2", + "rand 0.7.3", + "smallvec 1.4.1", + "void", + "wasm-timer", +] + +[[package]] +name = "libp2p-mplex" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be7d913a4cd57de2013257ec73f07d77bfce390b370023e2d59083e5ca079864" +dependencies = [ + "bytes 0.5.6", + "fnv", + "futures 0.3.4", + "futures_codec 0.4.0", + "libp2p-core", + "log", + "parking_lot 0.10.2", + "unsigned-varint 0.4.0", +] + +[[package]] +name = "libp2p-noise" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a03db664653369f46ee03fcec483a378c20195089bb43a26cb9fb0058009ac88" +dependencies = [ + "curve25519-dalek", + "futures 0.3.4", + "lazy_static", + "libp2p-core", + "log", + "prost", + "prost-build", + "rand 0.7.3", + "sha2 0.8.1", + "snow", + "static_assertions", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "libp2p-ping" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dedd34e35a9728d52d59ef36a218e411359a353f9011b2574b86ee790978f6" +dependencies = [ + "futures 0.3.4", + "libp2p-core", + "libp2p-swarm", + "log", + "rand 0.7.3", + "void", + "wasm-timer", +] + +[[package]] +name = "libp2p-swarm" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce53ff4d127cf8b39adf84dbd381ca32d49bd85788cee08e6669da2495993930" +dependencies = [ + "futures 0.3.4", + "libp2p-core", + "log", + "rand 0.7.3", + "smallvec 1.4.1", + "void", + "wasm-timer", +] + +[[package]] +name = "libp2p-tcp" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481500c5774c62e8c413e9535b3f33a0e3dbacf2da63b8d3056c686a9df4146" +dependencies = [ + "async-std", + "futures 0.3.4", + "futures-timer 3.0.2", + "get_if_addrs", + "ipnet", + "libp2p-core", + "log", + "socket2", +] + +[[package]] +name = "libp2p-wasm-ext" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f59fdbb5706f2723ca108c088b1c7a37f735a8c328021f0508007162627e9885" +dependencies = [ + "futures 0.3.4", + "js-sys", + "libp2p-core", + "parity-send-wrapper", + "wasm-bindgen", + "wasm-bindgen-futures", +] + +[[package]] +name = "libp2p-websocket" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "085fbe4c05c4116c2164ab4d5a521eb6e00516c444f61b3ee9f68c7b1e53580b" +dependencies = [ + "async-tls", + "bytes 0.5.6", + "either", + "futures 0.3.4", + "libp2p-core", + "log", + "quicksink", + "rustls", + "rw-stream-sink", + "soketto", + "url 2.1.1", + "webpki", + "webpki-roots 0.18.0", +] + +[[package]] +name = "libp2p-yamux" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da33e7b5f49c75c6a8afb0b8d1e229f5fa48be9f39bd14cdbc21459a02ac6fc" +dependencies = [ + "futures 0.3.4", + "libp2p-core", + "parking_lot 0.10.2", + "thiserror", + "yamux", +] + +[[package]] +name = "librocksdb-sys" +version = "6.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "883213ae3d09bfc3d104aefe94b25ebb183b6f4d3a515b23b14817e1f4854005" +dependencies = [ + "bindgen", + "cc", + "glob", + "libc", +] + +[[package]] +name = "libsecp256k1" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" +dependencies = [ + "arrayref", + "crunchy", + "digest 0.8.1", + "hmac-drbg", + "rand 0.7.3", + "sha2 0.8.1", + "subtle 2.2.2", + "typenum", +] + +[[package]] +name = "libz-sys" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" + +[[package]] +name = "linked_hash_set" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "linregress" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9290cf6f928576eeb9c096c6fad9d8d452a0a1a70a2bbffa6e36064eedc0aac9" +dependencies = [ + "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", ] @@ -1365,6 +2748,16 @@ 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.5" @@ -1404,6 +2797,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "miniz_oxide" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.6.22" @@ -1417,12 +2819,36 @@ dependencies = [ "kernel32-sys", "libc", "log", - "miow", + "miow 0.2.1", "net2", "slab", "winapi 0.2.8", ] +[[package]] +name = "mio-extras" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" +dependencies = [ + "lazycell", + "log", + "mio", + "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" @@ -1446,6 +2872,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" @@ -1469,8 +2905,8 @@ checksum = "826e14e8643cb12103b56efb963e5f9640b69b0f7bdcc460002092df4b0e959f" dependencies = [ "cfg-if", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -1481,9 +2917,9 @@ checksum = "f75db05d738947aa5389863aadafbcf2e509d7ba099dc2ddcdf4fc66bf7a9e03" dependencies = [ "blake2b_simd", "blake2s_simd", - "digest", + "digest 0.8.1", "sha-1", - "sha2", + "sha2 0.8.1", "sha3", "unsigned-varint 0.3.3", ] @@ -1500,8 +2936,8 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9157e87afbc2ef0d84cc0345423d715f445edde00141c93721c162de35a05e5" dependencies = [ - "bytes", - "futures", + "bytes 0.5.6", + "futures 0.3.4", "log", "pin-project", "smallvec 1.4.1", @@ -1516,15 +2952,24 @@ checksum = "aaa9fddbc34c8c35dd2108515587b8ce0cab396f17977b8c738568e4edb521a2" dependencies = [ "alga", "approx", - "generic-array", + "generic-array 0.12.3", "matrixmultiply", "num-complex", "num-rational", - "num-traits", + "num-traits 0.2.11", "rand 0.6.5", "typenum", ] +[[package]] +name = "names" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" +dependencies = [ + "rand 0.3.23", +] + [[package]] name = "net2" version = "0.2.34" @@ -1537,15 +2982,47 @@ dependencies = [ ] [[package]] -name = "node-primitives" -version = "2.0.0-rc4" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "void", +] + +[[package]] +name = "node-inspect" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "frame-system", + "derive_more", + "log", "parity-scale-codec", - "sp-application-crypto", + "sc-cli", + "sc-client-api", + "sc-service", + "sp-blockchain", "sp-core", "sp-runtime", + "structopt", ] [[package]] @@ -1555,30 +3032,55 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" [[package]] -name = "normalize-line-endings" -version = "0.3.0" +name = "nohash-hasher" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] -name = "num-bigint" -version = "0.2.6" +name = "nom" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" dependencies = [ - "autocfg 1.0.0", - "num-integer", - "num-traits", + "memchr", + "version_check", ] [[package]] -name = "num-complex" -version = "0.2.4" +name = "normalize-line-endings" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg 1.0.0", + "num-integer", + "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", + "num-traits 0.2.11", ] [[package]] @@ -1588,7 +3090,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]] @@ -1600,7 +3102,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]] @@ -1615,9 +3126,9 @@ dependencies = [ [[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", @@ -1629,7 +3140,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" dependencies = [ - "parking_lot 0.10.0", + "parking_lot 0.10.2", ] [[package]] @@ -1638,6 +3149,27 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "owning_ref" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "pallet-authority-discovery" version = "2.0.0-rc4" @@ -1757,6 +3289,67 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-contracts" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "frame-support", + "frame-system", + "pallet-contracts-primitives", + "parity-scale-codec", + "parity-wasm", + "pwasm-utils", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-sandbox", + "sp-std", + "wasmi-validation", +] + +[[package]] +name = "pallet-contracts-primitives" +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 = "pallet-contracts-rpc" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "pallet-contracts-primitives", + "pallet-contracts-rpc-runtime-api", + "parity-scale-codec", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", +] + +[[package]] +name = "pallet-contracts-rpc-runtime-api" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "pallet-contracts-primitives", + "parity-scale-codec", + "sp-api", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-finality-tracker" version = "2.0.0-rc4" @@ -2115,8 +3708,8 @@ source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478 dependencies = [ "proc-macro-crate", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -2203,6 +3796,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-transaction-payment-rpc" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "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 = "pallet-transaction-payment-rpc-runtime-api" version = "2.0.0-rc4" @@ -2270,6 +3881,38 @@ dependencies = [ "sp-std", ] +[[package]] +name = "parity-db" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d595e372d119261593297debbe4193811a4dc811d2a1ccbb8caaa6666ad7ab" +dependencies = [ + "blake2-rfc", + "crc32fast", + "libc", + "log", + "memmap", + "parking_lot 0.10.2", +] + +[[package]] +name = "parity-multiaddr" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f77055f9e81921a8cc7bebeb6cded3d128931d51f1e3dd6251f0770a6d431477" +dependencies = [ + "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 = "parity-multiaddr" version = "0.9.1" @@ -2281,11 +3924,26 @@ dependencies = [ "byteorder", "data-encoding", "multihash", - "percent-encoding", + "percent-encoding 2.1.0", "serde", "static_assertions", "unsigned-varint 0.4.0", - "url", + "url 2.1.1", +] + +[[package]] +name = "parity-multihash" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +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]] @@ -2309,8 +3967,33 @@ checksum = "5a0ec292e92e8ec7c58e576adacc1e3f399c597c8f263c42f18420abe58e7245" dependencies = [ "proc-macro-crate", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "parity-send-wrapper" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" + +[[package]] +name = "parity-tokio-ipc" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e57fea504fea33f9fbb5f49f378359030e7e026a6ab849bb9e8f0787376f1bf" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "libc", + "log", + "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]] @@ -2322,8 +4005,9 @@ dependencies = [ "cfg-if", "impl-trait-for-tuples", "parity-util-mem-derive", - "parking_lot 0.10.0", + "parking_lot 0.10.2", "primitive-types", + "smallvec 1.4.1", "winapi 0.3.8", ] @@ -2334,7 +4018,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ "proc-macro2", - "syn", + "syn 1.0.17", "synstructure", ] @@ -2357,12 +4041,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ "lock_api", - "parking_lot_core 0.7.0", + "parking_lot_core 0.7.2", ] [[package]] @@ -2382,9 +4066,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ "cfg-if", "cloudabi", @@ -2412,8 +4096,8 @@ checksum = "a62486e111e571b1e93b710b61e8f493c0013be39629b714cb166bdb06aa5a8a" dependencies = [ "proc-macro-hack", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -2423,9 +4107,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" dependencies = [ "byteorder", - "crypto-mac", + "crypto-mac 0.7.0", ] +[[package]] +name = "pdqselect" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec91767ecc0a0bbe558ce8c9da33c068066c57ecc8bb8477ef8c1ad3ef77c27" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" + [[package]] name = "percent-encoding" version = "2.1.0" @@ -2458,8 +4160,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -2474,6 +4176,31 @@ version = "0.1.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" +[[package]] +name = "pkg-config" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" + +[[package]] +name = "poly1305" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b42192ab143ed7619bf888a7f9c6733a9a2153b218e2cd557cfdb52fbf9bb1" +dependencies = [ + "universal-hash", +] + +[[package]] +name = "polyval" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9a50142b55ab3ed0e9f68dfb3709f1d90d29da24e91033f28b96330643107dc" +dependencies = [ + "cfg-if", + "universal-hash", +] + [[package]] name = "ppv-lite86" version = "0.2.6" @@ -2530,6 +4257,32 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-error" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc175e9777c3116627248584e8f8b3e2987405cabe1c0adf7d1dd28f09dc7880" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cc9795ca17eb581285ec44936da7fc2335a3f34f2ddd13118b6f4d515435c50" +dependencies = [ + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", + "syn-mid", + "version_check", +] + [[package]] name = "proc-macro-hack" version = "0.5.15" @@ -2548,7 +4301,22 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ - "unicode-xid", + "unicode-xid 0.2.0", +] + +[[package]] +name = "procfs" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c434e93ef69c216e68e4f417c927b4f31502c3560b72cfdb6827e2321c5c6b3e" +dependencies = [ + "bitflags", + "byteorder", + "chrono", + "hex", + "lazy_static", + "libc", + "libflate", ] [[package]] @@ -2571,7 +4339,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce49aefe0a6144a45de32927c77bd2859a5f7677b55f220ae5b744e87389c212" dependencies = [ - "bytes", + "bytes 0.5.6", "prost-derive", ] @@ -2581,7 +4349,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26" dependencies = [ - "bytes", + "bytes 0.5.6", "heck", "itertools 0.8.2", "log", @@ -2602,8 +4370,8 @@ dependencies = [ "anyhow", "itertools 0.8.2", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -2612,7 +4380,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1834f67c0697c001304b75be76f67add9c89742eda3a085ad8ee0bb38c3417aa" dependencies = [ - "bytes", + "bytes 0.5.6", "prost", ] @@ -2622,11 +4390,45 @@ version = "2.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d883f78645c21b7281d21305181aa1f4dd9e9363e7cf2566c93121552cff003e" +[[package]] +name = "pwasm-utils" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f7a12f176deee919f4ba55326ee17491c8b707d0987aed822682c821b660192" +dependencies = [ + "byteorder", + "log", + "parity-wasm", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quicksink" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858" +dependencies = [ + "futures-core", + "futures-sink", + "pin-project-lite", +] + [[package]] name = "quote" -version = "1.0.3" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ "proc-macro2", ] @@ -2637,6 +4439,29 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" +[[package]] +name = "rand" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" +dependencies = [ + "libc", + "rand 0.4.6", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi 0.3.8", +] + [[package]] name = "rand" version = "0.5.6" @@ -2776,6 +4601,7 @@ dependencies = [ "libc", "rand_core 0.4.2", "rdrand", + "wasm-bindgen", "winapi 0.3.8", ] @@ -2813,6 +4639,31 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" +[[package]] +name = "rayon" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +dependencies = [ + "autocfg 1.0.0", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +dependencies = [ + "crossbeam-deque", + "crossbeam-queue", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + [[package]] name = "rdrand" version = "0.4.0" @@ -2828,6 +4679,17 @@ 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 = [ + "getrandom", + "redox_syscall", + "rust-argon2", +] + [[package]] name = "ref-cast" version = "1.0.2" @@ -2844,8 +4706,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -2892,18 +4754,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] name = "ring" -version = "0.16.12" +version = "0.16.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" +checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" dependencies = [ "cc", "libc", + "once_cell", "spin", "untrusted", "web-sys", @@ -2911,910 +4774,2513 @@ dependencies = [ ] [[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc-hex" -version = "2.1.0" +name = "rle-decode-fast" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" [[package]] -name = "rustc_version" -version = "0.2.3" +name = "rocksdb" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "61aa17a99a2413cd71c1106691bf59dad7de0cd5099127f90e9d99c429c40d4a" dependencies = [ - "semver", + "libc", + "librocksdb-sys", ] [[package]] -name = "rw-stream-sink" -version = "0.2.1" +name = "rpassword" +version = "4.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" +checksum = "99371657d3c8e4d816fb6221db98fa408242b0b53bac08f8676a41f8554fe99f" dependencies = [ - "futures", - "pin-project", - "static_assertions", + "libc", + "winapi 0.3.8", ] [[package]] -name = "safe-mix" -version = "1.0.1" +name = "rust-argon2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" +checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" dependencies = [ - "rustc_version", + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", ] [[package]] -name = "schnorrkel" -version = "0.9.1" +name = "rustc-demangle" +version = "0.1.16" 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", - "subtle 2.2.2", - "zeroize", -] +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" [[package]] -name = "scopeguard" +name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[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" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] -name = "serde" -version = "1.0.106" +name = "rustc-hex" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" -dependencies = [ - "serde_derive", -] +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] -name = "serde_derive" -version = "1.0.106" +name = "rustc_version" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "proc-macro2", - "quote", - "syn", + "semver", ] [[package]] -name = "sha-1" -version = "0.8.2" +name = "rustls" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1" dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", + "base64", + "log", + "ring", + "sct", + "webpki", ] [[package]] -name = "sha2" -version = "0.8.1" +name = "rustls-native-certs" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +checksum = "a75ffeb84a6bd9d014713119542ce415db3a3e4748f0bfce1e1416cd224a23a5" dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", + "openssl-probe", + "rustls", + "schannel", + "security-framework", ] [[package]] -name = "sha3" -version = "0.8.2" +name = "rw-stream-sink" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" +checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" dependencies = [ - "block-buffer", - "byte-tools", - "digest", - "keccak", - "opaque-debug", + "futures 0.3.4", + "pin-project", + "static_assertions", ] [[package]] -name = "slab" -version = "0.4.2" +name = "ryu" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] -name = "smallvec" -version = "0.6.13" +name = "safe-mix" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" dependencies = [ - "maybe-uninit", + "rustc_version", ] [[package]] -name = "smallvec" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" - -[[package]] -name = "sp-api" -version = "2.0.0-rc4" +name = "sc-authority-discovery" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hash-db", + "bytes 0.5.6", + "derive_more", + "futures 0.3.4", + "futures-timer 3.0.2", + "libp2p", + "log", "parity-scale-codec", - "sp-api-proc-macro", + "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", - "sp-state-machine", - "sp-std", - "sp-version", + "substrate-prometheus-endpoint", ] [[package]] -name = "sp-api-proc-macro" -version = "2.0.0-rc4" +name = "sc-basic-authorship" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "blake2-rfc", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", + "futures 0.3.4", + "futures-timer 3.0.2", + "log", + "parity-scale-codec", + "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 = "sp-application-crypto" -version = "2.0.0-rc4" +name = "sc-block-builder" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "parity-scale-codec", - "serde", + "sc-client-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", "sp-core", - "sp-io", - "sp-std", + "sp-runtime", + "sp-state-machine", ] [[package]] -name = "sp-arithmetic" +name = "sc-chain-spec" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", + "impl-trait-for-tuples", + "sc-chain-spec-derive", + "sc-network", + "sc-telemetry", "serde", - "sp-debug-derive", - "sp-std", + "serde_json", + "sp-chain-spec", + "sp-core", + "sp-runtime", ] [[package]] -name = "sp-authority-discovery" +name = "sc-chain-spec-derive" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "parity-scale-codec", - "sp-api", - "sp-application-crypto", - "sp-runtime", - "sp-std", + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] -name = "sp-authorship" -version = "2.0.0-rc4" +name = "sc-cli" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "parity-scale-codec", - "sp-inherents", + "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-std", + "sp-state-machine", + "sp-utils", + "sp-version", + "structopt", + "substrate-prometheus-endpoint", + "time", + "tokio 0.2.22", ] [[package]] -name = "sp-block-builder" +name = "sc-client-api" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "derive_more", + "fnv", + "futures 0.3.4", + "hash-db", + "hex-literal", + "kvdb", + "lazy_static", + "log", "parity-scale-codec", + "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 = "sp-blockchain" -version = "2.0.0-rc4" +name = "sc-client-db" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "derive_more", + "blake2-rfc", + "hash-db", + "kvdb", + "kvdb-memorydb", + "kvdb-rocksdb", + "linked-hash-map", "log", - "lru", + "parity-db", "parity-scale-codec", - "parking_lot 0.10.0", - "sp-block-builder", + "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 = "sp-consensus" +name = "sc-consensus" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "sc-client-api", + "sp-blockchain", + "sp-consensus", + "sp-runtime", +] + +[[package]] +name = "sc-consensus-babe" version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "derive_more", - "futures", + "fork-tree", + "futures 0.3.4", "futures-timer 3.0.2", - "libp2p", "log", + "merlin", + "num-bigint", + "num-rational", + "num-traits 0.2.11", "parity-scale-codec", - "parking_lot 0.10.0", + "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-state-machine", - "sp-std", - "sp-utils", + "sp-timestamp", "sp-version", "substrate-prometheus-endpoint", - "wasm-timer", ] [[package]] -name = "sp-consensus-babe" +name = "sc-consensus-babe-rpc" version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "merlin", + "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", + "sp-api", + "sp-application-crypto", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-core", + "sp-runtime", +] + +[[package]] +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", + "parking_lot 0.10.2", + "sc-client-api", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +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", + "parking_lot 0.10.2", + "sc-client-api", + "sc-telemetry", "sp-api", "sp-application-crypto", + "sp-blockchain", "sp-consensus", - "sp-consensus-vrf", "sp-core", "sp-inherents", "sp-runtime", - "sp-std", - "sp-timestamp", + "sp-state-machine", ] [[package]] -name = "sp-consensus-vrf" +name = "sc-consensus-uncles" version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "parity-scale-codec", - "schnorrkel", + "log", + "sc-client-api", + "sp-authorship", + "sp-consensus", "sp-core", + "sp-inherents", "sp-runtime", - "sp-std", ] [[package]] -name = "sp-core" -version = "2.0.0-rc4" +name = "sc-executor" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "base58", - "blake2-rfc", - "byteorder", "derive_more", - "ed25519-dalek", - "futures", - "hash-db", - "hash256-std-hasher", - "hex", - "impl-serde 0.3.0", "lazy_static", "libsecp256k1", "log", - "merlin", - "num-traits", "parity-scale-codec", - "parity-util-mem", - "parking_lot 0.10.0", - "primitive-types", - "rand 0.7.3", - "regex", - "schnorrkel", - "serde", - "sha2", - "sp-debug-derive", + "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-std", - "sp-storage", - "substrate-bip39", - "tiny-bip39", - "tiny-keccak", - "twox-hash", + "sp-serializer", + "sp-trie", + "sp-version", + "sp-wasm-interface", "wasmi", - "zeroize", ] [[package]] -name = "sp-debug-derive" -version = "2.0.0-rc4" +name = "sc-executor-common" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "derive_more", + "log", + "parity-scale-codec", + "parity-wasm", + "sp-allocator", + "sp-core", + "sp-runtime-interface", + "sp-serializer", + "sp-wasm-interface", + "wasmi", ] [[package]] -name = "sp-externalities" +name = "sc-executor-wasmi" version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "environmental", + "log", "parity-scale-codec", - "sp-std", - "sp-storage", + "sc-executor-common", + "sp-allocator", + "sp-core", + "sp-runtime-interface", + "sp-wasm-interface", + "wasmi", ] [[package]] -name = "sp-finality-grandpa" -version = "2.0.0-rc4" +name = "sc-finality-grandpa" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "assert_matches", + "derive_more", "finality-grandpa", + "fork-tree", + "futures 0.3.4", + "futures-timer 3.0.2", "log", "parity-scale-codec", - "serde", + "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-std", + "sp-utils", + "substrate-prometheus-endpoint", ] [[package]] -name = "sp-finality-tracker" -version = "2.0.0-rc4" +name = "sc-finality-grandpa-rpc" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "parity-scale-codec", - "sp-inherents", - "sp-std", + "derive_more", + "finality-grandpa", + "futures 0.3.4", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "log", + "sc-finality-grandpa", + "serde", + "serde_json", ] [[package]] -name = "sp-inherents" -version = "2.0.0-rc4" +name = "sc-informant" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "derive_more", - "parity-scale-codec", - "parking_lot 0.10.0", - "sp-core", - "sp-std", + "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 = "sp-io" +name = "sc-keystore" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "futures", - "hash-db", - "libsecp256k1", - "log", - "parity-scale-codec", - "parking_lot 0.10.0", + "derive_more", + "hex", + "merlin", + "parking_lot 0.10.2", + "rand 0.7.3", + "serde_json", + "sp-application-crypto", "sp-core", - "sp-externalities", - "sp-runtime-interface", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-trie", - "sp-wasm-interface", + "subtle 2.2.2", ] [[package]] -name = "sp-keyring" +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", + "parking_lot 0.10.2", + "sc-client-api", + "sc-executor", + "sp-api", + "sp-blockchain", "sp-core", + "sp-externalities", "sp-runtime", - "strum", + "sp-state-machine", ] [[package]] -name = "sp-npos-elections" -version = "2.0.0-rc4" +name = "sc-network" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "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", + "slog", + "slog_derive", + "smallvec 0.6.13", "sp-arithmetic", - "sp-npos-elections-compact", - "sp-std", + "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 = "sp-npos-elections-compact" -version = "2.0.0-rc4" +name = "sc-network-gossip" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", + "futures 0.3.4", + "futures-timer 3.0.2", + "libp2p", + "log", + "lru", + "sc-network", + "sp-runtime", + "wasm-timer", ] [[package]] -name = "sp-offchain" +name = "sc-offchain" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "sp-api", + "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", + "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 = "sp-panic-handler" +name = "sc-peerset" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "backtrace", + "futures 0.3.4", + "libp2p", "log", + "serde_json", + "sp-utils", + "wasm-timer", ] [[package]] -name = "sp-runtime" -version = "2.0.0-rc4" +name = "sc-proposer-metrics" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "either", - "hash256-std-hasher", - "impl-trait-for-tuples", "log", - "parity-scale-codec", - "parity-util-mem", - "paste", - "rand 0.7.3", - "serde", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", - "sp-inherents", - "sp-io", - "sp-std", + "substrate-prometheus-endpoint", ] [[package]] -name = "sp-runtime-interface" +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", - "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 = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", + "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 = "sp-session" -version = "2.0.0-rc4" +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", - "sp-api", + "parking_lot 0.10.2", + "serde", + "serde_json", + "sp-chain-spec", "sp-core", + "sp-rpc", "sp-runtime", - "sp-staking", - "sp-std", + "sp-transaction-pool", + "sp-version", ] [[package]] -name = "sp-staking" +name = "sc-rpc-server" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "parity-scale-codec", + "jsonrpc-core", + "jsonrpc-http-server", + "jsonrpc-ipc-server", + "jsonrpc-pubsub", + "jsonrpc-ws-server", + "log", + "serde", + "serde_json", "sp-runtime", - "sp-std", ] [[package]] -name = "sp-state-machine" +name = "sc-service" version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "derive_more", + "directories", + "exit-future", + "futures 0.1.29", + "futures 0.3.4", + "futures-timer 3.0.2", "hash-db", - "itertools 0.9.0", + "jsonrpc-pubsub", + "lazy_static", "log", - "num-traits", + "netstat2", + "parity-multiaddr 0.7.3", "parity-scale-codec", - "parking_lot 0.10.0", + "parity-util-mem", + "parking_lot 0.10.2", + "pin-project", + "procfs", "rand 0.7.3", - "smallvec 1.4.1", + "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", + "slog", + "sp-api", + "sp-application-crypto", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", "sp-core", "sp-externalities", - "sp-panic-handler", + "sp-io", + "sp-runtime", + "sp-session", + "sp-state-machine", + "sp-transaction-pool", "sp-trie", - "trie-db", - "trie-root", + "sp-utils", + "sp-version", + "substrate-prometheus-endpoint", + "sysinfo", + "tempfile", + "tracing", + "wasm-timer", ] [[package]] -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" +name = "sc-state-db" +version = "0.8.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "impl-serde 0.2.3", - "ref-cast", - "serde", - "sp-debug-derive", - "sp-std", + "log", + "parity-scale-codec", + "parity-util-mem", + "parity-util-mem-derive", + "parking_lot 0.10.2", + "sc-client-api", + "sp-core", ] [[package]] -name = "sp-timestamp" +name = "sc-telemetry" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sp-api", - "sp-inherents", - "sp-runtime", - "sp-std", + "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 = "sp-tracing" +name = "sc-tracing" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ + "erased-serde", "log", - "rental", - "tracing", + "parking_lot 0.10.2", + "rustc-hash", + "sc-telemetry", + "serde", + "serde_json", + "slog", + "sp-tracing", + "tracing-core", ] [[package]] -name = "sp-transaction-pool" +name = "sc-transaction-graph" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ "derive_more", - "futures", + "futures 0.3.4", + "linked-hash-map", "log", - "parity-scale-codec", + "parity-util-mem", + "parking_lot 0.10.2", "serde", - "sp-api", "sp-blockchain", + "sp-core", "sp-runtime", + "sp-transaction-pool", "sp-utils", + "wasm-timer", ] [[package]] -name = "sp-trie" +name = "sc-transaction-pool" version = "2.0.0-rc4" source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" dependencies = [ - "hash-db", - "memory-db", + "derive_more", + "futures 0.3.4", + "futures-diagnose", + "intervalier", + "log", "parity-scale-codec", + "parity-util-mem", + "parking_lot 0.10.2", + "sc-client-api", + "sc-transaction-graph", + "sp-api", + "sp-blockchain", "sp-core", - "sp-std", - "trie-db", - "trie-root", + "sp-runtime", + "sp-tracing", + "sp-transaction-pool", + "sp-utils", + "substrate-prometheus-endpoint", + "wasm-timer", ] [[package]] -name = "sp-utils" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ - "futures", - "futures-core", - "futures-timer 3.0.2", "lazy_static", - "prometheus", + "winapi 0.3.8", ] [[package]] -name = "sp-version" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +name = "schnorrkel" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" dependencies = [ - "impl-serde 0.2.3", - "parity-scale-codec", - "serde", - "sp-runtime", - "sp-std", + "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 = "sp-wasm-interface" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +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 = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sp-std", - "wasmi", + "ring", + "untrusted", ] [[package]] -name = "spin" -version = "0.5.2" +name = "security-framework" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] [[package]] -name = "stable_deref_trait" -version = "1.1.1" +name = "security-framework-sys" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" +checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] -name = "static_assertions" -version = "1.1.0" +name = "semver" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +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 = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +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 = [ + "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 = [ + "block-buffer 0.9.0", + "cfg-if", + "cpuid-bool", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha3" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" +dependencies = [ + "block-buffer 0.7.3", + "byte-tools", + "digest 0.8.1", + "keccak", + "opaque-debug 0.2.3", +] + +[[package]] +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 = [ + "arc-swap", + "libc", +] + +[[package]] +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 = [ + "erased-serde", +] + +[[package]] +name = "slog-json" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" +dependencies = [ + "chrono", + "erased-serde", + "serde", + "serde_json", + "slog", +] + +[[package]] +name = "slog-scope" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c44c89dd8b0ae4537d1ae318353eaf7840b4869c536e31c41e963d1ea523ee6" +dependencies = [ + "arc-swap", + "lazy_static", + "slog", +] + +[[package]] +name = "slog_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a945ec7f7ce853e89ffa36be1e27dce9a43e82ff9093bf3461c30d5da74ed11b" +dependencies = [ + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +dependencies = [ + "maybe-uninit", +] + +[[package]] +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 = [ + "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 = "socket2" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", +] + +[[package]] +name = "soketto" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c9dab3f95c9ebdf3a88268c19af668f637a3c5039c2c56ff2d40b1b2d64a25b" +dependencies = [ + "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 = "sp-allocator" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "log", + "sp-core", + "sp-std", + "sp-wasm-interface", +] + +[[package]] +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", + "sp-api-proc-macro", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-version", +] + +[[package]] +name = "sp-api-proc-macro" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "blake2-rfc", + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "sp-application-crypto" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +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", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-authority-discovery" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-application-crypto", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-authorship" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-inherents", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-block-builder" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-inherents", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-blockchain" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "log", + "lru", + "parity-scale-codec", + "parking_lot 0.10.2", + "sp-block-builder", + "sp-consensus", + "sp-runtime", + "sp-state-machine", +] + +[[package]] +name = "sp-chain-spec" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "sp-consensus" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "futures 0.3.4", + "futures-timer 3.0.2", + "libp2p", + "log", + "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 = "sp-consensus-babe" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "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 = "sp-core" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "base58", + "blake2-rfc", + "byteorder", + "derive_more", + "ed25519-dalek", + "futures 0.3.4", + "hash-db", + "hash256-std-hasher", + "hex", + "impl-serde 0.3.0", + "lazy_static", + "libsecp256k1", + "log", + "merlin", + "num-traits 0.2.11", + "parity-scale-codec", + "parity-util-mem", + "parking_lot 0.10.2", + "primitive-types", + "rand 0.7.3", + "regex", + "schnorrkel", + "serde", + "sha2 0.8.1", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "substrate-bip39", + "tiny-bip39", + "tiny-keccak", + "twox-hash", + "wasmi", + "zeroize", +] + +[[package]] +name = "sp-database" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "kvdb", + "parking_lot 0.10.2", +] + +[[package]] +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 = [ + "environmental", + "parity-scale-codec", + "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 = [ + "finality-grandpa", + "log", + "parity-scale-codec", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-finality-tracker" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-inherents", + "sp-std", +] + +[[package]] +name = "sp-inherents" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "derive_more", + "parity-scale-codec", + "parking_lot 0.10.2", + "sp-core", + "sp-std", +] + +[[package]] +name = "sp-io" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "futures 0.3.4", + "hash-db", + "libsecp256k1", + "log", + "parity-scale-codec", + "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 = "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 = [ + "parity-scale-codec", + "serde", + "sp-arithmetic", + "sp-npos-elections-compact", + "sp-std", +] + +[[package]] +name = "sp-npos-elections-compact" +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 = "sp-offchain" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "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", +] + +[[package]] +name = "sp-rpc" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "serde", + "sp-core", +] + +[[package]] +name = "sp-runtime" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "parity-util-mem", + "paste", + "rand 0.7.3", + "serde", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-inherents", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-runtime-interface" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "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 = [ + "Inflector", + "proc-macro-crate", + "proc-macro2", + "quote 1.0.7", + "syn 1.0.17", +] + +[[package]] +name = "sp-sandbox" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-core", + "sp-io", + "sp-std", + "sp-wasm-interface", + "wasmi", +] + +[[package]] +name = "sp-serializer" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "sp-session" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-core", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +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 0.2.11", + "parity-scale-codec", + "parking_lot 0.10.2", + "rand 0.7.3", + "smallvec 1.4.1", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-trie", + "trie-db", + "trie-root", +] + +[[package]] +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 = [ + "impl-serde 0.2.3", + "ref-cast", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-timestamp" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-api", + "sp-inherents", + "sp-runtime", + "sp-std", + "wasm-timer", +] + +[[package]] +name = "sp-tracing" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "log", + "rental", + "tracing", +] + +[[package]] +name = "sp-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", + "log", + "parity-scale-codec", + "serde", + "sp-api", + "sp-blockchain", + "sp-runtime", + "sp-utils", +] + +[[package]] +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", + "sp-core", + "sp-std", + "trie-db", + "trie-root", +] + +[[package]] +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 = [ + "impl-serde 0.2.3", + "parity-scale-codec", + "serde", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-wasm-interface" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-std", + "wasmi", +] + +[[package]] +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 = "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-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", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + +[[package]] +name = "subtle" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" + +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +dependencies = [ + "quote 0.3.15", + "synom", + "unicode-xid 0.0.4", +] + +[[package]] +name = "syn" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" +dependencies = [ + "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", + "quote 1.0.7", + "syn 1.0.17", + "unicode-xid 0.2.0", +] + +[[package]] +name = "sysinfo" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac193374347e7c263c5f547524f36ff8ec6702d56c8799c8331d26dffe8c1e" +dependencies = [ + "cfg-if", + "doc-comment", + "libc", + "ntapi", + "once_cell", + "rayon", + "winapi 0.3.8", +] + +[[package]] +name = "take_mut" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if", + "libc", + "rand 0.7.3", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.8", +] + +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +dependencies = [ + "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]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +dependencies = [ + "libc", + "redox_syscall", + "winapi 0.3.8", +] + +[[package]] +name = "tiny-bip39" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" +dependencies = [ + "failure", + "hmac", + "once_cell", + "pbkdf2", + "rand 0.7.3", + "rustc-hash", + "sha2 0.8.1", + "unicode-normalization", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tokio" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "mio", + "num_cpus", + "tokio-codec", + "tokio-current-thread", + "tokio-executor 0.1.10", + "tokio-fs", + "tokio-io", + "tokio-reactor", + "tokio-sync 0.1.8", + "tokio-tcp", + "tokio-threadpool", + "tokio-timer", + "tokio-udp", + "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 = "statrs" -version = "0.10.0" +name = "tokio-buf" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10102ac8d55e35db2b3fafc26f81ba8647da2e15879ab686a67e6d19af2685e8" +checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" dependencies = [ - "rand 0.5.6", + "bytes 0.4.12", + "either", + "futures 0.1.29", ] [[package]] -name = "strum" -version = "0.16.0" +name = "tokio-codec" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6138f8f88a16d90134763314e3fc76fa3ed6a7db4725d6acf9a3ef95a3188d22" +checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" dependencies = [ - "strum_macros", + "bytes 0.4.12", + "futures 0.1.29", + "tokio-io", ] [[package]] -name = "strum_macros" -version = "0.16.0" +name = "tokio-current-thread" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81" +checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", + "futures 0.1.29", + "tokio-executor 0.1.10", ] [[package]] -name = "substrate-bip39" -version = "0.4.1" +name = "tokio-executor" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c004e8166d6e0aa3a9d5fa673e5b7098ff25f930de1013a21341988151e681bb" +checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel", - "sha2", + "crossbeam-utils", + "futures 0.1.29", ] [[package]] -name = "substrate-prometheus-endpoint" -version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +name = "tokio-executor" +version = "0.2.0-alpha.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ee9ceecf69145923834ea73f32ba40c790fd877b74a7817dd0b089f1eb9c7c8" dependencies = [ - "async-std", - "derive_more", - "futures-util", - "hyper", - "log", - "prometheus", - "tokio", + "futures-util-preview", + "lazy_static", + "tokio-sync 0.2.0-alpha.6", ] [[package]] -name = "substrate-wasm-builder-runner" -version = "1.0.6" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +name = "tokio-fs" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" +dependencies = [ + "futures 0.1.29", + "tokio-io", + "tokio-threadpool", +] [[package]] -name = "subtle" -version = "1.0.0" +name = "tokio-io" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" +checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "log", +] [[package]] -name = "subtle" -version = "2.2.2" +name = "tokio-named-pipes" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" +checksum = "9d282d483052288b2308ba5ee795f5673b159c9bdf63c385a05609da782a5eae" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "mio", + "mio-named-pipes", + "tokio 0.1.22", +] [[package]] -name = "syn" -version = "1.0.17" +name = "tokio-reactor" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" +checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", + "crossbeam-utils", + "futures 0.1.29", + "lazy_static", + "log", + "mio", + "num_cpus", + "parking_lot 0.9.0", + "slab", + "tokio-executor 0.1.10", + "tokio-io", + "tokio-sync 0.1.8", ] [[package]] -name = "synstructure" -version = "0.12.3" +name = "tokio-rustls" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" +checksum = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4" dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", + "futures-core", + "rustls", + "tokio 0.2.22", + "webpki", ] [[package]] -name = "tempfile" -version = "3.1.0" +name = "tokio-service" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" dependencies = [ - "cfg-if", - "libc", - "rand 0.7.3", - "redox_syscall", - "remove_dir_all", - "winapi 0.3.8", + "futures 0.1.29", ] [[package]] -name = "thiserror" -version = "1.0.20" +name = "tokio-sync" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" dependencies = [ - "thiserror-impl", + "fnv", + "futures 0.1.29", ] [[package]] -name = "thiserror-impl" -version = "1.0.20" +name = "tokio-sync" +version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +checksum = "4f1aaeb685540f7407ea0e27f1c9757d258c7c6bf4e3eb19da6fc59b747239d2" dependencies = [ - "proc-macro2", - "quote", - "syn", + "fnv", + "futures-core-preview", + "futures-util-preview", ] [[package]] -name = "thread_local" -version = "1.0.1" +name = "tokio-tcp" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" dependencies = [ - "lazy_static", + "bytes 0.4.12", + "futures 0.1.29", + "iovec", + "mio", + "tokio-io", + "tokio-reactor", ] [[package]] -name = "time" -version = "0.1.42" +name = "tokio-threadpool" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" dependencies = [ - "libc", - "redox_syscall", - "winapi 0.3.8", + "crossbeam-deque", + "crossbeam-queue", + "crossbeam-utils", + "futures 0.1.29", + "lazy_static", + "log", + "num_cpus", + "slab", + "tokio-executor 0.1.10", ] [[package]] -name = "tiny-bip39" -version = "0.7.3" +name = "tokio-timer" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" +checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" dependencies = [ - "failure", - "hmac", - "once_cell", - "pbkdf2", - "rand 0.7.3", - "rustc-hash", - "sha2", - "unicode-normalization", + "crossbeam-utils", + "futures 0.1.29", + "slab", + "tokio-executor 0.1.10", ] [[package]] -name = "tiny-keccak" -version = "2.0.2" +name = "tokio-udp" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" dependencies = [ - "crunchy", + "bytes 0.4.12", + "futures 0.1.29", + "log", + "mio", + "tokio-codec", + "tokio-io", + "tokio-reactor", ] [[package]] -name = "tokio" -version = "0.2.22" +name = "tokio-uds" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" dependencies = [ - "bytes", - "fnv", - "futures-core", - "memchr", - "pin-project-lite", + "bytes 0.4.12", + "futures 0.1.29", + "iovec", + "libc", + "log", + "mio", + "mio-uds", + "tokio-codec", + "tokio-io", + "tokio-reactor", ] [[package]] @@ -3823,12 +7289,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "bytes", + "bytes 0.5.6", "futures-core", "futures-sink", "log", "pin-project-lite", - "tokio", + "tokio 0.2.22", ] [[package]] @@ -3865,8 +7331,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", ] [[package]] @@ -3939,6 +7405,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.4" @@ -3963,23 +7438,55 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" + [[package]] name = "unicode-xid" 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.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f67332660eb59a6f1eb24ff1220c9e8d01738a8503c6002e30bcfe4bd9f2b4a9" +dependencies = [ + "bytes 0.5.6", + "futures-io", + "futures-util", + "futures_codec 0.3.4", +] [[package]] name = "unsigned-varint" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "669d776983b692a906c881fcd0cfb34271a48e197e4d6cb8df32b05bfc3d3fa5" +dependencies = [ + "bytes 0.5.6", + "futures_codec 0.4.0", +] [[package]] name = "untrusted" @@ -3987,23 +7494,73 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "url" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +dependencies = [ + "idna 0.1.5", + "matches", + "percent-encoding 1.0.1", +] + [[package]] name = "url" version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" dependencies = [ - "idna", + "idna 0.2.0", "matches", - "percent-encoding", + "percent-encoding 2.1.0", ] +[[package]] +name = "vcpkg" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[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.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + [[package]] name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "want" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" +dependencies = [ + "futures 0.1.29", + "log", + "try-lock", +] + [[package]] name = "want" version = "0.3.0" @@ -4040,8 +7597,8 @@ dependencies = [ "lazy_static", "log", "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", "wasm-bindgen-shared", ] @@ -4063,7 +7620,7 @@ version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" dependencies = [ - "quote", + "quote 1.0.7", "wasm-bindgen-macro-support", ] @@ -4074,8 +7631,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4092,11 +7649,11 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "324c5e65a08699c9c4334ba136597ab22b85dccd4b65dd1e36ccf8f723a95b54" dependencies = [ - "futures", + "futures 0.3.4", "js-sys", "parking_lot 0.9.0", "pin-utils", - "send_wrapper", + "send_wrapper 0.2.0", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -4111,7 +7668,7 @@ dependencies = [ "libc", "memory_units", "num-rational", - "num-traits", + "num-traits 0.2.11", "parity-wasm", "wasmi-validation", ] @@ -4135,6 +7692,34 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab146130f5f790d45f82aeeb09e55a256573373ec64409fc19a6fb82fb1032ae" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cd5736df7f12a964a5067a12c62fa38e1bd8080aff1f80bc29be7c80d19ab4" +dependencies = [ + "webpki", +] + +[[package]] +name = "webpki-roots" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739" +dependencies = [ + "webpki", +] + [[package]] name = "which" version = "3.1.1" @@ -4172,12 +7757,39 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "ws" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c51a2c47b5798ccc774ffb93ff536aec7c4275d722fd9c740c83cdd1af1f2d94" +dependencies = [ + "byteorder", + "bytes 0.4.12", + "httparse", + "log", + "mio", + "mio-extras", + "rand 0.7.3", + "sha-1", + "slab", + "url 2.1.1", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -4188,6 +7800,31 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "x25519-dalek" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "637ff90c9540fa3073bb577e65033069e4bae7c79d49d74aa3ffdf5342a53217" +dependencies = [ + "curve25519-dalek", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "yamux" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd37e58a1256a0b328ce9c67d8b62ecdd02f4803ba443df478835cb1a41a637c" +dependencies = [ + "futures 0.3.4", + "log", + "nohash-hasher", + "parking_lot 0.10.2", + "rand 0.7.3", + "static_assertions", +] + [[package]] name = "zeroize" version = "1.1.0" @@ -4204,7 +7841,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" dependencies = [ "proc-macro2", - "quote", - "syn", + "quote 1.0.7", + "syn 1.0.17", "synstructure", ] diff --git a/Cargo.toml b/Cargo.toml index 7ed7a3c361..fa1b9d0512 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ members = [ "runtime-modules/versioned-store", "runtime-modules/versioned-store-permissions", "runtime-modules/working-group", -# "node", + "node", # "utils/chain-spec-builder/" ] diff --git a/node/Cargo.toml b/node/Cargo.toml index 704759f57e..ba720ac4ff 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.6.0' +version = '3.0.0' default-run = "joystream-node" [[bin]] @@ -13,144 +13,238 @@ path = 'bin/main.rs' [lib] crate-type = ["cdylib", "rlib"] +#[dependencies] +#derive_more = '0.14.0' +#exit-future = '0.1.4' + +#hex = '0.4' + [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 +codec = { package = "parity-scale-codec", version = "1.3.1" } +serde = { version = "1.0.102", features = ["derive"] } +futures = { version = "0.3.1", features = ["compat"] } +hex-literal = "0.2.1" +jsonrpc-core = "14.2.0" +log = "0.4.8" +rand = "0.7.2" +structopt = { version = "0.3.8"} +tracing = "0.1.10" +parking_lot = "0.10.0" + 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 +tokio = '0.1.22' + +# 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-timestamp = { package = 'sp-timestamp', default-features = false, 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-keyring = { package = 'sp-keyring', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sp-io = { package = 'sp-io', 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' } + +# 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-client-db = { package = 'sc-client-db', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-offchain = { package = 'sc-offchain', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-rpc = { package = 'sc-rpc', 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-tracing = { package = 'sc-tracing', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +sc-telemetry = { package = 'sc-telemetry', 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' } +sp-block-builder = { package = 'sp-block-builder', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +pallet-contracts-rpc = { package = 'pallet-contracts-rpc', 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' } +sc-executor = { package = 'sc-executor', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +frame-benchmarking = { package = 'frame-benchmarking', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } + +#sc-client-api = { version = "2.0.0-rc4", path = "../../../client/api" } +#jsonrpc-core = "14.2.0" +#node-primitives = { version = "2.0.0-rc4", path = "../primitives" } +#node-runtime = { version = "2.0.0-rc4", path = "../runtime" } +#sp-runtime = { version = "2.0.0-rc4", path = "../../../primitives/runtime" } +#sp-api = { version = "2.0.0-rc4", path = "../../../primitives/api" } +#pallet-contracts-rpc = { version = "0.8.0-rc4", path = "../../../frame/contracts/rpc/" } +#pallet-transaction-payment-rpc = { version = "2.0.0-rc4", path = "../../../frame/transaction-payment/rpc/" } +#substrate-frame-rpc-system = { version = "2.0.0-rc4", path = "../../../utils/frame/rpc/system" } +#sp-transaction-pool = { version = "2.0.0-rc4", path = "../../../primitives/transaction-pool" } +#sc-consensus-babe = { version = "0.8.0-rc4", path = "../../../client/consensus/babe" } +#sc-consensus-babe-rpc = { version = "0.8.0-rc4", path = "../../../client/consensus/babe/rpc" } +#sp-consensus-babe = { version = "0.8.0-rc4", path = "../../../primitives/consensus/babe" } +#sc-keystore = { version = "2.0.0-rc4", path = "../../../client/keystore" } +#sc-consensus-epochs = { version = "0.8.0-rc4", path = "../../../client/consensus/epochs" } +#sp-consensus = { version = "0.8.0-rc4", path = "../../../primitives/consensus/common" } +#sp-blockchain = { version = "2.0.0-rc4", path = "../../../primitives/blockchain" } +#sc-finality-grandpa = { version = "0.8.0-rc4", path = "../../../client/finality-grandpa" } +#sc-finality-grandpa-rpc = { version = "0.8.0-rc4", path = "../../../client/finality-grandpa/rpc" } +#sc-rpc-api = { version = "0.8.0-rc4", path = "../../../client/rpc-api" } +#sp-block-builder = { version = "2.0.0-rc4", path = "../../../primitives/block-builder" } + +# frame dependencies +pallet-indices = { package = 'pallet-indices', 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-contracts = { package = 'pallet-contracts', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +frame-system = { package = 'frame-system', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +pallet-balances = { package = 'pallet-balances', 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' } +frame-support = { package = 'frame-support', 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-authority-discovery = { package = 'pallet-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +pallet-staking = { package = 'pallet-staking', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +pallet-grandpa = { package = 'pallet-grandpa', 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' } +frame-benchmarking-cli = { package = 'frame-benchmarking-cli', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +node-inspect = { package = 'node-inspect', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } + +# 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} + + +#[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 [build-dependencies] vergen = '3' diff --git a/node/bin/main.rs b/node/bin/main.rs index 70006bf571..88b0057639 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() +} \ No newline at end of file diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index a602cfd1fe..685cfd52ca 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 node_runtime::{ +use node_runtime::{AccountId, GenesisConfig}; +use sp_runtime::{Perbill}; +use sp_core::{Pair, Public, sr25519}; +use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_finality_grandpa::AuthorityId as GrandpaId; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use serde_json as json; + +use node_runtime::{ContractsConfig, versioned_store::InputValidationLengthConstraint as VsInputValidation, AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig, CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig, DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig, - MembersConfig, MigrationConfig, Perbill, ProposalsCodexConfig, SessionConfig, SessionKeys, + MembersConfig, MigrationConfig, 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; 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,22 +76,31 @@ 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 { - SessionKeys { - grandpa, - babe, - im_online, - } +fn session_keys( + grandpa: GrandpaId, + babe: BabeId, + im_online: ImOnlineId, + authority_discovery: AuthorityDiscoveryId, +) -> SessionKeys { + SessionKeys { grandpa, babe, im_online, authority_discovery } } impl Alternative { @@ -98,6 +110,7 @@ impl Alternative { Alternative::Development => ChainSpec::from_genesis( "Development", "dev", + ChainType::Development, || { testnet_genesis( vec![get_authority_keys_from_seed("Alice")], @@ -110,7 +123,7 @@ impl Alternative { ], ) }, - vec![], + Vec::new(), None, None, Some(chain_spec_properties()), @@ -119,6 +132,7 @@ impl Alternative { Alternative::LocalTestnet => ChainSpec::from_genesis( "Local Testnet", "local_testnet", + ChainType::Local, || { testnet_genesis( vec![ @@ -142,7 +156,7 @@ impl Alternative { ], ) }, - vec![], + Vec::new(), None, None, Some(chain_spec_properties()), @@ -150,14 +164,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 { @@ -178,7 +184,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, ) -> GenesisConfig { @@ -187,6 +200,8 @@ pub fn testnet_genesis( const STASH: Balance = 20 * DOLLARS; const ENDOWMENT: Balance = 100_000 * DOLLARS; + let enable_println = false; + // default codex proposals config parameters let cpcp = node_runtime::ProposalsConfigParameters::default(); let default_text_constraint = node_runtime::working_group::default_text_constraint(); @@ -196,29 +211,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 @@ -229,15 +230,32 @@ 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 }), + 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_indices: Some(IndicesConfig { indices: 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::>(), + }), + pallet_contracts: Some(ContractsConfig { + current_schedule: pallet_contracts::Schedule { + enable_println, // this should only be enabled on development chains + ..Default::default() + }, + }), council: Some(CouncilConfig { active_council: vec![], term_ends_at: 1, diff --git a/node/src/cli.rs b/node/src/cli.rs index 9c33d231aa..2272180966 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..0f4d3ec06d --- /dev/null +++ b/node/src/command.rs @@ -0,0 +1,104 @@ +// 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::{chain_spec, service}; +use crate::cli::{Cli, Subcommand}; +use crate::node_rpc; +use crate::node_executor; + +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 impl_version() -> &'static str { + "3.0.0" + } + + fn description() -> &'static str { + "Joystream substrate node" + } + + fn author() -> &'static str { + "Joystream contributors" + } + + fn support_url() -> &'static str { + "https://www.joystream.org/" + } + + fn copyright_start_year() -> i32 { + 2019 + } + + fn executable_name() -> &'static str { + "joystream-node" + } + + fn load_spec(&self, id: &str) -> std::result::Result, String> { + Ok(match id { + "dev" => Box::new(chain_spec::Alternative::Development.load().unwrap()), //TODO + "local" => Box::new(chain_spec::Alternative::LocalTestnet.load().unwrap()), + 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 d0b23aa71a..0f492584cd 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -2,4 +2,8 @@ pub mod chain_spec; pub mod cli; pub mod forum_config; pub mod members_config; +#[macro_use] pub mod service; +pub mod command; +pub mod node_rpc; +pub mod node_executor; 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..ca414e130a --- /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..f384e3ed4b --- /dev/null +++ b/node/src/node_rpc.rs @@ -0,0 +1,193 @@ +// 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::{opaque::Block, BlockNumber, AccountId, Index, Balance, Hash}; +use node_runtime::UncheckedExtrinsic; +use sp_api::ProvideRuntimeApi; +use sp_transaction_pool::TransactionPool; +use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend}; +use sp_consensus::SelectChain; +use sc_keystore::KeyStorePtr; +use sp_consensus_babe::BabeApi; +use sc_consensus_epochs::SharedEpochChanges; +use sc_consensus_babe::{Config, Epoch}; +use sc_consensus_babe_rpc::BabeRpcHandler; +use sc_finality_grandpa::{SharedVoterState, SharedAuthoritySet}; +use sc_finality_grandpa_rpc::GrandpaRpcHandler; +use sc_rpc_api::DenyUnsafe; +use sp_block_builder::BlockBuilder; + +/// 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_contracts_rpc::ContractsRuntimeApi, + C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + C::Api: BabeApi, + C::Api: BlockBuilder, + P: TransactionPool + 'static, + M: jsonrpc_core::Metadata + Default, + SC: SelectChain +'static, +{ + use substrate_frame_rpc_system::{FullSystem, SystemApi}; + use pallet_contracts_rpc::{Contracts, ContractsApi}; + use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; + + 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( + ContractsApi::to_delegate(Contracts::new(client.clone())) + ); + 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..73abbddf95 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -16,108 +16,137 @@ #![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; +// Substrate implementation issue. +#![allow(clippy::redundant_closure_call)] + +//! Service implementation. Specialized wrapper over substrate service. + 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 sc_finality_grandpa::{ + self as grandpa, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider, }; -use transaction_pool::{self, txpool::Pool as TransactionPool}; - -construct_simple_protocol! { - /// Demo protocol attachment for substrate. - pub struct NodeProtocol where Block = Block { } -} +use node_runtime::opaque::Block; +use node_runtime::RuntimeApi; +use sc_service::{ + AbstractService, ServiceBuilder, config::Configuration, error::{Error as ServiceError}, +}; +use sp_inherents::InherentDataProviders; +use sc_consensus::LongestChain; -// 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 crate::node_rpc; +use crate::node_executor; /// 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; - let mut import_setup = None; - let inherent_data_providers = inherents::InherentDataProviders::new(); - - let builder = substrate_service::ServiceBuilder::new_full::< - node_runtime::opaque::Block, - node_runtime::RuntimeApi, - crate::service::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_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, _>( - client.clone(), - &*client, - 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) - })?; - // 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) - }}; + ($config:expr) => {{ + use std::sync::Arc; + + let mut import_setup = None; + let mut rpc_setup = None; + let inherent_data_providers = sp_inherents::InherentDataProviders::new(); + + let builder = sc_service::ServiceBuilder::new_full::< + Block, RuntimeApi, node_executor::Executor + >($config)? + .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, + 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.clone() as Arc<_>), + select_chain, + )?; + 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) + }) + })?; + + (builder, import_setup, inherent_data_providers, rpc_setup) + }} } /// Creates a full service from the configuration. @@ -126,58 +155,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); + let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) = + 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 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 babe_config = babe::BabeParams { + let can_author_with = + sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); + + let babe_config = sc_consensus_babe::BabeParams { keystore: service.keystore(), client, select_chain, @@ -187,62 +215,95 @@ macro_rules! new_full { inherent_data_providers: inherent_data_providers.clone(), force_authoring, babe_link, + can_author_with, + }; + + 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 babe = babe::start_babe(babe_config)?; - service.spawn_essential_task(babe); - } + 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,106 +313,325 @@ 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) + 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; - let inherent_data_providers = InherentDataProviders::new(); - - 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_import_queue_and_fprb( - |_config, client, backend, fetcher, _select_chain, _tx_pool| { - 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>( - client.clone(), - backend, - &*client, - Arc::new(fetch_checker), - )?; - - let finality_proof_import = grandpa_block_import.clone(); - 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)?, - grandpa_block_import, - client.clone(), - client.clone(), - )?; - - let import_queue = babe::import_queue( - babe_link, - babe_block_import, - None, - Some(Box::new(finality_proof_import)), - client.clone(), - client, - inherent_data_providers.clone(), - )?; - - 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 _) - })? - // We don't have any custom rpc extensions - // .with_rpc_extensions(|client, pool| -> RpcExtension { - // node_rpc::create(client, pool) - // })? - .build()?; - - Ok(service) +pub fn new_light(config: Configuration) + -> Result { + let inherent_data_providers = InherentDataProviders::new(); + + let service = ServiceBuilder::new_light::(config)? + .with_select_chain(|_config, backend| { + Ok(LongestChain::new(backend.clone())) + })? + .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, + 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( + client.clone(), + backend, + &(client.clone() as Arc<_>), + Arc::new(fetch_checker), + )?; + + let finality_proof_import = grandpa_block_import.clone(); + let finality_proof_request_builder = + finality_proof_import.create_finality_proof_request_builder(); + + let (babe_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, + babe_block_import, + None, + Some(Box::new(finality_proof_import)), + client, + inherent_data_providers.clone(), + spawn_task_handle, + registry, + )?; + + Ok((import_queue, finality_proof_request_builder)) + })? + .with_finality_proof_provider(|client, backend| { + // 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)) + })? + .build_light()?; + + Ok(service) +} + +#[cfg(test)] +mod tests { + use std::{sync::Arc, borrow::Cow, any::Any}; + use sc_consensus_babe::{ + CompatibleDigestItem, BabeIntermediate, INTERMEDIATE_KEY + }; + use sc_consensus_epochs::descendent_query; + use sp_consensus::{ + Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy, BlockImport, + RecordProof, + }; + use node_primitives::{Block, DigestItem, Signature}; + use node_runtime::{BalancesCall, Call, UncheckedExtrinsic, Address}; + use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION}; + use codec::{Encode, Decode}; + use sp_core::{crypto::Pair as CryptoPair, H256}; + use sp_runtime::{ + generic::{BlockId, Era, Digest, SignedPayload}, + traits::{Block as BlockT, Header as HeaderT}, + traits::Verify, + OpaqueExtrinsic, + }; + use sp_timestamp; + use sp_finality_tracker; + use sp_keyring::AccountKeyring; + use sc_service::AbstractService; + use crate::service::{new_full, new_light}; + use sp_runtime::traits::IdentifyAccount; + use sp_transaction_pool::{MaintainedTransactionPool, ChainEvent}; + + type AccountPublic = ::Signer; + + #[test] + // It is "ignored", but the node-cli ignored tests are running on the CI. + // This can be run locally with `cargo test --release -p node-cli test_sync -- --ignored`. + #[ignore] + fn test_sync() { + let keystore_path = tempfile::tempdir().expect("Creates keystore path"); + let keystore = sc_keystore::Store::open(keystore_path.path(), None) + .expect("Creates keystore"); + let alice = keystore.write().insert_ephemeral_from_seed::("//Alice") + .expect("Creates authority pair"); + + let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority(); + + // For the block factory + let mut slot_num = 1u64; + + // For the extrinsics factory + let bob = Arc::new(AccountKeyring::Bob.pair()); + let charlie = Arc::new(AccountKeyring::Charlie.pair()); + let mut index = 0; + + sc_service_test::sync( + chain_spec, + |config| { + let mut setup_handles = None; + new_full!(config, | + block_import: &sc_consensus_babe::BabeBlockImport, + babe_link: &sc_consensus_babe::BabeLink, + | { + setup_handles = Some((block_import.clone(), babe_link.clone())); + }).map(move |(node, x)| (node, (x, setup_handles.unwrap()))) + }, + |config| new_light(config), + |service, &mut (ref inherent_data_providers, (ref mut block_import, ref babe_link))| { + let mut inherent_data = inherent_data_providers + .create_inherent_data() + .expect("Creates inherent data."); + inherent_data.replace_data(sp_finality_tracker::INHERENT_IDENTIFIER, &1u64); + + let parent_id = BlockId::number(service.client().chain_info().best_number); + let parent_header = service.client().header(&parent_id).unwrap().unwrap(); + let parent_hash = parent_header.hash(); + let parent_number = *parent_header.number(); + + futures::executor::block_on( + service.transaction_pool().maintain( + ChainEvent::NewBlock { + is_new_best: true, + hash: parent_header.hash(), + tree_route: None, + header: parent_header.clone(), + }, + ) + ); + + let mut proposer_factory = sc_basic_authorship::ProposerFactory::new( + service.client(), + service.transaction_pool(), + None, + ); + + let epoch_descriptor = babe_link.epoch_changes().lock().epoch_descriptor_for_child_of( + descendent_query(&*service.client()), + &parent_hash, + parent_number, + slot_num, + ).unwrap().unwrap(); + + let mut digest = Digest::::default(); + + // even though there's only one authority some slots might be empty, + // so we must keep trying the next slots until we can claim one. + let babe_pre_digest = loop { + inherent_data.replace_data(sp_timestamp::INHERENT_IDENTIFIER, &(slot_num * SLOT_DURATION)); + if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot( + slot_num, + &parent_header, + &*service.client(), + &keystore, + &babe_link, + ) { + break babe_pre_digest; + } + + slot_num += 1; + }; + + digest.push(::babe_pre_digest(babe_pre_digest)); + + let new_block = futures::executor::block_on(async move { + let proposer = proposer_factory.init(&parent_header).await; + proposer.unwrap().propose( + inherent_data, + digest, + std::time::Duration::from_secs(1), + RecordProof::Yes, + ).await + }).expect("Error making test block").block; + + let (new_header, new_body) = new_block.deconstruct(); + let pre_hash = new_header.hash(); + // sign the pre-sealed hash of the block and then + // add it to a digest item. + let to_sign = pre_hash.encode(); + let signature = alice.sign(&to_sign[..]); + let item = ::babe_seal( + signature.into(), + ); + slot_num += 1; + + let mut params = BlockImportParams::new(BlockOrigin::File, new_header); + params.post_digests.push(item); + params.body = Some(new_body); + params.intermediates.insert( + Cow::from(INTERMEDIATE_KEY), + Box::new(BabeIntermediate:: { epoch_descriptor }) as Box, + ); + params.fork_choice = Some(ForkChoiceStrategy::LongestChain); + + block_import.import_block(params, Default::default()) + .expect("error importing test block"); + }, + |service, _| { + let amount = 5 * CENTS; + let to: Address = AccountPublic::from(bob.public()).into_account().into(); + let from: Address = AccountPublic::from(charlie.public()).into_account().into(); + let genesis_hash = service.client().block_hash(0).unwrap().unwrap(); + let best_block_id = BlockId::number(service.client().chain_info().best_number); + let (spec_version, transaction_version) = { + let version = service.client().runtime_version_at(&best_block_id).unwrap(); + (version.spec_version, version.transaction_version) + }; + let signer = charlie.clone(); + + let function = Call::Balances(BalancesCall::transfer(to.into(), amount)); + + let check_spec_version = frame_system::CheckSpecVersion::new(); + let check_tx_version = frame_system::CheckTxVersion::new(); + let check_genesis = frame_system::CheckGenesis::new(); + let check_era = frame_system::CheckEra::from(Era::Immortal); + let check_nonce = frame_system::CheckNonce::from(index); + let check_weight = frame_system::CheckWeight::new(); + let payment = pallet_transaction_payment::ChargeTransactionPayment::from(0); + let validate_grandpa_equivocation = pallet_grandpa::ValidateEquivocationReport::new(); + let extra = ( + check_spec_version, + check_tx_version, + check_genesis, + check_era, + check_nonce, + check_weight, + payment, + validate_grandpa_equivocation, + ); + let raw_payload = SignedPayload::from_raw( + function, + extra, + (spec_version, transaction_version, genesis_hash, genesis_hash, (), (), (), ()) + ); + let signature = raw_payload.using_encoded(|payload| { + signer.sign(payload) + }); + let (function, extra, _) = raw_payload.deconstruct(); + let xt = UncheckedExtrinsic::new_signed( + function, + from.into(), + signature.into(), + extra, + ).encode(); + let v: Vec = Decode::decode(&mut xt.as_slice()).unwrap(); + + index += 1; + OpaqueExtrinsic(v) + }, + ); + } + + #[test] + #[ignore] + fn test_consensus() { + sc_service_test::consensus( + crate::chain_spec::tests::integration_test_config_with_two_authorities(), + |config| new_full(config), + |config| new_light(config), + vec![ + "//Alice".into(), + "//Bob".into(), + ], + ) + } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 6aabcf1749..52c711d4cb 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -25,7 +25,7 @@ sp-block-builder = { package = 'sp-block-builder', default-features = false, git 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'} -node-primitives = { package = 'node-primitives', 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'} @@ -52,6 +52,9 @@ pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git 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'} +pallet-contracts = { package = 'pallet-contracts', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-contracts-rpc-runtime-api = { package = 'pallet-contracts-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} +pallet-contracts-primitives = { package = 'pallet-contracts-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} # Joystream common = { package = 'pallet-common', default-features = false, path = '../runtime-modules/common'} @@ -101,7 +104,7 @@ std = [ 'sp-block-builder/std', 'sp-session/std', 'sp-staking/std', - 'node-primitives/std', + 'sp-application-crypto/std', # Frame 'frame-support/std', @@ -128,6 +131,9 @@ std = [ 'pallet-im-online/std', 'pallet-collective/std', 'pallet-offences/std', + 'pallet-contracts/std', + 'pallet-contracts-rpc-runtime-api/std', + 'pallet-contracts-primitives/std', # Joystream 'common/std', diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ffd592fb01..fe6bdf15c3 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -14,13 +14,14 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod integration; +mod primitives; mod migration; #[cfg(test)] mod tests; // Runtime integration tests use codec::Encode; use frame_support::inherent::{CheckInherentsResult, InherentData}; -use frame_support::traits::KeyOwnerProofSystem; +use frame_support::traits::{KeyOwnerProofSystem}; use frame_support::weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, IdentityFee, Weight, @@ -38,103 +39,35 @@ use sp_core::crypto::KeyTypeId; use sp_core::OpaqueMetadata; use sp_runtime::curve::PiecewiseLinear; use sp_runtime::generic::SignedPayload; -use sp_runtime::traits::{ - BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, Saturating, StaticLookup, Verify, +use sp_runtime::traits::{OpaqueKeys, + BlakeTwo256, Block as BlockT, NumberFor, Saturating, StaticLookup, }; use sp_runtime::transaction_validity::{TransactionSource, TransactionValidity}; -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, - MultiSignature, Perbill, Perquintill, SaturatedConversion, -}; +use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, Perbill, Perquintill, SaturatedConversion}; use sp_std::boxed::Box; use sp_std::vec::Vec; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; use system::EnsureRoot; +use pallet_contracts_rpc_runtime_api::ContractExecResult; use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator}; +pub use primitives::*; use content_working_group as content_wg; use governance::{council, election}; use storage::{data_directory, data_object_storage_registry, data_object_type_registry}; -/// 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; - -/// 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 data structures. -pub mod opaque { - use super::*; - - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; +// Node dependencies +pub use common; +pub use versioned_store; +pub use forum; +pub use working_group; +pub use governance::election_params::ElectionParameters; +pub use pallet_staking::StakerStatus; +pub use proposals_codex::ProposalsConfigParameters; - pub type Header = generic::Header; - pub type Block = generic::Block; - 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, - } - } -} /// This runtime version. pub const VERSION: RuntimeVersion = RuntimeVersion { @@ -258,7 +191,7 @@ impl pallet_grandpa::Trait for Runtime { type HandleEquivocation = pallet_grandpa::EquivocationHandler< Self::KeyOwnerIdentification, - node_primitives::report::ReporterAppCrypto, + primitives::report::ReporterAppCrypto, Runtime, Offences, >; @@ -366,9 +299,28 @@ parameter_types! { pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128); } +// type NegativeImbalance = >::NegativeImbalance; +// +// pub struct DealWithFees; +// impl OnUnbalanced for DealWithFees { +// fn on_unbalanceds(mut fees_then_tips: impl Iterator) { +// if let Some(fees) = fees_then_tips.next() { +// // // for fees, 80% to treasury, 20% to author +// // let mut split = fees.ration(80, 20); +// // if let Some(tips) = fees_then_tips.next() { +// // // for tips, if any, 80% to treasury, 20% to author (though this can be anything) +// // tips.ration_merge_into(80, 20, &mut split); +// // } +// // Treasury::on_unbalanced(split.0); +// // Author::on_unbalanced(split.1); +// } +// } +// } + + impl pallet_transaction_payment::Trait for Runtime { type Currency = Balances; - type OnTransactionPayment = (); + type OnTransactionPayment = (); // TODO: adjust fee type TransactionByteFee = TransactionByteFee; type WeightToFee = IdentityFee; // TODO: adjust weight type FeeMultiplierUpdate = @@ -391,16 +343,14 @@ impl pallet_authorship::Trait for Runtime { 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 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`. @@ -417,7 +367,7 @@ impl pallet_session::Trait for Runtime { type ShouldEndSession = Babe; type NextSessionRotation = Babe; type SessionManager = pallet_session::historical::NoteHistoricalRoot; - type SessionHandler = SessionHandlers; + type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; type DisabledValidatorsThreshold = DisabledValidatorsThreshold; } @@ -700,6 +650,49 @@ 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 +} + +impl pallet_contracts::Trait for Runtime { + type Time = Timestamp; + type Randomness = RandomnessCollectiveFlip; + type Currency = Balances; + type Event = Event; + type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer; + type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter; + type RentPayment = (); + type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap; + type TombstoneDeposit = TombstoneDeposit; + type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset; + type RentByteFee = RentByteFee; + type RentDepositOffset = RentDepositOffset; + type SurchargeReward = SurchargeReward; + type MaxDepth = pallet_contracts::DefaultMaxDepth; + type MaxValueSize = pallet_contracts::DefaultMaxValueSize; + type WeightPrice = pallet_transaction_payment::Module; +} + +/// 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, @@ -724,6 +717,7 @@ construct_runtime!( Offences: pallet_offences::{Module, Call, Storage, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, + Contracts: pallet_contracts::{Module, Call, Config, Storage, Event}, // Joystream Migration: migration::{Module, Call, Storage, Event, Config}, CouncilElection: election::{Module, Call, Storage, Event, Config}, @@ -755,14 +749,6 @@ construct_runtime!( /// 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::CheckSpecVersion, @@ -775,11 +761,24 @@ pub type SignedExtra = ( pallet_grandpa::ValidateEquivocationReport, ); +/// 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>; +frame_executive::Executive, Runtime, AllModules>; impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -905,6 +904,53 @@ impl_runtime_apis! { } } + + impl pallet_contracts_rpc_runtime_api::ContractsApi + for Runtime + { + fn call( + origin: AccountId, + dest: AccountId, + value: Balance, + gas_limit: u64, + input_data: Vec, + ) -> ContractExecResult { + let exec_result = + Contracts::bare_call(origin, dest, value, gas_limit, input_data); + match exec_result { + Ok(v) => ContractExecResult::Success { + status: v.status, + data: v.data, + }, + Err(_) => ContractExecResult::Error, + } + } + + fn get_storage( + address: AccountId, + key: [u8; 32], + ) -> pallet_contracts_primitives::GetStorageResult { + Contracts::get_storage(address, key) + } + + fn rent_projection( + address: AccountId, + ) -> pallet_contracts_primitives::RentProjectionResult { + Contracts::rent_projection(address) + } + } + + + 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) @@ -915,14 +961,4 @@ impl_runtime_apis! { SessionKeys::decode_into_raw_public_keys(&encoded) } } - - 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) - } - } } diff --git a/runtime/src/primitives.rs b/runtime/src/primitives.rs new file mode 100644 index 0000000000..0f837498bf --- /dev/null +++ b/runtime/src/primitives.rs @@ -0,0 +1,92 @@ +//! Low-level types used throughout the Substrate code. + +#![warn(missing_docs)] + +#![cfg_attr(not(feature = "std"), no_std)] + +use sp_runtime::{traits::{Verify, IdentifyAccount}, 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 system::offchain::AppCrypto; + use sp_core::crypto::{key_types, KeyTypeId}; + + /// 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; + } +} From 13664bb7a1c0c2267195f6abdae8f84b3b2e7056 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 4 Aug 2020 11:55:55 +0300 Subject: [PATCH 38/56] node: Fix node tests. --- Cargo.lock | 136 ++++++ node/Cargo.toml | 13 + node/bin/main.rs | 2 +- node/src/chain_spec.rs | 114 ++++- node/src/cli.rs | 4 +- node/src/command.rs | 146 +++---- node/src/lib.rs | 2 +- node/src/node_executor.rs | 8 +- node/src/node_rpc.rs | 256 ++++++----- node/src/service.rs | 876 ++++++++++++++++++++------------------ runtime/src/constants.rs | 49 +++ runtime/src/lib.rs | 209 ++++----- runtime/src/primitives.rs | 55 +-- 13 files changed, 1067 insertions(+), 803 deletions(-) create mode 100644 runtime/src/constants.rs diff --git a/Cargo.lock b/Cargo.lock index dc44112197..4c5e5449b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1985,6 +1985,7 @@ dependencies = [ "sc-rpc", "sc-rpc-api", "sc-service", + "sc-service-test", "sc-telemetry", "sc-tracing", "sc-transaction-pool", @@ -2008,6 +2009,7 @@ dependencies = [ "structopt", "substrate-browser-utils", "substrate-frame-rpc-system", + "tempfile", "tokio 0.1.22", "tracing", "vergen", @@ -5633,6 +5635,43 @@ dependencies = [ "wasm-timer", ] +[[package]] +name = "sc-service-test" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "env_logger", + "fdlimit", + "futures 0.1.29", + "futures 0.3.4", + "hex-literal", + "log", + "parity-scale-codec", + "parking_lot 0.10.2", + "sc-block-builder", + "sc-client-api", + "sc-client-db", + "sc-executor", + "sc-light", + "sc-network", + "sc-service", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-runtime", + "sp-state-machine", + "sp-storage", + "sp-transaction-pool", + "sp-trie", + "substrate-test-runtime", + "substrate-test-runtime-client", + "tempfile", + "tokio 0.1.22", +] + [[package]] name = "sc-state-db" version = "0.8.0-rc4" @@ -6198,6 +6237,20 @@ dependencies = [ "wasm-timer", ] +[[package]] +name = "sp-consensus-aura" +version = "0.8.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-application-crypto", + "sp-inherents", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + [[package]] name = "sp-consensus-babe" version = "0.8.0-rc4" @@ -6814,6 +6867,89 @@ dependencies = [ "tokio 0.2.22", ] +[[package]] +name = "substrate-test-client" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "futures 0.3.4", + "hash-db", + "parity-scale-codec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-executor", + "sc-light", + "sc-service", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-keyring", + "sp-runtime", + "sp-state-machine", +] + +[[package]] +name = "substrate-test-runtime" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "cfg-if", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "log", + "memory-db", + "pallet-babe", + "pallet-timestamp", + "parity-scale-codec", + "parity-util-mem", + "sc-service", + "serde", + "sp-api", + "sp-application-crypto", + "sp-block-builder", + "sp-consensus-aura", + "sp-consensus-babe", + "sp-core", + "sp-finality-grandpa", + "sp-inherents", + "sp-io", + "sp-keyring", + "sp-offchain", + "sp-runtime", + "sp-runtime-interface", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-trie", + "sp-version", + "substrate-wasm-builder-runner", + "trie-db", +] + +[[package]] +name = "substrate-test-runtime-client" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "futures 0.3.4", + "parity-scale-codec", + "sc-block-builder", + "sc-client-api", + "sc-consensus", + "sc-light", + "sc-service", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "substrate-test-client", + "substrate-test-runtime", +] + [[package]] name = "substrate-wasm-builder-runner" version = "1.0.6" diff --git a/node/Cargo.toml b/node/Cargo.toml index ba720ac4ff..d0b2703216 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -127,6 +127,19 @@ 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] +#sc-keystore = { version = "2.0.0-rc4", path = "../../../client/keystore" } +#sc-consensus = { version = "0.8.0-rc4", path = "../../../client/consensus/common" } +sc-consensus-babe = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', features = ["test-helpers"]} +#sc-consensus-epochs = { version = "0.8.0-rc4", path = "../../../client/consensus/epochs" } +sc-service-test = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +#futures = "0.3.4" +tempfile = "3.1.0" +#assert_cmd = "1.0" +#nix = "0.17" +#serde_json = "1.0" +#regex = "1" +#platforms = "0.2.1" #[dependencies.substrate-basic-authorship] #git = 'https://github.com/paritytech/substrate.git' diff --git a/node/bin/main.rs b/node/bin/main.rs index 88b0057639..9298282e3a 100644 --- a/node/bin/main.rs +++ b/node/bin/main.rs @@ -20,4 +20,4 @@ fn main() -> sc_cli::Result<()> { joystream_node::command::run() -} \ No newline at end of file +} diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 685cfd52ca..e641b4ed8d 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -20,22 +20,22 @@ #![allow(clippy::identity_op)] use node_runtime::{AccountId, GenesisConfig}; -use sp_runtime::{Perbill}; -use sp_core::{Pair, Public, sr25519}; -use sp_runtime::traits::{IdentifyAccount, Verify}; -use sp_consensus_babe::AuthorityId as BabeId; -use sp_finality_grandpa::AuthorityId as GrandpaId; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; 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::{ContractsConfig, +use node_runtime::{ versioned_store::InputValidationLengthConstraint as VsInputValidation, AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig, - CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig, + ContractsConfig, CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig, DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig, - MembersConfig, MigrationConfig, ProposalsCodexConfig, SessionConfig, SessionKeys, - Signature, StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig, SystemConfig, + MembersConfig, MigrationConfig, ProposalsCodexConfig, SessionConfig, SessionKeys, Signature, + StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY, }; @@ -100,7 +100,12 @@ fn session_keys( im_online: ImOnlineId, authority_discovery: AuthorityDiscoveryId, ) -> SessionKeys { - SessionKeys { grandpa, babe, im_online, authority_discovery } + SessionKeys { + grandpa, + babe, + im_online, + authority_discovery, + } } impl Alternative { @@ -241,14 +246,16 @@ pub fn testnet_genesis( }), pallet_indices: Some(IndicesConfig { indices: 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::>(), + 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::>(), }), pallet_contracts: Some(ContractsConfig { current_schedule: pallet_contracts::Schedule { @@ -384,3 +391,72 @@ pub fn testnet_genesis( }), } } + +#[cfg(test)] +pub(crate) mod tests { + use super::*; + use crate::service::{new_full, new_light}; + use sc_service_test; + + fn local_testnet_genesis_instant_single() -> GenesisConfig { + testnet_genesis( + vec![get_authority_keys_from_seed("Alice")], + get_account_id_from_seed::("Alice"), + vec![get_authority_keys_from_seed("Alice").0], + ) + } + + /// Local testnet config (single validator - Alice) + pub fn integration_test_config_with_single_authority() -> ChainSpec { + ChainSpec::from_genesis( + "Integration Test", + "test", + ChainType::Development, + local_testnet_genesis_instant_single, + vec![], + None, + None, + None, + Default::default(), + ) + } + + fn local_testnet_genesis() -> GenesisConfig { + testnet_genesis( + vec![ + get_authority_keys_from_seed("Alice"), + get_authority_keys_from_seed("Bob"), + ], + get_account_id_from_seed::("Alice"), + vec![ + get_authority_keys_from_seed("Alice").0, + get_authority_keys_from_seed("Bob").0, + ], + ) + } + + /// Local testnet config (multivalidator Alice + Bob) + pub fn integration_test_config_with_two_authorities() -> ChainSpec { + ChainSpec::from_genesis( + "Integration Test", + "test", + ChainType::Development, + local_testnet_genesis, + vec![], + None, + None, + None, + Default::default(), + ) + } + + #[test] + #[ignore] + fn test_connectivity() { + sc_service_test::connectivity( + integration_test_config_with_two_authorities(), + |config| new_full(config), + |config| new_light(config), + ); + } +} diff --git a/node/src/cli.rs b/node/src/cli.rs index 2272180966..6acca3e920 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -37,8 +37,8 @@ pub enum Subcommand { /// The custom inspect subcommmand for decoding blocks and extrinsics. #[structopt( - name = "inspect", - about = "Decode given block or extrinsic using current native runtime." + name = "inspect", + about = "Decode given block or extrinsic using current native runtime." )] Inspect(node_inspect::cli::InspectCmd), diff --git a/node/src/command.rs b/node/src/command.rs index 0f4d3ec06d..2195aa6501 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -14,91 +14,87 @@ // You should have received a copy of the GNU General Public License // along with Joystream node. If not, see . -use crate::{chain_spec, service}; use crate::cli::{Cli, Subcommand}; -use crate::node_rpc; 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, -}; +use sc_finality_grandpa::{self as grandpa}; impl SubstrateCli for Cli { - fn impl_name() -> &'static str { - "Joystream Node" - } - - fn impl_version() -> &'static str { - "3.0.0" - } - - fn description() -> &'static str { - "Joystream substrate node" - } - - fn author() -> &'static str { - "Joystream contributors" - } - - fn support_url() -> &'static str { - "https://www.joystream.org/" - } - - fn copyright_start_year() -> i32 { - 2019 - } - - fn executable_name() -> &'static str { - "joystream-node" - } - - fn load_spec(&self, id: &str) -> std::result::Result, String> { - Ok(match id { - "dev" => Box::new(chain_spec::Alternative::Development.load().unwrap()), //TODO - "local" => Box::new(chain_spec::Alternative::LocalTestnet.load().unwrap()), - path => Box::new(chain_spec::ChainSpec::from_json_file( - std::path::PathBuf::from(path), - )?), - }) - } + fn impl_name() -> &'static str { + "Joystream Node" + } + + fn impl_version() -> &'static str { + "3.0.0" + } + + fn description() -> &'static str { + "Joystream substrate node" + } + + fn author() -> &'static str { + "Joystream contributors" + } + + fn support_url() -> &'static str { + "https://www.joystream.org/" + } + + fn copyright_start_year() -> i32 { + 2019 + } + + fn executable_name() -> &'static str { + "joystream-node" + } + + fn load_spec(&self, id: &str) -> std::result::Result, String> { + Ok(match id { + "dev" => Box::new(chain_spec::Alternative::Development.load().unwrap()), //TODO + "local" => Box::new(chain_spec::Alternative::LocalTestnet.load().unwrap()), + 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)) - } - } + 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 0f492584cd..8a77fe5cba 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -5,5 +5,5 @@ pub mod members_config; #[macro_use] pub mod service; pub mod command; -pub mod node_rpc; pub mod node_executor; +pub mod node_rpc; diff --git a/node/src/node_executor.rs b/node/src/node_executor.rs index ca414e130a..665ca94898 100644 --- a/node/src/node_executor.rs +++ b/node/src/node_executor.rs @@ -3,8 +3,8 @@ 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, + 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 index f384e3ed4b..5a6a055402 100644 --- a/node/src/node_rpc.rs +++ b/node/src/node_rpc.rs @@ -32,162 +32,160 @@ use std::sync::Arc; -use node_runtime::{opaque::Block, BlockNumber, AccountId, Index, Balance, Hash}; use node_runtime::UncheckedExtrinsic; -use sp_api::ProvideRuntimeApi; -use sp_transaction_pool::TransactionPool; -use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend}; -use sp_consensus::SelectChain; -use sc_keystore::KeyStorePtr; -use sp_consensus_babe::BabeApi; -use sc_consensus_epochs::SharedEpochChanges; +use node_runtime::{opaque::Block, AccountId, Balance, BlockNumber, Hash, Index}; use sc_consensus_babe::{Config, Epoch}; use sc_consensus_babe_rpc::BabeRpcHandler; -use sc_finality_grandpa::{SharedVoterState, SharedAuthoritySet}; +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, + /// 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, + /// 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, + /// 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, + /// 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_contracts_rpc::ContractsRuntimeApi, - C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - C::Api: BabeApi, - C::Api: BlockBuilder, - P: TransactionPool + 'static, - M: jsonrpc_core::Metadata + Default, - SC: SelectChain +'static, +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_contracts_rpc::ContractsRuntimeApi, + 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 substrate_frame_rpc_system::{FullSystem, SystemApi}; - use pallet_contracts_rpc::{Contracts, ContractsApi}; - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; - - 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( - ContractsApi::to_delegate(Contracts::new(client.clone())) - ); - 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 + use pallet_contracts_rpc::{Contracts, ContractsApi}; + 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(ContractsApi::to_delegate(Contracts::new(client.clone()))); + 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, +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 + 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 73abbddf95..9a3f9f32ab 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -21,132 +21,137 @@ //! Service implementation. Specialized wrapper over substrate service. -use std::sync::Arc; -use sc_finality_grandpa::{ - self as grandpa, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider, -}; 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::{ - AbstractService, ServiceBuilder, config::Configuration, error::{Error as ServiceError}, + config::Configuration, error::Error as ServiceError, AbstractService, ServiceBuilder, }; use sp_inherents::InherentDataProviders; -use sc_consensus::LongestChain; +use std::sync::Arc; -use crate::node_rpc; 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_rules! new_full_start { - ($config:expr) => {{ - use std::sync::Arc; - - let mut import_setup = None; - let mut rpc_setup = None; - let inherent_data_providers = sp_inherents::InherentDataProviders::new(); - - let builder = sc_service::ServiceBuilder::new_full::< - Block, RuntimeApi, node_executor::Executor - >($config)? - .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, - 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.clone() as Arc<_>), - select_chain, - )?; - 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) - }) - })?; - - (builder, import_setup, inherent_data_providers, rpc_setup) - }} + ($config:expr) => {{ + use std::sync::Arc; + + let mut import_setup = None; + let mut rpc_setup = None; + let inherent_data_providers = sp_inherents::InherentDataProviders::new(); + + let builder = sc_service::ServiceBuilder::new_full::< + Block, + RuntimeApi, + node_executor::Executor, + >($config)? + .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, + 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.clone() as Arc<_>), + select_chain, + )?; + 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) + }) + })?; + + (builder, import_setup, inherent_data_providers, rpc_setup) + }}; } /// Creates a full service from the configuration. @@ -314,324 +319,343 @@ macro_rules! new_full { } /// Builds a new service for a full client. -pub fn new_full(config: Configuration) - -> Result -{ - new_full!(config).map(|(service, _)| service) +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: Configuration) - -> Result { - let inherent_data_providers = InherentDataProviders::new(); - - let service = ServiceBuilder::new_light::(config)? - .with_select_chain(|_config, backend| { - Ok(LongestChain::new(backend.clone())) - })? - .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, - 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( - client.clone(), - backend, - &(client.clone() as Arc<_>), - Arc::new(fetch_checker), - )?; - - let finality_proof_import = grandpa_block_import.clone(); - let finality_proof_request_builder = - finality_proof_import.create_finality_proof_request_builder(); - - let (babe_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, - babe_block_import, - None, - Some(Box::new(finality_proof_import)), - client, - inherent_data_providers.clone(), - spawn_task_handle, - registry, - )?; - - Ok((import_queue, finality_proof_request_builder)) - })? - .with_finality_proof_provider(|client, backend| { - // 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)) - })? - .build_light()?; - - Ok(service) +pub fn new_light(config: Configuration) -> Result { + let inherent_data_providers = InherentDataProviders::new(); + + let service = ServiceBuilder::new_light::(config)? + .with_select_chain(|_config, backend| Ok(LongestChain::new(backend.clone())))? + .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, + 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( + client.clone(), + backend, + &(client.clone() as Arc<_>), + Arc::new(fetch_checker), + )?; + + let finality_proof_import = grandpa_block_import.clone(); + let finality_proof_request_builder = + finality_proof_import.create_finality_proof_request_builder(); + + let (babe_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, + babe_block_import, + None, + Some(Box::new(finality_proof_import)), + client, + inherent_data_providers.clone(), + spawn_task_handle, + registry, + )?; + + Ok((import_queue, finality_proof_request_builder)) + }, + )? + .with_finality_proof_provider(|client, backend| { + // 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)) + })? + .build_light()?; + + Ok(service) } #[cfg(test)] mod tests { - use std::{sync::Arc, borrow::Cow, any::Any}; - use sc_consensus_babe::{ - CompatibleDigestItem, BabeIntermediate, INTERMEDIATE_KEY - }; - use sc_consensus_epochs::descendent_query; - use sp_consensus::{ - Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy, BlockImport, - RecordProof, - }; - use node_primitives::{Block, DigestItem, Signature}; - use node_runtime::{BalancesCall, Call, UncheckedExtrinsic, Address}; - use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION}; - use codec::{Encode, Decode}; - use sp_core::{crypto::Pair as CryptoPair, H256}; - use sp_runtime::{ - generic::{BlockId, Era, Digest, SignedPayload}, - traits::{Block as BlockT, Header as HeaderT}, - traits::Verify, - OpaqueExtrinsic, - }; - use sp_timestamp; - use sp_finality_tracker; - use sp_keyring::AccountKeyring; - use sc_service::AbstractService; - use crate::service::{new_full, new_light}; - use sp_runtime::traits::IdentifyAccount; - use sp_transaction_pool::{MaintainedTransactionPool, ChainEvent}; - - type AccountPublic = ::Signer; - - #[test] - // It is "ignored", but the node-cli ignored tests are running on the CI. - // This can be run locally with `cargo test --release -p node-cli test_sync -- --ignored`. - #[ignore] - fn test_sync() { - let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = sc_keystore::Store::open(keystore_path.path(), None) - .expect("Creates keystore"); - let alice = keystore.write().insert_ephemeral_from_seed::("//Alice") - .expect("Creates authority pair"); - - let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority(); - - // For the block factory - let mut slot_num = 1u64; - - // For the extrinsics factory - let bob = Arc::new(AccountKeyring::Bob.pair()); - let charlie = Arc::new(AccountKeyring::Charlie.pair()); - let mut index = 0; - - sc_service_test::sync( - chain_spec, - |config| { - let mut setup_handles = None; - new_full!(config, | - block_import: &sc_consensus_babe::BabeBlockImport, - babe_link: &sc_consensus_babe::BabeLink, - | { - setup_handles = Some((block_import.clone(), babe_link.clone())); - }).map(move |(node, x)| (node, (x, setup_handles.unwrap()))) - }, - |config| new_light(config), - |service, &mut (ref inherent_data_providers, (ref mut block_import, ref babe_link))| { - let mut inherent_data = inherent_data_providers - .create_inherent_data() - .expect("Creates inherent data."); - inherent_data.replace_data(sp_finality_tracker::INHERENT_IDENTIFIER, &1u64); - - let parent_id = BlockId::number(service.client().chain_info().best_number); - let parent_header = service.client().header(&parent_id).unwrap().unwrap(); - let parent_hash = parent_header.hash(); - let parent_number = *parent_header.number(); - - futures::executor::block_on( - service.transaction_pool().maintain( - ChainEvent::NewBlock { - is_new_best: true, - hash: parent_header.hash(), - tree_route: None, - header: parent_header.clone(), - }, - ) - ); - - let mut proposer_factory = sc_basic_authorship::ProposerFactory::new( - service.client(), - service.transaction_pool(), - None, - ); - - let epoch_descriptor = babe_link.epoch_changes().lock().epoch_descriptor_for_child_of( - descendent_query(&*service.client()), - &parent_hash, - parent_number, - slot_num, - ).unwrap().unwrap(); - - let mut digest = Digest::::default(); - - // even though there's only one authority some slots might be empty, - // so we must keep trying the next slots until we can claim one. - let babe_pre_digest = loop { - inherent_data.replace_data(sp_timestamp::INHERENT_IDENTIFIER, &(slot_num * SLOT_DURATION)); - if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot( - slot_num, - &parent_header, - &*service.client(), - &keystore, - &babe_link, - ) { - break babe_pre_digest; - } - - slot_num += 1; - }; - - digest.push(::babe_pre_digest(babe_pre_digest)); - - let new_block = futures::executor::block_on(async move { - let proposer = proposer_factory.init(&parent_header).await; - proposer.unwrap().propose( - inherent_data, - digest, - std::time::Duration::from_secs(1), - RecordProof::Yes, - ).await - }).expect("Error making test block").block; - - let (new_header, new_body) = new_block.deconstruct(); - let pre_hash = new_header.hash(); - // sign the pre-sealed hash of the block and then - // add it to a digest item. - let to_sign = pre_hash.encode(); - let signature = alice.sign(&to_sign[..]); - let item = ::babe_seal( - signature.into(), - ); - slot_num += 1; - - let mut params = BlockImportParams::new(BlockOrigin::File, new_header); - params.post_digests.push(item); - params.body = Some(new_body); - params.intermediates.insert( - Cow::from(INTERMEDIATE_KEY), - Box::new(BabeIntermediate:: { epoch_descriptor }) as Box, - ); - params.fork_choice = Some(ForkChoiceStrategy::LongestChain); - - block_import.import_block(params, Default::default()) - .expect("error importing test block"); - }, - |service, _| { - let amount = 5 * CENTS; - let to: Address = AccountPublic::from(bob.public()).into_account().into(); - let from: Address = AccountPublic::from(charlie.public()).into_account().into(); - let genesis_hash = service.client().block_hash(0).unwrap().unwrap(); - let best_block_id = BlockId::number(service.client().chain_info().best_number); - let (spec_version, transaction_version) = { - let version = service.client().runtime_version_at(&best_block_id).unwrap(); - (version.spec_version, version.transaction_version) - }; - let signer = charlie.clone(); - - let function = Call::Balances(BalancesCall::transfer(to.into(), amount)); - - let check_spec_version = frame_system::CheckSpecVersion::new(); - let check_tx_version = frame_system::CheckTxVersion::new(); - let check_genesis = frame_system::CheckGenesis::new(); - let check_era = frame_system::CheckEra::from(Era::Immortal); - let check_nonce = frame_system::CheckNonce::from(index); - let check_weight = frame_system::CheckWeight::new(); - let payment = pallet_transaction_payment::ChargeTransactionPayment::from(0); - let validate_grandpa_equivocation = pallet_grandpa::ValidateEquivocationReport::new(); - let extra = ( - check_spec_version, - check_tx_version, - check_genesis, - check_era, - check_nonce, - check_weight, - payment, - validate_grandpa_equivocation, - ); - let raw_payload = SignedPayload::from_raw( - function, - extra, - (spec_version, transaction_version, genesis_hash, genesis_hash, (), (), (), ()) - ); - let signature = raw_payload.using_encoded(|payload| { - signer.sign(payload) - }); - let (function, extra, _) = raw_payload.deconstruct(); - let xt = UncheckedExtrinsic::new_signed( - function, - from.into(), - signature.into(), - extra, - ).encode(); - let v: Vec = Decode::decode(&mut xt.as_slice()).unwrap(); - - index += 1; - OpaqueExtrinsic(v) - }, - ); - } - - #[test] - #[ignore] - fn test_consensus() { - sc_service_test::consensus( - crate::chain_spec::tests::integration_test_config_with_two_authorities(), - |config| new_full(config), - |config| new_light(config), - vec![ - "//Alice".into(), - "//Bob".into(), - ], - ) - } + use crate::node_executor; + use crate::node_rpc; + use crate::service::{new_full, new_light}; + use codec::{Decode, Encode}; + use node_runtime::RuntimeApi; + use node_runtime::{currency::CENTS, SLOT_DURATION}; + use node_runtime::{opaque::Block, DigestItem, Signature}; + use node_runtime::{Address, BalancesCall, Call, UncheckedExtrinsic}; + use sc_consensus_babe::{BabeIntermediate, CompatibleDigestItem, INTERMEDIATE_KEY}; + use sc_consensus_epochs::descendent_query; + use sc_finality_grandpa::{self as grandpa}; + use sc_service::AbstractService; + use sp_consensus::{ + BlockImport, BlockImportParams, BlockOrigin, Environment, ForkChoiceStrategy, Proposer, + RecordProof, + }; + use sp_core::{crypto::Pair as CryptoPair, H256}; + use sp_finality_tracker; + use sp_keyring::AccountKeyring; + use sp_runtime::traits::IdentifyAccount; + use sp_runtime::{ + generic::{BlockId, Digest, Era, SignedPayload}, + traits::Verify, + traits::{Block as BlockT, Header as HeaderT}, + OpaqueExtrinsic, + }; + use sp_timestamp; + use sp_transaction_pool::{ChainEvent, MaintainedTransactionPool}; + use std::{any::Any, borrow::Cow, sync::Arc}; + + type AccountPublic = ::Signer; + + // Long running test. Run it locally only after the node changes. + #[test] + // It is "ignored", but the node-cli ignored tests are running on the CI. + // This can be run locally with `cargo test --release -p node-cli test_sync -- --ignored`. + #[ignore] + fn test_sync() { + let keystore_path = tempfile::tempdir().expect("Creates keystore path"); + let keystore = + sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore"); + let alice = keystore + .write() + .insert_ephemeral_from_seed::("//Alice") + .expect("Creates authority pair"); + + let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority(); + + // For the block factory + let mut slot_num = 1u64; + + // For the extrinsics factory + let bob = Arc::new(AccountKeyring::Bob.pair()); + let charlie = Arc::new(AccountKeyring::Charlie.pair()); + let mut index = 0; + + sc_service_test::sync( + chain_spec, + |config| { + let mut setup_handles = None; + new_full!( + config, + |block_import: &sc_consensus_babe::BabeBlockImport, + babe_link: &sc_consensus_babe::BabeLink| { + setup_handles = Some((block_import.clone(), babe_link.clone())); + } + ) + .map(move |(node, x)| (node, (x, setup_handles.unwrap()))) + }, + |config| new_light(config), + |service, &mut (ref inherent_data_providers, (ref mut block_import, ref babe_link))| { + let mut inherent_data = inherent_data_providers + .create_inherent_data() + .expect("Creates inherent data."); + inherent_data.replace_data(sp_finality_tracker::INHERENT_IDENTIFIER, &1u64); + + let parent_id = BlockId::number(service.client().chain_info().best_number); + let parent_header = service.client().header(&parent_id).unwrap().unwrap(); + let parent_hash = parent_header.hash(); + let parent_number = *parent_header.number(); + + futures::executor::block_on(service.transaction_pool().maintain( + ChainEvent::NewBlock { + is_new_best: true, + hash: parent_header.hash(), + tree_route: None, + header: parent_header.clone(), + }, + )); + + let mut proposer_factory = sc_basic_authorship::ProposerFactory::new( + service.client(), + service.transaction_pool(), + None, + ); + + let epoch_descriptor = babe_link + .epoch_changes() + .lock() + .epoch_descriptor_for_child_of( + descendent_query(&*service.client()), + &parent_hash, + parent_number, + slot_num, + ) + .unwrap() + .unwrap(); + + let mut digest = Digest::::default(); + + // even though there's only one authority some slots might be empty, + // so we must keep trying the next slots until we can claim one. + let babe_pre_digest = loop { + inherent_data.replace_data( + sp_timestamp::INHERENT_IDENTIFIER, + &(slot_num * SLOT_DURATION), + ); + if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot( + slot_num, + &parent_header, + &*service.client(), + &keystore, + &babe_link, + ) { + break babe_pre_digest; + } + + slot_num += 1; + }; + + digest.push(::babe_pre_digest( + babe_pre_digest, + )); + + let new_block = futures::executor::block_on(async move { + let proposer = proposer_factory.init(&parent_header).await; + proposer + .unwrap() + .propose( + inherent_data, + digest, + std::time::Duration::from_secs(1), + RecordProof::Yes, + ) + .await + }) + .expect("Error making test block") + .block; + + let (new_header, new_body) = new_block.deconstruct(); + let pre_hash = new_header.hash(); + // sign the pre-sealed hash of the block and then + // add it to a digest item. + let to_sign = pre_hash.encode(); + let signature = alice.sign(&to_sign[..]); + let item = ::babe_seal(signature.into()); + slot_num += 1; + + let mut params = BlockImportParams::new(BlockOrigin::File, new_header); + params.post_digests.push(item); + params.body = Some(new_body); + params.intermediates.insert( + Cow::from(INTERMEDIATE_KEY), + Box::new(BabeIntermediate:: { epoch_descriptor }) as Box, + ); + params.fork_choice = Some(ForkChoiceStrategy::LongestChain); + + block_import + .import_block(params, Default::default()) + .expect("error importing test block"); + }, + |service, _| { + let amount = 5 * CENTS; + let to: Address = AccountPublic::from(bob.public()).into_account().into(); + let from: Address = AccountPublic::from(charlie.public()).into_account().into(); + let genesis_hash = service.client().block_hash(0).unwrap().unwrap(); + let best_block_id = BlockId::number(service.client().chain_info().best_number); + let (spec_version, transaction_version) = { + let version = service.client().runtime_version_at(&best_block_id).unwrap(); + (version.spec_version, version.transaction_version) + }; + let signer = charlie.clone(); + + let function = Call::Balances(BalancesCall::transfer(to.into(), amount)); + + let check_spec_version = frame_system::CheckSpecVersion::new(); + let check_tx_version = frame_system::CheckTxVersion::new(); + let check_genesis = frame_system::CheckGenesis::new(); + let check_era = frame_system::CheckEra::from(Era::Immortal); + let check_nonce = frame_system::CheckNonce::from(index); + let check_weight = frame_system::CheckWeight::new(); + let payment = pallet_transaction_payment::ChargeTransactionPayment::from(0); + let validate_grandpa_equivocation = + pallet_grandpa::ValidateEquivocationReport::new(); + let extra = ( + check_spec_version, + check_tx_version, + check_genesis, + check_era, + check_nonce, + check_weight, + payment, + validate_grandpa_equivocation, + ); + let raw_payload = SignedPayload::from_raw( + function, + extra, + ( + spec_version, + transaction_version, + genesis_hash, + genesis_hash, + (), + (), + (), + (), + ), + ); + let signature = raw_payload.using_encoded(|payload| signer.sign(payload)); + let (function, extra, _) = raw_payload.deconstruct(); + let xt = + UncheckedExtrinsic::new_signed(function, from.into(), signature.into(), extra) + .encode(); + let v: Vec = Decode::decode(&mut xt.as_slice()).unwrap(); + + index += 1; + OpaqueExtrinsic(v) + }, + ); + } + + #[test] + #[ignore] + fn test_consensus() { + sc_service_test::consensus( + crate::chain_spec::tests::integration_test_config_with_two_authorities(), + |config| new_full(config), + |config| new_light(config), + vec!["//Alice".into(), "//Bob".into()], + ) + } } 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/lib.rs b/runtime/src/lib.rs index fe6bdf15c3..ddb076cf3d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -13,25 +13,27 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +mod constants; mod integration; -mod primitives; mod migration; +mod primitives; #[cfg(test)] mod tests; // Runtime integration tests use codec::Encode; use frame_support::inherent::{CheckInherentsResult, InherentData}; -use frame_support::traits::{KeyOwnerProofSystem}; +use frame_support::traits::KeyOwnerProofSystem; use frame_support::weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, - IdentityFee, Weight, + Weight, WeightToFeeCoefficients, WeightToFeePolynomial, }; use frame_support::{construct_runtime, debug, parameter_types, traits::Randomness}; +use pallet_contracts_rpc_runtime_api::ContractExecResult; use pallet_grandpa::fg_primitives; 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 pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; +use pallet_transaction_payment::Multiplier; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -39,19 +41,22 @@ use sp_core::crypto::KeyTypeId; use sp_core::OpaqueMetadata; use sp_runtime::curve::PiecewiseLinear; use sp_runtime::generic::SignedPayload; -use sp_runtime::traits::{OpaqueKeys, - BlakeTwo256, Block as BlockT, NumberFor, Saturating, StaticLookup, +use sp_runtime::traits::{ + BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys, Saturating, StaticLookup, }; use sp_runtime::transaction_validity::{TransactionSource, TransactionValidity}; -use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, Perbill, Perquintill, SaturatedConversion}; +use sp_runtime::{ + create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, Perbill, + Perquintill, SaturatedConversion, +}; use sp_std::boxed::Box; use sp_std::vec::Vec; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; use system::EnsureRoot; -use pallet_contracts_rpc_runtime_api::ContractExecResult; +pub use constants::*; use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator}; pub use primitives::*; @@ -61,13 +66,12 @@ use storage::{data_directory, data_object_storage_registry, data_object_type_reg // Node dependencies pub use common; -pub use versioned_store; pub use forum; -pub use working_group; pub use governance::election_params::ElectionParameters; pub use pallet_staking::StakerStatus; pub use proposals_codex::ProposalsConfigParameters; - +pub use versioned_store; +pub use working_group; /// This runtime version. pub const VERSION: RuntimeVersion = RuntimeVersion { @@ -80,40 +84,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { 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 information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { @@ -293,38 +263,31 @@ impl pallet_balances::Trait for Runtime { } parameter_types! { - pub const TransactionByteFee: Balance = 1; // TODO: adjust fee + pub const TransactionByteFee: Balance = 0; // TODO: adjust fee pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000); pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128); } -// type NegativeImbalance = >::NegativeImbalance; -// -// pub struct DealWithFees; -// impl OnUnbalanced for DealWithFees { -// fn on_unbalanceds(mut fees_then_tips: impl Iterator) { -// if let Some(fees) = fees_then_tips.next() { -// // // for fees, 80% to treasury, 20% to author -// // let mut split = fees.ration(80, 20); -// // if let Some(tips) = fees_then_tips.next() { -// // // for tips, if any, 80% to treasury, 20% to author (though this can be anything) -// // tips.ration_merge_into(80, 20, &mut split); -// // } -// // Treasury::on_unbalanced(split.0); -// // Author::on_unbalanced(split.1); -// } -// } -// } - - impl pallet_transaction_payment::Trait for Runtime { type Currency = Balances; - type OnTransactionPayment = (); // TODO: adjust fee + type OnTransactionPayment = (); type TransactionByteFee = TransactionByteFee; - type WeightToFee = IdentityFee; // TODO: adjust weight - type FeeMultiplierUpdate = - TargetedFeeAdjustment; + type WeightToFee = NoWeights; // TODO: adjust weight + type FeeMultiplierUpdate = (); // TODO: adjust fee +} + +pub struct NoWeights; +impl WeightToFeePolynomial for NoWeights { + type Balance = Balance; + + fn polynomial() -> WeightToFeeCoefficients { + Default::default() + } + + fn calc(_weight: &u64) -> Self::Balance { + Default::default() + } } impl pallet_sudo::Trait for Runtime { @@ -344,12 +307,12 @@ impl pallet_authorship::Trait for Runtime { } impl_opaque_keys! { - pub struct SessionKeys { - pub grandpa: Grandpa, - pub babe: Babe, - pub im_online: ImOnline, - pub authority_discovery: AuthorityDiscovery, - } + 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 @@ -651,10 +614,10 @@ impl proposals_codex::Trait for Runtime { } 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 + 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 } impl pallet_contracts::Trait for Runtime { @@ -761,6 +724,9 @@ pub type SignedExtra = ( pallet_grandpa::ValidateEquivocationReport, ); +/// Digest item type. +pub type DigestItem = generic::DigestItem; + /// Block header type as expected by this runtime. pub type Header = generic::Header; @@ -778,7 +744,10 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic, Runtime, AllModules>; + frame_executive::Executive, Runtime, AllModules>; + +#[cfg(any(feature = "std", test))] +pub use pallet_balances::Call as BalancesCall; impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -907,49 +876,49 @@ impl_runtime_apis! { impl pallet_contracts_rpc_runtime_api::ContractsApi for Runtime - { - fn call( - origin: AccountId, - dest: AccountId, - value: Balance, - gas_limit: u64, - input_data: Vec, - ) -> ContractExecResult { - let exec_result = - Contracts::bare_call(origin, dest, value, gas_limit, input_data); - match exec_result { - Ok(v) => ContractExecResult::Success { - status: v.status, - data: v.data, - }, - Err(_) => ContractExecResult::Error, - } - } - - fn get_storage( - address: AccountId, - key: [u8; 32], - ) -> pallet_contracts_primitives::GetStorageResult { - Contracts::get_storage(address, key) - } - - fn rent_projection( - address: AccountId, - ) -> pallet_contracts_primitives::RentProjectionResult { - Contracts::rent_projection(address) - } - } + { + fn call( + origin: AccountId, + dest: AccountId, + value: Balance, + gas_limit: u64, + input_data: Vec, + ) -> ContractExecResult { + let exec_result = + Contracts::bare_call(origin, dest, value, gas_limit, input_data); + match exec_result { + Ok(v) => ContractExecResult::Success { + status: v.status, + data: v.data, + }, + Err(_) => ContractExecResult::Error, + } + } + + fn get_storage( + address: AccountId, + key: [u8; 32], + ) -> pallet_contracts_primitives::GetStorageResult { + Contracts::get_storage(address, key) + } + + fn rent_projection( + address: AccountId, + ) -> pallet_contracts_primitives::RentProjectionResult { + Contracts::rent_projection(address) + } + } 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) - } - } + 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 { diff --git a/runtime/src/primitives.rs b/runtime/src/primitives.rs index 0f837498bf..99ea7258e3 100644 --- a/runtime/src/primitives.rs +++ b/runtime/src/primitives.rs @@ -4,7 +4,10 @@ #![cfg_attr(not(feature = "std"), no_std)] -use sp_runtime::{traits::{Verify, IdentifyAccount}, MultiSignature}; +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + MultiSignature, +}; /// Priority for a transaction. Additive. Higher is better. pub type TransactionPriority = u64; @@ -64,29 +67,29 @@ pub type ActorId = u64; /// GRANDPA. Any rewards for misbehavior reporting will be paid out to this /// account. pub mod report { - use super::{Signature, Verify}; - use system::offchain::AppCrypto; - use sp_core::crypto::{key_types, KeyTypeId}; - - /// 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; - } + 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; + } } From 45657b9d9c330e608cd7c01ff67668620be4b3ef Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 4 Aug 2020 13:01:26 +0300 Subject: [PATCH 39/56] runtime: Move out code from the lib.rs to the integration module --- runtime/src/integration/mod.rs | 1 + runtime/src/integration/transactions.rs | 71 +++++++++++++++++++++++++ runtime/src/lib.rs | 54 ++----------------- 3 files changed, 77 insertions(+), 49 deletions(-) create mode 100644 runtime/src/integration/transactions.rs diff --git a/runtime/src/integration/mod.rs b/runtime/src/integration/mod.rs index 592b56f838..35774a7c6c 100644 --- a/runtime/src/integration/mod.rs +++ b/runtime/src/integration/mod.rs @@ -2,5 +2,6 @@ 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/transactions.rs b/runtime/src/integration/transactions.rs new file mode 100644 index 0000000000..4ce4916813 --- /dev/null +++ b/runtime/src/integration/transactions.rs @@ -0,0 +1,71 @@ +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::traits::StaticLookup; +use sp_runtime::SaturatedConversion; + +use crate::{AccountId, Balance, BlockHashCount, Index, SignedExtra, UncheckedExtrinsic}; +use crate::{Call, Indices, 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 address = Indices::unlookup(account); + let (call, extra, _) = raw_payload.deconstruct(); + Some((call, (address, signature, extra))) +} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ddb076cf3d..20b0054f8a 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -20,14 +20,13 @@ mod primitives; #[cfg(test)] mod tests; // Runtime integration tests -use codec::Encode; use frame_support::inherent::{CheckInherentsResult, InherentData}; use frame_support::traits::KeyOwnerProofSystem; use frame_support::weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, - Weight, WeightToFeeCoefficients, WeightToFeePolynomial, + Weight, }; -use frame_support::{construct_runtime, debug, parameter_types, traits::Randomness}; +use frame_support::{construct_runtime, parameter_types, traits::Randomness}; use pallet_contracts_rpc_runtime_api::ContractExecResult; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -40,14 +39,13 @@ use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::crypto::KeyTypeId; use sp_core::OpaqueMetadata; use sp_runtime::curve::PiecewiseLinear; -use sp_runtime::generic::SignedPayload; use sp_runtime::traits::{ BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys, Saturating, StaticLookup, }; use sp_runtime::transaction_validity::{TransactionSource, TransactionValidity}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, Perbill, - Perquintill, SaturatedConversion, + Perquintill, }; use sp_std::boxed::Box; use sp_std::vec::Vec; @@ -180,36 +178,7 @@ where 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 address = Indices::unlookup(account); - let (call, extra, _) = raw_payload.deconstruct(); - Some((call, (address, signature, extra))) + integration::transactions::create_transaction::(call, public, account, nonce) } } @@ -273,23 +242,10 @@ impl pallet_transaction_payment::Trait for Runtime { type Currency = Balances; type OnTransactionPayment = (); type TransactionByteFee = TransactionByteFee; - type WeightToFee = NoWeights; // TODO: adjust weight + type WeightToFee = integration::transactions::NoWeights; // TODO: adjust weight type FeeMultiplierUpdate = (); // TODO: adjust fee } -pub struct NoWeights; -impl WeightToFeePolynomial for NoWeights { - type Balance = Balance; - - fn polynomial() -> WeightToFeeCoefficients { - Default::default() - } - - fn calc(_weight: &u64) -> Self::Balance { - Default::default() - } -} - impl pallet_sudo::Trait for Runtime { type Event = Event; type Call = Call; From 15e1181c3e1fcc81858e0f5a1a6d97db75871100 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 4 Aug 2020 13:44:31 +0300 Subject: [PATCH 40/56] runtime: Move runtime api code to the separate module --- runtime/src/lib.rs | 247 ++----------------------------------- runtime/src/runtime_api.rs | 244 ++++++++++++++++++++++++++++++++++++ 2 files changed, 254 insertions(+), 237 deletions(-) create mode 100644 runtime/src/runtime_api.rs diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 20b0054f8a..ef34ca3c3a 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -17,35 +17,26 @@ mod constants; mod integration; mod migration; mod primitives; +mod runtime_api; #[cfg(test)] mod tests; // Runtime integration tests -use frame_support::inherent::{CheckInherentsResult, InherentData}; use frame_support::traits::KeyOwnerProofSystem; use frame_support::weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, Weight, }; -use frame_support::{construct_runtime, parameter_types, traits::Randomness}; -use pallet_contracts_rpc_runtime_api::ContractExecResult; -use pallet_grandpa::fg_primitives; +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 pallet_transaction_payment::Multiplier; -use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; -use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::crypto::KeyTypeId; -use sp_core::OpaqueMetadata; use sp_runtime::curve::PiecewiseLinear; -use sp_runtime::traits::{ - BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys, Saturating, StaticLookup, -}; -use sp_runtime::transaction_validity::{TransactionSource, TransactionValidity}; +use sp_runtime::traits::{BlakeTwo256, Block as BlockT, OpaqueKeys, Saturating}; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber, Perbill, - Perquintill, + create_runtime_str, generic, impl_opaque_keys, FixedPointNumber, Perbill, Perquintill, }; use sp_std::boxed::Box; use sp_std::vec::Vec; @@ -55,8 +46,10 @@ use sp_version::RuntimeVersion; use system::EnsureRoot; pub use constants::*; -use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator}; pub use primitives::*; +pub use runtime_api::*; + +use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator}; use content_working_group as content_wg; use governance::{council, election}; @@ -66,6 +59,8 @@ use storage::{data_directory, data_object_storage_registry, data_object_type_reg pub use common; pub use forum; pub use governance::election_params::ElectionParameters; +#[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; @@ -78,7 +73,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { authoring_version: 7, spec_version: 0, impl_version: 0, - apis: RUNTIME_API_VERSIONS, + apis: crate::runtime_api::EXPORTED_RUNTIME_API_VERSIONS, transaction_version: 1, }; @@ -665,225 +660,3 @@ construct_runtime!( StorageWorkingGroup: working_group::::{Module, Call, Storage, Config, Event}, } ); - -/// The address format for describing accounts. -pub type Address = ::Source; -/// 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>; - -#[cfg(any(feature = "std", test))] -pub use pallet_balances::Call as BalancesCall; - -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_contracts_rpc_runtime_api::ContractsApi - for Runtime - { - fn call( - origin: AccountId, - dest: AccountId, - value: Balance, - gas_limit: u64, - input_data: Vec, - ) -> ContractExecResult { - let exec_result = - Contracts::bare_call(origin, dest, value, gas_limit, input_data); - match exec_result { - Ok(v) => ContractExecResult::Success { - status: v.status, - data: v.data, - }, - Err(_) => ContractExecResult::Error, - } - } - - fn get_storage( - address: AccountId, - key: [u8; 32], - ) -> pallet_contracts_primitives::GetStorageResult { - Contracts::get_storage(address, key) - } - - fn rent_projection( - address: AccountId, - ) -> pallet_contracts_primitives::RentProjectionResult { - Contracts::rent_projection(address) - } - } - - - 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/runtime_api.rs b/runtime/src/runtime_api.rs new file mode 100644 index 0000000000..a7dc3fcb86 --- /dev/null +++ b/runtime/src/runtime_api.rs @@ -0,0 +1,244 @@ +use frame_support::inherent::{CheckInherentsResult, InherentData}; +use frame_support::traits::{KeyOwnerProofSystem, Randomness}; +use frame_support::unsigned::{TransactionSource, TransactionValidity}; +use pallet_contracts_rpc_runtime_api::ContractExecResult; +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, StaticLookup}; +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, Contracts, Grandpa, Historical, Indices, + InherentDataExt, RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment, +}; + +/// The address format for describing accounts. +pub type Address = ::Source; +/// 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_contracts_rpc_runtime_api::ContractsApi + for Runtime + { + fn call( + origin: AccountId, + dest: AccountId, + value: Balance, + gas_limit: u64, + input_data: Vec, + ) -> ContractExecResult { + let exec_result = + Contracts::bare_call(origin, dest, value, gas_limit, input_data); + match exec_result { + Ok(v) => ContractExecResult::Success { + status: v.status, + data: v.data, + }, + Err(_) => ContractExecResult::Error, + } + } + + fn get_storage( + address: AccountId, + key: [u8; 32], + ) -> pallet_contracts_primitives::GetStorageResult { + Contracts::get_storage(address, key) + } + + fn rent_projection( + address: AccountId, + ) -> pallet_contracts_primitives::RentProjectionResult { + Contracts::rent_projection(address) + } + } + + + 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) + } + } +} From 10fa8dd43f556b7e253181594722fc43ef3f2964 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 4 Aug 2020 20:15:27 +0300 Subject: [PATCH 41/56] node: Remove unnecessary dependencies. --- Cargo.lock | 77 ++++++++++++---- node/Cargo.toml | 225 +++++++-------------------------------------- runtime/Cargo.toml | 22 ++++- 3 files changed, 115 insertions(+), 209 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c5e5449b0..c93e6630fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1197,6 +1197,20 @@ dependencies = [ "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" @@ -1944,34 +1958,23 @@ version = "3.0.0" dependencies = [ "frame-benchmarking", "frame-benchmarking-cli", - "frame-support", "frame-system", "futures 0.3.4", - "hex-literal", "joystream-node-runtime", "jsonrpc-core", - "log", "node-inspect", - "pallet-authority-discovery", - "pallet-balances", "pallet-contracts", "pallet-contracts-rpc", "pallet-grandpa", "pallet-im-online", - "pallet-indices", - "pallet-staking", - "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc", "parity-scale-codec", - "parking_lot 0.10.2", - "rand 0.7.3", "sc-authority-discovery", "sc-basic-authorship", "sc-chain-spec", "sc-cli", "sc-client-api", - "sc-client-db", "sc-consensus", "sc-consensus-babe", "sc-consensus-babe-rpc", @@ -1981,13 +1984,9 @@ dependencies = [ "sc-finality-grandpa-rpc", "sc-keystore", "sc-network", - "sc-offchain", - "sc-rpc", "sc-rpc-api", "sc-service", "sc-service-test", - "sc-telemetry", - "sc-tracing", "sc-transaction-pool", "serde", "serde_json", @@ -2001,7 +2000,6 @@ dependencies = [ "sp-finality-grandpa", "sp-finality-tracker", "sp-inherents", - "sp-io", "sp-keyring", "sp-runtime", "sp-timestamp", @@ -2010,8 +2008,6 @@ dependencies = [ "substrate-browser-utils", "substrate-frame-rpc-system", "tempfile", - "tokio 0.1.22", - "tracing", "vergen", "wasm-bindgen", "wasm-bindgen-futures", @@ -2021,9 +2017,11 @@ dependencies = [ name = "joystream-node-runtime" 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", @@ -2045,6 +2043,7 @@ dependencies = [ "pallet-membership", "pallet-memo", "pallet-offences", + "pallet-offences-benchmarking", "pallet-proposals-codex", "pallet-proposals-discussion", "pallet-proposals-engine", @@ -2052,6 +2051,7 @@ dependencies = [ "pallet-recurring-reward", "pallet-service-discovery", "pallet-session", + "pallet-session-benchmarking", "pallet-stake", "pallet-staking", "pallet-staking-reward-curve", @@ -3244,6 +3244,7 @@ name = "pallet-collective" 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", @@ -3449,6 +3450,7 @@ name = "pallet-im-online" 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", @@ -3468,6 +3470,7 @@ name = "pallet-indices" 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", @@ -3524,6 +3527,27 @@ dependencies = [ "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" @@ -3667,6 +3691,20 @@ dependencies = [ "sp-trie", ] +[[package]] +name = "pallet-session-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-session", + "pallet-staking", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-stake" version = "3.0.0" @@ -3688,11 +3726,13 @@ 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", @@ -3764,6 +3804,7 @@ dependencies = [ "parity-scale-codec", "serde", "sp-inherents", + "sp-io", "sp-runtime", "sp-std", "sp-timestamp", diff --git a/node/Cargo.toml b/node/Cargo.toml index d0b2703216..dcc697e07d 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -13,27 +13,13 @@ path = 'bin/main.rs' [lib] crate-type = ["cdylib", "rlib"] -#[dependencies] -#derive_more = '0.14.0' -#exit-future = '0.1.4' - -#hex = '0.4' - [dependencies] # third-party dependencies -codec = { package = "parity-scale-codec", version = "1.3.1" } serde = { version = "1.0.102", features = ["derive"] } futures = { version = "0.3.1", features = ["compat"] } -hex-literal = "0.2.1" jsonrpc-core = "14.2.0" -log = "0.4.8" -rand = "0.7.2" -structopt = { version = "0.3.8"} -tracing = "0.1.10" -parking_lot = "0.10.0" - +structopt = { version = "0.3.8", optional = true} serde_json = '1.0' -tokio = '0.1.22' # primitives sp-authority-discovery = { package = 'sp-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } @@ -41,15 +27,13 @@ sp-consensus-babe = { package = 'sp-consensus-babe', git = 'https://github.com/p 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-timestamp = { package = 'sp-timestamp', default-features = false, 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-keyring = { package = 'sp-keyring', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -sp-io = { package = 'sp-io', 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' } @@ -59,68 +43,31 @@ sc-transaction-pool = { package = 'sc-transaction-pool', git = 'https://github.c 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-client-db = { package = 'sc-client-db', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -sc-offchain = { package = 'sc-offchain', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -sc-rpc = { package = 'sc-rpc', 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-tracing = { package = 'sc-tracing', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -sc-telemetry = { package = 'sc-telemetry', 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' } -sp-block-builder = { package = 'sp-block-builder', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -pallet-contracts-rpc = { package = 'pallet-contracts-rpc', 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' } sc-executor = { package = 'sc-executor', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -frame-benchmarking = { package = 'frame-benchmarking', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } - -#sc-client-api = { version = "2.0.0-rc4", path = "../../../client/api" } -#jsonrpc-core = "14.2.0" -#node-primitives = { version = "2.0.0-rc4", path = "../primitives" } -#node-runtime = { version = "2.0.0-rc4", path = "../runtime" } -#sp-runtime = { version = "2.0.0-rc4", path = "../../../primitives/runtime" } -#sp-api = { version = "2.0.0-rc4", path = "../../../primitives/api" } -#pallet-contracts-rpc = { version = "0.8.0-rc4", path = "../../../frame/contracts/rpc/" } -#pallet-transaction-payment-rpc = { version = "2.0.0-rc4", path = "../../../frame/transaction-payment/rpc/" } -#substrate-frame-rpc-system = { version = "2.0.0-rc4", path = "../../../utils/frame/rpc/system" } -#sp-transaction-pool = { version = "2.0.0-rc4", path = "../../../primitives/transaction-pool" } -#sc-consensus-babe = { version = "0.8.0-rc4", path = "../../../client/consensus/babe" } -#sc-consensus-babe-rpc = { version = "0.8.0-rc4", path = "../../../client/consensus/babe/rpc" } -#sp-consensus-babe = { version = "0.8.0-rc4", path = "../../../primitives/consensus/babe" } -#sc-keystore = { version = "2.0.0-rc4", path = "../../../client/keystore" } -#sc-consensus-epochs = { version = "0.8.0-rc4", path = "../../../client/consensus/epochs" } -#sp-consensus = { version = "0.8.0-rc4", path = "../../../primitives/consensus/common" } -#sp-blockchain = { version = "2.0.0-rc4", path = "../../../primitives/blockchain" } -#sc-finality-grandpa = { version = "0.8.0-rc4", path = "../../../client/finality-grandpa" } -#sc-finality-grandpa-rpc = { version = "0.8.0-rc4", path = "../../../client/finality-grandpa/rpc" } -#sc-rpc-api = { version = "0.8.0-rc4", path = "../../../client/rpc-api" } -#sp-block-builder = { version = "2.0.0-rc4", path = "../../../primitives/block-builder" } # frame dependencies -pallet-indices = { package = 'pallet-indices', 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-contracts = { package = 'pallet-contracts', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -frame-system = { package = 'frame-system', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -pallet-balances = { package = 'pallet-balances', 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' } -frame-support = { package = 'frame-support', 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-authority-discovery = { package = 'pallet-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -pallet-staking = { package = 'pallet-staking', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -pallet-grandpa = { package = 'pallet-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +pallet-contracts-rpc = { package = 'pallet-contracts-rpc', 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' } -frame-benchmarking-cli = { package = 'frame-benchmarking-cli', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -node-inspect = { package = 'node-inspect', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } +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 } @@ -128,136 +75,34 @@ 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] -#sc-keystore = { version = "2.0.0-rc4", path = "../../../client/keystore" } -#sc-consensus = { version = "0.8.0-rc4", path = "../../../client/consensus/common" } +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"]} -#sc-consensus-epochs = { version = "0.8.0-rc4", path = "../../../client/consensus/epochs" } sc-service-test = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } -#futures = "0.3.4" -tempfile = "3.1.0" -#assert_cmd = "1.0" -#nix = "0.17" -#serde_json = "1.0" -#regex = "1" -#platforms = "0.2.1" - -#[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 +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' + +[features] +default = [ "cli" ] +browser = [ + "browser-utils", + "wasm-bindgen", + "wasm-bindgen-futures", +] +cli = [ + "node-inspect", + "sc-cli", + "frame-benchmarking-cli", + "sc-service/db", + "structopt", +] +runtime-benchmarks = [ + "node-runtime/runtime-benchmarks", + "frame-benchmarking-cli", +] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 52c711d4cb..60549123ab 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -56,6 +56,12 @@ pallet-contracts = { package = 'pallet-contracts', default-features = false, git pallet-contracts-rpc-runtime-api = { package = 'pallet-contracts-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} pallet-contracts-primitives = { package = 'pallet-contracts-primitives', 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'} @@ -155,6 +161,20 @@ 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-indices/runtime-benchmarks", + "pallet-staking/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "frame-benchmarking", + "frame-system-benchmarking", + "pallet-offences-benchmarking", + "pallet-session-benchmarking", +] From fb9845beb7773e2282057572488259bf32487218 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 5 Aug 2020 18:57:05 +0300 Subject: [PATCH 42/56] runtime: Remove migration and indices module. --- Cargo.lock | 18 ----- node/src/chain_spec.rs | 9 +-- node/src/service.rs | 8 +- .../proposals/codex/src/tests/mock.rs | 23 ------ runtime-modules/working-group/src/lib.rs | 3 +- runtime/Cargo.toml | 3 - runtime/src/integration/transactions.rs | 6 +- runtime/src/lib.rs | 29 +------ runtime/src/migration.rs | 75 ------------------- runtime/src/runtime_api.rs | 10 +-- 10 files changed, 18 insertions(+), 166 deletions(-) delete mode 100644 runtime/src/migration.rs diff --git a/Cargo.lock b/Cargo.lock index c93e6630fe..eb14550702 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2039,7 +2039,6 @@ dependencies = [ "pallet-grandpa", "pallet-hiring", "pallet-im-online", - "pallet-indices", "pallet-membership", "pallet-memo", "pallet-offences", @@ -3465,23 +3464,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-indices" -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", - "serde", - "sp-core", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-membership" version = "3.0.0" diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index e641b4ed8d..76b188397e 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -33,10 +33,9 @@ use node_runtime::{ versioned_store::InputValidationLengthConstraint as VsInputValidation, AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig, ContractsConfig, CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig, - DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig, - MembersConfig, MigrationConfig, 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, }; type AccountPublic = ::Signer; @@ -244,7 +243,6 @@ pub fn testnet_genesis( pallet_grandpa: Some(GrandpaConfig { authorities: vec![], }), - pallet_indices: Some(IndicesConfig { indices: vec![] }), pallet_session: Some(SessionConfig { keys: initial_authorities .iter() @@ -334,7 +332,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/service.rs b/node/src/service.rs index 9a3f9f32ab..a1ebae62c5 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -423,8 +423,8 @@ mod tests { use codec::{Decode, Encode}; use node_runtime::RuntimeApi; use node_runtime::{currency::CENTS, SLOT_DURATION}; - use node_runtime::{opaque::Block, DigestItem, Signature}; - use node_runtime::{Address, BalancesCall, Call, UncheckedExtrinsic}; + use node_runtime::{opaque::Block, AccountId, DigestItem, Signature}; + use node_runtime::{BalancesCall, Call, UncheckedExtrinsic}; use sc_consensus_babe::{BabeIntermediate, CompatibleDigestItem, INTERMEDIATE_KEY}; use sc_consensus_epochs::descendent_query; use sc_finality_grandpa::{self as grandpa}; @@ -590,8 +590,8 @@ mod tests { }, |service, _| { let amount = 5 * CENTS; - let to: Address = AccountPublic::from(bob.public()).into_account().into(); - let from: Address = AccountPublic::from(charlie.public()).into_account().into(); + let to: AccountId = AccountPublic::from(bob.public()).into_account().into(); + let from: AccountId = AccountPublic::from(charlie.public()).into_account().into(); let genesis_hash = service.client().block_hash(0).unwrap().unwrap(); let best_block_id = BlockId::number(service.client().chain_info().best_number); let (spec_version, transaction_version) = { diff --git a/runtime-modules/proposals/codex/src/tests/mock.rs b/runtime-modules/proposals/codex/src/tests/mock.rs index ccef3b3a10..071e58a4ba 100644 --- a/runtime-modules/proposals/codex/src/tests/mock.rs +++ b/runtime-modules/proposals/codex/src/tests/mock.rs @@ -230,29 +230,6 @@ where pub type Extrinsic = TestXt; -/* - type Currency = Balances; - type UnixTime = Timestamp; - type CurrencyToVote = CurrencyToVoteHandler; - type RewardRemainder = RewardRemainderMock; - type Event = MetaEvent; - type Slash = (); - type Reward = (); - type SessionsPerEra = SessionsPerEra; - type SlashDeferDuration = SlashDeferDuration; - type SlashCancelOrigin = frame_system::EnsureRoot; - type BondingDuration = BondingDuration; - type SessionInterface = Self; - type RewardCurve = RewardCurve; - type NextNewSession = Session; - type ElectionLookahead = ElectionLookahead; - type Call = Call; - type MaxIterations = MaxIterations; - type MinSolutionScoreBump = MinSolutionScoreBump; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; - type UnsignedPriority = UnsignedPriority; -*/ - impl staking::SessionInterface for Test { fn disable_validator(_: &u64) -> Result { unimplemented!() diff --git a/runtime-modules/working-group/src/lib.rs b/runtime-modules/working-group/src/lib.rs index e057b7a575..d4206a67c5 100644 --- a/runtime-modules/working-group/src/lib.rs +++ b/runtime-modules/working-group/src/lib.rs @@ -1475,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/Cargo.toml b/runtime/Cargo.toml index 60549123ab..80298d58ae 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -37,7 +37,6 @@ system = { package = 'frame-system', default-features = false, git = 'https://gi 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-indices = { package = 'pallet-indices', 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'} @@ -133,7 +132,6 @@ std = [ 'pallet-staking/std', # 'pallet-staking-reward-curve/std', // don't have 'std' features 'pallet-sudo/std', - 'pallet-indices/std', 'pallet-im-online/std', 'pallet-collective/std', 'pallet-offences/std', @@ -168,7 +166,6 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-im-online/runtime-benchmarks", - "pallet-indices/runtime-benchmarks", "pallet-staking/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "frame-benchmarking", diff --git a/runtime/src/integration/transactions.rs b/runtime/src/integration/transactions.rs index 4ce4916813..865e09bd2f 100644 --- a/runtime/src/integration/transactions.rs +++ b/runtime/src/integration/transactions.rs @@ -3,11 +3,10 @@ use frame_support::debug; use frame_support::weights::{WeightToFeeCoefficients, WeightToFeePolynomial}; use sp_runtime::generic; use sp_runtime::generic::SignedPayload; -use sp_runtime::traits::StaticLookup; use sp_runtime::SaturatedConversion; use crate::{AccountId, Balance, BlockHashCount, Index, SignedExtra, UncheckedExtrinsic}; -use crate::{Call, Indices, Runtime, System}; +use crate::{Call, Runtime, System}; /// Stub for zero transaction weights. pub struct NoWeights; @@ -65,7 +64,6 @@ pub(crate) fn create_transaction< }) .ok()?; let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?; - let address = Indices::unlookup(account); let (call, extra, _) = raw_payload.deconstruct(); - Some((call, (address, signature, extra))) + Some((call, (account, signature, extra))) } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ef34ca3c3a..e89630bdc0 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -15,7 +15,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod constants; mod integration; -mod migration; mod primitives; mod runtime_api; #[cfg(test)] @@ -30,14 +29,11 @@ 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 pallet_transaction_payment::Multiplier; 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, OpaqueKeys, Saturating}; -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, FixedPointNumber, Perbill, Perquintill, -}; +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")] @@ -110,7 +106,7 @@ impl system::Trait for Runtime { type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; - type Lookup = Indices; + type Lookup = IdentityLookup; type Header = generic::Header; type Event = Event; type BlockHashCount = BlockHashCount; @@ -190,17 +186,6 @@ where type OverarchingCall = Call; } -parameter_types! { - pub const IndexDeposit: Balance = 0; // no minimum deposit -} - -impl pallet_indices::Trait for Runtime { - type AccountIndex = AccountIndex; - type Currency = Balances; - type Deposit = IndexDeposit; - type Event = Event; -} - parameter_types! { pub const MinimumPeriod: Moment = SLOT_DURATION / 2; } @@ -228,9 +213,6 @@ impl pallet_balances::Trait for Runtime { parameter_types! { pub const TransactionByteFee: Balance = 0; // TODO: adjust fee - pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); - pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000); - pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128); } impl pallet_transaction_payment::Trait for Runtime { @@ -487,9 +469,6 @@ impl forum::Trait for Runtime { type PostId = PostId; } -impl migration::Trait for Runtime { - type Event = Event; -} // The storage working group instance alias. pub type StorageWorkingGroupInstance = working_group::Instance2; @@ -618,7 +597,6 @@ construct_runtime!( Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, - Indices: pallet_indices::{Module, Call, Storage, Config, Event}, Balances: pallet_balances::{Module, Call, Storage, Config, Event}, TransactionPayment: pallet_transaction_payment::{Module, Storage}, Staking: pallet_staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, @@ -633,7 +611,6 @@ construct_runtime!( Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, Contracts: pallet_contracts::{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}, diff --git a/runtime/src/migration.rs b/runtime/src/migration.rs deleted file mode 100644 index 64e527b541..0000000000 --- a/runtime/src/migration.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Clippy linter warning -#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design - -use crate::VERSION; -use frame_support::weights::Weight; -use frame_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. - } -} - -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(fn spec_version) build(|_config: &GenesisConfig| { - Some(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) -> Weight { - 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, - )); - } - - 10_000_000 // TODO adjust weight - } - } -} - -impl Module {} diff --git a/runtime/src/runtime_api.rs b/runtime/src/runtime_api.rs index a7dc3fcb86..8e4e7298df 100644 --- a/runtime/src/runtime_api.rs +++ b/runtime/src/runtime_api.rs @@ -7,7 +7,7 @@ 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, StaticLookup}; +use sp_runtime::traits::{BlakeTwo256, Block as BlockT, NumberFor}; use sp_runtime::{generic, ApplyExtrinsicResult}; use sp_std::vec::Vec; @@ -17,12 +17,10 @@ use crate::{ GrandpaId, Hash, Index, RuntimeVersion, Signature, VERSION, }; use crate::{ - AllModules, AuthorityDiscovery, Babe, Call, Contracts, Grandpa, Historical, Indices, - InherentDataExt, RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment, + AllModules, AuthorityDiscovery, Babe, Call, Contracts, Grandpa, Historical, InherentDataExt, + RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment, }; -/// The address format for describing accounts. -pub type Address = ::Source; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( system::CheckSpecVersion, @@ -51,7 +49,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = From 58d6221e77c4d73bf8861377e36ac833b3c35e0a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 6 Aug 2020 20:52:33 +0300 Subject: [PATCH 43/56] chain-spec-builder: Convert the chain-spec-builder crate. --- Cargo.lock | 14 ++++++++++ Cargo.toml | 2 +- node/src/chain_spec.rs | 3 ++- utils/chain-spec-builder/Cargo.toml | 35 ++++++++----------------- utils/chain-spec-builder/src/main.rs | 39 +++++++++++----------------- 5 files changed, 43 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb14550702..0d3554627c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -560,6 +560,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "chain-spec-builder" +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", +] + [[package]] name = "chrono" version = "0.4.11" diff --git a/Cargo.toml b/Cargo.toml index fa1b9d0512..2db388f05e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ members = [ "runtime-modules/versioned-store-permissions", "runtime-modules/working-group", "node", -# "utils/chain-spec-builder/" + "utils/chain-spec-builder/" ] [profile.release] diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 76b188397e..5ca7cb1100 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -19,7 +19,6 @@ // Example: voting_period: 1 * DAY #![allow(clippy::identity_op)] -use node_runtime::{AccountId, GenesisConfig}; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use serde_json as json; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -38,6 +37,8 @@ use node_runtime::{ StorageWorkingGroupConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY, }; +pub use node_runtime::{AccountId, GenesisConfig}; + type AccountPublic = ::Signer; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. diff --git a/utils/chain-spec-builder/Cargo.toml b/utils/chain-spec-builder/Cargo.toml index fb344bad93..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.0.0-alpha.3" -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" -joystream-node = { version = "2.1.2", path = "../../node" } +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 d8faee6e8b..3a8b90919d 100644 --- a/utils/chain-spec-builder/src/main.rs +++ b/utils/chain-spec-builder/src/main.rs @@ -24,14 +24,15 @@ use rand::{distributions::Alphanumeric, rngs::OsRng, Rng}; use structopt::StructOpt; use joystream_node::chain_spec::{self, chain_spec_properties, AccountId}; -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 @@ -133,26 +134,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> { @@ -160,7 +157,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 @@ -169,17 +166,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(()) From cb8c85d21cd62e4eb029b0fc084d78e156124ede Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 10 Aug 2020 13:44:40 +0300 Subject: [PATCH 44/56] node: Update the build.rs --- Cargo.lock | 26 ++++++++------- node/Cargo.toml | 7 +++- node/build.rs | 83 +++++++++++++++++++++++++++++++++++++----------- runtime/build.rs | 16 +++------- 4 files changed, 90 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d3554627c..ce40629a35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2020,9 +2020,9 @@ dependencies = [ "sp-transaction-pool", "structopt", "substrate-browser-utils", + "substrate-build-script-utils", "substrate-frame-rpc-system", "tempfile", - "vergen", "wasm-bindgen", "wasm-bindgen-futures", ] @@ -4221,6 +4221,12 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" +[[package]] +name = "platforms" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" + [[package]] name = "poly1305" version = "0.6.0" @@ -6867,6 +6873,14 @@ dependencies = [ "wasm-bindgen-futures", ] +[[package]] +name = "substrate-build-script-utils" +version = "2.0.0-rc4" +source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" +dependencies = [ + "platforms", +] + [[package]] name = "substrate-frame-rpc-system" version = "2.0.0-rc4" @@ -7701,16 +7715,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" -[[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.9.2" diff --git a/node/Cargo.toml b/node/Cargo.toml index dcc697e07d..b2ee37808a 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -86,7 +86,11 @@ pallet-transaction-payment = { package = 'pallet-transaction-payment', git = 'ht 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" ] @@ -101,6 +105,7 @@ cli = [ "frame-benchmarking-cli", "sc-service/db", "structopt", + "substrate-build-script-utils", ] runtime-benchmarks = [ "node-runtime/runtime-benchmarks", 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/runtime/build.rs b/runtime/build.rs index 828f0ef5c2..2b3a5ae5ac 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -15,25 +15,19 @@ // 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() { - env::set_var("BUILD_DUMMY_WASM_BINARY", "1"); + env::set_var("DUMMY_WASM_BINARY_ENV", "1"); 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() } From a8b2de776847b33cbdff6cd6de47cadb1de06789 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 10 Aug 2020 14:30:07 +0300 Subject: [PATCH 45/56] node: Fix review comments. - removed all traces of the pallet_contracts (runtime, rpc, node, chain_spec) - fix load_spec TODO --- Cargo.lock | 3 --- node/src/chain_spec.rs | 10 +--------- node/src/command.rs | 4 ++-- node/src/node_rpc.rs | 3 --- runtime/Cargo.toml | 6 ------ runtime/src/lib.rs | 20 ------------------- runtime/src/runtime_api.rs | 40 +------------------------------------- 7 files changed, 4 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce40629a35..8f63a9be9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2044,9 +2044,6 @@ dependencies = [ "pallet-collective", "pallet-common", "pallet-content-working-group", - "pallet-contracts", - "pallet-contracts-primitives", - "pallet-contracts-rpc-runtime-api", "pallet-finality-tracker", "pallet-forum", "pallet-governance", diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 5ca7cb1100..19a8156ca8 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -31,7 +31,7 @@ use sp_runtime::Perbill; use node_runtime::{ versioned_store::InputValidationLengthConstraint as VsInputValidation, AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig, - ContractsConfig, CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig, + CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig, DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, MembersConfig, ProposalsCodexConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY, @@ -205,8 +205,6 @@ pub fn testnet_genesis( const STASH: Balance = 20 * DOLLARS; const ENDOWMENT: Balance = 100_000 * DOLLARS; - let enable_println = false; - // default codex proposals config parameters let cpcp = node_runtime::ProposalsConfigParameters::default(); let default_text_constraint = node_runtime::working_group::default_text_constraint(); @@ -256,12 +254,6 @@ pub fn testnet_genesis( }) .collect::>(), }), - pallet_contracts: Some(ContractsConfig { - current_schedule: pallet_contracts::Schedule { - enable_println, // this should only be enabled on development chains - ..Default::default() - }, - }), council: Some(CouncilConfig { active_council: vec![], term_ends_at: 1, diff --git a/node/src/command.rs b/node/src/command.rs index 2195aa6501..12fe4cb1c8 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -55,8 +55,8 @@ impl SubstrateCli for Cli { fn load_spec(&self, id: &str) -> std::result::Result, String> { Ok(match id { - "dev" => Box::new(chain_spec::Alternative::Development.load().unwrap()), //TODO - "local" => Box::new(chain_spec::Alternative::LocalTestnet.load().unwrap()), + "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), )?), diff --git a/node/src/node_rpc.rs b/node/src/node_rpc.rs index 5a6a055402..f33509e208 100644 --- a/node/src/node_rpc.rs +++ b/node/src/node_rpc.rs @@ -101,7 +101,6 @@ where C: HeaderBackend + HeaderMetadata + 'static, C: Send + Sync + 'static, C::Api: substrate_frame_rpc_system::AccountNonceApi, - C::Api: pallet_contracts_rpc::ContractsRuntimeApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi< Block, Balance, @@ -113,7 +112,6 @@ where M: jsonrpc_core::Metadata + Default, SC: SelectChain + 'static, { - use pallet_contracts_rpc::{Contracts, ContractsApi}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; use substrate_frame_rpc_system::{FullSystem, SystemApi}; @@ -144,7 +142,6 @@ where // 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(ContractsApi::to_delegate(Contracts::new(client.clone()))); io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new( client.clone(), ))); diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 80298d58ae..4c68a0f426 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -51,9 +51,6 @@ pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git 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'} -pallet-contracts = { package = 'pallet-contracts', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} -pallet-contracts-rpc-runtime-api = { package = 'pallet-contracts-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'} -pallet-contracts-primitives = { package = 'pallet-contracts-primitives', 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 } @@ -135,9 +132,6 @@ std = [ 'pallet-im-online/std', 'pallet-collective/std', 'pallet-offences/std', - 'pallet-contracts/std', - 'pallet-contracts-rpc-runtime-api/std', - 'pallet-contracts-primitives/std', # Joystream 'common/std', diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index e89630bdc0..b8fc167ab5 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -550,25 +550,6 @@ parameter_types! { pub const SurchargeReward: Balance = 0; // no reward } -impl pallet_contracts::Trait for Runtime { - type Time = Timestamp; - type Randomness = RandomnessCollectiveFlip; - type Currency = Balances; - type Event = Event; - type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer; - type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter; - type RentPayment = (); - type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap; - type TombstoneDeposit = TombstoneDeposit; - type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset; - type RentByteFee = RentByteFee; - type RentDepositOffset = RentDepositOffset; - type SurchargeReward = SurchargeReward; - type MaxDepth = pallet_contracts::DefaultMaxDepth; - type MaxValueSize = pallet_contracts::DefaultMaxValueSize; - type WeightPrice = pallet_transaction_payment::Module; -} - /// 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 @@ -609,7 +590,6 @@ construct_runtime!( Offences: pallet_offences::{Module, Call, Storage, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, - Contracts: pallet_contracts::{Module, Call, Config, Storage, Event}, // Joystream CouncilElection: election::{Module, Call, Storage, Event, Config}, Council: council::{Module, Call, Storage, Event, Config}, diff --git a/runtime/src/runtime_api.rs b/runtime/src/runtime_api.rs index 8e4e7298df..acb9c4e015 100644 --- a/runtime/src/runtime_api.rs +++ b/runtime/src/runtime_api.rs @@ -1,7 +1,6 @@ use frame_support::inherent::{CheckInherentsResult, InherentData}; use frame_support::traits::{KeyOwnerProofSystem, Randomness}; use frame_support::unsigned::{TransactionSource, TransactionValidity}; -use pallet_contracts_rpc_runtime_api::ContractExecResult; use pallet_grandpa::fg_primitives; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use sp_api::impl_runtime_apis; @@ -17,7 +16,7 @@ use crate::{ GrandpaId, Hash, Index, RuntimeVersion, Signature, VERSION, }; use crate::{ - AllModules, AuthorityDiscovery, Babe, Call, Contracts, Grandpa, Historical, InherentDataExt, + AllModules, AuthorityDiscovery, Babe, Call, Grandpa, Historical, InherentDataExt, RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment, }; @@ -182,43 +181,6 @@ impl_runtime_apis! { } } - - impl pallet_contracts_rpc_runtime_api::ContractsApi - for Runtime - { - fn call( - origin: AccountId, - dest: AccountId, - value: Balance, - gas_limit: u64, - input_data: Vec, - ) -> ContractExecResult { - let exec_result = - Contracts::bare_call(origin, dest, value, gas_limit, input_data); - match exec_result { - Ok(v) => ContractExecResult::Success { - status: v.status, - data: v.data, - }, - Err(_) => ContractExecResult::Error, - } - } - - fn get_storage( - address: AccountId, - key: [u8; 32], - ) -> pallet_contracts_primitives::GetStorageResult { - Contracts::get_storage(address, key) - } - - fn rent_projection( - address: AccountId, - ) -> pallet_contracts_primitives::RentProjectionResult { - Contracts::rent_projection(address) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< Block, Balance, From e01eb1cfc625be6da976bd9903132c591457861e Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 10 Aug 2020 18:22:08 +0300 Subject: [PATCH 46/56] runtime: Renames AccountInfo to the StorageProviderAccountInfo --- runtime-modules/service-discovery/src/lib.rs | 18 +++++++++--------- runtime-modules/service-discovery/src/tests.rs | 6 +++--- runtime/src/tests/storage_integration.rs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/runtime-modules/service-discovery/src/lib.rs b/runtime-modules/service-discovery/src/lib.rs index 09afda67da..286e6d62c8 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 StorageProviderAccountInfo to save an IPNS identity for the storage provider. +//! - [unset_ipns_id](./struct.Module.html#method.unset_ipns_id) - Deletes the StorageProviderAccountInfo 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. //! @@ -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 StorageProviderAccountInfo { /// IPNS Identity. pub identity: IPNSIdentity, /// Block at which information expires. @@ -81,11 +81,11 @@ decl_storage! { /// Bootstrap endpoints maintained by root pub BootstrapEndpoints get(fn bootstrap_endpoints): Vec; - /// Mapping of service providers' storage provider id to their AccountInfo + /// Mapping of service providers' storage provider id to their StorageProviderAccountInfo pub AccountInfoByStorageProviderId get(fn account_info_by_storage_provider_id): - map hasher(blake2_128_concat) StorageProviderId => AccountInfo; + map hasher(blake2_128_concat) StorageProviderId => StorageProviderAccountInfo; - /// Lifetime of an AccountInfo record in AccountInfoByAccountId map + /// Lifetime of an StorageProviderAccountInfo record in AccountInfoByAccountId map pub DefaultLifetime get(fn default_lifetime) config(): T::BlockNumber = T::BlockNumber::from(DEFAULT_LIFETIME); } @@ -115,7 +115,7 @@ decl_module! { /// Default deposit_event() handler fn deposit_event() = default; - /// Creates the AccountInfo to save an IPNS identity for the storage provider. + /// Creates the StorageProviderAccountInfo 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( @@ -131,7 +131,7 @@ decl_module! { // == MUTATION SAFE == // - >::insert(storage_provider_id, AccountInfo { + >::insert(storage_provider_id, StorageProviderAccountInfo { identity: id.clone(), expires_at: >::block_number() + Self::default_lifetime(), }); @@ -139,7 +139,7 @@ decl_module! { Self::deposit_event(RawEvent::AccountInfoUpdated(storage_provider_id, id)); } - /// Deletes the AccountInfo with the IPNS identity for the storage provider. + /// Deletes the StorageProviderAccountInfo 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) { diff --git a/runtime-modules/service-discovery/src/tests.rs b/runtime-modules/service-discovery/src/tests.rs index 9982943527..4f3aa7b7ce 100644 --- a/runtime-modules/service-discovery/src/tests.rs +++ b/runtime-modules/service-discovery/src/tests.rs @@ -27,7 +27,7 @@ fn set_ipns_id() { let account_info = Discovery::account_info_by_storage_provider_id(&storage_provider_id); assert_eq!( account_info, - AccountInfo { + StorageProviderAccountInfo { identity: identity.clone(), expires_at: current_block_number + ttl } @@ -70,7 +70,7 @@ fn unset_ipns_id() { >::insert( &storage_provider_id, - AccountInfo { + StorageProviderAccountInfo { expires_at: 1000, identity: "alice".as_bytes().to_vec(), }, @@ -120,7 +120,7 @@ fn is_account_info_expired() { let id = "alice".as_bytes().to_vec(); >::insert( &storage_provider_id, - AccountInfo { + StorageProviderAccountInfo { expires_at, identity: id.clone(), }, diff --git a/runtime/src/tests/storage_integration.rs b/runtime/src/tests/storage_integration.rs index 22cb0bd36a..9bb53a477e 100644 --- a/runtime/src/tests/storage_integration.rs +++ b/runtime/src/tests/storage_integration.rs @@ -28,7 +28,7 @@ fn storage_provider_helper_succeeds() { 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::StorageProviderAccountInfo{ identity: Vec::new(), expires_at: 1000 }; From 191f38825584b2f6fff30ee7379706d4116177ad Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 10 Aug 2020 18:46:35 +0300 Subject: [PATCH 47/56] node: Remove pallet-contracts dependency --- Cargo.lock | 87 ------------------------------------------------- node/Cargo.toml | 2 -- 2 files changed, 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f63a9be9f..a4d6c24964 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1977,8 +1977,6 @@ dependencies = [ "joystream-node-runtime", "jsonrpc-core", "node-inspect", - "pallet-contracts", - "pallet-contracts-rpc", "pallet-grandpa", "pallet-im-online", "pallet-transaction-payment", @@ -3302,67 +3300,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-contracts" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "frame-support", - "frame-system", - "pallet-contracts-primitives", - "parity-scale-codec", - "parity-wasm", - "pwasm-utils", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-sandbox", - "sp-std", - "wasmi-validation", -] - -[[package]] -name = "pallet-contracts-primitives" -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 = "pallet-contracts-rpc" -version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "jsonrpc-core", - "jsonrpc-core-client", - "jsonrpc-derive", - "pallet-contracts-primitives", - "pallet-contracts-rpc-runtime-api", - "parity-scale-codec", - "serde", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-rpc", - "sp-runtime", -] - -[[package]] -name = "pallet-contracts-rpc-runtime-api" -version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "pallet-contracts-primitives", - "parity-scale-codec", - "sp-api", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-finality-tracker" version = "2.0.0-rc4" @@ -4432,17 +4369,6 @@ version = "2.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d883f78645c21b7281d21305181aa1f4dd9e9363e7cf2566c93121552cff003e" -[[package]] -name = "pwasm-utils" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7a12f176deee919f4ba55326ee17491c8b707d0987aed822682c821b660192" -dependencies = [ - "byteorder", - "log", - "parity-wasm", -] - [[package]] name = "quick-error" version = "1.2.3" @@ -6563,19 +6489,6 @@ dependencies = [ "syn 1.0.17", ] -[[package]] -name = "sp-sandbox" -version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "parity-scale-codec", - "sp-core", - "sp-io", - "sp-std", - "sp-wasm-interface", - "wasmi", -] - [[package]] name = "sp-serializer" version = "2.0.0-rc4" diff --git a/node/Cargo.toml b/node/Cargo.toml index b2ee37808a..4b76605371 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -54,9 +54,7 @@ sc-rpc-api = { package = 'sc-rpc-api', git = 'https://github.com/paritytech/subs sc-executor = { package = 'sc-executor', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } # frame dependencies -pallet-contracts = { package = 'pallet-contracts', 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-contracts-rpc = { package = 'pallet-contracts-rpc', 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' } From 67cd58c4a0cdfa65576d3d83e97c01a887f5270e Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 10 Aug 2020 19:47:08 +0300 Subject: [PATCH 48/56] runtime: Restore valid env variable. --- runtime/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/build.rs b/runtime/build.rs index 2b3a5ae5ac..269bd9dd1b 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder; fn main() { if !in_real_cargo_environment() { - env::set_var("DUMMY_WASM_BINARY_ENV", "1"); + env::set_var("BUILD_DUMMY_WASM_BINARY", "1"); println!("Building DUMMY Wasm binary"); } From 70c2e8a89c9bd2c1097c347d26b1877846e58deb Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 11 Aug 2020 13:55:39 +0300 Subject: [PATCH 49/56] node: Forum sudo key changed. --- node/src/chain_spec.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 19a8156ca8..4d8274ef3b 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -233,7 +233,9 @@ pub fn testnet_genesis( slash_reward_fraction: Perbill::from_percent(10), ..Default::default() }), - pallet_sudo: Some(SudoConfig { key: root_key }), + pallet_sudo: Some(SudoConfig { + key: root_key.clone(), + }), pallet_babe: Some(BabeConfig { authorities: vec![], }), @@ -275,9 +277,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, }), From c74ec0d6f62873512acf12810aa81c12699cab95 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 13 Aug 2020 11:16:23 +0300 Subject: [PATCH 50/56] runtime: Rename StorageProviderAccountInfo to ServiceProviderRecord --- runtime-modules/service-discovery/src/lib.rs | 18 +++++++++--------- runtime-modules/service-discovery/src/tests.rs | 6 +++--- runtime/src/tests/storage_integration.rs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/runtime-modules/service-discovery/src/lib.rs b/runtime-modules/service-discovery/src/lib.rs index 286e6d62c8..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 StorageProviderAccountInfo to save an IPNS identity for the storage provider. -//! - [unset_ipns_id](./struct.Module.html#method.unset_ipns_id) - Deletes the StorageProviderAccountInfo 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. //! @@ -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 StorageProviderAccountInfo { +pub struct ServiceProviderRecord { /// IPNS Identity. pub identity: IPNSIdentity, /// Block at which information expires. @@ -81,11 +81,11 @@ decl_storage! { /// Bootstrap endpoints maintained by root pub BootstrapEndpoints get(fn bootstrap_endpoints): Vec; - /// Mapping of service providers' storage provider id to their StorageProviderAccountInfo + /// 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 => StorageProviderAccountInfo; + map hasher(blake2_128_concat) StorageProviderId => ServiceProviderRecord; - /// Lifetime of an StorageProviderAccountInfo record in AccountInfoByAccountId map + /// Lifetime of an ServiceProviderRecord record in AccountInfoByAccountId map pub DefaultLifetime get(fn default_lifetime) config(): T::BlockNumber = T::BlockNumber::from(DEFAULT_LIFETIME); } @@ -115,7 +115,7 @@ decl_module! { /// Default deposit_event() handler fn deposit_event() = default; - /// Creates the StorageProviderAccountInfo 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( @@ -131,7 +131,7 @@ decl_module! { // == MUTATION SAFE == // - >::insert(storage_provider_id, StorageProviderAccountInfo { + >::insert(storage_provider_id, ServiceProviderRecord { identity: id.clone(), expires_at: >::block_number() + Self::default_lifetime(), }); @@ -139,7 +139,7 @@ decl_module! { Self::deposit_event(RawEvent::AccountInfoUpdated(storage_provider_id, id)); } - /// Deletes the StorageProviderAccountInfo 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) { diff --git a/runtime-modules/service-discovery/src/tests.rs b/runtime-modules/service-discovery/src/tests.rs index 4f3aa7b7ce..969dc51ce2 100644 --- a/runtime-modules/service-discovery/src/tests.rs +++ b/runtime-modules/service-discovery/src/tests.rs @@ -27,7 +27,7 @@ fn set_ipns_id() { let account_info = Discovery::account_info_by_storage_provider_id(&storage_provider_id); assert_eq!( account_info, - StorageProviderAccountInfo { + ServiceProviderRecord { identity: identity.clone(), expires_at: current_block_number + ttl } @@ -70,7 +70,7 @@ fn unset_ipns_id() { >::insert( &storage_provider_id, - StorageProviderAccountInfo { + ServiceProviderRecord { expires_at: 1000, identity: "alice".as_bytes().to_vec(), }, @@ -120,7 +120,7 @@ fn is_account_info_expired() { let id = "alice".as_bytes().to_vec(); >::insert( &storage_provider_id, - StorageProviderAccountInfo { + ServiceProviderRecord { expires_at, identity: id.clone(), }, diff --git a/runtime/src/tests/storage_integration.rs b/runtime/src/tests/storage_integration.rs index 9bb53a477e..3d3e9093f4 100644 --- a/runtime/src/tests/storage_integration.rs +++ b/runtime/src/tests/storage_integration.rs @@ -28,7 +28,7 @@ fn storage_provider_helper_succeeds() { let random_provider_result = >::get_random_storage_provider(); assert!(random_provider_result.is_err()); - let account_info = service_discovery::StorageProviderAccountInfo{ + let account_info = service_discovery::ServiceProviderRecord{ identity: Vec::new(), expires_at: 1000 }; From abc363b4603654c6146f47597611bb461f15d7ab Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 13 Aug 2020 11:50:44 +0300 Subject: [PATCH 51/56] node: Restore node information from the environment variables. --- node/src/command.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index 12fe4cb1c8..5372c9c7eb 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -29,18 +29,6 @@ impl SubstrateCli for Cli { "Joystream Node" } - fn impl_version() -> &'static str { - "3.0.0" - } - - fn description() -> &'static str { - "Joystream substrate node" - } - - fn author() -> &'static str { - "Joystream contributors" - } - fn support_url() -> &'static str { "https://www.joystream.org/" } @@ -53,6 +41,18 @@ impl SubstrateCli for Cli { "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()?), From f22c3800567e751510fefc9f0b8e70614627fd23 Mon Sep 17 00:00:00 2001 From: Mokhtar Naamani Date: Mon, 17 Aug 2020 18:13:09 +0300 Subject: [PATCH 52/56] travis: use latest nightly --- .travis.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5fc40dd352..5cad9cca4a 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,7 @@ 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 --all + - TRIGGER_WASM_BUILD=1 cargo build --release + - ls -l ./target/release/wbuild/joystream-node-runtime/ From c9b94178f1a0306af0399d896cc5692d457e08a3 Mon Sep 17 00:00:00 2001 From: Mokhtar Naamani Date: Tue, 18 Aug 2020 09:33:02 +0300 Subject: [PATCH 53/56] travis: skip clippy --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5cad9cca4a..00a0fc0dea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ 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 -- -D warnings + # - BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release -- -D warnings - BUILD_DUMMY_WASM_BINARY=1 cargo test --release --all - TRIGGER_WASM_BUILD=1 cargo build --release - ls -l ./target/release/wbuild/joystream-node-runtime/ From c430942db7428471fc7b24c75b7d16ea628a3750 Mon Sep 17 00:00:00 2001 From: Mokhtar Naamani Date: Tue, 18 Aug 2020 10:56:53 +0300 Subject: [PATCH 54/56] README: add note about workaround for RLS --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) 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. From b1faa28e492d9d6cac3c40cab2672ef97a01743e Mon Sep 17 00:00:00 2001 From: Mokhtar Naamani Date: Wed, 19 Aug 2020 17:08:32 +0300 Subject: [PATCH 55/56] node: drop sc-service-test based unit tests --- Cargo.lock | 135 ----------------------- node/Cargo.toml | 1 - node/src/chain_spec.rs | 71 ------------ node/src/service.rs | 245 ----------------------------------------- 4 files changed, 452 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4d6c24964..9d8cae3af2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1998,7 +1998,6 @@ dependencies = [ "sc-network", "sc-rpc-api", "sc-service", - "sc-service-test", "sc-transaction-pool", "serde", "serde_json", @@ -5601,43 +5600,6 @@ dependencies = [ "wasm-timer", ] -[[package]] -name = "sc-service-test" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "env_logger", - "fdlimit", - "futures 0.1.29", - "futures 0.3.4", - "hex-literal", - "log", - "parity-scale-codec", - "parking_lot 0.10.2", - "sc-block-builder", - "sc-client-api", - "sc-client-db", - "sc-executor", - "sc-light", - "sc-network", - "sc-service", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-externalities", - "sp-panic-handler", - "sp-runtime", - "sp-state-machine", - "sp-storage", - "sp-transaction-pool", - "sp-trie", - "substrate-test-runtime", - "substrate-test-runtime-client", - "tempfile", - "tokio 0.1.22", -] - [[package]] name = "sc-state-db" version = "0.8.0-rc4" @@ -6203,20 +6165,6 @@ dependencies = [ "wasm-timer", ] -[[package]] -name = "sp-consensus-aura" -version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "parity-scale-codec", - "sp-api", - "sp-application-crypto", - "sp-inherents", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - [[package]] name = "sp-consensus-babe" version = "0.8.0-rc4" @@ -6828,89 +6776,6 @@ dependencies = [ "tokio 0.2.22", ] -[[package]] -name = "substrate-test-client" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "futures 0.3.4", - "hash-db", - "parity-scale-codec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-executor", - "sc-light", - "sc-service", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-keyring", - "sp-runtime", - "sp-state-machine", -] - -[[package]] -name = "substrate-test-runtime" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "cfg-if", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "log", - "memory-db", - "pallet-babe", - "pallet-timestamp", - "parity-scale-codec", - "parity-util-mem", - "sc-service", - "serde", - "sp-api", - "sp-application-crypto", - "sp-block-builder", - "sp-consensus-aura", - "sp-consensus-babe", - "sp-core", - "sp-finality-grandpa", - "sp-inherents", - "sp-io", - "sp-keyring", - "sp-offchain", - "sp-runtime", - "sp-runtime-interface", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-trie", - "sp-version", - "substrate-wasm-builder-runner", - "trie-db", -] - -[[package]] -name = "substrate-test-runtime-client" -version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4" -dependencies = [ - "futures 0.3.4", - "parity-scale-codec", - "sc-block-builder", - "sc-client-api", - "sc-consensus", - "sc-light", - "sc-service", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-runtime", - "substrate-test-client", - "substrate-test-runtime", -] - [[package]] name = "substrate-wasm-builder-runner" version = "1.0.6" diff --git a/node/Cargo.toml b/node/Cargo.toml index 4b76605371..f7ccadb54d 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -78,7 +78,6 @@ 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"]} -sc-service-test = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' } 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' } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 45d6786aed..5b8ea39cd1 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -382,74 +382,3 @@ pub fn testnet_genesis( }), } } - -#[cfg(test)] -pub(crate) mod tests { - use super::*; - use crate::service::{new_full, new_light}; - use sc_service_test; - - fn local_testnet_genesis_instant_single() -> GenesisConfig { - testnet_genesis( - vec![get_authority_keys_from_seed("Alice")], - get_account_id_from_seed::("Alice"), - vec![get_authority_keys_from_seed("Alice").0], - crate::proposals_config::development(), - ) - } - - /// Local testnet config (single validator - Alice) - pub fn integration_test_config_with_single_authority() -> ChainSpec { - ChainSpec::from_genesis( - "Integration Test", - "test", - ChainType::Development, - local_testnet_genesis_instant_single, - vec![], - None, - None, - None, - Default::default(), - ) - } - - fn local_testnet_genesis() -> GenesisConfig { - testnet_genesis( - vec![ - get_authority_keys_from_seed("Alice"), - get_authority_keys_from_seed("Bob"), - ], - get_account_id_from_seed::("Alice"), - vec![ - get_authority_keys_from_seed("Alice").0, - get_authority_keys_from_seed("Bob").0, - ], - crate::proposals_config::development(), - ) - } - - /// Local testnet config (multivalidator Alice + Bob) - pub fn integration_test_config_with_two_authorities() -> ChainSpec { - ChainSpec::from_genesis( - "Integration Test", - "test", - ChainType::Development, - local_testnet_genesis, - vec![], - None, - None, - None, - Default::default(), - ) - } - - #[test] - #[ignore] - fn test_connectivity() { - sc_service_test::connectivity( - integration_test_config_with_two_authorities(), - |config| new_full(config), - |config| new_light(config), - ); - } -} diff --git a/node/src/service.rs b/node/src/service.rs index a1ebae62c5..0aeed1e7a1 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -414,248 +414,3 @@ pub fn new_light(config: Configuration) -> Result::Signer; - - // Long running test. Run it locally only after the node changes. - #[test] - // It is "ignored", but the node-cli ignored tests are running on the CI. - // This can be run locally with `cargo test --release -p node-cli test_sync -- --ignored`. - #[ignore] - fn test_sync() { - let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = - sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore"); - let alice = keystore - .write() - .insert_ephemeral_from_seed::("//Alice") - .expect("Creates authority pair"); - - let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority(); - - // For the block factory - let mut slot_num = 1u64; - - // For the extrinsics factory - let bob = Arc::new(AccountKeyring::Bob.pair()); - let charlie = Arc::new(AccountKeyring::Charlie.pair()); - let mut index = 0; - - sc_service_test::sync( - chain_spec, - |config| { - let mut setup_handles = None; - new_full!( - config, - |block_import: &sc_consensus_babe::BabeBlockImport, - babe_link: &sc_consensus_babe::BabeLink| { - setup_handles = Some((block_import.clone(), babe_link.clone())); - } - ) - .map(move |(node, x)| (node, (x, setup_handles.unwrap()))) - }, - |config| new_light(config), - |service, &mut (ref inherent_data_providers, (ref mut block_import, ref babe_link))| { - let mut inherent_data = inherent_data_providers - .create_inherent_data() - .expect("Creates inherent data."); - inherent_data.replace_data(sp_finality_tracker::INHERENT_IDENTIFIER, &1u64); - - let parent_id = BlockId::number(service.client().chain_info().best_number); - let parent_header = service.client().header(&parent_id).unwrap().unwrap(); - let parent_hash = parent_header.hash(); - let parent_number = *parent_header.number(); - - futures::executor::block_on(service.transaction_pool().maintain( - ChainEvent::NewBlock { - is_new_best: true, - hash: parent_header.hash(), - tree_route: None, - header: parent_header.clone(), - }, - )); - - let mut proposer_factory = sc_basic_authorship::ProposerFactory::new( - service.client(), - service.transaction_pool(), - None, - ); - - let epoch_descriptor = babe_link - .epoch_changes() - .lock() - .epoch_descriptor_for_child_of( - descendent_query(&*service.client()), - &parent_hash, - parent_number, - slot_num, - ) - .unwrap() - .unwrap(); - - let mut digest = Digest::::default(); - - // even though there's only one authority some slots might be empty, - // so we must keep trying the next slots until we can claim one. - let babe_pre_digest = loop { - inherent_data.replace_data( - sp_timestamp::INHERENT_IDENTIFIER, - &(slot_num * SLOT_DURATION), - ); - if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot( - slot_num, - &parent_header, - &*service.client(), - &keystore, - &babe_link, - ) { - break babe_pre_digest; - } - - slot_num += 1; - }; - - digest.push(::babe_pre_digest( - babe_pre_digest, - )); - - let new_block = futures::executor::block_on(async move { - let proposer = proposer_factory.init(&parent_header).await; - proposer - .unwrap() - .propose( - inherent_data, - digest, - std::time::Duration::from_secs(1), - RecordProof::Yes, - ) - .await - }) - .expect("Error making test block") - .block; - - let (new_header, new_body) = new_block.deconstruct(); - let pre_hash = new_header.hash(); - // sign the pre-sealed hash of the block and then - // add it to a digest item. - let to_sign = pre_hash.encode(); - let signature = alice.sign(&to_sign[..]); - let item = ::babe_seal(signature.into()); - slot_num += 1; - - let mut params = BlockImportParams::new(BlockOrigin::File, new_header); - params.post_digests.push(item); - params.body = Some(new_body); - params.intermediates.insert( - Cow::from(INTERMEDIATE_KEY), - Box::new(BabeIntermediate:: { epoch_descriptor }) as Box, - ); - params.fork_choice = Some(ForkChoiceStrategy::LongestChain); - - block_import - .import_block(params, Default::default()) - .expect("error importing test block"); - }, - |service, _| { - let amount = 5 * CENTS; - let to: AccountId = AccountPublic::from(bob.public()).into_account().into(); - let from: AccountId = AccountPublic::from(charlie.public()).into_account().into(); - let genesis_hash = service.client().block_hash(0).unwrap().unwrap(); - let best_block_id = BlockId::number(service.client().chain_info().best_number); - let (spec_version, transaction_version) = { - let version = service.client().runtime_version_at(&best_block_id).unwrap(); - (version.spec_version, version.transaction_version) - }; - let signer = charlie.clone(); - - let function = Call::Balances(BalancesCall::transfer(to.into(), amount)); - - let check_spec_version = frame_system::CheckSpecVersion::new(); - let check_tx_version = frame_system::CheckTxVersion::new(); - let check_genesis = frame_system::CheckGenesis::new(); - let check_era = frame_system::CheckEra::from(Era::Immortal); - let check_nonce = frame_system::CheckNonce::from(index); - let check_weight = frame_system::CheckWeight::new(); - let payment = pallet_transaction_payment::ChargeTransactionPayment::from(0); - let validate_grandpa_equivocation = - pallet_grandpa::ValidateEquivocationReport::new(); - let extra = ( - check_spec_version, - check_tx_version, - check_genesis, - check_era, - check_nonce, - check_weight, - payment, - validate_grandpa_equivocation, - ); - let raw_payload = SignedPayload::from_raw( - function, - extra, - ( - spec_version, - transaction_version, - genesis_hash, - genesis_hash, - (), - (), - (), - (), - ), - ); - let signature = raw_payload.using_encoded(|payload| signer.sign(payload)); - let (function, extra, _) = raw_payload.deconstruct(); - let xt = - UncheckedExtrinsic::new_signed(function, from.into(), signature.into(), extra) - .encode(); - let v: Vec = Decode::decode(&mut xt.as_slice()).unwrap(); - - index += 1; - OpaqueExtrinsic(v) - }, - ); - } - - #[test] - #[ignore] - fn test_consensus() { - sc_service_test::consensus( - crate::chain_spec::tests::integration_test_config_with_two_authorities(), - |config| new_full(config), - |config| new_light(config), - vec!["//Alice".into(), "//Bob".into()], - ) - } -} From 8563990c591b3b5ca11dfd47f6d2bbd1bad25e0c Mon Sep 17 00:00:00 2001 From: Mokhtar Naamani Date: Wed, 19 Aug 2020 17:09:12 +0300 Subject: [PATCH 56/56] travis: re-enable clippy, run joystream-node to test build --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00a0fc0dea..fb8c6a5ad3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,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 -- -D warnings - - BUILD_DUMMY_WASM_BINARY=1 cargo test --release --all + - 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