Skip to content

Commit

Permalink
Merge pull request #181 from ethpandaops/pk910/fix-validator-activity…
Browse files Browse the repository at this point in the history
…-panic

fix panic when loading validator activity from cached voting aggregation
  • Loading branch information
pk910 authored Nov 28, 2024
2 parents bdd39d7 + 7240920 commit d0e0fd2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions indexer/beacon/epochvotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type epochVotesKey [32 + 8 + 32 + 1]byte

// generate epochStatsKey from epoch and dependentRoot
func getEpochVotesKey(epoch phase0.Epoch, dependentRoot phase0.Root, highestRoot phase0.Root, blockCount uint8, hasValues bool) epochVotesKey {
func getEpochVotesKey(epoch phase0.Epoch, dependentRoot phase0.Root, highestRoot phase0.Root, blockCount uint8, hasValues bool, isPrecalc bool) epochVotesKey {
var key epochVotesKey

copy(key[0:], dependentRoot[:])
Expand All @@ -26,6 +26,9 @@ func getEpochVotesKey(epoch phase0.Epoch, dependentRoot phase0.Root, highestRoot
if hasValues {
key[72] |= 0x80
}
if isPrecalc {
key[72] |= 0x40
}

return key
}
Expand Down Expand Up @@ -63,8 +66,9 @@ func (indexer *Indexer) aggregateEpochVotes(epoch phase0.Epoch, chainState *cons
}

votesWithValues := epochStats != nil && epochStats.ready
votesWithPrecalc := epochStats != nil && epochStats.precalcValues != nil

votesKey := getEpochVotesKey(epoch, targetRoot, blocks[len(blocks)-1].Root, uint8(len(blocks)), votesWithValues)
votesKey := getEpochVotesKey(epoch, targetRoot, blocks[len(blocks)-1].Root, uint8(len(blocks)), votesWithValues, votesWithPrecalc)
if cachedVotes, isOk := indexer.epochCache.votesCache.Get(votesKey); isOk {
return cachedVotes
}
Expand Down

0 comments on commit d0e0fd2

Please sign in to comment.