Skip to content

Commit 4e87fd6

Browse files
Merge branch 'sprint-1.15' into fix/conductor
2 parents bfd981f + 8aaf842 commit 4e87fd6

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

code/go/0chain.net/blobbercore/filestore/storage.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (fs *FileStore) WriteFile(allocID, conID string, fileData *FileInputData, i
106106
_ = os.Remove(tempFilePath)
107107
return nil, common.NewError("file_size_mismatch", "File size is greater than expected")
108108
}
109-
logging.Logger.Info("temp_file_write: ", zap.String("filePath", fileData.Path), zap.Int64("currentSize", currentSize), zap.Int64("initialSize", initialSize), zap.Int64("writtenSize", writtenSize), zap.Int64("offset", fileData.UploadOffset), zap.Bool("ChunkUploaded", fileRef.ChunkUploaded))
109+
logging.Logger.Info("temp_file_write: ", zap.String("filePath", fileData.Path), zap.Int64("currentSize", currentSize), zap.Int64("initialSize", initialSize), zap.Int64("writtenSize", writtenSize), zap.Int64("offset", fileData.UploadOffset), zap.String("tempFilePath", tempFilePath))
110110
fileRef.Size = writtenSize
111111
fileRef.Name = fileData.Name
112112
fileRef.Path = fileData.Path
@@ -182,12 +182,6 @@ func (fs *FileStore) DeletePreCommitDir(allocID string) error {
182182
if err != nil {
183183
return common.NewError("pre_commit_dir_deletion_error", err.Error())
184184
}
185-
tempDir := fs.getAllocTempDir(allocID)
186-
err = os.RemoveAll(tempDir)
187-
if err != nil {
188-
return common.NewError("temp_dir_deletion_error", err.Error())
189-
}
190-
191185
return nil
192186
}
193187

@@ -398,7 +392,7 @@ func (fs *FileStore) DeleteTempFile(allocID, conID string, fd *FileInputData) er
398392
return common.NewError("invalid_allocation_id", "Allocation id cannot be empty")
399393
}
400394
fileObjectPath := fs.getTempPathForFile(allocID, fd.Name, encryption.Hash(fd.Path), conID)
401-
395+
logging.Logger.Info("deleting_temp_file", zap.String("fileObjectPath", fileObjectPath), zap.String("allocation_id", allocID), zap.String("connection_id", conID))
402396
finfo, err := os.Stat(fileObjectPath)
403397
if err != nil {
404398
if errors.Is(err, os.ErrNotExist) {

code/go/0chain.net/blobbercore/filestore/tree_validation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ func (c *CommitHasher) Start(ctx context.Context, connID, allocID, fileName, fil
427427
tempFilePath := GetFileStore().GetTempFilePath(allocID, connID, fileName, filePathHash)
428428
f, err := os.Open(tempFilePath)
429429
if err != nil {
430+
logging.Logger.Error("hasher_open", zap.Error(err), zap.String("tempFilePath", tempFilePath))
430431
c.hashErr = err
431432
return
432433
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b
618618
return nil, common.NewError("chain_length_exceeded", "Chain length exceeded")
619619
}
620620

621-
err = writemarkerEntity.VerifyMarker(ctx, allocationObj, connectionObj)
621+
err = writemarkerEntity.VerifyMarker(ctx, allocationObj, connectionObj, latestWriteMarkerEntity)
622622
if err != nil {
623623
result.AllocationRoot = allocationObj.AllocationRoot
624624
result.ErrorMessage = "Verification of write marker failed: " + err.Error()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func GetWriteMarkerEntity(ctx context.Context, allocation_root string) (*WriteMa
142142
// err := db.First(wm, "allocation_root = ?", allocation_root).Error
143143
err := db.Table((WriteMarkerEntity{}).TableName()).
144144
Where("allocation_root=?", allocation_root).
145-
Order("timestamp desc").
145+
Order("sequence desc").
146146
Take(wm).Error
147147
if err != nil {
148148
return nil, err

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ type CommitConnection struct {
2525
ChainData []byte `json:"chain_data"`
2626
}
2727

28+
const timeGap = 180
29+
2830
// VerifyMarker verify WriteMarker's hash and check allocation_root if it is unique
29-
func (wme *WriteMarkerEntity) VerifyMarker(ctx context.Context, dbAllocation *allocation.Allocation, co *allocation.AllocationChangeCollector) error {
31+
func (wme *WriteMarkerEntity) VerifyMarker(ctx context.Context, dbAllocation *allocation.Allocation, co *allocation.AllocationChangeCollector, latestWM *WriteMarkerEntity) error {
3032
if wme == nil {
3133
return common.NewError("invalid_write_marker", "No Write Marker was found")
3234
}
@@ -92,9 +94,11 @@ func (wme *WriteMarkerEntity) VerifyMarker(ctx context.Context, dbAllocation *al
9294
}
9395

9496
currTime := common.Now()
95-
// blobber clock is allowed to be 60 seconds behind the current time
96-
if wme.WM.Timestamp > currTime+60 {
97-
return common.NewError("write_marker_validation_failed", "Write Marker timestamp is in the future")
97+
// blobber clock is allowed to be 180 seconds behind the current time
98+
if wme.WM.Timestamp > currTime+timeGap {
99+
if latestWM == nil || wme.WM.Timestamp > latestWM.WM.Timestamp+timeGap {
100+
return common.NewError("write_marker_validation_failed", "Write Marker timestamp is in the future")
101+
}
98102
}
99103

100104
hashData := wme.WM.GetHashData()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.21
44

55
require (
66
github.com/0chain/errors v1.0.3
7-
github.com/0chain/gosdk v1.14.0-RC4
7+
github.com/0chain/gosdk v1.14.0
88
github.com/DATA-DOG/go-sqlmock v1.5.0
99
github.com/didip/tollbooth/v6 v6.1.2
1010
github.com/go-openapi/runtime v0.26.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs
4040
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E=
4141
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
4242
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
43-
github.com/0chain/gosdk v1.14.0-RC4 h1:KOek+3Reuo/QMKjFEKuCtSopSBwKicu6KIDpyNdw6jc=
44-
github.com/0chain/gosdk v1.14.0-RC4/go.mod h1:tgAiVAuIy+Vs1tGfKCPEuuWWARwNQBEw32y950LrqrU=
43+
github.com/0chain/gosdk v1.14.0 h1:jmvfnPphIXQo8YQcRvEEvN7S+mBZQSURmmI7FsmL2YA=
44+
github.com/0chain/gosdk v1.14.0/go.mod h1:tgAiVAuIy+Vs1tGfKCPEuuWWARwNQBEw32y950LrqrU=
4545
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4646
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
4747
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=

0 commit comments

Comments
 (0)