This repository was archived by the owner on Oct 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 19
19
"maxFeePerGas" : "0xa862145e" ,
20
20
"maxPriorityFeePerGas" : "0xa8621440" ,
21
21
"paymasterAndData" : "0x" ,
22
- "preVerificationGas" : "0xc869 " ,
22
+ "preVerificationGas" : "0xc539 " ,
23
23
"signature" : "0xa925dcc5e5131636e244d4405334c25f034ebdd85c0cb12e8cdb13c15249c2d466d0bade18e2cafd3513497f7f968dcbb63e519acd9b76dcae7acd61f11aa8421b" ,
24
24
}
25
25
MockByteCode = common .Hex2Bytes ("6080604052" )
Original file line number Diff line number Diff line change @@ -4,12 +4,24 @@ import (
4
4
"fmt"
5
5
"math/big"
6
6
7
+ "github.com/stackup-wallet/stackup-bundler/pkg/gas"
7
8
"github.com/stackup-wallet/stackup-bundler/pkg/userop"
8
9
)
9
10
10
11
// ValidateGasAvailable checks that the max available gas is less than the batch gas limit.
11
12
func ValidateGasAvailable (op * userop.UserOperation , maxBatchGasLimit * big.Int ) error {
12
- if op .GetMaxGasAvailable ().Cmp (maxBatchGasLimit ) > 0 {
13
+ // This calculation ensures that we are only checking the gas used for execution. In rollups, the PVG also
14
+ // includes the L1 callData cost. If the L1 gas component spikes, it can cause the PVG value of legit ops
15
+ // to be greater than the maxBatchGasLimit. For non-rollups, the results would be the same as just calling
16
+ // op.GetMaxGasAvailable().
17
+ static , err := gas .NewDefaultOverhead ().CalcPreVerificationGas (op )
18
+ if err != nil {
19
+ return err
20
+ }
21
+ mgl := big .NewInt (0 ).Sub (op .GetMaxGasAvailable (), op .PreVerificationGas )
22
+ mga := big .NewInt (0 ).Add (mgl , static )
23
+
24
+ if mga .Cmp (maxBatchGasLimit ) > 0 {
13
25
return fmt .Errorf ("gasLimit: exceeds maxBatchGasLimit of %s" , maxBatchGasLimit .String ())
14
26
}
15
27
You can’t perform that action at this time.
0 commit comments