Skip to content

Commit 2c53081

Browse files
committed
add review comments
1 parent 7332487 commit 2c53081

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

cmd/util/cmd/rollback-executed-height/cmd/rollback_executed_height.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,10 @@ func runE(*cobra.Command, []string) error {
111111

112112
// remove chunk data packs first, because otherwise the index to find chunk data pack will be removed.
113113
if len(chunkIDs) > 0 {
114-
chunkDataPackIDs, err := chunkDataPacks.BatchRemove(chunkIDs, protocolDBBatch)
114+
_, err := chunkDataPacks.BatchRemove(chunkIDs, protocolDBBatch)
115115
if err != nil {
116116
return fmt.Errorf("could not remove chunk data packs at %v: %w", flagHeight, err)
117117
}
118-
119-
err = storedChunkDataPacks.Remove(chunkDataPackIDs)
120-
if err != nil {
121-
return fmt.Errorf("could not commit chunk batch at %v: %w", flagHeight, err)
122-
}
123118
}
124119

125120
err = protocolDBBatch.Commit()
@@ -143,8 +138,11 @@ func runE(*cobra.Command, []string) error {
143138
})
144139
}
145140

146-
// use badger instances directly instead of stroage interfaces so that the interface don't
147-
// need to include the Remove methods
141+
// removeExecutionResultsFromHeight removes all execution results and related data
142+
// from the specified block height onward to roll back the protocol state.
143+
// It returns the chunk IDs removed from the protocol state DB,
144+
// which can then be used to delete the corresponding chunk data packs from chunk
145+
// data pack database.
148146
func removeExecutionResultsFromHeight(
149147
protocolDBBatch storage.Batch,
150148
protoState protocol.State,

engine/execution/state/state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ func (s *state) saveExecutionResults(
419419
// in the protocol database (signifying the node's slashable commitment to the respective result) is
420420
// done by the functor returned by `Store`. The functor's is invoked as part of the atomic batch update
421421
// of the protocol database below.
422-
storeFunc, err := s.chunkDataPacks.Store(chunks)
422+
storeChunkDataPacksFunc, err := s.chunkDataPacks.Store(chunks)
423423
if err != nil {
424424
return fmt.Errorf("can not store chunk data packs for block ID: %v: %w", blockID, err)
425425
}
@@ -446,7 +446,7 @@ func (s *state) saveExecutionResults(
446446
return s.db.WithReaderBatchWriter(func(batch storage.ReaderBatchWriter) error {
447447
// store the ChunkID -> StoredChunkDataPack.ID() mapping
448448
// in s.db (protocol database along with other execution data in a single batch)
449-
err := storeFunc(lctx, batch)
449+
err := storeChunkDataPacksFunc(lctx, batch)
450450
if err != nil {
451451
return fmt.Errorf("cannot store chunk data packs: %w", err)
452452
}

0 commit comments

Comments
 (0)