Skip to content

Commit

Permalink
fix: remove the functionality for deleting all state changes
Browse files Browse the repository at this point in the history
due to an issue where deleting state change also deletes trie nodes,
the functionality for deleting state change data has been removed
  • Loading branch information
Pangssu committed Jan 7, 2025
1 parent 7bf9198 commit aaebe37
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
28 changes: 0 additions & 28 deletions core/kroma_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,31 +205,3 @@ func DeleteStateChanges(db ethdb.KeyValueStore, blockNumber uint64) error {
}
return batch.Write()
}

func DeleteAllStateChanges(db ethdb.KeyValueStore) error {
batch := db.NewBatch()
deleteFunc := func(prefix []byte) error {
it := db.NewIterator(prefix, nil)
defer it.Release()
for it.Next() {
err := batch.Delete(it.Key())
if err != nil {
return err
}
}
if it.Error() != nil {
return it.Error()
}
return nil
}
if err := deleteFunc(destructChangesPrefix); err != nil {
return err
}
if err := deleteFunc(accountChangesPrefix); err != nil {
return err
}
if err := deleteFunc(storageChangesPrefix); err != nil {
return err
}
return batch.Write()
}
9 changes: 0 additions & 9 deletions migration/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,6 @@ func (m *StateMigrator) FinalizeTransition(transitionBlock types.Block) {
// Switch trie backend to MPT
cfg.Zktrie = false
m.backend.BlockChain().TrieDB().SetBackend(false)

// Delete all state changes.
go func() {
if err := core.DeleteAllStateChanges(m.db); err != nil {
log.Warn("Failed to delete all state changes for MPT migration", "err", err)
} else {
log.Info("All state changes have been deleted for MPT migration")
}
}()
}

func (m *StateMigrator) waitForMigrationReady(target *types.Header) {
Expand Down

0 comments on commit aaebe37

Please sign in to comment.