Skip to content

Commit ed1e03f

Browse files
committed
add debug logs
1 parent c8b0659 commit ed1e03f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

code/go/0chain.net/blobbercore/challenge/protocol.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func (cr *ChallengeEntity) LoadValidationTickets(ctx context.Context) error {
8383
// unlocking it as it will be locked for longer time and handler.CommitWrite
8484
// will fail.
8585
allocMu := lock.GetMutex(allocation.Allocation{}.TableName(), cr.AllocationID)
86+
logging.Logger.Debug("[challenge]load: ", zap.String("challenge_id", cr.ChallengeID), zap.String("allocation_id", cr.AllocationID))
8687
allocMu.RLock()
8788

8889
allocationObj, err := allocation.Repo.GetAllocationFromDB(ctx, cr.AllocationID)
@@ -105,15 +106,15 @@ func (cr *ChallengeEntity) LoadValidationTickets(ctx context.Context) error {
105106
var (
106107
postData map[string]any
107108
)
108-
109+
logging.Logger.Debug("[challenge]getPost", zap.String("allocation_id", cr.AllocationID))
109110
if allocationObj.IsStorageV2() {
110111
postData, err = cr.getPostDataV2(ctx, allocationObj)
111112
} else {
112113
postData, err = cr.getPostData(ctx, allocationObj)
113114
}
114115
allocMu.RUnlock()
115116
if err != nil {
116-
logging.Logger.Error("[challenge]load: ", zap.String("challenge_id", cr.ChallengeID), zap.Error(err))
117+
logging.Logger.Error("[challenge]load: ", zap.String("challenge_id", cr.ChallengeID), zap.String("allocation_id", cr.AllocationID), zap.Error(err))
117118
cr.CancelChallenge(ctx, err)
118119
return err
119120
}
@@ -294,7 +295,7 @@ func (cr *ChallengeEntity) SaveChallengeResult(ctx context.Context, t *coreTxn.T
294295
func (cr *ChallengeEntity) getPostDataV2(ctx context.Context, allocationObj *allocation.Allocation) (map[string]any, error) {
295296
trie := allocationObj.GetTrie()
296297
copyTrie := wmpt.New(trie.CopyRoot(filestore.COLLAPSE_DEPTH), datastore.GetBlockStore())
297-
298+
logging.Logger.Info("[challenge]getPostDataV2: ", zap.String("allocation_id", cr.AllocationID))
298299
var (
299300
blockNum = int64(0)
300301
postData = make(map[string]interface{})
@@ -307,7 +308,7 @@ func (cr *ChallengeEntity) getPostDataV2(ctx context.Context, allocationObj *all
307308
blockNum = r.Int63n(int64(copyTrie.Weight()))
308309
blockNum++
309310
cr.BlockNum = blockNum
310-
logging.Logger.Info("[challenge]rand: ", zap.Uint64("trie.NumBlocks", trie.Weight()), zap.Any("blockNum", blockNum), zap.Any("challenge_id", cr.ChallengeID), zap.Any("random_seed", cr.RandomNumber))
311+
logging.Logger.Info("[challenge]rand: ", zap.Uint64("trie.NumBlocks", trie.Weight()), zap.Any("blockNum", blockNum), zap.Any("challenge_id", cr.ChallengeID), zap.Any("random_seed", cr.RandomNumber), zap.String("allocation_id", cr.AllocationID))
311312
key, objectProof, err := copyTrie.GetBlockProof(uint64(blockNum))
312313
if err != nil {
313314
return nil, err
@@ -330,6 +331,7 @@ func (cr *ChallengeEntity) getPostDataV2(ctx context.Context, allocationObj *all
330331
return nil, common.NewError("root_mismatch", "File meta root mismatch")
331332
}
332333
}
334+
logging.Logger.Debug("[challenge]getPostDataV2Block: ", zap.Any("blockNum", blockNum), zap.String("allocation_id", cr.AllocationID))
333335
cr.RespondedAllocationRoot = allocationObj.AllocationRoot
334336
if blockNum > 0 {
335337
r := rand.New(rand.NewSource(cr.RandomNumber))
@@ -385,6 +387,7 @@ func (cr *ChallengeEntity) getPostDataV2(ctx context.Context, allocationObj *all
385387

386388
return nil, err
387389
}
390+
logging.Logger.Debug("[challenge]getPostDataV2Return ", zap.Any("blockNum", blockNum), zap.String("allocation_id", cr.AllocationID))
388391
return postData, nil
389392
}
390393

code/go/0chain.net/blobbercore/handler/storage_handler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ func (fsh *StorageHandler) GetReferencePathV2(ctx context.Context, r *http.Reque
589589
case result := <-resCh:
590590
return result, nil
591591
case err := <-errCh:
592+
logging.Logger.Error("GetReferencePathV2", zap.Error(err))
592593
return nil, err
593594
}
594595

@@ -708,10 +709,11 @@ func (fsh *StorageHandler) getReferencePathV2(ctx context.Context, r *http.Reque
708709
return
709710
}
710711
allocMu := lock.GetMutex(allocation.Allocation{}.TableName(), allocationId)
712+
logging.Logger.Debug("getReferencePathV2Lock", zap.String("allocation_id", allocationId))
711713
allocMu.RLock()
712714
defer allocMu.RUnlock()
713715
now := time.Now()
714-
716+
logging.Logger.Debug("getTrie", zap.String("allocation_id", allocationId))
715717
trie := allocationObj.GetTrie()
716718
if trie == nil {
717719
errCh <- common.NewError("invalid_parameters", "Trie not found for allocation.")

0 commit comments

Comments
 (0)