Merge PR #2365: Validator Commission Model
* Update validator commission fields * Remove CommissionChangeToday and update to use CommissionChangeTime * Implement commission as a first class citizen type * Implement stringer for Comission * Move commission type and logic to new file * Add new commission errors * Add commission to create validator message * Implement and call UpdateValidatorCommission * Update godoc for UpdateValidatorCommission * Add Abs to the decimal type * Implement new SetValidatorCommission * Update decimal short godocs * Move set initial commission logic * Move initial commission validation to Commission type * Update initial validator commission logic and unit tests * Remove commission update time from struct and move to validator * Update validator create handler tests * Implement commission logic for CLI * Fix make lint failure * Fix make cover failure * Update edit validator logic to handle new commission rate * Fix lint and cover * Update create/edit validator simulation to include commission params * Update MsgEditValidator godoc * Update pending log * Update staking tx docs * Fix CLI create validator test * Update variables names for commission strings * Merge UpdateTime into Commission type * Update create-validator usage in docs * Update more docs with examples * More doc updates
This commit is contained in:
committed by
Rigel
parent
8774adc7de
commit
9dafa3252d
@@ -23,32 +23,48 @@ func SimulateMsgCreateValidator(m auth.AccountMapper, k stake.Keeper) simulation
|
||||
description := stake.Description{
|
||||
Moniker: simulation.RandStringOfLength(r, 10),
|
||||
}
|
||||
|
||||
maxCommission := sdk.NewInt(10)
|
||||
commission := stake.NewCommissionMsg(
|
||||
sdk.NewDecWithPrec(simulation.RandomAmount(r, maxCommission).Int64(), 1),
|
||||
sdk.NewDecWithPrec(simulation.RandomAmount(r, maxCommission).Int64(), 1),
|
||||
sdk.NewDecWithPrec(simulation.RandomAmount(r, maxCommission).Int64(), 1),
|
||||
)
|
||||
|
||||
key := simulation.RandomKey(r, keys)
|
||||
pubkey := key.PubKey()
|
||||
address := sdk.ValAddress(pubkey.Address())
|
||||
amount := m.GetAccount(ctx, sdk.AccAddress(address)).GetCoins().AmountOf(denom)
|
||||
|
||||
if amount.GT(sdk.ZeroInt()) {
|
||||
amount = simulation.RandomAmount(r, amount)
|
||||
}
|
||||
|
||||
if amount.Equal(sdk.ZeroInt()) {
|
||||
return "no-operation", nil, nil
|
||||
}
|
||||
|
||||
msg := stake.MsgCreateValidator{
|
||||
Description: description,
|
||||
Commission: commission,
|
||||
ValidatorAddr: address,
|
||||
DelegatorAddr: sdk.AccAddress(address),
|
||||
PubKey: pubkey,
|
||||
Delegation: sdk.NewCoin(denom, amount),
|
||||
}
|
||||
|
||||
if msg.ValidateBasic() != nil {
|
||||
return "", nil, fmt.Errorf("expected msg to pass ValidateBasic: %s", msg.GetSignBytes())
|
||||
}
|
||||
|
||||
ctx, write := ctx.CacheContext()
|
||||
result := handler(ctx, msg)
|
||||
if result.IsOK() {
|
||||
write()
|
||||
}
|
||||
|
||||
event(fmt.Sprintf("stake/MsgCreateValidator/%v", result.IsOK()))
|
||||
|
||||
// require.True(t, result.IsOK(), "expected OK result but instead got %v", result)
|
||||
action = fmt.Sprintf("TestMsgCreateValidator: ok %v, msg %s", result.IsOK(), msg.GetSignBytes())
|
||||
return action, nil, nil
|
||||
@@ -66,16 +82,24 @@ func SimulateMsgEditValidator(k stake.Keeper) simulation.Operation {
|
||||
Website: simulation.RandStringOfLength(r, 10),
|
||||
Details: simulation.RandStringOfLength(r, 10),
|
||||
}
|
||||
|
||||
maxCommission := sdk.NewInt(10)
|
||||
newCommissionRate := sdk.NewDecWithPrec(simulation.RandomAmount(r, maxCommission).Int64(), 1)
|
||||
|
||||
key := simulation.RandomKey(r, keys)
|
||||
pubkey := key.PubKey()
|
||||
address := sdk.ValAddress(pubkey.Address())
|
||||
|
||||
msg := stake.MsgEditValidator{
|
||||
Description: description,
|
||||
ValidatorAddr: address,
|
||||
Description: description,
|
||||
ValidatorAddr: address,
|
||||
CommissionRate: &newCommissionRate,
|
||||
}
|
||||
|
||||
if msg.ValidateBasic() != nil {
|
||||
return "", nil, fmt.Errorf("expected msg to pass ValidateBasic: %s", msg.GetSignBytes())
|
||||
}
|
||||
|
||||
ctx, write := ctx.CacheContext()
|
||||
result := handler(ctx, msg)
|
||||
if result.IsOK() {
|
||||
|
||||
Reference in New Issue
Block a user