Skip to content

Commit 040debc

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

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

vms/avm/state.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (g *gForkStateMigration) Migrate(
161161

162162
lastMigratedUTXO, _, err := next.getLastMigratedUTXO()
163163
if err != nil {
164-
return nil, fmt.Errorf("failed to get last migrated UTXO: %w", err)
164+
return nil, fmt.Errorf("failed to get last migrated utxo: %w", err)
165165
}
166166

167167
for utxo, err := range prevState.UTXOs(lastMigratedUTXO) {
@@ -172,7 +172,7 @@ func (g *gForkStateMigration) Migrate(
172172
next.AddUTXO(utxo)
173173
utxoID := utxo.InputID()
174174
if err := prevUTXODB.Delete(utxoID[:]); err != nil {
175-
return nil, fmt.Errorf("failed to delete utxo: %w", err)
175+
return nil, fmt.Errorf("failed to delete migrated utxo: %w", err)
176176
}
177177

178178
if err := next.putLastMigratedUTXO(utxo.InputID()); err != nil {
@@ -201,7 +201,7 @@ func (g *gForkStateMigration) Migrate(
201201
}
202202

203203
if err := prevTXDB.Delete(itr.Key()); err != nil {
204-
return nil, fmt.Errorf("failed to migrate tx: %w", err)
204+
return nil, fmt.Errorf("failed to delete migrated tx: %w", err)
205205
}
206206

207207
if err := g.commit(baseDB); err != nil {
@@ -244,15 +244,17 @@ func (g *gForkStateMigration) Migrate(
244244
}
245245

246246
if ok {
247-
// TODO skips
248247
startingBlkHeightKey = database.PackUInt64(lastMigratedBlkHeight)
249248
}
250249

251-
//TODO check that this is migrated
252250
for itr := prevBlockIDDB.NewIteratorWithStart(startingBlkHeightKey); itr.Next(); {
253251
if err := next.state.BlockIDDB.Put(itr.Key(), itr.Value()); err != nil {
254252
return nil, fmt.Errorf("failed to migrate block height: %w", err)
255253
}
254+
255+
if err := prevBlockIDDB.Delete(itr.Key()); err != nil {
256+
return nil, fmt.Errorf("failed to delete migrated block height: %w", err)
257+
}
256258
}
257259

258260
g.log.Debug("migrating singletons")

vms/avm/vm_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ func TestVMLinearizeStateMigration(t *testing.T) {
904904
require.ErrorIs(err, database.ErrNotFound)
905905

906906
_, err = vm.GetBlockIDAtHeight(context.Background(), itr.Value())
907-
require.NoError(err, database.ErrNotFound)
907+
require.ErrorIs(err, database.ErrNotFound)
908908
}
909909

910910
for _, txID := range wantTxs {

0 commit comments

Comments
 (0)