graph-node
graph-node copied to clipboard
try_ can not trap reverts due to InternalError ModuleError error
Do you want to request a feature or report a bug?
Bug
What is the current behavior? We are using version Graph Node version: 0.27.0 :: fraction2+16 (7356e0b16 2022-09-19). We have a mapping that performs an eth_call using the try_ form of a contract function so that we can trap reverts. However, we are seeing that a revert fails to be trapped by the try_ function.
docker-graph-node-1 | Sep 21 04:17:46.315 WARN Trying again after eth_call RPC call for block #1570881 (5f6ed3d120495bb4d3db642b144a64e04f5a277528294da023faf9777a19de9e) failed (attempt #10) with result Err(Web3Error(Rpc(Error { code: InternalError, message: "execution fatal: Module(ModuleError { index: 60, error: [7, 0, 0, 0], message: None })", data: None }))), sgd: 1, subgraph_id: QmeJGJQ1CkHwFWgzqF28Xrmoxdu1RosK8dFGgT8NgNq9MD, component: SubgraphInstanceManager
docker-graph-node-1 | Sep 21 04:17:46.317 INFO Done processing trigger, gas_used: 0, data_source: Contract, handler: handleOfferCreated, total_ms: 1972, transaction: 0x6fde…5554, address: 0xd7e2…06d2, signature: OfferCreated(indexed bytes16,address,uint256,address,bytes32), sgd: 1, subgraph_id: QmeJGJQ1CkHwFWgzqF28Xrmoxdu1RosK8dFGgT8NgNq9MD, component: SubgraphInstanceManager
docker-graph-node-1 | Sep 21 04:17:46.318 INFO Possible reorg detected, retrying, error: failed to process trigger: block #1570881 (0x5f6e…de9e), transaction 6fdef523e943f1fcbd76e0de67a8ab998379538f45f9b050f69bcc9fa94b5554: Ethereum node returned an error when calling function "getOffer" of contract "Contract": RPC error: Error { code: InternalError, message: "execution fatal: Module(ModuleError { index: 60, error: [7, 0, 0, 0], message: None })", data: None }
docker-graph-node-1 | wasm backtrace:
docker-graph-node-1 | 0: 0x2267 - <unknown>!generated/Contract/Contract/Contract#try_getOffer
docker-graph-node-1 | 1: 0x4a32 - <unknown>!src/mapping/handleOfferCreated
docker-graph-node-1 | , block_hash: 0x5f6ed3d120495bb4d3db642b144a64e04f5a277528294da023faf9777a19de9e, block_number: 1570881, sgd: 1, subgraph_id: QmeJGJQ1CkHwFWgzqF28Xrmoxdu1RosK8dFGgT8NgNq9MD, component: SubgraphInstanceManager
docker-graph-node-1 | Sep 21 04:17:46.582 INFO Scanning blocks [1443664, 1443664], range_size: 1, sgd: 1, subgraph_id: QmeJGJQ1CkHwFWgzqF28Xrmoxdu1RosK8dFGgT8NgNq9MD, component: BlockStream
export function handleOfferCreated(event: OfferCreated): void {
let contract = Contract.bind(event.address);
let offerResult = contract.try_getOffer(event.params.offerId);
if (offerResult.reverted) { return; }
let offer = offerResult.value;
//
}
- event: OfferCreated(indexed bytes16,address,uint256,address,bytes32)
handler: handleOfferCreated
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
$ curl https://evm.astar.network/ -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"data":"0x7448b2c08c22659db0f5454796efdc2590d47f9000000000000000000000000000000000","gas":"0x2faf080","to":"0xd7e22afb7bfd8d04e025fa34b65e306f47f606d2"},{"blockHash":"0x5f6ed3d120495bb4d3db642b144a64e04f5a277528294da023faf9777a19de9e"}],"id":3380}' -H 'Content-Type: application/json'
{"jsonrpc":"2.0","error":{"code":-32603,"message":"execution fatal: Module(ModuleError { index: 60, error: [7, 0, 0, 0], message: None })"},"id":3380}
What is the expected behavior?
My expectation would be that the call:
let offerResult = contract.try_getOffer(event.params.offerId);
would actually absorb the revert without error, and that offerResult.reverted would be equal to true.
facing the same issue here! any progress so far?
hi @longhoangwkm that is indeed an error, bit it looks like an execution error rather than an eth_call revert, which I think is why it isn't been handled by the try_, is that correct @leoyvens?
Is that revert message expected @jessepinkman9900 @longhoangwkm, what is happening there, execution fatal?
HI @azf20, I think any error from jsonrpc response should be caught by try_ 🤔
try_ will only work when json rpc error is recognized by graph node as an error that's known to be deterministic. Astar is not yet supported in the network so we haven't evaluated its error format. But on your node you can set the environment variable GRAPH_GETH_ETH_CALL_ERRORS='execution fatal' and it will classify that as a deterministic error.
Thanks @leoyvens , let me try again and report later
It works now, Thanks @leoyvens, but I think it's a temporary solution, hopefully there is a fix for the root cause