Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

improvement: tx size includes IsValid field, Haskell omits it

Open
#179 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
blockchain

Research direction

Start in TxBuilderImpl.ts at calculateFeeIteratively and trace calculateTransactionSize, then compare its serialization with the cited Haskell toCBORForSizeComputation reference. Done means fee-size computation uses the three-element transaction representation without IsValid and no longer includes that field's CBOR overhead.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
22
Forks
31
Avg merge
3d 4h
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntersectMBO/evolution-sdk

All issues in IntersectMBO/evolution-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.