Skip to content

Latest commit

 

History

History
98 lines (70 loc) · 4.11 KB

File metadata and controls

98 lines (70 loc) · 4.11 KB

DEX.DO-indexer

Writer-side service. It ingests Acki Nacki chain data, decodes DEX events, and maintains the Postgres read-model served by services/api.

Specifications

Implementation details belong in the tech specs above, not in this README.

Configuration

Config file: config/indexer.<env>.yaml. Local default: config/indexer.local.yaml. Override with APP_CONFIG=/path/to/file.yaml.

Config sections:

  • app: environment name and log level.
  • database: Postgres URL and pool settings.
  • graphql: gateway endpoint, optional bearer token, page size, request timeout.
  • indexer: polling/reconciliation intervals, reprojection_batch_size, ignored_addresses, ignored_event_types (event types dropped before decode, matched by dst; see docs/tech-specs/indexer.md), and the inference reconciler knobs: inference_reconciliation_interval_ms, inference_reference_price_refresh_ms, inference_sweep_interval_ms, inference_orphan_cutoff_ms (see docs/tech-specs/indexer.md). Event capture is fixed to the DEX src_dapp_id plus the legacy RootPN account stream; see docs/tech-specs/indexer.md.

Logging is configured by environment variables, not YAML: RUST_LOG sets the filter (default info), and LOG_DIR (optional) makes the service additionally write daily-rotated indexer.log.<date> files into that directory, retaining LOG_MAX_FILES of them (default 14). See docs/deployment.md and docs/tech-specs/indexer.md.

Metrics are OpenTelemetry/OTLP and also environment-driven: when OTEL_EXPORTER_OTLP_METRICS_ENDPOINT (or OTEL_EXPORTER_OTLP_ENDPOINT) is set, the service exports orders_created_event_cnt and order_partially_filled_event_cnt; with neither set, no metrics are collected. See docs/tech-specs/indexer.md.

Database

The indexer applies SQL migrations from migrations/ on startup. Column and table semantics live in docs/tech-specs/data-schema.md.

On a fresh Supabase project, grant the application role permissions on public before the first run:

grant usage, create on schema public to indexer;
grant all privileges on all tables    in schema public to indexer;
grant all privileges on all sequences in schema public to indexer;
alter default privileges in schema public grant all on tables    to indexer;
alter default privileges in schema public grant all on sequences to indexer;

Replace indexer with the role name from the pooler username.

Running

cargo run -p dodex-indexer

Reload config in a running process:

kill -USR1 <pid>

Restart the process for changes that are documented as startup-pinned in the indexer tech spec.

Tests

Unit tests:

cargo test -p dodex-infrastructure --lib

DB-backed indexer/infrastructure tests:

docker compose -f docker-compose.test.yml up -d --wait
export TEST_DATABASE_URL=postgres://dodex:dodex@localhost:55432/dodex_test
cargo test -p dodex-infrastructure --tests
docker compose -f docker-compose.test.yml down

The test database role must own public because the test suite runs migrations on connect.

Deployment

Self-hosting the service (Docker Compose, own GraphQL + Postgres/Supabase) is covered in docs/deployment.md; the repository-level entry point is README.md.