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

Graph-node should verify connected network on start #2674

Open koen84 opened 3 years ago

koen84 commented 3 years ago

Graph-node currently "takes your word" for which network you're connecting it to. It should verify this, at least at startup.

If you specific --ethereum-rpc as mainnet the actual connection can be anything (e.g. rinkeby or even something not ETH), it'll simply use the connection. Best case is the log will fill with errors. But it also happens that it skips over blocks as it (off course) doesn't encounter events it should index.

Verifying chainid with net_version would avoid problems.

azf20 commented 3 years ago

This is an interesting and good idea. There is currently no concept of chain id graph node, and the strings used for network identification are not canonical outside "mainnet" which has meaning on the network