Redeemers: toScriptDataHash ignores the codec options when encoding datums
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 88/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- blockchain
调研方向
从 packages/evolution/src/Redeemers.ts 开始,重点关注 encodeDatumsTaggedSet 和 toScriptDataHash 的两个分支。为有 redeemers 和无 redeemers 时的 canonical options,以及 default-options control 添加回归覆盖;当 canonical hash 与 node oracle 匹配且现有 default hash 保持不变时,测试即完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 22
- 派生
- 35
- 平均合并
- 21 小时 8 分钟
- 30 天内合并 PR
- 50
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
IntersectMBO/evolution-sdk 的其他 Issue
-
Kupmios: protocol parameters fail against Ogmios v7 (maxReferenceScriptsSize renamed)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 84/100
IntersectMBO/evolution-sdk#559 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
IntersectMBO/evolution-sdk#557 ·
维护者通常 1 天内回复
-
dependabot: remove stale @types/bip39 entries可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭dependencies good first issue
难度 1/5 1 小时以内 新手友好度 93/100
IntersectMBO/evolution-sdk#541 ·
维护者通常 1 天内回复
-
txBuilder: committee cert redeemers are never resolved to a certificate index可能已有人在做 @Kshot3000 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 80/100
IntersectMBO/evolution-sdk#518 ·
维护者通常 1 天内回复
-
RewardAccount: validate header type bits and bech32 prefix可能已有人在做 @Kshot3000 于 2 天前认领。 未关闭enhancement external-review
难度 2/5 1-3 小时 新手友好度 84/100
IntersectMBO/evolution-sdk#456 · 1 条评论 ·
维护者通常 1 天内回复
查看 IntersectMBO/evolution-sdk 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
TomerAberbach/profiler-md#733 ·
维护者通常 1 天内回复
-
bug priority: medium
难度 2/5 1-3 小时 新手友好度 68/100
brentspine/brents-toasts#143 ·
-
🐛 bug 🗺️ DB Models & Ops
难度 2/5 1-3 小时 新手友好度 83/100
LibreChat-AI/LibreChat#17214 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
Wavvon/Wavvon-clients#136 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
umami-software/umami#4637 ·
维护者通常 3 天内回复