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.
This commit is contained in:
Etan Kissling 2022-08-12 15:48:33 +02:00 committed by GitHub
parent d07d7b1c48
commit 98a533c781
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 10 deletions

View File

@ -1410,24 +1410,25 @@ proc startEth1Syncing(m: Eth1Monitor, delayBeforeStart: Duration) {.async.} =
let shouldProcessDeposits = not m.depositContractAddress.isZeroMemory let shouldProcessDeposits = not m.depositContractAddress.isZeroMemory
var eth1SyncedTo: Eth1BlockNumber var eth1SyncedTo: Eth1BlockNumber
if shouldProcessDeposits and m.depositsChain.blocks.len == 0: if shouldProcessDeposits:
let startBlock = awaitWithRetries( if m.depositsChain.blocks.len == 0:
m.dataProvider.getBlockByHash( let startBlock = awaitWithRetries(
m.depositsChain.finalizedBlockHash.asBlockHash)) m.dataProvider.getBlockByHash(
m.depositsChain.finalizedBlockHash.asBlockHash))
m.depositsChain.addBlock Eth1Block( m.depositsChain.addBlock Eth1Block(
hash: m.depositsChain.finalizedBlockHash, hash: m.depositsChain.finalizedBlockHash,
number: Eth1BlockNumber startBlock.number, number: Eth1BlockNumber startBlock.number,
timestamp: Eth1BlockTimestamp startBlock.timestamp) timestamp: Eth1BlockTimestamp startBlock.timestamp)
eth1SyncedTo = Eth1BlockNumber startBlock.number eth1SyncedTo = Eth1BlockNumber m.depositsChain.blocks[^1].number
eth1_synced_head.set eth1SyncedTo.toGaugeValue eth1_synced_head.set eth1SyncedTo.toGaugeValue
eth1_finalized_head.set eth1SyncedTo.toGaugeValue eth1_finalized_head.set eth1SyncedTo.toGaugeValue
eth1_finalized_deposits.set( eth1_finalized_deposits.set(
m.depositsChain.finalizedDepositsMerkleizer.getChunkCount.toGaugeValue) 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: while true:
if bnStatus == BeaconNodeStatus.Stopping: if bnStatus == BeaconNodeStatus.Stopping: