From fcee52406ed6e0ee25db6be67e90dd1892237204 Mon Sep 17 00:00:00 2001 From: Nicolas Deschildre Date: Tue, 7 May 2024 07:43:40 +0200 Subject: [PATCH] blobBalanceUsage: Adding check for balance. --- eth/gasestimator/gasestimator.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eth/gasestimator/gasestimator.go b/eth/gasestimator/gasestimator.go index 9d33212fef..8e1bb58cbc 100644 --- a/eth/gasestimator/gasestimator.go +++ b/eth/gasestimator/gasestimator.go @@ -83,6 +83,9 @@ func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uin 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) + if blobBalanceUsage.Cmp(available) >= 0 { + return 0, nil, core.ErrInsufficientFunds + } available.Sub(available, blobBalanceUsage) } allowance := new(big.Int).Div(available, feeCap)