fix(x/slashing): consensus failure after cons key rotation (#19038)
This commit is contained in:
parent
b98b6eb076
commit
eaf92c225c
@ -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 {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user