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

Commit 55d142e

Browse files
authored
Reduce variability in Arbitrum PVG by sanitising paymasterAndData (#193)
1 parent 30dfee6 commit 55d142e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pkg/gas/pvg.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gas
22

33
import (
4+
"bytes"
45
"context"
56
"math"
67
"math/big"
@@ -39,9 +40,22 @@ func CalcArbitrumPVGWithEthClient(
3940
pk, _ := crypto.GenerateKey()
4041
dummy, _ := signer.New(hexutil.Encode(crypto.FromECDSA(pk))[2:])
4142
return func(op *userop.UserOperation, static *big.Int) (*big.Int, error) {
43+
// Sanitize paymasterAndData.
44+
// TODO: Figure out why variability in this field is causing Arbitrum's precompile to return different
45+
// values.
46+
data, err := op.ToMap()
47+
if err != nil {
48+
return nil, err
49+
}
50+
data["paymasterAndData"] = hexutil.Encode(bytes.Repeat([]byte{1}, len(op.PaymasterAndData)))
51+
tmp, err := userop.New(data)
52+
if err != nil {
53+
return nil, err
54+
}
55+
4256
// Pack handleOps method inputs
4357
ho, err := methods.HandleOpsMethod.Inputs.Pack(
44-
[]entrypoint.UserOperation{entrypoint.UserOperation(*op)},
58+
[]entrypoint.UserOperation{entrypoint.UserOperation(*tmp)},
4559
dummy.Address,
4660
)
4761
if err != nil {
@@ -50,7 +64,7 @@ func CalcArbitrumPVGWithEthClient(
5064

5165
// Encode function data for gasEstimateL1Component
5266
create := false
53-
if op.Nonce.Cmp(common.Big0) == 0 {
67+
if tmp.Nonce.Cmp(common.Big0) == 0 {
5468
create = true
5569
}
5670
ge, err := nodeinterface.GasEstimateL1ComponentMethod.Inputs.Pack(

0 commit comments

Comments
 (0)