@@ -265,12 +265,12 @@ func (f *FullRecovery) processFinalizedBatches(batches []*batchEvents) error {
265265 for _ , b := range batches {
266266 args , err := f .l1Reader .FetchCommitTxData (b .commit )
267267 if err != nil {
268- return fmt .Errorf ("failed to fetch commit tx data of batch %d, tx hash: %v, err: %w" , firstBatch .commit .BatchIndex ().Uint64 (), firstBatch .commit .TxHash ().Hex (), err )
268+ return fmt .Errorf ("failed to fetch commit tx data of batch %d, tx hash: %v, err: %w" , b .commit .BatchIndex ().Uint64 (), b .commit .TxHash ().Hex (), err )
269269 }
270270
271271 // all batches we process here will be > CodecV7 since that is the minimum codec version for permissionless batches
272272 if args .Version < 7 {
273- return fmt .Errorf ("unsupported codec version: %v, batch index: %v, tx hash: %s" , args .Version , firstBatch .commit .BatchIndex ().Uint64 (), firstBatch .commit .TxHash ().Hex ())
273+ return fmt .Errorf ("unsupported codec version: %v, batch index: %v, tx hash: %s" , args .Version , b .commit .BatchIndex ().Uint64 (), b .commit .TxHash ().Hex ())
274274 }
275275
276276 codec , err := encoding .CodecFromVersion (encoding .CodecVersion (args .Version ))
@@ -388,7 +388,7 @@ func (f *FullRecovery) insertBatchIntoDB(batch *batchEvents, codec encoding.Code
388388
389389 // 5.4 Reproduce batch.
390390 dbParentBatch , err := f .batchORM .GetLatestBatch (f .ctx )
391- if err != nil {
391+ if err != nil || dbParentBatch == nil {
392392 return fmt .Errorf ("failed to get latest batch from DB: %w" , err )
393393 }
394394
0 commit comments