From 21f2896f8d097d205caab201aa87e318f603a17d Mon Sep 17 00:00:00 2001 From: Xuefeng Zhu Date: Mon, 14 Oct 2019 10:49:14 -0700 Subject: [PATCH] Merge PR #5157: Remove pubkey from slashing infraction log --- x/slashing/internal/keeper/infractions.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/x/slashing/internal/keeper/infractions.go b/x/slashing/internal/keeper/infractions.go index 9dafb40803..e71ccb7142 100644 --- a/x/slashing/internal/keeper/infractions.go +++ b/x/slashing/internal/keeper/infractions.go @@ -21,8 +21,7 @@ func (k Keeper) HandleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio // fetch the validator public key consAddr := sdk.ConsAddress(addr) - pubkey, err := k.GetPubkey(ctx, addr) - if err != nil { + if _, err := k.GetPubkey(ctx, addr); err != nil { // Ignore evidence that cannot be handled. // NOTE: // We used to panic with: @@ -38,7 +37,7 @@ func (k Keeper) HandleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio // Reject evidence if the double-sign is too old if age > k.MaxEvidenceAge(ctx) { logger.Info(fmt.Sprintf("Ignored double sign from %s at height %d, age of %d past max age of %d", - sdk.ConsAddress(pubkey.Address()), infractionHeight, age, k.MaxEvidenceAge(ctx))) + consAddr, infractionHeight, age, k.MaxEvidenceAge(ctx))) return } @@ -59,12 +58,12 @@ func (k Keeper) HandleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio // validator is already tombstoned if signInfo.Tombstoned { - logger.Info(fmt.Sprintf("Ignored double sign from %s at height %d, validator already tombstoned", sdk.ConsAddress(pubkey.Address()), infractionHeight)) + logger.Info(fmt.Sprintf("Ignored double sign from %s at height %d, validator already tombstoned", consAddr, infractionHeight)) return } // double sign confirmed - logger.Info(fmt.Sprintf("Confirmed double sign from %s at height %d, age of %d", sdk.ConsAddress(pubkey.Address()), infractionHeight, age)) + logger.Info(fmt.Sprintf("Confirmed double sign from %s at height %d, age of %d", consAddr, infractionHeight, age)) // We need to retrieve the stake distribution which signed the block, so we subtract ValidatorUpdateDelay from the evidence height. // Note that this *can* result in a negative "distributionHeight", up to -ValidatorUpdateDelay, @@ -119,8 +118,7 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr crypto.Address, p // fetch the validator public key consAddr := sdk.ConsAddress(addr) - pubkey, err := k.GetPubkey(ctx, addr) - if err != nil { + if _, err := k.GetPubkey(ctx, addr); err != nil { panic(fmt.Sprintf("Validator consensus-address %s not found", consAddr)) } @@ -164,7 +162,7 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr crypto.Address, p ) logger.Info( - fmt.Sprintf("Absent validator %s (%s) at height %d, %d missed, threshold %d", consAddr, pubkey, height, signInfo.MissedBlocksCounter, k.MinSignedPerWindow(ctx))) + fmt.Sprintf("Absent validator %s at height %d, %d missed, threshold %d", consAddr, height, signInfo.MissedBlocksCounter, k.MinSignedPerWindow(ctx))) } minHeight := signInfo.StartHeight + k.SignedBlocksWindow(ctx)