Commit Graph

136 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
92da6b1d44
multi: fix linter warnings with updated linter 2023-08-22 16:34:47 -07:00
Olaoluwa Osuntokun
3f8d33d7ab
funding: add SIMPLE_TAPROOT case to TestCommitmentTypeFundmaxSanityCheck 2023-08-22 16:34:36 -07:00
Olaoluwa Osuntokun
384b1b1c12
feature: use +100 staging bit for taproot channels
In this commit, we carry out a new notion introduced during a recent
spec meeting to use a feature bit plus 100 before the feature has been
finalized in the spec.

We split into the Final and Staging bits.
2023-08-22 16:34:28 -07:00
Olaoluwa Osuntokun
dd05dd55d4
funding: add explicit chan type support for zeroconf+scid+taproot
We also remove the old implicit negotiation as well, as we'll be
updating tests to use explciit when required.
2023-08-22 16:34:20 -07:00
Olaoluwa Osuntokun
d98136e850
funding: add support for implicit negotiation for taproot chans
Otherwise, in the itests (which are mainly based on implicit
negotiation), we won't try to open taproot chans when we actually need
to.

We may want to revisit this however, since it may lock in parties trying
to use the defaults that aren't currently setting the explicit commit
type during funding.
2023-08-22 16:33:52 -07:00
Olaoluwa Osuntokun
9f6ed65d80
funding: add unit tests for reg+zero conf taproot chans 2023-08-22 16:32:27 -07:00
Olaoluwa Osuntokun
7d7513aa3c
routing+funding: add new makeFundingScript to support reg and taproot channels
In this commit, we start to set _internally_ a new feature bit in the
channel announcements we generate. As these taproot channels can only be
unadvertised, this will never actually leak to the public network. The
funding manager will then set this field to allow the router to properly
validate these channels.
2023-08-22 16:32:10 -07:00
Olaoluwa Osuntokun
15978a8691
funding+peer: add support for new musig2 channel funding flow
In this commit, we add support for the new musig2 channel funding flow.
This flow is identical to the existing flow, but not both sides need to
exchange local nonces up front, and then signatures sent are now partial
signatures instead of regular signatures.

The funding manager also gains some new state of the local nonces it
needs to generate in order to send the funding locked message, and also
process the funding locked message from the remote party.

In order to allow the funding manger to generate the nonces that need to
be applied to each channel, then AddNewChannel method has been modified
to accept a set of options that the peer will then use to bind the
nonces to a new channel.
2023-08-22 16:32:07 -07:00
Olaoluwa Osuntokun
a8416300dd
funding: update explicitNegotiateCommitmentType to recognize taproot chans 2023-08-22 16:32:05 -07:00
yyforyongyu
6820b08b53
funding: put assertNoFwdingPolicy in wait.NoError 2023-08-22 11:10:15 +08:00
yyforyongyu
0a6b05d2de
funding: catching barrier signal in receivedChannelReady
There is a race condition,
- goroutine_1: performing `stateStep` under `channelReadySent`. Once
  `receivedChannelReady` returns true, it will mark the channel state as
  `addedToRouterGraph`, which will delete the initial forwarding policy
  for private channels.
- goroutine_2: performing `handleChannelReady`, which processes the
  remote's channelReady message. It will ask brontide to `AddNewChannel`
  in the end.
- goroutine_3: performing `handleNewActiveChannel` in brontide, which
  will query the initial forwarding policy and fail to find it because
  it's already deleted in goroutine_1.

To fix it, we require `receivedChannelReady` to also check that the
channel's barrier signal in the map `handleChannelReadyBarriers` doesn't
exist, as this signal is removed once `handleChannelReady` finishes
adding the channel in brontide.
2023-08-22 09:52:49 +08:00
yyforyongyu
32d8208272
funding: add new method handleChannelReadyReceived
This commit is a pure code move. We add a new method
`handleChannelReadyReceived` to handle the channel's state change after
the remote's channel ready message is received.
2023-08-22 09:52:46 +08:00
yyforyongyu
d9e0464929
funding: defer initial forwarding policy deletion
This commit moves the deletion of the initial forwarding policy to the
end of `stateStep` to make sure the router has persisted it to disk
before the deletion.
2023-08-22 08:21:53 +08:00
yyforyongyu
38b106ccf3
funding: rename channelReady to channelReadySent for clarity 2023-08-22 07:04:17 +08:00
Oliver Gugger
d822d75f00
server+funding: remove previous link update mechanism
Because we now send the correct initial forwarding policy to Brontide,
the correct initial values are inserted into the link and we no longer
need to update the link in a later step.
2023-08-22 06:22:34 +08:00
Oliver Gugger
7ac445caaf
funding: make sure initial policy is always set 2023-08-22 06:22:34 +08:00
Oliver Gugger
d5c504c8de
multi: use fwding policy from models pkg 2023-08-22 06:22:33 +08:00
Oliver Gugger
59b5fb1565
channeldb+funding: move policy encoding into channel DB 2023-08-22 06:22:33 +08:00
Oliver Gugger
36fcf65e97
funding+channeldb: rename fwding -> forwarding 2023-08-18 09:44:23 +02:00
Oliver Gugger
4770cb0aaf
manager: also store initial time lock delta and HTLC settings
This will allow us to also set the TimeLockDelta and HTLC settings
when creating the channel. We leave the actual implementation of
the RPC and CLI changes to another PR, this is just to make
things more consistent.
2023-08-18 09:44:06 +02:00
Oliver Gugger
5b9aa63cec
funding: extract defaultForwardingPolicy 2023-08-18 09:44:06 +02:00
Oliver Gugger
665179ece2
funding+server: don't use wallet DB for channel operations
Since the actual wallet backends might be different between the wallet
DB and the actual channel state DB, we pass in the correct struct to the
funding manager.
2023-08-18 09:44:05 +02:00
Olaoluwa Osuntokun
c6a68d193c
Merge pull request #7177 from morehouse/fix_chantype_negotiation
funding: fix channel type negotiation bug
2023-08-14 17:15:52 -07:00
Matt Morehouse
e6a2167f38
funding: refactor negotiateCommitmentType
- use a switch instead of nested ifs to improve readability
- improve some variable names
- reword comments
2023-08-11 11:20:07 -05:00
yyforyongyu
0dd2aa0aef
multi: add itest to check race between channel_ready and update_add_htlc
This commit adds a new itest case to check the race condition found in
issue #7401. In order to control the funding manager's state, a new dev
config for the funding manager is introduced to specify a duration we
should hold before processing remote node's channel_ready message.

A new development config, `DevConfig` is introduced in `lncfg` and will
only have effect if built with flag `integration`. This can also be
extended for future integration tests if more dev-only flags are needed.
2023-08-09 01:29:19 +08:00
yyforyongyu
927572583b
multi: remove pending channel from Brontide when funding flow failed
This commit adds a new interface method, `RemovePendingChannel`, to be
used when the funding flow is failed after calling `AddPendingChannel`
such that the Brontide has the most up-to-date view of the active
channels.
2023-08-09 01:29:18 +08:00
yyforyongyu
3ed579d06f
funding: make failFundingFlow takes both channel IDs
This commit adds a new struct `chanIdentifier` which wraps the pending
channel ID and active channel ID. This struct is then used in
`failFundingFlow` so the channel ID can be access there.
2023-08-09 01:29:18 +08:00
yyforyongyu
e46bd8e177
multi: add AddPendingChannel to peer interface
The funding manager has been updated to use `AddPendingChannel`. Note
that we track the pending channel before it's confirmed as the peer may
have a block height in the future(from our view), thus they may start
operating in this channel before we consider it as fully open.

The mocked peers have been updated to implement the new interface method.
2023-08-09 00:17:22 +08:00
Slyghtning
47bcf7af69
funding: add all parameters to batch open channel 2023-07-26 09:49:22 +02:00
Slyghtning
e4f0e58214
lnd: handles selected outpoints in parseOpenChannelReq 2023-07-24 13:06:59 +02:00
Olaoluwa Osuntokun
86e7b4e1e0
Merge pull request #7794 from yyforyongyu/prepare-channel-ready-fix
brontide: refactor peer to prepare channel ready fix
2023-07-04 12:39:59 -07:00
yyforyongyu
a66d42c682
funding: use SyncMap to simplify map usage 2023-06-27 20:19:37 +08:00
ziggie
39f9673bc7
lnd: update defaultMaxLocalCSVDelay
Make sure our default local csv delay maximum is symetric
compared  to the remote default csv maximum.
2023-06-26 23:39:45 +02:00
Oliver Gugger
cf1f44ab10
Merge pull request #7689 from guggero/housekeeping
Housekeeping (fix small issues, take over stale contributor PRs)
2023-06-13 17:42:53 +02:00
Oliver Gugger
56dba2df03
multi: update linter, fix new issues 2023-06-13 11:58:33 +02:00
Maxwell Sayles
9dea695079 funding: make MaxWaitNumBlocksFundingConf public to be used to compute
`FundingExpiryBlocks`.
2023-06-12 10:04:04 -07:00
shaurya947
db44924c5a
lnwallet: add Memo to InitFundingReserveMsg
We also pass the value of Memo from funding/manager.go.
2023-05-18 13:02:30 -04:00
shaurya947
7c6faa4c98
funding: add Memo to InitFundingMsg struct
We add byte-array field called Memo to the InitFundingMsg struct.
We also provide a value for this from
rpcserver.go#parseOpenChannelReq().
2023-05-18 13:02:30 -04:00
Matt Morehouse
a8a50f32f5
funding: fix channel type negotiation bug
The bug manifests when a nil ChannelType is passed to the funding
manager in InitFundingMsg. A default value for ChannelType is selected
and sent in the OpenChannel message. However, a nil ChannelType is
stored in the reservation context. This causes our ChannelType checks in
handleFundingAccept to be bypassed.

Usually this makes us end up in the "peer unexpectedly sent explicit
ChannelType" case, where we can still recover by reselecting a default
ChannelType and verifying it matches the one the peer sent. But if the
peer sends a nil ChannelType, we miss it.

While fixing the bug, I also tried to simplify the negotiation logic, as
the complexity is likely what hid the bug in the first place.

Now negotiateCommitmentType only returns the ChannelType to be used in
OpenChannel/AcceptChannel and the CommitmentType to pass to the wallet.
It will even return a nil ChannelType when we're supposed to use implicit
negotiation, so we don't need to manually set it to nil for OpenChannel
and AcceptChannel.
2023-05-17 11:28:40 -05:00
Matt Morehouse
0ae9c63d64
funding: make expectsChanType a pointer
This allows us to expect chanType to be nil, which will be possible
after the next commit.
2023-05-17 11:27:41 -05:00
Matt Morehouse
34186dee19
funding: remove incorrect and repetitive comments
We don't actually do the logging described in the first comment, and the
second comment block repeats much of the first comment block.
2023-05-17 11:27:41 -05:00
Matt Morehouse
e59cd7f91d
funding: stop naming commit types chanType
negotiateCommitmentType returns both a chanType and a commitType, so it
is really confusing when the commitType is called chanType instead.
2023-05-17 11:27:41 -05:00
Matt Morehouse
ec85b5be72
funding: rename channelType parameter
This prevents us from confusing the channelType parameter with the
chanType local.
2023-05-17 11:27:41 -05:00
Oliver Gugger
8df4edef1b
Merge pull request #7624 from ellemouton/marshalBytesAndStringTxid
multi: populate both string and byte TXID in lnrpc.Outpoint
2023-05-08 17:32:54 +02:00
Carla Kirk-Cohen
3f9f0ea5d1
multi/refactor: separate methods for get and set node announcement
In preparation for a more complex function signature for set node
announcement, separate get and set so that readonly callers don't need
to handle the extra arguments.
2023-05-04 10:35:42 -04:00
Elle Mouton
ef17b12a86
funding: update "funding locked" in error string
Replace a few uncaught instances of "funding locked" found in error
strings with "channel_ready"
2023-04-27 20:03:44 +02:00
Elle Mouton
9ea3f55694
multi: update "funding locked" comments
Replace a few un-caught instances of "funding locked" in some comments
with "channel_ready"
2023-04-27 20:02:34 +02:00
Elle Mouton
7b186716a1
multi: populate both string and byte TXID in lnrpc.Outpoint
This commit adds a a new `MarshalOutPoint` helper in the `lnrpc` package
that can be used to convert a `wire.Outpoint` to an `lnrpc.Outpoint`.
By using this helper, we are less likely to forget to populate both the
string and byte form of the TXID.
2023-04-24 16:19:26 +02:00
Elle Mouton
784dc8d530
funding: use default fwding policy if persisted values not found
In this commit, a bug is fixed in the funding manager that could result
in the funding process erroring out if the persisted initial forwarding
policy is not found. This could occur if a node restarts after opening a
channel that is not yet fully confirmed and also upgrades their node
from a pre-0.16 version to 0.16 since the values are only expected to be
persisted after 0.16.
2023-04-19 11:51:32 +02:00
Oliver Gugger
af70af2710
funding+server: update switch after sending channel update
With this commit we give the funding manager the ability to inform the
switch about custom channel policies, right after we've announced the
channel to the network.
This change is necessary because before #6753 a channel could only be
opened with the default forwarding policies, so the switch automatically
had the "correct" default values. Since #6753 added the ability to
specify forwarding policies at channel open time, we announced those
policies to the network but never updated the switch to inform it about
the changed policies (previously changing the policies was only possible
through the UpdateChannelPolicy RPC which did call the switch).
2023-04-18 09:40:18 +02:00