This repository was archived by the owner on Oct 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -3,18 +3,29 @@ package batch
3
3
import (
4
4
"math/big"
5
5
6
+ "github.com/stackup-wallet/stackup-bundler/pkg/gas"
6
7
"github.com/stackup-wallet/stackup-bundler/pkg/modules"
7
8
"github.com/stackup-wallet/stackup-bundler/pkg/userop"
8
9
)
9
10
10
11
// MaintainGasLimit returns a BatchHandlerFunc that ensures the max gas used from the entire batch does not
11
12
// exceed the allowed threshold.
12
13
func MaintainGasLimit (maxBatchGasLimit * big.Int ) modules.BatchHandlerFunc {
14
+ // See comment in pkg/modules/checks/gas.go
15
+ staticOv := gas .NewDefaultOverhead ()
16
+
13
17
return func (ctx * modules.BatchHandlerCtx ) error {
14
18
bat := []* userop.UserOperation {}
15
19
sum := big .NewInt (0 )
16
20
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 )
18
29
if sum .Cmp (maxBatchGasLimit ) >= 0 {
19
30
break
20
31
}
You can’t perform that action at this time.
0 commit comments