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

improvement: tx size includes IsValid field, Haskell omits it

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
typescript
领域
blockchain

调研方向

从 TxBuilderImpl.ts 中的 calculateFeeIteratively 开始,跟踪 calculateTransactionSize,然后将其序列化结果与所引用的 Haskell toCBORForSizeComputation 参考实现进行比较。当 fee-size 计算使用不含 IsValid 的三元素交易表示,并且不再包含该字段的 CBOR 开销时,即表示完成。

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

描述

enhancement

Summary

calculateFeeIteratively serializes the transaction using a 4-element CBOR array (body, witnessSet, isValid, auxiliaryData). The Cardano node computes the fee-relevant size using toCBORForSizeComputation, which omits IsValid and produces a 3-element array.

This results in a tx size ~1 byte larger than the node calculates, causing a fee over-estimate of ~44 lovelace (1 byte × minFeeCoefficient).

Haskell Reference

-- eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs
toCBORForSizeComputation AlonzoTx {atBody, atWits, atAuxData} =
  encodeListLen 3        -- 3 elements, no IsValid
    <> encCBOR atBody
    <> encCBOR atWits
    <> encodeNullStrictMaybe encCBOR atAuxData

Our Code

// TxBuilderImpl.ts — calculateFeeIteratively
const transaction = new Transaction.Transaction({
  body,
  witnessSet: fakeWitnessSet,
  isValid: true,     // included in CBOR, node does not count this
  auxiliaryData: ...
})
const size = yield* calculateTransactionSize(transaction)

Impact

~44 lovelace over-charge per transaction. Safe (node accepts fees above minimum) but imprecise.

Fix

Serialize only [body, witnessSet, auxiliaryData] (3-element array) for size computation, or subtract the isValid CBOR overhead (~2 bytes) from the measured size.

主要语言
TypeScript
星标
22
派生
31
平均合并
2 天 12 小时
30 天内合并 PR
36

环境准备

  • 没有 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 摘要。