Introduce StableHashMap to support hashable-1.5.0.0 #1378
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
hashable-1.4.5.0
the hash algorithm for types that are based onByteArray
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 classStableHashable
. Instances ofStableHashable
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 fromhashable-1.4.4.0
.PR checklist:
Additionally, please justify why you should or should not do the following: