lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Another Config File PR

Open realbigsean opened this issue 3 years ago • 3 comments

Issue Addressed

#2748

Proposed Changes

  • Allows reading from a YAML or TOML config file.
  • CLI arguments take precedence over file arguments if both are provided
  • This also includes a fix to a documentation issue I stumbled on where advanced-pre-releases was linked when advanced-release-candidates.md should be

Additional Info

The solution here is a combination of what @pawanjay176 suggested here and what the argfile crate provides.

Pawan's solution required using clap to parse and validate the config file flag, and then using clap_derive's update_from to update/validate the original command with the file config. But this requires the extensive migration here, which may take a while to get merged.

argfile circumvents the need for clap_derive's update_from by parsing the config file directly from the cli args and expanding it prior to doing any clap parsing. But it provides no ability to override file config with cli args and requires using a syntax along the lines of lighthouse bn @argfile which is unlike what is provided by other consensus clients.

This solution mimics argfile's preprocessing but is more suited to lighthouse's specific needs. It also does not depend on or conflict with #3007.

realbigsean avatar Mar 11 '22 16:03 realbigsean

Ooh, this is interesting! Very simple to implement. It is a shame you can't override with the CI, but it does make things simpler to reason about!

But it provides no ability to override file config with cli args and requires using a syntax along the lines of lighthouse bn @argfile which is unlike what is provided by other consensus clients.

Looking at the PR, it seems we'd use lighthouse bn --config-file rather than the @argfile?

paulhauner avatar Mar 14 '22 00:03 paulhauner

But it provides no ability to override file config with cli args and requires using a syntax along the lines of lighthouse bn @argfile which is unlike what is provided by other consensus clients.

^ These are limitations of the argfile crate which is why I didn't use that crate in this PR. In this PR you can override file config with CLI and use lighthouse bn --config-file

realbigsean avatar Mar 14 '22 02:03 realbigsean

I'm going to drop the ready-for-review tags due to conflicts. Sorry about letting this one go stale, we can chat about it sometime :)

paulhauner avatar Jul 04 '22 00:07 paulhauner