Ticket Selection Algorithm¶
Every block, 5 tickets are pseudorandomly selected from the ticket pool to vote. Below is a high-level description of the ticket selection algorithm. A more detailed, low-level walkthrough of the ticket selection code can be found in this video.
Pseudorandom number generation¶
Tickets are selected from the ticket pool using a deterministic Pseudorandom Number Generator (PRNG). It is deterministic because the seed input to the PRNG is derived from the hash of the previous block (the block being voted on). Specifically, the seed is a serialization of the header of the previous block suffixed with a constant derived from the hex representation of the mathematical constant Pi (𝜋), which acts as a publicly verifiable Nothing-Up-My-Sleeve (NUMS) constant. All eligible tickets in the ticket pool (also referred to as live tickets) are hashed using the BLAKE-256 hash function and sorted lexicographically by their hash to generate a total order. Finally, uniformly random values constrained by the number of total eligible tickets as an upper bound are produced and used as indices into the total order.