Enable faster channel opening & deposit by parallelizing them and their confirmations #1128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, channel open & deposit can take a very long time, since they're called separatelly from userspace and needs to be processed serially, as deposit can only be done after channel state is in place.
But the information needed for deposit is available while opening the channel (when the respective txs are sent and mined), and therefore, we can parallelize these operations (and specially their confirmation) to minimize the time needed to open a channel.
So, this PR:
channelOpen.request
accept an optionaldeposit
paramtoken.approve
in parallel withopenChannel
channelId
and right away callsetTotalDeposit
with itchannelDeposit.failure
if it doesn't succeedopenChannel
method acceptsdeposit
, waits for the respective events, and notify users through anonChange
callbackWith this, open + deposit can complete and be confirmed as soon as N + 1 blocks, while the previous schema required
2 * (N + 1)
blocks, where N is the number of confirmation blocks.