What is the proper way of detecting when UO runs out of gas?
rho-cassiopeiae opened this issue · 1 comments
I'm playing around with a local bundler.
For some reason, first UO for every sender always fails because it runs out of gas. Even doubling the values received from eth_estimateUserOperationGas
doesn't help. Tripling usually works though. Subsequent UOs (when the sender is already deployed) succeed right away.
Does eth_estimateUserOperationGas
not account for account deployment?
And how to properly detect OOG?
Here is the eth_getUserOperationReceipt
output of one of the initCode
containing UOs:
{
"jsonrpc": "2.0",
"id": 0,
"result": {
"userOpHash": "0x754633b06d63307d5a1405e5a2da444ae4fcd7e43983012ad174a504c09dbe5d",
"sender": "0x20FD69D46DC690ef926d209FF016398D6613F168",
"nonce": "0x0",
"actualGasCost": "0xfd2c1be369e",
"actualGasUsed": "0x73c99",
"success": false,
"logs": [],
"receipt": {
"to": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"contractAddress": null,
"transactionIndex": "0x0",
"gasUsed": "0x694b0",
"logsBloom": "0x000004000000000000000000000000004000000000000000000000010000000000180000000000000002000100000000801000000000000000000a00000020000000000000000002000000000000020080000000000000000000000000002000000000000a0000000000000000010800000000000000004000800000000200000000000000000000000000000000000000000200000480000000000008000000000000000000100000400004000400000000000000000000000002000000000000000020000000000001000000040040000000000000000000002000000020000240000000110002000000000000000000000000000000000000000000000000",
"blockHash": "0x6fc08eb018a97642b4fe1bfc875369d0fe655189b3394c5349b36021243d8353",
"transactionHash": "0x9b0220d14f82d02cc0bc100fb01a07d7510f1aa3fb15965a5e9bcc88c9f64718",
"logs": [
{
"transactionIndex": "0x0",
"blockNumber": "0x1d",
"transactionHash": "0x9b0220d14f82d02cc0bc100fb01a07d7510f1aa3fb15965a5e9bcc88c9f64718",
"address": "0x20FD69D46DC690ef926d209FF016398D6613F168",
"topics": [
"0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b",
"0x0000000000000000000000008abb13360b87be5eeb1b98647a016add927a136c"
],
"data": "0x",
"logIndex": "0x0",
"blockHash": "0x6fc08eb018a97642b4fe1bfc875369d0fe655189b3394c5349b36021243d8353"
},
{
"transactionIndex": "0x0",
"blockNumber": "0x1d",
"transactionHash": "0x9b0220d14f82d02cc0bc100fb01a07d7510f1aa3fb15965a5e9bcc88c9f64718",
"address": "0x20FD69D46DC690ef926d209FF016398D6613F168",
"topics": [
"0x47e55c76e7a6f1fd8996a1da8008c1ea29699cca35e7bcd057f2dec313b6e5de",
"0x0000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d2789",
"0x000000000000000000000000bf2ff171c3c4a63fbbd369ddb021c75934005e81"
],
"data": "0x",
"logIndex": "0x1",
"blockHash": "0x6fc08eb018a97642b4fe1bfc875369d0fe655189b3394c5349b36021243d8353"
},
{
"transactionIndex": "0x0",
"blockNumber": "0x1d",
"transactionHash": "0x9b0220d14f82d02cc0bc100fb01a07d7510f1aa3fb15965a5e9bcc88c9f64718",
"address": "0x20FD69D46DC690ef926d209FF016398D6613F168",
"topics": [
"0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000001",
"logIndex": "0x2",
"blockHash": "0x6fc08eb018a97642b4fe1bfc875369d0fe655189b3394c5349b36021243d8353"
},
{
"transactionIndex": "0x0",
"blockNumber": "0x1d",
"transactionHash": "0x9b0220d14f82d02cc0bc100fb01a07d7510f1aa3fb15965a5e9bcc88c9f64718",
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"topics": [
"0xd51a9c61267aa6196961883ecf5ff2da6619c37dac0fa92122513fb32c032d2d",
"0x754633b06d63307d5a1405e5a2da444ae4fcd7e43983012ad174a504c09dbe5d",
"0x00000000000000000000000020fd69d46dc690ef926d209ff016398d6613f168"
],
"data": "0x0000000000000000000000009406cc6185a346906296840746125a0e449764540000000000000000000000000000000000000000000000000000000000000000",
"logIndex": "0x3",
"blockHash": "0x6fc08eb018a97642b4fe1bfc875369d0fe655189b3394c5349b36021243d8353"
},
{
"transactionIndex": "0x0",
"blockNumber": "0x1d",
"transactionHash": "0x9b0220d14f82d02cc0bc100fb01a07d7510f1aa3fb15965a5e9bcc88c9f64718",
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"topics": [
"0x2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c4",
"0x00000000000000000000000020fd69d46dc690ef926d209ff016398d6613f168"
],
"data": "0x000000000000000000000000000000000000000000000000000039ab48b003b8",
"logIndex": "0x4",
"blockHash": "0x6fc08eb018a97642b4fe1bfc875369d0fe655189b3394c5349b36021243d8353"
},
{
"transactionIndex": "0x0",
"blockNumber": "0x1d",
"transactionHash": "0x9b0220d14f82d02cc0bc100fb01a07d7510f1aa3fb15965a5e9bcc88c9f64718",
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"topics": [
"0xbb47ee3e183a558b1a2ff0874b079f3fc5478b7454eacf2bfc5af2ff5878f972"
],
"data": "0x",
"logIndex": "0x5",
"blockHash": "0x6fc08eb018a97642b4fe1bfc875369d0fe655189b3394c5349b36021243d8353"
},
{
"transactionIndex": "0x0",
"blockNumber": "0x1d",
"transactionHash": "0x9b0220d14f82d02cc0bc100fb01a07d7510f1aa3fb15965a5e9bcc88c9f64718",
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"topics": [
"0x49628fd1471006c1482da88028e9ce4dbb080b815c9b0344d39e5a8e6ec1419f",
"0x754633b06d63307d5a1405e5a2da444ae4fcd7e43983012ad174a504c09dbe5d",
"0x00000000000000000000000020fd69d46dc690ef926d209ff016398d6613f168",
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fd2c1be369e0000000000000000000000000000000000000000000000000000000000073c99",
"logIndex": "0x6",
"blockHash": "0x6fc08eb018a97642b4fe1bfc875369d0fe655189b3394c5349b36021243d8353"
}
],
"blockNumber": "0x1d",
"confirmations": "0x1",
"cumulativeGasUsed": "0x694b0",
"effectiveGasPrice": "0x5b97ef4e",
"status": "0x1",
"type": "0x2",
"byzantium": true
}
}
}
The final event in the logs is UserOperationEvent
. It decodes into:
{
"userOpHash": "0x754633b06d63307d5a1405e5a2da444ae4fcd7e43983012ad174a504c09dbe5d",
"sender": "0x20FD69D46DC690ef926d209FF016398D6613F168",
"paymaster": "0x0000000000000000000000000000000000000000",
"nonce": 0,
"success": false,
"actualGasCost": 17397868017310,
"actualGasUsed": 474265
}
But there's no UserOperationRevertReason
event or anything explaining the reason as far as I can see.
How should I detect OOG? Check success == false and then compare actualGasUsed
with the values that I set on the UO?
UserOperationRevertReason event is emitted only if there is a non-empty reason. so if it isn't emitted, (and success=false), it means there was a revert with no reason, which is probably OOG. like normal TX, you can't tell OOG from "just" revert with no reason (the actualGasUsed should probably be a good hint of OOG)
regarding gas estimation: yes, we know we currently don't calculate it correctly. it is strange, though that it is 3x. can you give a concrete example?