hub icon indicating copy to clipboard operation
hub copied to clipboard

HashXHistoryPrefixRow issue with endianness of TxNums written to DB

Open moodyjon opened this issue 3 years ago • 1 comments

Python scribe when run on my machine (MacOS ARM64) produces little-endian txnums for hashXhistory prefix. (I just looked up M1 mac behavior, and it's little-endian by default) But there could be some more exotic platform that writes txnums big-endian fashion.

The endianness should be corrected to big-endian like other numbers in the database OR it should be locked to be little-endian specifically.

For now, I am correcting (herald.go) HashXHistoryValue implementation to read TxNums in little-endian form.

moodyjon avatar Sep 01 '22 17:09 moodyjon

This is a consequence of using an array.array('I'), which uses the native endianness. And I think it's actually worse - docs say It can be 16 bits or 32 bits depending on the platform. (https://docs.python.org/3/library/array.html). Perhaps another library offers good enough performance and the ability to specify endianness, or we could make our own fast little endian uint32 array serializer/deserializer in cython.

jackrobison avatar Sep 14 '22 01:09 jackrobison