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 uniqueness checking #21

Open
ReedOei opened this issue Jan 20, 2021 · 0 comments
Open

Add uniqueness checking #21

ReedOei opened this issue Jan 20, 2021 · 0 comments

Comments

@ReedOei
Copy link
Owner

ReedOei commented Jan 20, 2021

Whenever a new value of a unique type is created, we need to dynamically check to ensure that it has not been created before. To do this, we should:

  1. Implement hashing of every kind of base type (could be done by generating helper functions or just generating the hashing code inline). We should use abi.encodePacked for this (see this). Note that this will be very costly for maps and arrays; that is fine, because we want to ensure that uniqueness is properly handled, even at the cost of performance. We should consider adding a warning for this in the future (see Warn on expensive unique types #23).
  2. Add a mapping (bytes32 => bool) as a field of the contract for every unique type T.
  3. Whenever a new value of T is created: hash it, check if it's in the map, and throw an error if so, otherwise, add it to the map.
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

No branches or pull requests

1 participant