Repository navigation
Conversation
3d72627 to
9f3fec7
Compare
|
Rebased onto current main (9f3fec7) — this PR had gone conflicting after the codec-options and redeemer-indexing work landed upstream (#652/#656/#658 series). Two semantic adjustments came with the rebase, both verified rather than mechanical:
Red/green re-verified on the rebased branch: all six new tests fail individually on current main and pass with the fix; the full suite is 1749 passed / 75 skipped / 0 failed (main baseline 1743 + 6 new). Independent builder — not affiliated with IntersectMBO, the Cardano Foundation or IOG. |
Fixes #179.
Transaction size was measured from the full 4-element CBOR encoding
[body, witnessSet, isValid, auxiliaryData]. The ledger measures a transaction differently —toCBORForSizeComputationin the Alonzo Tx module:That one ledger size (
tx ^. sizeTxF) feeds both the minimum fee and themaxTxSizecheck. The full encoding is exactly one byte longer — the boolean; the array header is one byte at both lengths — so every built transaction overpaid the minimum fee byminFeeCoefficientlovelace (44 lovelace at the usual coefficient), fee validation could reject a transaction whose fee was exactly the ledger minimum, and themaxTxSizecheck compared against a size one byte larger than the node's.Change
Transaction.toCBORBytesForSizeComputation: the 3-element[body, witnessSet, auxiliaryData]bytes, each component written exactly astoCBORByteswrites it under the default options, joined as the full encoding joins them (auxiliary data present → its bytes; absent → the null the ledger'sencodeNullStrictMaybewrites).calculateTransactionSizein the builder (fee estimation and themaxTxSizecheck, viabuild.ts) now measures those bytes.FeeValidation.validateTransactionFeenow measures those bytes.Submission paths are untouched: providers still serialize the full 4-element transaction, which is what gets submitted.
Tests
Six new cases in
test/Transaction.SizeComputation.test.ts, each run individually against main first:83…f6(3-element header, no boolean) — RED on main (the function does not exist there);83…a10000) — RED on main;isValidflag's value;0x83;calculateTransactionSizereturns 17 for the fixture, not 18 — RED on main (expected 18 to be 17);validateTransactionFeeaccepts a fee set to exactly the ledger minimum (200,000 = 44 × 17 + 199,252) — RED on main, which demanded 200,044.Existing expectations that encode the old size moved by exactly the fee difference — 44 lovelace, or one byte of size — in
TxBuilder.EdgeCases,TxBuilder.InsufficientChange,TxBuilder.Reselection,TxBuilder.SendAll,TxBuilder.UnfrackDrainandTxBuilder.UnfrackChangeHandling(in the last, only the residual change output and the one exact-fee assertion move; the token-bundle outputs are minUTxO-driven and unchanged).Results: the new file passes 6/6 and the affected builder files pass; the full package suite passes 1749 passed / 75 skipped / 0 failed (current main baseline 1743 + 6 new), test files 108 passed / 1 skipped of 109.
tsc --noEmitand eslint are clean, and the touched source files' prettier diff counts match main's exactly. A patch changeset is included.Rebased onto current main (9f3fec7). The codec-options work (#652) had changed
calculateTransactionSizeto take the caller's codec options, so the size function now threads them:Transaction.toCBORBytesForSizeComputationaccepts the same options and writes the body and witness set with them, exactly astoCBORBytesjoins its components. The rebase also surfaced one test file recorded after this PR was opened,TxBuilder.CodecOptions(#652): its default-options goldens are re-recorded — every one of the 16 cases moves by exactly the same −44 lovelace fee difference, with no other change — and itscheckWrittenfee assertion now measures the ledger size of the bytes it checks (the full encoding minus the one-byteisValidflag), which is the size the fee is computed from.Independent builder — not affiliated with IntersectMBO, the Cardano Foundation or IOG.
@Kshot9000 (https://x.com/kshot9000) · ADA: addr1q8hnl6vl5a6k3rw3n5g3jtte696zcl76kfatzv7gpswa9r0dj7fma6klq55y4ffm7tf0em09udnyhuk4ah92pl5x9jpqjae44v
cc @cardano-foundation @IntersectMBO