-
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
Implement new fields for the type and version of the transaction #1062
Conversation
Hello @dsaveliev! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2019-05-06 08:12:46 UTC |
Concept ACK 6427ac9 |
The description feels a bit out-of-place. The "dead byte" referred to in #1011 is the 3rd byte which serves no use currently, which this Pull Request correctly fixes.
This seems to refer to the version byte. That byte is not the byte which is referred to as "dead byte". |
Signed-off-by: Dmitry Saveliev <[email protected]>
6427ac9
to
6d5c41d
Compare
Right now
And I'm talking about the last byte - it would be easier for us to keep all 4 bytes of |
In my opinion just because something is easier is not a good excuse to not have a clean protocol. |
// tx version | ||
"01000000" | ||
"01" |
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.
I see we had a version and then type before and now it's opposite. I think it makes more sense to keep the previous order as it makes it easier to compare the change.
So, finally, we decided to keep all four original bytes but split them into four independent fields. |
We decided to go with this:
This will make for 4 fields each 1 byte. This should be ultimately compatible with bitcoin, clearly distinguish |
Related and intended to fix #1011
TL;DR: Let's keep it as is and reserve our "dead byte" for the future needs.
This PR is an attempt to substitute current
uint32_t nVersion
combo withuint8_t version
anduint8_t type
fields inside ofCTransaction
.The reason to keep
version
filed is quite simple - it serves the needs of BIP-68 (Relative lock-time using consensus-enforced sequence numbers) and essentially implements some kind of flag. In theory, this logic can be substituted by BIP-112CHECKSEQUENCEVERIFY
but this is another big topic for discussion.In this sense
version
andtype
express orthogonal concepts and this is the reason to keep them both in the transaction (otherwise we will getn_versions * m_types
elements for unified field).Even though an idea looks viable at first sight, harsh reality punches us right into face:
transaction_tests
, which totally useless since we must rewritetx_valid.json
andtx_invalid.json
completely (and better to write some kind of generator to produce this stubs automatically)And even if previous problems can be solved, continuous syncing with bitcoin codebase will force to repeat all this work over and over again.
Looks like it's better in similar cases to stick up to bitcoin protocol, otherwise, we will drown in tech debt very quickly. Consider this PR like an illustration of efforts, needed to introduce a minimal change in the protocol.
As an alternative, I can suggest to split
nVersion
into four 1-byte fields and preserve the original byte order. Two unused fields will be reserved for future needs.Signed-off-by: Dmitry Saveliev [email protected]