Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundler gives weird PVG in OP stack chains #908

Open
ChiHaoLu opened this issue Nov 11, 2024 · 7 comments
Open

Bundler gives weird PVG in OP stack chains #908

ChiHaoLu opened this issue Nov 11, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@ChiHaoLu
Copy link

ChiHaoLu commented Nov 11, 2024

Describe the bug
Hi, I use the alchemy bundler on OP stack chains, but the preVerificationGas returned by the estimateUserOperationGas is weird.

[JsonRpcProvider][eth_estimateUserOperationGas][request] {"jsonrpc":"2.0","id":0,"method":"eth_estimateUserOperationGas","params":[{"sender":"0x886249b36f169612fF75975071Cae0C51f80E8b1","nonce":"0x0","callData":"0xe9ae5c530100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000260000000000000000000000000886249b36f169612ff75975071cae0c51f80e8b1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000184d64db8fc0000000000000000000000004294dd02e30b9b6c8787d00dde46abe31aac506f00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000502801e794fd1b9048ec9c97fd34f62bf0488222000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a40fd8377b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000886249b36f169612ff75975071cae0c51f80e8b10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004294dd02e30b9b6c8787d00dde46abe31aac506f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001443f707e6b00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000094b008aa00579c1307b0ef2c499ad98a8ce58e58000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000002aeeb6ac7a9b98fa7a086f725df0cc10c3cbde2d00000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","factory":"0x5eab992e90ce6144df8f218c359bcafa787acd85","factoryData":"0x4d44ac28000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000124cf7a1d770000000000000000000000000000000071727de22e5e9d8baf0edac6f37da0320000000000000000000000005442f6bd07b08f164a616d829dda50eae93f2dae000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a06b9889c4476b60e9e1764e0a706e8d374c2c8c6ded1369a359102b618a1d1d573f362de3b13b75e9a09a2546d5ad59fda27dfd5531d194faa42ccaff19fb3c6e49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630000000000000000000000004d7f573039fddc84fdb28515ba20d75ef6b987ff000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000","maxFeePerGas":"0xf43ee","maxPriorityFeePerGas":"0xf4240","signature":"0x5442f6bd07b08f164a616d829dda50eae93f2dae000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040e6957b6184564b3c8619910d1c4814da267124d6b633ec4b6ea815b3d0a00c280556ef669e59df09d5ee03d48f76a9c2c5a927d66d51603dffc80330d3adeeef000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000005050000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000362c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73657d0000000000000000000000"},"0x0000000071727De22E5E9d8BAf0edAc6f37da032"]}
[JsonRpcProvider][eth_estimateUserOperationGas][response] {
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "preVerificationGas": "0x35b9c5",
    "callGasLimit": "0x85bb8",
    "verificationGasLimit": "0xdcbef",
    "paymasterVerificationGasLimit": null
  }
}

If I send this userOp to bundler, the precheck will failed due to PVG is too low.

Error: {
  "jsonrpc": "2.0",
  "id": 0,
  "error": {
    "code": -32000,
    "message": "precheck failed: preVerificationGas is 1133120 but must be at least 2490360"
  }
}

This problem also occurs in all OP stack.

To reproduce
Re-estimate the above userOp by calling Alchemy Bundler API again on OP mainnet before the block 0x79ed4e2.

Because I have sent userOp w/ this nonce on chain successfully be re-calculate the PVG by myself.

Expected behavior
The PVG should be lower.

@ChiHaoLu ChiHaoLu added bug Something isn't working needs-triage Issue needs triage labels Nov 11, 2024
@ChiHaoLu ChiHaoLu reopened this Nov 11, 2024
@ChiHaoLu ChiHaoLu changed the title Bundler gives weird PVG in Base Sepolia Bundler gives weird PVG in OP stack chains Nov 11, 2024
@dancoombs
Copy link
Collaborator

Couple of things here:

  1. PVG is a dynamic value on L2s as its dependent on both the L2 fees as well as the L1 DA fee (blob or calldata depending on the network). Thus, its important to quickly submit UOs after estimation. A buffer is also recommended to be added to increase the chances of landing the UO. The longer it takes between estimation and submission, the higher buffer you should use.
  2. Gas estimation uses the supplied maxFeePerGas and maxPriorityFeePerGas values when estimating. Since those impact PVG its recommended that they don't change between estimation and submission.
  3. When doing gas estimation is recommended to use dummy signatures that cause the highest amount of gas utilization, including calldata costs.

@ChiHaoLu
Copy link
Author

ChiHaoLu commented Nov 11, 2024

I know all of things you mentioned. But the problem is that the responded PVG is rational or not. It is much higher than other chains.

Below example is my latest userOp which sent successfully on OP mainnet.

The PVG (responded by bundler) is 0x21ea868(= 35,563,624), the total cost for userOp sender is 0x28515a648335 (= 0.000044329873998645 ETH).

[JsonRpcProvider][eth_estimateUserOperationGas][request] {"jsonrpc":"2.0","id":0,"method":"eth_estimateUserOperationGas","params":[{"sender":"0x5F890C1952e8952ACFafc829143aeEA5f2a27a5d","nonce":"0x0","callData":"0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002600000000000000000000000005f890c1952e8952acfafc829143aeea5f2a27a5d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000184d64db8fc00000000000000000000000092c6e5d5ceb3e069abe4b58caae0d850ae40e51c00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000502801e794fd1b9048ec9c97fd34f62bf0488222000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a40fd8377b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000024c4d66de80000000000000000000000005f890c1952e8952acfafc829143aeea5f2a27a5d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000092c6e5d5ceb3e069abe4b58caae0d850ae40e51c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001443f707e6b00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000094b008aa00579c1307b0ef2c499ad98a8ce58e58000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000002aeeb6ac7a9b98fa7a086f725df0cc10c3cbde2d00000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","factory":"0x5eab992e90ce6144df8f218c359bcafa787acd85","factoryData":"0x4d44ac28000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000124cf7a1d770000000000000000000000000000000071727de22e5e9d8baf0edac6f37da0320000000000000000000000005442f6bd07b08f164a616d829dda50eae93f2dae000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a06f0c704a838d013c0dcfcd626e71908f6d7e83e73f49cb4b8086cb066aa1ba34293c23677b07a0f1df6430d796fee487e382b16155d39903b21d7d7c08d52ad749960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630000000000000000000000004d7f573039fddc84fdb28515ba20d75ef6b987ff000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000","maxFeePerGas":"0x125175","maxPriorityFeePerGas":"0x124f80","signature":"0x5442f6bd07b08f164a616d829dda50eae93f2dae000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040e6957b6184564b3c8619910d1c4814da267124d6b633ec4b6ea815b3d0a00c280556ef669e59df09d5ee03d48f76a9c2c5a927d66d51603dffc80330d3adeeef000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000005050000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000362c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73657d0000000000000000000000"},"0x0000000071727De22E5E9d8BAf0edAc6f37da032"]}
[JsonRpcProvider][eth_estimateUserOperationGas][response] {
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "preVerificationGas": "0x21ea868",
    "callGasLimit": "0x85bb8",
    "verificationGasLimit": "0xeab91",
    "paymasterVerificationGasLimit": null
  }
}
[JsonRpcProvider][eth_sendUserOperation][request] {"jsonrpc":"2.0","id":0,"method":"eth_sendUserOperation","params":[{"sender":"0x5F890C1952e8952ACFafc829143aeEA5f2a27a5d","nonce":"0x0","callData":"0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002600000000000000000000000005f890c1952e8952acfafc829143aeea5f2a27a5d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000184d64db8fc00000000000000000000000092c6e5d5ceb3e069abe4b58caae0d850ae40e51c00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000502801e794fd1b9048ec9c97fd34f62bf0488222000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a40fd8377b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000024c4d66de80000000000000000000000005f890c1952e8952acfafc829143aeea5f2a27a5d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000092c6e5d5ceb3e069abe4b58caae0d850ae40e51c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001443f707e6b00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000094b008aa00579c1307b0ef2c499ad98a8ce58e58000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000002aeeb6ac7a9b98fa7a086f725df0cc10c3cbde2d00000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","factory":"0x5eab992e90ce6144df8f218c359bcafa787acd85","factoryData":"0x4d44ac28000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000124cf7a1d770000000000000000000000000000000071727de22e5e9d8baf0edac6f37da0320000000000000000000000005442f6bd07b08f164a616d829dda50eae93f2dae000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a06f0c704a838d013c0dcfcd626e71908f6d7e83e73f49cb4b8086cb066aa1ba34293c23677b07a0f1df6430d796fee487e382b16155d39903b21d7d7c08d52ad749960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630000000000000000000000004d7f573039fddc84fdb28515ba20d75ef6b987ff000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000","callGasLimit":"0x931b0","verificationGasLimit":"0x119aae","preVerificationGas":"0x21ea868","maxFeePerGas":"0x125175","maxPriorityFeePerGas":"0x47868c00","paymasterVerificationGasLimit":"0x0","paymasterPostOpGasLimit":"0x0","signature":"0x5442f6bd07b08f164a616d829dda50eae93f2dae000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040d12e1763053d948c80ff494b5f5b5c58d84dd3a28ceb33d3f00ef275902109ce132d60711a57eb402b5564b73769fe00b9d3112f8e2b95f3fd4b45ffa73acb1d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000005050000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a32c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73652c226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f796162506578227d000000000000000000000000000000000000000000000000000000000000"},"0x0000000071727De22E5E9d8BAf0edAc6f37da032"]}
[JsonRpcProvider][eth_sendUserOperation][response] {
  "jsonrpc": "2.0",
  "id": 0,
  "result": "0x04838cbbccca629ad6b038e2da91a1969a7f070bf2a1a3d88f7aaac190b5f9fc"
}

@ChiHaoLu
Copy link
Author

Besides, the responded PVG from eth_estimateUserOperationGas is very different from the precheck in eth_sendUserOperation. How can I calculate a rational PVG which can make my userOp on-chain but not exceed too much?

@dancoombs
Copy link
Collaborator

PVG is charging for L1 DA costs in L2 gas. So if L1 costs are high, but L2 gas is low, then PVG may be a large number. But in terms of absolute cost, it should be similar to any L2 transaction (maybe slightly higher due to due PVG buffers).

@dancoombs
Copy link
Collaborator

Besides, the responded PVG from eth_estimateUserOperationGas is very different from the precheck in eth_sendUserOperation.

What do you mean from the precheck?

How can I calculate a rational PVG which can make my userOp on-chain but not exceed too much?

  1. Estimate gas fees
  2. Submit a eth_estimateUserOperationGas with those fees and dummy signature
  3. Apply a buffer on the returned PVG. This buffer is application dependent.
  4. Sign and submit UO. The faster this is done after (2) the better the PVG estimate will be.

@ChiHaoLu
Copy link
Author

My question is the precheck from here which occurs in eth_sendUserOperation. Do you know Alchemy Bundler do a precheck in the eth_sendUserOperation?

Error: {
  "jsonrpc": "2.0",
  "id": 0,
  "error": {
    "code": -32000,
    "message": "precheck failed: preVerificationGas is 1133120 but must be at least 2490360"
  }
}

You can reproduce this error by:

  1. Estimating an userOp by eth_estimateUserOperationGas and get the bundler suggests PVG (maybe a x value).
  2. Changing the PVG to 0.
  3. Send it to Bundler by eth_sendUserOperation.
  4. You get a precheck error which requires your userOp at least y which is totally different from the x.

@dancoombs
Copy link
Collaborator

Yes, I understand what you mean now. The required preVerificationGas value changes on L2s due to changes in fees and a higher value may be required when you submit. The same suggestions from this comment apply #908 (comment)

@dancoombs dancoombs removed the needs-triage Issue needs triage label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants