Skip to content

fix(provider): accept null for Blockfrost's nullable protocol parameters (#569 part 1) - #626

Open
Kshot3000 wants to merge 1 commit into
IntersectMBO:mainfrom
Kshot3000:fix/blockfrost-nullable-params
Open

Kshot3000 wants to merge 1 commit into
IntersectMBO:mainfrom
Kshot3000:fix/blockfrost-nullable-params

Conversation

@Kshot3000

Copy link
Copy Markdown

Fixes part 1 of #569.

Problem

The Blockfrost OpenAPI spec marks 15 fields of /epochs/latest/parameters as nullable: max_val_size, cost_models, cost_models_raw, price_mem, price_step, max_tx_ex_mem, max_tx_ex_steps, max_block_ex_mem, max_block_ex_steps, collateral_percent, max_collateral_inputs, coins_per_utxo_size, min_fee_ref_script_cost_per_byte, drep_deposit and gov_action_deposit. BlockfrostProtocolParameters declared them with Schema.optional, which rejects null — so a single null from Blockfrost failed the whole getProtocolParameters decode with a ProviderError.

Reproduced first: a parameters payload (the test file's OpenAPI-example fixture) with all 15 fields set to null fails getProtocolParameters on current main.

Fix

Each of the 15 fields is now Schema.optionalWith(X, { nullable: true }), exactly as #569 prescribes. A decoded null flows into transformProtocolParameters, whose existing defaults (?? 0n, || 0, and ?. in costModelFromBlockfrost) already handle it — no transform change was needed.

Deliberately left out

  • Part 2 (native scripts: cbor: null / serialised_size: null and rebuilding from /scripts/{hash}/json) — a larger change to the script-fetch flow, better reviewed on its own.
  • Part 3 (stale fields) — utxo_cost_per_word and consumed_by_tx are unread and safe to drop, but tx_index has an existing test asserting its exact decode past 2^53 (Blockfrost.test.ts, "decodes tx_index past 2^53 exactly"), so I left that call to the maintainers rather than deleting a deliberate test in a drive-by PR.

Tests

  • New test: all 15 nullable fields set to null decode through getProtocolParameters and fall back to the documented defaults (0 / 0n, empty cost models).
  • Blockfrost provider test file: 15/15 pass.
  • Full package suite: 1679 passed / 75 skipped / 0 failed (test files 101 passed / 1 skipped of 102).
  • tsc --noEmit and eslint on the changed files are clean. (Prettier already flags both touched files on unmodified main; I matched the surrounding style instead of reformatting unrelated hunks.)
  • A patch changeset is included.

Independent builder — not affiliated with the Cardano Foundation, IOG or Intersect.
@Kshot9000 (https://x.com/kshot9000)
ADA: addr1q8hnl6vl5a6k3rw3n5g3jtte696zcl76kfatzv7gpswa9r0dj7fma6klq55y4ffm7tf0em09udnyhuk4ah92pl5x9jpqjae44v

The Blockfrost OpenAPI spec marks 15 fields of /epochs/latest/parameters
nullable, but BlockfrostProtocolParameters used Schema.optional, which
rejects null — one null failed the whole getProtocolParameters decode.
The 15 fields now use Schema.optionalWith(..., { nullable: true }); the
decoded null reaches transformProtocolParameters, whose existing
?? 0n / || 0 defaults apply. Part 1 of IntersectMBO#569; the native-script rebuild
(part 2) and stale-field removal (part 3) are left out deliberately.

New test: all 15 fields null decode and fall back to the defaults.
Blockfrost file 15/15; full suite 1679 passed / 75 skipped / 0 failed.

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.

1 participant