graph-node: Make `function not found` a deterministic failure

Do you want to request a feature or report a bug? Bug

What is the current behavior? If a subgraph handler calls a function that doesn’t exist, the subgraph fails with deterministic: false, and the following error log:

failed to process trigger: block #13380099 (0x38d4…b3aa), transaction ca32b1581b837c6ca539cf6c2fd542e9bcacbdc345c6a424382b4f0e48b96153: function handleSwapped not found

Example subgraph

What is the expected behavior? This handler will never run successfully, so this error should be deterministic

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 15 (8 by maintainers)

Most upvoted comments

I’ve observed these myself:

(Same as OP) On block 13380098 (38d484acc0f3fe698ac05340877f5d8f766bb23f03883797a6e8452fb524b3aa) subgraph QmWXF3jTLo6Wy9MxDZz6WKhET3GFcSFqn6vmrDDYPF7UHK failed with

failed to process trigger: block #13380099 (0x38d4…b3aa), transaction ca32b1581b837c6ca539cf6c2fd542e9bcacbdc345c6a424382b4f0e48b96153: function handleSwapped not found

On block 13663246 (f5d44376510d09486cc9214cdf87be12948e6155ef76c8203fb963adde16c0f8) subgraph QmY7xD8w9ekjrYLgSr7P1mNhi5dESzhnJmQjx3CssGZYVc failed with

failed to process trigger: block #13663248 (0xf5d4…c0f8), transaction 7022d1ffc2b5bca80ef6c29115694f2c406b079d88c8957568e41d46c5fc6745: Entity Swap[0x7022d1ffc2b5bca80ef6c29115694f2c406b079d88c8957568e41d46c5fc6745-0]: missing value for non-nullable field `fromAmount` wasm backtrace: 0: 0x3172 - <unknown>!generated/schema/Swap#save 1: 0x360f - <unknown>!src/mappings/core/handleSwap

On block 13468096 (33939ae7b79fa2ec62390600d783cee53d344c3ceaed2a12c8237137248189c0) subgraph QmZdsSbRwVD7VVVm5WGxZZC6HYvbjnFb4hcwvQ4fTs5bxA failed with

failed to process trigger: block #13468099 (0x3393…89c0), transaction ee9aaf59819efc11375abe3c5ed0953597ef4daf805b4c0379bc81f1d232d155: Entity SavingsManager[0x9781c4e9b9cc6ac18405891df20ad3566fb6b301]: missing value for non-nullable field `address` wasm backtrace: 0: 0x18fe - <unknown>!generated/schema/SavingsManager#save 1: 0x2c38 - <unknown>!src/mappings/SavingsManager/handleStreamsFrozen

On block 4965314 (be4a6efc693c2e16b0df7ddeed5f057bd18e23544a3302b4efb7272aa3cbf066) subgraph QmNrS2U5DHqn5DJiKKD1ZS4BpHeAGDsKjftHMwX8LqSZqv failed with

failed to process trigger: block #4965316 (0xbe4a…f066), transaction ad66aefe198276fd6036ac7ae74d39cc75890f75a8d0456bb373fa92a38e8c73: Entity NFT[parcel-0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d-14291859410679415465461733512134264881229]: missing value for non-nullable field `tokenId` wasm backtrace: 0: 0x183c - <unknown>!src/entities/schema/NFT#save 1: 0x1964 - <unknown>!src/handlers/parcel/handleUpdate

Two error variants observed:

  1. function handleSwapped not found
  2. missing value for non-nullable field

@tilacog

Plan of attack:

  1. If a handler does not exist but the subgraph tries to call it -> make that a deterministic error.
  2. Add validation for the next subgraph API version that catches situations where handlers referenced in the manifest do not actually exist in the WASM mappings. If that’s the case, reject the deployment or fail to start the subgraph.

@obernardovieira After #2797 the error message should become more specific. If you could reproduce again and send me the subgraph id on Discord I can try to look into the cause.