Koios and Maestro fail on datums nested past 1,250 levels

Aperta
#678 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
api, backend

Direzione di ricerca

Read HttpUtils.ts:74-86 and HttpUtils.ts:127 to trace JSON parsing and the numberAsText reviver, then compare the datum response paths in Koios.ts and Maestro.ts. Reproduce the stack overflow with a deeply nested datum and inspect existing provider tests. Done means Koios and Maestro return UTxOs and datums at ledger-supported depths, including the cases described here.

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

Descrizione

bug

A Koios address_info row whose inline datum is a list nested 1,500 levels deep makes KoiosEffect.getUtxos fail. With fetch stubbed to return that row, the call fails with ProviderError "Koios getUtxos failed", and its cause ends in "Maximum call stack size exceeded". MaestroEffect.getUtxos fails the same way with "Maestro get paginated UTxOs failed". Koios returns the UTxO up to 1,252 levels and Maestro up to 1,253 levels. The same Koios row decodes when it carries a 15,000-level datum in bytes and a shallow JSON form, as #677 now allows.

Both providers parse every response with Schema.parseJson({ reviver: numberAsText }) (HttpUtils.ts:74-86, applied at HttpUtils.ts:127). The reviver keeps each number as the text the server wrote. The runtime calls a reviver by walking the parsed value recursively, so a deep value overflows the stack. Koios sends each datum's JSON form in inline_datum.value (Koios.ts:113, Koios.ts:239) and Maestro in datum.json (Maestro.ts:103). The SDK reads only the CBOR bytes of each datum, but the reviver walks the whole response first. Each datum level is two JSON levels ({"list":[...]}). JSON.parse with a reviver fails from 1,259 datum levels, and JSON.parse without one reads at least 40,000.

Before #662 the CBOR decoder failed at about the same depth and hid this limit. One UTxO with such a datum at an address still makes getUtxos() fail for the whole address on Koios and Maestro. Koios getUtxosByOutRef and getDatum fail the same way at 1,500 levels, since utxo_info and datum_info also carry the JSON form. The ledger accepts such datums. The Plutus data decoder limits the size of each leaf, not the depth (PlutusCore/Data.hs, decodeData), so a datum can nest about 16,000 levels in one transaction.

One possible fix, not decided: when the parse with the reviver overflows, quote each number token in one linear scan of the text and parse again without the reviver.

Koios and Maestro should return UTxOs and datums at any depth the ledger accepts, as Blockfrost and Kupmios do since #677.

Lingua principale
TypeScript
Stelle
22
Fork
33
Merge medio
21h 38m
PR unite (30g)
55

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 IntersectMBO/evolution-sdk

Tutte le issue di IntersectMBO/evolution-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.