Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Ogmios: represent 64-bit amounts as bigint with lossless JSON to avoid precision loss

Đã đóng
#406 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

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

@emmanuel-musau đang làm issue này rồi.

Từ ngày 28/9/2026.

Đá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
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu trong packages/evolution/src/sdk/provider/internal/Ogmios.ts, tập trung vào các kiểu amount bị ảnh hưởng và toOgmiosUTxOs, sau đó kiểm tra HttpUtils.postJson để xem việc tuần tự hóa request và response. Truy vết đường đi additionalUtxo từ KupmiosEffects.ts và KoiosEffect.ts. Hoàn tất khi trường hợp hồi quy bảo toàn 2^64-1 và 2^53+1 dưới dạng các số JSON chính xác, không có dấu ngoặc kép, và việc phân tích amount đầu vào không bị mất dữ liệu.

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

Mô tả

bug external-review

Summary

The Ogmios provider converts 64-bit Cardano amounts (lovelace and native-token quantities) with Number(...), but a JS number is exact only to 2^53-1. Cardano amounts are uint64, so any value above 2^53 is silently corrupted. Every other provider uses BigInt(...), and the SDK models Coin as Schema.BigInt up to 2^64-1, so this is an inconsistent defect. The corrupted values are sent to Ogmios as the additionalUtxo set during transaction evaluation, producing wrong ex-units/fees and on-chain rejection for transactions involving high-supply tokens. Fail closed: no fund loss, the tx is just rejected.

Affected

packages/evolution/src/sdk/provider/internal/Ogmios.ts: OgmiosAssets type (L128), Value type (L130-132), toOgmiosUTxOs Number(quantity) (L189) and Number(lovelace) (L216), inbound LovelaceAsset schema (L24-26), Delegation rewards/deposit (L118-119)
reached via: KupmiosEffects.ts:380 and KoiosEffect.ts:325 (additionalUtxo for evaluateTransaction)
transport: HttpUtils.postJson (bodyJson -> JSON.stringify on send; response.json -> JSON.parse on receive)
contrast (correct): Koios.ts:292/298, Maestro.ts toBigInt, Blockfrost.ts

Fix

Represent Ogmios amounts as bigint end to end (OgmiosAssets -> Record<string, Record<string, bigint>>, Value.ada.lovelace -> bigint, drop Number(...) in toOgmiosUTxOs).
Important: Ogmios encodes amounts as UNQUOTED JSON numbers (per the Ogmios v6 API, e.g. { "ada": { "lovelace": 1234 } }), so:

  • on send, a bigint cannot go through JSON.stringify; emit it as a bare JSON numeric literal via a lossless serializer (json-bigint style or a replacer that splices the integer), not as a quoted string (Ogmios will reject a string).
  • on receive, response.json uses standard JSON.parse which truncates above 2^53 before the schema, so any inbound amount field that can exceed 2^53 needs a big-int-aware parser, not just a BigInt schema. (The evaluate response is only ex-units, which are small, so the live issue is the send path; fix the receive path too for correctness on amount-bearing Ogmios queries.)

Regression test

  • given: a UTxO with token quantity 2^64-1 and lovelace 2^53+1, run toOgmiosUTxOs([utxo]) and serialize the additionalUtxo body the same way the request does
  • before fix: amounts are corrupted (2^64-1 -> 18446744073709552000, 2^53+1 -> 2^53)
  • after fix: the serialized payload contains the exact integers as unquoted JSON numbers, round-tripping unchanged

Must FAIL on main today and PASS after the fix.

Reference

GHSA-mrqw-3c7x-96mg

Ngôn ngữ chính
TypeScript
Star
22
Fork
33
Merge trung bình
2 ngày 5 giờ
Pull request đã merge (30 ngày)
41

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.