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

splicing: Adds the features needed to enable collaborative splicing & resizing of active channels. #5675

Closed
wants to merge 819 commits into from

Conversation

ddustin
Copy link
Collaborator

@ddustin ddustin commented Oct 25, 2022

Note this PR has been closed in favor of #6253

This PR is meant to add splicing to CoreLightning. Splicing enables the resizing of multiple channels in a single on-chain transaction, without any channels being "down" or closed during any part of the process. While enabling the resizing of multiple of your own channels -- splicing also gives your peers (and their peers, and their peers' peers, etc.) an opportunity to dynamically add channels as well.

Not only can participants add their own resizes, due to compatibility with @niftynei's dual funding feature, they can also add channel opens into the same batch. Eventually dual closing will allow all onchain lightning events to be batched into a single bitcoin transaction.

This will also, in time, enable wallets to implement "one balance" apps that allow users to send lightning & on-chain payments without needing to manage two "bitcoin balances" -- with the lowest fees possible.

The code implements splicing spec located here: lightning/bolts#863

My endless gratitude to @niftynei 🙏 who has helped an insane amount with planning, disagnosing, and literally writing parts of the code -- not sure I could have gotten this far without her. Thanks as well to @cdecker, @rustyrussell and everyone who helped me while working on this.

Here are the things I believe need to be done before the PR can be considered ready for a developer-only release

  • Refactor splice_init RPC to take a user's initial PSBT
  • Do byte ownership fee calculations
  • Enable signature ordering logic
  • Add splice commit sigs to inflight
  • Redo inflight process to cache a copy in channeld
  • Add BOLT messages with corresponding commit hashes
  • Change splice RPC to use channel_id instead of peer_id
  • Finish Collaborative transaction building #5287
  • Refactor this code to use Collaborative transaction building #5287
  • Refactor RPC to remove splice_finalized
  • Move wire updates to experimental patches
  • Add #if EXPERIMENTAL && DEVELOPER flags around code
  • Diagnose why the committed_splice_count check fails in handle_peer_commitsig
  • Update channel balance on splice_locked & save to DB
  • Load correct channel balance post splice_lock after restart
  • Test splicing a post-spliced channel
  • Check for TODO items in code
  • Correct balance checks for the l2 code path lisa gist. See check_balances
  • Reconnect logic

Copy link
Collaborator

@niftynei niftynei left a comment

Choose a reason for hiding this comment

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

biggest PR ever, but looking like a great splice_start.

Reviewed in-person w/ @ddustin, really really nice work!

lightningd/peer_htlcs.c Outdated Show resolved Hide resolved
common/psbt_internal.c Outdated Show resolved Hide resolved
hsmd/hsmd_wire.csv Show resolved Hide resolved
hsmd/libhsmd.c Outdated Show resolved Hide resolved
lightningd/channel_control.c Outdated Show resolved Hide resolved
lightningd/channel_control.c Outdated Show resolved Hide resolved
tests/test_splicing.py Outdated Show resolved Hide resolved
tests/test_splicing.py Outdated Show resolved Hide resolved
tests/test_splicing.py Outdated Show resolved Hide resolved
tests/test_splicing.py Outdated Show resolved Hide resolved
@niftynei
Copy link
Collaborator

niftynei commented Nov 3, 2022

Splice to the moon! 🚀 🌔

@ddustin ddustin force-pushed the ddustin/splice branch 2 times, most recently from 9ee496a to 8b0713a Compare November 23, 2022 13:10
@ddustin
Copy link
Collaborator Author

ddustin commented Dec 30, 2022

Forcing locktime to 0 until a spec conversation can happen: https://github.com/lightning/bolts/pull/863/files#r1059493624

@ddustin ddustin force-pushed the ddustin/splice branch 2 times, most recently from 81c2ab5 to e1e0fb6 Compare January 10, 2023 18:04
@ddustin ddustin mentioned this pull request Jan 18, 2023
71 tasks
@ddustin
Copy link
Collaborator Author

ddustin commented Jan 18, 2023

Forcing locktime to 0 until a spec conversation can happen: https://github.com/lightning/bolts/pull/863/files#r1059493624

Spec talk was to allow all locktimes in the spec and implementations can restrict which they'll accept as they decide (ie not too far in the future).

@piqjen-1xofFi-sikxyh
Copy link

🚀

@ddustin ddustin marked this pull request as ready for review March 6, 2023 00:18
@ddustin ddustin requested a review from cdecker as a code owner March 6, 2023 00:18
@ddustin ddustin force-pushed the ddustin/splice branch 15 times, most recently from 625e737 to d1aceb3 Compare March 6, 2023 14:28
rustyrussell and others added 23 commits May 11, 2023 20:20
…-block.

Turns out this was accidentally changed for v0.10.1 in
d8e6889 where we made fee levels less
aggressive.

Oops.  I guess we can fix the docs.  And we now have "2blocks" if you
want it really fast!

Closes: ElementsProject#6129
Changelog-Fixed: JSON-RPC: `feerates` document correctly that urgent means 6 blocks (not 2), and give better feerate examples.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Using the -n flag on echo is non-standard for zsh. printf ‘%s’ accomplishes the equivilent thing.

Changelog-Added: Small fix for Mac OS building
Update gossip routiens and various other hecks on the channel state to consider AWAITING_SPLICE to be routable and treated similar to CHANNELD_NORMAL.

Small updates to psbt interface

Changelog-None
Some fields weren’t intitialized causing complex crashes elsewhere.

Changelog-None
Update the lightningd <-> channeld interface with lots of new commands to needed to facilitate spicing.

Implement the channeld splicing protocol leveraging the interactivetx protocol.

Implement lightningd’s channel_control to support channeld in its splicing efforts.

Changelog-Added: Added the features to enable splicing & resizing of active channels.
# Conflicts:
#	channeld/channeld.c
Switches implementation over to a signed relative amount instead of absolute splice result
Make HTLC balance enforcement aware of pending slice-out’s
Handle REMOTE vs LOCAL on view correctly
Implement channel reestablish for splicing
Fix shadow variable problem
Also convert everything to an array thingy
@ddustin ddustin closed this May 12, 2023
@ddustin ddustin deleted the ddustin/splice branch May 12, 2023 01:11
@ddustin
Copy link
Collaborator Author

ddustin commented May 12, 2023

Github inadvertently auto-closed this PR. It appears I don't have repo permissions to re-open it.

Could someone with admin privileges reopen it for me?

@ddustin
Copy link
Collaborator Author

ddustin commented May 12, 2023

Due to github's "force-close" I had to move this over to a new PR: #6253

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.