-
Notifications
You must be signed in to change notification settings - Fork 375
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
map state is not persisted correctly, resulting in nil pointer dereference #817
Comments
The error here is coming from the virtual machine interpreting your code, not the Gno code itself. I'll need more information about the Gno version you are executing. Can you provide a specific commit from where you built the binaries? Thanks! |
Thx for checking!, I've built binary with current |
It is important to note that the transactions were executed on Do you reproduce the issue with a local node built from |
sorry to give you confusion. stacktrace is from my local node with so it is happening both |
There seems to be a problem with persisting maps because they are non-deterministic. For now, it looks like you're better off using avl.Tree. |
UPDATE: looks like map variable isn't being saved (doesn't keep state) Below example code, there are 2 data types
In After init, even
|
nice we're using the challenges folder! thank you manfred |
Anyone can try this; please add me as reviewer. |
Fix gnolang#817 There was actually 2 bugs in the code responsible for loading a map from the state: - `UnmarshalAmino` doesn't check that `ml.Tail` is nil before accessing it. It is correctly done for instance in `MapList.Append` for instance. The fix just ensures that `ml.Tail` is not nil. - `fillTypesOfValue` which is called just after the store data is unmarshalSized, resets the map data by calling `MapValue.MakeMap()`. So at the end the map is always empty, whatever was stored before the transaction. The fix replaces the call of `MakeMap` to a simple map creation. This has to be confirmed, but this change may also fix gnolang#311, because I'm not convinced that the indetermenistic behavior of the golang map can be a problem when saved to the store. Indeed, a gno map is serialized with the help of a slice, which should remove any indetermenistic problem.
Fix gnolang#817 There was actually 2 bugs in the code responsible for loading a map from the state: - `UnmarshalAmino` doesn't check that `ml.Tail` is nil before accessing it. It is correctly done for instance in `MapList.Append` for instance. The fix just ensures that `ml.Tail` is not nil. - `fillTypesOfValue` which is called just after the store data is unmarshalSized, resets the map data by calling `MapValue.MakeMap()`. So at the end the map is always empty, whatever was stored before the transaction. The fix replaces the call of `MakeMap` to a simple map creation. This has to be confirmed, but this change may also fix gnolang#311, because I'm not convinced that the indetermenistic behavior of the golang map can be a problem when saved to the store. Indeed, a gno map is serialized with the help of a slice, which should remove any indetermenistic problem.
runtime error: invalid memory address or nil pointer dereference
Description
map disappears after first call(not sure this is exact explanation)
Your environment
master
branchmaster
branchSteps to reproduce
Deploy below package
run
gno test
works fine just like belowwhich prints
after addpkg, first maketx call works fine
but second maketx call fail
Expected behaviour
update map value
Actual behaviour
map disappears
Stack Trace
The text was updated successfully, but these errors were encountered: