Skip to content

autopilot: feature configuration #629

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

Merged
merged 7 commits into from
Sep 5, 2023
Merged

autopilot: feature configuration #629

merged 7 commits into from
Sep 5, 2023

Conversation

bitromortac
Copy link
Contributor

In this PR we add support for configuration of features within autopilot. Feature configuration can signal preferences to autopilot which are not enforceable by the litd firewall.

  • Default configurations for each feature are available via the ListFeatures call
  • Support for feature configuration is added to litcli
  • Pubkeys, channel ids, and channel points in configuration strings are obfuscated

Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

First review looks good after Elle's comment has been addressed 🚀! Really nice work :)!!

Leaving two suggestions for improvements that are non blocking. I'd especially want to hear you're opinion on how the configuration should be specified in the autopilot a cmd.

@ellemouton
Copy link
Member

requesting @guggero too for architecture ack

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

aACK, very nice!

Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

LGTM after fixing the issue mentioned in #629 🔥:rocket:, great work!!

Copy link
Member

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

LGTM! 🔥 great work

@bitromortac
Copy link
Contributor Author

Rebased on #621

This commit adds a field to the autopilot server rpc that transports
default configurations from autopilot to litd.
We pass on default configuration to litrpc in order to display them in
the list features call.
We add command line flags to litcli in order to be able to submit
feature configurations when registering a session.
@bitromortac
Copy link
Contributor Author

Rebased on #637

Copy link
Member

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

LGTM!

privMapPairs := make(map[string]string)
newConfigMap := make(map[string]any)
for k, v := range configMap {
// We only substitute items in lists.
Copy link
Member

Choose a reason for hiding this comment

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

why only lists?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so far I didn't have any better applications than for lists of items, similar to the peer deny list and channel deny lists and didn't want to be too restrictive. a fallback for a single field could be to use a list with a single item (hacky)

item, ok := item.(string)
allStrings = allStrings && ok
anyString = anyString || ok
stringList[i] = item
Copy link
Member

Choose a reason for hiding this comment

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

wont this panic if !ok since then we are assigning a non-string to a string list?

Copy link
Member

Choose a reason for hiding this comment

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

ah ok it doesnt panic since item at this point is empty. But maybe just for clarity, let's do:

if !ok {
    continue
}

stringList[i] = item

newConfigMap := make(map[string]any)
for k, v := range configMap {
// We only substitute items in lists.
list, ok := v.([]any)
Copy link
Member

Choose a reason for hiding this comment

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

if we are only doing "lists of strings" then why not do v.([]string) here?

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 tried that, but it didn't work, see https://go.dev/play/p/iA-IUn5VHR4

{
// A list of numbers is not obfuscated. Those can be
// useful to submit histograms for example.
name: "channel ids",
Copy link
Member

Choose a reason for hiding this comment

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

we would want to obfuscate channel IDs though. Even though they are numbers. This makes me think we should allow the user to specify specify somehow that a list/item in a config struct should be obfuscated. We need to think about how to do this though... We can do this in future though :) we just need to do it before ever asking for channel IDs in the config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, agree that we need to think more about these cases and that such a signal could make sense, for now the signal for obfuscation is to have a list of strings, which includes the channel id case as well, just the numbers converted to strings

Copy link
Member

Choose a reason for hiding this comment

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

which includes the channel id case as well, just the numbers converted to strings

Cool - as long as the firewalldb.Uint64ToStr method is being used for this conversion to strings. Since the converted string needs to match other places where the channel ID is being used .

Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

tACK LGTM!!! 🔥:rocket:🔥

Awesome 🥳!!!

We obfuscate pubkeys, channel points and ids entered in configurations.

The channel id lengths for different block heights can be checked with:
```python
len(str(1 << 40 | 2923 << 16 | 30))
len(str(10_000_000 << 40 | 2923 << 16 | 30))
```
We also upate sample data to reflect the latest state of the api.
This commit returns an empty PrivacyMapReader if the privacy bucket for
the group doesn't yet exist.
@ellemouton ellemouton merged commit a942af6 into master Sep 5, 2023
@guggero guggero deleted the persist-config branch September 5, 2023 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants