@@ -399,6 +399,53 @@ func (b *daBlockV7) Decode(data []byte) error {
399399 return nil
400400}
401401
402+ // daChunkV7 groups consecutive DABlocks with their transactions.
403+ // Note: In DACodecV7 there is no notion of chunks. Blobs contain the entire batch data without any information of Chunks within.
404+ // However, for compatibility reasons DAChunks are still used in the codebase.
405+ // This way we can still uniquely identify a set of blocks and their L1 messages via their hash.
406+ type daChunkV7 struct {
407+ daChunkV1
408+ }
409+
410+ // newDAChunkV1 is a constructor for daChunkV1, initializing with blocks and transactions.
411+ func newDAChunkV7 (blocks []DABlock , transactions [][]* types.TransactionData ) * daChunkV7 {
412+ return & daChunkV7 {
413+ daChunkV1 {
414+ blocks : blocks ,
415+ transactions : transactions ,
416+ },
417+ }
418+ }
419+
420+ // Hash computes the hash of the DAChunk data.
421+ func (c * daChunkV7 ) Hash () (common.Hash , error ) {
422+ var dataBytes []byte
423+
424+ // concatenate block contexts
425+ for _ , block := range c .blocks {
426+ encodedBlock := block .Encode ()
427+ dataBytes = append (dataBytes , encodedBlock ... )
428+ }
429+
430+ // concatenate l1 tx hashes
431+ for _ , blockTxs := range c .transactions {
432+ for _ , txData := range blockTxs {
433+ if txData .Type != types .L1MessageTxType {
434+ continue
435+ }
436+
437+ hashBytes := common .FromHex (txData .TxHash )
438+ if len (hashBytes ) != common .HashLength {
439+ return common.Hash {}, fmt .Errorf ("unexpected hash: %s" , txData .TxHash )
440+ }
441+ dataBytes = append (dataBytes , hashBytes ... )
442+ }
443+ }
444+
445+ hash := crypto .Keccak256Hash (dataBytes )
446+ return hash , nil
447+ }
448+
402449// decompressV7Bytes decompresses the given blob bytes into the original payload bytes.
403450func decompressV7Bytes (compressedBytes []byte ) ([]byte , error ) {
404451 var res []byte
0 commit comments