@@ -55,6 +55,9 @@ func RunValidationMigration(cmd *cobra.Command, args []string) {
5555
5656 // Calculate work distribution for workers
5757 numWorkers := DEFAULT_WORKERS
58+ if config .Cfg .Migrator .WorkerCount > 0 {
59+ numWorkers = int (config .Cfg .Migrator .WorkerCount )
60+ }
5861 workRanges := divideBlockRange (rangeStartBlock , rangeEndBlock , numWorkers )
5962 log .Info ().Msgf ("Starting %d workers to process migration" , len (workRanges ))
6063
@@ -376,7 +379,9 @@ func (m *Migrator) DetermineMigrationBoundaries(targetStartBlock, targetEndBlock
376379 }
377380
378381 log .Info ().Msgf ("Block in the target storage for range %s to %s: count=%s, max=%s" , startBlock .String (), endBlock .String (), blockCount .String (), maxStoredBlock .String ())
379- if maxStoredBlock != nil && maxStoredBlock .Cmp (startBlock ) >= 0 {
382+ // Only adjust start block if we actually have blocks stored (count > 0)
383+ // When count is 0, maxStoredBlock might be 0 but that doesn't mean block 0 exists
384+ if blockCount .Sign () > 0 && maxStoredBlock != nil && maxStoredBlock .Cmp (startBlock ) >= 0 {
380385 startBlock = new (big.Int ).Add (maxStoredBlock , big .NewInt (1 ))
381386 }
382387
@@ -411,7 +416,9 @@ func (m *Migrator) DetermineMigrationBoundariesForRange(rangeStart, rangeEnd *bi
411416 }
412417
413418 actualStart := rangeStart
414- if maxStoredBlock != nil && maxStoredBlock .Cmp (rangeStart ) >= 0 {
419+ // Only adjust start block if we actually have blocks stored (blockCount > 0)
420+ // When blockCount is 0, maxStoredBlock might be 0 but that doesn't mean block 0 exists
421+ if blockCount .Sign () > 0 && maxStoredBlock != nil && maxStoredBlock .Cmp (rangeStart ) >= 0 {
415422 // We have some blocks already, start from the next one
416423 actualStart = new (big.Int ).Add (maxStoredBlock , big .NewInt (1 ))
417424
0 commit comments