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

Introduce StableHashMap to support hashable-1.5.0.0 #1378

Merged
merged 3 commits into from
Nov 4, 2024

Conversation

larskuhtz
Copy link
Contributor

@larskuhtz larskuhtz commented Nov 1, 2024

In hashable-1.4.5.0 the hash algorithm for types that are based on ByteArray changes from a custom version of fnv1 to xxhash. This changes the order of items in HashMaps, some of which are relevant for on-chain semantics.

Ideally, no use of unordered-containers should depend on the order of items, which is an internal detail of the data structure as indicated by the use of the term "unordered" in the name of the package. Unfortunately, Pact violates this assumption in a few places where the order of items affects on-chain semantics. In particular, the order in which modules are resolved and loaded is affected by this.

As work around, this PR introduces a StableHashMap that is backed by the class StableHashable. Instances of StableHashable promise to never change the hash value for a given value.

This PR also includes instances of StableHashable for a few basic types that are compatible with the hash values from hashable-1.4.4.0.

PR checklist:

  • Test coverage for the proposed changes
  • PR description contains example output from repl interaction or a snippet from unit test output

Additionally, please justify why you should or should not do the following:

  • Confirm replay/back compat
  • Benchmark regressions
  • (For Kadena engineers) Run integration-tests against a Chainweb built with this version of Pact

@larskuhtz larskuhtz merged commit 1027a1f into master Nov 4, 2024
13 of 14 checks passed
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.

4 participants