-
Notifications
You must be signed in to change notification settings - Fork 341
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 package variable breaks the contract execution without exception #311
Comments
Golang's team intentionally made it random, starting with Go 1, to make developers not rely on it. Protobuf also specifies that they have fewer guarantees and implements them as slices of structs on the wire. And on a side note, some web2 CTO friends added linters to prevent their teams from using maps. Even in web2, indeterministic maps were too confusing with flappy unit tests or bugs discovered in production. They told me that maps are generally deficient in performance, not only in go. But please, keep this comment as a hint and not a fact. My current feeling:
|
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.
The maptest contract does not return anything when Deposit() is called a second time. The contract seems to have stopped executing before the return but no panic or exception.
The text was updated successfully, but these errors were encountered: