lnd icon indicating copy to clipboard operation
lnd copied to clipboard

Clarify misleading updatechanpolicy cli help

Open SachinMeier opened this issue 3 years ago • 10 comments
trafficstars

Change Description

Associated Issue: https://github.com/lightningnetwork/lnd/issues/1523

The updatechanpolicy cli command uses IntFlag and FloatFlag, which autopopulate a (default: 0) at the end of flag descriptions. These are unhelpful since we ignore flags that are not set by this command, and do not set them to zero.

Steps to Test

No lnd behavior should change. For lncli, no behavior outside of the help message for updatechanpolicy should change.

To test:

  • Run lnd with at least one channel.
  • Set fees to a specific non-zero rate using fee_rate flag.
  • Verify that fees were accurately set using the feereport command.
  • Set fees to zero by setting fee_rate to 0.0.
  • Verify that fees on that channel are now 0.
  • Set fees to non-zero rate using fee_rate_ppm flag.
  • Verify that fee rate updated using feereport command.
  • Set fees to zero by setting fee_rate_ppm to 0.
  • Verify that fees on that channel are now 0.

Pull Request Checklist

Testing

  • [ ] Your PR passes all CI checks.
  • [ ] Tests covering the positive and negative (error paths) are included.
  • [ ] Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

SachinMeier avatar Jul 23 '22 06:07 SachinMeier

Updated commit message, thanks!

SachinMeier avatar Jul 25 '22 06:07 SachinMeier

@yyforyongyu: review reminder @SachinMeier, remember to re-request review from reviewers when ready

Thank you. @C-Otto has an alternative MR to switch to v2 of the cli. @Roasbeef didn't seem to like that every arg is now a string, but in my opinion, this is the simplest way to get rid of inaccurate argument descriptions for all args, so I have not made any updates yet. If anyone has further suggestions, I am happy to go with another idea.

SachinMeier avatar Aug 08 '22 23:08 SachinMeier

Note that I recommend to NOT switch to v2, see the comments in my PR.

C-Otto avatar Aug 09 '22 19:08 C-Otto

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

lightninglabs-deploy avatar Sep 16 '22 13:09 lightninglabs-deploy

After receiving feedback from a few people, I still think the current changes would result in the simplest interface for CLI users, even if we are interpreting integer arguments as strings and then parsing integers internally. The other methods for removing the defaults added even more code, and I do not think this command should set any values implicitly if they were not specified explicitly.

SachinMeier avatar Sep 16 '22 17:09 SachinMeier

So the way I see it, we have two options here:

  1. Use string flags to get rid of the misleading (default: 0) suffix and do all integer parsing manually.
  2. Set the Value field for all fields to their default values lnd would use and then implement ctx.IsSet() for all of the optional flags to find out if the user wanted to set them or not (it IsSet() returns false, we'd set the value to 0 on the RPC to make sure we don't overwrite the value).

@Roasbeef, @yyforyongyu what's your opinion on this? Personally I like option 2, even if that is a bit more effort to implement.

guggero avatar Sep 22 '22 12:09 guggero

thank you @guggero. I am satisfied with option 2 as well. I'll add those changes this week if possible.

WRT release notes, which release should I target with this MR? i have a conflict in the old release notes I need to resolve.

SachinMeier avatar Sep 26 '22 20:09 SachinMeier

WRT release notes, which release should I target with this MR? i have a conflict in the old release notes I need to resolve.

I think v0.16.0-beta is still the aim here.

guggero avatar Sep 26 '22 20:09 guggero

So the way I see it, we have two options here:

  1. Use string flags to get rid of the misleading (default: 0) suffix and do all integer parsing manually.
  2. Set the Value field for all fields to their default values lnd would use and then implement ctx.IsSet() for all of the optional flags to find out if the user wanted to set them or not (it IsSet() returns false, we'd set the value to 0 on the RPC to make sure we don't overwrite the value).

@Roasbeef, @yyforyongyu what's your opinion on this? Personally I like option 2, even if that is a bit more effort to implement.

Yeah I'd say option 2 is better, option 1 seems hacky.

yyforyongyu avatar Sep 28 '22 09:09 yyforyongyu

@SachinMeier it doesn't look like you're using ctx.IsSet() at all in the latest version?

guggero avatar Oct 10 '22 11:10 guggero

My apologies for the delay. I have updated the PR to make CLTV optional. I did not do so with baseFee and feeRate since we'd need flags to differentiate between unset and 0 values. This seemed like overkill to me, so I didn't implement it.

it doesn't look like you're using ctx.IsSet() at all in the latest version?

@guggero is this how you intended for ctx.IsSet to be used? I think i misinterpreted you last time.

SachinMeier avatar Nov 04 '22 05:11 SachinMeier

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

lightninglabs-deploy avatar Nov 18 '22 12:11 lightninglabs-deploy

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

lightninglabs-deploy avatar Apr 04 '23 03:04 lightninglabs-deploy

I am unclear on what people think is the best approach, so I'm going to close this

SachinMeier avatar Apr 06 '23 21:04 SachinMeier