sui/guardian: more informative error messages
This commit is contained in:
parent
bf70827fe7
commit
04b0018cfe
|
@ -314,14 +314,14 @@ func (e *Watcher) Run(ctx context.Context) error {
|
||||||
|
|
||||||
resp, err := http.Post(e.suiRPC, "application/json", strings.NewReader(buf))
|
resp, err := http.Post(e.suiRPC, "application/json", strings.NewReader(buf))
|
||||||
if err != nil {
|
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)
|
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
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)
|
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ func (e *Watcher) Run(ctx context.Context) error {
|
||||||
var res SuiTxnQuery
|
var res SuiTxnQuery
|
||||||
err = json.Unmarshal(body, &res)
|
err = json.Unmarshal(body, &res)
|
||||||
if err != nil {
|
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)
|
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -342,9 +342,8 @@ func (e *Watcher) Run(ctx context.Context) error {
|
||||||
for _, chunk := range res.Result.Data {
|
for _, chunk := range res.Result.Data {
|
||||||
err := e.inspectBody(logger, chunk)
|
err := e.inspectBody(logger, chunk)
|
||||||
if err != nil {
|
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:
|
case msg := <-pumpData:
|
||||||
logger.Info("receive", zap.String("body", string(msg)))
|
logger.Info("receive", zap.String("body", string(msg)))
|
||||||
|
@ -352,7 +351,7 @@ func (e *Watcher) Run(ctx context.Context) error {
|
||||||
var res SuiEventMsg
|
var res SuiEventMsg
|
||||||
err = json.Unmarshal(msg, &res)
|
err = json.Unmarshal(msg, &res)
|
||||||
if err != nil {
|
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
|
continue
|
||||||
}
|
}
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
|
@ -378,14 +377,14 @@ func (e *Watcher) Run(ctx context.Context) error {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
resp, err := http.Post(e.suiRPC, "application/json", strings.NewReader(`{"jsonrpc":"2.0", "id": 1, "method": "sui_getCommitteeInfo", "params": []}`))
|
resp, err := http.Post(e.suiRPC, "application/json", strings.NewReader(`{"jsonrpc":"2.0", "id": 1, "method": "sui_getCommitteeInfo", "params": []}`))
|
||||||
if err != nil {
|
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)
|
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1)
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
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)
|
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -394,7 +393,7 @@ func (e *Watcher) Run(ctx context.Context) error {
|
||||||
var res SuiCommitteeInfo
|
var res SuiCommitteeInfo
|
||||||
err = json.Unmarshal(body, &res)
|
err = json.Unmarshal(body, &res)
|
||||||
if err != nil {
|
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)
|
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSui, 1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue