sigp / lighthouse

Ethereum consensus client in Rust
https://lighthouse.sigmaprime.io/
Apache License 2.0
2.92k stars 741 forks source link

Support passing configs via env vars #4734

Open karalabe opened 1 year ago

karalabe commented 1 year ago

We've just introduced a nifty feature into Geth where you can specify configurations in env vars too, not only cli flags. Each flag is mapped to an env var automatically, so it's fairly obvious and easy to understand.

E.g. --state.scheme would be GETH_STATE_SCHEME

Wondering if Lighthouse has a similar feature planned?

The benefit of this is that in many cloud or container provider settings, the usual way to configure stuff is via env vars. Most providers allow you to define env vars in templates, add defaults, docs, etc to them, making these templates easy to redistribute and even check for issues. Although they usually also support passing CLI flags, that's just one mega-mess of a single string containing everything, so it's very brittle.

My assumption is that whatever CLI library you're using already has support for env vars, you just need to tell them which var is mapped to which flag.

michaelsproul commented 1 year ago

My hesitation about env vars is that they get silently ignored if you typo the variable name. It's probably something we could still have a go at though. Our track record with making sweeping changes to the CLI arg parsing is... not good however. We're on an old arg-parsing library at the moment, and previous attempts to add config file support bit-rotted and never merged (cf. #2748).

karalabe commented 1 year ago

True, that mistyping could have adverse effects. Wondering how I'd solve it (for us too), perhaps one way would be to iterate over all the GETH_ prefixed env vars on startup, and anything not mapped to a flag would be printed in a warning log saying that an env var is present, but not used. Of course, it's still not as strict as flat out refusing to start on a bad flag, but it's a step closer to finding issues.

karalabe commented 1 year ago

A quick implementation:

Screenshot 2023-09-14 at 17 24 26
protolambda commented 9 months ago

Is this feature still being considered? This would make docker setups less painful to configure.

karalabe commented 9 months ago

It’s been merged and released months ago :)

On Sun, 21 Jan 2024 at 17:32, protolambda @.***> wrote:

Is this feature still being considered? This would make docker setups less painful to configure.

— Reply to this email directly, view it on GitHub https://github.com/sigp/lighthouse/issues/4734#issuecomment-1902688183, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7UGLJCBVLJYN5S5DINFDYPU7K7AVCNFSM6AAAAAA4X7QH5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBSGY4DQMJYGM . You are receiving this because you authored the thread.Message ID: @.***>

karalabe commented 9 months ago

Oh shit, wrong repo, sorry for the noise

On Sun, 21 Jan 2024 at 19:35, Péter Szilágyi @.***> wrote:

It’s been merged and released months ago :)

On Sun, 21 Jan 2024 at 17:32, protolambda @.***> wrote:

Is this feature still being considered? This would make docker setups less painful to configure.

— Reply to this email directly, view it on GitHub https://github.com/sigp/lighthouse/issues/4734#issuecomment-1902688183, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7UGLJCBVLJYN5S5DINFDYPU7K7AVCNFSM6AAAAAA4X7QH5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBSGY4DQMJYGM . You are receiving this because you authored the thread.Message ID: @.***>

dapplion commented 9 months ago

Linking related latest issue to overhaul the CLI

protolambda commented 8 months ago

Any chance this feature can be implemented, now that the mainnet Dencun release is out of the way? I am still interested in being able to configure lighthouse this way.