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

Mismatch for Conway predicate failures #4666

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aniketd
Copy link
Contributor

@aniketd aniketd commented Oct 7, 2024

Description

This is the second (Conway) part of #4619.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • 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)
  • 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)
  • 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

@aniketd aniketd changed the title Aniketd/mismatch for conway Mismatch for Conway predicate failures Oct 7, 2024
@aniketd aniketd force-pushed the aniketd/mismatch-type-for-predicate-failures branch from 87dba8f to a6572dd Compare October 8, 2024 10:13
Base automatically changed from aniketd/mismatch-type-for-predicate-failures to master October 8, 2024 12:26
@aniketd aniketd force-pushed the aniketd/mismatch-for-conway branch 3 times, most recently from 7e89bac to 99cee0e Compare October 10, 2024 19:53
@aniketd aniketd marked this pull request as ready for review October 10, 2024 19:53
@aniketd aniketd requested a review from a team as a code owner October 10, 2024 19:53
Copy link
Contributor

@neilmayhew neilmayhew left a comment

Choose a reason for hiding this comment

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

Very nice improvement! Your handling of the protocol encoding variations is neat, too.

My suggestions are mostly cosmetic.

However, there's a more substantial one at the end. It doesn't affect the functionality, but it does affect the readability.

I've also suggested a few additional places where Mismatch could be used.

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Ledger.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs Outdated Show resolved Hide resolved
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

All my comments in BBODY rule module apply to all other rules affected by this PR.

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Bbody.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Bbody.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs Outdated Show resolved Hide resolved
Copy link
Contributor

@TimSheard TimSheard left a comment

Choose a reason for hiding this comment

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

OK I only commented on the Coders parts.
The extra constraint should not be there. We should try hrd to get rid of it.

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

This is looking great!
A few more simplifications and improvements and it will ready to go

@aniketd aniketd force-pushed the aniketd/mismatch-for-conway branch 3 times, most recently from 34b1182 to e8ec767 Compare October 18, 2024 12:05
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-binary
version: 1.4.0.0
version: 1.4.1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this requires 1.5.0.0, because it's a breaking change .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change won't break any client usage of the library, because it just introduces a new constructor. So a minor bump should be enough I thought.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
version: 1.4.1.0
version: 1.5.0.0

@teodanciu is right! This is a major breaking change. This is not explicitly listed in PVP, but it is widely considered to be a breaking change in the Haskell community. See some discussions here and comment by Phadej: "It adds constructors to LicenseId and LicenseListVersion, Language.Haskell.Extension.Extension. These are breaking changes."

Here is my reason depicted with an example why I consider such change to be a breaking change:

Imagine package A-1.0.0 defines Foo:

data Foo = Foo | Bar deriving Read

Package B-1.0.0 depends on A >= 1.0 and provides a function:

readFooIxMaybe :: String -> Maybe Int
readFooIxMaybe str = do
  foo <- readMaybe str
  pure $ case foo of
    Foo -> 1
    Bar -> 2

If you add a constructor to Foo and only bump a minor version in package A-1.0.1:

data Foo = Foo | Bar | Baz deriving Read

Then package B-1.0.0 will have the readFooIxMaybe function turn from a total to a partial function.

Also, add {Enc,Dec}CBORGroup instances for Mismatch
Rules:
- BBODY
- GOV
- GOVCERT
- LEDGER
- UTXO
- UTXOW
@aniketd aniketd requested a review from lehins October 23, 2024 14:12
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

There is one change that is still necessary that I overlooked and @teodanciu caught. It needs to be fixed. Otherwise it is ready to be merged.

@@ -1,8 +1,10 @@
# Version history for `cardano-ledger-binary`

## 1.4.0.1
## 1.4.1.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I did not catch it earlier, but adding a new constructor to a sum type is commonly considered a breaking change.

Suggested change
## 1.4.1.0
## 1.5.0.0

@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-binary
version: 1.4.0.0
version: 1.4.1.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
version: 1.4.1.0
version: 1.5.0.0

@teodanciu is right! This is a major breaking change. This is not explicitly listed in PVP, but it is widely considered to be a breaking change in the Haskell community. See some discussions here and comment by Phadej: "It adds constructors to LicenseId and LicenseListVersion, Language.Haskell.Extension.Extension. These are breaking changes."

Here is my reason depicted with an example why I consider such change to be a breaking change:

Imagine package A-1.0.0 defines Foo:

data Foo = Foo | Bar deriving Read

Package B-1.0.0 depends on A >= 1.0 and provides a function:

readFooIxMaybe :: String -> Maybe Int
readFooIxMaybe str = do
  foo <- readMaybe str
  pure $ case foo of
    Foo -> 1
    Bar -> 2

If you add a constructor to Foo and only bump a minor version in package A-1.0.1:

data Foo = Foo | Bar | Baz deriving Read

Then package B-1.0.0 will have the readFooIxMaybe function turn from a total to a partial function.

*
* Extend `Coders` to accommodate `{Enc|Dec}CBORGroup`. #4666
* Add `ToGroup` to `Encode`
* Add `FromGroup` to `Decode`

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* Add `{Enc|Dec}CBORGroup` instance for `(a, b)`

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.

5 participants