Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Cerrado
#406 1 comentario 0 reacciones 1 asignado Ver en GitHub

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
Área
api, backend

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

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

Lenguaje dominante
TypeScript
Estrellas
22
Forks
33
Merge medio
2 d 5 h
PR fusionados (30 d)
41

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de IntersectMBO/evolution-sdk

Todos los issues de IntersectMBO/evolution-sdk

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.