Skip to content
Open
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
1 change: 1 addition & 0 deletions execution/gethexec/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have enough context to understand this line change. Could you please add a brief description?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now I look at the entire computation and not sure I get it.

can you add a comment with the full computation for computing backlog cost here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! We want to capture two values: l1GasPrice and backlogCost. This is the code we had initially:

			blobFeePerByte, _ := s.parentChain.BlobFeePerByte(ctx, header)
			blobFeePerByte.Mul(blobFeePerByte, blobTxBlobGasPerBlob)
			blobFeePerByte.Div(blobFeePerByte, usableBytesInBlob)
			l1GasPrice = blobFeePerByte.Int64() / 16
			backlogCost = (backlogCallDataUnits * blobFeePerByte.Int64()) / 16

This means:

l1GasPrice = (blobFeePerByte * blobTxBlobGasPerBlob) / (usableBytesInBlob * 16)
backlogCost = backlogCallDataUnits * (blobFeePerByte * blobTxBlobGasPerBlob) / (usableBytesInBlob * 16)

The problem here was that we divide with usableBytesInBlob too early and because of rounding, the value of blobFeePerByte becomes zero. Then even if we multiply with backlogCallDataUnits, it will still stay zero. The solution here was to multiply with backlogCallDataUnits before we divide. The problem here was that I forgot a line that multiplied with blobFeePerByte (the intention was to use it there as, well, this is why I had even extracted it outside of the if else).

backlogFee.Mul(backlogFee, blobTxBlobGasPerBlob)
backlogFee.Div(backlogFee, usableBytesInBlob)
backlogCost = backlogFee.Int64() / 16
Expand Down
Loading