Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Redeemers: toScriptDataHash ignores the codec options when encoding datums

Aperta Adatta ai principianti
#579 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
blockchain

Direzione di ricerca

Inizia da packages/evolution/src/Redeemers.ts, concentrandoti su encodeDatumsTaggedSet e su entrambi i rami di toScriptDataHash. Aggiungi una copertura di regressione per le opzioni canoniche con e senza redeemers, oltre al controllo delle opzioni predefinite; i test sono completati quando l'hash canonico corrisponde al node oracle e l'hash predefinito esistente rimane invariato.

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

Descrizione

Summary

Redeemers.toScriptDataHash(redeemers, costModels, datums, options) applies options to the redeemers but always encodes the datums with CML_DATA_DEFAULT_OPTIONS. Asked for a canonical hash, it returns the hash over indefinite-length datums:

const d = Data.fromCBORHex("d8799f019f02ffff")
Data.toCBORHex(d, CBOR.CANONICAL_OPTIONS)            // d87982018102, the bytes in the witness set
Redeemers.toScriptDataHash(empty, costModels, [d], CBOR.CANONICAL_OPTIONS)
// 80dbaeaf…, the hash over d8799f019f02ffff; expected ac4817df…

The ledger hashes the datums exactly as they appear in the witness set: cardano-ledger Alonzo/Tx.hs L318-321 builds the script integrity bytes from originalBytes of the redeemers and datums. A transaction whose witness set carries canonical datums therefore needs the hash over canonical datums.

Affected

packages/evolution/src/Redeemers.ts

  • encodeDatumsTaggedSet (L548-555) defaults to CML_DATA_DEFAULT_OPTIONS
  • toScriptDataHash calls it without options in both branches: datums with no redeemers (L600) and redeemers with datums (L612)

The builder is not affected today: it computes the hash with default options and does not add witness datums.

Fix

Pass the caller's options through to encodeDatumsTaggedSet when the caller gives them. When options is left at its default, keep encoding datums with CML_DATA_DEFAULT_OPTIONS, so today's default hashes do not change.

Regression test

Oracle is the node.

  • given: datum d8799f019f02ffff, no redeemers, CANONICAL_OPTIONS
  • before fix: 80dbaeaf…
  • after fix: ac4817df…, blake2b-256 of a0 d9010281 d87982018102 a0
  • same check for the branch with redeemers and datums
  • control: with default options the hash is unchanged

Devnet, raw submission through Ogmios. The witness set carries d87982018102, and the output holds its datum hash:

  • script data hash from toScriptDataHash(..., CANONICAL_OPTIONS): rejected with 3113, provided 80dbaeaf…, computed ac4817df…
  • script data hash ac4817df…: accepted

Must FAIL on main today and PASS after the fix.

Lingua principale
TypeScript
Stelle
22
Fork
31
Merge medio
4g 6h
PR unite (30g)
27

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.