CBOR: tags with 4- and 8-byte headers fail to decode, and two smaller preservation gaps

Aperta
#580 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #635 di @Kshot3000 — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start in packages/evolution/src/CBOR.ts at decodeTagAt and encodeMapSync, then review the preservation specification at .specs/cbor-encoding-preservation.md. Update the documentation comment in docs/content/docs/encoding/cbor.mdx and add the listed regression cases for tag 258 and the bfff witness set. Done means the tests fail on main, pass after the changes, and both inputs round-trip byte for byte.

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

Descrizione

Three small gaps found while testing format preservation, in order of impact.

1. Tags with a 4- or 8-byte header fail to decode

decodeTagAt accepts tag headers only up to 2 bytes, so a transaction that writes tag 258 as da00000102 fails with CBORError: Unsupported tag encoding: 26. The node accepts that transaction, and CML round-trips it byte for byte. The spec says tag header width is preserved (.specs/cbor-encoding-preservation.md L180-183) and lists "non-minimal tag width" as supported (L329), which holds only for 1- and 2-byte headers.

Affected: packages/evolution/src/CBOR.ts decodeTagAt (L2044-2054), which has no branch for additional info 26 or 27.

Fix: decode 4- and 8-byte tag headers and record the width, as integer headers already do.

Devnet, raw submission through Ogmios: inputs written as 00 da00000102 81 [input], signed over their own body, were accepted. Transaction.fromCBORHex on the same bytes throws.

2. An empty indefinite witness set is written back as a0

An unsigned transaction with witness set bfff comes back from fromCBORHex then toCBORHex with a0. The body and the transaction id are unchanged, because the id is taken over the body only (cardano-ledger Core.hs L651), so no signature is affected. addVKeyWitnessesHex keeps the indefinite map. CML round-trips it byte for byte.

Affected: the empty map fast path in encodeMapSync (L1371), the same one #576 fixes for Plutus data. The fix for #576 covers this too; this entry only adds a regression case.

3. The CBOR guide says re-encoding is canonical by default

docs/content/docs/encoding/cbor.mdx L37 comments "Re-encode to hex (canonical by default)". The default, CML_DEFAULT_OPTIONS, keeps map insertion order (sortMapKeys: false), and the same page says so at L135. The comment should say the default keeps the original order.

Regression test

  • Transaction.fromCBORHex accepts tag 258 written with a 4-byte header, and toCBORHex returns the same bytes
  • 84 [body] bfff f5 f6 round-trips byte for byte

Must FAIL on main today and PASS after the fix.

Lingua principale
TypeScript
Stelle
22
Fork
34
Merge medio
16h 53m
PR unite (30g)
10

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/evolution-sdk

Tutte le issue di IntersectMBO/evolution-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.