From 3b07fccd001a9936ae22a0bfb63656e44c2f6146 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 20 Nov 2024 11:16:16 +0530 Subject: [PATCH] Check batchProcessed > 0 to avoid underflow --- arbnode/sync_monitor.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arbnode/sync_monitor.go b/arbnode/sync_monitor.go index 629068c4fb..f06e9ca49f 100644 --- a/arbnode/sync_monitor.go +++ b/arbnode/sync_monitor.go @@ -146,11 +146,13 @@ func (s *SyncMonitor) FullSyncProgressMap() map[string]interface{} { batchProcessed := s.inboxReader.GetLastReadBatchCount() res["batchProcessed"] = batchProcessed - processedBatchMsgs, err := s.inboxReader.Tracker().GetBatchMessageCount(batchProcessed - 1) - if err != nil { - res["batchMetadataError"] = err.Error() - } else { - res["messageOfProcessedBatch"] = processedBatchMsgs + if batchProcessed > 0 { + processedBatchMsgs, err := s.inboxReader.Tracker().GetBatchMessageCount(batchProcessed - 1) + if err != nil { + res["batchMetadataError"] = err.Error() + } else { + res["messageOfProcessedBatch"] = processedBatchMsgs + } } l1reader := s.inboxReader.l1Reader