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

Encode all integers before saving to the sqlite database #3013

hackaugusto opened this Issue Nov 13, 2018 · 1 comment


None yet
4 participants

hackaugusto commented Nov 13, 2018

Problem Definition

SQLite support up to 8 bytes integers, but Raiden uses values up to 32 bytes. If a query is built with a value larger than 2 ** 8 -1 the following exception is thrown:

OverflowError: Python int too large to convert to SQLite INTEGER

This means we cannot represent integers in SQLite directly, and the value must be encoded with another representation.


  • Choose an alternative representation, preferably a representation which respects the total order of integers
  • Implement this new representation in the serializers/deserializers of all state_changes / events / state objects which contain integers
  • Fix the SQLite queries which rely on integers to also encode the values as appropriate:
    • Mainly done in

Backwards Compatibility

This will break database compatibility, since the representation of integers will change.

@hackaugusto hackaugusto changed the title from Encode all integers to hexadecimal before saving to the sqlite database to Encode all integers before saving to the sqlite database Nov 13, 2018


This comment has been minimized.


andrevmatos commented Nov 13, 2018

I think SQLite supports the NUMERIC datatypes, e.g. Decimal(30, 0), which supports arbitrarily large values (stored as text/blob if can't fit on standard int sizes). Lib/driver is then responsible for converting them upon reading, even casting it to python's Decimal type. Wouldn't it fit more transparently this usecase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment