Whenever we are are unable to receive a sidecar packet in an auto
sidecar negotiator try to init its mailbox. This will allow us to
continue reading/writting in the mailbox in cases where the server
went down and came back.
This commit fixes an instance of a "break" keyword that didn't have the
desired effect (breaking out of the outer for loop).
This didn't lead to an endless loop just because of the break in the
error case a few lines above where we would leave the loop in case of an
invalid state transition.
In this commit, we fix an existing issue that would cause sidecar
negotiation to halt if either the server restarted, or if the main
connection was torn down. To address this, we add a simple abstraction
that implements stateful exponential back-off that'll wait for a period
of time before trying to read from the mailbox again.
Without this extra case on restart, the recipient would have an
unhandled state transition that would cause them to not expect the
channel as it should once the batch is finalized.
We only need to re-send the simulated retransmission message if we're
starting from scratch and haven't yet received the provider's message.
Otherwise, this will cause an unnecessary internal state transition.
In this commit, we extract the existing automated sidecar negotiation
functionality into a new struct. This is strictly a refactoring change
intended to allow the core code to be more easily unit tested as all
interaction now behind a set of interfaces permitting greater
testability via mocks.
In this commit, we fix a bug in the retransmission case for the
provider. Before this commit, the provider would attempt to re-send the
initial offer ticket on restart if it hadn't yet received the registered
ticket. This fails as the recipient's stream ID is derived from their
pubkey information that's only contained in the registered ticket.
To fix this, we'll simply use the sha512 hash of the offer sig since
it's known when the ticket is initially created.
In this commit, we move most of the sidecar logic to a new file, and
also tweak each of the main state machines to be able to properly handle
retransmission events by both sides. When the provider restarts, it'll
send over a plain offered ticket, which'll prompt the receiver to
re-send their registered ticket. When the receiver restarts, it'll
re-send its registered ticket, which'll prompt the provider to re-send
their ordered ticket.