zeitgeistpm / zeitgeist

An evolving blockchain for prediction markets and futarchy.
https://zeitgeist.pm
GNU General Public License v3.0
173 stars 41 forks source link

[Runtime] Use Babe instead of Aura #240

Open sea212 opened 3 years ago

sea212 commented 3 years ago

BABE provides a mechanism to select the authors of the next block. In that term it is almost identical to AURA, with the difference that multiple block authors can be selected for one slot. AURA uses a round-robin scheme, whereas BABE uses a Verifiable Random Function (VRF) to select the next set of block authors. In BABE, for every epoch, every validator is assigned a weight. For equal chances are weights are equal, in a PoS system the weight is inversely proportional with the stake amount. Every weight is split into n different slots. On every slot, every validator in the set of validators generates a pseudorandom number using the VRF. If the validators random number is less than the weight assigned, then the validator is allowed to produce a block. Along with the random number, a proof is submitted, such that every other participant can verify that this number was indeed pseudorandomly generated. At this point we can see, that it is possible that multiple validators generate numbers less than their weight and therefore multiple validators can have the right to produce a block at a given slot. Therefore temporary forks happen more frequently when using BABE, but this is no greater issue, since a finality mechanism like GRANDPA will ensure (relatively fast), what the finalized canonical chain is.

BABE has (at least) one major advantage. Since the set of validators provides verifiably pseudorandomly generated numbers, a new source of entropy comes into existence in the deterministic low-entropy chain. Every pseudo random number can be cleverly mixed to obtain a good source of entropy and therefore potentially a good random number generator.

Currently we use the Randomness Collective Coin Flip Pallet to generate randomness. This is a very insecure way to generate entropy and should only be used in tests.

c410-f3r commented 3 years ago

Cumulus does not yet support BABE (https://github.com/paritytech/cumulus/tree/master/client/consensus) and the current used consensus algorithm based on the MoonBeam implementation (https://github.com/PureStake/cumulus/tree/nimbus) is based on Aura. Therefore, it will probably take some time before BABE is available