@@ -14,10 +14,12 @@ import (
14
14
"github.com/stackup-wallet/stackup-bundler/pkg/userop"
15
15
)
16
16
17
- type CalcPreVerificationGasFunc = func (op * userop.UserOperation ) (* big.Int , error )
17
+ // CalcPreVerificationGasFunc defines an interface for a function to calculate PVG given a userOp and a static
18
+ // value. The static input is the value derived from the default overheads.
19
+ type CalcPreVerificationGasFunc = func (op * userop.UserOperation , static * big.Int ) (* big.Int , error )
18
20
19
21
func calcPVGFuncNoop () CalcPreVerificationGasFunc {
20
- return func (op * userop.UserOperation ) (* big.Int , error ) {
22
+ return func (op * userop.UserOperation , static * big. Int ) (* big.Int , error ) {
21
23
return nil , nil
22
24
}
23
25
}
@@ -30,7 +32,7 @@ func CalcArbitrumPVGWithEthClient(
30
32
) CalcPreVerificationGasFunc {
31
33
pk , _ := crypto .GenerateKey ()
32
34
dummy , _ := signer .New (hexutil .Encode (crypto .FromECDSA (pk ))[2 :])
33
- return func (op * userop.UserOperation ) (* big.Int , error ) {
35
+ return func (op * userop.UserOperation , static * big. Int ) (* big.Int , error ) {
34
36
// Pack handleOps method inputs
35
37
ho , err := methods .HandleOpsMethod .Inputs .Pack (
36
38
[]entrypoint.UserOperation {entrypoint .UserOperation (* op )},
@@ -65,11 +67,11 @@ func CalcArbitrumPVGWithEthClient(
65
67
return nil , err
66
68
}
67
69
68
- // Return GasEstimateForL1 as PVG
70
+ // Return static + GasEstimateForL1 as PVG
69
71
gas , err := nodeinterface .DecodeGasEstimateL1ComponentOutput (out )
70
72
if err != nil {
71
73
return nil , err
72
74
}
73
- return big .NewInt (int64 (gas .GasEstimateForL1 )), nil
75
+ return big .NewInt (0 ). Add ( static , big . NewInt ( int64 (gas .GasEstimateForL1 ) )), nil
74
76
}
75
77
}
0 commit comments