gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
880 stars 364 forks source link

feat(stdlibs): add math/rand #2455

Closed thehowl closed 3 months ago

thehowl commented 3 months ago

This PR ports over to Gno the math/rand/v2 Go package. It provides pseudo-random number generation.

Notable omissions:

This PR requires a version bump to go 1.22 to have math/rand/v2 in the standard libraries; otherwise the Native tests won't work. We can rollback the changes to move it to 1.22 by removing the native math/rand implementation, and only using the stdlibs.

BREAKING CHANGE: existing usages of math/rand used Go's math/rand; however, in this new standard library we use its v2, so results will be different.

Closes #1272; See-also #1267

Contributors' checklist... - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
thehowl commented 3 months ago

cc @leohhhn

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 54.71%. Comparing base (f6235fd) to head (a9f9f47).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2455 +/- ## ========================================== + Coverage 54.68% 54.71% +0.03% ========================================== Files 583 583 Lines 78503 78499 -4 ========================================== + Hits 42930 42952 +22 + Misses 32364 32341 -23 + Partials 3209 3206 -3 ``` | [Flag](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | Coverage Δ | | |---|---|---| | [contribs/gnodev](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `23.81% <ø> (ø)` | | | [contribs/gnofaucet](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `14.46% <ø> (ø)` | | | [contribs/gnokeykc](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `0.00% <ø> (ø)` | | | [contribs/gnomd](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `0.00% <ø> (ø)` | | | [gno.land](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `62.54% <ø> (ø)` | | | [gnovm](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `59.98% <100.00%> (+0.03%)` | :arrow_up: | | [misc/autocounterd](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `0.00% <ø> (ø)` | | | [misc/genproto](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `0.00% <ø> (ø)` | | | [misc/genstd](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `73.90% <ø> (ø)` | | | [misc/goscan](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `0.00% <ø> (ø)` | | | [misc/logos](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `17.38% <ø> (ø)` | | | [misc/loop](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `0.00% <ø> (ø)` | | | [tm2](https://app.codecov.io/gh/gnolang/gno/pull/2455/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang) | `54.46% <ø> (+0.09%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gnolang#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.