Commit 9c366e67 authored by Hamdi Allam's avatar Hamdi Allam

nits

parent 7fe5de7c
...@@ -148,7 +148,7 @@ export const findEventForStateBatch = async <TSubmissionEventArgs>( ...@@ -148,7 +148,7 @@ export const findEventForStateBatch = async <TSubmissionEventArgs>(
} }
// Update the event cache if we don't have the event. // Update the event cache if we don't have the event.
logger?.info('event not cached from index. warming cache...', { index }) logger?.info('event not cached for index. warming cache...', { index })
await updateOracleCache(oracle, logger) await updateOracleCache(oracle, logger)
// Event better be in cache now! // Event better be in cache now!
......
...@@ -219,6 +219,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -219,6 +219,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
// We use this a lot, a bit cleaner to pull out to the top level of the state object. // We use this a lot, a bit cleaner to pull out to the top level of the state object.
this.state.fpw = await this.state.messenger.getChallengePeriodSeconds() this.state.fpw = await this.state.messenger.getChallengePeriodSeconds()
this.logger.info(`fault proof window is ${this.state.fpw} seconds`)
if (this.options.bedrock) { if (this.options.bedrock) {
const oo = this.state.messenger.contracts.l1.L2OutputOracle const oo = this.state.messenger.contracts.l1.L2OutputOracle
this.state.oo = { this.state.oo = {
...@@ -255,10 +257,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -255,10 +257,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
// but it happens often on testnets because the FPW is very short. // but it happens often on testnets because the FPW is very short.
if (firstUnfinalized === undefined) { if (firstUnfinalized === undefined) {
this.logger.info('no unfinalized batches found. skipping all batches.') this.logger.info('no unfinalized batches found. skipping all batches.')
// `getTotalElements - 1` is the last batch. So the current count of batches
// represents the next expected batch to be published
const totalBatches = await this.state.oo.getTotalElements() const totalBatches = await this.state.oo.getTotalElements()
this.state.currentBatchIndex = totalBatches.toNumber() this.state.currentBatchIndex = totalBatches.toNumber() - 1
} else { } else {
this.state.currentBatchIndex = firstUnfinalized this.state.currentBatchIndex = firstUnfinalized
} }
...@@ -266,8 +266,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -266,8 +266,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
this.state.currentBatchIndex = this.options.startBatchIndex this.state.currentBatchIndex = this.options.startBatchIndex
} }
this.logger.info('starting height', { this.logger.info('starting batch', {
startBatchIndex: this.state.currentBatchIndex, batchIndex: this.state.currentBatchIndex,
}) })
// Set the initial metrics. // Set the initial metrics.
...@@ -287,7 +287,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -287,7 +287,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
let latestBatchIndex: number let latestBatchIndex: number
try { try {
latestBatchIndex = (await this.state.oo.getTotalElements()).toNumber() - 1 const totalBatches = await this.state.oo.getTotalElements()
latestBatchIndex = totalBatches.toNumber() - 1
} catch (err) { } catch (err) {
this.logger.error('failed to query total # of batches', { this.logger.error('failed to query total # of batches', {
error: err, error: err,
...@@ -303,7 +304,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -303,7 +304,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
} }
if (this.state.currentBatchIndex > latestBatchIndex) { if (this.state.currentBatchIndex > latestBatchIndex) {
this.logger.info('batch index is ahead of L1. waiting...', { this.logger.info('batch index is ahead of the oracle. waiting...', {
batchIndex: this.state.currentBatchIndex, batchIndex: this.state.currentBatchIndex,
latestBatchIndex, latestBatchIndex,
}) })
...@@ -314,7 +315,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -314,7 +315,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
this.metrics.highestBatchIndex.set({ type: 'known' }, latestBatchIndex) this.metrics.highestBatchIndex.set({ type: 'known' }, latestBatchIndex)
this.logger.info('checking batch', { this.logger.info('checking batch', {
batchIndex: this.state.currentBatchIndex, batchIndex: this.state.currentBatchIndex,
latestIndex: latestBatchIndex, latestBatchIndex,
}) })
let event: PartialEvent let event: PartialEvent
...@@ -325,7 +326,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -325,7 +326,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
this.logger this.logger
) )
} catch (err) { } catch (err) {
this.logger.error('failed to fetch event associated the batch', { this.logger.error('failed to fetch event associated with batch', {
error: err, error: err,
node: 'l1', node: 'l1',
section: 'findEventForStateBatch', section: 'findEventForStateBatch',
...@@ -448,7 +449,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -448,7 +449,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
event.transactionHash event.transactionHash
) )
} catch (err) { } catch (err) {
this.logger.error('failed to require acquire batch transaction', { this.logger.error('failed to acquire batch transaction', {
error: err, error: err,
node: 'l1', node: 'l1',
section: 'getTransaction', section: 'getTransaction',
...@@ -474,7 +475,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> { ...@@ -474,7 +475,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
this.logger.info('L2 node is behind. waiting for sync...', { this.logger.info('L2 node is behind. waiting for sync...', {
batchBlockStart: batchStart, batchBlockStart: batchStart,
batchBlockEnd: batchEnd, batchBlockEnd: batchEnd,
l2Block: latestBlock, l2BlockHeight: latestBlock,
}) })
return return
} }
......
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