-
Notifications
You must be signed in to change notification settings - Fork 96
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
autopilot: generic rules per feature #634
autopilot: generic rules per feature #634
Conversation
ebac616
to
c861768
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First code review looks good 🚀fire:! Awaiting rebase before testing.
how do we signal empty restrictions for more than a single feature? currently we have to repeat the restrictions as often as the number of features, which requires to set several flags (a flag --feature-peer-restrict-list="" does not count)
Given that we opted for this version with feature configurations, I think it makes sense to do it like you've implemented it in this PR.
could we transition to json-style lists like "[item1,item1]" to signal empty restrictions with "[]", similarly to the feature configuration?
No strong opinion here, as long as we keep it consistent.
We change the flags to have a
feature
prefix, which is a breaking change.
Just a thought, would it make sense to keep the old flags as well for now, i.e. "channel-restrict-list" & "peer-restrict-list" but mark them as deprecated and remove them later to not make this a breaking change with this PR? And if the old flags are set, we keep the old behaviour, but also make sure that only one version of the flags are set and error if both versions are set. Do you think that would make sense?
cmd/litcli/autopilot.go
Outdated
Usage: `List of channel IDs that the ` + | ||
`Autopilot server should not ` + | ||
`perform actions on. In the ` + | ||
`form of: [chanID1,chanID2,...]. ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Should be as below, correct?
`form of: [chanID1,chanID2,...]. ` + | |
`form of: ["chanID1","chanID2",...]. ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah that was intentional, we would error to parse into []int64 otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while we are here, let's clear up this confusion by specifying that this should be a list of numbers. Since even in LND, there is a ChannelID
which is a uint64 and another which is a string ([32]byte)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a disadvantage of the generic flags is that it's not as well documented
c861768
to
8a4eeb6
Compare
Rebased the PR.
Am with you there, will check if it's worth to keep them backwards compatible. I also found a small issue which is preexisting: |
@bitromortac - is this ready for review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! will test on next round 👍
cmd/litcli/autopilot.go
Outdated
Usage: `List of channel IDs that the ` + | ||
`Autopilot server should not ` + | ||
`perform actions on. In the ` + | ||
`form of: [chanID1,chanID2,...]. ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while we are here, let's clear up this confusion by specifying that this should be a list of numbers. Since even in LND, there is a ChannelID
which is a uint64 and another which is a string ([32]byte)
cmd/litcli/autopilot.go
Outdated
"perform actions on. In the " + | ||
"form of: chanID1,chanID2,...", | ||
cli.StringSliceFlag{ | ||
Name: "feature-channel-restrict-list", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically this rename is a backwards incompatible change... imo it is fine since I dont think anyone is using this at the command line level yet. But perhaps something we should at least include in the release notes? (btw, I think we should have a running issue per release where we keep track of notes we want to make in the release so that we dont forget cc @ViktorTigerstrom )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move these to be next to feature-config
just so that all the per-feature flags are together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah - I saw @ViktorTigerstrom's suggestion now re keeping the old flags for now.
We could do that and then add a waring and a todo that they will be removed in the release after the next one. That's definitely the more friendly way of doing things :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I changed it to remain backwards compatible
8a4eeb6
to
cfa19f8
Compare
I changed this PR to include generic feature rule setting via JSON flags. Legacy flags are preserved and marked for deprecation. |
cfa19f8
to
fcac5f0
Compare
@ViktorTigerstrom: review reminder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK LGTM 🔥🚀!!
Great work!! Thanks for addressing the feedback about adding deprecating support 🚀!
Just adding some minor feedback in my comments below that's not blocking.
Also, I'd just like to show two examples of adding an autopilot session that intuitively probably shouldn't be accepted by the parsing, but that is. We probably don't really need to address these examples though, but feel free to address them if you want:
- When using the legacy version of setting the
peer-restrict-list
arg with multiple features, if you add multiplepeer-restrict-list
args where the last arg is set to "", that is accepted:
litcli autopilot a --label="test" --feature=AutoFees --peer-restrict-list="peerID1" --feature=SampleFeature --peer-restrict-list=""
- If the same feature is specified more than once when adding a autpilot session, that's accepted and only the last version is used:
litcli autopilot a --label="test" --feature=AutoFees --feature-rules="{\"rules\":{}}" --feature=AutoFees --feature-rules="{\"rules\":{\"channel-restriction\":{\"channel_restrict\":{\"channel_ids\":[chanID1]}}}}"
cmd/litcli/autopilot.go
Outdated
"rate-limit": { | ||
"rate_limit": { | ||
"read_limit": { | ||
"iterations": 10, | ||
"num_hours": 1 | ||
}, | ||
"write_limit": { | ||
"iterations": 1, | ||
"num_hours": 1 | ||
} | ||
} | ||
}, | ||
"channel-restriction": { | ||
"channel_restrict": { | ||
"channel_ids": [ | ||
18283782789, | ||
22891928322, | ||
31878293727 | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Since this enables users to set any of the rules now, I do think that:
- It makes sense to give an example for all types rules the user can set, i.e. also include examples of the
channel-policy-bounds
,history-limit
&peer-restriction
rule types here. - Clarify in the docs that if a specific rule type is not set, the default values will be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good calls, concerning 1, I have added the most interesting rules for AutoFees
, but left others away since I think it would add too much help output and it should be clear how to apply the pattern. I updated the help text a bit more to give more hints on how to correctly set rules. I've added that comment for 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but left others away since I think it would add too much help output and it should be clear how to apply the pattern
Ok thanks for the edits :)! Sure, I see your point, let's avoid adding too much output. In case we end up getting lot's of user questions of how to apply a specific rule in the future, we can always revisit this and add more info :)!
This commit adds generic feature rule flags. Legacy flags `channel-restrict-list` and `peer-restrict-list` are deprecated.
fcac5f0
to
34eeb2a
Compare
Thanks for the review and testing 🙏 @ViktorTigerstrom, those issues should be fixed in the latest version, great calls! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! thanks for this 🔥
@ViktorTigerstrom - will leave it to you to merge just incase you had anything to add re the latest updates to your feedback :)
Thanks for the fixes, they look great 🙏! |
We would like to be able to set different rules for different features. This is solved by introducing JSON-serialized (per-feature) rule flags where all the rules from
litcli autopilot features
can be set.