Repository navigation
Conversation
…ntersectMBO#398) ConstantValue permits a plain JS boolean, but the flat encoder's Bool branch read .index off the value, so con bool false encoded with the True bit and produced the same flat bytes as con bool true. Handle the boolean form in encodeData; the decoded { index } form is unchanged, and booleans nested in a list of Bool go through the same branch. Tests: 4 new in UPLC.test.ts (3 RED on main, 1 control). UPLC file 43/43; full suite 1682 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.
Fixes #398.
The bug
ConstantValuepermits a plain JS boolean for a Bool constant, but the flat encoder's Bool branch read.indexoff the value:A JS boolean has no
.index, soundefined === 0nis false andfalsewas encoded with the True bit.con bool falseandcon bool trueproduced identical flat bytes (0100004a21for a bare constant program), so a script built from a false boolean computed that constant as true.The fix
The Bool branch of
encodeDatanow handles the primitive form the type advertises, as the issue suggests:The decoded
{ index }form encodes exactly as before, and because the list/pair branches route through the sameencodeData, JS booleans nested in alist Boolare fixed by the same change.Tests
Four new tests in
test/UPLC.test.ts, all written against main first:falseencodes differently from JStrueand decodes back to{ index: 0n }— on main both encoded to0100004a21(RED)truedecodes back to{ index: 1n }(control, passed before and after){ index }representation byte for byte — on main JSfalsegave0100004a21against the{ index: 0n }form's0100004a01(RED)With the fix: UPLC test file 43/43, full package suite 1682 passed / 75 skipped / 0 failed (test files 101 passed / 1 skipped of 102; main baseline 1678 + the 4 new tests),
tsc --noEmitand eslint clean. A patch changeset is included.Independent builder — not affiliated with the Cardano Foundation, IOG or Intersect.
@Kshot9000 (https://x.com/kshot9000) · ADA: addr1q8hnl6vl5a6k3rw3n5g3jtte696zcl76kfatzv7gpswa9r0dj7fma6klq55y4ffm7tf0em09udnyhuk4ah92pl5x9jpqjae44v
cc @cardano-foundation @IntersectMBO