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

refactor: move startup logic to per-indexer container #327

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

Sekhmet
Copy link
Contributor

@Sekhmet Sekhmet commented Dec 5, 2024

This PR moves startup logic to container class. This change is internal only, no external API change happened.
Container will encapsulate indexer and separate it from main Checkpoint instance.

Right now it moves:

  • reset/resetMetadata calls.
  • validateConfig call.
  • validateStore call.
  • Helper methods like getConfigStartBlock and getStartBlockNum as those are used in container.

In the future entire logic for indexer will be encapsulated in Container. Checkpoint will only manage containers calling its life cycle methods (start/reset).

Test plan

  1. Use checkpoint-template.
  2. Make sure resetMetadata is called before reset.
  3. Comment out your writer.
  4. Start server, you get error message about missing writer.
  5. Restore writer.
  6. Comment out resetMetadata in config.json change Infura node from sepolia to mainnet.
  7. Start server, you get error message about network change.
  8. Restore original Infura node.
  9. Start server, it works as before.

@Sekhmet Sekhmet requested a review from bonustrack December 5, 2024 15:47
Copy link
Contributor

@bonustrack bonustrack left a comment

Choose a reason for hiding this comment

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

Works well tACK. How a "container" is different from an "indexer"? Also wdyt about exposing "indexer" value in "_metadata" GraphQL entity?

@Sekhmet
Copy link
Contributor Author

Sekhmet commented Dec 6, 2024

How a "container" is different from an "indexer"?

Indexer just encapsulates logic of how specific network should be processed. If someone wants to create new indexer (for Bitcoin, Solana, etc.) they only need new Indexer (and its Provider).

Container will contain logic of what was previously part of core Checkpoint instance (startup, validation, resetting data, actually running main loop with reorg detection etc.). This part is common across all indexers so we keep it as internal part of Checkpoint.

Also wdyt about exposing "indexer" value in "_metadata" GraphQL entity?

I had it prepared as a PR, but it included quite a bit of exclusions in the code to only expose it in the metadata entities that I decided to postpone it until regular entities have it too this way it will be supported across all entities and won't require adding special cases in the code.

@bonustrack
Copy link
Contributor

Sounds good!

@Sekhmet Sekhmet merged commit 16f0aef into next Dec 9, 2024
@Sekhmet Sekhmet deleted the sekhmet/startup-in-container branch December 9, 2024 07:05
Sekhmet added a commit that referenced this pull request Jan 22, 2025
* feat: add indexer to metadata (#325)

With support for multiple indexers in single Checkpoint instance
we have to accomodate for those in our database.
This commit makes necessary changes in our metadata store.

Currently checkpoint still supports single indexer, but now metadata can accomodate it.

* refactor: move startup logic to per-indexer container (#327)

* refactor: move lifecycle logic to per-indexer container (#328)

* feat: add support for multi chain indexing (#329)

* feat: add multi chains indexing

* fix: add indexer fields to all entities via AST

* fix: make current block in register per-indexer

* test: update tests to match multi indexer implementation

* feat: rename indexer to _indexer on entities

* refactor: remove legacy applyBlockFilter
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.

2 participants