From 6c979210c168ac9ca12190c4d398fab9dc8b06e4 Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 4 Dec 2024 14:40:00 +0100 Subject: [PATCH] fix for running dora on phase0 chain --- indexer/beacon/block_helper.go | 2 +- indexer/beacon/epochstate.go | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/indexer/beacon/block_helper.go b/indexer/beacon/block_helper.go index 2be6744d..29c460cc 100644 --- a/indexer/beacon/block_helper.go +++ b/indexer/beacon/block_helper.go @@ -286,7 +286,7 @@ func getStateDepositIndex(state *spec.VersionedBeaconState) uint64 { return 0 } -// getStateRandaoMixes returns the RANDAO mixes from a versioned beacon state. +// getStateRandaoMixes returns the current sync committee from a versioned beacon state. func getStateCurrentSyncCommittee(v *spec.VersionedBeaconState) ([]phase0.BLSPubKey, error) { switch v.Version { case spec.DataVersionPhase0: diff --git a/indexer/beacon/epochstate.go b/indexer/beacon/epochstate.go index ada1a4c6..2f3b05a6 100644 --- a/indexer/beacon/epochstate.go +++ b/indexer/beacon/epochstate.go @@ -172,19 +172,23 @@ func (s *epochState) processState(state *spec.VersionedBeaconState, cache *epoch s.randaoMixes = randaoMixes s.depositIndex = getStateDepositIndex(state) - currentSyncCommittee, err := getStateCurrentSyncCommittee(state) - if err != nil { - return fmt.Errorf("error getting current sync committee from state %v: %v", s.slotRoot.String(), err) - } + if state.Version >= spec.DataVersionAltair { + currentSyncCommittee, err := getStateCurrentSyncCommittee(state) + if err != nil { + return fmt.Errorf("error getting current sync committee from state %v: %v", s.slotRoot.String(), err) + } - syncCommittee := make([]phase0.ValidatorIndex, len(currentSyncCommittee)) - for i, v := range currentSyncCommittee { - syncCommittee[i] = validatorPubkeyMap[v] - } - if cache != nil { - syncCommittee = cache.getOrUpdateSyncCommittee(syncCommittee) + syncCommittee := make([]phase0.ValidatorIndex, len(currentSyncCommittee)) + for i, v := range currentSyncCommittee { + syncCommittee[i] = validatorPubkeyMap[v] + } + if cache != nil { + syncCommittee = cache.getOrUpdateSyncCommittee(syncCommittee) + } + s.syncCommittee = syncCommittee + } else { + s.syncCommittee = []phase0.ValidatorIndex{} } - s.syncCommittee = syncCommittee return nil }