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

add new max channel size config option #4567

Merged
merged 1 commit into from
Sep 15, 2020

Conversation

calvinrzachman
Copy link
Contributor

@calvinrzachman calvinrzachman commented Aug 25, 2020

  • let users specify their MAXIMUM WUMBO with new config option which sets the maximum channel size lnd will accept
  • current implementation is a simple check by the fundingManager rather than anything to do with the ChannelAcceptor
  • Add test cases which verify that maximum channel limit is respected for wumbo/non-wumbo channels
  • use --maxchansize 0 value to distinguish set/unset config. If user sets max value to 0 it will not do anything as 0 is currently used to indicate to the funding manager that the limit should not be enforced. This seems justifiable since --maxchansize=0 doesn't seem to make sense at first glance.
  • add integration test case to ensure that config parsing and validation is proper. I simplified the funding managers check electing to rely on config.go to correctly parse and set up either i) non wumbo default limit of 0.16 BTC OR ii) wumbo default soft limit of 10 BTC OR iii) a user specified max channel size

Addresses: #4557

Pull Request Checklist

  • If this is your first time contributing, we recommend you read the Code
    Contribution Guidelines
  • All changes are Go version 1.12 compliant
  • The code being submitted is commented according to Code Documentation and Commenting
  • For new code: Code is accompanied by tests which exercise both
    the positive and negative (error paths) conditions (if applicable)
  • For bug fixes: Code is accompanied by new tests which trigger
    the bug being fixed to prevent regressions
  • Any new logging statements use an appropriate subsystem and
    logging level
  • Code has been formatted with go fmt
  • Protobuf files (lnrpc/**/*.proto) have been formatted with
    make rpc-format and compiled with make rpc
  • For code and documentation: lines are wrapped at 80 characters
    (the tab character should be counted as 8 characters, not 4, as some IDEs do
    per default)
  • Running make check does not fail any tests
  • Running go vet does not report any issues
  • Running make lint does not report any new issues that did not
    already exist
  • All commits build properly and pass tests. Only in exceptional
    cases it can be justifiable to violate this condition. In that case, the
    reason should be stated in the commit message.
  • Commits have a logical structure according to Ideal Git Commit Structure

@Roasbeef Roasbeef added config Parameters/arguments/config file related issues/PRs enhancement Improvements to existing features / behaviour safety General label for issues/PRs related to the safety of using the software labels Aug 25, 2020
@Roasbeef Roasbeef added this to the 0.11.1 milestone Aug 25, 2020
@Roasbeef Roasbeef added funding Related to the opening of new channels with funding transactions on the blockchain v0.12 labels Aug 25, 2020
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.

Straightforward diff, thanks for the contribution! Only request is to add either a unit test at the funding manager, or extend an existing itest to exercise the code path.

@@ -1254,7 +1259,7 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
// We'll reject any request to create a channel that's above the
// current soft-limit for channel size, but only if we're rejecting all
// wumbo channel initiations.
if f.cfg.NoWumboChans && msg.FundingAmount > MaxFundingAmount {
if f.cfg.NoWumboChans && amt > MaxFundingAmount {
Copy link
Member

Choose a reason for hiding this comment

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

👍

@Roasbeef
Copy link
Member

NP on not using a channel acceptor, this is much simpler after all, in the future we may opt to roll it out into one, just so we can have all the logic coupled in a single place.

Should this configurable maximum be above the old soft-limit or should we permit any value? If above soft limit only, ensure that this setting does not override wumbo channel enablement (ie: don't impose a cap that is lower than the old limit)

What do you mean above the old soft limit? You mean like ensuring if wumbo isn't activated, then we don't allow this value to be set?

One other thing I think we should consider is adding a new default soft-limit if wumbo is activated. Just to make sure users are protected somewhat, and need to explicitly allow mega-wumbo channels.

config.go Outdated Show resolved Hide resolved
@calvinrzachman calvinrzachman force-pushed the max-wumbo branch 4 times, most recently from 2d76256 to a9ec4f0 Compare August 26, 2020 05:39
@calvinrzachman
Copy link
Contributor Author

calvinrzachman commented Aug 26, 2020

Hi @Roasbeef, thanks for the review. I was hoping to get the test case and validation added in before you made a first pass, but alas. I’ve added those in and made a couple changes.

Apologies for any confusion, here is where things are currently:

  • ANY explicit user setting of --maxchansize is respected (both for wumbo and non-wumbo).
  • For non-wumbo configurations this limit remains 16777215 satoshis by default as specified in BOLT-0002. NOTE: This is already enforced by this existing code.
  • For wumbo funding managers this limit is NOT enforced by default (currently indicated by zero value). We could modify this to impose a new new default soft-limit in the wumbo case as you mentioned.

Maybe there is a better way to do this than using a zero value. This breaks down should the user set --maxchansize=0 but perhaps it's okay since that is most certainly not a valid setting anyway. An alternative way to distinguish between the zero value and an unset value is with pointers.

One more thing: Right now I only enforce --maxchansize inside handleFundingOpen() which I believe is in response to an OpenChannel message from a peer. It makes sense to me to enforce this on channels created by user inside handleInitFundingMsg(). Let me know what you think and whether I took this in the wrong direction.

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.

Thanks for the PR, awesome change 👍

I agree that perhaps a soft-limit by default is preferred. If you opt into wumbo, then you should be able to open channels of any size you like, but IMO it should be a second opt-in to start accepting huuuge channels.

@calvinrzachman
Copy link
Contributor Author

At first a new larger default seemed to defeat the nature of WUMBO channels, but given that people will be entrusting their wealth to lnd, that's starting to sound like a better and better idea.

Any thoughts on what the new default maximum channel size should be?

@Roasbeef
Copy link
Member

Any thoughts on what the new default maximum channel size should be?

10 BTC?

@Roasbeef
Copy link
Member

If you opt into wumbo, then you should be able to open channels of any size you like, but IMO it should be a second opt-in to start accepting huuuge channels.

Yeh there's a distinction here:

  • pre wumbo .16 is the limit
  • post wumbo you can open any size you want
  • post wumbo there's a new default soft limit for accepting
  • post wumbo, users can modify the default acceptance max

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.

This PR is super close! IMO we want to have a default soft-limit for for wumbo chans in place. In the past, we threw around a value of 10 BTC which seemed reasonable at the time. This would only be for accepting the channels as mentioned.

We'd like to tag our v0.11.1 version in a few days here, and I think this is really close, so I'd like to get it in.

config.go Outdated Show resolved Hide resolved
config.go Outdated Show resolved Hide resolved
config.go Outdated Show resolved Hide resolved
fundingmanager.go Outdated Show resolved Hide resolved
@calvinrzachman calvinrzachman force-pushed the max-wumbo branch 2 times, most recently from 227d0a1 to a4646db Compare September 12, 2020 15:49
@calvinrzachman calvinrzachman changed the title WIP: add new max channel size config option add new max channel size config option Sep 12, 2020
@calvinrzachman
Copy link
Contributor Author

calvinrzachman commented Sep 12, 2020

Latest update contains enforcement for 10 BTC default wumbo limit. I elected to setup defaults in ValidateConfig() inside config.go and keep the simplest check I could think of in the Funding Manager. Since the funding manager now trusts only its config in determining the MaxChanSize, I added a new itest to verify that config.go handles explicit user setting of --maxchansize and both wumbo/non-wumbo defaults.

I agree this is close. One thing I am unsure on right now is whether my setting of the default limits will screw up the case where lnd is run with Litecoin. I will think on this a bit more and do my best to finish this PR off this weekend.

@Roasbeef
Copy link
Member

One thing I am unsure on right now is whether my setting of the default limits will screw up the case where lnd is run with Litecoin.

The default can always be overridden in that case. FWIW, the 0.16 number itself was very Bitcoin specific.

@Roasbeef
Copy link
Member

The latest set of changes is looking pretty good to me! Final thing is to either squashed down these commits into one, or update the title+body for each of the commits. As the change is relatively contained, I think maybe we can just squash them into one. Thanks again for working on this!

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 🧬

Changed looking good to me, final nit is just to squash into a single commit. Will test this out a bit locally and also wait on the other reviewer before merging.

- let users specify their MAXIMUM WUMBO with new config option which sets the maximum channel size lnd will accept
- current implementation is a simple check by the fundingManager rather than anything to do with the ChannelAcceptor
- Add test cases which verify that maximum channel limit is respected for wumbo/non-wumbo channels
- use --maxchansize 0 value to distinguish set/unset config. If user sets max value to 0 it will not do anything as 0 is currently used to indicate to the funding manager that the limit should not be enforced. This seems justifiable since --maxchansize=0 doesn't seem to make sense at first glance.
- add integration test case to ensure that config parsing and valiation is proper. I simplified the funding managers check electing to rely on config.go to correctly parse and set up either i) non wumbo default limit of 0.16 BTC OR ii) wumbo default soft limit of 10 BTC

Addresses: lightningnetwork#4557
@calvinrzachman
Copy link
Contributor Author

@Roasbeef Squashed ✅ Thanks for the guidance on the way through. It was fun to start learning the 2nd most important codebase in the world. I'll be on the lookout for another issue/PR soon.

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.

Thanks @calvinrzachman!! Very clean PR, LGTM 👌

@Roasbeef Roasbeef merged commit fa342a1 into lightningnetwork:master Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Parameters/arguments/config file related issues/PRs enhancement Improvements to existing features / behaviour funding Related to the opening of new channels with funding transactions on the blockchain safety General label for issues/PRs related to the safety of using the software v0.12
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants