Skip mainnet RPC probe when mainnet is explicitly disabled#23
Skip mainnet RPC probe when mainnet is explicitly disabled#23MysticRyuujin wants to merge 2 commits into
Conversation
Closes TrueBlocks#22. When chains.mainnet.enabled is explicitly false in the config YAML, skip the install.Configured() reachability check and the ValidateChains "mainnet must be enabled" guard. This unblocks headless / air-gapped / container / CI deployments (kurtosis devnets, isolated environments) where no real mainnet node is available. Behavior preserved when mainnet is enabled or when the enabled field is omitted (legacy configs): RPC must be reachable and return chainId == 1. Structural checks (non-empty RPC, non-zero chainId) still apply on the disabled branch so downstream code reading main.RPCs[0] remains safe.
|
Hey Chase — thanks for this. Appreciate you digging in. I can't merge it though. The *bool YAML re-parse creates a hidden three-state boolean — two identical Chain structs with different runtime behavior. It's fragile and surprising. Simpler approach: add Also, new config fields need documentation — book and config.yaml.example. Happy to discuss further. Hopefully, your AI can do this easily. |
Per maintainer feedback on PR TrueBlocks#23: a plain bool in the [general] section is clearer than a second-pass *bool unmarshal that creates a hidden three-state boolean. Default false preserves existing behavior; set true to skip the mainnet RPC reachability probe in headless / air-gapped / container / CI deployments. Documented in config.yaml.example and the user manual.
|
Thanks for the review @tjayrush — that critique was on point. Pushed a revised version that drops the
Test list and details are in the updated PR description. |
Summary
Closes #22.
Adds a
skipMainnetProbe: falsefield to the[general]section ofconfig.yaml. Whentrue,install.Configured()skips the mainnet RPC reachability probe and the wizard no longer rejectsmainnet.enabled: false. This unblocks headless / air-gapped / container / CI deployments — specifically, the kurtosisethereum-packageintegration that runs khedra against an isolated devnet with no public network access.Default is
false, so existing installs are completely unaffected.Design (revised per maintainer feedback)
The first version of this PR detected the headless case with a second-pass YAML unmarshal into a
*bool. As @tjayrush pointed out, that created a hidden three-state boolean — two identicalChainstructs could exhibit different runtime behavior depending on whetherenabledwas omitted or explicitlyfalse. Fragile and surprising.This revision replaces that with a plain bool in the
[general]section, exactly as suggested. No YAML sniffing, no ambiguity, no helper functions.How it works
pkg/types/general.goSkipMainnetProbe boolwithkoanf/yaml/jsontags. No validate tag needed for a plain bool.pkg/types/config.goskipMainnetProbe: {{ .General.SkipMainnetProbe }}under thegeneral:block.pkg/types/apply_env.goKeyGeneralSkipMainnetProbe = "TB_KHEDRA_GENERAL_SKIPMAINNETPROBE"with astrconv.ParseBoolhandler.pkg/install/validity.goConfigured()callscheckMainnetAccessible()unlesscfg.General.SkipMainnetProbeis true.chainId != 0) still run unconditionally, so downstream code that readsmain.RPCs[0](env wiring inaction_daemon.go) stays safe.pkg/install/validation.goValidateChainscontinues to emitrequire_mainnetwhenmainnet.enabled: falseunlessgeneral.skipMainnetProbe: true. Error message updated to mention the escape hatch.Docs
config.yaml.example— field added with explanatory note.book/src/user_manual/getting_started.md— reference config + note 7 (with kurtosis link and env-var override).Test plan
go build ./...cleango test ./pkg/install/... ./pkg/types/...passes — includes:TestConfigured_SkipMainnetProbe_SkipsReachabilityProbeTestConfigured_SkipMainnetProbeOmitted_RequiresReachableProbeTestConfigured_SkipMainnetProbeFalse_RequiresReachableProbeTestConfigured_SkipMainnetProbe_StillRequiresRPCTestConfigured_SkipMainnetProbe_StillRequiresChainIDTestValidateChains_MainnetDisabled_RequireMainnetByDefaultTestValidateChains_MainnetDisabled_SkipProbeAllowedTestValidateChains_MainnetDisabled_SkipProbe_RequiresRPCTestGetEnvironmentKeysupdated for the new env key