From ce43bb6dea6a25ade33b79184c9eacaa0797c345 Mon Sep 17 00:00:00 2001 From: pharr117 Date: Tue, 26 Dec 2023 18:14:43 -0500 Subject: [PATCH 1/2] Split out request blocks for better error checking, allow skipping gov module requests for particular chains --- app.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/app.py b/app.py index c705374..203d65a 100644 --- a/app.py +++ b/app.py @@ -46,6 +46,11 @@ "https://cosmos-lcd.quickapi.com:443", ] +NETWORKS_NO_GOV_MODULE = [ + "noble", + "nobletestnet", +] + # Global variables to store the data for mainnets and testnets MAINNET_DATA = [] TESTNET_DATA = [] @@ -140,6 +145,13 @@ def is_endpoint_healthy(endpoint): timeout=1, verify=False, ) + + if response.status_code == 501: + response = requests.get( + f"{endpoint}/cosmos/upgrade/v1beta1/current_plan", + timeout=1, + verify=False, + ) return response.status_code == 200 except: return False @@ -568,12 +580,27 @@ def fetch_data_for_network(network, network_type, repo_path): if current_endpoint in SERVER_BLACKLIST: continue + + active_upgrade_check_failed = False + upgrade_plan_check_failed = False try: + if network in NETWORKS_NO_GOV_MODULE: + raise Exception("Network does not have gov module") ( active_upgrade_name, active_upgrade_version, active_upgrade_height, ) = fetch_active_upgrade_proposals(current_endpoint, network, network_repo_url) + + except: + ( + active_upgrade_name, + active_upgrade_version, + active_upgrade_height, + ) = (None, None, None) + active_upgrade_check_failed = True + + try: ( current_upgrade_name, current_upgrade_version, @@ -581,6 +608,15 @@ def fetch_data_for_network(network, network_type, repo_path): current_plan_dump, ) = fetch_current_upgrade_plan(current_endpoint, network, network_repo_url) except: + ( + current_upgrade_name, + current_upgrade_version, + current_upgrade_height, + current_plan_dump, + ) = (None, None, None, None) + upgrade_plan_check_failed = True + + if active_upgrade_check_failed and upgrade_plan_check_failed: if index + 1 < len(healthy_rest_endpoints): print( f"Failed to query rest endpoints {current_endpoint}, trying next rest endpoint" @@ -592,6 +628,12 @@ def fetch_data_for_network(network, network_type, repo_path): ) break + if active_upgrade_check_failed and network not in NETWORKS_NO_GOV_MODULE: + print( + f"Failed to query active upgrade endpoint {current_endpoint}, trying next rest endpoint" + ) + continue + if ( active_upgrade_version and (active_upgrade_height is not None) From c49fbef33f082c42bb624ce000e94cf535f8eb25 Mon Sep 17 00:00:00 2001 From: pharr117 Date: Tue, 26 Dec 2023 18:22:48 -0500 Subject: [PATCH 2/2] Move off gov endpoint for health check, use base tendermint endpoint --- app.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app.py b/app.py index 203d65a..562a0c6 100644 --- a/app.py +++ b/app.py @@ -141,14 +141,7 @@ def is_endpoint_healthy(endpoint): # some chains dont implement the /health endpoint. Should we just skip /health and go directly to the below? if response.status_code == 501: response = requests.get( - f"{endpoint}/cosmos/gov/v1beta1/proposals?proposal_status=2", - timeout=1, - verify=False, - ) - - if response.status_code == 501: - response = requests.get( - f"{endpoint}/cosmos/upgrade/v1beta1/current_plan", + f"{endpoint}/cosmos/base/tendermint/v1beta1/node_info", timeout=1, verify=False, )