Skip to content

Commit 6469a69

Browse files
committed
fix: remove persisted checkpoint states from the previous run at startup
1 parent 0dee422 commit 6469a69

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,11 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
151151
await this.datastore.init();
152152
}
153153
const persistedKeys = await this.datastore.readKeys();
154-
for (const persistedKey of persistedKeys) {
155-
const cp = datastoreKeyToCheckpoint(persistedKey);
156-
this.cache.set(toCacheKey(cp), {type: CacheItemType.persisted, value: persistedKey});
157-
this.epochIndex.getOrDefault(cp.epoch).add(toRootHex(cp.root));
158-
}
159-
this.logger.info("Loaded persisted checkpoint states from the last run", {
154+
// all checkpoint states from the last run are not trusted, remove them
155+
// otherwise if we have a bad checkpoint state from the last run, the node get stucked
156+
// this was found during mekong devnet, see https://github.com/ChainSafe/lodestar/pull/7255
157+
await Promise.all(persistedKeys.map((key) => this.datastore.remove(key)));
158+
this.logger.info("Removed persisted checkpoint states from the last run", {
160159
count: persistedKeys.length,
161160
maxEpochsInMemory: this.maxEpochsInMemory,
162161
});

0 commit comments

Comments
 (0)