Skip to content

fix(provider): fail with ProviderError for Kupo plutus:v4 scripts and Byron addresses - #624

Open
Kshot3000 wants to merge 1 commit into
IntersectMBO:mainfrom
Kshot3000:fix/kupmios-plutusv4-byron-addresses
Open

Kshot3000 wants to merge 1 commit into
IntersectMBO:mainfrom
Kshot3000:fix/kupmios-plutusv4-byron-addresses

Conversation

@Kshot3000

Copy link
Copy Markdown

Fixes #572.

Kupo (checked against v2.10.0 to v2.12.0 in the issue) can return two responses the Kupmios provider could not handle. Both now fail as typed ProviderErrors — the error type every other Kupmios read path already returns — instead of an opaque parse error or an unhandled defect.

PlutusV4 scripts

  • ScriptSchema in Kupo.ts now accepts the plutus:v4 literal that /scripts/{hash} can return since Kupo v2.12, so the response decodes.
  • getScriptEffect matches on the language with Effect.flatMap instead of Effect.map. The languages the SDK models (native, PlutusV1/V2/V3) resolve as before; anything else — today that is plutus:v4 — fails with a ProviderError naming the language as not supported yet. Before, the schema rejection surfaced as a generic parse error buried in the cause chain (after five retries of a deterministic failure), and the default: throw in the old Effect.map would have turned the newly accepted literal into a defect.

Byron addresses

  • Kupo writes Byron-era addresses in base58 (src/Kupo/Data/Cardano/Address.hs in Kupo). kupmiosUtxosToUtxos decoded every returned address with CoreAddress.fromBech32 inside Effect.map, so a Byron output from an output-reference or policy query threw and surfaced as a defect (Cause.Die — I reproduced exactly that). The decode now runs through Effect.try and fails with a ProviderError that names the address and explains that Kupo writes Byron addresses in base58 and that Byron addresses are not supported, since a UTxO's address here is a Shelley Address and cannot represent one.

Tests — four new cases in test/provider/Kupmios.test.ts, all with fetch stubbed in the file's existing style:

  • a /matches UTxO carrying a Byron base58 address (the output address from Kupo's golden vector test/vectors/golden/1.json) fails with Cause.Fail + ProviderError mentioning Byron/base58 — red before this change as Cause.Die;
  • ScriptSchema decodes {language: "plutus:v4"} — red before as a ParseError;
  • a plutus:v4 reference script fails with a ProviderError whose cause chain names plutus:v4 as not supported and contains no parse error — red before;
  • a plutus:v3 reference script still resolves to a PlutusV3 script reference (happy-path guard for the map → flatMap restructure).

Full package suite: 2,736 passed, 7 skipped, 0 failed. tsc --noEmit and eslint clean; a patch changeset is included.

I am an independent builder, not affiliated with Intersect, the Cardano Foundation, or IOG.


@Kshot9000 (https://x.com/kshot9000) · ADA: addr1q8hnl6vl5a6k3rw3n5g3jtte696zcl76kfatzv7gpswa9r0dj7fma6klq55y4ffm7tf0em09udnyhuk4ah92pl5x9jpqjae44v

… Byron addresses

Kupo v2.12 can return two responses the Kupmios provider could not
handle (issue IntersectMBO#572):

- /scripts/{hash} can return language "plutus:v4", which ScriptSchema
  rejected, so the lookup failed with an opaque schema parse error.
  Accept the literal and fail in getScript with a ProviderError naming
  the language as not supported yet, instead of throwing inside
  Effect.map, which would surface as a defect.
- /matches can return UTxOs at Byron-era addresses, which Kupo writes
  in base58. CoreAddress.fromBech32 threw inside Effect.map in
  kupmiosUtxosToUtxos, surfacing as a defect. Decode via Effect.try and
  fail with a ProviderError explaining Byron addresses are not
  supported.

Tests: four new cases in Kupmios.test.ts (Byron defect -> Fail with
ProviderError, schema accepts plutus:v4, plutus:v4 script fails with a
ProviderError naming it as unsupported and no parse error, plutus:v3
reference script still resolves). Full package suite: 2736 passed,
7 skipped. Changeset: patch.
@Kshot3000

Copy link
Copy Markdown
Author

Correction to the test totals in my commit message and the PR description above: the "2,736 passed, 7 skipped" figure was wrong — it came from a background test result on this machine that was not this package's suite, and I quoted it before this run's own result landed. My mistake.

The actual full-suite result for @evolution-sdk/evolution on this branch (exit code 0):

  • Test Files: 101 passed | 1 skipped (102)
  • Tests: 1,682 passed | 75 skipped (1,757), 0 failed
  • test/provider/Kupmios.test.ts on its own: 20/20 passed (16 existing + the 4 new cases)
  • tsc --noEmit and eslint clean, as stated

The conclusion is unchanged — the whole suite is green — only the totals were misstated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kupmios: PlutusV4 scripts and Byron addresses from Kupo

1 participant