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

sidecar channels 2/3: non-functional preparations for sidecar channels #242

Merged
merged 13 commits into from Apr 6, 2021

Conversation

guggero
Copy link
Member

@guggero guggero commented Apr 2, 2021

I realized that having a large PR that cannot be merged after review because of dependencies against the server is not ideal.
That's why I extracted all refactoring and other non-functional commits from #222 and #235 into this PR.

Because this adds no new user-facing functionality, the PR can be merged after successful review. Most of the commits have already been at least partially reviewed in #222.

I hope this makes the review flow a bit easier, even if it's done at a very late stage. If this makes it even more complicated, I apologize to the reviewers!

With this commit we add a first description and HOWTO about what sidecar
channels are and how they can be created.
We add this commit first to give any reviewer the full context about
what we're trying to achieve first.
For proper and safe channel acceptance the recipient node also needs to
know which key index it used for a ticket's multisig key so it can sign
the authentication flow with the auctioneer correctly (which takes a key
locator and not key descriptor).

To make the offer and sidecar contract more explicit, we also include
the lease duration in blocks in the offer part. This field will
overwrite any value set when using the CLI to submit the bid order.
Both the trader offering to buy a sidecar channel for another node as
well as the recipient node will need to store the involved sidecar
tickets in their local databases. We add a simple store interface and
its implementation that will be used in future commits.
For maximum re-usability of the signing/verifying code, we add them as
helper methods to the sidecar package itself.
With this commit we add the optional sidecar ticket to bid orders.
Because the node submitting the bid order doesn't necessarily need to be
the node creating the offer, we just store the ticket as is and don't
require it to be in the database already.
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.
The channel funding process for a sidecar channel will look different
from the normal process. To avoid too much code duplication, we first
extract the parts that remain the same into its own method.
We no longer need to hold a mutex since when we get to the
waitForChannelOpen method all previously spawned goroutines must have
completed.
To prepare for accepting sidecar channels where we don't have a real
order item in our local database, we use the order fetcher function in
the funding manager instead of the DB directly. That way we can pass in
fake bid orders during the sidecar acceptance.
As a preparation to reuse that code in the sidecar acceptor, we extract
it into its own function.
As a preparation to add non-exported fields to the funding manager, we
want to create a NewManager function that takes a config instead of
instantiating the manager directly.
As a preparation to be able to serve the pending channel updates from
lnd to multiple internal subscribers, we move the handling of those
events to the funding manager itself.
As a preparation for allowing multiple managers to consume the pending
channel updates, we move those events from a single channel to a
subscribe.Server construct.
We also pass in the subscription client to use into waitForChannelOpen
so we can use a different one in different flows.
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🐅

// for every account as soon as it's confirmed open. This method will
// return as soon as the authentication was successful. Messages sent
// from the server can then be received on the FromServerChan channel.
StartAccountSubscription(context.Context, *keychain.KeyDescriptor) error
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@halseth halseth merged commit e480bba into master Apr 6, 2021
@guggero guggero deleted the sidecar-prepare-refactor branch April 6, 2021 11:36
positiveblue pushed a commit to positiveblue/pool that referenced this pull request Oct 11, 2022
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.

None yet

3 participants