-
Notifications
You must be signed in to change notification settings - Fork 66
Update randomness doc #1281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update randomness doc #1281
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
docs/tools/kit/index.md
Outdated
* This hook is designed for simple use cases that **don’t require a [commit-reveal scheme]**, such as randomized UIs. | ||
* For **more advanced use cases** that **do** require a [commit-reveal scheme], Flow provides built-in support for that pattern. | ||
* Values are **deterministic**: if a transaction fails and retries, the same random value will be regenerated. | ||
* Randomness is generated using Flow’s **on-chain `revertibleRandom`**, producing pseudorandom values tied to block and script execution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are no transactions in this case, it's all script based (under the hood, this makes a difference in how randomness works).
* For **more advanced use cases** that **do** require a [commit-reveal scheme], Flow provides built-in support for that pattern. | ||
* Values are **deterministic**: if a transaction fails and retries, the same random value will be regenerated. | ||
* Randomness is generated using Flow’s **on-chain `revertibleRandom`**, producing pseudorandom values tied to block and script execution. | ||
* Values are **deterministic**: The values returned for identical calls within the same block will be identical. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is described here in determinism, so I moved the "deterministic" note here
docs/tools/kit/index.md
Outdated
* Values are **deterministic**: if a transaction fails and retries, the same random value will be regenerated. | ||
* Randomness is generated using Flow’s **on-chain `revertibleRandom`**, producing pseudorandom values tied to block and script execution. | ||
* Values are **deterministic**: The values returned for identical calls within the same block will be identical. | ||
* If `count ` is larger than one, the returned values are disctinct. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this so that developers don't think determinism means all count
values are equal
* Randomness is generated using Flow’s **on-chain `revertibleRandom`**, producing pseudorandom values tied to block and script execution. | ||
* Values are **deterministic**: The values returned for identical calls within the same block will be identical. | ||
* If `count ` is larger than one, the returned values are disctinct. | ||
* This hook is designed for simple use cases that don't require unpredictability, such as randomized UIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit-reveal solves the reversibility issue, but here in the script nothing is reversible so commit-reveal doesn't add any advantage.
The main thing developers should be aware of is that the block random source in the lib is publicly known (since this is script-based). There is nothing wrong with that in many applications like the example mentioned here (UIs)
* If `count ` is larger than one, the returned values are disctinct. | ||
* This hook is designed for simple use cases that don't require unpredictability, such as randomized UIs. | ||
Since the hook uses script executions on existing blocks, Flow's randon source is already public and the randoms are predictable. | ||
* For **more advanced use cases** that **do** require on-chain randomness logic via transactions, Flow provides built-in support using Cadence's `revertibleRandom` and [commit-reveal scheme]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more advanced cases are the ones with the logic fully on-chain via transactions (not scripts). This is where randomness is unpredictable, and reversibility can or cannot be an issue, so I added the mention of transactions here. Both "reversibleRandom" and "commit-reveal" work in that case depending on the app.
Co-authored-by: Chase Fleming <chasefleming@users.noreply.github.com>
No description provided.