Redeemers: toScriptDataHash ignores the codec options when encoding datums
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- blockchain
Research direction
Start in packages/evolution/src/Redeemers.ts, focusing on encodeDatumsTaggedSet and both toScriptDataHash branches. Add regression coverage for canonical options with and without redeemers, plus the default-options control; the tests are done when the canonical hash matches the node oracle and the existing default hash remains unchanged.
Written by the indexing model from the issue text.
Description
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 toCML_DATA_DEFAULT_OPTIONStoScriptDataHashcalls it withoutoptionsin 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 ofa0 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, provided80dbaeaf…, computedac4817df… - script data hash
ac4817df…: accepted
Must FAIL on main today and PASS after the fix.
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 31
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 27
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IntersectMBO/evolution-sdk
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
IntersectMBO/evolution-sdk#559 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
IntersectMBO/evolution-sdk#557 ·
Maintainers usually reply within 1 day
-
dependencies good first issue
Difficulty 1/5 Under an hour Newbie friendliness 93/100
IntersectMBO/evolution-sdk#541 ·
Maintainers usually reply within 1 day
-
bug external-review
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
IntersectMBO/evolution-sdk#530 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
IntersectMBO/evolution-sdk#518 ·
Maintainers usually reply within 1 day
All issues in IntersectMBO/evolution-sdk
Similar issues
-
bug HemiStake
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
hemilabs/ui-monorepo#2413 ·
Maintainers usually reply within 1 day
-
component/ui framework/react kind/bug language/javascript
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
meshery/meshery#22216 · 3 comments ·
Maintainers usually reply within 1 day
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
paperclipai/paperclip#14982 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
lingdojo/kana-dojo#31515 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day