Status route accepts fractional or negative node ids as the chain tip

Aperta Adatta ai principianti
#340 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nextjs, typescript
Ambito
api

Direzione di ricerca

Inizia da reference-implementations/dacs-directory/app/api/dacs/status/route.ts:48, dove viene preso il primo id numerico di transazione, e leggi le righe 54-67 per vedere come txsBehind, cursorAheadBy e chainResetSuspected derivano da esso. Confronta con la guardia observedTip in src/catalog/scan.ts:493 e lo schema intero-o-null in src/catalog/contracts.ts:232-233. Sostituisci il controllo typeof id === "number" con Number.isSafeInteger(id) && id >= 0, poi aggiungi casi con id frazionario e id negativo accanto ai test esistenti della route di stato in test/rpc-read-limits.test.ts (righe 56-88), aspettandoti che chainLatestTx e txsBehind siano null. Fatto significa che quei test passano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

contributors-section

Where: reference-implementations/dacs-directory/app/api/dacs/status/route.ts:48 (on phase0-completion at the linked commit)

What goes wrong: GET /api/dacs/status takes the first transaction id from the node's reply with typeof id === "number" (route.ts:48). A fractional id such as 1270.5, or a negative id, is returned as chainLatestTx and used to compute txsBehind, cursorAheadBy and chainResetSuspected (route.ts:54-67). The status schema declares chainLatestTx and txsBehind as integer-or-null (src/catalog/contracts.ts:232-233), so the reply can break its own schema.

Suggested fix: Accept only safe non-negative integers (Number.isSafeInteger(id) && id >= 0) and leave chainLatestTx null otherwise, as the scanner already does for observedTip (src/catalog/scan.ts:493). Add route tests with a fractional id and a negative id next to the existing status-route tests in test/rpc-read-limits.test.ts (lines 56-88); expect chainLatestTx and txsBehind to be null.

Size: Small

This comes from a code review, not from a failing run, so please confirm it before starting. Send the fix as a pull request to phase0-completion. It merges once tests pass and a maintainer has approved it.

Lingua principale
TypeScript
Stelle
0
Fork
3
Merge medio
20h 26m
PR unite (30g)
119

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DACS-Agent-commerce/Community

Tutte le issue di DACS-Agent-commerce/Community

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.