Skip to content

Commit

Permalink
Merge branch 'unstable' into devnet-5
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Nov 28, 2024
2 parents bb689c8 + 48dea55 commit 1a74884
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,11 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
await this.datastore.init();
}
const persistedKeys = await this.datastore.readKeys();
for (const persistedKey of persistedKeys) {
const cp = datastoreKeyToCheckpoint(persistedKey);
this.cache.set(toCacheKey(cp), {type: CacheItemType.persisted, value: persistedKey});
this.epochIndex.getOrDefault(cp.epoch).add(toRootHex(cp.root));
}
this.logger.info("Loaded persisted checkpoint states from the last run", {
// all checkpoint states from the last run are not trusted, remove them
// otherwise if we have a bad checkpoint state from the last run, the node get stucked
// this was found during mekong devnet, see https://github.com/ChainSafe/lodestar/pull/7255
await Promise.all(persistedKeys.map((key) => this.datastore.remove(key)));
this.logger.info("Removed persisted checkpoint states from the last run", {
count: persistedKeys.length,
maxEpochsInMemory: this.maxEpochsInMemory,
});
Expand Down
6 changes: 6 additions & 0 deletions packages/state-transition/src/epoch/processPendingDeposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ function applyPendingDeposit(
addValidatorToRegistry(ForkSeq.electra, state, pubkey, withdrawalCredentials, amount);
const newValidatorIndex = state.validators.length - 1;
cache.isCompoundingValidatorArr[newValidatorIndex] = hasCompoundingWithdrawalCredential(withdrawalCredentials);
// set balance, so that the next deposit of same pubkey will increase the balance correctly
// this is to fix the double deposit issue found in mekong
// see https://github.com/ChainSafe/lodestar/pull/7255
if (cachedBalances) {
cachedBalances[newValidatorIndex] = amount;
}
}
} else {
// Increase balance
Expand Down

0 comments on commit 1a74884

Please sign in to comment.