Merge PR #4403: Paramchange proposal skips omitempty fields
This commit is contained in:
committed by
Alexander Bezobchuk
parent
8fecc7724b
commit
91e75cb74a
@@ -1,6 +1,7 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
@@ -26,8 +27,6 @@ func (spc simParamChange) compKey() string {
|
||||
// paramChangePool defines a static slice of possible simulated parameter changes
|
||||
// where each simParamChange corresponds to a ParamChange with a simValue
|
||||
// function to generate a simulated new value.
|
||||
//
|
||||
// TODO: governance parameters (blocked on an upgrade to go-amino)
|
||||
var paramChangePool = []simParamChange{
|
||||
// staking parameters
|
||||
{
|
||||
@@ -80,6 +79,55 @@ var paramChangePool = []simParamChange{
|
||||
return fmt.Sprintf("\"%s\"", simulation.ModuleParamSimulator["InflationRateChange"](r).(sdk.Dec))
|
||||
},
|
||||
},
|
||||
// gov parameters
|
||||
{
|
||||
"gov",
|
||||
"votingparams",
|
||||
"",
|
||||
func(r *rand.Rand) string {
|
||||
return fmt.Sprintf(`{"voting_period": "%d"}`, simulation.ModuleParamSimulator["VotingParams/VotingPeriod"](r).(time.Duration))
|
||||
},
|
||||
},
|
||||
{
|
||||
"gov",
|
||||
"depositparams",
|
||||
"",
|
||||
func(r *rand.Rand) string {
|
||||
return fmt.Sprintf(`{"max_deposit_period": "%d"}`, simulation.ModuleParamSimulator["VotingParams/VotingPeriod"](r).(time.Duration))
|
||||
},
|
||||
},
|
||||
{
|
||||
"gov",
|
||||
"tallyparams",
|
||||
"",
|
||||
func(r *rand.Rand) string {
|
||||
changes := []struct {
|
||||
key string
|
||||
value sdk.Dec
|
||||
}{
|
||||
{"quorum", simulation.ModuleParamSimulator["TallyParams/Quorum"](r).(sdk.Dec)},
|
||||
{"threshold", simulation.ModuleParamSimulator["TallyParams/Threshold"](r).(sdk.Dec)},
|
||||
{"veto", simulation.ModuleParamSimulator["TallyParams/Veto"](r).(sdk.Dec)},
|
||||
}
|
||||
|
||||
pc := make(map[string]string)
|
||||
numChanges := simulation.RandIntBetween(r, 1, len(changes))
|
||||
for i := 0; i < numChanges; i++ {
|
||||
c := changes[r.Intn(len(changes))]
|
||||
|
||||
_, ok := pc[c.key]
|
||||
for ok {
|
||||
c := changes[r.Intn(len(changes))]
|
||||
_, ok = pc[c.key]
|
||||
}
|
||||
|
||||
pc[c.key] = c.value.String()
|
||||
}
|
||||
|
||||
bz, _ := json.Marshal(pc)
|
||||
return string(bz)
|
||||
},
|
||||
},
|
||||
// auth parameters
|
||||
{
|
||||
"auth",
|
||||
@@ -126,7 +174,7 @@ func SimulateParamChangeProposalContent(r *rand.Rand, _ *baseapp.BaseApp, _ sdk.
|
||||
}
|
||||
|
||||
paramChangesKeys[spc.compKey()] = struct{}{}
|
||||
paramChanges[i] = params.NewParamChange(spc.subspace, spc.key, spc.subkey, spc.simValue(r))
|
||||
paramChanges[i] = params.NewParamChangeWithSubkey(spc.subspace, spc.key, spc.subkey, spc.simValue(r))
|
||||
}
|
||||
|
||||
return params.NewParameterChangeProposal(
|
||||
|
||||
Reference in New Issue
Block a user