-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
refactor: simplify TxFormats
common fields logic
#4637
Conversation
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.
👍 Nice refactor.
I’d simply move the ticket field out of the individual transaction formats and into the common fields and then add a manual check in Transactor.cpp to ensure that transactions that aren’t supposed to have this field (i.e. system generated pseudo-transactions) don’t accidentally include it. |
Given this PR has two approvals, I think we can put this in for now, and consider the above suggestion in a separate/later PR. |
@mvadari - at your convenience, you can resolve the conflict so that this PR would be able to merge cleanly on |
199bbad
to
97d89af
Compare
(Since this PR was force-pushed, let's get 1 re-review from @HowardHinnant , at his convenience) |
Sorry, was I supposed to merge it? I thought you preferred rebases + force pushes. |
FWIW, I prefer merge commits. It's the way git is designed to be used. |
Minor refactor to `TxFormats.cpp`: - Rename `commonFields` to `pseudoCommonFields` (since it is the common fields that all pseudo-transactions need) - Add a new static variable, `commonFields`, which represents all the common fields that non-pseudo transactions need (essentially everything that `pseudoCommonFields` contains, plus `sfTicketSequence`) This makes it harder to accidentally leave out `sfTicketSequence` in a new transaction.
Minor refactor to `TxFormats.cpp`: - Rename `commonFields` to `pseudoCommonFields` (since it is the common fields that all pseudo-transactions need) - Add a new static variable, `commonFields`, which represents all the common fields that non-pseudo transactions need (essentially everything that `pseudoCommonFields` contains, plus `sfTicketSequence`) This makes it harder to accidentally leave out `sfTicketSequence` in a new transaction.
Make transactions and pseudo-transactions share the same commonFields again. This regularizes the code in a nice way. While this technically allows pseudo-transactions to have a TicketSequence field, pseudo-transactions are only ever constructed by code paths that don't add such a field, so this is not a transaction processing change. It may be possible to add a separate check to ensure TicketSequence (and other fields that don't make sense on pseudo-transactions) are never added to pseudo-transactions, but that should not be necessary. (TicketSequence is not the only common field that can not and does not appear in pseudo-transactions.) Note: TicketSequence is already documented as a common field. Related: #4637 Fix #4714
Make transactions and pseudo-transactions share the same commonFields again. This regularizes the code in a nice way. While this technically allows pseudo-transactions to have a TicketSequence field, pseudo-transactions are only ever constructed by code paths that don't add such a field, so this is not a transaction processing change. It may be possible to add a separate check to ensure TicketSequence (and other fields that don't make sense on pseudo-transactions) are never added to pseudo-transactions, but that should not be necessary. (TicketSequence is not the only common field that can not and does not appear in pseudo-transactions.) Note: TicketSequence is already documented as a common field. Related: XRPLF#4637 Fix XRPLF#4714
Minor refactor to `TxFormats.cpp`: - Rename `commonFields` to `pseudoCommonFields` (since it is the common fields that all pseudo-transactions need) - Add a new static variable, `commonFields`, which represents all the common fields that non-pseudo transactions need (essentially everything that `pseudoCommonFields` contains, plus `sfTicketSequence`) This makes it harder to accidentally leave out `sfTicketSequence` in a new transaction.
Make transactions and pseudo-transactions share the same commonFields again. This regularizes the code in a nice way. While this technically allows pseudo-transactions to have a TicketSequence field, pseudo-transactions are only ever constructed by code paths that don't add such a field, so this is not a transaction processing change. It may be possible to add a separate check to ensure TicketSequence (and other fields that don't make sense on pseudo-transactions) are never added to pseudo-transactions, but that should not be necessary. (TicketSequence is not the only common field that can not and does not appear in pseudo-transactions.) Note: TicketSequence is already documented as a common field. Related: XRPLF#4637 Fix XRPLF#4714
High Level Overview of Change
This PR proposes a minor refactor to
ripple/protocol/TxFormats.cpp
, renamingcommonFields
topseudoCommonFields
(since it is the common fields that all pseudo-transactions need) and adding a new static variable,commonFields
, which represents all the common fields that non-pseudo transactions need (essentially everything thatpseudoCommonFields
contains, plussfTicketSequence
).Context of Change
This makes it harder to accidentally leave out
sfTicketSequence
in a new transaction.Type of Change