fix(x/slashing): consensus failure after cons key rotation (#19038)

This commit is contained in:
atheeshp
2024-01-12 14:42:26 +00:00
committed by GitHub
parent b98b6eb076
commit eaf92c225c
3 changed files with 17 additions and 3 deletions
+10 -2
View File
@@ -32,15 +32,23 @@ func (k Keeper) HandleValidatorSignatureWithParams(ctx context.Context, params t
consAddr := sdk.ConsAddress(addr)
// don't update missed blocks when validator's jailed
isJailed, err := k.sk.IsValidatorJailed(ctx, consAddr)
val, err := k.sk.ValidatorByConsAddr(ctx, consAddr)
if err != nil {
return err
}
if isJailed {
if val.IsJailed() {
return nil
}
// read the cons address again because validator may've rotated it's key
valConsAddr, err := val.GetConsAddr()
if err != nil {
return err
}
consAddr = sdk.ConsAddress(valConsAddr)
// fetch signing info
signInfo, err := k.ValidatorSigningInfo.Get(ctx, consAddr)
if err != nil {
+6
View File
@@ -252,6 +252,12 @@ func (k Keeper) performConsensusPubKeyUpdate(ctx context.Context, oldPubKey, new
return types.ErrInvalidConsPubKey.Wrap("failed to get signing info for old public key")
}
consAddr, err := k.sk.ConsensusAddressCodec().BytesToString(newPubKey.Address())
if err != nil {
return err
}
signingInfo.Address = consAddr
if err := k.ValidatorSigningInfo.Set(ctx, sdk.ConsAddress(newPubKey.Address()), signingInfo); err != nil {
return err
}
+1 -1
View File
@@ -124,7 +124,7 @@ func (s *KeeperTestSuite) TestPerformConsensusPubKeyUpdate() {
newConsAddr := sdk.ConsAddress(pks[1].Address())
newInfo := slashingtypes.NewValidatorSigningInfo(
oldConsAddr.String(),
newConsAddr.String(),
int64(4),
int64(3),
time.Unix(2, 0).UTC(),