Skip to content

Commit

Permalink
fix node db (#40)
Browse files Browse the repository at this point in the history
* fix node db

* delete da too
  • Loading branch information
sh-cha authored Nov 6, 2024
1 parent 0b2fa08 commit e03e229
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions challenger/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ func ResetHeight(db types.DB, nodeName string) error {
}
nodeDB := db.WithPrefix([]byte(nodeName))

if err := DeletePendingEvents(db); err != nil {
if err := DeletePendingEvents(nodeDB); err != nil {
return err
}

if err := DeletePendingChallenges(db); err != nil {
if err := DeletePendingChallenges(nodeDB); err != nil {
return err
}

Expand Down
10 changes: 7 additions & 3 deletions executor/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ func ResetHeights(db types.DB) error {
types.HostName,
types.ChildName,
types.BatchName,
types.DAHostName,
types.DACelestiaName,
}
for _, dbName := range dbNames {
if err := ResetHeight(db, dbName); err != nil {
Expand All @@ -25,18 +27,20 @@ func ResetHeights(db types.DB) error {
func ResetHeight(db types.DB, nodeName string) error {
if nodeName != types.HostName &&
nodeName != types.ChildName &&
nodeName != types.BatchName {
nodeName != types.BatchName &&
nodeName != types.DAHostName &&
nodeName != types.DACelestiaName {
return errors.New("unknown node name")
}
nodeDB := db.WithPrefix([]byte(nodeName))
err := node.DeleteSyncInfo(nodeDB)
if err != nil {
return err
}
if err := node.DeletePendingTxs(db); err != nil {
if err := node.DeletePendingTxs(nodeDB); err != nil {
return err
}
if err := node.DeleteProcessedMsgs(db); err != nil {
if err := node.DeleteProcessedMsgs(nodeDB); err != nil {
return err
}
fmt.Printf("reset height to 0 for node %s\n", string(nodeDB.GetPrefix()))
Expand Down

0 comments on commit e03e229

Please sign in to comment.