Repository navigation
Conversation
…cate it The cardano-cli JSON form carries `slot` and `required` as JSON numbers, so a CDDL uint64 above `Number.MAX_SAFE_INTEGER` has no exact representation in it. `Number(script.slot)` returned a different slot and reported nothing. A script read off the chain may carry any uint64, so this is reachable on decode and not only when authoring one. `Hash.symbol` stops going through `toJSON`, which would now throw for exactly these scripts: a `HashSet` holding one would fail, and before the refusal two scripts differing only above the bound hashed equal. `fromJSON`, the inverse that found this, is left for its own change.
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.
One of the four fixes asked for in the closing comment on
#619 — smallest fix plus its test, nothing else.
The defect
The cardano-cli JSON form carries
slotandrequiredas JSON numbers, so a CDDL uint64 aboveNumber.MAX_SAFE_INTEGERhas no exact representation in it.Number(script.slot)returned adifferent slot and reported nothing.
A script read off the chain may carry any uint64, so this is reachable on decode, not only when
authoring one.
One consequence worth naming
Hash.symbolstops going throughtoJSON, which would now throw for exactly these scripts: aHashSetholding one would fail. It hashes the variant directly instead — and before the refusal,two scripts differing only above the bound hashed equal.
Contents
packages/evolution/src/NativeScripts.ts— the range refusal, andHash.symbolofftoJSON.packages/evolution/test/NativeScripts.JSON.test.ts— at the bound, above it, and the two scriptsthat used to hash equal.
Deliberately left out:
fromJSONand itsNativeScriptJSONmodule, as asked.Verification
All six CI tasks run locally off
ci.ymlagainst this base (lint,type-check,test,build,check:dts,docgen): green.packages/evolution: 1918 passed, 75 skipped, 0 failed. The new test file fails on this base without the source change, so it does exercise it.devnet's suite needs Docker and was not run here.