Skip to content

Commit 49574cb

Browse files
committed
Scale compression ratio to match scalars precision
1 parent 90bd9f4 commit 49574cb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

rollup/fees/rollup_fee.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ func calculateEncodedRollupFeeFeeFeynman(
206206
// tx size (RLP-encoded)
207207
txSize := big.NewInt(int64(len(data)))
208208

209-
// compression_ratio(tx) = 1 (placeholder)
210-
compressionRatio := big.NewInt(1)
209+
// compression_ratio(tx) = 1 (placeholder, scaled to match scalars precision)
210+
compressionRatio := big.NewInt(rcfg.Precision.Int64())
211211

212212
// compute gas components
213213
execGas := new(big.Int).Mul(execScalar, l1BaseFee)
@@ -216,11 +216,13 @@ func calculateEncodedRollupFeeFeeFeynman(
216216
// fee per byte = execGas + blobGas
217217
feePerByte := new(big.Int).Add(execGas, blobGas)
218218

219-
// fee = compression_ratio * tx_size * (execGas + blobGas)
219+
// rollupFee = compression_ratio * tx_size * feePerByte
220220
rollupFee := new(big.Int).Mul(compressionRatio, txSize)
221221
rollupFee.Mul(rollupFee, feePerByte)
222222

223-
rollupFee = new(big.Int).Quo(rollupFee, rcfg.Precision)
223+
// Divide by rcfg.Precision (once for ratio, once for scalar)
224+
rollupFee.Div(rollupFee, rcfg.Precision)
225+
rollupFee.Div(rollupFee, rcfg.Precision)
224226

225227
return rollupFee
226228
}

0 commit comments

Comments
 (0)