feat: add `simulate` RPC to dry-run a tx (XLS-69d)
High Level Overview of Change
This PR adds a new API method, titled simulate, which executes a dry run of a transaction submission.
This PR also fixes #5070.
Context of Change
It is useful to take a transaction, simulate execution it in the current ledger, and return the metadata - but not persist the transaction in the ledger. This can be used for testing, analysis, and more.
XLS spec: https://github.com/XRPLF/XRPL-Standards/pull/207
Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Refactor (non-breaking change that only restructures code)
- [ ] Performance (increase or change in throughput and/or latency)
- [x] Tests (you added tests for code that already exists, or your new feature included in this PR)
- [ ] Documentation update
- [ ] Chore (no impact to binary, e.g.
.gitignore, formatting, dropping support for older tooling) - [ ] Release
API Impact
- [x] Public API: New feature (new methods and/or new fields)
- [ ] Public API: Breaking change (in general, breaking changes should only impact the next api_version)
- [ ]
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl) - [ ] Peer protocol change (must be backward compatible or bump the peer protocol version)
Test Plan
Testing is still in progress. Unit tests are and will be added.
Current Status
This PR is complete and ready for review. You can build this branch and sync with the network of your choice (including Mainnet). The public is welcome to test and use this code (at your own risk). Next steps are code review and QA testing.
Codecov Report
Attention: Patch coverage is 98.21429% with 6 lines in your changes missing coverage. Please review.
Project coverage is 78.1%. Comparing base (
50b8f19) to head (4845f7b). Report is 1 commits behind head on develop.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/xrpld/rpc/detail/TransactionSign.cpp | 94.0% | 5 Missing :warning: |
| src/xrpld/app/tx/detail/apply.cpp | 90.0% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #5069 +/- ##
=========================================
+ Coverage 78.0% 78.1% +0.1%
=========================================
Files 789 790 +1
Lines 67061 67279 +218
Branches 8108 8101 -7
=========================================
+ Hits 52324 52562 +238
+ Misses 14737 14717 -20
| Files with missing lines | Coverage Δ | |
|---|---|---|
| include/xrpl/protocol/ErrorCodes.h | 100.0% <ø> (ø) |
|
| src/libxrpl/protocol/ErrorCodes.cpp | 85.7% <ø> (ø) |
|
| src/libxrpl/protocol/InnerObjectFormats.cpp | 100.0% <100.0%> (ø) |
|
| src/xrpld/app/ledger/detail/BuildLedger.cpp | 91.4% <100.0%> (ø) |
|
| src/xrpld/app/ledger/detail/LedgerMaster.cpp | 44.0% <100.0%> (+0.1%) |
:arrow_up: |
| src/xrpld/app/ledger/detail/OpenLedger.cpp | 73.4% <100.0%> (+0.3%) |
:arrow_up: |
| src/xrpld/app/main/Main.cpp | 79.8% <ø> (ø) |
|
| src/xrpld/app/misc/NetworkOPs.cpp | 70.1% <100.0%> (+<0.1%) |
:arrow_up: |
| src/xrpld/app/misc/TxQ.h | 98.2% <ø> (ø) |
|
| src/xrpld/app/misc/detail/TxQ.cpp | 98.8% <100.0%> (+<0.1%) |
:arrow_up: |
| ... and 18 more |
This is now fully finished and ready for review.
Maybe you forgot to commit but I don't see expired NFT offer tests
Maybe you forgot to commit but I don't see expired NFT offer tests
#5247
Adding the performance testing results composed by @sophiax851 here for reference. Conclusion:
A rippled client handler node can support ~1200 requests/sec of Simulate RPC load, simulating mixed payment transaction loads (considered the heaviest type of Simulate), while in an XRPL network with real payment transactions load (150tps). It far exceeds the RPC limit (~100 requests/sec) allowed for a single IP that is not on the rippled whitelist. In other words, a rippled node can handle the maximum Simulate traffic permitted from multiple (>10) anonymous sources
Compared to the TX RPC load, the type of Simulate RPC used in the testing is 2.2 times more CPU resource-intensive.
Based on the above results, the risk of using Simulate as a tool to overload a rippled node appears to be low and is outweighed by the benefits Simulate is designed to provide to the community users, therefore, it passes performance testing.
This PR increases overall test coverage of the project by 0.10% , to 78.10% , which is really nice - thank you @mvadari !