Skip to content

fix: use provider-supplied cost models in script integrity hash#825

Open
JoelDellamaggiore wants to merge 1 commit into
MeshJS:mainfrom
JoelDellamaggiore:fix/dynamic-cost-models-from-provider
Open

fix: use provider-supplied cost models in script integrity hash#825
JoelDellamaggiore wants to merge 1 commit into
MeshJS:mainfrom
JoelDellamaggiore:fix/dynamic-cost-models-from-provider

Conversation

@JoelDellamaggiore
Copy link
Copy Markdown

Summary

Fixes the PPViewHashesDontMatch failure on Plutus V3 mints submitted to preprod and preview, and prevents the same failure from hitting mainnet once the PV11 hard fork is enacted.

The CardanoSDKSerializerCore was hashing scripts with the hardcoded DEFAULT_V[123]_COST_MODEL_LIST from @meshsdk/common, regardless of the protocol parameters supplied to the serializer. This PR makes the serializer prefer cost models from protocolParams.costModels when present, falling back to the hardcoded defaults otherwise. Backwards compatible — existing callers that pass a Protocol without costModels keep current behavior.

See #824 for the full root cause analysis and on-chain verification.

Affect components

  • @meshsdk/common
  • @meshsdk/contract
  • @meshsdk/core
  • @meshsdk/core-csl
  • @meshsdk/core-cst
  • @meshsdk/hydra
  • @meshsdk/provider
  • @meshsdk/react
  • @meshsdk/svelte
  • @meshsdk/transaction
  • @meshsdk/wallet
  • Mesh playground (i.e. https://meshjs.dev/)
  • Mesh CLI

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Code refactoring (improving code quality without changing its behavior)
  • Documentation update (adding or updating documentation related to the project)

Related Issues

Closes #824

Checklist

  • My code is appropriately commented and includes relevant documentation, if necessary
  • I have added tests to cover my changes, if necessary
  • I have updated the documentation, if necessary
  • All new and existing tests pass (i.e. npm run test)
  • The build is pass (i.e. npm run build)

Additional Information

End-to-end verified on Cardano preprod with a CIP-68 mint that was previously failing with PPViewHashesDontMatch:

https://preprod.cardanoscan.io/transaction/2dc2622f2adc08da0b1b698f7e000ea2085a2e54ac33a64ab38b5b6aeed2aa52

Changes

  • Add optional CostModels type and Protocol.costModels field in @meshsdk/common.
  • castProtocol passes the costModels object through when present.
  • CardanoSDKSerializerCore reads cost models from protocolParams.costModels?.PlutusV[123] when available, falls back to DEFAULT_V[123]_COST_MODEL_LIST otherwise.
  • Two new tests in protocol.test.ts covering presence/absence of costModels on castProtocol.

Notes for reviewers

  • New local variables use let to match the surrounding style in CardanoSDKSerializerCore (the function declares similar locals with let even when not reassigned).
  • No JSDoc added on CostModels or Protocol.costModels, to match the existing convention in protocol.ts (no type-level JSDoc on Protocol, Asset, PoolParams, etc.).
  • Pre-existing test suite failures on main (6 in @meshsdk/common, 5 in @meshsdk/core-cst — module resolution issues unrelated to cost models) are unaffected by this PR. Verified by running tests on main and on this branch with identical fail/pass counts (only difference: +2 new passing tests in protocol.test.ts).

The serializer currently hashes Plutus cost models from a hardcoded
default (DEFAULT_V[123]_COST_MODEL_LIST), regardless of the protocol
parameters passed in. This produces an incorrect scriptIntegrityHash
on any network whose cost model differs from those defaults.

Concrete impact: mainnet still uses the default (297 V3 entries), but
preprod and preview have expanded V3 to 350 entries ahead of the
upcoming PV11 hard fork. Today any Plutus V3 mint submitted to
preprod/preview fails with PPViewHashesDontMatch. Once PV11 is enacted,
mainnet will be affected too.

This change makes the CardanoSDKSerializer prefer cost models supplied
through Protocol.costModels (typically derived from the provider's
fetchProtocolParameters response) and fall back to the hardcoded
defaults when not supplied. Backwards compatible — existing callers
that pass a Protocol without costModels keep current behavior.

Changes:
- Add optional CostModels type and Protocol.costModels field
- castProtocol passes the costModels object through
- CardanoSDKSerializerCore reads cost models from protocolParams when
  available, falls back to DEFAULT_V[123]_COST_MODEL_LIST otherwise
- Tests for castProtocol covering presence/absence of costModels
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.

PPViewHashesDontMatch on Plutus V3 mints in preprod/preview after recent Cardano cost model expansion (will affect mainnet at PV11 hard fork)

1 participant