Implements three infrastructure improvements and testing enhancements to support local development, production safety, and codec correctness.
- Added
scripts/seed.sqlwith realistic demo data (SEP-41 token events, interface, state, and per-holder balances) - Added
scripts/seed.shwrapper script for easy execution - Added
make seedtarget to Makefile - Zero-data first-run is now solved:
make seedpopulates a working dataset in seconds - Explorer and API show meaningful data immediately after seeding
Usage:
make db
make seed
cargo run -p lumenqraph-api
# Visit localhost:8080/contracts and see demo data- Added Postgres advisory lock (
pg_advisory_lock) to prevent concurrent indexer instances from racing - Lock ID:
0x6c756d656e717261("lumenqra" as i64) - Only one indexer runs as leader; others block and become hot standbys
- Guards both migrations and polling to prevent: duplicate migration runs, redundant RPC calls, racing cursor updates
- Lock is automatically released on shutdown (normal exit, backfill, or deep-backfill)
- Documented single-writer guarantee in code comments
Behavior:
- First instance acquires lock immediately and becomes active
- Second instance logs "blocking until it releases" and waits
- On leader failure, a standby takes over automatically
- Added
clamp_with_warning()helper to validate and clamp numeric config at load time PAGE_SIZE: clamped to RPC bounds (1–10000) with clear log messagePOLL_INTERVAL_SECS: minimum 1 secondMAX_CATCHUP_LEDGERS: minimum 1RETENTION_LEDGERS: rejects negatives, clamps to 0REORG_OVERLAP_LEDGERS: rejects negatives, clamps to 0- Out-of-range values log warnings at startup (before any work happens)
- Added unit tests for all boundary conditions
Why: PAGE_SIZE=0 or 100000 now fails fast with "PAGE_SIZE is below minimum; clamping to 1" instead of a confusing RPC error at runtime.
- Added 7 new edge-case tests for the strkey encoder/decoder:
strkey_bad_crc: Flip a payload byte to corrupt checksum → rejectedstrkey_truncated_input: Various truncated lengths → rejectedstrkey_overlength_input: Extra characters → rejectedstrkey_wrong_version_byte: G-strkey vs C-strkey mismatch → rejectedstrkey_roundtrip_g_and_c: Valid G/C keys round-trip correctlystrkey_invalid_base32_chars: Invalid chars ('0', '1', '8', '!') → rejected- Extended
invalid_contract_ids_rejectedwith explicit CRC corruption
Coverage: Bad CRC, wrong length, wrong version byte, invalid alphabet all return typed errors (never panic or wrong-but-accepted keys).
- All new tests pass:
cargo test --workspace - Config clamping tests verify boundary behavior
- Strkey tests cover all documented failure modes from #96
- Seed script tested locally: populates 4 events, 1 spec, 1 state row, 2 balance rows
Closes #93
Closes #94
Closes #95
Closes #96