@@ -157,7 +157,7 @@ func (d *DACodecV1) constructBlobPayload(chunks []*Chunk, maxNumChunksPerBatch i
157157
158158 // challenge digest preimage
159159 // 1 hash for metadata, 1 hash for each chunk, 1 hash for blob versioned hash
160- challengePreimage := make ([]byte , (1 + maxNumChunksPerBatch + 1 )* 32 )
160+ challengePreimage := make ([]byte , (1 + maxNumChunksPerBatch + 1 )* common . HashLength )
161161
162162 // the chunk data hash used for calculating the challenge preimage
163163 var chunkDataHash common.Hash
@@ -191,15 +191,15 @@ func (d *DACodecV1) constructBlobPayload(chunks []*Chunk, maxNumChunksPerBatch i
191191
192192 // challenge: compute chunk data hash
193193 chunkDataHash = crypto .Keccak256Hash (blobBytes [currentChunkStartIndex :])
194- copy (challengePreimage [32 + chunkID * 32 :], chunkDataHash [:])
194+ copy (challengePreimage [common . HashLength + chunkID * common . HashLength :], chunkDataHash [:])
195195 }
196196
197197 // if we have fewer than maxNumChunksPerBatch chunks, the rest
198198 // of the blob metadata is correctly initialized to 0,
199199 // but we need to add padding to the challenge preimage
200200 for chunkID := len (chunks ); chunkID < maxNumChunksPerBatch ; chunkID ++ {
201201 // use the last chunk's data hash as padding
202- copy (challengePreimage [32 + chunkID * 32 :], chunkDataHash [:])
202+ copy (challengePreimage [common . HashLength + chunkID * common . HashLength :], chunkDataHash [:])
203203 }
204204
205205 // challenge: compute metadata hash
@@ -220,7 +220,7 @@ func (d *DACodecV1) constructBlobPayload(chunks []*Chunk, maxNumChunksPerBatch i
220220 blobVersionedHash := kzg4844 .CalcBlobHashV1 (sha256 .New (), & c )
221221
222222 // challenge: append blob versioned hash
223- copy (challengePreimage [(1 + maxNumChunksPerBatch )* 32 :], blobVersionedHash [:])
223+ copy (challengePreimage [(1 + maxNumChunksPerBatch )* common . HashLength :], blobVersionedHash [:])
224224
225225 // compute z = challenge_digest % BLS_MODULUS
226226 challengeDigest := crypto .Keccak256Hash (challengePreimage )
@@ -295,17 +295,17 @@ func (d *DACodecV1) EstimateBlockL1CommitGas(b *Block) (uint64, error) {
295295 total += calldataNonZeroByteGas * blockContextByteSize
296296
297297 // sload
298- total += 2100 * numL1Messages // numL1Messages times cold sload in L1MessageQueue
298+ total += coldSloadGas * numL1Messages // numL1Messages times cold sload in L1MessageQueue
299299
300300 // staticcall
301- total += 100 * numL1Messages // numL1Messages times call to L1MessageQueue
302- total += 100 * numL1Messages // numL1Messages times warm address access to L1MessageQueue
301+ total += warmAddressAccessGas * numL1Messages // numL1Messages times call to L1MessageQueue
302+ total += warmAddressAccessGas * numL1Messages // numL1Messages times warm address access to L1MessageQueue
303303
304- total += getMemoryExpansionCost (36 ) * numL1Messages // staticcall to proxy
305- total += 100 * numL1Messages // read admin in proxy
306- total += 100 * numL1Messages // read impl in proxy
307- total += 100 * numL1Messages // access impl
308- total += getMemoryExpansionCost (36 ) * numL1Messages // delegatecall to impl
304+ total += getMemoryExpansionCost (functionSignatureBytes + defaultParameterBytes ) * numL1Messages // staticcall to proxy
305+ total += warmAddressAccessGas * numL1Messages // read admin in proxy
306+ total += warmAddressAccessGas * numL1Messages // read impl in proxy
307+ total += warmAddressAccessGas * numL1Messages // access impl
308+ total += getMemoryExpansionCost (functionSignatureBytes + defaultParameterBytes ) * numL1Messages // delegatecall to impl
309309
310310 return total , nil
311311}
@@ -329,10 +329,10 @@ func (d *DACodecV1) EstimateChunkL1CommitGas(c *Chunk) (uint64, error) {
329329 }
330330
331331 numBlocks := uint64 (len (c .Blocks ))
332- totalL1CommitGas += 100 * numBlocks // numBlocks times warm sload
333- totalL1CommitGas += calldataNonZeroByteGas // numBlocks field of chunk encoding in calldata
332+ totalL1CommitGas += warmSloadGas * numBlocks // numBlocks times warm sload
333+ totalL1CommitGas += calldataNonZeroByteGas // numBlocks field of chunk encoding in calldata
334334
335- totalL1CommitGas += getKeccak256Gas (58 * numBlocks + 32 * totalNonSkippedL1Messages ) // chunk hash
335+ totalL1CommitGas += getKeccak256Gas (58 * numBlocks + common . HashLength * totalNonSkippedL1Messages ) // chunk hash
336336 return totalL1CommitGas , nil
337337}
338338
@@ -341,22 +341,22 @@ func (d *DACodecV1) EstimateBatchL1CommitGas(b *Batch) (uint64, error) {
341341 var totalL1CommitGas uint64
342342
343343 // Add extra gas costs
344- totalL1CommitGas += 100000 // constant to account for ops like _getAdmin, _implementation, _requireNotPaused, etc
345- totalL1CommitGas += 4 * 2100 // 4 one-time cold sload for commitBatch
346- totalL1CommitGas += 20000 // 1 time sstore
347- totalL1CommitGas += 21000 // base fee for tx
344+ totalL1CommitGas += extraGasCost // constant to account for ops like _getAdmin, _implementation, _requireNotPaused, etc
345+ totalL1CommitGas += 4 * coldSloadGas // 4 one-time cold sload for commitBatch
346+ totalL1CommitGas += sstoreGas // 1 time sstore
347+ totalL1CommitGas += baseTxGas // base gas for tx
348348 totalL1CommitGas += calldataNonZeroByteGas // version in calldata
349349
350350 // adjusting gas:
351351 // add 1 time cold sload (2100 gas) for L1MessageQueue
352352 // add 1 time cold address access (2600 gas) for L1MessageQueue
353353 // minus 1 time warm sload (100 gas) & 1 time warm address access (100 gas)
354- totalL1CommitGas += (2100 + 2600 - 100 - 100 )
355- totalL1CommitGas += getKeccak256Gas (89 + 32 ) // parent batch header hash, length is estimated as 89 (constant part)+ 32 (1 skippedL1MessageBitmap)
356- totalL1CommitGas += calldataNonZeroByteGas * (89 + 32 ) // parent batch header in calldata
354+ totalL1CommitGas += (coldSloadGas + coldAddressAccessGas - warmSloadGas - warmAddressAccessGas )
355+ totalL1CommitGas += getKeccak256Gas (daBatchV0EncodedMinLength + skippedL1MessageBitmapByteSize ) // parent batch header hash, length is estimated as (constant part) + (1 skippedL1MessageBitmap)
356+ totalL1CommitGas += calldataNonZeroByteGas * (daBatchV0EncodedMinLength + skippedL1MessageBitmapByteSize ) // parent batch header in calldata
357357
358358 // adjust batch data hash gas cost
359- totalL1CommitGas += getKeccak256Gas (uint64 (32 * len (b .Chunks )))
359+ totalL1CommitGas += getKeccak256Gas (uint64 (common . HashLength * len (b .Chunks )))
360360
361361 totalL1MessagePoppedBefore := b .TotalL1MessagePoppedBefore
362362
@@ -370,8 +370,8 @@ func (d *DACodecV1) EstimateBatchL1CommitGas(b *Batch) (uint64, error) {
370370 totalL1MessagePoppedInChunk := chunk .NumL1Messages (totalL1MessagePoppedBefore )
371371 totalL1MessagePoppedBefore += totalL1MessagePoppedInChunk
372372
373- totalL1CommitGas += calldataNonZeroByteGas * (32 * (totalL1MessagePoppedInChunk + 255 ) / 256 )
374- totalL1CommitGas += getKeccak256Gas (89 + 32 * (totalL1MessagePoppedInChunk + 255 )/ 256 )
373+ totalL1CommitGas += calldataNonZeroByteGas * (skippedL1MessageBitmapByteSize * (totalL1MessagePoppedInChunk + 255 ) / 256 )
374+ totalL1CommitGas += getKeccak256Gas (daBatchV3OffsetParentBatchHash + skippedL1MessageBitmapByteSize * (totalL1MessagePoppedInChunk + 255 )/ 256 )
375375
376376 chunkL1CommitCalldataSize , err := d .EstimateChunkL1CommitCalldataSize (chunk )
377377 if err != nil {
0 commit comments