Skip to content

Commit

Permalink
Merge pull request #126 from migalabs/fix/goteth-stuck-historical-mod…
Browse files Browse the repository at this point in the history
…e-with-init_slot-lt-32

fix bug when init_slot less than 32
  • Loading branch information
santi1234567 committed Jul 30, 2024
2 parents e05673a + 3031e28 commit bf2c186
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/analyzer/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func (s *ChainAnalyzer) WaitForPrevState(slot phase0.Slot) {
// check if state two epochs before is available
// the idea is that blocks are too fast to download, wait for states as well

if slot < spec.SlotsPerEpoch*2 {
return
}
prevStateEpoch := slot/spec.SlotsPerEpoch - 2 // epoch to check if state downloaded
prevStateSlot := (prevStateEpoch+1)*spec.SlotsPerEpoch - 1 // slot at which the check state was downloaded

Expand Down
5 changes: 3 additions & 2 deletions pkg/analyzer/routines.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ func (s *ChainAnalyzer) runHistorical(init phase0.Slot, end phase0.Slot) {
if i >= finalizedSlot.Slot {
// keep 2 epochs before finalized, needed to calculate epoch metrics
s.AdvanceFinalized(finalizedSlot.Slot - spec.SlotsPerEpoch*5) // includes check and clean
} else {
} else if i > (5 * spec.SlotsPerEpoch) {
// keep 5 epochs before current downloading slot, need 3 at least for epoch metrics
// magic number, 2 extra if processer takes long
s.downloadCache.CleanUpTo(i - (5 * spec.SlotsPerEpoch)) // only clean, no check, keep
cleanUpToSlot := i - (5 * spec.SlotsPerEpoch)
s.downloadCache.CleanUpTo(cleanUpToSlot) // only clean, no check, keep
}
}

Expand Down

0 comments on commit bf2c186

Please sign in to comment.