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

Move past multiple orders in Filling state #1775

Merged
merged 7 commits into from
Jan 3, 2024
Merged

Conversation

luckysori
Copy link
Contributor

Fixes #1762.

Ultimately, it's still bad that we have no way of linking an order that is in Filling to a particular subchannel update. With such information we would be able to more confidently discard irrelevant orders and continue with the only relevant one.

I considered other approaches, but I think this is the simplest.

@luckysori luckysori self-assigned this Jan 2, 2024
@luckysori luckysori force-pushed the fix/two-open-orders branch 2 times, most recently from 7282d5f to 8674eeb Compare January 3, 2024 03:58
I don't see any benefit in dumbing down this model for the frontend.
And it can create confusion when debugging issues.
If no new `Order`s can be submitted until the current `Order` in
`Filling` is either moved to `Filled` or `Failed`, we ensure that we
cannot have multiple `Order`s in `Filling` at the same time.

This is important because this was supposed to be an invariant which
we were not upholding.
The previous patch attempted to prevent the situation from happening,
but we have already encountered instances where this has happened.

To handle them, we choose to:

- Take the _oldest_ `Order` in `OrderState::Filling`, because it is
the one that was never resolved in the first place. This order is the
one most likely to match the unfinished update to the subchannel.

- Discard all other `Order`s in `OrderState::Filling`, because the
user should not have been able to create them anyway.
The function `order_failed` does some cleanup when an order could not
be filled. But if the DB does not know about this order for some
reason, there isn't really anything to clean up in terms of orders and
the rest of the cleanup should continue.
@luckysori luckysori changed the base branch from main to fix/broken-just-gen January 3, 2024 04:26
Base automatically changed from fix/broken-just-gen to main January 3, 2024 07:25
Copy link
Contributor

@bonomat bonomat left a comment

Choose a reason for hiding this comment

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

I think this is a fair approach. Once we move to dlc-channels we can rethink this though.

@luckysori luckysori added this pull request to the merge queue Jan 3, 2024
Merged via the queue into main with commit 115aa5e Jan 3, 2024
9 checks passed
@luckysori luckysori deleted the fix/two-open-orders branch January 3, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More than one order is being filled at the same time, this should not happen
2 participants