Skip to content
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

org.ton.block.VarUInteger addition always throws an exception #102

Open
mcnckc opened this issue Sep 13, 2023 · 1 comment
Open

org.ton.block.VarUInteger addition always throws an exception #102

mcnckc opened this issue Sep 13, 2023 · 1 comment
Labels
wontfix This will not be worked on

Comments

@mcnckc
Copy link

mcnckc commented Sep 13, 2023

On almost any addition (say VarUInteger(1)+VarUInteger(1)) an exception is thrown from plus in line 45

https://github.com/andreypfau/ton-kotlin/blob/b1edc4b134e89ccf252149f27c85fd530377cebe/ton-kotlin-block/src/commonMain/kotlin/org/ton/block/VarUInteger.kt#L41-L47

This happens, because VarUInteger, when constructed, holds number's length in bytes:
https://github.com/andreypfau/ton-kotlin/blob/b1edc4b134e89ccf252149f27c85fd530377cebe/ton-kotlin-block/src/commonMain/kotlin/org/ton/block/VarUInteger.kt#L26-L31

Therefore, in line 45, maxLen contains number of bytes, but actualLen is clearly number of bits, and very often number of bits is larger, causing this exception. It is also related to other mathematical operators with VarUInteger
Moreover, to me it seems that bit length anyway can increase when adding two numbers of the same bit length

@andreypfau
Copy link
Collaborator

arithmetic operators will be removed in the next release due separation of serialization objects
and actual arithmetics, use BigInt instead.

@andreypfau andreypfau added the wontfix This will not be worked on label Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants