Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent: warn and wait if subgraph is behind the chain head #762

Merged
merged 10 commits into from
Sep 29, 2023

Conversation

tilacog
Copy link
Contributor

@tilacog tilacog commented Sep 4, 2023

This PR introduces a new class, SubgraphFreshnessChecker, designed to continuously retry subgraph queries if the subgraph is significantly behind the latest block in the blockchain. When such a condition is met, a warning will indicate the incident alongside the current block distance from the chain head.

Configuration options have been extended both in network specification files and CLI parameters:

  • maxBlockDistance: Defines the threshold for subgraph freshness by measuring the distance between the latest indexed block in the subgraph and the most recent block on the network.
  • freshnessSleepMilliseconds: Specifies the duration to wait before reattempting the query.

After monitoring the testnet indexer block distances for an hour, we observed that the block distances for Arbitrum-Goerli typically fall below the 50-block threshold. No such distances were noted in Goerli. Consequently, we have set the default values for maxBlockDistance to 0 blocks and freshnessSleepMilliseconds to 5000.

arbitrum-goerli goerli

If the Agent or Service utilizes these default settings while operating on Arbitrum networks, a warning will be emitted to inform the user of the potential risk that queries may never be considered fresh.

@tilacog tilacog linked an issue Sep 4, 2023 that may be closed by this pull request
@tilacog tilacog force-pushed the 662-indexer-agent-warn-and-wait-if-subgraph-is-behind branch 8 times, most recently from fd45a0c to fe25da4 Compare September 6, 2023 05:40
@tilacog
Copy link
Contributor Author

tilacog commented Sep 6, 2023

CI results differ between the two previous runs: failed tests in one run have passed in the other. Also, tests passed locally.

@tilacog tilacog marked this pull request as ready for review September 6, 2023 05:51
@tilacog tilacog force-pushed the 662-indexer-agent-warn-and-wait-if-subgraph-is-behind branch from fe25da4 to 10a55a8 Compare September 6, 2023 15:10
@tilacog tilacog force-pushed the 662-indexer-agent-warn-and-wait-if-subgraph-is-behind branch from 10a55a8 to 16a202d Compare September 6, 2023 20:27
@tilacog
Copy link
Contributor Author

tilacog commented Sep 6, 2023

Rebased on top of latest main

@tilacog tilacog requested a review from hopeyen September 25, 2023 21:43
packages/indexer-agent/src/commands/start.ts Show resolved Hide resolved
packages/indexer-agent/src/commands/start.ts Show resolved Hide resolved
packages/indexer-common/src/subgraphs.ts Outdated Show resolved Hide resolved
packages/indexer-common/src/subgraphs.ts Outdated Show resolved Hide resolved
@tilacog tilacog requested a review from hopeyen September 27, 2023 20:10
Copy link
Contributor

@fordN fordN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just warn in the case of the subgraph being ahead of the provider. Otherwise looks great! Feel free to merge once you update that part.

@tilacog tilacog merged commit 12e9c2f into main Sep 29, 2023
9 checks passed
@tilacog tilacog deleted the 662-indexer-agent-warn-and-wait-if-subgraph-is-behind branch September 29, 2023 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

indexer-agent: Warn and wait if subgraph is behind
3 participants