From 4d7852e10646a54747a5958fecb111c4f0cbf61e Mon Sep 17 00:00:00 2001 From: g11tech Date: Fri, 1 Jul 2022 01:07:56 +0530 Subject: [PATCH] Fix the eth1 tracker poll loop when the blocks are slow (#4221) --- .../lodestar/src/eth1/eth1DepositDataTracker.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/lodestar/src/eth1/eth1DepositDataTracker.ts b/packages/lodestar/src/eth1/eth1DepositDataTracker.ts index 89324aa83b37..dc28b2b65143 100644 --- a/packages/lodestar/src/eth1/eth1DepositDataTracker.ts +++ b/packages/lodestar/src/eth1/eth1DepositDataTracker.ts @@ -305,10 +305,15 @@ export class Eth1DepositDataTracker { return true; } else { // Blocks are slower than expected, reduce eth1FollowDistance. Limit min CATCHUP_MIN_FOLLOW_DISTANCE - const delta = ETH1_FOLLOW_DISTANCE_DELTA_IF_SLOW; - this.eth1FollowDistance = Math.max(this.eth1FollowDistance - delta, ETH_MIN_FOLLOW_DISTANCE); - - return false; + const delta = + this.eth1FollowDistance - + Math.max(this.eth1FollowDistance - ETH1_FOLLOW_DISTANCE_DELTA_IF_SLOW, ETH_MIN_FOLLOW_DISTANCE); + this.eth1FollowDistance = this.eth1FollowDistance - delta; + + // Even if the blocks are slow, when we are all caught up as there is no + // further possibility to reduce follow distance, we need to call it quits + // for now, else it leads to an incessant poll on the EL + return delta === 0; } }