From 47849430eab71ee5f02880b2e474fc0c43dec7ac Mon Sep 17 00:00:00 2001 From: Philip Offtermatt Date: Wed, 12 Jun 2024 09:29:44 +0200 Subject: [PATCH] Handle case where topN is not found --- x/ccv/provider/keeper/grpc_query.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index eaae7b0f69..b1a5b36dcd 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -66,10 +66,15 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, chainID string) (types.Chain, } topN, found := k.GetTopN(ctx, chainID) + if !found { + k.Logger(ctx).Error("failed to get top N, treating as 0", "chain", chainID) + topN = 0 + } // Get the minimal power in the top N for the consumer chain minPowerInTopN, found := k.GetMinimumPowerInTopN(ctx, chainID) if !found { + k.Logger(ctx).Error("failed to get minimum power in top N, treating as -1", "chain", chainID) minPowerInTopN = -1 }