From a69764f9f01b3bda466a990ae4a83a667bce1957 Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Fri, 25 Mar 2022 19:19:03 +0530 Subject: [PATCH] chore: Better error msgs when node isn't synced (#11449) * better err msg by checking node height * get node sync info and check for catching up * small fix * small fix * fix test * add changelog Co-authored-by: Marko --- CHANGELOG.md | 1 + x/auth/client/cli/query.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeafa2d1e..b13f496a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -170,6 +170,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* [\#11449](https://github.com/cosmos/cosmos-sdk/pull/11449) Improved error messages when node isn't synced. * [\#11349](https://github.com/cosmos/cosmos-sdk/pull/11349) Add `RegisterAminoMsg` function that checks that a msg name is <40 chars (else this would break ledger nano signing) then registers the concrete msg type with amino, it should be used for registering `sdk.Msg`s with amino instead of `cdc.RegisterConcrete`. * [\#11089](https://github.com/cosmos/cosmos-sdk/pull/11089]) Now cosmos-sdk consumers can upgrade gRPC to its newest versions. * [\#10439](https://github.com/cosmos/cosmos-sdk/pull/10439) Check error for `RegisterQueryHandlerClient` in all modules `RegisterGRPCGatewayRoutes`. diff --git a/x/auth/client/cli/query.go b/x/auth/client/cli/query.go index 08b4a3d1e..41fd652dc 100644 --- a/x/auth/client/cli/query.go +++ b/x/auth/client/cli/query.go @@ -100,6 +100,18 @@ func GetAccountCmd() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) res, err := queryClient.Account(cmd.Context(), &types.QueryAccountRequest{Address: key.String()}) if err != nil { + node, err2 := clientCtx.GetNode() + if err2 != nil { + return err2 + } + status, err2 := node.Status(context.Background()) + if err2 != nil { + return err2 + } + catchingUp := status.SyncInfo.CatchingUp + if !catchingUp { + return errors.Wrapf(err, "your node may be syncing, please check node status using `/status`") + } return err }