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 <fjl@twurst.com>
  • Loading branch information
2 people authored and jorgemmsilva committed Jun 17, 2024
1 parent 573c19b commit 93a7c9f
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 93a7c9f

Please sign in to comment.