From 98a533c781342bd03d69b78db0e91df97280bceb Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 12 Aug 2022 15:48:33 +0200 Subject: [PATCH] resume EL sync at correct block on reconnect (#3957) When connection to the EL is lost as part of EL deposits importing, the targeted block range to sync would reset. This is changed to properly remember import progress across reconnects. --- beacon_chain/eth1/eth1_monitor.nim | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/beacon_chain/eth1/eth1_monitor.nim b/beacon_chain/eth1/eth1_monitor.nim index bda709698..2100a10b7 100644 --- a/beacon_chain/eth1/eth1_monitor.nim +++ b/beacon_chain/eth1/eth1_monitor.nim @@ -1410,24 +1410,25 @@ proc startEth1Syncing(m: Eth1Monitor, delayBeforeStart: Duration) {.async.} = let shouldProcessDeposits = not m.depositContractAddress.isZeroMemory var eth1SyncedTo: Eth1BlockNumber - if shouldProcessDeposits and m.depositsChain.blocks.len == 0: - let startBlock = awaitWithRetries( - m.dataProvider.getBlockByHash( - m.depositsChain.finalizedBlockHash.asBlockHash)) + if shouldProcessDeposits: + if m.depositsChain.blocks.len == 0: + let startBlock = awaitWithRetries( + m.dataProvider.getBlockByHash( + m.depositsChain.finalizedBlockHash.asBlockHash)) - m.depositsChain.addBlock Eth1Block( - hash: m.depositsChain.finalizedBlockHash, - number: Eth1BlockNumber startBlock.number, - timestamp: Eth1BlockTimestamp startBlock.timestamp) + m.depositsChain.addBlock Eth1Block( + hash: m.depositsChain.finalizedBlockHash, + number: Eth1BlockNumber startBlock.number, + timestamp: Eth1BlockTimestamp startBlock.timestamp) - eth1SyncedTo = Eth1BlockNumber startBlock.number + eth1SyncedTo = Eth1BlockNumber m.depositsChain.blocks[^1].number eth1_synced_head.set eth1SyncedTo.toGaugeValue eth1_finalized_head.set eth1SyncedTo.toGaugeValue eth1_finalized_deposits.set( m.depositsChain.finalizedDepositsMerkleizer.getChunkCount.toGaugeValue) - debug "Starting Eth1 syncing", `from` = shortLog(m.depositsChain.blocks[0]) + debug "Starting Eth1 syncing", `from` = shortLog(m.depositsChain.blocks[^1]) while true: if bnStatus == BeaconNodeStatus.Stopping: