Skip to content

Commit f23ebd2

Browse files
Merge branch 'sprint-1.10' into replace-with-multiops
2 parents 6c42a1c + 0a01870 commit f23ebd2

File tree

11 files changed

+30
-20
lines changed

11 files changed

+30
-20
lines changed

.github/workflows/build-&-publish-docker-image.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ env:
2121

2222
jobs:
2323
blobber:
24+
timeout-minutes: 25
2425
runs-on: [self-hosted, arc-runner]
2526
steps:
2627
- name: Set docker image tag
@@ -95,6 +96,7 @@ jobs:
9596
./docker.local/bin/build.blobber.sh
9697
9798
validator:
99+
timeout-minutes: 20
98100
runs-on: [self-hosted, arc-runner]
99101
steps:
100102
- name: Set docker image tag

code/go/0chain.net/blobbercore/allocation/allocationchange.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ func (cc *AllocationChangeCollector) ApplyChanges(ctx context.Context, allocatio
217217
return err
218218
}
219219
}
220-
logging.Logger.Info("ApplyChanges", zap.Any("rootRef", rootRef))
221220
_, err = rootRef.CalculateHash(ctx, true)
222221
return err
223222
}

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ type Allocation struct {
4848
RepairerID string `gorm:"column:repairer_id;size:64;not null"`
4949
Expiration common.Timestamp `gorm:"column:expiration_date;not null"`
5050
// AllocationRoot allcation_root of last write_marker
51-
AllocationRoot string `gorm:"column:allocation_root;size:64;not null;default:''"`
52-
FileMetaRoot string `gorm:"column:file_meta_root;size:64;not null;default:''"`
53-
BlobberSize int64 `gorm:"column:blobber_size;not null;default:0"`
54-
BlobberSizeUsed int64 `gorm:"column:blobber_size_used;not null;default:0"`
55-
LatestRedeemedWM string `gorm:"column:latest_redeemed_write_marker;size:64"`
56-
IsRedeemRequired bool `gorm:"column:is_redeem_required"`
57-
TimeUnit time.Duration `gorm:"column:time_unit;not null;default:172800000000000"`
51+
AllocationRoot string `gorm:"column:allocation_root;size:64;not null;default:''"`
52+
FileMetaRoot string `gorm:"column:file_meta_root;size:64;not null;default:''"`
53+
BlobberSize int64 `gorm:"column:blobber_size;not null;default:0"`
54+
BlobberSizeUsed int64 `gorm:"column:blobber_size_used;not null;default:0"`
55+
LatestRedeemedWM string `gorm:"column:latest_redeemed_write_marker;size:64"`
56+
IsRedeemRequired bool `gorm:"column:is_redeem_required"`
57+
TimeUnit time.Duration `gorm:"column:time_unit;not null;default:172800000000000"`
58+
StartTime common.Timestamp `gorm:"column:start_time;not null"`
5859
// Ending and cleaning
5960
CleanedUp bool `gorm:"column:cleaned_up;not null;default:false"`
6061
Finalized bool `gorm:"column:finalized;not null;default:false"`

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func FetchAllocationFromEventsDB(ctx context.Context, allocationID string, alloc
108108
a.Finalized = sa.Finalized
109109
a.TimeUnit = sa.TimeUnit
110110
a.FileOptions = sa.FileOptions
111+
a.StartTime = sa.StartTime
111112

112113
m := map[string]interface{}{
113114
"allocation_id": a.ID,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func (fs *FileStore) WriteFile(allocID, conID string, fileData *FileInputData, i
8383
if err != nil {
8484
return nil, common.NewError("file_seek_error", err.Error())
8585
}
86-
87-
writtenSize, err := io.Copy(f, infile)
86+
buf := make([]byte, BufferSize)
87+
writtenSize, err := io.CopyBuffer(f, infile, buf)
8888
if err != nil {
8989
return nil, common.NewError("file_write_error", err.Error())
9090
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ func (cmd *UploadFileCommand) IsValidated(ctx context.Context, req *http.Request
5050
}
5151

5252
fileChanger := &allocation.UploadFileChanger{}
53-
5453
uploadMetaString := req.FormValue(UploadMeta)
5554
err := json.Unmarshal([]byte(uploadMetaString), fileChanger)
5655
if err != nil {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,19 +490,19 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b
490490
return nil, common.NewError("invalid_parameters", "Invalid connection id passed")
491491
}
492492

493-
err = checkPendingMarkers(ctx, allocationObj.ID)
494-
if err != nil {
495-
Logger.Error("Error checking pending markers", zap.Error(err))
496-
return nil, common.NewError("pending_markers", "previous marker is still pending to be redeemed")
497-
}
498-
499493
// Lock will compete with other CommitWrites and Challenge validation
500494
mutex := lock.GetMutex(allocationObj.TableName(), allocationID)
501495
mutex.Lock()
502496
defer mutex.Unlock()
503497

504498
elapsedGetLock := time.Since(startTime) - elapsedAllocation
505499

500+
err = checkPendingMarkers(ctx, allocationObj.ID)
501+
if err != nil {
502+
Logger.Error("Error checking pending markers", zap.Error(err))
503+
return nil, common.NewError("pending_markers", "previous marker is still pending to be redeemed")
504+
}
505+
506506
connectionObj, err := allocation.GetAllocationChanges(ctx, connectionID, allocationID, clientID)
507507

508508
if err != nil {

code/go/0chain.net/blobbercore/readmarker/readmarker.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ func (rm *ReadMarkerEntity) VerifyMarker(ctx context.Context, sa *allocation.All
103103
return common.NewError("read_marker_validation_failed", "Read Marker clientID does not match request clientID")
104104
}
105105

106+
if rm.LatestRM.Timestamp < sa.StartTime {
107+
return common.NewError("read_marker_validation_failed", "Readmarker timestamp is before the allocation start time")
108+
}
109+
106110
if rm.LatestRM.Timestamp > sa.Expiration {
107-
zLogger.Logger.Error("Readmarker is for an expired allocation", zap.Any("rm", rm))
108111
return common.NewError("read_marker_validation_failed", "Readmarker is for an expired allocation")
109112
}
110113

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@ func (wme *WriteMarkerEntity) VerifyMarker(ctx context.Context, dbAllocation *al
8181
if clientID == "" || clientID != wme.WM.ClientID || clientID != co.ClientID || co.ClientID != wme.WM.ClientID {
8282
return common.NewError("write_marker_validation_failed", "Write Marker is not by the same client who uploaded")
8383
}
84+
if wme.WM.Timestamp < dbAllocation.StartTime {
85+
return common.NewError("write_marker_validation_failed", "Write Marker timestamp is before the allocation start time")
86+
}
8487

8588
currTime := common.Now()
8689
// blobber clock is allowed to be 10 seconds behind the current time
87-
if wme.WM.Timestamp > currTime+10 {
90+
if wme.WM.Timestamp > currTime+60 {
8891
return common.NewError("write_marker_validation_failed", "Write Marker timestamp is in the future")
8992
}
9093

code/go/0chain.net/core/transaction/entity.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ type StorageAllocation struct {
9090
TimeUnit time.Duration `json:"time_unit"`
9191
WritePool uint64 `json:"write_pool"`
9292
FileOptions uint16 `json:"file_options"`
93+
StartTime common.Timestamp `json:"start_time"`
9394

9495
DataShards int64 `json:"data_shards"`
9596
ParityShards int64 `json:"parity_shards"`

0 commit comments

Comments
 (0)