Skip to content

fix(core): collapse empty ${VAR} substitutions to None#303

Merged
obchain merged 2 commits into
mainfrom
fix/config-unblock-startup
Apr 24, 2026
Merged

fix(core): collapse empty ${VAR} substitutions to None#303
obchain merged 2 commits into
mainfrom
fix/config-unblock-startup

Conversation

@obchain
Copy link
Copy Markdown
Owner

@obchain obchain commented Apr 23, 2026

Summary

  • Local-mainnet validator caught that empty CHARON_BSC_PRIVATE_RPC_URL / CHARON_BSC_PRIVATE_RPC_AUTH env vars pass through substitute_env_vars as literal empty strings, deserialize as Some(SecretString("")), then silently defeat Config::validate's is_none() gate and attach blank Authorization: Bearer headers to private-RPC submits.
  • Added Config::normalize_empty_secrets called once from Config::load to collapse empty SecretString values to None on every chain, restoring the "None = unset" invariant downstream callers assume.

Scope

  • crates/charon-core/src/config.rs only. No behavior change for non-empty secrets. No new config fields.

Trace (live-mainnet start with empty CHARON_BSC_PRIVATE_RPC_URL)

  1. substitute_env_vars -> private_rpc_url = ""
  2. serde -> Some(SecretString(""))
  3. normalize_empty_secrets -> None
  4. validate -> is_none() && !allow_public_mempool -> ConfigError::PrivateRpcRequired

Silent start now impossible without explicit allow_public_mempool = true.

Test plan

  • cargo test -p charon-core config:: -> 11/11 pass (5 new)
  • blockchain-code-reviewer: APPROVE (no blockers, no missed surface)
  • Reviewer sign-off before merge into feat/19-private-rpc-submit

Empty env vars (CHARON_*_PRIVATE_RPC_URL, CHARON_*_PRIVATE_RPC_AUTH)
were substituted to `""`, deserialized as Some(SecretString("")),
producing blank Authorization: Bearer headers and defeating
Config::validate's is_none() gate on the private-RPC requirement.
Normalize empty SecretStrings to None in Config::load so downstream
code can trust None to mean "unset".
@obchain obchain changed the base branch from feat/19-private-rpc-submit to main April 24, 2026 17:46
@obchain obchain changed the base branch from main to feat/19-private-rpc-submit April 24, 2026 17:50
…artup

# Conflicts:
#	crates/charon-core/src/config.rs
@obchain obchain changed the base branch from feat/19-private-rpc-submit to main April 24, 2026 18:02
@obchain obchain merged commit 77f19bd into main Apr 24, 2026
2 of 4 checks passed
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.

1 participant