Skip to content

Commit 1fc3eec

Browse files
committed
fix file meta root check for rollback
1 parent 3b841dd commit 1fc3eec

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ func (fsh *StorageHandler) Rollback(ctx context.Context, r *http.Request) (*blob
19391939
} else {
19401940
trie = allocationObj.GetTrie()
19411941
allocationRoot = writeMarker.AllocationRoot
1942-
fileMetaRoot = allocationRoot
1942+
fileMetaRoot = writeMarker.FileMetaRoot
19431943
}
19441944

19451945
if allocationRoot != writeMarker.AllocationRoot {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ func (wme *WriteMarkerEntity) VerifyRollbackMarker(ctx context.Context, dbAlloca
229229
return common.NewError("write_marker_validation_failed", fmt.Sprintf("Write Marker allocation root %v does not match the previous allocation root of latest write marker %v", wme.WM.AllocationRoot, latestWM.WM.PreviousAllocationRoot))
230230
}
231231

232+
prevWM, err := GetWriteMarkerEntity(ctx, dbAllocation.ID, latestWM.WM.PreviousAllocationRoot)
233+
if err != nil {
234+
return common.NewError("write_marker_validation_failed", "Error getting previous write marker. "+err.Error())
235+
}
236+
if wme.WM.FileMetaRoot != prevWM.WM.FileMetaRoot {
237+
return common.NewError("write_marker_validation_failed", fmt.Sprintf("Write Marker file meta root %v does not match the file meta root of previous write marker %v", wme.WM.FileMetaRoot, prevWM.WM.FileMetaRoot))
238+
}
239+
232240
if wme.WM.Timestamp != latestWM.WM.Timestamp {
233241
return common.NewError("write_marker_validation_failed", fmt.Sprintf("Write Marker timestamp %v does not match the timestamp of latest write marker %v", wme.WM.Timestamp, latestWM.WM.Timestamp))
234242
}

0 commit comments

Comments
 (0)