crates/sui-indexer-alt/README.md
Running the indexer requires a Postgres-compatible database to be installed and running on the system.
brew install postgresql@15
postgresql://$(whoami):postgres@localhost:5432/postgres
brew install --cask docker
open -a Docker
docker run --detach --publish 5433:5432 --env POSTGRES_PASSWORD=postgres_pw google/alloydbomni
postgresql://postgres:postgres_pw@localhost:5433/postgres
The indexer will try to connect to the following database URL by default:
postgres://postgres:postgrespw@localhost:5432/sui_indexer_alt
This database can be created with the following commands (run from this directory):
# Install the CLI (if not already installed)
cargo install diesel_cli --no-default-features --features postgres
# Use it to create the database and run migrations on it.
diesel setup \
--database-url="postgres://postgres:postgrespw@localhost:5432/sui_indexer_alt" \
--migration-dir ../sui-indexer-alt-schema/migrations
If more migrations are added after the database is set-up, the indexer will automatically apply them when it starts up.
Tests require postgres to be installed (but not necessarily running), and benefit from the following tools:
cargo install cargo-insta # snapshot testing utility
cargo install cargo-nextest # better test runner
The following tests are related to the indexer (run from the root of the repo):
cargo nextest run \
-p sui-indexer-alt \
-p sui-indexer-alt-framework \
-p sui-indexer-alt-e2e-tests
The first package is the indexer's own unit tests, the second is the indexing framework's unit tests, and the third is an end-to-end test suite that includes the indexer as well as the RPCs that read from its database.
The indexer is mostly configured through a TOML file, a copy of the default config can be generated using the following command:
cargo run --bin sui-indexer-alt -- generate-config > indexer_alt_config.toml
A source of checkpoints is required (exactly one of --remote-store-url,
--local-ingestion-path, or --rpc-api-url), and a --config must be
supplied (see "Configuration" above for details on generating a configuration
file).
cargo run --bin sui-indexer-alt -- indexer \
--database-url {url} \
--remote-store-url https://checkpoints.mainnet.sui.io \
--config indexer_alt_config.toml
Some pipelines identify regions to prune by transaction sequence number, or by
epoch. These pipelines require the cp_sequence_numbers table be populated in
the database they are writing to, otherwise they are unable to translate a
checkpoint sequence range into a transaction or epoch range.
Only one instance of the indexer writing to that database needs to populate
this table, by enabling the cp_sequence_numbers pipeline.