cardano-wasm: gRPC-Web UTxO glue incompatible with shipped v1beta protobuf bundle

Aperta
#1,323 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
grpc, haskell, javascript

Direzione di ricerca

Inizia da GRPC.hs:51-54 e confronta il suo JS generato con i campi v1beta ReadUtxosRequest in query.proto:101-104 e con il bundle distribuito. Poi leggi Query.hs:95 e cardano.proto:36,256-262 per seguire le richieste senza chiave e le rappresentazioni di coin. Il lavoro è completato quando getUtxosForAddress e getAllUtxos funzionano con il server v1beta e i valori di coin non vuoti non causano più un errore di tipo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug WASM

Summary

The cardano-wasm JS glue is written against the obsolete utxorpc.v1alpha API, while the shipped browser bundle is generated from this repo's v1beta protos (nix/proto-to-js.nix:17 uses cardano-rpc-src = ../cardano-rpc).
As a result the core UTxO-reading API of the browser SDK does not work against the in-repo proto and server.
Wallets depending on it cannot read balances.
It fails closed (exception or empty list), so there is no on-chain fund loss.

Concrete breaks

1. getUtxosForAddress throws an unconditional TypeError

GRPC.hs:51-54 references proto.utxorpc.v1alpha.cardano.AddressArray and calls req.setCardanoAddresses().
Neither exists in v1beta: ReadUtxosRequest only has keys + field_mask (query.proto:101-104).
Every call throws before any network request is made.

2. getAllUtxos always returns empty

js_readAllUtxos sends a keyless ReadUtxosRequest.
The v1beta server deliberately returns an empty response for that (Query.hs:95: "Returns an empty response when no keys are provided").
This means a silent zero balance for every wallet built on the SDK.

3. BigInt(utxo.cardano.coin) type mismatch

The glue assumes a scalar coin, but the v1beta TxOutput.coin is a BigInt message {int|bigUInt|bigNInt} (cardano.proto:36,256-262).
It would throw a BigInt(object) TypeError if the UTxO list were ever non-empty.

Note: js-test/basic-test.golden never exercises the gRPC paths, so the breakage is untested in-repo.

Reproduction

  1. Inspect the JS emitted by GRPC.hs:51-54:
    let addresses = new proto.utxorpc.v1alpha.cardano.AddressArray();
    addresses.addItems(btoa($2));
    req.setCardanoAddresses(addresses);
    
  2. Inspect the shipped bundle's schema (generated from v1beta): ReadUtxosRequest fields are only keys + field_mask. utxorpc.v1alpha.cardano.AddressArray does not exist in the bundle.
  3. Server side: Query.hs:95 - a keyless ReadUtxosRequest returns defMessage (empty).

Any wallet calling getUtxosForAddress(addr) throws TypeError: proto.utxorpc.v1alpha.cardano.AddressArray is not a constructor.
getAllUtxos() always resolves to [].

Suggested fix

Regenerate the JS glue against the v1beta protos.
Use ReadUtxosRequest.keys for address lookups.
Parse coin from the v1beta BigInt message fields (int as Number, bigUInt as base64 big-endian bytes converted to BigInt).


Originally reported by @Ranchhand87 as security advisory GHSA-6f73-hf45-g35g.
Converted to a public issue since it fails closed and has no security impact.

Lingua principale
Haskell
Stelle
41
Fork
32
Merge medio
1g 9h
PR unite (30g)
22

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di IntersectMBO/cardano-api

Tutte le issue di IntersectMBO/cardano-api

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.