graphprotocol / graph-node

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
https://thegraph.com
Apache License 2.0
2.89k stars 962 forks source link

[Bug] deterministic substreams errors are not reported at the graph-node level #4975

Open madumas opened 10 months ago

madumas commented 10 months ago

Bug report

A subgraph-powerered-subgraph that fails with a deterministic error is not properly handled by graph-node. It should detect the error, and report the subgraph as "failed" in a deterministic way. Instead, graph-node reports the subgraph to be healthy and continually retries the substream

graph-node: v0.32.0 firehose-ethereum: v1.4.10

Relevant log output

Nov 07 14:12:41.040 INFO Blockstreams connected, provider: substreams, deployment: QmT2nEwS9YWFzLE39Ujuv2oNVhgbctc8VUtB28RXb4wUbY, sgd: 351, subgraph_id: QmT2nEwS9YWFzLE39Ujuv2oNVhgbctc8VUtB28RXb4wUbY, component: SubstreamsBlockStream
Nov 07 14:12:41.043 INFO received err, provider: substreams, deployment: QmT2nEwS9YWFzLE39Ujuv2oNVhgbctc8VUtB28RXb4wUbY, sgd: 351, subgraph_id: QmT2nEwS9YWFzLE39Ujuv2oNVhgbctc8VUtB28RXb4wUbY, component: SubstreamsBlockStream
Nov 07 14:12:41.043 ERRO An error occurred while streaming blocks: status: Unknown, message: "rpc error: code = InvalidArgument desc = step new irr: handler step new: execute modules: applying executor results \"graph_out\": execute: maps wasm call: block 9974225: module \"graph_out\": wasm execution failed deterministically: panic in the wasm: \"called `Option::unwrap()` on a `None` value\" at /Users/mack/.cargo/registry/src/github.com-1ecc6299db9ec823/substreams-0.5.10/src/scalar.rs:404:25

IPFS hash

QmT2nEwS9YWFzLE39Ujuv2oNVhgbctc8VUtB28RXb4wUbY

Subgraph name or link to explorer

No response

Some information to help us out

OS information

None

azf20 commented 9 months ago

thanks @madumas! @mangas checking if this is the currently expected behaviour, or if we have some error handling in place for substreams?

mangas commented 9 months ago

We currently don't have this information surfaced through the GRPC types. The current Error definition looks like this:

message Error {
  string module = 1;
  string reason = 2;
  repeated string logs = 3;
  // FailureLogsTruncated is a flag that tells you if you received all the logs or if they
  // were truncated because you logged too much (fixed limit currently is set to 128 KiB).
  bool logs_truncated = 4;
}

The correct way to handle this would be for a deterministic flag (or similar) to be added so that the graph-node can treat it as such.

sduchesneau commented 9 months ago

@mangas we don't need a flag: the condition is in the Error Code: code = InvalidArgument

Invalid Argument is returned from Substreams when the error is "not due to the state of the system".

I'm not certain why you are getting "Status: Unknown" however... I will investigate that

sduchesneau commented 9 months ago

The GRPC issue has been fixed in substreams, pulled to firehose-core https://github.com/streamingfast/firehose-core/releases/tag/v0.2.4

Status field will show as InvalidArgument instead of Unknown.

Now, can graph-node be configured to consider "InvalidArgument" status code as a deterministic error ?

@mangas

azf20 commented 9 months ago

@sduchesneau is that the only error code which is indicative of a deterministic error?

github-actions[bot] commented 3 months ago

Looks like this issue has been open for 6 months with no activity. Is it still relevant? If not, please remember to close it.