Skip to content

Add option to set remote channel reservation in open channel#2708

Closed
roeierez wants to merge 5 commits intolightningnetwork:masterfrom
roeierez:configure_chan_reserve
Closed

Add option to set remote channel reservation in open channel#2708
roeierez wants to merge 5 commits intolightningnetwork:masterfrom
roeierez:configure_chan_reserve

Conversation

@roeierez
Copy link
Contributor

@roeierez roeierez commented Feb 26, 2019

This PR adds the option for a channel initiator to set the “channel_reserve_satoshis”, as defined in Bolt 2 for open_channel message.
Before this change, the field was fixed to 1% of the channel capacity (the recommended value in Bolt 2).
It seems reasonable to allow the channel initiator to change this value if it is willing to take the risk (or responsibility) of watching and monitoring the channel on-chain.
With the ability to dynamically set the channel reserve, nodes will be able to provide the other side better liquidity, enabling them to spend more funds

@roeierez roeierez force-pushed the configure_chan_reserve branch from 2bfa980 to be28948 Compare February 27, 2019 16:33
@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour rpc Related to the RPC interface funding Related to the opening of new channels with funding transactions on the blockchain cli Related to the command line interface P3 might get fixed, nice to have labels Mar 5, 2019
@roeierez
Copy link
Contributor Author

Do you think it worth scheduling this PR for 0.7.1 release now that the channel reserve fields are in the RPC interface (#3238)?

@halseth
Copy link
Contributor

halseth commented Jul 18, 2019

Can target for 0.8 possibly.

@roeierez
Copy link
Contributor Author

Can target for 0.8 possibly.

That would be great!

@cfromknecht cfromknecht added this to the 0.8 milestone Jul 23, 2019
@wpaulino
Copy link
Contributor

Needs a rebase.

@roeierez roeierez force-pushed the configure_chan_reserve branch from be28948 to a108889 Compare August 1, 2019 09:01
@roeierez roeierez force-pushed the configure_chan_reserve branch from a108889 to 6a368e6 Compare August 1, 2019 09:15
@roeierez
Copy link
Contributor Author

roeierez commented Aug 1, 2019

Rebased.

@Roasbeef Roasbeef removed their request for review August 7, 2019 02:28
@Roasbeef
Copy link
Member

Roasbeef commented Aug 7, 2019

With the ability to dynamically set the channel reserve

Likely just a choice of wording here, but isn't dynamic, even with this it would still be fixed. Also this isn't costless, by setting this value to zero or near zero (as I'm guessing you'd like to do), you introduce a costless attack for who ever you open a channel with.

@roeierez
Copy link
Contributor Author

roeierez commented Aug 7, 2019

Likely just a choice of wording here, but isn't dynamic

Agree. Removed the word dynamically.

you introduce a costless attack for who ever you open a channel with

Right. To me, though, it looks like it is a business decision that shouldn't be limited by the protocol itself. Default value may remain 1%, but it is up to the initiator to change the value based on its business model. For example, Bitrefill offers their users to buy channels. In this case, users already have skin in the game.

Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

looks pretty good on first pass!

Copy link
Contributor

Choose a reason for hiding this comment

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

if i'm reading this correctly, we'll only use the user chosen reserve if it is at least the our dust limit. it doesn't seem obvious that it would be ignored if the value is too low. should we check this sooner in the pipeline and return an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I have shifted the input validation code to rpcserver.go similar to the way other rpc fields are being validated: https://github.com/lightningnetwork/lnd/pull/2708/files#diff-01ada5680aaa18fc79cbf78b2d55a37bR1366

@roeierez roeierez force-pushed the configure_chan_reserve branch from 6a368e6 to 80e19f0 Compare August 8, 2019 08:33
@wpaulino wpaulino requested review from wpaulino and removed request for halseth August 12, 2019 23:54
Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

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

LGTM, though we should add some tests at the funding manager level with different values (valid and invalid).

server.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: move next to remoteCsvDelay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@roeierez
Copy link
Contributor Author

we should add some tests at the funding manager level with different values (valid and invalid)

Sounds good! I will work on that.

@roeierez roeierez force-pushed the configure_chan_reserve branch 2 times, most recently from 85e8436 to 61d109c Compare August 27, 2019 09:10
@roeierez
Copy link
Contributor Author

@wpaulino I added tests for:

  1. custom valid value.
  2. non valid value below dust.
  3. non valid value over capacity.

For the functionality to be testable I needed to add validation for the channel reserve inside the fundingmanager.go.
Although I didn't see other parameters validated there, I think it is good to have it there since there are other code flows that use the fundingmanager besides RPC interface.
Also rebased.

@halseth
Copy link
Contributor

halseth commented Sep 24, 2020

This is no longer blocked by anchor outputs, and can be rebased.

@Roasbeef Roasbeef added this to the 0.13.0 milestone Oct 1, 2020
@Roasbeef Roasbeef added abandoned up for grabs PRs which have been abandoned by their original authors and can be taken up by someone else labels Mar 23, 2021
@Roasbeef Roasbeef removed this from the 0.13.0 milestone Mar 23, 2021
This commit is the basis of enabling the intiator of a channel
to determine the amount of satoshis he requires the remote
peer to reserve as a direct payment in his side of the channel
As stated in Bolt 2.
This commit uses the "remote_chan_reserve_sat" field value that was
added to the OpenChannelRequest in the funding workflow.

Upon start of the workflow the handleInitFundingMsg code was changed
to take this value into account, save it in the pending channel
reservation and finally read the value when creating the  channel
constraints for the remote contribution in handleFundingAccept.
@roeierez roeierez force-pushed the configure_chan_reserve branch from 61d109c to f1a7479 Compare April 20, 2021 14:57
This commit adds the lncli support to configure the remote channel
reservation value.
This commit adds validation for channel reserve custom parameter in
the funding manager itself.
Since opening a channel is not done only from the RPC interface, this
validation makes sure callers won't pass a wrong value.
It also makes the channel reserve functionality testable.
@roeierez roeierez force-pushed the configure_chan_reserve branch 3 times, most recently from ea6e106 to cf4e796 Compare April 20, 2021 18:20
This commit adds three test cases for the remote channel reserve
parameter:
1. custom valid value.
2. non valid value bellow dust.
3. non valid value over capacity.
@roeierez roeierez force-pushed the configure_chan_reserve branch from cf4e796 to d9c3f5d Compare April 20, 2021 19:31
uint32 max_local_csv = 17;

// The number of satoshis we require the remote peer to reserve.
int64 remote_chan_reserve_sat = 18;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: make uint64?

localFundingAmt btcutil.Amount) error {

dustLimit := lnwallet.DefaultDustLimit()
if chanReserve > 0 && chanReserve < dustLimit {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: could omit the > 0 check if the proto type is unsigned.

if chanReserve == 0 {
chanReserve = f.cfg.RequiredRemoteChanReserve(capacity, ourDustLimit)
}
if chanReserve < ourDustLimit {
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have a similar check in CommitConstraints, though that doesn't check against the capacity.

case <-alice.msgChan:
t.Fatalf("init funding workflow should fail with invalid chan"+
"reserve %v", chanReserve)
case <-initReq.Err:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should assert on the expected error here.

@carlaKC
Copy link
Collaborator

carlaKC commented Jan 18, 2022

@roeierez still interested in getting this in? I can pick up review once its rebased.

@carlaKC carlaKC removed the request for review from cfromknecht January 18, 2022 07:05
@Bosch-0
Copy link

Bosch-0 commented May 26, 2022

Would be great to see this in LND. LDK recently merged in a similar feature: lightningdevkit/rust-lightning#1163

by setting this value to zero or near zero (as I'm guessing you'd like to do), you introduce a costless attack for who ever you open a channel with.

@Roasbeef you could also look at this in reverse if the channel opener had big trust issues with their partner they could increase the reserve so more is at stake. This would make sense if the local capacities of both parties differs substantially.

As @roeierez mentioned, this is more of a business feature (particularly for LSPs) but the default can stay at 1% and changes be opt-in only.

@lightninglabs-deploy
Copy link
Collaborator

@roeierez, remember to re-request review from reviewers when ready

@ellemouton
Copy link
Collaborator

@roeierez, Im gonna close this PR has it has been replaced by this one. I have kept you as commit author where it applies. Thanks again for the og pr!

@ellemouton ellemouton closed this Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command line interface enhancement Improvements to existing features / behaviour funding Related to the opening of new channels with funding transactions on the blockchain P3 might get fixed, nice to have rpc Related to the RPC interface up for grabs PRs which have been abandoned by their original authors and can be taken up by someone else v0.12

Projects

None yet

Development

Successfully merging this pull request may close these issues.

startup option for channel_reserve_satoshis (LND)

10 participants