openmina / mina-p2p-messages-rs

0 stars 0 forks source link

Sort out signed/unsigned integers representation on Rust side #43

Closed akoptelov closed 11 months ago

akoptelov commented 11 months ago

In Mina, unsigned 32- and 64-bit integers are widely used. Still, it looks like their binprot encoding is based on signed integers represented by the the same bits.

As our Rust types are based on binprot shapes, and that singned-ness is "erased" in the shapes, all integers in Rust are based on signed built-in variants (i32, i64). That causes some confusion when using these types/fields in Rust (see e.g. #38), and also JSON representation is incorrect.

It seems that we should use u32/u64 types as interface types for our unsigned Mina numbers, but keep binprot using i32/i64 respectively (question is, what type should be used for storing?).