Commit 2296cf81 authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(fd): make sure fd doesn't sync beyond tip (#2793)

Fixes a bug where the FD would try to get blocks beyond the local tip,
triggering an error in L2Geth.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 6b76465e
---
'@eth-optimism/fault-detector': patch
---
Fix bug where FD would try to sync beyond local tip
......@@ -135,6 +135,16 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
const batchStart = event.args._prevTotalElements.toNumber() + 1
const batchSize = event.args._batchSize.toNumber()
const batchEnd = batchStart + batchSize
const latestBlock = await this.options.l2RpcProvider.getBlockNumber()
if (latestBlock < batchEnd) {
this.logger.info(`node is behind, waiting for sync`, {
batchEnd,
latestBlock,
})
return
}
// `getBlockRange` has a limit of 1000 blocks, so we have to break this request out into
// multiple requests of maximum 1000 blocks in the case that batchSize > 1000.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment