-
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
Add new command line option to make replaying transactions easier #5027
Conversation
This new option can be used only if replay is also enabled. It takes a transaction hash from the ledger loaded for replay, and will cause a specific line to be hit in Transactor.cpp, right before the selected transaction is applied.
297bc96
to
d87bcca
Compare
d87bcca
to
f62f663
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #5027 +/- ##
=========================================
+ Coverage 71.1% 71.3% +0.2%
=========================================
Files 796 796
Lines 66997 66883 -114
Branches 10979 10867 -112
=========================================
+ Hits 47635 47685 +50
+ Misses 19362 19198 -164
|
I will try to add add unit test for this change, since apparently |
2b7b7f7
to
92ca3f8
Compare
JLOG(m_journal.fatal()) | ||
<< "Ledger " << replayLedger->info().seq | ||
<< " does not contain the transaction hash " << *trapTxID; | ||
return false; |
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.
Should we return false
in this case or just log? The semantics of this call is to return false
if the ledger fails to load.
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.
Yes, that's intentional - you only use this functionality when replaying a transaction, and failing a little earlier (still need several minutes to load that ledger) will save your time.
|
||
env.close(); | ||
auto const closed = env.rpc("ledger", "current", "full")[jss::result]; | ||
BEAST_EXPECT(closed[jss::ledger][jss::accountState].size() == 98); |
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 is the meaning of the tests for 97, 98, "<=", etc? Can you add some comments to clarify. Just adding the comments in one code block would be useful.
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.
Added comment to explain - in replay
mode, the ledger being replayed needs to be explicitly accepted e.g. with env.close()
. Before this call, we are getting an earlier ledger as current
, with one fewer state objects.
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'm a little torn on this patch. On the one hand, this makes it easier to replay transactions without needing to set conditional breakpoints. On the other hand, knowing how to set conditional breakpoints is a skill I'd expect anyone wanting to replay transactions to have. On the other hand, this is pretty simple code, so adding it isn't too large of a cost.
If other people find this useful I think it's OK to add.
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.
👍
585268c
to
79dff4b
Compare
* upstream/develop: (32 commits) fixInnerObjTemplate2 amendment (XRPLF#5047) Set version to 2.3.0-b1 Ignore restructuring commits (XRPLF#4997) Recompute loops (XRPLF#4997) Rewrite includes (XRPLF#4997) Rearrange sources (XRPLF#4997) Move CMake directory (XRPLF#4997) Add bin/physical.sh (XRPLF#4997) Prepare to rearrange sources: (XRPLF#4997) Change order of checks in amm_info: (XRPLF#4924) Add the fixEnforceNFTokenTrustline amendment: (XRPLF#4946) Replaces the usage of boost::string_view with std::string_view (XRPLF#4509) docs: explain how to find a clang-format patch generated by CI (XRPLF#4521) XLS-52d: NFTokenMintOffer (XRPLF#4845) chore: remove repeat words (XRPLF#5041) Expose all amendments known by libxrpl (XRPLF#5026) fixReducedOffersV2: prevent offers from blocking order books: (XRPLF#5032) Additional unit tests for testing deletion of trust lines (XRPLF#4886) Fix conan typo: (XRPLF#5044) Add new command line option to make replaying transactions easier: (XRPLF#5027) ...
…RPLF#5027) * Add trap_tx_hash command line option This new option can be used only if replay is also enabled. It takes a transaction hash from the ledger loaded for replay, and will cause a specific line to be hit in Transactor.cpp, right before the selected transaction is applied.
High Level Overview of Change
Add new command line option
trap_tx_hash
to make replaying transactions easierThis new option can be used only if
replay
is also enabled. It takes a transaction hash from the ledger loaded for replay, and will cause a specific line to be hit inTransactor::operator()
, right beforeapply()
.Emit an error if:
replay
uint256
in hex)Context of Change
While replaying specific ledger is relatively easy, things get more difficult if we want to debug a specific transaction within the ledger. There are several options, but all of them are a hassle. Why not just a new option to
rippled
to hit a very specific line of code, right before a specific transaction on the replayed ledger is being applied.This change adds new virtual function
std::optional<uint256> trapTxID() const
toripple::Application
class. This new function is called insideTransactor::operator()
to check if:If both conditions are met,
rippled
will simply logTransaction trapped
followed by a hash. The user can put a breakpoint at this line to break into the debugger.Type of Change
.gitignore
, formatting, dropping support for older tooling)