From f83fe44326c469874dab3c6c4b1f0b85e60dcd7a Mon Sep 17 00:00:00 2001 From: Nicolas Deschildre Date: Fri, 3 May 2024 21:04:14 +0200 Subject: [PATCH] Fix: eth_estimateGas with blobs fails when capped by limited funds --- eth/gasestimator/gasestimator.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eth/gasestimator/gasestimator.go b/eth/gasestimator/gasestimator.go index f07f98956e..9d33212fef 100644 --- a/eth/gasestimator/gasestimator.go +++ b/eth/gasestimator/gasestimator.go @@ -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) + } allowance := new(big.Int).Div(available, feeCap) // If the allowance is larger than maximum uint64, skip checking