From 3bd9df7aaf2d316bd4a6cfa4afb31be983ede6f4 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Fri, 28 Mar 2025 23:11:17 +0800 Subject: [PATCH 1/3] fix(rollup-relayer): rollup status overwrite --- common/version/version.go | 2 +- rollup/internal/orm/batch.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common/version/version.go b/common/version/version.go index fa3f8f67dc..4b56e16a49 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.4.98" +var tag = "v4.4.99" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/rollup/internal/orm/batch.go b/rollup/internal/orm/batch.go index 7267e32d98..3f1e834a8b 100644 --- a/rollup/internal/orm/batch.go +++ b/rollup/internal/orm/batch.go @@ -413,6 +413,16 @@ func (o *Batch) UpdateCommitTxHashAndRollupStatus(ctx context.Context, hash stri db = dbTX[0] } db = db.WithContext(ctx) + + var currentBatch Batch + if err := db.Where("hash", hash).First(¤tBatch).Error; err != nil { + return fmt.Errorf("Batch.UpdateCommitTxHashAndRollupStatus error when querying current status: %w, batch hash: %v", err, hash) + } + + if types.RollupStatus(currentBatch.RollupStatus) == types.RollupFinalized { + return nil + } + db = db.Model(&Batch{}) db = db.Where("hash", hash) From 84ca61b13cc9a40b0a13f71a97fb6e810c421651 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Fri, 28 Mar 2025 23:57:26 +0800 Subject: [PATCH 2/3] fix unit tests --- rollup/internal/orm/orm_test.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/rollup/internal/orm/orm_test.go b/rollup/internal/orm/orm_test.go index baaeb4b5e0..5844daac19 100644 --- a/rollup/internal/orm/orm_test.go +++ b/rollup/internal/orm/orm_test.go @@ -318,8 +318,8 @@ func TestBatchOrm(t *testing.T) { updatedBatch, err = batchOrm.GetLatestBatch(context.Background()) assert.NoError(t, err) assert.NotNil(t, updatedBatch) - assert.Equal(t, "commitTxHash", updatedBatch.CommitTxHash) - assert.Equal(t, types.RollupCommitted, types.RollupStatus(updatedBatch.RollupStatus)) + assert.Equal(t, "", updatedBatch.CommitTxHash) + assert.Equal(t, types.RollupFinalized, types.RollupStatus(updatedBatch.RollupStatus)) err = batchOrm.UpdateFinalizeTxHashAndRollupStatus(context.Background(), batchHash2, "finalizeTxHash", types.RollupFinalizeFailed) assert.NoError(t, err) @@ -332,9 +332,8 @@ func TestBatchOrm(t *testing.T) { batches, err := batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 0, codecVersion, 0) assert.NoError(t, err) - assert.Equal(t, 2, len(batches)) + assert.Equal(t, 1, len(batches)) assert.Equal(t, batchHash1, batches[0].Hash) - assert.Equal(t, batchHash2, batches[1].Hash) batches, err = batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 0, codecVersion, 1) assert.NoError(t, err) @@ -343,8 +342,7 @@ func TestBatchOrm(t *testing.T) { batches, err = batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 1, codecVersion, 0) assert.NoError(t, err) - assert.Equal(t, 1, len(batches)) - assert.Equal(t, batchHash2, batches[0].Hash) + assert.Equal(t, 0, len(batches)) batches, err = batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 0, codecVersion+1, 0) assert.NoError(t, err) @@ -361,13 +359,10 @@ func TestBatchOrm(t *testing.T) { batches, err = batchOrm.GetCommittedBatchesGEIndexGECodecVersion(context.Background(), 0, codecVersion, 0) assert.NoError(t, err) - assert.Equal(t, 2, len(batches)) + assert.Equal(t, 1, len(batches)) assert.Equal(t, batchHash1, batches[0].Hash) - assert.Equal(t, batchHash2, batches[1].Hash) assert.Equal(t, types.ProvingTaskFailed, types.ProvingStatus(batches[0].ProvingStatus)) assert.Equal(t, types.RollupCommitFailed, types.RollupStatus(batches[0].RollupStatus)) - assert.Equal(t, types.ProvingTaskVerified, types.ProvingStatus(batches[1].ProvingStatus)) - assert.Equal(t, types.RollupFinalizeFailed, types.RollupStatus(batches[1].RollupStatus)) } } From 63f02ad36738fd64c8e980c806d5cc3099615bf6 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Mon, 31 Mar 2025 18:16:43 +0800 Subject: [PATCH 3/3] update status check --- rollup/internal/orm/batch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup/internal/orm/batch.go b/rollup/internal/orm/batch.go index 3f1e834a8b..979ecf1eda 100644 --- a/rollup/internal/orm/batch.go +++ b/rollup/internal/orm/batch.go @@ -419,7 +419,7 @@ func (o *Batch) UpdateCommitTxHashAndRollupStatus(ctx context.Context, hash stri return fmt.Errorf("Batch.UpdateCommitTxHashAndRollupStatus error when querying current status: %w, batch hash: %v", err, hash) } - if types.RollupStatus(currentBatch.RollupStatus) == types.RollupFinalized { + if types.RollupStatus(currentBatch.RollupStatus) == types.RollupFinalizing || types.RollupStatus(currentBatch.RollupStatus) == types.RollupFinalized { return nil }