Skip to content

Commit

Permalink
resume EL sync at correct block on reconnect (#3957)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
etan-status authored Aug 12, 2022
1 parent d07d7b1 commit 98a533c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions beacon_chain/eth1/eth1_monitor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 98a533c

Please sign in to comment.