CBOR: bignum payloads bypass bounded_bytes chunking above 64 bytes
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 86/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从 packages/evolution/src/CBOR.ts 中的 encodeUintSync、encodeNintSync 以及现有的 BoundedBytes 和 encodeBoundedBytesSync 路径开始;检查 packages/evolution/src/Data.ts 中的 CDDL 注释。运行现有的 CBOR 或 datum-hash 测试,然后为超过 64 字节的正数和负数情况添加回归覆盖。完成的标准是这些 payload 使用 chunked strings,同时 9 字节的情况仍为 definite,并且预期的哈希值匹配。
由索引模型根据 Issue 内容生成。
描述
Summary
Plutus Data integers whose magnitude exceeds 64 bytes (|value| >= 2^512) are encoded as a single
definite-length byte string under CBOR tag 2 or 3. The Conway CDDL, quoted in this repo at
Data.ts L165-167, defines a bignum payload as bounded_bytes = bytes .size (0..64), so a magnitude
of 65 bytes or more must be an indefinite-length byte string split into chunks of at most 64 bytes.
The SDK already applies that rule to Data byte-string leaves, so the same file chunks a 65-byte
bytearray and does not chunk a 65-byte bignum. The result is Plutus data that violates the grammar,
and a datum hash that differs from the one computed over the chunked form.
Affected
packages/evolution/src/CBOR.ts
- encodeUintSync (L985-991): passes
bigintToBytes(value)straight toencodeTagSync(2, ...)(L989-990) - encodeNintSync (L1028-1035): same for tag 3 (L1033-1034)
- contrast: the
BoundedBytesnode (L1231-1239) routes throughencodeBoundedBytesSync(L1109),
which chunks at 64 bytes and is applied unconditionally
packages/evolution/src/Data.ts
- CDDL for big_uint / big_nint / bounded_bytes documented at L165-167
Fix
Wrap the bignum magnitude in the existing BoundedBytes node so the chunking rule applies, mirroring
the fix PR #160 made for byte-string leaves:
return encodeTagSync(2, BoundedBytes.make(bigintToBytes(value)), options, fmt)
and the tag 3 analogue in encodeNintSync. Alternatively have encodeTagSync treat tag 2 and 3
payloads as bounded bytes. Note #395 edits the same two lines of encodeNintSync for the negative
bignum boundary, so the two changes will conflict.
Regression test
- given:
Data.int(2n ** 512n) - before fix: encodes to
c25841...(single 65-byte definite string);toDatumHashis9b2838f7... - after fix: encodes to
c25f5840...4100ff;toDatumHashis
939bb1f51ea88f86a070fefb5c1185d10b4d10a13e3b7db24aac02220c18adab - negative analogue:
Data.int(-(2n ** 520n))chunks under tag 3 rather than emittingc35841... - unchanged: a 9-byte bignum such as
2n ** 64nstays definite, so only the over-64-byte case moves
Must FAIL on main today and PASS after the fix.
Reference
Same defect class as #158, which covered Data byte-string leaves and was fixed in PR #160. The
integer path was never routed through BoundedBytes.
- 主要语言
- TypeScript
- 星标
- 22
- 派生
- 35
- 平均合并
- 19 小时 9 分钟
- 30 天内合并 PR
- 65
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
IntersectMBO/evolution-sdk 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
IntersectMBO/evolution-sdk#696 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 79/100
IntersectMBO/evolution-sdk#694 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
IntersectMBO/evolution-sdk#559 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
IntersectMBO/evolution-sdk#557 ·
维护者通常 1 天内回复
-
txBuilder: committee cert redeemers are never resolved to a certificate index可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 80/100
IntersectMBO/evolution-sdk#518 ·
维护者通常 1 天内回复
查看 IntersectMBO/evolution-sdk 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 70/100
microsoft/playwright#43640 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
grasshopper-protocol/grsshppr#172 ·
维护者通常 1 天内回复
-
bug help wanted
难度 2/5 1-3 小时 新手友好度 78/100
Tencent/teamai-cli#1397 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
DouyinFE/semi-design#3641 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复