Browse Source

sui/guardian: more informative error messages

Josh Siegel 2 years ago
parent
commit
04b0018cfe
1 changed files with 8 additions and 9 deletions
  1. 8 9
      node/pkg/watchers/sui/watcher.go

+ 8 - 9
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