Skip to content

Commit 3afa437

Browse files
committed
delete blocks
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
1 parent 0fde00a commit 3afa437

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

vms/avm/state.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ func (g *gForkStateMigration) Migrate(
225225
if err := next.state.BlockDB.Put(itr.Key(), itr.Value()); err != nil {
226226
return nil, fmt.Errorf("failed to migrate block: %w", err)
227227
}
228+
229+
if err := prevBlockDB.Delete(itr.Key()); err != nil {
230+
return nil, fmt.Errorf("failed to delete migrated block: %w", err)
231+
}
232+
233+
if err := g.commit(baseDB); err != nil {
234+
return nil, fmt.Errorf("failed to commit db: %w", err)
235+
}
228236
}
229237

230238
g.log.Debug("migrating height index")

vms/avm/vm_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,10 @@ func TestVMLinearizeStateMigration(t *testing.T) {
901901

902902
for itr := wantBlkIDs.NewIterator(); itr.Next(); {
903903
_, err := vm.GetBlock(context.Background(), itr.Key())
904-
require.NoError(err)
904+
require.ErrorIs(err, database.ErrNotFound)
905+
906+
_, err = vm.GetBlockIDAtHeight(context.Background(), itr.Value())
907+
require.NoError(err, database.ErrNotFound)
905908
}
906909

907910
for _, txID := range wantTxs {

0 commit comments

Comments
 (0)