Skip to content

feat(solana-indexer): PR 14 PostgresStore persist decoded events + slot watermark#4631

Draft
squadgazzz wants to merge 2 commits into
mainfrom
solana-indexer/PR14-postgres-store
Draft

feat(solana-indexer): PR 14 PostgresStore persist decoded events + slot watermark#4631
squadgazzz wants to merge 2 commits into
mainfrom
solana-indexer/PR14-postgres-store

Conversation

@squadgazzz

Copy link
Copy Markdown
Contributor

Description

Implements the PostgresStore persistence for the indexer's live path: decoded settlement events and the slot watermark land in the solana.* tables in one transaction. This retires the todo!() stubs on Persistence for the ingest path and gives the decoder a real store to write through in a follow-up.

Runs ahead of the schema being frozen. The solana.* DDL lives in a test-only fixture applied to docker Postgres in the #[ignore] test, not a committed flyway migration, so staging and prod stay clean until the shape settles. When it does, it promotes to database/sql-solana/ plus a compose service, mirroring the pool-indexer.

Changes

  • Persistence holds a PgPool and implements persist_events (events plus watermark in one transaction), write_watermark (monotonic), and read_watermark, all runtime sqlx queries.
  • Settlement mapping: OrderCreated writes solana.order_pda (off-chain path, solana.orders is the orderbook's row), SettlementFinalized writes solana.settlements plus per-order solana.trades plus the cumulative solana.order_pda counters, OrderClosed/OrderCancelled set the cancellation timestamp. Buffer and admin events are skipped (no MVP table).
  • Test-only schema.sql fixture and an #[ignore] docker-Postgres test.
  • The finalization and recovery Persistence methods stay todo!() (their own PRs, recovery is out of scope for v0.1).

How to test

docker compose up -d, then cargo nextest run -p solana-indexer --run-ignored all --test-threads 1. Non-ignored tests run without a database.

Notes

  • Placeholders mirror PR 7.2: instruction_index and fee_amount on solana.trades, and the buy-side amount, are constants until the decoder resolves them from proposed-solution data.
  • The decoder does not call persist_events yet. Wiring it needs a Store trait so the decoder unit tests inject a fake rather than a live database, deferred to a follow-up.
  • schema.sql is deliberately not a flyway migration (see Description).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant