From 1b1996e0d2f508e11aeef1e107db877105ead215 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Tue, 3 May 2022 19:06:09 +0000 Subject: [PATCH] fix(tss): fix validator key query (#1461) --- cmd/axelard/cmd/vald/tss/tss.go | 4 ++++ x/tss/keeper/grpc_query.go | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/axelard/cmd/vald/tss/tss.go b/cmd/axelard/cmd/vald/tss/tss.go index e1e61971f..ccb23900a 100644 --- a/cmd/axelard/cmd/vald/tss/tss.go +++ b/cmd/axelard/cmd/vald/tss/tss.go @@ -213,6 +213,10 @@ func (mgr *Mgr) RefreshKeys(ctx context.Context) error { mgr.Keys = make(map[string][][]byte, len(valKeysResponse.Keys)) for keyID, keys := range valKeysResponse.Keys { + if len(keys.Keys) == 0 { + return fmt.Errorf("received no keys for key id %s", keyID) + } + mgr.Logger.Info(fmt.Sprintf("retrieved key %s", keyID)) mgr.Keys[keyID] = keys.Keys } diff --git a/x/tss/keeper/grpc_query.go b/x/tss/keeper/grpc_query.go index 43be98a18..02b64c259 100644 --- a/x/tss/keeper/grpc_query.go +++ b/x/tss/keeper/grpc_query.go @@ -114,15 +114,15 @@ func (q Querier) getSerializedMultisigKeys(ctx sdk.Context, key exported.Key, va return nil, false } - pubkeys, ok := q.keeper.GetMultisigPubKeysByValidator(ctx, key.ID, valAddress) - if !ok { + pubKeys, ok := q.keeper.GetMultisigPubKeysByValidator(ctx, key.ID, valAddress) + if !ok || len(pubKeys) == 0 { return nil, false } - valKeys := make([][]byte, len(pubkeys)) + valKeys := make([][]byte, len(pubKeys)) - for i, pubkey := range pubkeys { - wrappedKey := btcec.PublicKey(pubkey) + for i, pubKey := range pubKeys { + wrappedKey := btcec.PublicKey(pubKey) valKeys[i] = wrappedKey.SerializeCompressed() }