@@ -21,6 +21,7 @@ import (
21
21
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
22
22
"github.com/0chain/blobber/code/go/0chain.net/core/transaction"
23
23
"github.com/0chain/blobber/code/go/0chain.net/core/util"
24
+ "github.com/0chain/common/core/util/wmpt"
24
25
sdkUtil "github.com/0chain/gosdk/core/util"
25
26
"github.com/remeh/sizedwaitgroup"
26
27
"gorm.io/gorm"
@@ -339,21 +340,22 @@ func (cr *ChallengeEntity) SaveChallengeResult(ctx context.Context, t *transacti
339
340
340
341
func (cr * ChallengeEntity ) getPostDataV2 (ctx context.Context , allocationObj * allocation.Allocation ) (map [string ]any , error ) {
341
342
trie := allocationObj .GetTrie ()
343
+ copyTrie := wmpt .New (trie .CopyRoot (filestore .COLLAPSE_DEPTH ), datastore .GetBlockStore ())
344
+
342
345
var (
343
346
blockNum = int64 (0 )
344
347
postData = make (map [string ]interface {})
345
348
ref * reference.Ref
346
349
objectSize int64
347
350
proofGenTime int64 = - 1
348
351
)
349
- if trie .Weight () > 0 {
352
+ if copyTrie .Weight () > 0 {
350
353
r := rand .New (rand .NewSource (cr .RandomNumber ))
351
- blockNum = r .Int63n (int64 (trie .Weight ()))
354
+ blockNum = r .Int63n (int64 (copyTrie .Weight ()))
352
355
blockNum ++
353
356
cr .BlockNum = blockNum
354
-
355
357
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 ))
356
- key , objectProof , err := trie .GetBlockProof (uint64 (blockNum ))
358
+ key , objectProof , err := copyTrie .GetBlockProof (uint64 (blockNum ))
357
359
if err != nil {
358
360
return nil , err
359
361
}
@@ -367,6 +369,12 @@ func (cr *ChallengeEntity) getPostDataV2(ctx context.Context, allocationObj *all
367
369
}
368
370
cr .RefID = ref .ID
369
371
postData ["object_proof" ] = objectProof
372
+ fileMetaRootBytes := copyTrie .Root ()
373
+ fileMetaRoot := hex .EncodeToString (fileMetaRootBytes )
374
+ if fileMetaRoot != allocationObj .FileMetaRoot {
375
+ logging .Logger .Error ("root_mismatch" , zap .Any ("file_meta_root" , allocationObj .FileMetaRoot ), zap .Any ("file_meta_root" , fileMetaRoot ))
376
+ return nil , common .NewError ("root_mismatch" , "File meta root mismatch" )
377
+ }
370
378
}
371
379
cr .RespondedAllocationRoot = allocationObj .AllocationRoot
372
380
if blockNum > 0 {
0 commit comments