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

Commit 5058cf4

Browse files
authored
Only account for execution gas in MaintainGasLimit (#253)
1 parent 9777e7f commit 5058cf4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pkg/modules/batch/gaslimit.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,29 @@ package batch
33
import (
44
"math/big"
55

6+
"github.com/stackup-wallet/stackup-bundler/pkg/gas"
67
"github.com/stackup-wallet/stackup-bundler/pkg/modules"
78
"github.com/stackup-wallet/stackup-bundler/pkg/userop"
89
)
910

1011
// MaintainGasLimit returns a BatchHandlerFunc that ensures the max gas used from the entire batch does not
1112
// exceed the allowed threshold.
1213
func MaintainGasLimit(maxBatchGasLimit *big.Int) modules.BatchHandlerFunc {
14+
// See comment in pkg/modules/checks/gas.go
15+
staticOv := gas.NewDefaultOverhead()
16+
1317
return func(ctx *modules.BatchHandlerCtx) error {
1418
bat := []*userop.UserOperation{}
1519
sum := big.NewInt(0)
1620
for _, op := range ctx.Batch {
17-
sum = big.NewInt(0).Add(sum, op.GetMaxGasAvailable())
21+
static, err := staticOv.CalcPreVerificationGas(op)
22+
if err != nil {
23+
return err
24+
}
25+
mgl := big.NewInt(0).Sub(op.GetMaxGasAvailable(), op.PreVerificationGas)
26+
mga := big.NewInt(0).Add(mgl, static)
27+
28+
sum = big.NewInt(0).Add(sum, mga)
1829
if sum.Cmp(maxBatchGasLimit) >= 0 {
1930
break
2031
}

0 commit comments

Comments
 (0)