Skip to content
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

fixInnerObjTemplate2 amendment #5047

Merged
merged 8 commits into from
Jun 27, 2024

Conversation

scottschurr
Copy link
Collaborator

High Level Overview of Change

Apply inner object templates to all remaining (non-AMM) inner objects.

Context of Change

It was discovered that the inner objects added to the code base for the AMM were not properly protected by their templates. That oversight was corrected by the fixInnerObjTemplate amendment.

An audit showed that there were additional inner objects that did not have their templates applied. This pull request applies templates to those additional inner objects.

Adds a unit test for applying the template to sfMajorities. Other remaining inner objects showed no problems having templates applied.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Tests (unit tests were added for the templates added to Amendments)
  • Amendment.

Apply inner object templates to all remaining (non-AMM)
inner objects.

Adds a unit test for applying the template to sfMajorities.
Other remaining inner objects showed no problems having
templates applied.
@scottschurr scottschurr added Bug Amendment Perf impact not expected Change is not expected to improve nor harm performance. labels Jun 14, 2024
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.

Project coverage is 71.3%. Comparing base (ef02893) to head (80f0120).

Current head 80f0120 differs from pull request most recent head c6a0802

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

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5047     +/-   ##
=========================================
- Coverage     71.3%   71.3%   -0.0%     
=========================================
  Files          796     796             
  Lines        66987   66902     -85     
  Branches     10892   10866     -26     
=========================================
- Hits         47793   47703     -90     
- Misses       19194   19199      +5     
Files Coverage Δ
src/ripple/app/ledger/Ledger.cpp 75.4% <100.0%> (ø)
src/ripple/app/misc/impl/AMMUtils.cpp 99.4% <100.0%> (ø)
src/ripple/app/tx/impl/AMMVote.cpp 96.0% <100.0%> (ø)
src/ripple/app/tx/impl/SetSignerList.cpp 91.2% <100.0%> (ø)
src/ripple/protocol/Feature.h 100.0% <ø> (ø)
src/ripple/protocol/STObject.h 92.4% <ø> (ø)
src/ripple/protocol/impl/Feature.cpp 94.6% <ø> (ø)
src/ripple/protocol/impl/STObject.cpp 85.3% <100.0%> (ø)
src/ripple/rpc/impl/TransactionSign.cpp 88.2% <100.0%> (ø)
src/ripple/app/tx/impl/Change.cpp 68.5% <75.0%> (ø)
... and 1 more

... and 1581 files with indirect coverage changes

Impacted file tree graph


// The if is complicated because inner object templates were added in
// two phases:
// 1. If there are no available Rules, then always apply the template.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should the template be applied if there is no Rules?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregtatcam, great question.

The way getCurrentTransactionRules() works is:

  1. If we're currently inside a transaction then the Rules are set and available.
  2. If this code is ever called when we're not inside a transaction, then the optional is unseated.

This means that if the optional is unseated then we're not inside a transaction, and any changes we make will not be transaction breaking. We have two choices we could make at this point:

  1. If we're not inside a transaction, stick with the old behavior.
  2. If we're not inside a transaction apply the new behavior.

In my opinion the new behavior (apply the template) is strictly safer than the old behavior (don't apply the template). So I'm choosing to bias the change to honor safety.

Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification. Applying the new behavior sounds right to me. One argument to use the new behavior is when a unit-test doesn't call a transaction but does call a function with this amendment, for instance some utility. We want to make sure that the unit-test fails in this case if there is a difference in before/after.

Copy link
Collaborator

@gregtatcam gregtatcam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

Copy link
Collaborator

@seelabs seelabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

std::optional<Rules> const& rules = getCurrentTransactionRules();
bool const isAMMObj = name == sfAuctionSlot || name == sfVoteEntry;
if (!rules || (rules->enabled(fixInnerObjTemplate) && isAMMObj) ||
(rules->enabled(fixInnerObjTemplate2) && !isAMMObj))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was my only concern. Usually, when we introduce an amendment I want code where it's trivially clear that the code with the amendment switched off is not transaction breaking. That's not true here. I understand why it's not true, but that means we need to audit the old code to make sure all the old existing calls to makeInnerObject are for auction slots or vote entries.

I took a look at the old code and that does appear to be true. No action needed on this comment, I just wanted to add a note that I did that audit in case anyone wants to dummy check me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of code also got my attention and I did review the old existing calls to makeInnerObject to make sure it looked right.

@scottschurr
Copy link
Collaborator Author

Thanks for the reviews! This PR needs to go through the physical restructure re-mapping process before it can be merged. So I'll do the remapping soon. Once that is done I'll mark the PR as passed.

@scottschurr
Copy link
Collaborator Author

The physical restructure is done. Unit tests, start, sync, and graceful stop all work on my Mac for both debug and release builds. The CI problem with coverage looks like a host thing. I'm marking this pull request passed.

@scottschurr scottschurr added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Jun 26, 2024
@zrayn zrayn merged commit 9fec615 into XRPLF:develop Jun 27, 2024
16 of 17 checks passed
ximinez added a commit to ximinez/rippled that referenced this pull request Jul 1, 2024
* 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)
  ...
@scottschurr scottschurr deleted the apply-more-innerobj-templ branch July 5, 2024 20:44
@ximinez ximinez mentioned this pull request Jul 31, 2024
1 task
vlntb pushed a commit to vlntb/rippled that referenced this pull request Aug 23, 2024
* fixInnerObjTemplate2 amendment:

Apply inner object templates to all remaining (non-AMM)
inner objects.

Adds a unit test for applying the template to sfMajorities.
Other remaining inner objects showed no problems having
templates applied.

* Move CMake directory

* Rearrange sources

* Rewrite includes

* Recompute loops

---------

Co-authored-by: Pretty Printer <cpp@ripple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Amendment Bug Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. Perf impact not expected Change is not expected to improve nor harm performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants