Skip to content

Commit

Permalink
dont double unmarshal validator
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jun 19, 2024
1 parent df7a478 commit 5f72a2c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 31 deletions.
6 changes: 3 additions & 3 deletions x/gov/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions x/slashing/keeper/infractions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ func (k Keeper) HandleValidatorSignatureWithParams(ctx sdk.Context, params types
consAddr := sdk.ConsAddress(addr)

// don't update missed blocks when validator's jailed
if k.sk.IsValidatorJailed(ctx, consAddr) {
validator := k.sk.ValidatorByConsAddr(ctx, consAddr)
if validator.IsJailed() {
return
}

Expand Down Expand Up @@ -112,7 +113,6 @@ func (k Keeper) HandleValidatorSignatureWithParams(ctx sdk.Context, params types
// if we are past the minimum height and the validator has missed too many blocks, punish them
if height > minHeight && signInfo.MissedBlocksCounter > maxMissed {
modifiedSignInfo = true
validator := k.sk.ValidatorByConsAddr(ctx, consAddr)
if validator != nil && !validator.IsJailed() {
// Downtime confirmed: slash and jail the validator
// We need to retrieve the stake distribution which signed the block, so we subtract ValidatorUpdateDelay from the evidence height,
Expand Down
14 changes: 0 additions & 14 deletions x/slashing/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions x/slashing/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ type StakingKeeper interface {

// MaxValidators returns the maximum amount of bonded validators
MaxValidators(sdk.Context) uint32

// IsValidatorJailed returns if the validator is jailed.
IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool
}

// StakingHooks event hooks for staking validator object (noalias)
Expand Down
9 changes: 0 additions & 9 deletions x/staking/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,3 @@ func (k Keeper) UnbondAllMatureValidators(ctx sdk.Context) {
}
}
}

func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool {
v, ok := k.GetValidatorByConsAddr(ctx, addr)
if !ok {
return false
}

return v.Jailed
}

0 comments on commit 5f72a2c

Please sign in to comment.