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

fix amendment: flag check for credentials #5250

Merged
merged 6 commits into from
Feb 10, 2025
Merged

Conversation

oleks-rip
Copy link
Collaborator

@oleks-rip oleks-rip commented Jan 17, 2025

High Level Overview of Change

Add transaction flag checking functionality for Credentials

Context of Change

CredentialCreate / CredentialAccept / CredentialDelete transactions will check sfFlags field in preflight()

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.2%. Comparing base (8103459) to head (80e9e62).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #5250   +/-   ##
=======================================
  Coverage     78.1%   78.2%           
=======================================
  Files          790     790           
  Lines        67622   67638   +16     
  Branches      8163    8163           
=======================================
+ Hits         52844   52862   +18     
+ Misses       14778   14776    -2     
Files with missing lines Coverage Δ
include/xrpl/protocol/Feature.h 100.0% <ø> (ø)
src/xrpld/app/tx/detail/Credentials.cpp 96.9% <100.0%> (+0.2%) ⬆️
src/xrpld/app/tx/detail/SetSignerList.cpp 91.8% <100.0%> (+0.2%) ⬆️

... and 2 files with indirect coverage changes

Impacted file tree graph

include/xrpl/protocol/detail/features.macro Outdated Show resolved Hide resolved
src/test/app/Credentials_test.cpp Outdated Show resolved Hide resolved
include/xrpl/protocol/detail/features.macro Outdated Show resolved Hide resolved
@Bronek Bronek self-requested a review January 20, 2025 11:39
@dangell7
Copy link
Collaborator

The flag check is also missing on other transactions. Should we add the flag check to other transactions as well? I believe the other one is SignerListSet.

@Bronek
Copy link
Collaborator

Bronek commented Jan 20, 2025

@dangell7 makes sense, but it should be a different amendment (we do not want this amendment to be rejected by operators, because of compatibility anxiety)

@mvadari
Copy link
Collaborator

mvadari commented Jan 22, 2025

@dangell7 makes sense, but it should be a different amendment (we do not want this amendment to be rejected by operators, because of compatibility anxiety)

I disagree @Bronek - I think we should cover everything in one amendment.

@Bronek
Copy link
Collaborator

Bronek commented Jan 22, 2025

@dangell7 makes sense, but it should be a different amendment (we do not want this amendment to be rejected by operators, because of compatibility anxiety)

I disagree @Bronek - I think we should cover everything in one amendment.

Fair enough. I am not going to oppose strongly, just wary of scope creep.

@mvadari
Copy link
Collaborator

mvadari commented Jan 22, 2025

@dangell7 makes sense, but it should be a different amendment (we do not want this amendment to be rejected by operators, because of compatibility anxiety)

I disagree @Bronek - I think we should cover everything in one amendment.

Fair enough. I am not going to oppose strongly, just wary of scope creep.

My concern is about amendment count creep - needing a separate amendment just to add one additional check feels kind of dumb. Agree that scope creep is a concern, but IMO this slight scope creep is fine (and I wouldn't want to expand it further).

@ximinez ximinez dismissed their stale review January 23, 2025 00:20

New name is good. I have not done a full review, so I'm not going to approve. Since my issue has been addressed, I'm just going to dismiss my review.

@oleks-rip oleks-rip force-pushed the cred_fix branch 3 times, most recently from b882a6e to 8c8a262 Compare January 23, 2025 20:26
@Bronek Bronek self-requested a review January 23, 2025 21:06
@@ -29,6 +29,8 @@
// If you add an amendment here, then do not forget to increment `numFeatures`
// in include/xrpl/protocol/Feature.h.

// Check flags in Credential transactions
XRPL_FIX (TransactionFlags, Supported::yes, VoteBehavior::DefaultNo)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
XRPL_FIX (TransactionFlags, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (InvalidFlags, Supported::yes, VoteBehavior::DefaultNo)

Something like this maybe? So it's clearer what's being fixed

Copy link
Collaborator Author

@oleks-rip oleks-rip Jan 24, 2025

Choose a reason for hiding this comment

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

Not so clear - it feels like we testing flag values themselves if they are valid or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, so you're now actually erroring for invalid flags.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not exact. One case - Transaction can fail with valid flag, which not processing by it, that's what we are testing.
And another case when someone can create flag value that is not acceptable as a single flag. For example binary value 011. Or value that is already occupied.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm thinking from the perspective of someone who sees fixTransactionFlags by itself and doesn't look into the code (which will be the vast majority of people). That's confusing to me. vs fixInvalidFlags is clearer to me about what it's fixing - flags that are invalid are being handled properly now.

Copy link
Collaborator Author

@oleks-rip oleks-rip Jan 31, 2025

Choose a reason for hiding this comment

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

Exact the same reason, but opposite conclusion for me :-) fixInvalidFlags is dedicated to flags type/values checks, and fixTransactionFlags directly point that it has something to do with flags in transactions

Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we combine them? fixInvalidTxFlags

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think "fix invalid" is a bit overkill phrase. Fixing something is implying that it is invalid/incorrect/wrong. So fixInvalidFlags is equal to fixFlags by its meaning. Which is less informative than fixTransactionFlags.

Choose a reason for hiding this comment

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

For the community I think I would err on the side of over kill and go with fixInvalidTxFlags

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

@oleks-rip
Copy link
Collaborator Author

oleks-rip commented Jan 24, 2025

@Bronek @mvadari there is also Change transaction which doesn't check for flag combination (but use some of them). But this tx is not so common, it doesn't documented on the SITE and I didn't found it usage. Do you know more about it and should it check for flags or not?

@Bronek
Copy link
Collaborator

Bronek commented Jan 27, 2025

@Bronek @mvadari there is also Change transaction which doesn't check for flag combination (but use some of them). But this tx is not so common, it doesn't documented on the SITE and I didn't found it usage. Do you know more about it and should it check for flags or not?

It is a pseudo-transaction, responsible for all of:

using EnableAmendment = Change;
using SetFee = Change;
using UNLModify = Change;

I agree we should enforce its flags, and since this PR has mutated to enforcing flags perhaps it is also the right place to add enforcement to this PR.

There is a caveat: the enforcement of flags (as seen in this PR) is subject to amendment voting, and this Change transaction, as seen above, is a key part of the amendment voting process, so we could potentially break amendment voting by voting this change in. Would be good to have a 3rd opinion here, maybe @JoelKatz can comment.

@ximinez
Copy link
Collaborator

ximinez commented Jan 27, 2025

I agree we should enforce its flags, and since this PR has mutated to enforcing flags perhaps it is also the right place to add enforcement to this PR.

There is a caveat: the enforcement of flags (as seen in this PR) is subject to amendment voting, and this Change transaction, as seen above, is a key part of the amendment voting process, so we could potentially break amendment voting by voting this change in. Would be good to have a 3rd opinion here, maybe @JoelKatz can comment.

It wouldn't hurt to add the check, as long as it's gated by the amendment. Technically, amendments are not active until the ledger after the EnableAmendment is processed.

However, it's probably not necessary, because there are only two ways a node is ever going to process a pseudo-transaction:

  1. It generates it itself.
  2. It is in the proposed transaction set from a majority of the UNL. Each of the UNL nodes are going to generate the transaction itself.

In other words, user input is never going to result in a valid pseudo-transaction, so they are much less likely to have invalid flags.

Conclusion: It may not be necessary, but it wouldn't hurt.

@oleks-rip oleks-rip force-pushed the cred_fix branch 3 times, most recently from 526b7f8 to 185a1d7 Compare January 28, 2025 18:18
@oleks-rip
Copy link
Collaborator Author

Conclusion: It may not be necessary, but it wouldn't hurt.

So better skip it to not to introduce some hidden bug

@mvadari mvadari changed the title RXI-1397 flag check for credentials fix amendment: flag check for credentials Jan 29, 2025
@mvadari mvadari added Bug Tech Debt Non-urgent improvements Amendment labels Jan 29, 2025
@oleks-rip oleks-rip force-pushed the cred_fix branch 3 times, most recently from 0e2bbc5 to 6b325d9 Compare February 5, 2025 22:28
@oleks-rip oleks-rip added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Feb 10, 2025
@oleks-rip
Copy link
Collaborator Author

ready to merge

@bthomee bthomee merged commit fa5a854 into XRPLF:develop Feb 10, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Amendment Bug Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. Tech Debt Non-urgent improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants