Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: staking spec upgrades / some renaming #3357

Merged
merged 22 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/develop' into rigel/staking-spec…
…-upgradesx2
  • Loading branch information
rigelrozanski committed Feb 8, 2019
commit f712c60fe977b02ae6c65995c11e83fed380b5d6
7 changes: 0 additions & 7 deletions x/staking/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ func (k Keeper) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress,
}
}

// AfterValidatorPowerDidChange - call hook if registered
func (k Keeper) AfterValidatorPowerDidChange(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) {
if k.hooks != nil {
k.hooks.AfterValidatorPowerDidChange(ctx, consAddr, valAddr)
}
}

// AfterValidatorBeginUnbonding - call hook if registered
func (k Keeper) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) {
if k.hooks != nil {
Expand Down
6 changes: 1 addition & 5 deletions x/staking/keeper/val_state_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab
if !found || !bytes.Equal(oldPowerBytes, newPowerBytes) {
updates = append(updates, validator.ABCIValidatorUpdate())

// Assert that the validator had updated its ValidatorDistInfo.FeePoolWithdrawalHeight.
// This hook is extremely useful, otherwise lazy accum bugs will be difficult to solve.
k.AfterValidatorPowerDidChange(ctx, validator.ConsAddress(), valAddr)

// set validator power on lookup index.
// set validator power on lookup index
k.SetLastValidatorPower(ctx, valAddr, newPower)
}

Expand Down
3 changes: 3 additions & 0 deletions x/staking/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.ValAddress) {
if validator.Tokens.IsPositive() {
panic("attempting to remove a validator which still contains tokens")
}
if validator.Tokens.GT(sdk.ZeroInt()) {
panic("validator being removed should never have positive tokens")
}

// delete the old validator record
store := ctx.KVStore(k.storeKey)
Expand Down
8 changes: 3 additions & 5 deletions x/staking/keeper/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,9 @@ func TestValidatorBasics(t *testing.T) {
"attempting to remove a validator which still contains tokens",
func() { keeper.RemoveValidator(ctx, validators[1].OperatorAddr) })

validators[1].Tokens = sdk.ZeroInt()
keeper.SetValidator(ctx, validators[1])

// now it can be removed
keeper.RemoveValidator(ctx, validators[1].OperatorAddr)
validators[1].Tokens = sdk.ZeroInt() // ...remove all tokens
keeper.SetValidator(ctx, validators[1]) // ...set the validator
keeper.RemoveValidator(ctx, validators[1].OperatorAddr) // Now it can be removed.
_, found = keeper.GetValidator(ctx, addrVals[1])
require.False(t, found)
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.