mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
core: new err to check balance and blobBalanceUsage
This commit is contained in:
parent
86a1f0c394
commit
548b39c522
2 changed files with 12 additions and 0 deletions
|
|
@ -68,6 +68,10 @@ var (
|
|||
// is higher than the balance of the user's account.
|
||||
ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value")
|
||||
|
||||
// ErrEip4844InsufficientFunds is returned if the total cost of executing an EIP-4844 transaction
|
||||
// is higher than the balance of the user's account, including the cost of blob gas.
|
||||
ErrEip4844InsufficientFunds = errors.New("insufficient funds for gas * price + blobGas * blobGasPrice + value")
|
||||
|
||||
// ErrGasUintOverflow is returned when calculating gas usage.
|
||||
ErrGasUintOverflow = errors.New("gas uint64 overflow")
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,14 @@ 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)
|
||||
if blobBalanceUsage.Cmp(available) > 0 {
|
||||
return 0, nil, core.ErrEip4844InsufficientFunds
|
||||
}
|
||||
available.Sub(available, blobBalanceUsage)
|
||||
}
|
||||
allowance := new(big.Int).Div(available, feeCap)
|
||||
|
||||
// If the allowance is larger than maximum uint64, skip checking
|
||||
|
|
|
|||
Loading…
Reference in a new issue