kava icon indicating copy to clipboard operation
kava copied to clipboard

Fix simulation param change encoding

Open rhuairahrighairidh opened this issue 4 years ago • 0 comments

In <module>/simulation/params.go params are generated, then formatted in strings. ie:

https://github.com/Kava-Labs/kava/blob/0949a912cfe0e24b6502760be68b9cb84e24dfb1/x/auction/simulation/params.go#L22

The string formatting is json marshalling the values. We should use the actual json marshaller. ie:

    return string(types.ModuleCdc.MustMarshalJSON(GenBidDuration(r)))

Background:

When these generated values (string types) are set in the params keeper (through the param gov handler) they're type cast to []byte then unmarshalled from json (using amino) , then validated, then marshalled back to json bytes and then set in the param store.

So the string formatting is effectively marshalling the types to json, which sounds like a bad idea.

Looking at v0.38 sdk modules. Whether they use quotes or not mirrors amino's decision to use quotes when marshalling to json.

rhuairahrighairidh avatar Apr 22 '20 19:04 rhuairahrighairidh