-
Notifications
You must be signed in to change notification settings - Fork 102
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
auth,book,market,ws: Unbook MIA users orders after a timeout #725
Conversation
d1a4450
to
10f42f1
Compare
dc35eaa
to
dce114f
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.
Noticed while reviewing this should be proof.IsRevoked():
Line 594 in 33c531a
proof.RefundCoin, proof.Script, proof.IsRevoked) |
Not totally related but I can get an err log on the server by disconnecting during an epoch:
[ERR] AUTH: Send requested for unknown user f7d86c5fd3a442451e6390011b2744d766fadc2520f12307ff4983419c84fd8f
I don't know if it should be error level. Not important though.
Also not related. The placement here seems off. Should be 2 (1 preimage misses) I think:
[DBG] AUTH: User f7d86c5fd3a442451e6390011b2744d766fadc2520f12307ff4983419c84fd8f score = 1: 0 (violations) + 1 (2 preimage misses) - 1 (1 successes)
Warning after completed trade that seems out of place. It only happens if I make a match, restart the client, and continue as normal:
[INF] CORE: Retiring inactive order 1258dae19b956c2f32ab22355656a3aec3ea60ee61fbdeda16682dadd2cbe47e in status executed
[INF] CORE: Retiring inactive order cc672c57012abaaf5fbe1937de4f609a92f81fa1eb190b19fe2c0d4e19fb3392 in status executed
[WRN] CORE: Unable to return btc funding coins: cannot return zero coins
I can't find any problems with this pr however.
@JoeGruffins Good catches. The I've noticed the |
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.
Looks good on a first pass. I see you're preparing to solve #712 too.
7eebbb0
to
20c41ef
Compare
9982746
to
b86ee89
Compare
Back to draft while implementing revoke_order |
|
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.
A couple items you may choose to follow up on, but otherwise looking good and testing well.
AuthManager needs to know when wsLink is down
c7be0b9
to
50595cd
Compare
When a user disconnects with booked orders, this gives the user a certain time to reconnect before all of their orders across all markets get unbooked (revoked). This time is set to broadcast timeout.
dex/ws and server/comms
Create a
Done() <-chan struct{}
method so consumers like server/auth can actually know when the connection died. Previously, a ping timeout or a clean client-initiated disconnect could never make theAuthManager
aware of the connection status change.server/auth
Make AuthManager aware of underlying wsLink drops with the
(*wsLink).Done
method. When successful'connect'
request registers the user connection inaddClient
, it begins a goroutine waiting on the channel from Done, which then triggersremoveClient
.removeClient
creates an unbook timer for the user. If the user does not return by the time the timer fires, it unbooks their orders. If the user does return,addClient
stops the timer.Care is taken in
addClient
andremoveClient
to deal with reused links and new links for already-connected users. Reused links simply update theclientInfo
map entries. New links for already-connected users also disconnect the old link but prevent removing theclientInfo
entries in the new link.Create
UserUnbooker func(account.AccountID)
andMiaUserTimeout time.Duration
config fields and correspondingAuthManager
fields. The unbook function is called from the unbook timer created byremoveClient
.Add
(*AuthManager).ExpectUsers(users map[account.AccountID]struct{}, within time.Duration)
to be used afterAuthManager
construction and beforeRun
to specify a list of users with booked orders who are expected to connectwithin
a certain time or have their orders unbooked. Note that this list is not specified to the constructor since we are using the(*Market).Book
method as a convenience (and authoritative source) for booked orders and their owners, andMarket
requires theAuthManager
on construction. Neither subsystem is running at this point, so alternativelyNewMarket
could be provided a pointer to an uninitialized market that is subsequently set-up.dcrdex startup with 2 booked orders, dexc not running and thus not reconnecting:
dexc started up after the timeout:
server/market
Add
(*Market).UnbookUserOrders(user account.AccountID)
for unbooking all of a users orders. This uses the server/book changes described below to unbook the orders from the in-memory book, unlocks the funding coins, revokes the orders, and notifies orderbook subscribers.server/book
Add
(*Book).RemoveUserOrders
and(*Book).UserOrderTotals
.Add
(*OrderPQ).RemoveUserOrders(user account.AccountID) (removed []*order.LimitOrder)
and(*OrderPQ).UserOrderTotals(user account.AccountID) (amt, count uint64)
.Add a
userOrders map[account.AccountID]map[order.OrderID]*order.LimitOrder
toOrderPQ
to facilitate the new methods.server/coinlock
Add
(*AssetCoinLocker).UnlockOrdersCoins(oids []order.OrderID)
for batch unlocking of order coins.server/dex
Create the
userUnbookFun
dispatcher for theAuthManager.UserUnbooker
. This dispatcher calls the new(*Market).UnbookUserOrders
method for each market.