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

Contract keys are broken in Scenarios #1623

Closed
bame-da opened this issue Jun 13, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@bame-da
Copy link
Contributor

commented Jun 13, 2019

I'm working on a DAML model for group chats:
https://gist.github.com/bame-da/7eb238eb87d8e20d6362948c22a50bed

The MessageIndex contract has a key, which goes wrong in two ways:

  1. At the end of the second_post scenario, I have two active MessageIndex contracts with the same key
  2. The reason we even try to create the second index is that the lookupByKey in GetOrCreateIndex doesn't work.
@bame-da

This comment has been minimized.

Copy link
Contributor Author

commented Jun 13, 2019

Not surprisingly, this is reproducible in Sandbox following exactly the steps from the scenario.

@gerolf-da

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2019

I'm fairly confident that I found the cause of this bug: hashCode and equals in ImmArray violate the contract that the hash codes of 2 objects need to be the same, if o1.equals(o2) == true.

@gerolf-da

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2019

In addition to that, FrontStack also didn't override and implement hashCode.

@bame-da

This comment has been minimized.

Copy link
Contributor Author

commented Jun 13, 2019

The latter is the more likely culprit, I think. That would explain why I only ran into this when using a list inside my keys.

gerolf-da added a commit that referenced this issue Jun 13, 2019

Correctly implement hashCode for ImmArray and Frontstack
ImmArray and FrontStack violated the contract between equals and
hashCode. ImmArray had a wrong implementation of hashCode, and
FrontStack had no implementation at all.

Fixes #1623.

gerolf-da added a commit that referenced this issue Jun 13, 2019

Correctly implement hashCode for ImmArray and Frontstack
ImmArray and FrontStack violated the contract between equals and
hashCode. ImmArray had a wrong implementation of hashCode, and
FrontStack had no implementation at all.

Fixes #1623.
@gerolf-da

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2019

Yes, the issue regarding the contract keys is probably rooted in FrontStack, because we are not slicing the record fields ImmArray.

gerolf-da added a commit that referenced this issue Jun 13, 2019

Correctly implement hashCode for ImmArray and Frontstack
ImmArray and FrontStack violated the contract between equals and
hashCode. ImmArray had a wrong implementation of hashCode, and
FrontStack had no implementation at all.

Fixes #1623.

gerolf-da added a commit that referenced this issue Jun 13, 2019

Correctly implement hashCode for ImmArray, FrontStack, BackStack (#1641)
ImmArray, FrontStack, and BackStack violated the contract between equals
and hashCode. ImmArray had a wrong implementation of hashCode, and
FrontStack and BackStack had no implementation at all.

Fixes #1623.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.