Commit 2f058b84 authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(fd): bug for short FPWs (#3486)

Fixes a bug in the fault detector that would cause errors when running
on testnets with very short fault proof windows. Now handles this case
explicitly.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent ef1e635b
---
'@eth-optimism/fault-detector': patch
---
Fixes a small bug in the fault detector that would cause errors for testnets where the fault proof window is extremely short.
......@@ -106,8 +106,21 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
// Figure out where to start syncing from.
if (this.options.startBatchIndex === -1) {
this.logger.info(`finding appropriate starting height`)
this.state.highestCheckedBatchIndex =
await findFirstUnfinalizedStateBatchIndex(this.state.scc)
const firstUnfinalized = await findFirstUnfinalizedStateBatchIndex(
this.state.scc
)
// We may not have an unfinalized batches in the case where no batches have been submitted
// for the entire duration of the FPW. We generally do not expect this to happen on mainnet,
// but it happens often on testnets because the FPW is very short.
if (firstUnfinalized === undefined) {
this.logger.info(`no unfinalized batches found, starting from latest`)
this.state.highestCheckedBatchIndex = (
await this.state.scc.getTotalBatches()
).toNumber()
} else {
this.state.highestCheckedBatchIndex = firstUnfinalized
}
} else {
this.state.highestCheckedBatchIndex = this.options.startBatchIndex
}
......
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