Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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(AMM): prevent orphaned objects, inconsistent ledger state: (updates XLS-30) #4626
fix(AMM): prevent orphaned objects, inconsistent ledger state: (updates XLS-30) #4626
Changes from 8 commits
da44bc8
5cead5b
eaef4b6
b28101f
cbd7144
40317c5
9cf3fd7
75af923
cd88481
9ddff74
2b1c8c6
c5e3c89
b63e696
2efa0f8
fa0d9c4
7e2c454
c07bb67
484e01f
cfa3201
a34d29b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
If the account root somehow doesn't exist, this is a log-worthy event but should the transaction be rolled back? If the account is missing we can still delete the AMM object... in fact we definitely should? The delete transactor should double as a "fix up" transactor. If an AMM ever gets into a bad state, somehow, then deleting it should repair the situation as much as possible.
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.
Counterpoint: If the account root doesn't exist, something has gone very, very wrong. Continuing with the deletion process may make things worse. Arguably, the ledger and transaction history should be examined manually to determine what happened and what's going on. The solution may require a fix amendment not just to clean up the ledger, but to prevent the issue from happening again.
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 would be an ungraceful failure mode. Half an AMM, if it happened, would probably crash the ledger or block an orderbook. You can't clean it up because of this pedantic check, even after restarting the whole network. Now you need to wait for an amendment and code update. You should seek to build graceful failure modes into production systems.
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.
If the ledger is corrupt, we're already in a failure mode. Better to stop than to continue in an state that may not be correct.
https://xrpl.org/intro-to-consensus.html#consensus-protocol-properties
If correctness is lost, then we do not want to make forward progress. This is not just me being stubborn, this is baked into the design of the ledger from the beginning.
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'm not sure this check is advisable in AMMDelete. If for some reason an illegal/invalid AMM was somehow created then we do want to let them delete it.
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 don't quite see how illegal/invalid AMM can be created. The validation in
AMMCreate
prevents this from happening and it's pretty much the same check. If we don't check it here then it's going to fail in preclaim validation because AMM for this asset pair can not exist. This check also gives a user a more informative message if currency or issuer are invalid or the tokens have the same currency/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.
It's defensive programming. If somehow the system is in a bad state, is there a graceful way to recover? The "somehow" is not important but for the sake of argument let's suppose a different (future) transactor malfunctioned and modified some part of the two AMM objects incorrectly.
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.
Minor nit: This error message seems "reversed" (it seems to mean "AMM is in empty state", whereas this check appears to check that it's not empty).
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's
tecAMM_NOT_EMPTY
in the latest commit.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.
should this code be tecAMM_NOT_EMPTY?