Skip to content

Commit

Permalink
fix: handle no vote in prune()
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Aug 14, 2023
1 parent 6f6011c commit d0be900
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/fork-choice/src/forkChoice/forkChoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,11 @@ export class ForkChoice implements IForkChoice {
const prunedNodes = this.protoArray.maybePrune(finalizedRoot);
const prunedCount = prunedNodes.length;
for (const vote of this.votes) {
// validator has never voted
if (vote === undefined) {
continue;
}

if (vote.currentIndex !== null) {
if (vote.currentIndex >= prunedCount) {
vote.currentIndex -= prunedCount;
Expand All @@ -680,6 +685,7 @@ export class ForkChoice implements IForkChoice {
vote.currentIndex = null;
}
}

if (vote.nextIndex !== null) {
if (vote.nextIndex >= prunedCount) {
vote.nextIndex -= prunedCount;
Expand Down

0 comments on commit d0be900

Please sign in to comment.