Skip to content

Commit

Permalink
Node/CCQ: Logging changes in watchers (#4173)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-riley authored Nov 27, 2024
1 parent 79946aa commit 5e07882
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
38 changes: 19 additions & 19 deletions node/pkg/watchers/evm/ccq.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (w *Watcher) ccqHandleEthCallQueryRequest(ctx context.Context, queryRequest
// Create the block query args.
blockMethod, callBlockArg, err := ccqCreateBlockRequest(block)
if err != nil {
w.ccqLogger.Error("invalid block id in eth_call query request",
w.ccqLogger.Info("invalid block id in eth_call query request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.Error(err),
Expand Down Expand Up @@ -131,7 +131,7 @@ func (w *Watcher) ccqHandleEthCallQueryRequest(ctx context.Context, queryRequest
defer cancel()
err = w.ethConn.RawBatchCallContext(timeout, batch)
if err != nil {
w.ccqLogger.Error("failed to process eth_call query request",
w.ccqLogger.Info("failed to process eth_call query request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.Any("batch", batch),
Expand All @@ -156,7 +156,7 @@ func (w *Watcher) ccqHandleEthCallQueryRequest(ctx context.Context, queryRequest
// Verify all the call results and build the batch of results.
results, err := w.ccqVerifyAndExtractQueryResults(requestId, evmCallData)
if err != nil {
w.ccqLogger.Error("failed to process eth_call query call request",
w.ccqLogger.Info("failed to process eth_call query call request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.Any("batch", batch),
Expand Down Expand Up @@ -201,7 +201,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q

// Verify that the two block hints are consistent, either both set, or both unset.
if (block == "") != (nextBlock == "") {
w.ccqLogger.Error("invalid block id hints in eth_call_by_timestamp query request, both should be either set or unset",
w.ccqLogger.Info("invalid block id hints in eth_call_by_timestamp query request, both should be either set or unset",
zap.String("requestId", requestId),
zap.Uint64("timestamp", req.TargetTimestamp),
zap.String("block", block),
Expand All @@ -214,7 +214,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
// Look up the blocks based on the timestamp if necessary.
if block == "" {
if w.ccqTimestampCache == nil {
w.ccqLogger.Error("error in block id hints in eth_call_by_timestamp query request, they are unset and chain does not support timestamp caching")
w.ccqLogger.Info("error in block id hints in eth_call_by_timestamp query request, they are unset and chain does not support timestamp caching")
w.ccqSendQueryResponse(queryRequest, query.QueryFatalError, nil)
return
}
Expand All @@ -226,7 +226,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
status := query.QueryRetryNeeded
firstBlockNum, firstBlockTime, lastBlockNum, lastBlockTime := w.ccqTimestampCache.GetRange()
if nextBlockNum == 0 {
w.ccqLogger.Warn("block look up failed in eth_call_by_timestamp query request, timestamp beyond the end of the cache, will wait and retry",
w.ccqLogger.Info("block look up failed in eth_call_by_timestamp query request, timestamp beyond the end of the cache, will wait and retry",
zap.String("requestId", requestId),
zap.Uint64("timestamp", req.TargetTimestamp),
zap.String("block", block),
Expand All @@ -240,7 +240,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
zap.Uint64("lastBlockTime", lastBlockTime),
)
} else if blockNum == 0 {
w.ccqLogger.Error("block look up failed in eth_call_by_timestamp query request, timestamp too old, failing request",
w.ccqLogger.Info("block look up failed in eth_call_by_timestamp query request, timestamp too old, failing request",
zap.String("requestId", requestId),
zap.Uint64("timestamp", req.TargetTimestamp),
zap.String("block", block),
Expand All @@ -255,7 +255,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
)
status = query.QueryFatalError
} else if w.ccqBackfillCache {
w.ccqLogger.Warn("block look up failed in eth_call_by_timestamp query request, timestamp is in a gap in the cache, will request a backfill and retry",
w.ccqLogger.Info("block look up failed in eth_call_by_timestamp query request, timestamp is in a gap in the cache, will request a backfill and retry",
zap.String("requestId", requestId),
zap.Uint64("timestamp", req.TargetTimestamp),
zap.String("block", block),
Expand All @@ -270,7 +270,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
)
w.ccqRequestBackfill(timestampForCache)
} else {
w.ccqLogger.Error("block look up failed in eth_call_by_timestamp query request, timestamp is in a gap in the cache, failing request",
w.ccqLogger.Info("block look up failed in eth_call_by_timestamp query request, timestamp is in a gap in the cache, failing request",
zap.String("requestId", requestId),
zap.Uint64("timestamp", req.TargetTimestamp),
zap.String("block", block),
Expand Down Expand Up @@ -305,7 +305,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
// Create the query args for both blocks.
blockMethod, callBlockArg, err := ccqCreateBlockRequest(block)
if err != nil {
w.ccqLogger.Error("invalid target block id hint in eth_call_by_timestamp query request",
w.ccqLogger.Info("invalid target block id hint in eth_call_by_timestamp query request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.String("nextBlock", nextBlock),
Expand All @@ -317,7 +317,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q

nextBlockMethod, _, err := ccqCreateBlockRequest(nextBlock)
if err != nil {
w.ccqLogger.Error("invalid following block id hint in eth_call_by_timestamp query request",
w.ccqLogger.Info("invalid following block id hint in eth_call_by_timestamp query request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.String("nextBlock", nextBlock),
Expand Down Expand Up @@ -362,7 +362,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
defer cancel()
err = w.ethConn.RawBatchCallContext(timeout, batch)
if err != nil {
w.ccqLogger.Error("failed to process eth_call_by_timestamp query request",
w.ccqLogger.Info("failed to process eth_call_by_timestamp query request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.String("nextBlock", nextBlock),
Expand Down Expand Up @@ -413,7 +413,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
followingTimestamp := uint64(nextBlockResult.Time * 1000000)

if targetBlockNum+1 != followingBlockNum {
w.ccqLogger.Error("eth_call_by_timestamp query blocks are not adjacent",
w.ccqLogger.Info("eth_call_by_timestamp query blocks are not adjacent",
zap.String("requestId", requestId),
zap.Uint64("desiredTimestamp", req.TargetTimestamp),
zap.Uint64("targetTimestamp", targetTimestamp),
Expand All @@ -430,7 +430,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
}

if req.TargetTimestamp < targetTimestamp || req.TargetTimestamp >= followingTimestamp {
w.ccqLogger.Error("eth_call_by_timestamp desired timestamp falls outside of block range",
w.ccqLogger.Info("eth_call_by_timestamp desired timestamp falls outside of block range",
zap.String("requestId", requestId),
zap.Uint64("desiredTimestamp", req.TargetTimestamp),
zap.Uint64("targetTimestamp", targetTimestamp),
Expand All @@ -449,7 +449,7 @@ func (w *Watcher) ccqHandleEthCallByTimestampQueryRequest(ctx context.Context, q
// Verify all the call results and build the batch of results.
results, err := w.ccqVerifyAndExtractQueryResults(requestId, evmCallData)
if err != nil {
w.ccqLogger.Error("failed to process eth_call_by_timestamp query call request",
w.ccqLogger.Info("failed to process eth_call_by_timestamp query call request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.String("nextBlock", nextBlock),
Expand Down Expand Up @@ -502,7 +502,7 @@ func (w *Watcher) ccqHandleEthCallWithFinalityQueryRequest(ctx context.Context,
// Validate the requested finality.
safeMode := req.Finality == "safe"
if req.Finality != "finalized" && !safeMode {
w.ccqLogger.Error("invalid finality in eth_call_with_finality query request",
w.ccqLogger.Info("invalid finality in eth_call_with_finality query request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.String("finality", req.Finality),
Expand All @@ -514,7 +514,7 @@ func (w *Watcher) ccqHandleEthCallWithFinalityQueryRequest(ctx context.Context,
// Create the block query args.
blockMethod, callBlockArg, err := ccqCreateBlockRequest(block)
if err != nil {
w.ccqLogger.Error("invalid block id in eth_call_with_finality query request",
w.ccqLogger.Info("invalid block id in eth_call_with_finality query request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.Error(err),
Expand Down Expand Up @@ -545,7 +545,7 @@ func (w *Watcher) ccqHandleEthCallWithFinalityQueryRequest(ctx context.Context,
defer cancel()
err = w.ethConn.RawBatchCallContext(timeout, batch)
if err != nil {
w.ccqLogger.Error("failed to process eth_call_with_finality query request",
w.ccqLogger.Info("failed to process eth_call_with_finality query request",
zap.String("requestId", requestId),
zap.String("block", block),
zap.Any("batch", batch),
Expand Down Expand Up @@ -593,7 +593,7 @@ func (w *Watcher) ccqHandleEthCallWithFinalityQueryRequest(ctx context.Context,
// Verify all the call results and build the batch of results.
results, err := w.ccqVerifyAndExtractQueryResults(requestId, evmCallData)
if err != nil {
w.ccqLogger.Error("failed to process eth_call_with_finality query call request",
w.ccqLogger.Info("failed to process eth_call_with_finality query call request",
zap.String("requestId", requestId),
zap.String("finality", req.Finality),
zap.Uint64("requestedBlockNumber", blockNumber),
Expand Down
8 changes: 6 additions & 2 deletions node/pkg/watchers/solana/ccq.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (w *SolanaWatcher) ccqBaseHandleSolanaAccountQueryRequest(
// Return without posting a response because a go routine was created to handle it.
return
}
w.ccqLogger.Error(fmt.Sprintf("read failed for %s query request", tag),
w.ccqLogger.Info(fmt.Sprintf("read failed for %s query request", tag),
zap.String("requestId", requestId),
zap.Any("accounts", accounts),
zap.Any("params", params),
Expand Down Expand Up @@ -574,13 +574,17 @@ func ccqIsBlockNotAvailable(err error) bool {
/*
A "Block not available for slot" error looks like this:
"(*jsonrpc.RPCError)(0xc0208a0270)({\n Code: (int) -32004,\n Message: (string) (len=38) \"Block not available for slot 282135928\",\n Data: (interface {}) <nil>\n})\n"
A "Minimum context slot has not been reached" error looks like this:
(*jsonrpc.RPCError)(0xc21e4f8ea0)({\n Code: (int) -32016,\n Message: (string) (len=41) \"Minimum context slot has not been reached\",\n Data: (map[string]interface {}) (len=1) {\n (string) (len=11) \"contextSlot\": (json.Number) (len=9) \"303955907\"\n }\n})\n"
*/
var rpcErr *jsonrpc.RPCError
if !errors.As(err, &rpcErr) {
return false // Some other kind of error.
}

if rpcErr.Code != -32004 { // Block not available for slot
if rpcErr.Code != -32004 && // Block not available for slot
rpcErr.Code != -32016 { // Minimum context slot has not been reached
return false // Some other kind of RPC error.
}

Expand Down

0 comments on commit 5e07882

Please sign in to comment.