Skip to content

Commit 03f3b2b

Browse files
authored
fix(rollup-verifier): delete committed batch meta when reverting a batch (#1000)
* fix(rollup-verifier): delete committed batch metadata when reverting a batch * chore: auto version bump [bot] * remove a comment --------- Co-authored-by: colinlyguo <[email protected]>
1 parent 233a6ad commit 03f3b2b

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

core/rawdb/accessors_rollup_event.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,11 @@ func ReadCommittedBatchMeta(db ethdb.Reader, batchIndex uint64) *CommittedBatchM
208208
}
209209
return cbm
210210
}
211+
212+
// DeleteCommittedBatchMeta removes the block ranges of all chunks associated with a specific batch from the database.
213+
// Note: Only non-finalized batches can be reverted.
214+
func DeleteCommittedBatchMeta(db ethdb.KeyValueWriter, batchIndex uint64) {
215+
if err := db.Delete(committedBatchMetaKey(batchIndex)); err != nil {
216+
log.Crit("failed to delete committed batch metadata", "batch index", batchIndex, "err", err)
217+
}
218+
}

core/rawdb/accessors_rollup_event_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func TestBatchChunkRanges(t *testing.T) {
211211
DeleteBatchChunkRanges(db, uint64(len(chunks)+1))
212212
}
213213

214-
func TestWriteReadCommittedBatchMeta(t *testing.T) {
214+
func TestWriteReadDeleteCommittedBatchMeta(t *testing.T) {
215215
db := NewMemoryDatabase()
216216

217217
testCases := []struct {
@@ -261,6 +261,19 @@ func TestWriteReadCommittedBatchMeta(t *testing.T) {
261261
if got := ReadCommittedBatchMeta(db, 256); got != nil {
262262
t.Fatalf("Expected nil for non-existing value, got %+v", got)
263263
}
264+
265+
// delete: revert batch
266+
for _, tc := range testCases {
267+
DeleteCommittedBatchMeta(db, tc.batchIndex)
268+
269+
readChunkRange := ReadCommittedBatchMeta(db, tc.batchIndex)
270+
if readChunkRange != nil {
271+
t.Fatal("Committed batch metadata was not deleted", "batch index", tc.batchIndex)
272+
}
273+
}
274+
275+
// delete non-existing value: ensure the delete operation handles non-existing values without errors.
276+
DeleteCommittedBatchMeta(db, 256)
264277
}
265278

266279
func TestOverwriteCommittedBatchMeta(t *testing.T) {

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 6 // Minor version component of the current release
27-
VersionPatch = 4 // Patch version component of the current release
27+
VersionPatch = 5 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

rollup/rollup_sync_service/rollup_sync_service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ func (s *RollupSyncService) parseAndUpdateRollupEventLogs(logs []types.Log, endB
219219
batchIndex := event.BatchIndex.Uint64()
220220
log.Trace("found new RevertBatch event", "batch index", batchIndex)
221221

222+
rawdb.DeleteCommittedBatchMeta(s.db, batchIndex)
222223
rawdb.DeleteBatchChunkRanges(s.db, batchIndex)
223224

224225
case s.l1FinalizeBatchEventSignature:

0 commit comments

Comments
 (0)