-
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
Add featureImmediateOfferKilled for tfImmediateOrCancel offers: #4157
Conversation
26 lines, including tests? Now that's impressive work. I know that keeping it simple is harder than it looks, and usually involves unseen work that's discarded on the way. So, thanks for the elegant solution. |
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.
Nice job on this. LGTM 👍
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.
Veto. @scottschurr: this breaks the "Immediate or Cancel" semantics. See comment below.
// ImmediateOrCancel offer that transfers absolutely no funds | ||
// returns tecKILLED rather than tesSUCCESS. Motivation for the | ||
// change is here: https://github.com/ripple/rippled/issues/4115 | ||
return {tecKILLED, false}; |
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 broken: it basically changes the semantics of Immediate or Cancel
to be those of Fill or Kill
.
A "Fill or Kill" order means: "if the offer can't be entirely filled by crossing against existing offers, abort. Never place an order on the order book."
An "Immediate or Cancel" order, on the other hand, means: "fill as much as you can by crossing against existing offers. If the offer isn't fully filled, that's fine, cancel the rest and never put an offer on the book."
So returning false
from here is a bug. It should return true
because you want to apply the executed crossings, but you don't want to go any further (i.e. to place the offer on the book).
Given the difference between FoK and IoC, I think that tecKILLED
is the wrong error code here; it should be tecPARTIALLY_FILLED
or somesuch.
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.
@nbougais, are you sure this is broken? Note the check for !crossed
in the conditional. So we should return {tecKILLED, false}
only in the case where no funds are transferred. If any funds were transferred, then we continue to return {tesSUCCESS, true}
as before. At least that's what I read crossed
as representing.
What am I missing?
Rebased to 1.9.2. |
aa3786b
to
09b681e
Compare
High Level Overview of Change
Fixes #4115
Context of Change
@mDuo13 noted:
The approach taken to this fix reuses the
tecKILLED
code. I hesitated on this because the descriptive text associated withtecKILLED
needs to change when applied in this new context. And that description change could not easily be protected by the amendment. However @mDuo13 pointed out:So this gave us the leash to make make the change minimally invasive. Even though, admittedly, it requires an amendment.
For me, the strongest motivation for this change is as follows (also from @mDuo13):
Type of Change
Before / After
Before: an
OfferCreate
transaction with thetfImmediateOrCancel
flag set that causes no funds to move returnstesSUCCESS
.After: an
OfferCreate
transaction with thetfImmediateOrCancel
flag set that causes no funds to move returnstecKILLED
.