@@ -213,11 +213,13 @@ func estimateTxCompressionRatio(data []byte, blockNumber uint64, blockTime uint6
213213// calculateTxCompressedSize calculates the size of `data` after compression using da-codec.
214214// We constrain compressed_size so that it cannot exceed the original size:
215215//
216- // compressed_size(tx) = min(size(zstd(tx)), size(tx ))
216+ // compressed_size(tx) = min(size(zstd(rlp( tx))) , size(rlp(tx) ))
217217//
218218// This provides an upper bound on the rollup fee for a given transaction, regardless
219219// what compression algorithm the sequencer/prover uses.
220220func calculateTxCompressedSize (data []byte , blockNumber uint64 , blockTime uint64 , config * params.ChainConfig ) (* big.Int , error ) {
221+ // Compressed size of empty data is 0.
222+ // In practice, the rlp-encoded transaction is always non-empty.
221223 if len (data ) == 0 {
222224 return common .Big0 , nil
223225 }
@@ -333,7 +335,7 @@ func calculateEncodedL1DataFeeGalileo(
333335 penaltyFactor * big.Int ,
334336 compressedSize * big.Int ,
335337) * big.Int {
336- // feePerByte = execGas + blobGas = (execScalar * l1BaseFee) + (blobScalar * l1BlobBaseFee)
338+ // feePerByte = (execScalar * l1BaseFee) + (blobScalar * l1BlobBaseFee)
337339 execGas := new (big.Int ).Mul (execScalar , l1BaseFee )
338340 blobGas := new (big.Int ).Mul (blobScalar , l1BlobBaseFee )
339341 feePerByte := new (big.Int ).Add (execGas , blobGas )
@@ -342,6 +344,7 @@ func calculateEncodedL1DataFeeGalileo(
342344 baseTerm := new (big.Int ).Mul (feePerByte , compressedSize )
343345
344346 // penaltyTerm = (baseTerm * compressedSize) / penaltyFactor
347+ // Note: We divide by penaltyFactor after multiplication to preserve precision.
345348 penaltyTerm := new (big.Int ).Mul (baseTerm , compressedSize )
346349 penaltyTerm .Div (penaltyTerm , penaltyFactor )
347350
0 commit comments