Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/gasestimator: include blobs in virtual balance computation #29703

Merged
merged 4 commits into from
May 7, 2024
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions eth/gasestimator/gasestimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uin
}
available.Sub(available, call.Value)
}
if opts.Config.IsCancun(opts.Header.Number, opts.Header.Time) && len(call.BlobHashes) > 0 {
blobBalanceUsage := new(big.Int).SetInt64(int64(len(call.BlobHashes) * params.BlobTxBlobGasPerBlob))
blobBalanceUsage.Mul(blobBalanceUsage, call.BlobGasFeeCap)
available.Sub(available, blobBalanceUsage)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need another check for balance > blobBalanceUsage here, otherwise it could go negative.

Copy link
Contributor Author

@nand2 nand2 May 6, 2024

Choose a reason for hiding this comment

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

You're right! Which one of the following options would you use for the error?

  • Using core.ErrInsufficientFunds as error, keeping insufficient funds for gas * price + value as description,
  • Using core.ErrInsufficientFunds as error, changing description to insufficient funds for gas * price + blobGas * blobGasPrice + value as description,
  • creating and using a new error, ErrEip4844InsufficientFunds with insufficient funds for gas * price + blobGas * blobGasPrice + value as description ?

I guess option 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added option 1/ for now, let me know.

}
allowance := new(big.Int).Div(available, feeCap)

// If the allowance is larger than maximum uint64, skip checking
Expand Down