Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Add a codec preset that follows the ledger encoder

未关闭
#612 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
blockchain

调研方向

Start with the CBOR default options named in the issue, CBOR.CML_DEFAULT_OPTIONS and CBOR.TX_DEFAULT_OPTIONS.ledger, and see how they set map and set ordering and length encoding. The ledger rules being matched (encodeMap, encodeSet, the 23-entry threshold) live in cardano-ledger, not this repo. Done means the regression test cases (unsorted inputs, multiple policies, more than 23 inputs or assets) encode byte-identically to cardano-cli build-raw output. The default switch is a separate, later change that needs its own release note.

由索引模型根据 Issue 内容生成。

描述

Summary

No codec preset writes a transaction the way the ledger encoder and cardano-cli do. CBOR.CML_DEFAULT_OPTIONS, the transaction default, keeps map keys and set items in insertion order and always writes definite lengths. The ledger sorts them and switches to indefinite lengths above 23 entries.

Evidence

cardano-ledger libs/cardano-ledger-binary/src/Cardano/Ledger/Binary/Encoding/Encoder.hs:

  • encodeMap (L395-400) folds the map in key order and uses variableMapLenEncoding: definite up to 23 entries, indefinite above (L426-436, lengthThreshold = 23).
  • encodeSet (L472-483) writes tag 258, the items in order, with the same rule through variableListLenEncoding (L457-460).

cardano-cli 10.5.1 conway transaction build-raw, with 25 inputs given in descending order and one output holding two policies given in descending order:

cardano-cli CML_DEFAULT_OPTIONS
Inputs sorted, d90102 9f ... ff as given, d90102 9819 ...
Policies in the output sorted as given

Proposal

  1. Add a preset that follows this layout, named after what it follows. The 23-entry rule needs a new encoder setting, since today a preset is either always definite or always indefinite.
  2. Check that each key type sorts the same way as the ledger's Ord instance before relying on byte order.
  3. Move CBOR.TX_DEFAULT_OPTIONS.ledger to the new preset in a later release. This changes the bytes of every transaction the builder makes, so it needs devnet proof and its own release note.

Regression test

Build transactions with unsorted inputs, several policies per output, more than 23 inputs and more than 23 assets. Encoded with the new preset, each is byte-identical to cardano-cli build-raw output for the same transaction.

主要语言
TypeScript
星标
22
派生
35
平均合并
20 小时 8 分钟
30 天内合并 PR
56

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IntersectMBO/evolution-sdk 的其他 Issue

查看 IntersectMBO/evolution-sdk 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。