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

Add a Mismatch type to be used for predicate failures #4619

Open
lehins opened this issue Sep 10, 2024 · 0 comments
Open

Add a Mismatch type to be used for predicate failures #4619

lehins opened this issue Sep 10, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request serialization Anything that affects serialization of ledger types

Comments

@lehins
Copy link
Collaborator

lehins commented Sep 10, 2024

One of the most common patterns in predicate failures is reporting a mismatched value. It is usually tricky to infer from the predicate failure which value was the expected value and which one was supplied by the user. There is also no guarantee that the order between the predicates will be consistent, leading to more confusion The proper Haskell solution for this is to add a type for this:

data Mismatch a = Mismatch
  { mismatchSupplied :: !a
  , mismatchExpected :: !a
  }

Adding the type is the easiest part of this task. Second part is to use it for all predicate failures that we have right now.

It is very important to not mess up serialization of Conway predicate failures, since that is the live era and we can't break the nope-to-client communication protocol. Prior eras do not have this problem anymore, as long as those predicate failures are not used in Conway. For the cases where predicate failures are still being used, we need to carefully adjust the encoders/decoders to keep them backwards compatible, while switching to using the Mismatch type.

@lehins lehins added enhancement New feature or request serialization Anything that affects serialization of ledger types labels Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request serialization Anything that affects serialization of ledger types
Projects
Status: In progress
Development

No branches or pull requests

2 participants