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
33import (
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.
1213func 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 }
You can’t perform that action at this time.
0 commit comments