Skip to content

Commit

Permalink
demonstrate defensive accum height for zero-delegations
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelrozanski committed Nov 22, 2018
1 parent ccfbfcf commit b466775
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions x/distribution/types/delegator_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (di DelegationDistInfo) WithdrawRewards(wc WithdrawContext, vi ValidatorDis
vi = vi.UpdateTotalDelAccum(wc.Height, totalDelShares)

if vi.DelAccum.Accum.IsZero() {
di.DelPoolWithdrawalHeight = wc.Height
return di, vi, fp, DecCoins{}
}

Expand Down
6 changes: 3 additions & 3 deletions x/stake/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,9 @@ func (k Keeper) BeginRedelegation(ctx sdk.Context, delAddr sdk.AccAddress,
}

rounded := returnAmount.TruncateInt()
if rounded.IsZero() { //TODO design consideration
return types.Redelegation{}, types.ErrVerySmallRedelegation(k.Codespace())
}
//if rounded.IsZero() { //TODO design consideration
//return types.Redelegation{}, types.ErrVerySmallRedelegation(k.Codespace())
//}
returnCoin := sdk.NewCoin(k.BondDenom(ctx), rounded)
change := returnAmount.Sub(sdk.NewDecFromInt(rounded))

Expand Down
8 changes: 4 additions & 4 deletions x/stake/simulation/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func AllInvariants(ck bank.Keeper, k stake.Keeper,
return err
}

err = PositiveDelegationInvariant(k)(app)
if err != nil {
return err
}
//err = PositiveDelegationInvariant(k)(app)
//if err != nil {
//return err
//}

err = DelegatorSharesInvariant(k)(app)
if err != nil {
Expand Down

0 comments on commit b466775

Please sign in to comment.