@@ -238,15 +238,16 @@ func (e *L1EventParser) ParseL1SingleCrossChainEventLogs(ctx context.Context, lo
238238
239239// ParseL1BatchEventLogs parses L1 watched batch events.
240240func (e * L1EventParser ) ParseL1BatchEventLogs (ctx context.Context , logs []types.Log , client * ethclient.Client , blockTimestampsMap map [uint64 ]uint64 ) ([]* orm.BatchEvent , error ) {
241- // Since CodecV7 introduced multiple CommitBatch events per transaction,
242- // each CommitBatch event corresponds to an individual blob containing block range data.
241+ // Since multiple CommitBatch events per transaction is introduced >= CodecV7,
242+ // with one transaction carrying multiple blobs,
243+ // each CommitBatch event corresponds to a blob containing block range data.
243244 // To correctly process these events, we need to:
244245 // 1. Parsing the associated blob data to extract the block range for each event
245246 // 2. Tracking the parent batch hash for each processed CommitBatch event, to:
246- // - Validate the batch hash
247- // - Derive the index of the current batch
247+ // - Validate the batch hash, since parent batch hash is needed to calculate the batch hash
248+ // - Derive the index of the current batch by the number of parent batch hashes tracked
248249 // In commitBatches and commitAndFinalizeBatch, the parent batch hash is passed in calldata,
249- // so that we can use it to get the first batch's parent batch hash.
250+ // so that we can use it to get the first batch's parent batch hash, and derive the rest .
250251 // The index map serves this purpose with:
251252 // Key: commit transaction hash
252253 // Value: parent batch hashes (in order) for each processed CommitBatch event in the transaction
@@ -469,26 +470,26 @@ func getRealFromAddress(ctx context.Context, eventSender common.Address, eventMe
469470 return sender .String (), nil
470471}
471472
472- func (e * L1EventParser ) getBatchBlockRangeFromBlob (ctx context.Context , codec encoding.Codec , versionedHash common.Hash , l1BlockTime uint64 ) ([]encoding.DABlock , error ) {
473- blob , err := e .blobClient .GetBlobByVersionedHashAndBlockTime (ctx , versionedHash , l1BlockTime )
473+ func (e * L1EventParser ) getBatchBlockRangeFromBlob (ctx context.Context , codec encoding.Codec , blobVersionedHash common.Hash , l1BlockTime uint64 ) ([]encoding.DABlock , error ) {
474+ blob , err := e .blobClient .GetBlobByVersionedHashAndBlockTime (ctx , blobVersionedHash , l1BlockTime )
474475 if err != nil {
475- return nil , fmt .Errorf ("failed to get blob %s: %w" , versionedHash .Hex (), err )
476+ return nil , fmt .Errorf ("failed to get blob %s: %w" , blobVersionedHash .Hex (), err )
476477 }
477478 if blob == nil {
478- return nil , fmt .Errorf ("blob %s not found" , versionedHash .Hex ())
479+ return nil , fmt .Errorf ("blob %s not found" , blobVersionedHash .Hex ())
479480 }
480481
481482 blobPayload , err := codec .DecodeBlob (blob )
482483 if err != nil {
483- return nil , fmt .Errorf ("blob %s decode error: %w" , versionedHash .Hex (), err )
484+ return nil , fmt .Errorf ("blob %s decode error: %w" , blobVersionedHash .Hex (), err )
484485 }
485486
486487 blocks := blobPayload .Blocks ()
487488 if len (blocks ) == 0 {
488- return nil , fmt .Errorf ("empty blocks in blob %s" , versionedHash .Hex ())
489+ return nil , fmt .Errorf ("empty blocks in blob %s" , blobVersionedHash .Hex ())
489490 }
490491
491- log .Debug ("Successfully processed blob" , "versionedHash " , versionedHash .Hex (), "blocksCount" , len (blocks ))
492+ log .Debug ("Successfully processed blob" , "blobVersionedHash " , blobVersionedHash .Hex (), "blocksCount" , len (blocks ))
492493
493494 return blocks , nil
494495}
0 commit comments