Random Number Generation
Last updated
Last updated
This is more of a technical documentation, and isn't a must read** **to understand the Summit ecosystem.
Random number generation is used to select the winning totem, and must be ensured to be accurate. Randomness is ensured by using a webserver watching the state of ElevationHelper.sol
(open source) and seeding randomness using the following flow:
Cron job starts a script 60 seconds before the end of each round
Webserver waits for nextSeedRoundAvailable
to switch to true
It then generates a random seed and encrypts it with its own address (Trusted Seeder address)
receiveSealedSeed
is called with the newly sealed seed
ElevationHelper.sol
marks the upcoming block in the future as a target
When the future block is mined, its hash is stored
Webserver waits for futureBlockMined
to become true
receiveUnsealedSeed
is called with the unencrypted random seed
ElevationHelper.sol
validates that this is true random seed by hashing it with the Trusted Seeder address (same as above), and matching the hash against the sealed seed
The hashes match, validating that the same random seed was used in both the sealed and unsealed seed
Webserver waits for the full round to end, then calls rollover
of Cartographer.sol
for any elevations whose rounds are ending
Webserver waits for that transaction to succeed, then calls rolloverPools
of Cartographer.sol
for those same elevations
The entirety of this flow occurs during the 60 second lockout at the end of each round, preventing users from changing anything about their risked yield until after the round is finalized.
The key aspect of the Randomness flow above is that
The Trusted Seeder webserver is blind to the future block hash when it generates the initial randomness seed (through matching of sealed and hashed unsealed seeds before and after future block mined)
The miner is blind to the unencrypted randomness seed when it generates the future block hash
With both parties blind to the actions of the other, neither can alone manipulate the final result. This is a known valid randomness pattern, adapted to the summit defi ecosystem.
This in-house webservice will be open source along with the rest of the summit ecosystem.
In the future this in-house webservice will be made available for a small fee to cover gas to any projects wishing to have trusted seeding for their projects. Though it is more centralized than VRF from chainlink, it costs a fraction of the price in gas (and link), and is very easy to implement in any contract.