Skip to content

fix(koios): explicitly order epoch_params to get current epoch#208

Merged
solidsnakedev merged 2 commits intomainfrom
fix/koios-epoch-params-ordering
Mar 16, 2026
Merged

fix(koios): explicitly order epoch_params to get current epoch#208
solidsnakedev merged 2 commits intomainfrom
fix/koios-epoch-params-ordering

Conversation

@solidsnakedev
Copy link
Collaborator

Koios preview load-balances across backend nodes whose PostgREST databases return rows in different physical order. Without an explicit order parameter, epoch_params?limit=1 non-deterministically returns either the current epoch (297 PlutusV3 cost model entries) or a stale pre-Plomin epoch (251 entries). When the stale epoch is returned, the SDK computes a scriptDataHash with the wrong cost model, causing PPViewHashesDontMatch on transaction submission.

Adds &order=epoch_no.desc to the Koios epoch_params query so limit=1 always returns the most recent epoch, regardless of backend node ordering.

Koios preview load-balances across backend nodes with different DB row
orderings. Without an explicit sort, epoch_params?limit=1 randomly
returns a stale epoch (e.g. 646 with 251 PlutusV3 cost model entries)
instead of the current one (297 entries), causing PPViewHashesDontMatch
when submitting transactions with Plutus scripts.
Copilot AI review requested due to automatic review settings March 16, 2026 10:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes non-deterministic protocol parameter resolution when querying Koios epoch_params (notably on preview), ensuring the SDK consistently uses the latest epoch’s cost model and avoids downstream scriptDataHash mismatches.

Changes:

  • Add an explicit order=epoch_no.desc to the Koios epoch_params request while keeping limit=1.
  • Add a patch changeset documenting the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/evolution/src/sdk/provider/internal/KoiosEffect.ts Makes getProtocolParameters deterministic by ordering epoch params by newest epoch.
.changeset/fix-koios-epoch-params-ordering.md Adds a patch-level release note for the Koios epoch ordering fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@solidsnakedev solidsnakedev merged commit 539525d into main Mar 16, 2026
12 checks passed
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.

2 participants