-
Notifications
You must be signed in to change notification settings - Fork 413
gnovm: random global variable pary #4182
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
Comments
I wrote a txtar test based on the reproduction method suggested in the previous issue, and this time it was successful. It seems that it was affected by the addition of the cross-realm feature (maybe #4060?). Below are the test and execution method. cd gno.land/pkg/integration
go test -v . -run Testdata/rand txtar script
Result
As shown in the test results, when calling the Render function with gnokey, you can see that the value Still we need to do more verification, but it seems like we don't need to modify or delete the |
@notJoon so basically you used the native golang random ? As you mentioned in the previous issue ? That's right ? |
The I think we should have 1. a realm that provides a global I think most can get away with creating a |
Description
related to #4039, this describes a deeper issue on the gnovm.
problematic : how do we manage random global variable to store the seed ?
to make random, we need a
seed
that will define the overall state of the randomness, with some pseudo random methods to edit the number based on the seed, with chaotic-like maths evaluations.but here, in gno, we cant store anything in a stdlib, because it (kind of) act like a pure package, so how to counter that ?
so as thehowl said here, we must get rid of the global variable, but how do we store the seed ?
Golang singleton
so one way would be to create a function to get the seed as a global variable internal to gno, so the global object is coded in the gno software (so coded in golang) and the function to get the object is called in gno
so instead of using this
globalRand
variable, we could actually callGetGlobalSeed()
and this function will return the Rand object from gno software directly, and not stored in a gno file.Use a pseudo realm package
since pure packages cant store variables, why not using packages that behaves like the
r/
packages (that can actually hold data) and require it in the randso i know we cant directly use gno.land/r packages in stdlibs, since we have to differenciate gno and gno.land, but its just an idea
Give up
just remove the random, since some people thinks its useless in gno, because it leads to less predicatable behaviours.
Do you have any other ideas ?
The text was updated successfully, but these errors were encountered: