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

Đang mở
#678 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
22
Fork
33
Merge trung bình
21 giờ 38 phút
Pull request đã merge (30 ngày)
55

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của IntersectMBO/evolution-sdk

Tất cả issue của IntersectMBO/evolution-sdk

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.