Merge PR #4244: Param Proposal Simulation Messages; Minting Params Fix

This commit is contained in:
Alexander Bezobchuk
2019-05-02 16:50:01 -04:00
committed by GitHub
parent 38f93128eb
commit 29ed730aff
9 changed files with 322 additions and 95 deletions
+72
View File
@@ -2,6 +2,9 @@ package simulation
import (
"math/rand"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
@@ -32,6 +35,75 @@ var (
{15, 92, 1},
{0, 3, 99},
})
// ModuleParamSimulator defines module parameter value simulators. All
// values simulated should be within valid acceptable range for the given
// parameter.
ModuleParamSimulator = map[string]func(r *rand.Rand) interface{}{
"MaxMemoCharacters": func(r *rand.Rand) interface{} {
return uint64(RandIntBetween(r, 100, 200))
},
"TxSigLimit": func(r *rand.Rand) interface{} {
return uint64(r.Intn(7) + 1)
},
"TxSizeCostPerByte": func(r *rand.Rand) interface{} {
return uint64(RandIntBetween(r, 5, 15))
},
"SigVerifyCostED25519": func(r *rand.Rand) interface{} {
return uint64(RandIntBetween(r, 500, 1000))
},
"SigVerifyCostSecp256k1": func(r *rand.Rand) interface{} {
return uint64(RandIntBetween(r, 500, 1000))
},
"DepositParams/MinDeposit": func(r *rand.Rand) interface{} {
return sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, int64(r.Intn(1e3)))}
},
"VotingParams/VotingPeriod": func(r *rand.Rand) interface{} {
return time.Duration(r.Intn(2*172800)) * time.Second
},
"TallyParams/Quorum": func(r *rand.Rand) interface{} {
return sdk.NewDecWithPrec(334, 3)
},
"TallyParams/Threshold": func(r *rand.Rand) interface{} {
return sdk.NewDecWithPrec(5, 1)
},
"TallyParams/Veto": func(r *rand.Rand) interface{} {
return sdk.NewDecWithPrec(334, 3)
},
"UnbondingTime": func(r *rand.Rand) interface{} {
return time.Duration(RandIntBetween(r, 60, 60*60*24*3*2)) * time.Second
},
"MaxValidators": func(r *rand.Rand) interface{} {
return uint16(r.Intn(250) + 1)
},
"SignedBlocksWindow": func(r *rand.Rand) interface{} {
return int64(RandIntBetween(r, 10, 1000))
},
"MinSignedPerWindow": func(r *rand.Rand) interface{} {
return sdk.NewDecWithPrec(int64(r.Intn(10)), 1)
},
"DowntimeJailDuration": func(r *rand.Rand) interface{} {
return time.Duration(RandIntBetween(r, 60, 60*60*24)) * time.Second
},
"SlashFractionDoubleSign": func(r *rand.Rand) interface{} {
return sdk.NewDec(1).Quo(sdk.NewDec(int64(r.Intn(50) + 1)))
},
"SlashFractionDowntime": func(r *rand.Rand) interface{} {
return sdk.NewDec(1).Quo(sdk.NewDec(int64(r.Intn(200) + 1)))
},
"InflationRateChange": func(r *rand.Rand) interface{} {
return sdk.NewDecWithPrec(int64(r.Intn(99)), 2)
},
"InflationMax": func(r *rand.Rand) interface{} {
return sdk.NewDecWithPrec(20, 2)
},
"InflationMin": func(r *rand.Rand) interface{} {
return sdk.NewDecWithPrec(7, 2)
},
"GoalBonded": func(r *rand.Rand) interface{} {
return sdk.NewDecWithPrec(67, 2)
},
}
)
// Simulation parameters