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

Fix how we update CostModels #3954

Merged
merged 5 commits into from
Dec 28, 2023
Merged

Fix how we update CostModels #3954

merged 5 commits into from
Dec 28, 2023

Conversation

lehins
Copy link
Collaborator

@lehins lehins commented Dec 22, 2023

Description

This is a follow up to #3953

There are a couple of problems with CostModels in Conway:

  • first one is that we retain invalid and unknown CostModels indefinitely. This PR clears them out as soon as a valid replacement has been added
  • ToJSON/FromJSON did not account for unknown and invalid CostModels, thus information was lost during roundtrip and there was no way for a user to see this very useful information
  • Constructor for CostMododels was exported thus it was very easy to invalidate invariant that CBOR and JSON instances rely on. Creation and modification of CostModels is done with smart constructors and through Monoid instance

Besides fixing CostModels this PR also adds more tests and organizes a little bit by removing duplicate functionality

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated. If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • All visible changes are prepended to the latest section of a CHANGELOG.md for the affected packages. New section is never added with the code changes. (See RELEASING.md)
  • 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

@lehins lehins requested review from teodanciu and ch1bo December 22, 2023 12:46
@lehins lehins force-pushed the lehins/cost-models-fixes branch from 05d2cc4 to 6cb680c Compare December 22, 2023 13:05
@lehins lehins requested a review from Soupstraw December 22, 2023 13:05
Copy link
Contributor

@teodanciu teodanciu left a comment

Choose a reason for hiding this comment

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

Looks good to me

@lehins lehins force-pushed the lehins/cost-models-fixes branch from 6cb680c to 687a9e4 Compare December 27, 2023 17:25
@lehins lehins enabled auto-merge December 27, 2023 17:28
…ror`

* `Eq` and `Ord` instances were hacky that were going through `Show`,
  which is unacceptable
* `EncCBOR` and `DecCBOR` will be useful later
* Ensure that invalid and Unknown CostModels are removed whenver a new
  valid CostModel for the language has been added
* Stop exporting constructor for the CostModels, thus allowing to
  enforce invariants
* Replace a unit test that checked `applyPPUpdates` with a more comprehensive
  property test
* Add `mkCostModels` and expose `flattenCostModel`
* Add `mkCostModelConst`
* Remove `Test.Cardano.Ledger.Alonzo.CostModel`
* Add `Cardano.Ledger.Plutus` that re-exports all plutus related
  functionality
* Add a new module for Plutus tests and include one property test
@lehins lehins force-pushed the lehins/cost-models-fixes branch from 687a9e4 to da317d2 Compare December 27, 2023 19:20
@lehins lehins merged commit 6ff8974 into master Dec 28, 2023
10 of 27 checks passed
@neilmayhew neilmayhew deleted the lehins/cost-models-fixes branch March 8, 2024 21:07
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