This document outlines the steps to take when the nightly reconciliation job detects a mismatch between the StreamPay database and the on-chain (Stellar/Soroban) state.
Check the reconciliation report (logs or Slack alert). Each mismatch includes:
- Stream ID: The unique identifier of the stream.
- Field: The field that mismatched (e.g.,
released_amount,total_amount,status). - DB Value: The value currently stored in our database.
- On-Chain Value: The value fetched directly from the Stellar/Soroban contract.
Before taking action, manually verify the stream state using a block explorer or the Stellar CLI.
- Soroban: Use
stellar contract reador a Soroban explorer. - Classic Stellar: Use StellarExpert.
- Index Lag: The indexer might be a few ledgers behind the current chain tip.
- Rounding: Small differences due to bigint/decimal conversion (check if within tolerance).
- Failed Transactions: A transaction might have been recorded in the DB but failed on-chain (or vice versa).
- Double Credits: Potential bug in the settlement logic.
- Trigger a manual backfill for the affected stream using the
backfill-indexer.tsscript. - Wait 5 minutes and run the reconciliation job again.
- Freeze the Stream: If the UI allows it, pause the stream to prevent further withdrawals.
- Investigate Logs: Search for the
correlation_idof the last settlement transaction for that stream. - Manual Fix: If the mismatch is confirmed and intentional (e.g., manual adjustment needed), update the DB record to match the on-chain truth.
- This indicates a potential smart contract bug or a deep chain reorganization (rare on Stellar).
- Escalated to the Blockchain Engineering team immediately.
- Review recent changes to
lib/indexer.tsor the smart contract logic. - Ensure
Idempotency-Keyis being used correctly for all mutating requests.