Skip to content

Commit

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

Co-authored-by: Felix Lange <fjl@twurst.com>
  • Loading branch information
nand2 and fjl authored May 7, 2024
1 parent e4b8058 commit d6e91e2
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 d6e91e2

Please sign in to comment.