Commit graph

16 commits

Author SHA1 Message Date
Oliver Gugger
986d889b74
multi: fix linter issues 2022-08-03 20:33:06 +02:00
positiveblue
ac3c44a966 sidecar: Init mailbox after server restarts
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.
2022-02-17 12:53:46 -08:00
Oliver Gugger
262eb198c5
multi: inform other side about ticket cancellation
To avoid the other side waiting for an update for a ticket that will
never come if it is canceled, we inform them instead.
2021-10-29 17:20:18 +02:00
Oliver Gugger
ceeb3b3f65
auto_sidecar: fix break within select
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.
2021-10-28 16:12:17 +02:00
Oliver Gugger
93b5e6a5c7
multi: fix formatting and comments 2021-09-29 15:15:24 +02:00
Olaoluwa Osuntokun
24d2f6127e
sidecar: add simple exponential back off for mailbox reads
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.
2021-06-25 14:59:11 -07:00
Olaoluwa Osuntokun
9a359dbc27 sidecar: clean up sidecar state for provider
When the provider gets a finalize for a matching ticket, then we'll try
to trigger the main state machine to exit.
2021-05-25 19:44:09 -07:00
Olaoluwa Osuntokun
67f01ec1b7 sidecar: on restart ensure recipient re-expects channel
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.
2021-05-25 19:13:11 -07:00
Olaoluwa Osuntokun
fbe1a10d9c
sidecar: add additional test case for message retransmission 2021-05-24 22:29:09 -07:00
Olaoluwa Osuntokun
3b4a2cdcb9
sidecar: maintain set of negotiators to ensure graceful shutdown
In this commit, we being to collect a map of all the negotiators so we
can ensure that if the main daemon needs to shutdown, then they do as
well.
2021-05-24 22:28:59 -07:00
Olaoluwa Osuntokun
026addd7cd
sidecar: add new method to allow negotiator to finalize ticket state 2021-05-24 22:28:57 -07:00
Olaoluwa Osuntokun
db646c5a49
sidecar: only simulate retransmission for provider if restarting from scratch
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.
2021-05-24 22:28:54 -07:00
Olaoluwa Osuntokun
36dbabd714
sidecar: add CurrentState() method to side car negotiator
This methods makes writing tests easier as the test context can
introspect into the negotiator's state.
2021-05-24 22:28:52 -07:00
Olaoluwa Osuntokun
2e99941389
sidecar: abstract automated negotiation into new struct
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.
2021-05-24 22:28:47 -07:00
Olaoluwa Osuntokun
3ca1be322e
sidecar: allow recipient ID to be derived using base offer ticket
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.
2021-05-24 22:28:44 -07:00
Olaoluwa Osuntokun
3e41af988e
sidecar: move sidecar logic to new file, properly handle retransmission
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.
2021-05-09 19:25:23 -07:00