Skip to content

feat: Add --network flag to CLI tools for multi-network support#2283

Open
rockysingh wants to merge 1 commit intohiero-ledger:mainfrom
rockysingh:2268-network-configuration-framework
Open

feat: Add --network flag to CLI tools for multi-network support#2283
rockysingh wants to merge 1 commit intohiero-ledger:mainfrom
rockysingh:2268-network-configuration-framework

Conversation

@rockysingh
Copy link
Contributor

@rockysingh rockysingh commented Feb 27, 2026

Summary

  • Adds a NetworkConfig record with static current() singleton that holds all network-specific parameters (GCS bucket, mirror node URL, genesis date, node range, genesis address book, etc.)
  • Adds --network option (mainnet/testnet) to BlockStreamTool root command with scope = ScopeType.INHERIT, making it available on all subcommands
  • Replaces hardcoded mainnet values across 16 files with NetworkConfig.current() references
  • AddressBookRegistry falls back to fetching the genesis address book from the mirror node API at runtime when a bundled resource isn't available (e.g. for testnet)

Files Changed

Area Files Change
New NetworkConfig.java Central config record with mainnet() / testnet() factories
CLI root BlockStreamTool.java --network option with inherited scope
GCS bucket DownloadConstants.java, MainNetBucket.java, DownloadDayImplV2.java, LiveDownloader.java Bucket name + path prefix from NetworkConfig
Mirror node FetchBlockQuery.java, FixBlockTime.java, BlockTimeCommand.java, UpdateBlockData.java, MirrorNodeAddressBook.java, ExtractDayBlocksFromApi.java Mirror node URL from NetworkConfig
Genesis date DownloadDaysV3.java, UpdateDayListingsCommand.java, Validate.java, ValidateWithStats.java Genesis date + node range from NetworkConfig
Address book AddressBookRegistry.java Genesis address book resource from NetworkConfig with mirror node fallback

Test plan

  • ./gradlew :tools:compileJava — compiles without errors
  • ./gradlew :tools:test — all 1075 existing tests pass
  • ./gradlew spotlessApply — formatting clean
  • Default behavior unchanged: commands without --network still use mainnet
  • Testnet: --network testnet commands hit testnet mirror node and GCS bucket

Closes #2268

@rockysingh rockysingh requested review from a team as code owners February 27, 2026 00:35
@rockysingh rockysingh marked this pull request as draft February 27, 2026 00:36
@rockysingh rockysingh self-assigned this Feb 27, 2026
@rockysingh rockysingh added the Block Node Tools Additional tools related to, but not part of, the Block Node label Feb 27, 2026
@rockysingh rockysingh added this to the 0.29.0 milestone Feb 27, 2026
@rockysingh rockysingh changed the title feat: Add --network flag to CLI tools for multi-network support (#2… feat: Add --network flag to CLI tools for multi-network support Feb 27, 2026
@rockysingh rockysingh changed the title feat: Add --network flag to CLI tools for multi-network support feat: Add --network flag to CLI tools for multi-network support Feb 27, 2026
…ro-ledger#2268)

  Introduce a NetworkConfig framework that replaces hardcoded mainnet
  values throughout the tools project, enabling the same CLI commands
  to work with testnet (and future networks) via a --network flag.

Signed-off-by: Rocky Thind <[email protected]>
@rockysingh rockysingh force-pushed the 2268-network-configuration-framework branch from cfec3b6 to 81179c3 Compare February 27, 2026 17:35
@rockysingh rockysingh marked this pull request as ready for review February 27, 2026 18:18
@rockysingh rockysingh changed the title feat: Add --network flag to CLI tools for multi-network support feat: Add --network flag to CLI tools for multi-network support Feb 27, 2026
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff              @@
##               main    #2283      +/-   ##
============================================
+ Coverage     80.74%   80.90%   +0.16%     
- Complexity     1461     1463       +2     
============================================
  Files           139      139              
  Lines          6766     6766              
  Branches        728      728              
============================================
+ Hits           5463     5474      +11     
+ Misses          984      969      -15     
- Partials        319      323       +4     

see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Block Node Tools Additional tools related to, but not part of, the Block Node

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Network Configuration Framework

2 participants