From 04b0018cfeb86a7b43157452ff9474421e064372 Mon Sep 17 00:00:00 2001 From: Josh Siegel Date: Tue, 17 Jan 2023 13:46:55 +0000 Subject: [PATCH] sui/guardian: more informative error messages --- node/pkg/watchers/sui/watcher.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/node/pkg/watchers/sui/watcher.go b/node/pkg/watchers/sui/watcher.go index cfc4da89f..9f97833f0 100644 --- a/node/pkg/watchers/sui/watcher.go +++ b/node/pkg/watchers/sui/watcher.go @@ -314,14 +314,14 @@ func (e *Watcher) Run(ctx context.Context) error { resp, err := http.Post(e.suiRPC, "application/json", strings.NewReader(buf)) if err != nil { - logger.Error(e.suiRPC, zap.Error(err)) + logger.Error("getEvents API failed", zap.String("suiRPC", e.suiRPC), zap.Error(err)) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1) continue } body, err := io.ReadAll(resp.Body) if err != nil { - logger.Error(e.suiRPC, zap.Error(err)) + logger.Error("unexpected truncated body when calling getEvents", zap.Error(err)) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1) continue @@ -333,7 +333,7 @@ func (e *Watcher) Run(ctx context.Context) error { var res SuiTxnQuery err = json.Unmarshal(body, &res) if err != nil { - logger.Error(e.suiRPC, zap.Error(err)) + logger.Error("failed to unmarshal event message", zap.Error(err)) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1) continue @@ -342,9 +342,8 @@ func (e *Watcher) Run(ctx context.Context) error { for _, chunk := range res.Result.Data { err := e.inspectBody(logger, chunk) if err != nil { - logger.Error(e.suiRPC, zap.Error(err)) + logger.Error("unspected error while parsing chunk data in event", zap.Error(err)) } - } case msg := <-pumpData: logger.Info("receive", zap.String("body", string(msg))) @@ -352,7 +351,7 @@ func (e *Watcher) Run(ctx context.Context) error { var res SuiEventMsg err = json.Unmarshal(msg, &res) if err != nil { - logger.Error("Unmarshal", zap.String("body", string(msg)), zap.Error(err)) + logger.Error("Failed to unmarshal SuiEventMsg", zap.String("body", string(msg)), zap.Error(err)) continue } if res.Error != nil { @@ -378,14 +377,14 @@ func (e *Watcher) Run(ctx context.Context) error { case <-timer.C: resp, err := http.Post(e.suiRPC, "application/json", strings.NewReader(`{"jsonrpc":"2.0", "id": 1, "method": "sui_getCommitteeInfo", "params": []}`)) if err != nil { - logger.Error(fmt.Sprintf("sui_getCommitteeInfo: %s", err.Error())) + logger.Error("sui_getCommitteeInfo failed", zap.Error(err)) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1) break } body, err := io.ReadAll(resp.Body) if err != nil { - logger.Error(fmt.Sprintf("sui_getCommitteeInfo: %s", err.Error())) + logger.Error("sui_getCommitteeInfo failed", zap.Error(err)) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1) break } @@ -394,7 +393,7 @@ func (e *Watcher) Run(ctx context.Context) error { var res SuiCommitteeInfo err = json.Unmarshal(body, &res) if err != nil { - logger.Error(e.suiRPC, zap.Error(err)) + logger.Error("unmarshal failed into SuiCommitteeInfo", zap.String("body", string(body)), zap.Error(err)) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1) continue