-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move simulation params back to modules (#4839)
move simulation params back to modules (#4839)
- Loading branch information
Showing
14 changed files
with
271 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package simulation | ||
|
||
import "math/rand" | ||
|
||
// Simulation parameter constants | ||
const ( | ||
MaxMemoChars = "max_memo_characters" | ||
TxSigLimit = "tx_sig_limit" | ||
TxSizeCostPerByte = "tx_size_cost_per_byte" | ||
SigVerifyCostED25519 = "sig_verify_cost_ed25519" | ||
SigVerifyCostSECP256K1 = "sig_verify_cost_secp256k1" | ||
) | ||
|
||
// GenParams generates random auth parameters | ||
func GenParams(paramSims map[string]func(r *rand.Rand) interface{}) { | ||
paramSims[MaxMemoChars] = func(r *rand.Rand) interface{} { | ||
return uint64(RandIntBetween(r, 100, 200)) | ||
} | ||
|
||
paramSims[TxSigLimit] = func(r *rand.Rand) interface{} { | ||
return uint64(r.Intn(7) + 1) | ||
} | ||
|
||
paramSims[TxSizeCostPerByte] = func(r *rand.Rand) interface{} { | ||
return uint64(RandIntBetween(r, 5, 15)) | ||
} | ||
|
||
paramSims[SigVerifyCostED25519] = func(r *rand.Rand) interface{} { | ||
return uint64(RandIntBetween(r, 500, 1000)) | ||
} | ||
|
||
paramSims[SigVerifyCostSECP256K1] = func(r *rand.Rand) interface{} { | ||
return uint64(RandIntBetween(r, 500, 1000)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package simulation | ||
|
||
import "math/rand" | ||
|
||
// Simulation parameter constants | ||
const ( | ||
SendEnabled = "send_enabled" | ||
) | ||
|
||
// GenParams generates random bank parameters | ||
func GenParams(paramSims map[string]func(r *rand.Rand) interface{}) { | ||
paramSims[SendEnabled] = func(r *rand.Rand) interface{} { | ||
return r.Int63n(2) == 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package simulation | ||
|
||
import ( | ||
"math/rand" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
|
||
// Simulation parameter constants | ||
const ( | ||
CommunityTax = "community_tax" | ||
BaseProposerReward = "base_proposer_reward" | ||
BonusProposerReward = "bonus_proposer_reward" | ||
) | ||
|
||
// GenParams generates random distribution parameters | ||
func GenParams(paramSims map[string]func(r *rand.Rand) interface{}) { | ||
paramSims[CommunityTax] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(1, 2).Add(sdk.NewDecWithPrec(int64(r.Intn(30)), 2)) | ||
} | ||
|
||
paramSims[BaseProposerReward] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(1, 2).Add(sdk.NewDecWithPrec(int64(r.Intn(30)), 2)) | ||
} | ||
|
||
paramSims[BonusProposerReward] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(1, 2).Add(sdk.NewDecWithPrec(int64(r.Intn(30)), 2)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package simulation | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Simulation parameter constants | ||
const ( | ||
DepositParamsMinDeposit = "deposit_params_min_deposit" | ||
VotingParamsVotingPeriod = "voting_params_voting_period" | ||
TallyParamsQuorum = "tally_params_quorum" | ||
TallyParamsThreshold = "tally_params_threshold" | ||
TallyParamsVeto = "tally_params_veto" | ||
) | ||
|
||
// GenParams generates random gov parameters | ||
func GenParams(paramSims map[string]func(r *rand.Rand) interface{}) { | ||
paramSims[DepositParamsMinDeposit] = func(r *rand.Rand) interface{} { | ||
return sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, int64(RandIntBetween(r, 1, 1e3)))} | ||
} | ||
|
||
paramSims[VotingParamsVotingPeriod] = func(r *rand.Rand) interface{} { | ||
return time.Duration(RandIntBetween(r, 1, 2*60*60*24*2)) * time.Second | ||
} | ||
|
||
paramSims[TallyParamsQuorum] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(int64(RandIntBetween(r, 334, 500)), 3) | ||
} | ||
|
||
paramSims[TallyParamsThreshold] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(int64(RandIntBetween(r, 450, 550)), 3) | ||
} | ||
|
||
paramSims[TallyParamsVeto] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(int64(RandIntBetween(r, 250, 334)), 3) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package simulation | ||
|
||
import ( | ||
"math/rand" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Simulation parameter constants | ||
const ( | ||
InflationRateChange = "inflation_rate_change" | ||
Inflation = "inflation" | ||
InflationMax = "inflation_max" | ||
InflationMin = "inflation_min" | ||
GoalBonded = "goal_bonded" | ||
) | ||
|
||
// GenParams generates random gov parameters | ||
func GenParams(paramSims map[string]func(r *rand.Rand) interface{}) { | ||
paramSims[InflationRateChange] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(int64(r.Intn(99)), 2) | ||
} | ||
|
||
paramSims[Inflation] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(int64(r.Intn(99)), 2) | ||
} | ||
|
||
paramSims[InflationMax] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(20, 2) | ||
} | ||
|
||
paramSims[InflationMin] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(7, 2) | ||
} | ||
|
||
paramSims[GoalBonded] = func(r *rand.Rand) interface{} { | ||
return sdk.NewDecWithPrec(67, 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// nolint | ||
// autogenerated code using github.com/rigelrozanski/multitool | ||
// aliases generated for the following subdirectories: | ||
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/simulation/util | ||
package simulation | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/x/simulation/util" | ||
) | ||
|
||
var ( | ||
// functions aliases | ||
RandStringOfLength = util.RandStringOfLength | ||
RandPositiveInt = util.RandPositiveInt | ||
RandomAmount = util.RandomAmount | ||
RandomDecAmount = util.RandomDecAmount | ||
RandTimestamp = util.RandTimestamp | ||
RandIntBetween = util.RandIntBetween | ||
DeriveRand = util.DeriveRand | ||
) |
Oops, something went wrong.