Skip to content

Commit 93a7c9f

Browse files
nand2fjl
authored andcommitted
eth/gasestimator: include blobs in virtual balance computation (ethereum#29703)
Fixes ethereum#29702 Co-authored-by: Felix Lange <fjl@twurst.com>
1 parent 573c19b commit 93a7c9f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

eth/gasestimator/gasestimator.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uin
8080
}
8181
available.Sub(available, call.Value)
8282
}
83+
if opts.Config.IsCancun(opts.Header.Number, opts.Header.Time) && len(call.BlobHashes) > 0 {
84+
blobGasPerBlob := new(big.Int).SetInt64(params.BlobTxBlobGasPerBlob)
85+
blobBalanceUsage := new(big.Int).SetInt64(int64(len(call.BlobHashes)))
86+
blobBalanceUsage.Mul(blobBalanceUsage, blobGasPerBlob)
87+
blobBalanceUsage.Mul(blobBalanceUsage, call.BlobGasFeeCap)
88+
if blobBalanceUsage.Cmp(available) >= 0 {
89+
return 0, nil, core.ErrInsufficientFunds
90+
}
91+
available.Sub(available, blobBalanceUsage)
92+
}
8393
allowance := new(big.Int).Div(available, feeCap)
8494

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

0 commit comments

Comments
 (0)