From b7fe1933031e52ec76ae76cdd58213995afccf32 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 12 Jul 2023 09:49:58 -0600 Subject: [PATCH] Fix an off-by-one when loading legacy validation info --- staker/block_validator.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index 108ef5710c..0ff74a8014 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -984,9 +984,12 @@ func (v *BlockValidator) checkLegacyValid() error { log.Warn("legacy valid batch ahead of db", "current", batchCount, "required", requiredBatchCount) return nil } - msgCount, err := v.inboxTracker.GetBatchMessageCount(v.legacyValidInfo.AfterPosition.BatchNumber) - if err != nil { - return err + var msgCount arbutil.MessageIndex + if v.legacyValidInfo.AfterPosition.BatchNumber > 0 { + msgCount, err = v.inboxTracker.GetBatchMessageCount(v.legacyValidInfo.AfterPosition.BatchNumber - 1) + if err != nil { + return err + } } msgCount += arbutil.MessageIndex(v.legacyValidInfo.AfterPosition.PosInBatch) processedCount, err := v.streamer.GetProcessedMessageCount()