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

未关闭
#678 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
api, backend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
22
派生
33
平均合并
21 小时 38 分钟
30 天内合并 PR
55

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IntersectMBO/evolution-sdk 的其他 Issue

查看 IntersectMBO/evolution-sdk 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。