Clean up random seed to make a bit more flexible (#2456)

* Reformulate random seed to be more random

- First 80 random values come from cycling the incomplete series (
  instead of filling with zeroes)
- Calculate random material each usage (use a single amalgamated
  ring buffer to store them for avoiding 81 lookups each time)
- Mutate inputs by hashing each with:
  - its index (into the 81)
  - an additional "subject" key provided by caller

This keeps the final output low-influence while still allowing
it to be used as the seed to independent contexts. (Hashing the
result to give the final seed is no better than using parent_hash).

* Docs

* Bump runtime

* Update notes

* Remove feature(alloc)

* Update srml/system/src/lib.rs

Co-Authored-By: gavofyork <github@gavwood.com>
This commit is contained in:
Gavin Wood
2019-05-06 13:57:30 +02:00
committed by Sergei Pepyakin
parent b42e37589e
commit adba89913e
13 changed files with 61 additions and 36 deletions
+1 -1
View File
@@ -443,7 +443,7 @@ mod tests {
header: Header {
parent_hash: [69u8; 32].into(),
number: 1,
state_root: hex!("4c10fddf15e63c91ff2aa13ab3a9b7f6b19938d533829489e72ba40278a08fac").into(),
state_root: hex!("ac2840371d51ff2e036c8fc05af7313b7a030f735c38b2f03b94cbe87bfbb7c9").into(),
extrinsics_root: hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314").into(),
digest: Digest { logs: vec![], },
},