Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions execution/gethexec/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,12 @@ func (s *Sequencer) updateExpectedSurplus(ctx context.Context) (int64, error) {
return 0, fmt.Errorf("error encountered getting blob base fee while updating expectedSurplus: %w", err)
}

// We want to calculate the following two values:
// - l1GasPrice = (blobFeePerByte * blobTxBlobGasPerBlob) / (usableBytesInBlob * 16)
// - backlogCost = backlogCallDataUnits * (blobFeePerByte * blobTxBlobGasPerBlob) / (usableBytesInBlob * 16)
// If we divide by usableBytesInBlob too early, the value of blobFeePerByte becomes zero because of rounding.
// Then even if we multiply with backlogCallDataUnits, the value will still remain zero.
// This is why we multiply with backlogCallDataUnits before we divide.
if backlogCallDataUnits == 0 {
blobFeePerByte.Mul(blobFeePerByte, blobTxBlobGasPerBlob)
blobFeePerByte.Div(blobFeePerByte, usableBytesInBlob)
Expand All @@ -1561,6 +1567,7 @@ func (s *Sequencer) updateExpectedSurplus(ctx context.Context) (int64, error) {
} else {
// l1GasPrice can be zero because of roundings, hence backlogCost is calculated separately
backlogFee := big.NewInt(backlogCallDataUnits)
backlogFee.Mul(backlogFee, blobFeePerByte)
backlogFee.Mul(backlogFee, blobTxBlobGasPerBlob)
backlogFee.Div(backlogFee, usableBytesInBlob)
backlogCost = backlogFee.Int64() / 16
Expand Down
Loading