Skip to content

Commit

Permalink
fixed deadlock in indexer due to processing epochs before genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 15, 2023
1 parent 0a998bc commit 4c74d20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion cmd/explorer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func main() {
"config": *configPath,
"version": utils.BuildVersion,
"chainName": utils.Config.Chain.Config.ConfigName}).Printf("starting")
logger.Debug("test")

if utils.Config.Chain.Config.SlotsPerEpoch == 0 || utils.Config.Chain.Config.SecondsPerSlot == 0 {
utils.LogFatal(err, "invalid chain configuration specified, you must specify the slots per epoch, seconds per slot and genesis timestamp in the config file", 0)
Expand Down
13 changes: 7 additions & 6 deletions indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ func (indexer *Indexer) runIndexer() {
logger.Errorf("Indexer Error while fetching genesis: %v", err)
} else if genesis != nil {
genesisTime := uint64(genesis.Data.GenesisTime)
logger.Infof("RPC Genesis: Time: %v, ForkVersion: %v, GVR: %v", genesisTime, genesis.Data.GenesisForkVersion, genesis.Data.GenesisValidatorsRoot)
if genesisTime != utils.Config.Chain.GenesisTimestamp {
logger.Warnf("Genesis time from RPC does not match the genesis time from explorer configuration.")
}
Expand Down Expand Up @@ -649,11 +648,13 @@ func (indexer *Indexer) loadEpochValidators(epoch uint64, epochStats *EpochStats
func (indexer *Indexer) processIndexing() {
// process old epochs
currentEpoch := utils.EpochOfSlot(indexer.state.lastHeadBlock)
maxProcessEpoch := currentEpoch - uint64(indexer.epochProcessingDelay)
for indexer.state.lastProcessedEpoch < maxProcessEpoch {
processEpoch := indexer.state.lastProcessedEpoch + 1
indexer.processEpoch(processEpoch)
indexer.state.lastProcessedEpoch = processEpoch
if currentEpoch >= uint64(indexer.epochProcessingDelay) {
maxProcessEpoch := currentEpoch - uint64(indexer.epochProcessingDelay)
for indexer.state.lastProcessedEpoch < maxProcessEpoch {
processEpoch := indexer.state.lastProcessedEpoch + 1
indexer.processEpoch(processEpoch)
indexer.state.lastProcessedEpoch = processEpoch
}
}
}

Expand Down

0 comments on commit 4c74d20

Please sign in to comment.