XRPLF / rippled

Decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++
https://xrpl.org
ISC License
4.48k stars 1.44k forks source link

Add new command line option to make replaying transactions easier #5027

Closed Bronek closed 2 weeks ago

Bronek commented 1 month ago

High Level Overview of Change

Add new command line option trap_tx_hash to make replaying transactions easier

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::operator(), right before apply().

Emit an error if:

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 to ripple::Application class. This new function is called inside Transactor::operator() to check if:

If both conditions are met, rippled will simply log Transaction trapped followed by a hash. The user can put a breakpoint at this line to break into the debugger.

Type of Change

codecov-commenter commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 71.3%. Comparing base (e3d1bb2) to head (add69ab).

:exclamation: Current head add69ab differs from pull request most recent head 79dff4b

Please upload reports for the commit 79dff4b to get more accurate results.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/XRPLF/rippled/pull/5027/graphs/tree.svg?width=650&height=150&src=pr&token=i2RPGI5xGF&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF)](https://app.codecov.io/gh/XRPLF/rippled/pull/5027?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF) ```diff @@ 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 ``` | [Files](https://app.codecov.io/gh/XRPLF/rippled/pull/5027?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF) | Coverage Δ | | |---|---|---| | [src/ripple/app/main/Application.cpp](https://app.codecov.io/gh/XRPLF/rippled/pull/5027?src=pr&el=tree&filepath=src%2Fripple%2Fapp%2Fmain%2FApplication.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9hcHAvbWFpbi9BcHBsaWNhdGlvbi5jcHA=) | `65.9% <100.0%> (+2.9%)` | :arrow_up: | | [src/ripple/app/main/Application.h](https://app.codecov.io/gh/XRPLF/rippled/pull/5027?src=pr&el=tree&filepath=src%2Fripple%2Fapp%2Fmain%2FApplication.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9hcHAvbWFpbi9BcHBsaWNhdGlvbi5o) | `100.0% <ø> (ø)` | | | [src/ripple/app/main/Main.cpp](https://app.codecov.io/gh/XRPLF/rippled/pull/5027?src=pr&el=tree&filepath=src%2Fripple%2Fapp%2Fmain%2FMain.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9hcHAvbWFpbi9NYWluLmNwcA==) | `79.6% <100.0%> (+32.6%)` | :arrow_up: | | [src/ripple/app/tx/impl/Transactor.cpp](https://app.codecov.io/gh/XRPLF/rippled/pull/5027?src=pr&el=tree&filepath=src%2Fripple%2Fapp%2Ftx%2Fimpl%2FTransactor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9hcHAvdHgvaW1wbC9UcmFuc2FjdG9yLmNwcA==) | `84.6% <100.0%> (+0.1%)` | :arrow_up: | | [src/ripple/core/Config.h](https://app.codecov.io/gh/XRPLF/rippled/pull/5027?src=pr&el=tree&filepath=src%2Fripple%2Fcore%2FConfig.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9jb3JlL0NvbmZpZy5o) | `77.8% <ø> (ø)` | | ... and [7 files with indirect coverage changes](https://app.codecov.io/gh/XRPLF/rippled/pull/5027/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF) [![Impacted file tree graph](https://app.codecov.io/gh/XRPLF/rippled/pull/5027/graphs/tree.svg?width=650&height=150&src=pr&token=i2RPGI5xGF&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF)](https://app.codecov.io/gh/XRPLF/rippled/pull/5027?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF)
Bronek commented 1 month ago

I will try to add add unit test for this change, since apparently Application class is usable in unit tests.