Skip to content

Indexer polls client.getTransaction() with a ledger sequence number instead of a transaction hash #534

Description

@sshdopey

Where: src/lib/indexer.ts, EventIndexer.poll() (around line 45-50)

What's wrong:

for (let seq = startLedger; seq <= endLedger; seq++) {
  const ledgerTx = await client.getTransaction(seq.toString());
  if (!ledgerTx || !("hash" in ledgerTx)) continue;
  const txHash = "hash" in ledgerTx ? (ledgerTx as any).hash : "";
  await this.processTransaction(client, txHash, seq);
}

Stellar RPC's getTransaction expects a transaction hash (a 64-char hex
string), not a ledger sequence number. Here it's called with seq.toString()
— i.e. something like "12345678" — for every ledger in the poll range. This
is not a valid transaction hash, so the RPC call will not resolve to a real
transaction; the response will not contain a hash field, the continue
branch fires every time, and processTransaction is never reached with real
data.

Impact: the event indexer — the feature tracked by issue #220 ("Build the
event indexer: ingest contract events into a queryable store") — never
actually discovers or ingests any real on-chain deposit/withdraw events. The
portfolio endpoint (GET /v1/portfolio/:address) and anything depending on
indexer.getEventsByAddress() reads from a store that stays empty.

Suggested fix: iterate actual transactions in the ledger range using the
correct RPC surface (e.g. enumerate transactions per ledger via
getLedgerEntries/an events API such as getEvents, or track transaction
hashes from submitted transactions rather than sequence numbers), and add a
regression test asserting the indexer advances its cursor by processing real
transaction hashes rather than looping ledger numbers into getTransaction.

Note: there is no src/__tests__/indexer.test.ts at all, so this path is
completely unexercised by the test suite (see the companion "Add tests for
lib/indexer.ts" issue).

Activity

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

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions