From 3031e28cbffc57aff8be30d15008c108992eef8c Mon Sep 17 00:00:00 2001 From: santi1234567 <45318759+santi1234567@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:17:03 -0300 Subject: [PATCH] fix case of init_slot less than 32 --- pkg/analyzer/download.go | 3 +++ pkg/analyzer/routines.go | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/analyzer/download.go b/pkg/analyzer/download.go index 167ef17e..0ff9380d 100644 --- a/pkg/analyzer/download.go +++ b/pkg/analyzer/download.go @@ -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 diff --git a/pkg/analyzer/routines.go b/pkg/analyzer/routines.go index 5896416c..12fd6752 100644 --- a/pkg/analyzer/routines.go +++ b/pkg/analyzer/routines.go @@ -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 } }