-
Notifications
You must be signed in to change notification settings - Fork 15
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
Change TxType type from uint16_t to uint8_t #1004
Conversation
This type is used in `Coin` and `snapshot::UTXOSubset` and we serialize it as `uint8_t` to reduce the disk usage. Since `TxType` is `uint16_t` there is a risk that we create a record that will have a number larger than 255 and it will cause incorrect value to be stored in the Coin or transferred via snapshot. To make it consistent on how this field is used, we should stick to `uint8_t` everywhere. Signed-off-by: Kostiantyn Stepaniuk <kostia@thirdhash.com>
The reasoning we have at the moment is misleading, with this rationale we must change type in the snapshot instead. Instead, I'd change the description. The rationale of this PR is to adjust TxType underlying type to the value which could satisfy our need for now and for nearest perspective. utACK for code change f052459. |
@frolosofsky I wrote few reasons. The first paragraph of the description says that we want to save 1 byte so we keep basically, the description is grouped like this:
|
@frolosofsky I extended the first paragraph which explains what we want to achieve. Let me, please, know if it's clearer. edited: Also added titles to every paragraph. Hope it brings also extra clarity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK f052459
It is nice to have uniform types
Tested on a testnet, haven't noticed it breaks the protocol. |
I would much prefer if we did not just trial-and-error understand whether a change breaks the protocol but if we actually understood what the repercussions of a given change are. Having said that, please do think about the protocol and maybe take into consideration how |
@scravy this is, of course, was checked and we have tests that: During serializing, we cast Do you see how the issue can occur using our client? Because the rationality of this PR is to avoid the error in our client first. Thinking about the external client, if they will set the first byte of |
See #1011 and the referenced code path. My concern is not about the change itself but how it is approached. From a protocol perspective this is just not sound and should be cleaned up properly. |
what we want to maintain
This
TxType
type is used inCoin
andsnapshot::UTXOSubset
and we serializeit as
uint8_t
to reduce the disk usage as 256 types of transactions must bemore than enough for all future transactions that we might create.
possible issue
Since
TxType
isuint16_t
there is a risk that we create a recordthat will have a number larger than 255 and it will cause incorrect
value to be stored in the Coin or transferred via snapshot.
proposed fix
To make it consistent on how this field is used,
we should stick to
uint8_t
everywhere.Signed-off-by: Kostiantyn Stepaniuk kostia@thirdhash.com