Skip to content

Instantly share code, notes, and snippets.

@imqdee
Last active May 6, 2024 20:32
Show Gist options
  • Select an option

  • Save imqdee/6a5e1709dd8f62b8e245d70c00572922 to your computer and use it in GitHub Desktop.

Select an option

Save imqdee/6a5e1709dd8f62b8e245d70c00572922 to your computer and use it in GitHub Desktop.

This RPC call works great when using a bundler not managed by Alchemy. However, an error is triggered when using your bundler.

cast rpc eth_estimateUserOperationGas "{\"sender\":\"0x80b86933313237be38B9E87dDbe99865A12c8ddd\",\"nonce\":\"0x0\",\"initCode\":\"0x29e69af6083f790d31804ed9adad40ccc32accc9af09872500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000120728da5b63228c33d0f2e2797ee87fda099a2795a31831d5e8f406a4a8be80ad4000000000000000000000000000000000000000000000000000000000000009849960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97635d00000000fbfc3007154e4ecc8c0b6e020557d7bd0014f4da2a72a853013e7a71eab983e798c0d3e190c6a5010203262001215820551be8f48a4b2d77a8cf8fe565fd8644c77f44aef04099b6764acf668a5dea0f225820e92de8f6a8d71246b08f68a8cfc10de82ee97f51b4cd585d978a1097931fc7720000000000000000000000000000000000000000000000000000000000000000000000000000004200f7aabdbddb526bb02fc3a1138ae375236d229c571509109d5ba7d5dd1591c6c058cbe00ad06e311706a0bb4a2d7cc8732a27a6f88d110c8e6376bdf53c2635f91c000000000000000000000000000000000000000000000000000000000000\",\"callData\":\"0xb61d27f6000000000000000000000000770be037c2e8b80e1e2c27ab1dbcf19ecfb022370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000041249c58b00000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"0x88b8\",\"verificationGasLimit\":\"0x11170\",\"preVerificationGas\":\"0x5208\",\"maxFeePerGas\":\"0x11401c\",\"maxPriorityFeePerGas\":\"0x113e10\",\"paymasterAndData\":\"0x904dff443aac03cefc537a85a98c1cd590dbbcb925134e88a75fce2b422d9cc1a0ddbd9eb74d720e6226c209a30297bae08c74b617bd0240c65bb42c5d7b96acfd5b228ecb94c020e68c508b2512923c9ea994031b\",\"signature\":\"0x00f7aabdbddb526bb02fc3a1138ae375236d229c571509109d5ba7d5dd1591c6c058cbe00ad06e311706a0bb4a2d7cc8732a27a6f88d110c8e6376bdf53c2635f91c\"}" "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" --rpc-url https://public.stackup.sh/api/v1/node/optimism-sepolia

{"preVerificationGas":206075716,"verificationGasLimit":396726,"callGasLimit":64706,"verificationGas":396726}

When using the RPC provided by Alchemy (https://opt-sepolia.g.alchemy.com/v2/XXXXXXX), the following error is triggered.

(code: -32500, message: validation reverted: [reason]: AA13 initCode failed or OOG, data: Some(Object {"reason": String("AA13 initCode failed or OOG")}))

What do you think? Could it be an issue from Rundler?

@imqdee
Copy link
Author

imqdee commented May 2, 2024

It works by removing the callGasLimit and verificationGasLimit fields as pointed out by @dancoombs on the Rundler Telegram.

Here is @dancoombs' explanation:

When you supply them during eth_estimateUserOperationGas Rundler doesn't estimate them, but just tries to verify that they are enough gas, skipping the expensive estimation procedure. We believe this to be inline with the spec https://github.com/eth-infinitism/account-abstraction/blob/develop/erc/ERCS/erc-4337.md#-eth_estimateuseroperationgas

Stackup's bundler seems to ignore them and perform gas estimation anyway.

@imqdee
Copy link
Author

imqdee commented May 4, 2024

Here is John Rising's response from @stackup-wallet

Hi qdqd, yes the Stackup bundler interprets a 0 gas parameter as one that is unspecified and will estimate it. When we asked Dan from Alchemy about how they interpret the spec, he said that Alchemy's Rundler performs the following logic:
If a gas limit is provided AND non-zero, then skip the estimation procedure for that limit, validate that its enough gas and that the call passes, and return the field as is.
If a gas limit is not provided OR zero, then run the estimation procedure.
So the Alchemy Rundler should behave the same as Stackup's bundler when eth_estimateUserOperationGas is called with 0 for callGasLimit and verificationGasLimit.
However, if callGasLimit and verificationGasLimit are undefined Stackup's bundler will return an error but Alchemy's Rundler won't. This is a difference in how we interpret the spec. We've assumed that these fields are required even if set to 0 since that's what the v0.6 test schema from the Ethereum Foundation implies. However, this is an inconsistency that we'll resolve with the other bundler teams so that all bundler implementations have the same interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment