-
Notifications
You must be signed in to change notification settings - Fork 2.7k
A random beacon #96
A random beacon #96
Conversation
Not yet complete but 75% there.
|
Could you link to the relevant paper? |
demo/runtime/src/safe_mix.rs
Outdated
| { | ||
| type Item = T; | ||
| fn mixed(self) -> Self::Item { | ||
| let mut accum = [[T::default(); 3]; 13]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
13 is pretty arbitrary. 3^13 is pretty big but not unreasonably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now a named constant.
demo/runtime/src/safe_mix.rs
Outdated
| Ok(seeds.iter().cloned().mixed()) | ||
| } | ||
|
|
||
| /// The mixed trait for mixing a ssequence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo. and why use a trait if it's supposed to be an implementation of a single algorithm? why not fn mix<I, T> instead of impl<I, T> Mixed for I?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not? is this not idiomatic?
demo/runtime/src/safe_mix.rs
Outdated
| } | ||
| } | ||
| } | ||
| accum[max_depth][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth noting in the docs that the amount of items is effectively truncated to the lowest power of three below it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| fn calculate_random() -> Hash { | ||
| let c = block_number() - 1; | ||
| (0..81) | ||
| .map(|i| if c >= i { block_hash(c - i) } else { Default::default() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so for the first 81 blocks the random seed won't be random at all -- I wonder if it's better to use a filter_map so that the early randomness is much more manipulable but not dominated by zero hashes. In polkadot we should have an initial epoch shuffle which ends after randomness is well-seeded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'll still be a bit random. but sure, lower security. thankfully it doesn't really matter.
* read head-data directly out of WASM memory * implement ext_post_message for parachain WASM * further refactoring of the parachain module * add externalities error type * accumulate posted messages when validating parachain candidate * define Extrinsic type in primitives * availability-store: store extrinsic data * compute extrinsic and check against candidate * add some egress queue tests * grumbles & substrate update * ensure everything builds
* added polkadot-js types * lint * turn lint on save on * remove parachain types and comments
* Add verify_btc_address function * Format code
* Fix ci GA * Add wasm workflow * Pin to some nightly version for wasm * Install wasm-gc * Add --git * Add wasm badge * Add stale workflow
…dator Do not submit unsigned root block extrinsic on nodes that do not produce blocks themselves
Uses the recursive-triplet-majority method on the last 81 blocks. Also removes the need for
with-envstuff (though let it be known, this makes serialisation/deserialisation more likely to become a performance bottleneck).http://www.cs.huji.ac.il/~nati/PAPERS/coll_coin_fl.pdf
Goes in after #98