We were missing a few selects on the quit channel which could lead to us
making another iteration in the loop while the server stream was already
set to nil. We fix that by making sure we always return one way or
another if the quit channel is closed.
Just to make the panic impossible to happen again, we also return from
the loop early if the server stream is nil, just in case.
The new version of RPC structs contains an internal lock and therefore
they shouldn't be memory copied anymore. The linter fortunately picked
up on this and warned us, so we pass in the pointer here directly
instead.
It turns out that on startup the auctioneer can get overwhelmed if
hundreds of traders try to authenticate all at once. So some of them run
into a timeout (which sounds like it's the trader's fault but the
timeout covers the whole 3-way handshake and is actually delayed by the
server, not the client) which wasn't handled correctly.
We now inspect the correct error if the authentication fails and try
reconnecting.
In this commit, we add automated sidecar negotiation for the recipient.
We'll use the new expose mailbox system to communicate with the provider
of the ticket to incrementally transform and complete it.
We add a new state machine attached to the sidecar acceptor that drives
the sidecar ticket to completion. We have two main states to handle:
sending the ticket w/ our node's information to the provider, and then
waiting for the final ticket from the provider that contains the order
information.
rpc: add automated ticket negotiation for the sidecar provider
In this commit, we add automated ticket negotiation for the sidecar
provider. The provider's state machine is a bit more involved as it
needs to do more in order to finalize the ticket. It starts by making a
new stream, and waiting for the recipient to send over the sidecar
information with their node information. From there it submits the bid,
checkpoints the state, and then adds the bid information before sending
the ticket back to the recipient.
The local database can now store a sidecar ticket with a bid order. We
now also need to accept it on the local RPC interface and forward it to
the auctioneer.
The name SubscribeAccountUpdates could indicate that this is a
long-running operation. The method returns after successful
authentication of the stream though. That's why we rename it to
StartAccountSubscription and update the comment to make it more clear
that this should return after a few seconds at the most.
With the server now exposing this new RPC, we want to add the output of
it to the getinfo call to give users an idea what the current market
situation looks like.
This commit fixes a missing mutex lock in the SendAuctionMessage. To
make it possible to hold it there, we need to remove the deferred unlock
in connectAndAuthenticate into connectServerStream. Otherwise we'd run
into deadlocks.
Because the batch Versions are in the order package, the use of
order.DefaultVersion is confusing and not clear to be related to the
version of the _batch_, just from its name. We fix that by renaming the
versions of the batch.
This commit fixes a wrong assumption the recovery was implemented with.
The auctioneer will only switch to the closed state once the closing TX
confirms. We therefore shouldn't map this to pending closed as that'll
try to re-broadcast the close TX (which fails for confirmed
transactions).
If we detect we have a pending batch in the local database that was
replaced by a different transaction, we try to clean up funding shims
and pending channels on startup as well.
To allow that, we use the funding manager as the BatchCleaner
implementation.
To be able to fully clean up an old, pending batch snapshot on daemon
startup, we first need to switch to a method that returns the full
snapshot instead of just its ID.
Because the RelevantBatchSnapshot RPC didn't return the raw batch
transaction at all, traders with a pending batch crashed here. We don't
necessarily need to know anything other than the transaction bytes here
so we might as well call the other RPC.
This prevents traders from canceling an order that does not belong to
them. Previously, the order nonce was required, but this could be
learned from any trader by matching with it throughout batch execution.