tweag / cooked-validators

MIT License
39 stars 11 forks source link

Function to decide when two `Constraints` are semanically equal #165

Closed carlhammann closed 1 year ago

carlhammann commented 1 year ago

The Constraints type has an Eq instance, which implements a very fine notion of equality. That's good, as we discussed when we defined it. Sometimes, however, we want to compare two Constraints and the question we have in mind is "Do they describe the same transaction?".

In the current reworking of the attack framework, the function sameConstraints tries to answer that question. At the moment, is is only used to make the modified transactions generated by the doubleSatAttack unique. There's also assertSameConstraints, which is based on the same logic and is used in a few test cases.

The function sameConstraints identifies the following:

The question is

At the moment, since the use of sameConstraints is still very limited, the worst thing that can happen is the double satisfaction attack generating slightly too many or few cases; for the future I think that we should get some function like sameConstraints right.

carlhammann commented 1 year ago

For the record: The implementation of sameConstraints I linked above is wrong. It identifies, say, [Mints a _ 1, Mints a _ 4]and [Mints a _ 3, Mints a _ 3].

Edit: The mistake is corrected in this commit, but the questions above still stand. Maybe they're even better illustrated....