Skip to content

Commit

Permalink
eth/gasestimator: include blobs in virtual balance computation (ether…
Browse files Browse the repository at this point in the history
…eum#29703)

Fixes ethereum#29702

Co-authored-by: Felix Lange <[email protected]>
  • Loading branch information
2 people authored and stwiname committed Sep 9, 2024
1 parent 3cd13ea commit a6a68a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eth/gasestimator/gasestimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ 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 {
blobGasPerBlob := new(big.Int).SetInt64(params.BlobTxBlobGasPerBlob)
blobBalanceUsage := new(big.Int).SetInt64(int64(len(call.BlobHashes)))
blobBalanceUsage.Mul(blobBalanceUsage, blobGasPerBlob)
blobBalanceUsage.Mul(blobBalanceUsage, call.BlobGasFeeCap)
if blobBalanceUsage.Cmp(available) >= 0 {
return 0, nil, core.ErrInsufficientFunds
}
available.Sub(available, blobBalanceUsage)
}
allowance := new(big.Int).Div(available, feeCap)

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

0 comments on commit a6a68a9

Please sign in to comment.