subquery / subql

SubQuery is an Open, Flexible, Fast and Universal data indexing framework for web3. Our mission is to help developers create the decentralised products of the future.
https://subquery.network
GNU General Public License v3.0
18.94k stars 331 forks source link

Healthcheck doesn't consider mine-on-demand EVMs #2589

Open hellowodl opened 2 weeks ago

hellowodl commented 2 weeks ago

Prerequisites

Description

The indexer's healthcheck relies on the last time a block was mined. Though there are various EVMs out there that mine blocks on demand, eg. rollup based chains or local development environments. Thus the current healthcheck doesn't work for all scenarios anymore.

The culprit is this method: https://github.com/subquery/subql/blob/c99be34fe74172a7cbad77f6ddaef1df0a066426/packages/node-core/src/meta/health.service.ts#L65

Details

Local Environment: @subql/cli/5.3.0 darwin-arm64 node-v20.18.0 Query Version: v2.15.2 (docker) Indexer Version: v5.1.7 (docker) Network Details:

Steps to Reproduce

  1. Deploy an example project with Anvil as the EVM/RPC
  2. Wait for a few seconds
  3. Healthcheck fails

Example project: I can create one on-request, though I don't have the time at the moment.

Expected behavior: The healthcheck preferably should check whether new blocks are mined instead of failing based upon time.

Actual behavior: When no new blocks are created within a certain time, the indexer's health check fails.

If desired I could write a fix. Though I'd like to know whether that is desired and what the desired route of implementation would be from you guys.

stwiname commented 2 weeks ago

Hi @hellowodl, thanks for your issue, this issue has been in the back of our mind but not big enough to consider addressing.

The health check is just a best guess that a growing chain is a healthy chain (and therefore a healthy RPC and indexer).

I think we can drop the requirement that the latest height by the RPC needs to grow.

So an unhealthy node is where the current indexing height is < the RPC reported chain height and not increasing within the interval. Otherwise its false.

If you have time to make this change it would be appreciated otherwise we will add it to our backlog.