@@ -25,9 +25,6 @@ func (d *DACodecV1) Version() CodecVersion {
2525
2626// NewDAChunk creates a new DAChunk from the given Chunk and the total number of L1 messages popped before.
2727func (d * DACodecV1 ) NewDAChunk (chunk * Chunk , totalL1MessagePoppedBefore uint64 ) (DAChunk , error ) {
28- var blocks []DABlock
29- var txs [][]* types.TransactionData
30-
3128 if chunk == nil {
3229 return nil , errors .New ("chunk is nil" )
3330 }
@@ -40,6 +37,9 @@ func (d *DACodecV1) NewDAChunk(chunk *Chunk, totalL1MessagePoppedBefore uint64)
4037 return nil , fmt .Errorf ("number of blocks (%d) exceeds maximum allowed (%d)" , len (chunk .Blocks ), math .MaxUint8 )
4138 }
4239
40+ blocks := make ([]DABlock , 0 , len (chunk .Blocks ))
41+ txs := make ([][]* types.TransactionData , 0 , len (chunk .Blocks ))
42+
4343 for _ , block := range chunk .Blocks {
4444 b , err := d .NewDABlock (block , totalL1MessagePoppedBefore )
4545 if err != nil {
@@ -60,9 +60,9 @@ func (d *DACodecV1) NewDAChunk(chunk *Chunk, totalL1MessagePoppedBefore uint64)
6060
6161// DecodeDAChunksRawTx takes a byte slice and decodes it into a []*DAChunkRawTx.
6262// Beginning from codecv1 tx data posted to blobs, not to chunk bytes in calldata
63- func (d * DACodecV1 ) DecodeDAChunksRawTx (bytes [][]byte ) ([]* DAChunkRawTx , error ) {
64- var chunks []* DAChunkRawTx
65- for _ , chunk := range bytes {
63+ func (d * DACodecV1 ) DecodeDAChunksRawTx (chunkBytes [][]byte ) ([]* DAChunkRawTx , error ) {
64+ chunks := make ( []* DAChunkRawTx , 0 , len ( chunkBytes ))
65+ for _ , chunk := range chunkBytes {
6666 if len (chunk ) < 1 {
6767 return nil , fmt .Errorf ("invalid chunk, length is less than 1" )
6868 }
0 commit comments