aptos-labs / aptos-indexer-processors

Set of core processors that index data on the Aptos blockchain
https://aptos.dev/indexer/indexer-landing
54 stars 63 forks source link

[Custom Processors] Proposal for Enhancing Aptos Indexer: Subgraph-Inspired Improvements #508

Open mshakeg opened 3 days ago

mshakeg commented 3 days ago

Overview

The Aptos Indexer is a powerful tool. However, drawing inspiration from established systems like The Graph's subgraphs could significantly improve its usability, efficiency, and developer experience. This issue proposes several key enhancements to align the Aptos Indexer more closely with subgraph functionality and developer experience.

Proposed Improvements

1. Schema Definition and Code Generation

Current State: manually defined database schemas in code(e.g. using SQLAlchemy ORM in python or typeorm for typescript).

Proposal:

Benefits:

2. Configuration and Event Filtering

Current State: Manual implementation of event filtering logic in processors.

Proposal:

Benefits:

3. Deployment Pipeline and Hosting

Current State: Manual deployment and hosting of processors.

Proposal:

Benefits:

4. Testing Framework

Current State: Limited specialized testing tools for processors.

Proposal:

Benefits:

5. Language-Specific API/SDK Libraries

Current State: Developers are required to fork the aptos-indexer-processors repo and implement custom processors within the relevant language folder(e.g. ./python, ./rust, ./typescript) in this repo.

Proposal:

Introduce language-specific API/SDK libraries (aptos-indexer-py, aptos-indexer-rs, aptos-indexer-ts) for Python, Rust, and TypeScript respectively, inspired by @graphprotocol/graph-ts used in subgraphs.

These libraries should provide:

  1. Type-safe interfaces for Aptos blockchain data
  2. Utility functions for common operations (e.g., cryptographic functions, big number handling)
  3. Standardized logging and error handling
  4. Helper methods for database operations
  5. Wrappers for Aptos-specific data types and operations

Benefits:

For reference on functionality and API design, see The Graph's @graphprotocol/graph-ts documentation: https://thegraph.com/docs/en/developing/graph-ts/api/

mshakeg commented 2 days ago

After further investigation it would seem like:

Developers are required to fork the aptos-indexer-processors repo and implement custom processors within the relevant language folder(e.g. ./python, ./rust, ./typescript) in this repo.

would only be applicable to python as a package has not yet been published like @aptos-labs/aptos-processor-sdk for typescript or aptos-indexer-processor-sdk for rust. However, the other suggestions would still be relevant.

mshakeg commented 3 hours ago

I've hacked a work around using the @aptos-labs/aptos-processor-sdk to give a very rudimentary solution to some of the improvements suggested in the original issue, such as:

  1. Configuration and Event Filtering - though all must be configured directly in code(not in a yaml file)
  2. Deployment Pipeline and Hosting - though code has to be manually added to the super processor repo

https://github.com/mshakeg/super-processor-example.git