Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust CostModel's FromJSON instance #3367

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

lehins
Copy link
Collaborator

@lehins lehins commented Apr 4, 2023

Description

It turns out cardano-node relies on JSON for CostModel for PlutusV2 to also contain the parameter names, not just a list of values. This PR implements this backwards compatibility in a forward compatible way.

  • Addition of costModelToMap, costModelFromMap and costModelParamNames
  • Made it possible for FromJSON to decode CostModels both as the new approach:
    1. as a list of cost models values,
    2. and the old approach of mapping from the parameter name to the cost model value

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Any changes are noted in the CHANGELOG.md for affected package
  • Code is formatted with fourmolu (use scripts/fourmolize.sh)
  • Cabal files are formatted (use scripts/cabal-format.sh)
  • hie.yaml has been updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

…w style:

* Addition of `costModelToMap`, `costModelFromMap` and `costModelParamNames`
* Made it possible for `FromJSON` to decode `CostModels` both as the new approach:
  1. as a list of cost models values,
  2. and the old approach of mapping from the parameter name to the cost model value
Copy link
Contributor

@JaredCorduan JaredCorduan left a comment

Choose a reason for hiding this comment

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

looks great!

@lehins lehins enabled auto-merge April 4, 2023 19:41
@lehins lehins merged commit 302e46f into master Apr 4, 2023
@iohk-bors iohk-bors bot deleted the lehins/fix-costmodel-json-instance branch April 4, 2023 19:48
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