Skip to content

Commit 596cefb

Browse files
committed
add log for block num
1 parent a5e5906 commit 596cefb

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ func (cr *ChallengeEntity) getPostDataV2(ctx context.Context, allocationObj *all
369369
}
370370
cr.RefID = ref.ID
371371
postData["object_proof"] = objectProof
372+
postData["block_num"] = blockNum
372373
fileMetaRootBytes := copyTrie.Root()
373374
fileMetaRoot := hex.EncodeToString(fileMetaRootBytes)
374375
if fileMetaRoot != allocationObj.FileMetaRoot {

code/go/0chain.net/validatorcore/storage/models.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ type ChallengeRequest struct {
309309
ObjectProof []byte `json:"object_proof"`
310310
Meta *RefMeta `json:"meta"`
311311
StorageVersion int `json:"storage_version"`
312+
BlockNum int64 `json:"block_num"`
312313
}
313314

314315
func (cr *ChallengeRequest) verifyBlockNum(challengeObj *Challenge) error {
@@ -458,6 +459,9 @@ func (cr *ChallengeRequest) verifyObjectProof(latestWM *writemarker.WriteMarker,
458459
r := rand.New(rand.NewSource(challengeRand))
459460
blockNum := r.Int63n(rootBlocks)
460461
blockNum++
462+
if blockNum != cr.BlockNum {
463+
return common.NewError("invalid_object_proof", fmt.Sprintf("Block num does not match with the challenge block num %d %d", cr.BlockNum, blockNum))
464+
}
461465

462466
trie := wmpt.New(nil, nil)
463467
hash, value, err := trie.VerifyBlockProof(uint64(blockNum), cr.ObjectProof)

0 commit comments

Comments
 (0)