-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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 atAuxDataOur 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request