diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock
index e6c1b6e4b7..e068b00d7c 100644
--- a/substrate/Cargo.lock
+++ b/substrate/Cargo.lock
@@ -4547,6 +4547,27 @@ dependencies = [
"substrate-test-utils",
]
+[[package]]
+name = "pallet-staking-fuzz"
+version = "0.0.0"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "honggfuzz",
+ "pallet-balances",
+ "pallet-indices",
+ "pallet-session",
+ "pallet-staking",
+ "pallet-staking-reward-curve",
+ "pallet-timestamp",
+ "parity-scale-codec",
+ "sp-core",
+ "sp-io",
+ "sp-phragmen",
+ "sp-runtime",
+ "sp-std",
+]
+
[[package]]
name = "pallet-staking-reward-curve"
version = "2.0.0-dev"
diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml
index abb0cca39c..5c410befbb 100644
--- a/substrate/Cargo.toml
+++ b/substrate/Cargo.toml
@@ -95,6 +95,7 @@ members = [
"frame/society",
"frame/staking",
"frame/staking/reward-curve",
+ "frame/staking/fuzzer",
"frame/sudo",
"frame/support",
"frame/support/procedural",
diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs
index 4ec0fa275b..98507abf5d 100644
--- a/substrate/bin/node/runtime/src/lib.rs
+++ b/substrate/bin/node/runtime/src/lib.rs
@@ -300,8 +300,9 @@ parameter_types! {
pub const BondingDuration: pallet_staking::EraIndex = 24 * 28;
pub const SlashDeferDuration: pallet_staking::EraIndex = 24 * 7; // 1/4 the bonding duration.
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
- pub const ElectionLookahead: BlockNumber = 25; // 10 minutes per session => 100 block.
+ pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
+ pub const MaxIterations: u32 = 5;
}
impl pallet_staking::Trait for Runtime {
@@ -322,6 +323,7 @@ impl pallet_staking::Trait for Runtime {
type NextNewSession = Session;
type ElectionLookahead = ElectionLookahead;
type Call = Call;
+ type MaxIterations = MaxIterations;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type UnsignedPriority = StakingUnsignedPriority;
}
diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs
index f0d0a095ae..d488fe4eac 100644
--- a/substrate/frame/session/benchmarking/src/mock.rs
+++ b/substrate/frame/session/benchmarking/src/mock.rs
@@ -180,6 +180,7 @@ impl pallet_staking::Trait for Test {
type Call = Call;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type UnsignedPriority = UnsignedPriority;
+ type MaxIterations = ();
}
impl crate::Trait for Test {}
diff --git a/substrate/frame/staking/fuzz/.gitignore b/substrate/frame/staking/fuzz/.gitignore
deleted file mode 100644
index 572e03bdf3..0000000000
--- a/substrate/frame/staking/fuzz/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-
-target
-corpus
-artifacts
diff --git a/substrate/frame/staking/fuzz/Cargo.toml b/substrate/frame/staking/fuzz/Cargo.toml
deleted file mode 100644
index a78fbf17dc..0000000000
--- a/substrate/frame/staking/fuzz/Cargo.toml
+++ /dev/null
@@ -1,38 +0,0 @@
-[package]
-name = "pallet-staking-fuzz"
-version = "0.0.0"
-authors = ["Automatically generated"]
-publish = false
-edition = "2018"
-
-[package.metadata]
-cargo-fuzz = true
-
-[dependencies]
-libfuzzer-sys = "0.3"
-codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
-pallet-staking = { version = "2.0.0-alpha.2", path = "..", features = ["testing-utils"] }
-pallet-staking-reward-curve = { version = "2.0.0-alpha.2", path = "../reward-curve" }
-pallet-session = { version = "2.0.0-alpha.2", path = "../../session" }
-pallet-indices = { version = "2.0.0-alpha.2", path = "../../indices" }
-pallet-balances = { version = "2.0.0-alpha.2", path = "../../balances" }
-pallet-timestamp = { version = "2.0.0-alpha.2", path = "../../timestamp" }
-frame-system = { version = "2.0.0-alpha.2", path = "../../system" }
-frame-support = { version = "2.0.0-alpha.2", path = "../../support" }
-sp-std = { version = "2.0.0-alpha.2", path = "../../../primitives/std" }
-sp-io ={ version = "2.0.0-alpha.2", path = "../../../primitives/io" }
-sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" }
-sp-phragmen = { version = "2.0.0-alpha.2", path = "../../../primitives/phragmen" }
-sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" }
-rand = "0.7.3"
-
-# Prevent this from interfering with workspaces
-[workspace]
-members = ["."]
-
-[[bin]]
-name = "submit_solution"
-path = "fuzz_targets/submit_solution.rs"
-
-[package.metadata.docs.rs]
-targets = ["x86_64-unknown-linux-gnu"]
diff --git a/substrate/frame/staking/fuzz/fuzz_targets/submit_solution.rs b/substrate/frame/staking/fuzz/fuzz_targets/submit_solution.rs
deleted file mode 100644
index 5d1fcf1d7e..0000000000
--- a/substrate/frame/staking/fuzz/fuzz_targets/submit_solution.rs
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
-// This file is part of Substrate.
-
-// Substrate 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.
-
-// Substrate 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 Substrate. If not, see .
-
-//! Fuzzing for staking pallet.
-
-#![no_main]
-use libfuzzer_sys::fuzz_target;
-use mock::Test;
-use pallet_staking::testing_utils::{
- self, USER, get_seq_phragmen_solution, get_weak_solution, setup_chain_stakers,
- set_validator_count, signed_account,
-};
-use frame_support::assert_ok;
-use sp_runtime::{traits::Dispatchable, DispatchError};
-
-mod mock;
-
-#[repr(u32)]
-#[allow(dead_code)]
-#[derive(Debug, Clone, Copy)]
-enum Mode {
- /// Initial submission. This will be rather cheap.
- InitialSubmission,
- /// A better submission that will replace the previous ones. This is the most expensive.
- StrongerSubmission,
- /// A weak submission that will be rejected. This will be rather cheap.
- WeakerSubmission,
-}
-
-pub fn new_test_ext() -> Result {
- frame_system::GenesisConfig::default().build_storage::().map(Into::into)
-}
-
-fuzz_target!(|do_reduce: bool| {
- let ext = new_test_ext();
- let mode: Mode = unsafe { std::mem::transmute(testing_utils::random(0, 2)) };
- let num_validators = testing_utils::random(50, 500);
- let num_nominators = testing_utils::random(200, 2000);
- let edge_per_voter = testing_utils::random(1, 16);
- let to_elect = testing_utils::random(10, num_validators);
-
- println!("+++ instance with params {} / {} / {} / {:?} / {}",
- num_nominators,
- num_validators,
- edge_per_voter,
- mode,
- to_elect,
- );
-
- ext.unwrap_or_default().execute_with(|| {
- // initial setup
- set_validator_count::(to_elect);
- setup_chain_stakers::(
- num_validators,
- num_nominators,
- edge_per_voter,
- );
-
- println!("++ Chain setup done.");
-
- // stuff to submit
- let (winners, compact, score) = match mode {
- Mode::InitialSubmission => {
- /* No need to setup anything */
- get_seq_phragmen_solution::(do_reduce)
- },
- Mode::StrongerSubmission => {
- let (winners, compact, score) = get_weak_solution::(false);
- assert_ok!(
- >::submit_election_solution(
- signed_account::(USER),
- winners,
- compact,
- score,
- )
- );
- get_seq_phragmen_solution::(do_reduce)
- },
- Mode::WeakerSubmission => {
- let (winners, compact, score) = get_seq_phragmen_solution::(do_reduce);
- assert_ok!(
- >::submit_election_solution(
- signed_account::(USER),
- winners,
- compact,
- score,
- )
- );
- get_weak_solution::(false)
- }
- };
-
- println!("++ Submission ready.");
-
- // must have chosen correct number of winners.
- assert_eq!(winners.len() as u32, >::validator_count());
-
- // final call and origin
- let call = pallet_staking::Call::::submit_election_solution(
- winners,
- compact,
- score,
- );
- let caller = signed_account::(USER);
-
- // actually submit
- match mode {
- Mode::WeakerSubmission => {
- assert_eq!(
- call.dispatch(caller.into()).unwrap_err(),
- DispatchError::Module { index: 0, error: 11, message: Some("PhragmenWeakSubmission") },
- );
- },
- _ => assert_ok!(call.dispatch(caller.into())),
- };
- })
-});
diff --git a/substrate/frame/staking/fuzzer/.gitignore b/substrate/frame/staking/fuzzer/.gitignore
new file mode 100644
index 0000000000..3ebcb104d4
--- /dev/null
+++ b/substrate/frame/staking/fuzzer/.gitignore
@@ -0,0 +1,2 @@
+hfuzz_target
+hfuzz_workspace
diff --git a/substrate/frame/staking/fuzz/Cargo.lock b/substrate/frame/staking/fuzzer/Cargo.lock
similarity index 85%
rename from substrate/frame/staking/fuzz/Cargo.lock
rename to substrate/frame/staking/fuzzer/Cargo.lock
index f6e8cfa08d..a45f33fdce 100644
--- a/substrate/frame/staking/fuzz/Cargo.lock
+++ b/substrate/frame/staking/fuzzer/Cargo.lock
@@ -29,10 +29,30 @@ dependencies = [
]
[[package]]
-name = "arbitrary"
-version = "0.4.0"
+name = "alga"
+version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16971f2f0ce65c5cf2a1546cc6a0af102ecb11e265ddaa9433fb3e5bfdf676a4"
+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 = "arbitrary"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75153c95fdedd7db9732dfbfc3702324a1627eec91ba56e37cd0ac78314ab2ed"
[[package]]
name = "arrayref"
@@ -69,9 +89,9 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "backtrace"
-version = "0.3.45"
+version = "0.3.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad235dabf00f36301792cfe82499880ba54c6486be094d1047b02bacb67c14e8"
+checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e"
dependencies = [
"backtrace-sys",
"cfg-if",
@@ -81,9 +101,9 @@ dependencies = [
[[package]]
name = "backtrace-sys"
-version = "0.1.33"
+version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e17b52e737c40a7d75abca20b29a19a0eb7ba9fc72c5a72dd282a0a3c2c0dc35"
+checksum = "7de8aba10a69c8e8d7622c5710229485ec32e9d55fdad160ea559c086fdcd118"
dependencies = [
"cc",
"libc",
@@ -109,9 +129,13 @@ checksum = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead"
[[package]]
name = "bitvec"
-version = "0.15.2"
+version = "0.17.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6"
+checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c"
+dependencies = [
+ "either",
+ "radium",
+]
[[package]]
name = "blake2-rfc"
@@ -146,9 +170,9 @@ dependencies = [
[[package]]
name = "bumpalo"
-version = "3.2.0"
+version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742"
+checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187"
[[package]]
name = "byte-slice-cast"
@@ -168,15 +192,6 @@ version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
-[[package]]
-name = "c2-chacha"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
-dependencies = [
- "ppv-lite86",
-]
-
[[package]]
name = "cc"
version = "1.0.50"
@@ -249,19 +264,6 @@ dependencies = [
"subtle 1.0.0",
]
-[[package]]
-name = "curve25519-dalek"
-version = "1.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d"
-dependencies = [
- "byteorder",
- "clear_on_drop",
- "digest",
- "rand_core 0.3.1",
- "subtle 2.2.2",
-]
-
[[package]]
name = "curve25519-dalek"
version = "2.0.0"
@@ -272,14 +274,14 @@ dependencies = [
"digest",
"rand_core 0.5.1",
"subtle 2.2.2",
- "zeroize 1.1.0",
+ "zeroize",
]
[[package]]
name = "derive_more"
-version = "0.99.3"
+version = "0.99.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a806e96c59a76a5ba6e18735b6cf833344671e61e7863f2edb5c518ea2cac95c"
+checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7"
dependencies = [
"proc-macro2",
"quote",
@@ -302,11 +304,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2"
dependencies = [
"clear_on_drop",
- "curve25519-dalek 2.0.0",
+ "curve25519-dalek",
"rand 0.7.3",
"sha2",
]
+[[package]]
+name = "either"
+version = "1.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
+
[[package]]
name = "environmental"
version = "1.1.1"
@@ -343,12 +351,11 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "fixed-hash"
-version = "0.5.2"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3367952ceb191f4ab95dd5685dc163ac539e36202f9fcfd0cb22f9f9c542fefc"
+checksum = "32529fc42e86ec06e5047092082aab9ad459b070c5d2a76b14f4f5ce70bf2e84"
dependencies = [
"byteorder",
- "libc",
"rand 0.7.3",
"rustc-hex",
"static_assertions",
@@ -356,10 +363,11 @@ dependencies = [
[[package]]
name = "frame-benchmarking"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-support",
"frame-system",
+ "linregress",
"parity-scale-codec",
"sp-api",
"sp-io",
@@ -370,7 +378,7 @@ dependencies = [
[[package]]
name = "frame-metadata"
-version = "11.0.0-alpha.3"
+version = "11.0.0-alpha.5"
dependencies = [
"parity-scale-codec",
"serde",
@@ -380,7 +388,7 @@ dependencies = [
[[package]]
name = "frame-support"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"bitmask",
"frame-metadata",
@@ -403,7 +411,7 @@ dependencies = [
[[package]]
name = "frame-support-procedural"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-support-procedural-tools",
"proc-macro2",
@@ -413,7 +421,7 @@ dependencies = [
[[package]]
name = "frame-support-procedural-tools"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-support-procedural-tools-derive",
"proc-macro-crate",
@@ -424,7 +432,7 @@ dependencies = [
[[package]]
name = "frame-support-procedural-tools-derive"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"proc-macro2",
"quote",
@@ -433,7 +441,7 @@ dependencies = [
[[package]]
name = "frame-system"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-support",
"impl-trait-for-tuples",
@@ -492,6 +500,7 @@ dependencies = [
"futures-core",
"futures-task",
"futures-util",
+ "num_cpus",
]
[[package]]
@@ -597,6 +606,15 @@ dependencies = [
"unicode-segmentation",
]
+[[package]]
+name = "hermit-abi"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "hex"
version = "0.4.2"
@@ -670,9 +688,9 @@ checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b"
[[package]]
name = "js-sys"
-version = "0.3.36"
+version = "0.3.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1cb931d43e71f560c81badb0191596562bafad2be06a3f9025b845c847c60df5"
+checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055"
dependencies = [
"wasm-bindgen",
]
@@ -691,20 +709,26 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.67"
+version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
+checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
[[package]]
name = "libfuzzer-sys"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb789afcc589a08928d1e466087445ab740a0f70a2ee23d9349a0e3723d65e1b"
+checksum = "8d718794b8e23533b9069bd2c4597d69e41cc7ab1c02700a502971aca0cdcf24"
dependencies = [
"arbitrary",
"cc",
]
+[[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"
@@ -721,6 +745,17 @@ dependencies = [
"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"
@@ -739,6 +774,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"
@@ -753,9 +797,9 @@ checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]]
name = "memory-db"
-version = "0.19.0"
+version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "198831fe8722331a395bc199a5d08efbc197497ef354cb4c77b969c02ffc0fc4"
+checksum = "f58381b20ebe2c578e75dececd9da411414903415349548ccc46aac3209cdfbc"
dependencies = [
"ahash",
"hash-db",
@@ -771,14 +815,31 @@ checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882"
[[package]]
name = "merlin"
-version = "1.3.0"
+version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e"
+checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78"
dependencies = [
"byteorder",
"keccak",
- "rand_core 0.4.2",
- "zeroize 1.1.0",
+ "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]]
@@ -798,6 +859,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"
@@ -810,9 +881,9 @@ dependencies = [
[[package]]
name = "num-rational"
-version = "0.2.3"
+version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da4dc79f9e6c81bef96148c8f6b8e72ad4541caa4a24373e900a36da07de03a3"
+checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
dependencies = [
"autocfg 1.0.0",
"num-bigint",
@@ -827,6 +898,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
dependencies = [
"autocfg 1.0.0",
+ "libm",
+]
+
+[[package]]
+name = "num_cpus"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
+dependencies = [
+ "hermit-abi",
+ "libc",
]
[[package]]
@@ -846,7 +928,7 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "pallet-authorship"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-support",
"frame-system",
@@ -862,7 +944,7 @@ dependencies = [
[[package]]
name = "pallet-balances"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -876,7 +958,7 @@ dependencies = [
[[package]]
name = "pallet-indices"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-support",
"frame-system",
@@ -891,7 +973,7 @@ dependencies = [
[[package]]
name = "pallet-session"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-support",
"frame-system",
@@ -908,7 +990,7 @@ dependencies = [
[[package]]
name = "pallet-staking"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-support",
"frame-system",
@@ -952,7 +1034,7 @@ dependencies = [
[[package]]
name = "pallet-staking-reward-curve"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -962,7 +1044,7 @@ dependencies = [
[[package]]
name = "pallet-timestamp"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -980,7 +1062,7 @@ dependencies = [
name = "parity-scale-codec"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f509c5e67ca0605ee17dcd3f91ef41cadd685c75a298fb6261b781a5acb3f910"
+checksum = "329c8f7f4244ddb5c37c103641027a76c530e65e8e4b8240b29f81ea40508b17"
dependencies = [
"arrayvec 0.5.1",
"bitvec",
@@ -991,7 +1073,7 @@ dependencies = [
[[package]]
name = "parity-scale-codec-derive"
-version = "1.3.0"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a0ec292e92e8ec7c58e576adacc1e3f399c597c8f263c42f18420abe58e7245"
dependencies = [
@@ -1003,9 +1085,9 @@ dependencies = [
[[package]]
name = "parity-util-mem"
-version = "0.5.1"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef1476e40bf8f5c6776e9600983435821ca86eb9819d74a6207cca69d091406a"
+checksum = "6e42755f26e5ea21a6a819d9e63cbd70713e9867a2b767ec2cc65ca7659532c5"
dependencies = [
"cfg-if",
"impl-trait-for-tuples",
@@ -1078,15 +1160,15 @@ dependencies = [
"cloudabi",
"libc",
"redox_syscall",
- "smallvec 1.3.0",
+ "smallvec 1.2.0",
"winapi",
]
[[package]]
name = "paste"
-version = "0.1.7"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "63e1afe738d71b1ebab5f1207c055054015427dbfc7bbe9ee1266894156ec046"
+checksum = "092d791bf7847f70bbd49085489fba25fc2c193571752bff9e36e74e72403932"
dependencies = [
"paste-impl",
"proc-macro-hack",
@@ -1094,9 +1176,9 @@ dependencies = [
[[package]]
name = "paste-impl"
-version = "0.1.7"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d4dc4a7f6f743211c5aab239640a65091535d97d43d92a52bca435a640892bb"
+checksum = "406c23fb4c45cc6f68a9bbabb8ec7bd6f8cfcbd17e9e8f72c2460282f8325729"
dependencies = [
"proc-macro-hack",
"proc-macro2",
@@ -1128,9 +1210,9 @@ checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
[[package]]
name = "primitive-types"
-version = "0.6.2"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e4336f4f5d5524fa60bcbd6fe626f9223d8142a50e7053e979acdf0da41ab975"
+checksum = "e5e4b9943a2da369aec5e96f7c10ebc74fcf434d39590d974b0a3460e6f67fbb"
dependencies = [
"fixed-hash",
"impl-codec",
@@ -1149,26 +1231,21 @@ dependencies = [
[[package]]
name = "proc-macro-hack"
-version = "0.5.11"
+version = "0.5.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
+checksum = "fcfdefadc3d57ca21cf17990a28ef4c0f7c61383a28cb7604cf4a18e6ede1420"
[[package]]
name = "proc-macro-nested"
-version = "0.1.3"
+version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e"
+checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694"
[[package]]
name = "proc-macro2"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
+checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
dependencies = [
"unicode-xid",
]
@@ -1182,6 +1259,25 @@ dependencies = [
"proc-macro2",
]
+[[package]]
+name = "radium"
+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"
@@ -1209,7 +1305,7 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom",
"libc",
- "rand_chacha 0.2.1",
+ "rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc 0.2.0",
]
@@ -1226,11 +1322,11 @@ dependencies = [
[[package]]
name = "rand_chacha"
-version = "0.2.1"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853"
+checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
- "c2-chacha",
+ "ppv-lite86",
"rand_core 0.5.1",
]
@@ -1329,6 +1425,12 @@ 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"
@@ -1346,9 +1448,9 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]]
name = "regex"
-version = "1.3.4"
+version = "1.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8"
+checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3"
dependencies = [
"aho-corasick",
"memchr",
@@ -1358,9 +1460,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.16"
+version = "0.6.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1132f845907680735a84409c3bebc64d1364a5683ffbce899550cd09d5eaefc1"
+checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae"
[[package]]
name = "rustc-demangle"
@@ -1391,19 +1493,20 @@ dependencies = [
[[package]]
name = "schnorrkel"
-version = "0.8.5"
+version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3"
+checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862"
dependencies = [
- "curve25519-dalek 1.2.3",
- "failure",
+ "arrayref",
+ "arrayvec 0.5.1",
+ "curve25519-dalek",
+ "getrandom",
"merlin",
- "rand 0.6.5",
- "rand_core 0.4.2",
- "rand_os",
+ "rand 0.7.3",
+ "rand_core 0.5.1",
"sha2",
"subtle 2.2.2",
- "zeroize 0.9.3",
+ "zeroize",
]
[[package]]
@@ -1435,18 +1538,18 @@ checksum = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4"
[[package]]
name = "serde"
-version = "1.0.104"
+version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
+checksum = "e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.104"
+version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
+checksum = "ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8"
dependencies = [
"proc-macro2",
"quote",
@@ -1482,13 +1585,13 @@ dependencies = [
[[package]]
name = "smallvec"
-version = "1.3.0"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
[[package]]
name = "sp-api"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"hash-db",
"parity-scale-codec",
@@ -1502,7 +1605,7 @@ dependencies = [
[[package]]
name = "sp-api-proc-macro"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"blake2-rfc",
"proc-macro-crate",
@@ -1513,7 +1616,7 @@ dependencies = [
[[package]]
name = "sp-application-crypto"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"parity-scale-codec",
"serde",
@@ -1524,7 +1627,7 @@ dependencies = [
[[package]]
name = "sp-arithmetic"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"integer-sqrt",
"num-traits",
@@ -1536,7 +1639,7 @@ dependencies = [
[[package]]
name = "sp-authorship"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"parity-scale-codec",
"sp-inherents",
@@ -1546,12 +1649,13 @@ dependencies = [
[[package]]
name = "sp-core"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"base58",
"blake2-rfc",
"byteorder",
"ed25519-dalek",
+ "futures",
"hash-db",
"hash256-std-hasher",
"hex",
@@ -1566,7 +1670,6 @@ dependencies = [
"primitive-types",
"rand 0.7.3",
"regex",
- "rustc-hex",
"schnorrkel",
"serde",
"sha2",
@@ -1580,12 +1683,12 @@ dependencies = [
"tiny-keccak",
"twox-hash",
"wasmi",
- "zeroize 1.1.0",
+ "zeroize",
]
[[package]]
name = "sp-debug-derive"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"proc-macro2",
"quote",
@@ -1594,7 +1697,7 @@ dependencies = [
[[package]]
name = "sp-externalities"
-version = "0.8.0-alpha.3"
+version = "0.8.0-alpha.5"
dependencies = [
"environmental",
"sp-std",
@@ -1603,7 +1706,7 @@ dependencies = [
[[package]]
name = "sp-inherents"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"derive_more",
"parity-scale-codec",
@@ -1614,7 +1717,7 @@ dependencies = [
[[package]]
name = "sp-io"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"hash-db",
"libsecp256k1",
@@ -1631,7 +1734,7 @@ dependencies = [
[[package]]
name = "sp-keyring"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"lazy_static",
"sp-core",
@@ -1641,7 +1744,7 @@ dependencies = [
[[package]]
name = "sp-panic-handler"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"backtrace",
"log",
@@ -1649,11 +1752,10 @@ dependencies = [
[[package]]
name = "sp-phragmen"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"parity-scale-codec",
"serde",
- "sp-core",
"sp-phragmen-compact",
"sp-runtime",
"sp-std",
@@ -1671,7 +1773,7 @@ dependencies = [
[[package]]
name = "sp-runtime"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"hash256-std-hasher",
"impl-trait-for-tuples",
@@ -1691,7 +1793,7 @@ dependencies = [
[[package]]
name = "sp-runtime-interface"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"parity-scale-codec",
"primitive-types",
@@ -1704,7 +1806,7 @@ dependencies = [
[[package]]
name = "sp-runtime-interface-proc-macro"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"Inflector",
"proc-macro-crate",
@@ -1715,7 +1817,7 @@ dependencies = [
[[package]]
name = "sp-staking"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"parity-scale-codec",
"sp-runtime",
@@ -1724,7 +1826,7 @@ dependencies = [
[[package]]
name = "sp-state-machine"
-version = "0.8.0-alpha.3"
+version = "0.8.0-alpha.5"
dependencies = [
"hash-db",
"log",
@@ -1742,11 +1844,11 @@ dependencies = [
[[package]]
name = "sp-std"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
[[package]]
name = "sp-storage"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"impl-serde 0.2.3",
"serde",
@@ -1756,7 +1858,7 @@ dependencies = [
[[package]]
name = "sp-timestamp"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"impl-trait-for-tuples",
"parity-scale-codec",
@@ -1769,7 +1871,7 @@ dependencies = [
[[package]]
name = "sp-trie"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"hash-db",
"memory-db",
@@ -1782,7 +1884,7 @@ dependencies = [
[[package]]
name = "sp-version"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"impl-serde 0.2.3",
"parity-scale-codec",
@@ -1793,7 +1895,7 @@ dependencies = [
[[package]]
name = "sp-wasm-interface"
-version = "2.0.0-alpha.3"
+version = "2.0.0-alpha.5"
dependencies = [
"impl-trait-for-tuples",
"parity-scale-codec",
@@ -1807,6 +1909,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 = "strum"
version = "0.16.0"
@@ -1830,9 +1941,9 @@ dependencies = [
[[package]]
name = "substrate-bip39"
-version = "0.3.1"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5"
+checksum = "c004e8166d6e0aa3a9d5fa673e5b7098ff25f930de1013a21341988151e681bb"
dependencies = [
"hmac",
"pbkdf2",
@@ -1854,9 +1965,9 @@ checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941"
[[package]]
name = "syn"
-version = "1.0.16"
+version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859"
+checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
dependencies = [
"proc-macro2",
"quote",
@@ -1886,9 +1997,9 @@ dependencies = [
[[package]]
name = "tiny-bip39"
-version = "0.7.1"
+version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a6848cd8f566953ce1e8faeba12ee23cbdbb0437754792cd857d44628b5685e3"
+checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2"
dependencies = [
"failure",
"hmac",
@@ -1958,7 +2069,7 @@ dependencies = [
"hashbrown",
"log",
"rustc-hex",
- "smallvec 1.3.0",
+ "smallvec 1.2.0",
]
[[package]]
@@ -2003,7 +2114,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4"
dependencies = [
- "smallvec 1.3.0",
+ "smallvec 1.2.0",
]
[[package]]
@@ -2026,9 +2137,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasm-bindgen"
-version = "0.2.59"
+version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3557c397ab5a8e347d434782bcd31fc1483d927a6826804cec05cc792ee2519d"
+checksum = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@@ -2036,9 +2147,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
-version = "0.2.59"
+version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0da9c9a19850d3af6df1cb9574970b566d617ecfaf36eb0b706b6f3ef9bd2f8"
+checksum = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd"
dependencies = [
"bumpalo",
"lazy_static",
@@ -2051,9 +2162,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
-version = "0.4.9"
+version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "457414a91863c0ec00090dba537f88ab955d93ca6555862c29b6d860990b8a8a"
+checksum = "7add542ea1ac7fdaa9dc25e031a6af33b7d63376292bd24140c637d00d1c312a"
dependencies = [
"cfg-if",
"js-sys",
@@ -2063,9 +2174,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.59"
+version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f6fde1d36e75a714b5fe0cffbb78978f222ea6baebb726af13c78869fdb4205"
+checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -2073,9 +2184,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.59"
+version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25bda4168030a6412ea8a047e27238cadf56f0e53516e1e83fec0a8b7c786f6d"
+checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931"
dependencies = [
"proc-macro2",
"quote",
@@ -2086,9 +2197,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.59"
+version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8"
+checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639"
[[package]]
name = "wasm-timer"
@@ -2131,9 +2242,9 @@ dependencies = [
[[package]]
name = "web-sys"
-version = "0.3.36"
+version = "0.3.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "721c6263e2c66fd44501cc5efbfa2b7dfa775d13e4ea38c46299646ed1f9c70a"
+checksum = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -2161,12 +2272,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-[[package]]
-name = "zeroize"
-version = "0.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86"
-
[[package]]
name = "zeroize"
version = "1.1.0"
diff --git a/substrate/frame/staking/fuzzer/Cargo.toml b/substrate/frame/staking/fuzzer/Cargo.toml
new file mode 100644
index 0000000000..34e956a367
--- /dev/null
+++ b/substrate/frame/staking/fuzzer/Cargo.toml
@@ -0,0 +1,34 @@
+[package]
+name = "pallet-staking-fuzz"
+version = "0.0.0"
+authors = ["Automatically generated"]
+publish = false
+edition = "2018"
+license = "GPL-3.0"
+homepage = "https://substrate.dev"
+repository = "https://github.com/paritytech/substrate/"
+description = "FRAME pallet staking fuzzing"
+
+[dependencies]
+honggfuzz = "0.5"
+codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
+pallet-staking = { version = "2.0.0-alpha.5", path = "..", features = ["testing-utils"] }
+pallet-staking-reward-curve = { version = "2.0.0-alpha.5", path = "../reward-curve" }
+pallet-session = { version = "2.0.0-alpha.5", path = "../../session" }
+pallet-indices = { version = "2.0.0-alpha.5", path = "../../indices" }
+pallet-balances = { version = "2.0.0-alpha.5", path = "../../balances" }
+pallet-timestamp = { version = "2.0.0-alpha.5", path = "../../timestamp" }
+frame-system = { version = "2.0.0-alpha.5", path = "../../system" }
+frame-support = { version = "2.0.0-alpha.5", path = "../../support" }
+sp-std = { version = "2.0.0-alpha.5", path = "../../../primitives/std" }
+sp-io ={ version = "2.0.0-alpha.5", path = "../../../primitives/io" }
+sp-core = { version = "2.0.0-alpha.5", path = "../../../primitives/core" }
+sp-phragmen = { version = "2.0.0-alpha.5", path = "../../../primitives/phragmen" }
+sp-runtime = { version = "2.0.0-alpha.5", path = "../../../primitives/runtime" }
+
+[[bin]]
+name = "submit_solution"
+path = "src/submit_solution.rs"
+
+[package.metadata.docs.rs]
+targets = ["x86_64-unknown-linux-gnu"]
diff --git a/substrate/frame/staking/fuzz/fuzz_targets/mock.rs b/substrate/frame/staking/fuzzer/src/mock.rs
similarity index 88%
rename from substrate/frame/staking/fuzz/fuzz_targets/mock.rs
rename to substrate/frame/staking/fuzzer/src/mock.rs
index 4bb3437f92..1819970e60 100644
--- a/substrate/frame/staking/fuzz/fuzz_targets/mock.rs
+++ b/substrate/frame/staking/fuzzer/src/mock.rs
@@ -24,11 +24,11 @@ type AccountIndex = u32;
type BlockNumber = u64;
type Balance = u64;
-type System = frame_system::Module;
-type Balances = pallet_balances::Module;
-type Staking = pallet_staking::Module;
-type Indices = pallet_indices::Module;
-type Session = pallet_session::Module;
+pub type System = frame_system::Module;
+pub type Balances = pallet_balances::Module;
+pub type Staking = pallet_staking::Module;
+pub type Indices = pallet_indices::Module;
+pub type Session = pallet_session::Module;
impl_outer_origin! {
pub enum Origin for Test where system = frame_system {}
@@ -57,6 +57,9 @@ pub struct Test;
impl frame_system::Trait for Test {
type Origin = Origin;
+ type DbWeight = ();
+ type BlockExecutionWeight = ();
+ type ExtrinsicBaseWeight = ();
type Index = AccountIndex;
type BlockNumber = BlockNumber;
type Call = Call;
@@ -150,18 +153,21 @@ pallet_staking_reward_curve::build! {
parameter_types! {
pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
+ pub const MaxIterations: u32 = 20;
}
pub type Extrinsic = sp_runtime::testing::TestXt;
-type SubmitTransaction = frame_system::offchain::TransactionSubmitter<
- sp_runtime::testing::UintAuthorityId,
- Test,
- Extrinsic,
->;
+
+impl frame_system::offchain::SendTransactionTypes for Test where
+ Call: From,
+{
+ type OverarchingCall = Call;
+ type Extrinsic = Extrinsic;
+}
impl pallet_staking::Trait for Test {
type Currency = Balances;
- type Time = pallet_timestamp::Module;
+ type UnixTime = pallet_timestamp::Module;
type CurrencyToVote = CurrencyToVoteHandler;
type RewardRemainder = ();
type Event = ();
@@ -176,7 +182,7 @@ impl pallet_staking::Trait for Test {
type NextNewSession = Session;
type ElectionLookahead = ();
type Call = Call;
- type SubmitTransaction = SubmitTransaction;
- type KeyType = sp_runtime::testing::UintAuthorityId;
+ type MaxIterations = MaxIterations;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
+ type UnsignedPriority = ();
}
diff --git a/substrate/frame/staking/fuzzer/src/submit_solution.rs b/substrate/frame/staking/fuzzer/src/submit_solution.rs
new file mode 100644
index 0000000000..90d8fc56ef
--- /dev/null
+++ b/substrate/frame/staking/fuzzer/src/submit_solution.rs
@@ -0,0 +1,152 @@
+// Copyright 2020 Parity Technologies (UK) Ltd.
+// This file is part of Substrate.
+
+// Substrate 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.
+
+// Substrate 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 Substrate. If not, see .
+
+//! Fuzzing for staking pallet.
+
+use honggfuzz::fuzz;
+
+use mock::Test;
+use pallet_staking::testing_utils::{
+ USER, get_seq_phragmen_solution, get_weak_solution, setup_chain_stakers,
+ set_validator_count, signed_account,
+};
+use frame_support::assert_ok;
+use sp_runtime::{traits::Dispatchable, DispatchError};
+
+mod mock;
+
+#[repr(u32)]
+#[allow(dead_code)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum Mode {
+ /// Initial submission. This will be rather cheap.
+ InitialSubmission,
+ /// A better submission that will replace the previous ones. This is the most expensive.
+ StrongerSubmission,
+ /// A weak submission that will be rejected. This will be rather cheap.
+ WeakerSubmission,
+}
+
+pub fn new_test_ext() -> Result {
+ frame_system::GenesisConfig::default().build_storage::().map(Into::into)
+}
+
+fn main() {
+ let to_range = |x: u32, a: u32, b: u32| {
+ let collapsed = x % b;
+ if collapsed >= a {
+ collapsed
+ } else {
+ collapsed + a
+ }
+ };
+ loop {
+ fuzz!(|data: (u32, u32, u32, u32, u32)| {
+ let (mut num_validators, mut num_nominators, mut edge_per_voter, mut to_elect, mode_u32) = data;
+ let ext = new_test_ext();
+ let mode: Mode = unsafe { std::mem::transmute(mode_u32) };
+ num_validators = to_range(num_validators, 50, 1000);
+ num_nominators = to_range(num_nominators, 50, 2000);
+ edge_per_voter = to_range(edge_per_voter, 1, 16);
+ to_elect = to_range(to_elect, 20, num_validators);
+ let do_reduce = true;
+
+ println!("+++ instance with params {} / {} / {} / {:?}({}) / {}",
+ num_nominators,
+ num_validators,
+ edge_per_voter,
+ mode,
+ mode_u32,
+ to_elect,
+ );
+
+ ext.unwrap_or_default().execute_with(|| {
+ // initial setup
+ set_validator_count::(to_elect);
+ pallet_staking::testing_utils::init_active_era();
+ setup_chain_stakers::(
+ num_validators,
+ num_nominators,
+ edge_per_voter,
+ );
+
+ println!("++ Chain setup done.");
+
+ // stuff to submit
+ let (winners, compact, score) = match mode {
+ Mode::InitialSubmission => {
+ /* No need to setup anything */
+ get_seq_phragmen_solution::(do_reduce)
+ },
+ Mode::StrongerSubmission => {
+ let (winners, compact, score) = get_weak_solution::(false);
+ println!("Weak on chain score = {:?}", score);
+ assert_ok!(
+ >::submit_election_solution(
+ signed_account::(USER),
+ winners,
+ compact,
+ score,
+ pallet_staking::testing_utils::active_era::(),
+ )
+ );
+ get_seq_phragmen_solution::(do_reduce)
+ },
+ Mode::WeakerSubmission => {
+ let (winners, compact, score) = get_seq_phragmen_solution::(do_reduce);
+ println!("Strong on chain score = {:?}", score);
+ assert_ok!(
+ >::submit_election_solution(
+ signed_account::(USER),
+ winners,
+ compact,
+ score,
+ pallet_staking::testing_utils::active_era::(),
+ )
+ );
+ get_weak_solution::(false)
+ }
+ };
+
+ println!("++ Submission ready. Score = {:?}", score);
+
+ // must have chosen correct number of winners.
+ assert_eq!(winners.len() as u32, >::validator_count());
+
+ // final call and origin
+ let call = pallet_staking::Call::::submit_election_solution(
+ winners,
+ compact,
+ score,
+ pallet_staking::testing_utils::active_era::(),
+ );
+ let caller = signed_account::(USER);
+
+ // actually submit
+ match mode {
+ Mode::WeakerSubmission => {
+ assert_eq!(
+ call.dispatch(caller.into()).unwrap_err().error,
+ DispatchError::Module { index: 0, error: 15, message: Some("PhragmenWeakSubmission") },
+ );
+ },
+ // NOTE: so exhaustive pattern doesn't work here.. maybe some rust issue? or due to `#[repr(u32)]`?
+ Mode::InitialSubmission | Mode::StrongerSubmission => assert!(call.dispatch(caller.into()).is_ok()),
+ };
+ })
+ });
+ }
+}
diff --git a/substrate/frame/staking/src/lib.rs b/substrate/frame/staking/src/lib.rs
index 87c6f09e62..67240d8d34 100644
--- a/substrate/frame/staking/src/lib.rs
+++ b/substrate/frame/staking/src/lib.rs
@@ -370,7 +370,7 @@ generate_compact_solution_type!(pub GenericCompactAssignments, 16);
#[derive(Encode, Decode, RuntimeDebug)]
pub struct ActiveEraInfo {
/// Index of era.
- index: EraIndex,
+ pub index: EraIndex,
/// Moment of start expresed as millisecond from `$UNIX_EPOCH`.
///
/// Start can be none if start hasn't been set for the era yet,
@@ -803,6 +803,10 @@ pub trait Trait: frame_system::Trait + SendTransactionTypes> {
/// The overarching call type.
type Call: Dispatchable + From> + IsSubType, Self> + Clone;
+ /// Maximum number of equalise iterations to run in the offchain submission. If set to 0,
+ /// equalize will not be executed at all.
+ type MaxIterations: Get;
+
/// The maximum number of nominator rewarded for each validator.
///
/// For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim
diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs
index f245c12a54..a34f342556 100644
--- a/substrate/frame/staking/src/mock.rs
+++ b/substrate/frame/staking/src/mock.rs
@@ -64,6 +64,7 @@ thread_local! {
static SLASH_DEFER_DURATION: RefCell = RefCell::new(0);
static ELECTION_LOOKAHEAD: RefCell = RefCell::new(0);
static PERIOD: RefCell = RefCell::new(1);
+ static MAX_ITERATIONS: RefCell = RefCell::new(0);
}
/// Another session handler struct to test on_disabled.
@@ -143,6 +144,13 @@ impl Get for SlashDeferDuration {
}
}
+pub struct MaxIterations;
+impl Get for MaxIterations {
+ fn get() -> u32 {
+ MAX_ITERATIONS.with(|v| *v.borrow())
+ }
+}
+
impl_outer_origin! {
pub enum Origin for Test where system = frame_system {}
}
@@ -310,6 +318,7 @@ impl Trait for Test {
type NextNewSession = Session;
type ElectionLookahead = ElectionLookahead;
type Call = Call;
+ type MaxIterations = MaxIterations;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type UnsignedPriority = UnsignedPriority;
}
@@ -337,6 +346,7 @@ pub struct ExtBuilder {
num_validators: Option,
invulnerables: Vec,
has_stakers: bool,
+ max_offchain_iterations: u32,
}
impl Default for ExtBuilder {
@@ -355,6 +365,7 @@ impl Default for ExtBuilder {
num_validators: None,
invulnerables: vec![],
has_stakers: true,
+ max_offchain_iterations: 0,
}
}
}
@@ -412,6 +423,10 @@ impl ExtBuilder {
self.has_stakers = has;
self
}
+ pub fn max_offchain_iterations(mut self, iterations: u32) -> Self {
+ self.max_offchain_iterations = iterations;
+ self
+ }
pub fn offchain_phragmen_ext(self) -> Self {
self.session_per_era(4)
.session_length(5)
@@ -423,6 +438,7 @@ impl ExtBuilder {
SESSION_PER_ERA.with(|v| *v.borrow_mut() = self.session_per_era);
ELECTION_LOOKAHEAD.with(|v| *v.borrow_mut() = self.election_lookahead);
PERIOD.with(|v| *v.borrow_mut() = self.session_length);
+ MAX_ITERATIONS.with(|v| *v.borrow_mut() = self.max_offchain_iterations);
}
pub fn build(self) -> sp_io::TestExternalities {
let _ = env_logger::try_init();
diff --git a/substrate/frame/staking/src/offchain_election.rs b/substrate/frame/staking/src/offchain_election.rs
index c2383d1eeb..572703f895 100644
--- a/substrate/frame/staking/src/offchain_election.rs
+++ b/substrate/frame/staking/src/offchain_election.rs
@@ -16,17 +16,18 @@
//! Helpers for offchain worker election.
+use codec::Decode;
use crate::{
Call, CompactAssignments, Module, NominatorIndex, OffchainAccuracy, Trait, ValidatorIndex,
};
use frame_system::offchain::SubmitTransaction;
use sp_phragmen::{
build_support_map, evaluate_support, reduce, Assignment, ExtendedBalance, PhragmenResult,
- PhragmenScore,
+ PhragmenScore, equalize,
};
use sp_runtime::offchain::storage::StorageValueRef;
-use sp_runtime::PerThing;
-use sp_runtime::RuntimeDebug;
+use sp_runtime::{PerThing, RuntimeDebug, traits::{TrailingZeroInput, Zero}};
+use frame_support::{debug, traits::Get};
use sp_std::{convert::TryInto, prelude::*};
/// Error types related to the offchain election machinery.
@@ -159,10 +160,7 @@ pub fn prepare_submission(
};
// Clean winners.
- let winners = winners
- .into_iter()
- .map(|(w, _)| w)
- .collect::>();
+ let winners = sp_phragmen::to_without_backing(winners);
// convert into absolute value and to obtain the reduced version.
let mut staked = sp_phragmen::assignment_ratio_to_staked(
@@ -170,10 +168,33 @@ pub fn prepare_submission(
>::slashable_balance_of_vote_weight,
);
+ // reduce
if do_reduce {
reduce(&mut staked);
}
+ let (mut support_map, _) = build_support_map::(&winners, &staked);
+
+ // equalize a random number of times.
+ let iterations_executed = match T::MaxIterations::get() {
+ 0 => {
+ // Don't run equalize at all
+ 0
+ }
+ iterations @ _ => {
+ let seed = sp_io::offchain::random_seed();
+ let iterations = ::decode(&mut TrailingZeroInput::new(seed.as_ref()))
+ .expect("input is padded with zeroes; qed") % iterations.saturating_add(1);
+ equalize(
+ &mut staked,
+ &mut support_map,
+ Zero::zero(),
+ iterations as usize,
+ )
+ }
+ };
+
+
// Convert back to ratio assignment. This takes less space.
let low_accuracy_assignment = sp_phragmen::assignment_staked_to_ratio(staked);
@@ -215,5 +236,12 @@ pub fn prepare_submission(
}
}
+ debug::native::debug!(
+ target: "staking",
+ "prepared solution after {} equalization iterations with score {:?}",
+ iterations_executed,
+ score,
+ );
+
Ok((winners_indexed, compact, score))
}
diff --git a/substrate/frame/staking/src/testing_utils.rs b/substrate/frame/staking/src/testing_utils.rs
index 4c1ee66a75..229b1e2c96 100644
--- a/substrate/frame/staking/src/testing_utils.rs
+++ b/substrate/frame/staking/src/testing_utils.rs
@@ -153,13 +153,13 @@ pub fn get_weak_solution(
let mut backing_stake_of: BTreeMap> = BTreeMap::new();
// self stake
- >::enumerate().for_each(|(who, _p)| {
+ >::iter().for_each(|(who, _p)| {
*backing_stake_of.entry(who.clone()).or_insert(Zero::zero()) +=
>::slashable_balance_of(&who)
});
// add nominator stuff
- >::enumerate().for_each(|(who, nomination)| {
+ >::iter().for_each(|(who, nomination)| {
nomination.targets.into_iter().for_each(|v| {
*backing_stake_of.entry(v).or_insert(Zero::zero()) +=
>::slashable_balance_of(&who)
@@ -176,7 +176,7 @@ pub fn get_weak_solution(
.collect();
let mut staked_assignments: Vec> = Vec::new();
- >::enumerate().for_each(|(who, nomination)| {
+ >::iter().for_each(|(who, nomination)| {
let mut dist: Vec<(T::AccountId, ExtendedBalance)> = Vec::new();
nomination.targets.into_iter().for_each(|v| {
if winners.iter().find(|&w| *w == v).is_some() {
@@ -325,16 +325,29 @@ pub fn clean(era: EraIndex)
::AccountId: codec::EncodeLike,
u32: codec::EncodeLike,
{
- >::enumerate().for_each(|(k, _)| {
+ >::iter().for_each(|(k, _)| {
let ctrl = >::bonded(&k).unwrap();
>::remove(&k);
>::remove(&k);
>::remove(&ctrl);
>::remove(k, era);
});
- >::enumerate().for_each(|(k, _)| >::remove(k));
+ >::iter().for_each(|(k, _)| >::remove(k));
>::remove_all();
>::remove_all();
>::kill();
QueuedScore::kill();
}
+
+/// get the active era.
+pub fn active_era() -> EraIndex {
+ >::active_era().unwrap().index
+}
+
+/// initialize the first era.
+pub fn init_active_era() {
+ ActiveEra::put(ActiveEraInfo {
+ index: 1,
+ start: None,
+ })
+}
diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs
index 3920b7bc0d..487a3fc346 100644
--- a/substrate/frame/staking/src/tests.rs
+++ b/substrate/frame/staking/src/tests.rs
@@ -2901,8 +2901,8 @@ mod offchain_phragmen {
#[test]
fn signed_result_can_be_submitted() {
- // should check that we have a new validator set normally,
- // event says that it comes from offchain.
+ // should check that we have a new validator set normally, event says that it comes from
+ // offchain.
ExtBuilder::default()
.offchain_phragmen_ext()
.build()
@@ -2989,8 +2989,8 @@ mod offchain_phragmen {
#[test]
fn early_solution_submission_is_rejected() {
- // should check that we have a new validator set normally,
- // event says that it comes from offchain.
+ // should check that we have a new validator set normally, event says that it comes from
+ // offchain.
ExtBuilder::default()
.offchain_phragmen_ext()
.build()
@@ -3119,7 +3119,7 @@ mod offchain_phragmen {
&inner,
),
TransactionValidity::Ok(ValidTransaction {
- priority: (1 << 20) + 1125, // the proposed slot stake.
+ priority: UnsignedPriority::get() + 1125, // the proposed slot stake.
requires: vec![],
provides: vec![("StakingOffchain", current_era()).encode()],
longevity: 3,
@@ -3129,6 +3129,50 @@ mod offchain_phragmen {
})
}
+ #[test]
+ fn offchain_worker_runs_with_equalise() {
+ // Offchain worker equalises based on the number provided by randomness. See the difference
+ // in the priority, which comes from the computed score.
+ let mut ext = ExtBuilder::default()
+ .offchain_phragmen_ext()
+ .validator_count(2)
+ .max_offchain_iterations(2)
+ .build();
+ let state = offchainify(&mut ext);
+ ext.execute_with(|| {
+ run_to_block(12);
+
+ // local key 11 is in the elected set.
+ assert_eq_uvec!(Session::validators(), vec![11, 21]);
+ assert_eq!(state.read().transactions.len(), 0);
+ Staking::offchain_worker(12);
+ assert_eq!(state.read().transactions.len(), 1);
+
+ let encoded = state.read().transactions[0].clone();
+ let extrinsic: Extrinsic = Decode::decode(&mut &*encoded).unwrap();
+
+ let call = extrinsic.call;
+ let inner = match call {
+ mock::Call::Staking(inner) => inner,
+ };
+
+ assert_eq!(
+ ::validate_unsigned(
+ TransactionSource::Local,
+ &inner,
+ ),
+ TransactionValidity::Ok(ValidTransaction {
+ // the proposed slot stake, with equalize.
+ priority: UnsignedPriority::get() + 1250,
+ requires: vec![],
+ provides: vec![("StakingOffchain", active_era()).encode()],
+ longevity: 3,
+ propagate: false,
+ })
+ )
+ })
+ }
+
#[test]
fn mediocre_submission_from_authority_is_early_rejected() {
let mut ext = ExtBuilder::default()
diff --git a/substrate/primitives/core/Cargo.toml b/substrate/primitives/core/Cargo.toml
index 5eecd83853..2ab23d23c4 100644
--- a/substrate/primitives/core/Cargo.toml
+++ b/substrate/primitives/core/Cargo.toml
@@ -24,7 +24,7 @@ wasmi = { version = "0.6.2", optional = true }
hash-db = { version = "0.15.2", default-features = false }
hash256-std-hasher = { version = "0.15.2", default-features = false }
base58 = { version = "0.1.0", optional = true }
-rand = { version = "0.7.2", optional = true }
+rand = { version = "0.7.3", optional = true, features = ["small_rng"] }
substrate-bip39 = { version = "0.4.1", optional = true }
tiny-bip39 = { version = "0.7", optional = true }
regex = { version = "1.3.1", optional = true }
diff --git a/substrate/primitives/core/src/offchain/testing.rs b/substrate/primitives/core/src/offchain/testing.rs
index f4faee6b02..fecf442c57 100644
--- a/substrate/primitives/core/src/offchain/testing.rs
+++ b/substrate/primitives/core/src/offchain/testing.rs
@@ -165,7 +165,12 @@ impl offchain::Externalities for TestOffchainExt {
}
fn random_seed(&mut self) -> [u8; 32] {
- unimplemented!("not needed in tests so far")
+ use rand::{SeedableRng, RngCore};
+ use rand::rngs::SmallRng;
+ let mut seed = [0u8; 32];
+ let mut small_rng = SmallRng::from_entropy();
+ small_rng.fill_bytes(&mut seed);
+ seed
}
fn local_storage_set(&mut self, kind: StorageKind, key: &[u8], value: &[u8]) {
diff --git a/substrate/primitives/phragmen/src/lib.rs b/substrate/primitives/phragmen/src/lib.rs
index 01d034a95e..f45732d5b8 100644
--- a/substrate/primitives/phragmen/src/lib.rs
+++ b/substrate/primitives/phragmen/src/lib.rs
@@ -158,7 +158,7 @@ pub struct PhragmenResult {
#[derive(RuntimeDebug, Clone, Default)]
#[cfg_attr(feature = "std", derive(PartialEq, Eq, Encode, Decode))]
pub struct Assignment {
- /// Voter's identifier
+ /// Voter's identifier.
pub who: AccountId,
/// The distribution of the voter's stake.
pub distribution: Vec<(AccountId, T)>,