# Participation Lotteries on Kusama
This document outlines how a configurable, reoccurring lottery system can be used to drive participation on the Kusama network.
Participation in Kusama is relatively low.
* Average number of votes per elected council member: 30
* Number of Society members: 5
* Number of votes on current democracy process (Ref 79): 20
Polkascan reports there are [~17,000 active accounts](https://polkascan.io/kusama) on Kusama.
The goal of Participation Lotteries is to stimulate participation on the Kusama network by giving an additional incentive for users to participate.
## User Story
The Kusama network is going to have a very important decision to be made through a democracy proposal. (Maybe a re-denomination...?) The network wants to stimulate participation of this vote by the end users, so it creates a new lottery.
Council, or some other origin with access will start a new lottery using the "vote" extrinsic. This lottery will be initialized with some funds from treasury to start the pot. Let's say 50 KSM
Users who want to opt into this lottery can do so by calling the `vote` extrinsic wrapped in a `buy_ticket` extrinsic. (Think like how we wrap calls for `sudo`).
By calling the `buy_ticket` extrinsic and wrapping the underlying call, the user purchases a 1 KSM ticket into the lottery, and the lottery pot increases by 1 KSM.
Users who are not interested in the lottery can simply choose to call `vote` directly. Nothing here is changed.
Users will continue to participate in the lottery until the lottery period is completed. (This lottery period will likely be tied to the event at hand, for example the time until the vote expires, the end of an Era/Epoch, etc...)
Once the lottery period is over, a random user among those participating will be selected and win the entirety of the pot.
## Game Theory
As with any game on the blockchain, there needs to be reasonable incentives and disincentives for users to behave the way we want.
The lottery is seeded by some funds from the treasury. As a result, any participant entering the lottery would have positive expected value (EV).
We can use the `seed` amount to control participation. The higher the seed, the larger the EV for a larger number of participants.
In general, it would seem that humans love to participate in lotteries. The chance to win a lot of money at little cost triggers something that may not always make economically sound decisions.
It is possible that this lottery system incentivizes "mindless" participation by users not interested in the underlying call, but just interested in participating in the lottery. AFAIK, this is unavoidable in any participation incentive mechanism. However, I think that on average, the network will benefit from more participation as a whole.
One potential issue with lotteries on the blockchain is that it is somewhat vulnerable to Sybil attacks. i.e. given that participating is positive EV, a user could create many many entries into the lottery to have a high chance of winning.
However, this can also be limited and controlled through fees and the `seed` amount. In order for a user to successfully complete such an attack, they would need to transfer at least the ticket price amount of tokens to N accounts. Then each of the N accounts need to submit a wrapped extrinsic for the underlying call to be made, which involves its own transaction fee on top of the ticket price.
That means that such an attack would cost `N * (transfer_fee + account_creation_fee + call_fee)` tokens. If the treasury seed is below this amount, the user is no longer incentivized to participate. Furthermore, margins would be slim for such a user, and continue to worsen as more users join.
### Other Important Points
To complete a lottery, we need to be able to randomly select a winner. Substrate/Kusama provides on chain randomness that is used for other parts of the network. It may be at certain absurd lottery pots, that block producers may be incetivized to hold back blocks which they are not the winner of the lottery, or some other negative incentives... Would potentially need feedback from W3F research team who knows more about the limits of using this randomness.
It would of course not be controllable directly by a user.
## Network Effects
A participation lottery can be used to drive forward the following behavioral changes to the network by attaching a lottery to a specific extrinsic:
* Have more users share their voice on important elections. (`vote`)
* Have users change/update their validator nominations on a regular schedule. (`nominate`)
* Have more users join Society or other similar social experiments (`put_bid`)
* Encourage brainstorming of ideas in future updates and changes (`propose_bounty`)
* Have more users (change their) backing of (candidate) council members (`electionPhragmen`,`vote`)
This section describes how a Participation Lottery may be implemented. Some details of the implementation are "known" and some things are "flexible"/"unknown".
* A new pallet will be created which manages these auctions.
* The pallet will be configurable to allow any call(s) in the runtime to be the source of buying a ticket.
* A configurable `seed` amount will be allocated from a funding source (like treasury) to kick off lotteries.
* Users will pay a configurable `ticket_price` to participate in lottery, this will be placed in the pool.
* Winners will be determined at some non-user-controllable future block, and use the on-chain randomness to pick a winner.
* More to be added...
* Lotteries can be regularly scheduled or initiated explicitly each time by governance.
* Multiple extrinsics can be whitelisted at once for one lottery.
* Participation can be limited 1 per lottery or 1 per extrinsic per lottery.
* Could have more than one lottery winner, maybe with lesser prize payouts.
* Previous lottery can be used to seed next lottery.
* More to be added....
Initial estimates predict that this end to end development should take 5 full days (spread over 2 - 3 weekends). For that work, a suggested budget of 250 KSM should be allocated.
To deliver this feature the following tasks need to be completed (with suggested delivery cost):
* [ ] Create the basic pallet structure/idea. (100 KSM)
* [ ] Refine pallet based on feedback and discovered limitations. (50 KSM)
* [ ] Write comprehensive tests ensuring safety of the pallet. (50 KSM)
* [ ] Benchmark and weigh the pallet for production use. (50 KSM)
* [ ] Have the pallet reviewed and merged by Parity development team.
It is possible that delivery may be delayed slightly based on unforeseen factors, but that should be made clear at milestone 2 where we need to refine the pallet based on feedback.
Feel free to add questions to this document below:
- [x] This seems like a project with similar complexity as the Bounty project. If this project is going to proposed as a Bounty, the council should get a ball-park figure to Budget this expense. I feel we need to evaluate actual cost/expenses (time spent * rate) of the Bounty project to allow proper budgetting of this project. (by Emiel)
> I would propose an initial budget of 250 KSM for approximately 5 days of work (~2 weekends), and any additional budget can come from donations if people are satisfied with my work and my timeliness.
- [ ] Make a question like this.
> I will answer like this.