Repository navigation
Conversation
…tMBO#580 part 1) decodeTagAt accepted tag headers only up to 2 bytes, so a transaction writing tag 258 as da00000102 failed with 'Unsupported tag encoding: 26' even though the node accepts it and CML round-trips it. Add the 26 and 27 branches mirroring decodeUintAt, with bound checks; the width was already recorded by additionalInfoToByteSize and replayed by encodeTagSync, so wide-header tags now round-trip byte for byte. Tests: wide-header round-trip vectors, plain decode of both widths, tag values that need each width, a bignum tag in a 4-byte header, truncated-header bound errors, and the transaction-level regression. Full suite: 1690 passed / 75 skipped / 0 failed.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Part 1 of #580: CBOR tags written with a 4- or 8-byte header fail to decode.
decodeTagAtinpackages/evolution/src/CBOR.tshad branches only for additional info < 24, 24 (1-byte) and 25 (2-byte), so a transaction that writes tag 258 asda00000102— a form the node accepts and CML round-trips byte for byte — threw:The fix
Two new branches in
decodeTagAt, mirroring howdecodeUintAtalready reads 4- and 8-byte integers in the same file:Insufficient data for 4-byte tagbound check);bigintbefore converting to thenumbertheTagschema models (with anInsufficient data for 8-byte tagbound check).No encoder change was needed: the width is already recorded from
additionalInfoToByteSize(26 → 4, 27 → 8) andencodeTagSyncalready replays a captured tag width throughencodeIntHeader, so a decoded wide-header tag re-encodes with the same width.Tests
Reproduced red on main first — each new test failed with
Unsupported tag encoding: 26/27(the truncated-header tests failed because the old code reported the encoding as unsupported rather than the data as insufficient):CBOR-with-format.test.ts: round-trip vectors for tag 258 in a 4-byte header (da000001028100) and an 8-byte header (db00000000000001028100), in both the hex and bytes suites; plain decode of both widths; a tag value that needs the 4-byte header (1,000,000) and one that needs the 8-byte header (2^32); a bignum tag (tag 2) written with a 4-byte header; truncated 4- and 8-byte headers rejected with the new bound errors.Transaction-with-format.test.ts: the issue's regression shape — the existing non-canonical test transaction with its inputs-set tag 258 written asda00000102— round-trips byte for byte, body included.Full
@evolution-sdk/evolutionsuite: 1690 passed / 75 skipped / 0 failed (test files 101 passed / 1 skipped of 102; main baseline 1678 passed + the 12 new tests).tsc --noEmitand eslint are clean. Prettier:CBOR.tsalready fails the check on unmodified main; this branch's prettier diff-line count for the file is identical to main's, and both test files are prettier-clean.Left out, deliberately
a0) belongs to CBOR: Plutus data encodings change on re-encode, breaking the script data hash and the transaction id #576's fix, as the issue itself states — it is not in this change.Independent builder — not affiliated with the Cardano Foundation, IOG or Intersect.
— Kyle Cox, @Kshot9000 (https://x.com/kshot9000)
Tips: ADA addr1q8hnl6vl5a6k3rw3n5g3jtte696zcl76kfatzv7gpswa9r0dj7fma6klq55y4ffm7tf0em09udnyhuk4ah92pl5x9jpqjae44v