Skip to content

Commit d375d8f

Browse files
authored
ci: Remove liveness checks for state sync configuration in interactive installer [DEV-5390] (#934)
* ci: Remove liveness checks for state sync configuration * Add link to state sync guide
1 parent aae5530 commit d375d8f

File tree

1 file changed

+21
-42
lines changed

1 file changed

+21
-42
lines changed

installer/installer.py

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,25 +1210,6 @@ def configure_node_settings(self) -> bool:
12101210
logging.exception(f"Failed to configure cheqd-noded settings. Reason: {e}")
12111211
return False
12121212

1213-
def _select_working_rpc_endpoint(self, chain: str) -> str:
1214-
try:
1215-
endpoints = []
1216-
if chain == "testnet":
1217-
endpoints = [TESTNET_RPC_ENDPOINT_EU, TESTNET_RPC_ENDPOINT_AP]
1218-
else:
1219-
endpoints = [MAINNET_RPC_ENDPOINT_EU, MAINNET_RPC_ENDPOINT_AP]
1220-
1221-
for endpoint in endpoints:
1222-
try:
1223-
req = request.Request(f"{endpoint}/status")
1224-
with request.urlopen(req, timeout=10) as resp:
1225-
if resp.getcode() == 200:
1226-
return endpoint
1227-
except Exception:
1228-
continue
1229-
except Exception as e:
1230-
logging.exception(f"Could not select a working RPC endpoint. Reason: {e}")
1231-
return ""
12321213

12331214
def _get_latest_block_height(self, rpc_endpoint: str) -> int:
12341215
try:
@@ -1253,13 +1234,6 @@ def _get_block_hash_at_height(self, rpc_endpoint: str, height: int) -> str:
12531234
logging.exception(f"Failed to fetch block hash at height {height} from {rpc_endpoint}. Reason: {e}")
12541235
raise
12551236

1256-
def _is_endpoint_healthy(self, endpoint: str) -> bool:
1257-
try:
1258-
req = request.Request(f"{endpoint}/status")
1259-
with request.urlopen(req, timeout=10) as resp:
1260-
return resp.getcode() == 200
1261-
except Exception:
1262-
return False
12631237

12641238
def configure_statesync(self) -> bool:
12651239
# Configure statesync settings in config.toml using selected network RPCs
@@ -1272,21 +1246,25 @@ def configure_statesync(self) -> bool:
12721246
else:
12731247
candidates = [MAINNET_RPC_ENDPOINT_EU, MAINNET_RPC_ENDPOINT_AP]
12741248

1275-
healthy = [ep for ep in candidates if self._is_endpoint_healthy(ep)]
1276-
if len(healthy) == 0:
1277-
logging.error("No working RPC endpoint found for statesync configuration")
1278-
return False
1249+
# Always set both endpoints and use the first for trusted state
1250+
rpc_servers = f"{candidates[0]},{candidates[1]}"
1251+
working_rpc = candidates[0]
12791252

1280-
if len(healthy) == 1:
1281-
rpc_servers = f"{healthy[0]},{healthy[0]}"
1282-
working_rpc = healthy[0]
1283-
else:
1284-
rpc_servers = f"{healthy[0]},{healthy[1]}"
1285-
working_rpc = healthy[0]
1286-
1287-
latest_height = self._get_latest_block_height(working_rpc)
1288-
trust_height = max(latest_height - 2000, 1)
1289-
trust_hash = self._get_block_hash_at_height(working_rpc, trust_height)
1253+
# Try to compute trusted state from the first endpoint; warn softly if unavailable
1254+
trust_height = None
1255+
trust_hash = None
1256+
try:
1257+
latest_height = self._get_latest_block_height(working_rpc)
1258+
trust_height = max(latest_height - 2000, 1)
1259+
trust_hash = self._get_block_hash_at_height(working_rpc, trust_height)
1260+
except Exception:
1261+
logging.warning(
1262+
"Could not fetch trusted state from %s. "
1263+
"Please calculate trust_height and trust_hash manually and update config.toml. "
1264+
"See more details at "
1265+
"https://docs.cheqd.io/node/validator-guides/validator-guide/reenable-pruning#state-sync",
1266+
working_rpc,
1267+
)
12901268

12911269
# Safely edit only the [statesync] section for 'enable'
12921270
with open(config_toml_path, "r") as f:
@@ -1332,8 +1310,9 @@ def upsert(key: str, value: str, quote: bool = False):
13321310

13331311
# Use existing search_and_replace helper for other statesync fields (unique keys)
13341312
search_and_replace('rpc_servers = ""', f'rpc_servers = "{rpc_servers}"', config_toml_path)
1335-
search_and_replace('trust_height = 0', f'trust_height = {trust_height}', config_toml_path)
1336-
search_and_replace('trust_hash = ""', f'trust_hash = "{trust_hash}"', config_toml_path)
1313+
if trust_height is not None and trust_hash is not None:
1314+
search_and_replace('trust_height = 0', f'trust_height = {trust_height}', config_toml_path)
1315+
search_and_replace('trust_hash = ""', f'trust_hash = "{trust_hash}"', config_toml_path)
13371316

13381317
logging.info("Configured state sync settings in config.toml")
13391318
return True

0 commit comments

Comments
 (0)