1

I read this post of Shawn https://substrate.stackexchange.com/a/128/2484 and found out, that random numbers for lotteries are not reliable, even with VRF on GRANDPA since the validators could earn more money through the lottery than for the block production. So I would derive, that the usage of random numbers for lotteries is not safe in production, when the stake is high enough. So therefore the question: Is pallet_lottery safe in production? If yes or no, please post why?

I am not regarding the problem of the modulus bias for pallet_lottery .

1 Answer 1

2

It's answered in the question you linked, but..

We only generate safe-ish randomness in babe, not grandpa. We might add better randomness generation to grandpa in the future if we first optimized https://github.com/kobigurk/aggregatable-dkg better, just no critical use cases right now.

Regardless, there is no way any blockchain can simultaneously close participants in a lottery and pick the winner, even if you generate good fresh threshold randomness in finality then you could only use the randomness after finality and worse adversaries could fork the chain so events finalize differently. You always need multi-block actions like waiting periods or commit-reveal, even an instant finality chain only provides the randomness in the next block.

All block producers learn their babe VRFs like two babe epochs in advance, and sassafras shall likely makes this three epochs, so several hours. If you've very low value operations then you could ignore the problem and use them directly, but otherwise you should either commit to participation far enough in advance for the epoch based one, aka close the lottery and wait for epoch randomness, which remains biasable, but much less so. There exist other tricks too..

We'll add cumulative VRF randomness in sassafras, but this actually makes high value lotteries worse.

2
  • Thanks for your answer. It's very complicated for me at least, because you are on a different level, but you are saying, that pallet_lottery is safe for small lottery pots? My actual use case is the following: Generate a voting incentive with a lottery. So you can compare it with pallet_democracy. Only reward in unlock_vote_lock. When the voting period is over, find a random number and with that determine a lucky winner. So that the voters are incentivised to vote, but the lottery pot is relatively small.
    – Chralt
    Sep 19, 2022 at 9:09
  • No. I'm saying you need to understand how to delay the lottery after it closes until the chain can give you good randomness. Sep 19, 2022 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.