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

Maximum block number too small? Potential integer rollover bug. #37

Open
j-huff opened this issue Sep 5, 2024 · 0 comments
Open

Maximum block number too small? Potential integer rollover bug. #37

j-huff opened this issue Sep 5, 2024 · 0 comments

Comments

@j-huff
Copy link

j-huff commented Sep 5, 2024

From my understanding of rfc9171, there isn't really a limit on the number of canonical blocks you can have. However, ION imposes a soft limit of around 255. This is because the block number is stored as a unsigned char in the ExtensionBlock struct, and selectBlkNumber similarly returns an unsigned char.

selectBlkNumber in particular could pose trouble if someone were to send a bundle containing a block number set to a multiple of 255. In that case, selectBlkNumber would return 0 due to rolling over after adding 1.

It's probably best to either impose a hard limit on the maximum block number, or store it as a uvast. According to the spec, the block number is simply for uniquely identifying blocks, so there is nothing stopping an implementation from starting their canonical block numbering from 2^64-1 instead of starting from 2 like ION does (0 and 1 are reserved for primary and payload blocks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant