crossbario / cfxdb

Database schemata for CrossbarFX and XBR, based on zLMDB
MIT License
0 stars 6 forks source link

close_balance in a channel should return uint256 #60

Closed om26er closed 4 years ago

om26er commented 4 years ago

Currently the close_balance https://github.com/crossbario/cfxdb/blob/master/cfxdb/xbrmm/channel.py#L512 tries to return an integer value. msgpack is not able to serialize that value. It wouldn't be an issue if we were using CBOR everywhere, but due to https://github.com/crossbario/autobahn-js/issues/466 we are currently using MsgPackSerializer in Planet and Markets UI.

>>> import msgpack
>>> msgpack.dumps(100000000000000000000)  # 100XBR
Traceback (most recent call last):
  File "msgpack/_packer.pyx", line 171, in msgpack._cmsgpack.Packer._pack
OverflowError: Python int too large to convert to C unsigned long

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/om26er/scm/crossbario/xbr-www/venv/lib/python3.8/site-packages/msgpack/__init__.py", line 35, in packb
    return Packer(**kwargs).pack(o)
  File "msgpack/_packer.pyx", line 286, in msgpack._cmsgpack.Packer.pack
  File "msgpack/_packer.pyx", line 292, in msgpack._cmsgpack.Packer.pack
  File "msgpack/_packer.pyx", line 289, in msgpack._cmsgpack.Packer.pack
  File "msgpack/_packer.pyx", line 182, in msgpack._cmsgpack.Packer._pack
OverflowError: Integer value out of range

The other option would be: I fix CBOR in ABJS once and for all ;-)

om26er commented 4 years ago

I worked around that here https://github.com/crossbario/crossbarfx/pull/654/files#diff-49f65beb5cba00592164fba27d21ef7dR2033 (WONT BE LANDING)

oberstet commented 4 years ago

the bug is: in marshal https://github.com/crossbario/cfxdb/blob/7ebe24a9415229ea6d073665b012dad553b1b0cd/cfxdb/xbrmm/channel.py#L208 we should pack the big int as a binary like we (correctly) do here https://github.com/crossbario/cfxdb/blob/master/cfxdb/xbrmm/channel.py#L203

om26er commented 4 years ago

the bug is: in marshal

oops, I am an idiot, seems that was a one liner ;-)