Skip to content

Commit 2acce16

Browse files
committed
feat: add start batch
1 parent 385d97c commit 2acce16

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Download Go dependencies
2+
FROM scrolltech/go-rust-builder:go-1.22-rust-nightly-2023-12-03 as base
3+
4+
WORKDIR /src
5+
COPY go.work* ./
6+
COPY ./rollup/go.* ./rollup/
7+
COPY ./common/go.* ./common/
8+
COPY ./coordinator/go.* ./coordinator/
9+
COPY ./database/go.* ./database/
10+
COPY ./tests/integration-test/go.* ./tests/integration-test/
11+
COPY ./bridge-history-api/go.* ./bridge-history-api/
12+
RUN go mod download -x
13+
14+
# Build blob_uploader
15+
FROM base as builder
16+
17+
RUN --mount=target=. \
18+
--mount=type=cache,target=/root/.cache/go-build \
19+
cd /src/rollup/cmd/blob_uploader/ && CGO_LDFLAGS="-ldl" go build -v -p 4 -o /bin/blob_uploader
20+
21+
# Pull blob_uploader into a second stage deploy ubuntu container
22+
FROM ubuntu:20.04
23+
24+
RUN apt update && apt install vim netcat-openbsd net-tools curl ca-certificates -y
25+
26+
ENV CGO_LDFLAGS="-ldl"
27+
28+
COPY --from=builder /bin/blob_uploader /bin/
29+
WORKDIR /app
30+
ENTRYPOINT ["blob_uploader"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
assets/
2+
docs/
3+
l2geth/
4+
rpc-gateway/
5+
*target/*

rollup/internal/controller/blob_uploader/blob_uploader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func NewBlobUploader(ctx context.Context, db *gorm.DB, cfg *config.BlobUploaderC
6262

6363
func (b *BlobUploader) UploadBlobToS3() {
6464
// get un-uploaded batches from database in ascending order by their index.
65-
dbBatch, err := b.batchOrm.GetFirstUnuploadedAndFailedBatch(b.ctx, types.BlobStoragePlatformS3)
65+
dbBatch, err := b.batchOrm.GetFirstUnuploadedAndFailedBatch(b.ctx, b.cfg.StartBatch, types.BlobStoragePlatformS3)
6666
if err != nil {
6767
log.Error("Failed to fetch unuploaded batch", "err", err)
6868
return

rollup/internal/orm/batch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ func (o *Batch) GetBatchByIndex(ctx context.Context, index uint64) (*Batch, erro
265265

266266
// GetFirstUnuploadedAndFailedBatch retrieves the first batch that either hasn't been uploaded to any blob storage service
267267
// or has failed upload status. The batch must have a commit_tx_hash (committed).
268-
func (o *Batch) GetFirstUnuploadedAndFailedBatch(ctx context.Context, platform types.BlobStoragePlatform) (*Batch, error) {
268+
func (o *Batch) GetFirstUnuploadedAndFailedBatch(ctx context.Context, startBatch uint64, platform types.BlobStoragePlatform) (*Batch, error) {
269269
db := o.db.WithContext(ctx)
270270
db = db.Model(&Batch{})
271271
db = db.Joins("LEFT JOIN blob_upload ON blob_upload.batch_index = batch.index")
272-
db = db.Where("batch.commit_tx_hash IS NOT NULL")
272+
db = db.Where("batch.commit_tx_hash IS NOT NULL AND batch.index >= ?", startBatch)
273273
db = db.Where("blob_upload.batch_index IS NULL OR blob_upload.status = ?", types.BlobUploadStatusFailed)
274274
db = db.Where("blob_upload.platform = ?", platform)
275275
db = db.Order("batch.index ASC")

0 commit comments

Comments
 (0)