From 8052856b7600c49425a12b0513965f567cf9ac93 Mon Sep 17 00:00:00 2001 From: hazim-j Date: Thu, 30 May 2024 03:32:34 +1000 Subject: [PATCH] OP stack: use getL1FeeUpperBound for PVG calculations --- pkg/gas/pvg.go | 6 +++--- pkg/optimism/gaspriceoracle/methods.go | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pkg/gas/pvg.go b/pkg/gas/pvg.go index 4b6d64db..4e1dcaa0 100644 --- a/pkg/gas/pvg.go +++ b/pkg/gas/pvg.go @@ -137,7 +137,7 @@ func CalcOptimismPVGWithEthClient( if err != nil { return nil, err } - ge, err := gaspriceoracle.GetL1FeeMethod.Inputs.Pack(data) + ge, err := gaspriceoracle.GetL1FeeUpperBoundMethod.Inputs.Pack(big.NewInt(int64(len(data)))) if err != nil { return nil, err } @@ -146,7 +146,7 @@ func CalcOptimismPVGWithEthClient( req := map[string]any{ "from": common.HexToAddress("0x"), "to": gaspriceoracle.PrecompileAddress, - "data": hexutil.Encode(append(gaspriceoracle.GetL1FeeMethod.ID, ge...)), + "data": hexutil.Encode(append(gaspriceoracle.GetL1FeeUpperBoundMethod.ID, ge...)), } var out any if err := rpc.Call(&out, "eth_call", &req, "latest"); err != nil { @@ -154,7 +154,7 @@ func CalcOptimismPVGWithEthClient( } // Get L1Fee and L2Price - l1fee, err := gaspriceoracle.DecodeGetL1FeeMethodOutput(out) + l1fee, err := gaspriceoracle.DecodeGetL1FeeUpperBoundOutput(out) if err != nil { return nil, err } diff --git a/pkg/optimism/gaspriceoracle/methods.go b/pkg/optimism/gaspriceoracle/methods.go index e842cccf..0be2d66e 100644 --- a/pkg/optimism/gaspriceoracle/methods.go +++ b/pkg/optimism/gaspriceoracle/methods.go @@ -10,18 +10,17 @@ import ( ) var ( - bytesT, _ = abi.NewType("bytes", "", nil) uint256T, _ = abi.NewType("uint256", "", nil) - GetL1FeeMethod = abi.NewMethod( - "getL1Fee", - "getL1Fee", + GetL1FeeUpperBoundMethod = abi.NewMethod( + "getL1FeeUpperBound", + "getL1FeeUpperBound", abi.Function, "", false, false, abi.Arguments{ - {Name: "data", Type: bytesT}, + {Name: "data", Type: uint256T}, }, abi.Arguments{ {Name: "fee", Type: uint256T}, @@ -29,7 +28,7 @@ var ( ) ) -func DecodeGetL1FeeMethodOutput(out any) (*big.Int, error) { +func DecodeGetL1FeeUpperBoundOutput(out any) (*big.Int, error) { hex, ok := out.(string) if !ok { return nil, errors.New("getL1Fee: cannot assert type: hex is not of type string") @@ -39,7 +38,7 @@ func DecodeGetL1FeeMethodOutput(out any) (*big.Int, error) { return nil, fmt.Errorf("getL1Fee: %s", err) } - args, err := GetL1FeeMethod.Outputs.Unpack(data) + args, err := GetL1FeeUpperBoundMethod.Outputs.Unpack(data) if err != nil { return nil, fmt.Errorf("getL1Fee: %s", err) }