-
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
move tfClawTwoAssets check to preflight #5201
Conversation
1b5a31d
to
3356b25
Compare
0083a15
to
12e9eee
Compare
12e9eee
to
62c6e0b
Compare
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.
LGTM
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #5201 +/- ##
=======================================
Coverage 77.9% 77.9%
=======================================
Files 784 784
Lines 66680 66681 +1
Branches 8138 8140 +2
=======================================
+ Hits 51942 51948 +6
+ Misses 14738 14733 -5
|
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.
Although changing to temMALFORMED
works, I personally prefer using temINVALID_FLAG
since it gives clearer message to the client on which part of the transaction might be wrong. However I don't see this as a blocker so you could decide at your discretion.
JLOG(ctx.j.trace()) | ||
<< "AMMClawback: tfClawTwoAssets can only be enabled when two " | ||
"assets in the AMM pool are both issued by the issuer"; | ||
return temMALFORMED; |
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.
Could maybe consider to return temINVALID_FLAG
maybe?
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.
It should be temMALFORMED. The flag is valid but the issuer is not the same.
I used temINVALID_FLAG
in my first commit, @gregtatcam adviced to change from temINVALID_FLAG
to temMALFORMED
.
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.
This is what the requestor of this issue suggested. I'm fine with temINVALID_FLAG
. How about temBAD_ISSUER
? After all this is what it's pretty much is.
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.
But if we change this to temBAD_ISSUER
then I think we should change to the same error this check
if (asset.account != issuer)
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 have to disagree here. We really should get away from using what I've been calling "redundant" error codes. tem
means malformed, so temMALFORMED
means "malformed malformed". (And before anyone points it out, I know it's used in a ton of places in the existing code, but that doesn't mean it's correct here.) This is especially true when there are other good options that already exist.
temINVALID_FLAG
has already been mentioned. It makes sense because you're not allowed to use that flag when the AMM has assets from two different issuers. One way to look at it is thattfClawTwoAssets
is a flag defined for a very specific special case - when the AMM has two different assets from the same issuer and the issuer wants to get both of them, instead of the default behavior of just one. Thus, it is invalid to use the flag when the issuers are different.- The two assets are properties of the AMM. They're not going to change. If the AMM was created with assets from two different issuers, then there is nothing you can change about the transaction to work with that AMM and use
tfClawTwoAssets
.
- The two assets are properties of the AMM. They're not going to change. If the AMM was created with assets from two different issuers, then there is nothing you can change about the transaction to work with that AMM and use
temBAD_AMM_TOKENS
could be considered, though the error message would need to be updated. The transaction can't be processed with the given flags because the tokens are not compatible with it.temBAD_ISSUER
is another option. The flag can not be used with the issuer ofasset2
.temINVALID_ACCOUNT_ID
is a stretch, but it could be considered invalid to specify that anasset2
account ID that is not the same asasset
.
Of these four options, though, I think temINVALID_FLAG
is the best, and is better than temMALFORMED
because at least it communicates some information about the problem.
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.
OK. Since everyone agrees on temINVALID_FLAG
, I changed the return error to temINVALID_FLAG
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.
@gregtatcam From my perspective, the flag can only be set if the issuer of the two assets are the same. So the flag would be considered as "invalid" if the issuers are different. I believe I did something similar in MPTokenIssuanceSet, where I returned temINVALID_FLAG
if both flags are set. I don't believe there is a written rule that says we can only return this error code when the flag mask is invalid.
And we may not want to introduce additional error codes like temBAD_ISSUER
since there is an upper limit to the total number of err codes.
Just my 2 cents
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.
Sounds good.
temBAD_ISSUER
is an existing error.
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.
Thanks for bearing the suggestions! :)
@ximinez Pipeline failed with some unit test errors, but it's transient because the error is |
Move tfClawTwoAssets check to preflight and return error temINVALID_FLAG --------- Co-authored-by: yinyiqian1 <yqian@ripple.com>
75e4ead
to
b54d85d
Compare
High Level Overview of Change
Context of Change
Type of Change
.gitignore
, formatting, dropping support for older tooling)API Impact
libxrpl
change (any change that may affectlibxrpl
or dependents oflibxrpl
)