substrate icon indicating copy to clipboard operation
substrate copied to clipboard

pallet-lottery: deal with randomness freshness

Open andresilva opened this issue 3 years ago • 2 comments

https://github.com/paritytech/substrate/pull/8180 changed the randomness API to also explicitly return how fresh some random material is. In order to safely use this entropy any commitments based on it must have been made before the randomness was known. In the context of the lottery pallet it means that people should only be able to sign up for the lottery to the point where we fetch the random data that will decide the winner, e.g. we accept new participants until block #50, on block #50 we get new (fresh) random material which is used later on to randomly select the winner.

andresilva avatar Mar 10 '21 11:03 andresilva

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 07 '21 21:07 stale[bot]

I've not looked at pallet_lottery but in general it depends upon the usage of the lottery.

It's clearly impossible for any blockchain to simultaneously close a lottery and produce randomness with which to decide the lottery, but you might survive doing this if the lottery was low enough value.

In our case, all block producers learn their babe/sassafras VRFs two/three epochs in advance, so you either need commitments to participate way in advance or else you need something like the random close time we use in elections.

burdges avatar Sep 19 '22 07:09 burdges