fix: use provider-supplied cost models in script integrity hash#825
Open
JoelDellamaggiore wants to merge 1 commit into
Open
fix: use provider-supplied cost models in script integrity hash#825JoelDellamaggiore wants to merge 1 commit into
JoelDellamaggiore wants to merge 1 commit into
Conversation
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
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.
Summary
Fixes the
PPViewHashesDontMatchfailure 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
CardanoSDKSerializerCorewas hashing scripts with the hardcodedDEFAULT_V[123]_COST_MODEL_LISTfrom@meshsdk/common, regardless of the protocol parameters supplied to the serializer. This PR makes the serializer prefer cost models fromprotocolParams.costModelswhen present, falling back to the hardcoded defaults otherwise. Backwards compatible — existing callers that pass aProtocolwithoutcostModelskeep 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/walletType of Change
Related Issues
Closes #824
Checklist
npm run test)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
CostModelstype andProtocol.costModelsfield in@meshsdk/common.castProtocolpasses thecostModelsobject through when present.CardanoSDKSerializerCorereads cost models fromprotocolParams.costModels?.PlutusV[123]when available, falls back toDEFAULT_V[123]_COST_MODEL_LISTotherwise.protocol.test.tscovering presence/absence ofcostModelsoncastProtocol.Notes for reviewers
letto match the surrounding style inCardanoSDKSerializerCore(the function declares similar locals withleteven when not reassigned).CostModelsorProtocol.costModels, to match the existing convention inprotocol.ts(no type-level JSDoc onProtocol,Asset,PoolParams, etc.).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 onmainand on this branch with identical fail/pass counts (only difference: +2 new passing tests inprotocol.test.ts).