@@ -243,9 +243,14 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov
243243 return nil , fmt .Errorf ("failed to get batch proofs for bundle task id:%s, no batch found" , task .TaskID )
244244 }
245245
246- parentBatch , err := bp .batchOrm .GetBatchByHash (ctx , batches [0 ].ParentBatchHash )
247- if err != nil {
248- return nil , fmt .Errorf ("failed to get parent batch for batch task id:%s err:%w" , task .TaskID , err )
246+ var prevStateRoot common.Hash
247+ // this would be common in test cases: the first batch has empty parent
248+ if batches [0 ].Index > 1 {
249+ parentBatch , err := bp .batchOrm .GetBatchByHash (ctx , batches [0 ].ParentBatchHash )
250+ if err != nil {
251+ return nil , fmt .Errorf ("failed to get parent batch for batch task id:%s err:%w" , task .TaskID , err )
252+ }
253+ prevStateRoot = common .HexToHash (parentBatch .StateRoot )
249254 }
250255
251256 var batchProofs []* message.OpenVMBatchProof
@@ -264,7 +269,7 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov
264269
265270 taskDetail .BundleInfo = & message.OpenVMBundleInfo {
266271 ChainID : bp .cfg .L2 .ChainID ,
267- PrevStateRoot : common . HexToHash ( parentBatch . StateRoot ) ,
272+ PrevStateRoot : prevStateRoot ,
268273 PostStateRoot : common .HexToHash (batches [len (batches )- 1 ].StateRoot ),
269274 WithdrawRoot : common .HexToHash (batches [len (batches )- 1 ].WithdrawRoot ),
270275 NumBatches : uint32 (len (batches )),
0 commit comments