Skip to content

Multiple data sources #762

Open
Open
@Jannis

Description

@Jannis

Summary

So far we only support Ethereum contracts as data sources and event handlers as mappings. As a consequence, the code that wires up subgraphs for indexing is kind of special-cased (e.g. everything is based on the block stream). We aim to extend subgraphs to support other data sources like IPFS files and make it easier to add more data source types over time.

This issue describes the requirements for supporting multiple data source types and the changes proposed to implement them.

Requirements

  • Need to support multiple data source types (e.g. ethereum/contract, ipfs/file etc.).
  • Supported data source types have some fields in common (like kind, name and mapping); other fields are unique to the data source type.
  • Data sources of all types are started and stopped with the subgraph deployment.
  • Data sources require their own state.
  • The overall progress of a subgraph needs to be calculated from all of its data sources.

Proposed Changes

I propose that the implementation takes place in two phases. First, implement block streaming, state management and progress information per data source rather than per subgraph. Then, extend the system to supporting generic (potentially different) data sources.

Phase 1

  1. Make SubgraphInstanceManager and SubgraphInstance instantiate a DataSourceInstance for every data source.
  2. Add a DataSourceIndexer trait that is responsible for indexing a particular type of data source. Add an EthereumContractInstance version that operates based on a block stream.
  3. Add Store helper to read the state of a data source of a subgraph as a From<serde_json::Value> or similar.
  4. Change block pointers to be for a data source instead a subgraph.

Phase 2

  1. Extend the GraphQL schema for the subgraph of subgraphs to support data sources of different types, either through interfaces or unions.
  2. Turn data sources and mappings in SubgraphManifest into either an enum or come up with builder-style pattern for creating DataSourceInstances from data sources.
  3. Make SubgraphRegistrar write different types of data sources to the store.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions