While exploring possibilities of code optimization, I've found some strange behaviour in TVM prefix hashmaps - mappings that support variable-length keys which are not prefixes of each other. In short, I create one such dictionary via TVM and one via my custom program in Python with same key-value pairs, try retrieving the same keys, and one attempt succeeds while other fails.
Is it a bug in TVM or in my program? If former, this market resolves YES. If latter, and no other bug is found by the end of 2024, resolves NO.
This market refers to instructions PFXDICTSET
, PFXDICTREPLACE
, PFXDICTADD
and PFXDICTDEL
of TVM of The Open Network blockchain.
Pieces of evidence:
The underlying code is awfully inconvenient to read or understand which functions call which ones, but there is a version from competitor blockchain Everscale which should theoretically be compatible - since it's a fork.
Nor blockchain nor VM have had many bugs earlier.
I've grouped files of my test into a single gist: https://gist.github.com/ProgramCrafter/a22ff3e820f644e57d7cddb57f7b7fe7. Please take note of matching and mismatching hashes in particular.
I've heard a report that someone tried using prefix hashmaps for a zero-terminated-string (that'd guarantee that one string isn't prefix of another) mapping and failed.