-
Notifications
You must be signed in to change notification settings - Fork 58
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
Unify configuration structure for Lurk library and CLI #706
Unify configuration structure for Lurk library and CLI #706
Conversation
3512e79
to
6e7ccb1
Compare
6e7ccb1
to
0ca1996
Compare
Note, even if I haven't had the time to give this a review: @samuelburnham and @winston-h-zhang have some overlap between this and #648 |
@samuelburnham what is the status of this PR? I agree with your comment that the Lurk config should be merged into |
e7579c6
to
feb4f03
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.
I like the general direction this is heading towards. Tyvm!
I wonder if the default config file should live in .config
or .lurk
. I usually like it when applications populate a single folder on my machine by default, but that's a subjective taste.
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.
Some streamlined comments about the utils
crate. I believe it's too simple to deserve its own crate right now. Especially because everything here seems to have a better home
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.
More comments from a third pass, now focusing on nitty gritty details
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.
I think this PR is headed in the right direction. There are a few remaining complexities I'd like to iron out:
- Preferably, I would like everything to be in one global config (merging
CLI_CONFIG
intoconfig::LURK_CONFIG
here), although I'm not strongly attached to the idea. Another reason is that we should be against the CLI having "ownership" over any part of the config (see pq's comment in the notion). - In the same way the CLI should not have any privilege to any particular config, the CLI should not have any privilege to modify environment variables. As we currently have it passing CLI arguments works by first overwriting the env vars of the corresponding arguments, and then propagating that change up to the config. This is really unpredictable; you might have default env vars, then accidentally overwrite everything by copy pasting someone else's CLI command.
- Documentation in
config.rs
detailing the behavior of the config. Is theconfig.toml
initialized to default values or does the user have to create one manually? Does theconfig.toml
stay in sync with the env vars, and/or are there any other automatic changes done which the user should be aware of? If I want to permanently change the default public params directory, do I have to manually editpublic_params_default_dir()
, is it safe to do so, etc?
Addressing each of these points:
- Merge
CLI_CONFIG
intoconfig::LURK_CONFIG
. - We should find some way to directly mutate the config from the CLI without taking a detour through env vars. Naively, I just want to make this a mutable static global, but @huitseeker definitely knows the better conventions here.
- I think these questions are more iffy and could warrant more discussion, so any ideas are welcome!
88fe620
to
df030a9
Compare
2a0e685
to
54f6540
Compare
54f6540
to
ef9ebd6
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.
This is amazing work 🙏🏼
Earlier in the (short) call we had you mentioned that the user would be able to use a custom config file but I don't see this signaled in the CLI help menu nor anywhere else for the user to know. How do you think the user should become aware of that feature? Or is it not implemented yet?
@arthurpaulino the config file itself can't be customized, but its location can be configured by the |
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.
I tested it and it seems to be fine. Maybe others can test it too
src/public_parameters/disk_cache
ef9ebd6
to
b406765
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.
This looks good to me globally, with some comments left inline.
Unify public param config with config.rs, spin out CLI config Address feedback and refactor CLI overrides Simplify global initialization Add configurable config file location
b406765
to
962f220
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.
Thanks a ton!
Moves the
LURK_DIRS
global variable toconfig.rs
asLURK_CONFIG: OnceCell<Settings>
. This enables the configuration of the public parameter cache location in the following ways:public_params_dir = "/path/to/public_params"
into the config file located at$HOME/.lurk/lurk.toml
or a configurable location (lowest priority)LURK_PUBLIC_PARAMS_DIR
env var (higher priority)--public-params-dir /path/to/public_params
arg to thelurk
binary to override the env var and config file (highest priority).The CLI mirrors the above settings in its own
CLI_CONFIG: OnceCell<CliSettings>
, while sharing thelurk.toml
config file for now:proofs_dir
,commits_dir
,circom_dir
LURK_PROOFS_DIR
,LURK_COMMITS_DIR
,LURK_CIRCOM_DIR
--proofs-dir
,--commits-dir
,--circom-dir
Removes the cache path arg from the
public_params
function in favor of the new configRefactors the CLI's
set_lurk_dirs()
function tolurk_config()
andcli_config()
, which use theOnceCell::get_or_init()
function to remove the prior reliance on function call order.Disambiguate/merge configs with the preexisting
src/config.rs
concerning parallelism. If merged, the configs would all be contained in$HOME/.lurk/lurk.toml
with the source insrc/config.rs
Add doc comments, particularly regarding the config options explained above
Fixes #621