Repository navigation
Conversation
… value (IntersectMBO#571) toUTxO only set scriptRef when reference_script.bytes was present, and its switch handled only the timelock native type — but db-sync stores no CBOR for native scripts before the Dijkstra era, so Koios returns bytes: null for timelock and multisig reference scripts and those UTxOs came back with no scriptRef and no error; multisig was dropped even when bytes were present. Native scripts with null bytes are now rebuilt recursively from reference_script.value (the db-sync script.json, decoded through the existing NativeJSONSchema) and checked against the hash Koios reports: a mismatch, or a value that does not decode as a native script, throws a clear error instead of silently dropping the script. multisig joins timelock on the bytes path. Five new tests, each verified red on unmodified main. Koios file 34/34; full suite 1683 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 part of #571: the Koios provider dropping native reference scripts.
The bug
toUTxOinKoios.tsonly setscriptRefwhenreference_script.byteswas present, and its switch handled only thetimelocknative type. But db-sync stores no CBOR for native scripts before the Dijkstra era, so Koios returnsbytes: nullfor timelock and multisig reference scripts — those UTxOs came back with noscriptRefand no error, and amultisigscript was dropped even when its bytes were present.The fix
timelockormultisig) reference script withbytes: null, the script is rebuilt fromreference_script.value— which is the db-syncscript.json(verified in the Koios/gREST source:reference_scriptis built ashash/bytes/value = script.json/type/size, and the JSON is the cardano-cli native-script form the SDK already models asNativeScriptJSON). The rebuild is recursive (sig/before/after/all/any/atLeast) and goes through the existingNativeJSONSchema.hashKoios reports, as Koios: native reference scripts are dropped #571 prescribes: a mismatch throws an error naming both hashes, and a value that does not decode as a native script throws a clear "could not be rebuilt" error — the script is never silently dropped or attached unchecked. This followstoUTxO's existing contract, whose other decoders (fromBech32,fromCBORHex) also throw on malformed input.multisigis added to the bytes path alongsidetimelock, keeping the bytes path for Dijkstra-era outputs.Left out, deliberately: the related question in #571 about
/utxo_inforeturning spent outputs. TheProviderinterface does not specify the expected behaviour, so that is a maintainer decision, not something to pick in a drive-by fix.Tests
Five new tests in
KoiosLovelace.test.ts, each verified red on unmodified main (the script came backundefined, or nothing threw), one-tfilter at a time:all [sig, any [sig, before]]script rebuilt from its value — asserted against a hand-encoded CBOR oracle and an independently computed blake2b-224 script hash (Pythonhashlib,0x00 || CBOR), not against the SDK's own encoder alone;Koios test file: 34/34. Full package suite: 1683 passed / 75 skipped / 0 failed (test files 101 passed / 1 skipped of 102; main baseline 1678 + the 5 new tests).
tsc --noEmitand eslint clean; both touched files' prettier diff-line counts exactly equal unmodified main's (they fail--checkon main too — no unrelated formatter hunks).Changeset added (patch).
Independent builder — not affiliated with the Cardano Foundation, IOG or Intersect.
@Kshot9000 — https://x.com/kshot9000
ADA donations: addr1q8hnl6vl5a6k3rw3n5g3jtte696zcl76kfatzv7gpswa9r0dj7fma6klq55y4ffm7tf0em09udnyhuk4ah92pl5x9jpqjae44v
cc @cardano-foundation @IntersectMBO