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

perf: don't double unmarshal validator #615

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
}
Loading