Skip to content

fix(config): use named constants for fallbacks, remove dead code, fix stale doc ref (#673, #674, #675, #678) - #860

Open
trakshan-mishra wants to merge 1 commit into
SO4-Markets:mainfrom
trakshan-mishra:fix/config-constants-and-docs
Open

fix(config): use named constants for fallbacks, remove dead code, fix stale doc ref (#673, #674, #675, #678)#860
trakshan-mishra wants to merge 1 commit into
SO4-Markets:mainfrom
trakshan-mishra:fix/config-constants-and-docs

Conversation

@trakshan-mishra

Copy link
Copy Markdown

Description

Bundles four config-module cleanups, all good-first-issues in oracle/src/config.rs and oracle/src/network_config.rs. Each is small, independent, and addresses the exact acceptance criteria in its issue.

#675bind_addr fallback duplicates the literal instead of reusing DEFAULT_BIND_ADDR

collect_or_default! for bind_addr used "0.0.0.0:8080".parse().unwrap() as its fallback, while every other tunable in the file reuses its DEFAULT_* constant. A future edit to DEFAULT_BIND_ADDR would silently desync from the fallback with no test catching it.

Fix: replaced the literal with DEFAULT_BIND_ADDR.parse().unwrap() and added a unit test (config_from_lookup_bind_addr_defaults_to_constant) asserting Config::from_lookup resolves to DEFAULT_BIND_ADDR when BIND_ADDR is unset.

#674ENV_KEY constant is unused; the literal "PRICE_FEED_CONFIG" is duplicated at the lookup

ENV_KEY was declared as the single source of truth for the env-var name, but the actual lookup at line 204 hardcoded the literal string. If the var name were ever renamed, ENV_KEY would silently go stale while the real lookups kept working off the duplicated literal.

Fix: replaced the literal at the lookup site with ENV_KEY. (The remaining PRICE_FEED_CONFIG references in shared/config/src/lib.rs are user-facing error messages and doc comments in a separate crate — not lookups — so they stay as literal strings describing the var name to users.)

#673MAINNET_RPC_URL is defined but never referenced

MAINNET_RPC_URL had no call site anywhere in the workspace. On Network::Mainnet, config.rs calls required(&mut lookup, "STELLAR_RPC_URL") unconditionally — there is no fallback path. This is intentional: the test config_from_lookup_requires_explicit_mainnet_rpc asserts that mainnet forces explicit RPC configuration (a safety measure). Wiring the constant as a fallback would break that test and the intentional design.

Fix: removed the dead constant rather than wiring it in, so the code stops implying a code path that doesn't exist. MAINNET_PASSPHRASE (which is used) is retained.

#678validate_strkey() doc comment cites an unrelated issue #3

The doc comment claimed CRC16/keypair-derivation validation is "wired with the keeper in #3", but #3 is an unrelated closed data-store rent estimation feature. No tracking issue exists for the CRC16/derivation gap.

Fix: reworded the doc comment to accurately describe the limitation without the stale issue pointer: full keypair verification happens in the keeper runtime, not at config load.

Type of change

  • 🐛 Bug fix (config correctness + dead code + stale docs)

Verification

cargo fmt --all                          # clean
cargo clippy --all-targets -- -D warnings # 0 warnings
cargo test --workspace                   # 296+ tests, 0 failures

The new test config_from_lookup_bind_addr_defaults_to_constant passes, and the existing config_from_lookup_requires_explicit_mainnet_rpc test still passes (confirming the MAINNET_RPC_URL removal doesn't affect the intentional mainnet-requires-explicit-RPC behavior).

Related issues

Closes #673, #674, #675, #678

… stale doc ref

Bundle four config-module cleanups (good-first-issues SO4-Markets#673, SO4-Markets#674, SO4-Markets#675, SO4-Markets#678):

- SO4-Markets#675: bind_addr collect_or_default fallback hardcoded "0.0.0.0:8080"
  instead of reusing DEFAULT_BIND_ADDR; a future edit to the constant
  would silently desync from the fallback with no test catching it.
  Replaced with DEFAULT_BIND_ADDR.parse().unwrap() and added a unit test
  asserting Config::from_lookup resolves to DEFAULT_BIND_ADDR when
  BIND_ADDR is unset.

- SO4-Markets#674: the ENV_KEY constant ("PRICE_FEED_CONFIG") was declared but
  never read — the actual lookup at line 204 hardcoded the literal
  string. Replaced the literal with ENV_KEY so the constant is the
  single source of truth for the env-var name.

- SO4-Markets#673: MAINNET_RPC_URL was defined but never referenced anywhere in
  the workspace. Mainnet intentionally requires explicit STELLAR_RPC_URL
  (enforced by config_from_lookup_requires_explicit_mainnet_rpc), so
  there is no fallback path to wire the constant into. Removed the dead
  constant to stop implying a code path that doesn't exist.

- SO4-Markets#678: validate_strkey() doc comment cited issue SO4-Markets#3 for CRC16/keypair
  derivation validation, but SO4-Markets#3 is an unrelated closed feature ticket.
  Reworded to describe the limitation accurately without the stale
  issue pointer.

cargo fmt, cargo clippy --all-targets -- -D warnings, and
cargo test --workspace all pass (296+ tests, 0 failures).

Closes SO4-Markets#673, SO4-Markets#674, SO4-Markets#675, SO4-Markets#678
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.

MAINNET_RPC_URL constant in network_config.rs is defined but never referenced anywhere

1 participant