Skip to content

Commit

Permalink
Split out request blocks for better error checking, allow skipping go…
Browse files Browse the repository at this point in the history
…v module requests for particular chains
  • Loading branch information
pharr117 committed Dec 26, 2023
1 parent 5b847fb commit ce43bb6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -568,19 +580,43 @@ 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,
current_upgrade_height,
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"
Expand All @@ -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)
Expand Down

0 comments on commit ce43bb6

Please sign in to comment.