Skip to content

Add --network parameter to prefill parameters with sane defaults per-network#540

Merged
cjonas9 merged 12 commits intomainfrom
network-parameter
Nov 20, 2025
Merged

Add --network parameter to prefill parameters with sane defaults per-network#540
cjonas9 merged 12 commits intomainfrom
network-parameter

Conversation

@cjonas9
Copy link
Contributor

@cjonas9 cjonas9 commented Nov 19, 2025

What

The PR introduces a new optional NETWORK configuration parameter in RPC, which allows users to specify a preset Stellar network, pubnet or testnet. When NETWORK is set, RPC automatically adjusts the relevant parameters in the deployed instance's configuration and generates a corresponding captive core config file. The NETWORK parameter may be specified through the command line (usage: --network [preset]), the .toml config file, or ENV variables.

If the NETWORK parameter is specified, these fields are automatically populated based on the chosen network:

  • HISTORY_ARCHIVE_URLS
  • NETWORK_PASSPHRASE
  • CAPTIVE_CORE_CONFIG_PATH: The default configuration file for pubnet and testnet is embedded in the Horizon binary and used to generate the default configuration.

If the NETWORK parameter isn't specified, HISTORY_ARCHIVE_URLS and NETWORK_PASSPHRASE are both mandatory. An error message is displayed if they're not supplied.

If the NETWORK parameter is specified but is not "pubnet" or "testnet", an error message is displayed.

If the NETWORK parameter is specified and (HISTORY_ARCHIVE_URLS or NETWORK_PASSPHRASE) is supplied, an error message is displayed. This error message is not displayed if HISTORY_ARCHIVE_URLS and NETWORK_PASSPHRASE exactly match the values the NETWORK parameter would supply.

This PR also introduces a test in main_test.go that validates this behavior. Specifically, the test will verify that when the network option is provided, the HISTORY_ARCHIVE_URLS and NETWORK_PASSPHRASE fields are populated with their correct values. Further, it verifies that supplying the network option with NETWORK_PASSPHRASE errors.

Why

This simplifies the user experience and enables users to rapidly choose a default network configuration without manually configuring HISTORY_ARCHIVE_URLS or NETWORK_PASSPHRASE. Users also no longer have to manually install a captive core configuration file for pubnet and testnet.

Known limitations

[N/A]

@cjonas9 cjonas9 requested a review from Shaptic November 19, 2025 00:33
@cjonas9 cjonas9 marked this pull request as ready for review November 20, 2025 00:25
@Shaptic Shaptic changed the title Network parameter Add --network parameter to prefill parameters with sane defaults per-network Nov 20, 2025
@cjonas9 cjonas9 merged commit 13a9cbf into main Nov 20, 2025
17 of 18 checks passed
@cjonas9 cjonas9 deleted the network-parameter branch November 20, 2025 22:53
@urvisavla
Copy link
Contributor

@Shaptic @cjonas9 Did we consider using the default configs from the ingest library? They were added specifically to avoid duplicating configuration, so updates to quorum sets etc need to be made only in one place.

@Shaptic
Copy link
Contributor

Shaptic commented Nov 20, 2025

@urvisavla we need extra flags for diagnostic events 😭

@cjonas9
Copy link
Contributor Author

cjonas9 commented Nov 21, 2025

@urvisavla @Shaptic Yeah, @mollykarcher and I talked about this. Mentally have it pointed as a 3-pt issue because it involves 1.) embedding/exporting the common cfg files 2.) then for each of RPC/Horizon/Galexie building some configurer that prepends the necessary alternative flags as bytes to the imported common configs []bytes. Doing that in the reverse order would probably kill all the convenience of this.
tldr: it's a little bit of a headache, but one I actually do want to do. Giving it some thought!

@cjonas9 cjonas9 linked an issue Nov 25, 2025 that may be closed by this pull request
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.

Add support for NETWORK configuration parameter

3 participants