sui
sui copied to clipboard
Add RandomGenerator to Sui Framework
Description
Add interfaces for fetching randomness: RandomGenerator
is a PRG with a seed that is derived from the global randomness (which is the same between randomness rounds) and a fresh UID (which is guaranteed to be unique by the framework). In other words, the seed is unpredictable without knowing the global randomness, and different for each created generator (thus not predictable even by different functions invoked for the same tx).
RandomGenerator
manages an internal state with a buffer of random bytes derived using the PRG, and provides high level functions for deriving integers from those random bytes.
Test Plan
Unit tests
If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.
Type of Change (Check all that apply)
- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [x] breaking change for FNs (FN binary must upgrade)
- [x] breaking change for validators or node operators (must upgrade binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration
Release notes
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
explorer | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Mar 21, 2024 2:37pm |
multisig-toolkit | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Mar 21, 2024 2:37pm |
mysten-ui | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Mar 21, 2024 2:37pm |
sui-core | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Mar 21, 2024 2:37pm |
sui-kiosk | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Mar 21, 2024 2:37pm |
sui-typescript-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Mar 21, 2024 2:37pm |
All the interfaces are in. I didn't complete the tests yet but wanted to receive the first round of feedbacks before I add snapshots, etc.
@dariorussi , please let me know if the design makes sense, and whether any of the functions better be implemented as native ones. @jonas-lj , please review the different crypto "conversions".
@kchalkias , @aschran - CCed in case you have comments as well.
The examples are currently insecure because of composition, please ignore them for now
Waiting with updating the snapshots until we finish the review of the Move code.
in case it helps....
1- go to <sui>/crates/sui-framework/packages/sui-framework
2- run sui move test --coverage
3- sui move coverage summary
will give you a summary of the percentage coverage for every module in the framework
4- sui move coverage bytecode --module random
will tell you which bytecodes/branches are not covered by tests
I can give you the results as of right now, though it's a bit of a verbose output, so let me know if you want them
in case it helps.... 1- go to
<sui>/crates/sui-framework/packages/sui-framework
2- runsui move test --coverage
3-sui move coverage summary
will give you a summary of the percentage coverage for every module in the framework 4-sui move coverage bytecode --module random
will tell you which bytecodes/branches are not covered by tests I can give you the results as of right now, though it's a bit of a verbose output, so let me know if you want them
Thanks @dariorussi - we cover all reachable code, except for unreachable assert aborts (for example, assert!(version == CURRENT_VERSION, EWrongInnerVersion)
)