From f91fe5646e91e07129ac3541b15810c496bf9709 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 10 Mar 2023 19:40:27 +0200 Subject: [PATCH] Redo fix #4588 --- beacon_chain/eth1/eth1_monitor.nim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/beacon_chain/eth1/eth1_monitor.nim b/beacon_chain/eth1/eth1_monitor.nim index 9ae161a21..5de3dfda2 100644 --- a/beacon_chain/eth1/eth1_monitor.nim +++ b/beacon_chain/eth1/eth1_monitor.nim @@ -1819,8 +1819,18 @@ proc stop(m: ELManager) {.async.} = const votedBlocksSafetyMargin = 50 -func earliestBlockOfInterest(m: ELManager, latestEth1BlockNumber: Eth1BlockNumber): Eth1BlockNumber = - latestEth1BlockNumber - (2 * m.cfg.ETH1_FOLLOW_DISTANCE) - votedBlocksSafetyMargin +func earliestBlockOfInterest( + m: ELManager, + latestEth1BlockNumber: Eth1BlockNumber): Eth1BlockNumber = + let blocksOfInterestRange = + SLOTS_PER_ETH1_VOTING_PERIOD + + (2 * m.cfg.ETH1_FOLLOW_DISTANCE) + + votedBlocksSafetyMargin + + if latestEth1BlockNumber > blocksOfInterestRange: + latestEth1BlockNumber - blocksOfInterestRange + else: + 0 proc syncBlockRange(m: ELManager, connection: ELConnection,