-
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
Unify JSON serialization format of transactions #4775
Unify JSON serialization format of transactions #4775
Conversation
3118db5
to
3801519
Compare
e9881c1
to
83c1934
Compare
b8b2813
to
43237ff
Compare
43237ff
to
4c9c01e
Compare
be2893a
to
e750918
Compare
0ffd642
to
7f6bf53
Compare
@ximinez I think I implemented all your remarks. Do you mind reviewing again ? Thank you ! |
We may consider turning this into a general-purpose template and using it elsewhere
d5d6af0
to
94c16d8
Compare
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.
hey bronek, I really like the latest set of changes on getJson
, it really simplifies things. I've left a few minor comments.
I think the presence of jss::ledger_index
inside tx_json
still needs to be addressed.
no, want to keep it where it is (in addition to the new location) in API version 2; then remove in API version 3 |
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.
thanks bronek, this PR looks good.
Per XRPLF/rippled#4775 (comment) this command only returns transactions from validated ledgers, so this clarifies that detail
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.
Partial review. Some of these comments may be outdated due to changes since I originally wrote them.
} | ||
catch (SHAMapMissingNode const& mn) | ||
{ | ||
auto stream = app_.journal("IsValidated").warn(); // TODO Better name ? |
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.
LedgerMaster
has an m_journal
member. May as well use that. In which case, you won't really need the stream
local. Just fall back to the usual pattern of JLOG(m_journal.warn())
.
src/ripple/app/misc/NetworkOPs.cpp
Outdated
// NOTE jvObj which is not a finished object for either API version. After | ||
// it's populated, we need to finish it for a specific API version. This is | ||
// done in a loop, near the end of this function. | ||
std::string hash = {}; |
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.
What about this idea? hash
is getting built the same way, regardless of the code path (to_string(getTransactionID())
). The old code path sticks it into the Json
object; the new way sticks it into an optional
. What if you undo the changes to STTx::getJson
, then pull the hash value it builds out here?
It would look something like:
jvObj[jss::transaction] = transaction->getJson(JsonOptions::none);
std::string const hash = jvObj[jss::transaction][jss::hash].asString();
jvObj[jss::transaction].removeMember(jss::hash);
Another advantage of initializing it here is that it can be made const
.
Fix #4727 Squashed commit of the following: commit 53e384f Author: Bronek Kozicki <brok@incorrekt.com> Date: Fri Nov 3 13:37:29 2023 +0000 Minor improvements commit c1f2ea4 Merge: 942e209 056255e Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Nov 2 21:43:11 2023 +0000 Merge branch 'develop' into feature/unify_transaction_json commit 942e209 Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Nov 2 21:26:05 2023 +0000 Unconditionally set validated in account_tx output commit b5b1118 Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Nov 2 21:14:37 2023 +0000 Remove obsolete comments commit 7770bc5 Author: Chenna Keshava <ckeshavabs@gmail.com> Date: Thu Nov 2 13:16:44 2023 -0700 simplify the extraction of transactionID from Transaction object commit 94c16d8 Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Nov 2 20:26:09 2023 +0000 Replace class enum JsonOptions with struct We may consider turning this into a general-purpose template and using it elsewhere commit b2a8a2d Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Nov 2 17:46:54 2023 +0000 Minor improvements commit 95b6055 Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Nov 2 17:14:53 2023 +0000 Improve getJson for Transaction and STTx commit 17e6588 Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Nov 2 12:06:30 2023 +0000 Fix typos commit 5973390 Author: Bronek Kozicki <brok@incorrekt.com> Date: Wed Nov 1 15:55:02 2023 +0000 Fix validated and close_time_iso in account_tx commit cdb3384 Author: Bronek Kozicki <brok@incorrekt.com> Date: Tue Oct 31 17:27:57 2023 +0000 Add ledger_hash, ledger_index to transaction_entry commit 0d8673c Author: Bronek Kozicki <brok@incorrekt.com> Date: Tue Oct 31 17:12:53 2023 +0000 Update API-CHANGELOG.md commit 625c812 Merge: 54f1d60 3b624d8 Author: Bronek Kozicki <brok@incorrekt.com> Date: Mon Oct 30 21:32:35 2023 +0000 Merge branch 'develop' into feature/unify_transaction_json commit 54f1d60 Author: Bronek Kozicki <brok@incorrekt.com> Date: Mon Oct 30 21:19:40 2023 +0000 Set ledger_hash on closed ledger, even if not validated commit ef1276c Author: Bronek Kozicki <brok@incorrekt.com> Date: Mon Oct 30 20:59:58 2023 +0000 Minor fixes commit c81bece Author: Bronek Kozicki <brok@incorrekt.com> Date: Mon Oct 30 17:45:49 2023 +0000 Rename mInLedger to mLedgerIndex commit c477eb4 Author: Bronek Kozicki <brok@incorrekt.com> Date: Mon Oct 30 17:35:33 2023 +0000 Improved comments commit e386093 Author: Chenna Keshava <ckeshavabs@gmail.com> Date: Thu Oct 26 17:51:41 2023 -0700 additional tests for Subscribe unit tests commit 9f1d544 Author: Bronek Kozicki <brok@incorrekt.com> Date: Mon Oct 30 16:09:17 2023 +0000 Time formatting fix commit 4e92ee4 Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Oct 26 14:04:40 2023 +0000 Store closeTime in LedgerFill commit 1115cef Author: Bronek Kozicki <brok@incorrekt.com> Date: Thu Oct 26 13:22:26 2023 +0100 Move isValidated from RPCHelpers to LedgerMaster commit 2035bbc Author: Bronek Kozicki <brok@incorrekt.com> Date: Tue Oct 24 19:15:50 2023 +0000 Set ledger_hash and ledger_index commit bdf90e5 Author: Bronek Kozicki <brok@incorrekt.com> Date: Tue Oct 24 18:24:30 2023 +0000 Remove inLedger from API version 2 commit c2a3b52 Author: Bronek Kozicki <brok@incorrekt.com> Date: Tue Oct 24 17:39:45 2023 +0000 Add unit test for tx commit 1a96800 Author: Bronek Kozicki <brok@incorrekt.com> Date: Tue Oct 24 16:53:31 2023 +0000 Add unit test for transaction_entry commit 2b397c9 Author: Bronek Kozicki <brok@incorrekt.com> Date: Tue Oct 24 15:45:41 2023 +0000 Add small APIv2 unit test for subscribe commit 4d517e2 Author: Bronek Kozicki <brok@incorrekt.com> Date: Mon Oct 23 15:27:35 2023 +0000 Store close_time_iso in API v2 output commit 910f125 Author: Bronek Kozicki <brok@incorrekt.com> Date: Wed Oct 18 17:24:42 2023 +0100 Output from tx commit 0fb0517 Author: Bronek Kozicki <brok@incorrekt.com> Date: Wed Oct 18 17:24:26 2023 +0100 Output from transaction_entry commit e4ce8b1 Author: Bronek Kozicki <brok@incorrekt.com> Date: Wed Oct 18 17:24:08 2023 +0100 Output from account_tx commit 92635aa Author: Bronek Kozicki <brok@incorrekt.com> Date: Wed Oct 18 17:23:49 2023 +0100 Output from ledger commit 76eee5a Author: Bronek Kozicki <brok@incorrekt.com> Date: Wed Oct 18 17:23:16 2023 +0100 Output from sign, submit etc. commit aa6de60 Author: Bronek Kozicki <brok@incorrekt.com> Date: Mon Oct 23 18:20:21 2023 +0000 Output for subscriptions commit ee53c5d Author: Bronek Kozicki <brok@incorrekt.com> Date: Wed Oct 25 18:17:10 2023 +0000 Formatting fix commit 65346dc Author: Bronek Kozicki <brok@incorrekt.com> Date: Wed Oct 25 18:07:18 2023 +0000 Remove include <ranges>
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 have a handful of comments here, but they're all pretty minor.
@@ -163,7 +164,7 @@ class Subscribe_test : public beast::unit_test::suite | |||
} | |||
|
|||
void | |||
testTransactions() | |||
testTransactions_APIv1() |
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.
This PR is great and I'm approving it. But I think we should also add testcase("transactions API Version 1")
. Small change :) I know that a bunch of tests don't have the testcase, and I'm not sure why... but if we have the facility, we should use it 😆
* Remove include <ranges> * Formatting fix * Output for subscriptions * Output from sign, submit etc. * Output from ledger * Output from account_tx * Output from transaction_entry * Output from tx * Store close_time_iso in API v2 output * Add small APIv2 unit test for subscribe * Add unit test for transaction_entry * Add unit test for tx * Remove inLedger from API version 2 * Set ledger_hash and ledger_index * Move isValidated from RPCHelpers to LedgerMaster * Store closeTime in LedgerFill * Time formatting fix * additional tests for Subscribe unit tests * Improved comments * Rename mInLedger to mLedgerIndex * Minor fixes * Set ledger_hash on closed ledger, even if not validated * Update API-CHANGELOG.md * Add ledger_hash, ledger_index to transaction_entry * Fix validated and close_time_iso in account_tx * Fix typos * Improve getJson for Transaction and STTx * Minor improvements * Replace class enum JsonOptions with struct We may consider turning this into a general-purpose template and using it elsewhere * simplify the extraction of transactionID from Transaction object * Remove obsolete comments * Unconditionally set validated in account_tx output * Minor improvements * Minor fixes --------- Co-authored-by: Chenna Keshava <ckeshavabs@gmail.com>
High Level Overview of Change
Unify JSON format of transaction as per #4727 , intended for API version 2 release
Type of Change
.gitignore
, formatting, dropping support for older tooling)API Impact
libxrpl
change (any change that may affectlibxrpl
or dependents oflibxrpl
)