#photon #snapshot #indexer #solana #compression #api #local

bin+lib photon-indexer

Solana indexer for general compression

48 breaking releases

new 0.50.0 Nov 20, 2024
0.48.0 Nov 11, 2024
0.39.0 Jul 29, 2024
0.3.0 Mar 29, 2024

#224 in Magic Beans

Download history 392/week @ 2024-07-29 109/week @ 2024-08-05 77/week @ 2024-08-12 235/week @ 2024-08-19 304/week @ 2024-08-26 44/week @ 2024-09-02 309/week @ 2024-09-09 335/week @ 2024-09-16 200/week @ 2024-09-23 203/week @ 2024-09-30 173/week @ 2024-10-07 129/week @ 2024-10-14 133/week @ 2024-10-21 191/week @ 2024-10-28 475/week @ 2024-11-04 454/week @ 2024-11-11

1,264 downloads per month

Apache-2.0

3MB
10K SLoC

Photon: the Indexer for ZK Compression on Solana

Photon is the core indexer for ZK Compression on the Solana blockchain. It offers rapid indexing capabilities, snapshot support, and flexible database options to cater to local and production deployments.

🚀 Quick Start

Installation

  1. Install dependencies:
sudo apt install -y build-essential pkg-config libssl-dev
  1. Install photon-indexer:
cargo install photon-indexer

🔧 Usage

Basic Usage

  • Run Photon with default settings against localnet:
photon

Configuration

  • Connect to Devnet:
photon --rpc-url=https://api.devnet.solana.com
  • Use gRPC for block streaming (requires GRPC_X_TOKEN env variable):
photon --rpc-url=https://api.devnet.solana.com --grpc-url=<grpc_url>
  • Use a local Postgres database:
photon --db-url=postgres://postgres@localhost/postgres
  • Specify a start slot:
photon --start-slot=123
  • For more advanced options:
photon --help

📸 Snapshots

Photon supports snapshots for quick bootstrapping.

Loading a Snapshot

  1. Download a snapshot:
photon-snapshot-loader --snapshot-dir=~/snapshot --snapshot-server-url=https://photon-devnet-snapshot.helius-rpc.com
  1. Run Photon with the snapshot:
photon --snapshot-dir=~/snapshot --rpc-url=https://api.devnet.solana.com --db-url=postgres://postgres@localhost/postgres

Creating Snapshots

Create a local snapshot:

photon-snapshotter --snapshot-dir=~/snapshot

Store snapshots in an R2 bucket:

photon-snapshotter --r2-bucket=some-bucket --r2-prefix=prefix

Note: Set R2_ACCESS_KEY, R2_ACCOUNT_ID, and R2_SECRET_KEY environment variables when using R2.

🗄️ Database Management

Photon supports both Postgres and SQLite. By default, it uses an in-memory SQLite database.

To use a custom database:

export DATABASE_URL="postgres://postgres@localhost/postgres"
photon-migration up
photon --db-url=$DATABASE_URL

🛠️ Local Development

Running Tests

  1. Set up the environment:
export MAINNET_RPC_URL=https://api.mainnet-beta.solana.com
export DEVNET_RPC_URL=https://api.devnet.solana.com
export TEST_DATABASE_URL="postgres://postgres@localhost/postgres"
  1. Install additional tools:
npm install -g @apidevtools/swagger-cli
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
docker run -p 3001:3001 docker.io/pmantica1/light-prover:1
  1. Run tests:
cargo test

Note: All migrations run automatically during tests for both Postgres and SQLite.

Database Model Generation

cargo install sea-orm-cli --version 0.10.6
sea-orm-cli generate entity -o src/dao/generated

API Documentation

Generate OpenAPI schemas:

cargo run --bin=photon-openapi

📬 Support

For support or queries, please open an issue on Github or contact the Helius discord.

Dependencies

~144MB
~2.5M SLoC