Aolotto Protocol Draw Algorithm Upgrade
We have optimized the Aolotto protocol's algorithm, and the draw will take place after the fifth block height.
Author: Aolotto
Source: Content Guild Translation
Originally published at: @aolotto_dao
Original link: https://www.notion.so/permadao/Aolotto-6b2415145c3e452a834978dd4a6f527b
In pursuit of greater fairness and security, Aolotto protocol has upgraded its draw algorithm and refined the draw mechanism, enabling users to participate in lottery betting within a fairer system.
Upgrade Details
The results of each round in the Aolotto protocol are generated using multiple random numbers based on the HMAC algorithm, which incorporates BlockHash. A key change in the new algorithm is that the block hash adoption has been delayed by 5 blocks compared to the previous method.
At the end of each round, the protocol immediately transitions to the next round, archiving the previous round’s betting records. However, the draw itself is postponed, waiting for 5 additional blocks to pass before generating the final lucky numbers based on the archived data.
The most critical step in the lottery process is the generation of random numbers. Once the numbers are created using the HMAC algorithm, the results become final and verifiable using publicly available on-chain data.
Why Upgrade the Algorithm?
Previously, the protocol used the current block hash directly as a source for generating random numbers. While this approach was already secure, it carried a theoretical risk of miner manipulation. Miners could potentially influence the hash value by adjusting block data. Although such manipulation would require considerable computational power and resources, making it unprofitable in practice, Aolotto aimed to eliminate even this slim possibility.
By delaying the use of the block hash by 5 blocks, miners lose the ability to influence future blocks. This ensures the randomness remains transparent, tamper-proof, and trustworthy, elevating the protocol's fairness and security standards.
How the New Algorithm Works
Round Ends and Archiving: At the end of each round, all bet records and states are archived on the Arweave blockchain, and a unique ArchiveId is generated as the first seed factor for the lottery draw.
Archival Confirmation: Once the archival is confirmed, the protocol generates an ArchivedId as the second seed factor.
Wait for the Block Height to Meet Conditions: The jackpot process checks the latest block height every minute to ensure the latest block height meets the condition of being at least 5 greater than the archived block height. Once the condition is met, the BlockHash of the latest block is retrieved as the third seed factor.
Extract Additional Factors: The protocol extracts the LastBetId (the ID of the last betting transaction) and TimeStamp (the timestamp of the lottery draw), which serve as the fourth and fifth seed factors.
Combine Seeds: The five seed factors are combined into a single string: BlockHash_ArchiveId_ArchivedId_LastBetId_TimeStamp.
Generate Lucky Numbers: The protocol generates 3-digit lucky numbers (random numbers between 0 and 9) based on the seed string, corresponding to seed+1, seed+2, and seed+3.
Determine and Announce Winners: The winners are determined from the archived information based on the lucky number, and the draw results are announced.
Final Thoughts
Generating random numbers on the blockchain is a delicate balance between unpredictability and verifiability. Non-deterministic algorithms can lack transparency, while deterministic ones risk predictability. On mainstream blockchains like Ethereum, third-party oracles are typically relied upon to ensure fairness in random number generation.
For AO, this is not an issue. AO supports Cron Messages, which allow smart contracts to execute functions at scheduled times. Through this mechanism, the Aolotto protocol can delay the draw process to a future point, effectively preventing the results from being predicted in advance and ensuring fair random number generation.