Skip to content

Commit 55dfbf6

Browse files
authored
fix(rollup-relayer): rollup status overwrite (#1638)
1 parent f3ddf43 commit 55dfbf6

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.4.98"
8+
var tag = "v4.4.99"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

rollup/internal/orm/batch.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,16 @@ func (o *Batch) UpdateCommitTxHashAndRollupStatus(ctx context.Context, hash stri
413413
db = dbTX[0]
414414
}
415415
db = db.WithContext(ctx)
416+
417+
var currentBatch Batch
418+
if err := db.Where("hash", hash).First(&currentBatch).Error; err != nil {
419+
return fmt.Errorf("Batch.UpdateCommitTxHashAndRollupStatus error when querying current status: %w, batch hash: %v", err, hash)
420+
}
421+
422+
if types.RollupStatus(currentBatch.RollupStatus) == types.RollupFinalizing || types.RollupStatus(currentBatch.RollupStatus) == types.RollupFinalized {
423+
return nil
424+
}
425+
416426
db = db.Model(&Batch{})
417427
db = db.Where("hash", hash)
418428

rollup/internal/orm/orm_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ func TestBatchOrm(t *testing.T) {
318318
updatedBatch, err = batchOrm.GetLatestBatch(context.Background())
319319
assert.NoError(t, err)
320320
assert.NotNil(t, updatedBatch)
321-
assert.Equal(t, "commitTxHash", updatedBatch.CommitTxHash)
322-
assert.Equal(t, types.RollupCommitted, types.RollupStatus(updatedBatch.RollupStatus))
321+
assert.Equal(t, "", updatedBatch.CommitTxHash)
322+
assert.Equal(t, types.RollupFinalized, types.RollupStatus(updatedBatch.RollupStatus))
323323

324324
err = batchOrm.UpdateFinalizeTxHashAndRollupStatus(context.Background(), batchHash2, "finalizeTxHash", types.RollupFinalizeFailed)
325325
assert.NoError(t, err)
@@ -332,9 +332,8 @@ func TestBatchOrm(t *testing.T) {
332332

333333
batches, err := batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 0, codecVersion, 0)
334334
assert.NoError(t, err)
335-
assert.Equal(t, 2, len(batches))
335+
assert.Equal(t, 1, len(batches))
336336
assert.Equal(t, batchHash1, batches[0].Hash)
337-
assert.Equal(t, batchHash2, batches[1].Hash)
338337

339338
batches, err = batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 0, codecVersion, 1)
340339
assert.NoError(t, err)
@@ -343,8 +342,7 @@ func TestBatchOrm(t *testing.T) {
343342

344343
batches, err = batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 1, codecVersion, 0)
345344
assert.NoError(t, err)
346-
assert.Equal(t, 1, len(batches))
347-
assert.Equal(t, batchHash2, batches[0].Hash)
345+
assert.Equal(t, 0, len(batches))
348346

349347
batches, err = batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 0, codecVersion+1, 0)
350348
assert.NoError(t, err)
@@ -361,13 +359,10 @@ func TestBatchOrm(t *testing.T) {
361359

362360
batches, err = batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 0, codecVersion, 0)
363361
assert.NoError(t, err)
364-
assert.Equal(t, 2, len(batches))
362+
assert.Equal(t, 1, len(batches))
365363
assert.Equal(t, batchHash1, batches[0].Hash)
366-
assert.Equal(t, batchHash2, batches[1].Hash)
367364
assert.Equal(t, types.ProvingTaskFailed, types.ProvingStatus(batches[0].ProvingStatus))
368365
assert.Equal(t, types.RollupCommitFailed, types.RollupStatus(batches[0].RollupStatus))
369-
assert.Equal(t, types.ProvingTaskVerified, types.ProvingStatus(batches[1].ProvingStatus))
370-
assert.Equal(t, types.RollupFinalizeFailed, types.RollupStatus(batches[1].RollupStatus))
371366
}
372367
}
373368

0 commit comments

Comments
 (0)