Skip to content

Commit

Permalink
Merge pull request #38 from DefiantLabs/patch/chains-missing-gov
Browse files Browse the repository at this point in the history
Patch/chains missing gov
  • Loading branch information
danbryan committed Jan 6, 2024
2 parents 5b847fb + c49fbef commit 6d4ad81
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion 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 @@ -136,7 +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",
f"{endpoint}/cosmos/base/tendermint/v1beta1/node_info",
timeout=1,
verify=False,
)
Expand Down Expand Up @@ -568,19 +573,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 +621,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 6d4ad81

Please sign in to comment.