Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit cbb1388

Browse files
authored
Check fee values are > 0 before estimating gas to prevent division by 0 panic (#149)
1 parent 19ee343 commit cbb1388

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/gas/estimate.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/ethereum/go-ethereum/common/hexutil"
88
"github.com/ethereum/go-ethereum/rpc"
99
"github.com/stackup-wallet/stackup-bundler/pkg/entrypoint/execution"
10+
"github.com/stackup-wallet/stackup-bundler/pkg/errors"
1011
"github.com/stackup-wallet/stackup-bundler/pkg/userop"
1112
)
1213

@@ -22,6 +23,13 @@ func EstimateGas(
2223
chainID *big.Int,
2324
tracer string,
2425
) (verificationGas uint64, callGas uint64, err error) {
26+
if op.MaxFeePerGas.Cmp(big.NewInt(0)) != 1 || op.MaxPriorityFeePerGas.Cmp(big.NewInt(0)) != 1 {
27+
return 0, 0, errors.NewRPCError(
28+
errors.INVALID_FIELDS,
29+
"maxFeePerGas and maxPriorityFeePerGas must be more than 0",
30+
nil,
31+
)
32+
}
2533
data, err := op.ToMap()
2634
if err != nil {
2735
return 0, 0, err

0 commit comments

Comments
 (0)