Gas simulation issue when emptying an implicit account into a new implicit account
I am using the RPC `helpers/scripts/run_operation` to retrieve the `consumed_gas` associated with emptying an implicit account into a new (not allocated) implicit account. The returned `consumed_gas` value is 1420 units. However, when trying to pre-apply the operation using the RPC `helpers/preapply/operations`, and a `gas_limit` of 1420 (+buffer of 100), the status of the transaction is backtracked with `proto.010-PtGRANAD.gas_exhausted.operation`. It seems that the `consumed_gas` value returned by the `run_operation` is too low in this particular case. I need to call the pre-apply endpoint with a higher `gas_limit` to have it successful (i.e., 1920 gas units). There are additional details/discussions on this thread: https://tezos-dev.slack.com/archives/C596FGNUR/p1631154106164100 Example response from the RPC helpers/scripts/run_operation: ``` { "contents": [ { "kind": "transaction", "source": "tz3QJfCeRULYDZoTiD36de8qbsHsT9dQc9AP", "fee": "0", "counter": "490749", "gas_limit": "1040000", "storage_limit": "35996", "amount": "6999120", "destination": "tz3jTCGUobcz1GoYhU1QTsobRqmVytVDvYaE", "metadata": { "balance_updates": [], "operation_result": { "status": "applied", "balance_updates": [ { "kind": "contract", "contract": "tz3QJfCeRULYDZoTiD36de8qbsHsT9dQc9AP", "change": "-6999120", "origin": "block" }, { "kind": "contract", "contract": "tz3jTCGUobcz1GoYhU1QTsobRqmVytVDvYaE", "change": "6999120", "origin": "block" }, { "kind": "contract", "contract": "tz3QJfCeRULYDZoTiD36de8qbsHsT9dQc9AP", "change": "-64250", "origin": "block" } ], "consumed_gas": "1420", "consumed_milligas": "1420000", "allocated_destination_contract": true } } } ], "signature": "edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg" } ``` Example response from the RPC `helpers/preapply/operations`: ``` [ { "contents": [ { "kind": "transaction", "source": "tz3SpKcrMiiL1E8ijDmZwfbdcDxRxu2R73f2", "fee": "443", "counter": "498026", "gas_limit": "1520", "storage_limit": "257", "amount": "8934427", "destination": "tz3SHdNomLvR8bcdd3NossSjxWamPuG82UHL", "metadata": { "balance_updates": [ { "kind": "contract", "contract": "tz3SpKcrMiiL1E8ijDmZwfbdcDxRxu2R73f2", "change": "-443", "origin": "block" }, { "kind": "freezer", "category": "fees", "delegate": "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU", "cycle": 108, "change": "443", "origin": "block" } ], "operation_result": { "status": "backtracked", "errors": [ { "kind": "temporary", "id": "proto.010-PtGRANAD.contract.cannot_pay_storage_fee" }, { "kind": "temporary", "id": "proto.010-PtGRANAD.gas_exhausted.operation" } ], "balance_updates": [ { "kind": "contract", "contract": "tz3SpKcrMiiL1E8ijDmZwfbdcDxRxu2R73f2", "change": "-8934427", "origin": "block" }, { "kind": "contract", "contract": "tz3SHdNomLvR8bcdd3NossSjxWamPuG82UHL", "change": "8934427", "origin": "block" }, { "kind": "contract", "contract": "tz3SpKcrMiiL1E8ijDmZwfbdcDxRxu2R73f2", "change": "-64250", "origin": "block" } ], "consumed_gas": "1420", "consumed_milligas": "1420000", "allocated_destination_contract": true } } } ], "signature": "p2sigQv2GeJHSzCXxxUasvAvTUsHzgxTCmYryLd6ihcXrtCuuzut6JNYVRR1iNTdgLG7DMVnp9Hv6LCgmmgqc316tC68tv5ynm" } ] ```
issue