fix(core): collapse empty ${VAR} substitutions to None#303
Merged
Conversation
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".
This was referenced Apr 23, 2026
…artup # Conflicts: # crates/charon-core/src/config.rs
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
CHARON_BSC_PRIVATE_RPC_URL/CHARON_BSC_PRIVATE_RPC_AUTHenv vars pass throughsubstitute_env_varsas literal empty strings, deserialize asSome(SecretString("")), then silently defeatConfig::validate'sis_none()gate and attach blankAuthorization: Bearerheaders to private-RPC submits.Config::normalize_empty_secretscalled once fromConfig::loadto collapse emptySecretStringvalues toNoneon every chain, restoring the "None = unset" invariant downstream callers assume.Scope
crates/charon-core/src/config.rsonly. No behavior change for non-empty secrets. No new config fields.Trace (live-mainnet start with empty
CHARON_BSC_PRIVATE_RPC_URL)substitute_env_vars->private_rpc_url = ""Some(SecretString(""))normalize_empty_secrets->Nonevalidate->is_none() && !allow_public_mempool->ConfigError::PrivateRpcRequiredSilent 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)feat/19-private-rpc-submit