Commit e7946239 authored by Maurelian's avatar Maurelian

feat(chain-mon): Default wd-mon scan from start of FPW

parent f30fdd3f
...@@ -30,7 +30,7 @@ type Metrics = { ...@@ -30,7 +30,7 @@ type Metrics = {
type State = { type State = {
messenger: CrossChainMessenger messenger: CrossChainMessenger
highestUncheckedBlockNumber: number highestUncheckedBlockNumber: number
finalizationWindow: number faultProofWindow: number
forgeryDetected: boolean forgeryDetected: boolean
} }
...@@ -109,10 +109,18 @@ export class WithdrawalMonitor extends BaseServiceV2<Options, Metrics, State> { ...@@ -109,10 +109,18 @@ export class WithdrawalMonitor extends BaseServiceV2<Options, Metrics, State> {
// Not detected by default. // Not detected by default.
this.state.forgeryDetected = false this.state.forgeryDetected = false
// For now we'll just start take it from the env or the tip of the chain this.state.faultProofWindow =
await this.state.messenger.getChallengePeriodSeconds()
this.logger.info(
`fault proof window is ${this.state.faultProofWindow} seconds`
)
// Set the start block number.
if (this.options.startBlockNumber === -1) { if (this.options.startBlockNumber === -1) {
// We default to starting from the earliest block still in the fault proof window.
const l1BlockNumber = await this.options.l1RpcProvider.getBlockNumber()
this.state.highestUncheckedBlockNumber = this.state.highestUncheckedBlockNumber =
await this.options.l1RpcProvider.getBlockNumber() l1BlockNumber - this.state.faultProofWindow / 12
} else { } else {
this.state.highestUncheckedBlockNumber = this.options.startBlockNumber this.state.highestUncheckedBlockNumber = this.options.startBlockNumber
} }
......
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