cli: let per-field flags override the --env base#3812
Merged
Conversation
Previously `--env` was mutually exclusive with the per-field override flags: the global `doublezero` flag rejected the combination at the clap layer, and `doublezero config set` printed "Invalid flag combination" and exited without writing. This made `--env local --program-id <X>` impossible. Now `--env <name>` resolves the whole network (ledger URL, WS URL, Solana L1 URL, serviceability and geolocation program IDs) as a base, and `--url`, `--ws`, `--solana-url`, `--program-id`, `--geo-program-id` each override only their own value on top (precedence: explicit flag > --env, per RFC-20 override hierarchy). The CliContextBuilder already layered this way, so the global flag only drops its `conflicts_with_all`; `config set` resolves the env base then applies per-field overrides. Adopt the new behavior in e2e: the manager and client containers configure the CLI with `--env local` plus per-field overrides for the container ledger URLs and the deployed serviceability program ID (and geolocation on the manager). The program-id override is required for the sentinel multicast-publisher test (generated keypair) and the compatibility tests (cloned program IDs).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--enva base that the per-field flags override, instead of being mutually exclusive with them.--env <name>resolves the whole network (ledger URL, WS URL, Solana L1 URL, serviceability + geolocation program IDs);--url,--ws,--solana-url,--program-id,--geo-program-ideach override only their own value on top (precedence: explicit flag >--env). This applies to both the globaldoublezeroflags anddoublezero config set.--env local --program-id <X>, which previously failed: the global flag rejected it at the clap layer (ArgumentConflict), andconfig setprintedInvalid flag combinationand exited without writing.--env localplus per-field overrides for the container ledger URLs and the deployed serviceability program ID (and geolocation on the manager).Why
Per RFC-20's override hierarchy (
explicit CLI flag > env var > value from --env), the per-field flags are meant to layer on top of--env, not conflict with it. The implementation enforced mutual exclusion, which contradicted the documented contract and prevented configuring a known environment while overriding a single field (e.g. pointinglocalat a container ledger or a cloned program). TheCliContextBuilderalready resolved values last-write-wins, so the global flag only needed itsconflicts_with_allremoved;config setnow resolves the env base then applies per-field overrides.The e2e override of
--program-idis required because the sentinel multicast-publisher stack deploys serviceability at a generated keypair and the compatibility tests clone testnet/mainnet program IDs; for standard stacks the env defaults already match the fixed localnet pubkeys.RFC: rfcs/rfc20-cli-standardization.md (§override hierarchy).
Testing Verification
config set --env local --url <container> --ws <container> --program-id <generated>writes aconfig.ymlwith the overridden URLs and the generated program ID while serviceability/geolocation defaults come fromlocal— confirmed with the compiled binary for the standard, generated-keypair, and cloned-program cases.TestE2E_SentinelMulticastPublisherCreatesPublisherspasses. This is the one stack that deploys serviceability at a generated keypair, so it exercises the--env local+--program-idoverride end-to-end: device, multicast group, and three IBRL users created, all multicast publishers verifiedActivated.env_combines_with_url/_ws/_solana_url/_program_id/_geo_program_id) andconfig setoverride tests (test_cli_config_set_env_with_program_id_overrides,..._geo_program_id_overrides).