Ogmios: represent 64-bit amounts as bigint with lossless JSON to avoid precision loss
Los mantenedores suelen responder en 1 día
@emmanuel-musau ya está trabajando en esto.
Desde el 28/9/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- typescript
Línea de trabajo
Comienza en packages/evolution/src/sdk/provider/internal/Ogmios.ts, centrándote en los tipos de cantidad afectados y en toOgmiosUTxOs; después inspecciona HttpUtils.postJson para la serialización de solicitudes y respuestas. Sigue la ruta additionalUtxo desde KupmiosEffects.ts y KoiosEffect.ts. El trabajo está terminado cuando el caso de regresión conserva 2^64-1 y 2^53+1 como números JSON exactos y sin comillas, y el análisis de cantidades entrantes no pierde precisión.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 22
- Forks
- 33
- Merge medio
- 2 d 5 h
- PR fusionados (30 d)
- 41
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de IntersectMBO/evolution-sdk
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
IntersectMBO/evolution-sdk#601 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
IntersectMBO/evolution-sdk#559 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
IntersectMBO/evolution-sdk#557 ·
Los mantenedores suelen responder en 1 día
-
dependencies good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 93/100
IntersectMBO/evolution-sdk#541 ·
Los mantenedores suelen responder en 1 día
-
bug external-review
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
IntersectMBO/evolution-sdk#530 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de IntersectMBO/evolution-sdk
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
MystenLabs/MemWal#1163 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Mondriaan
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
knaw-huc/textannoviz#709 ·
Los mantenedores suelen responder en 1 día
-
billion-context-pi
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
ranxianglei/billion-context#2521 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Add: YRF Music NepalAbiertostreams:add
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100