forked from harmony-one-vdao/validator_vote_node_info
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_version.py
More file actions
187 lines (156 loc) · 5.71 KB
/
node_version.py
File metadata and controls
187 lines (156 loc) · 5.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import logging
from time import sleep
from core.blskeys import *
latest_node_version = "v7331-v4.3.4-0-g4ea9072e"
# v7331-v4.3.4-0-g4ea9072e-dirty
# check a single wallets Node version.
check_wallet = "one199wuwepjjefwyyx8tc3g74mljmnnfulnzf7a6a"
def validator_node_version(
fn: str,
latest_version: str,
grouped_data: dict,
num_pages: int = 100,
save_json_data: bool = False,
check_wallet: str = False,
) -> None:
active_validators = 0
not_updated = 0
is_updated = 0
unknown = 0
elected = 0
elected_not_updated = 0
elected_is_updated = 0
elected_unknown = 0
csv_data = []
result = []
res, _, prometheus_data = call_api(prometheus)
if not res:
log.error("Error Connecting, Shutting Down.. ")
return False
prometheus_data = prometheus_data["data"]
display_check = f"Wallet {check_wallet} NOT Found."
for y in yield_data(result, check_wallet=check_wallet, num_pages=num_pages):
result, check_wallet, show, include, v, e = y
is_elected = False
validators = {x["Name"]: [] for x in csv_data}
if not validators.get("Name"):
validators.update({v.name: []})
include = True
if e.active_status == "active":
w = []
active_validators += 1
if e.epos_status == "currently elected":
elected += 1
is_elected = True
for blskey in v.bls_public_keys:
_, _, versions, shard = bls_key_version(blskey, prometheus_data)
# We only need to register 1 key per shard because it is the binary version not the key that require updating.
if shard not in validators[v.name]:
validators[v.name] += [int(shard)]
shards = validators[v.name]
vers = (latest_node_version not in versions) and (
f"{latest_node_version}-dirty" not in versions
)
if (
include
# and (latest_node_version not in versions)
and vers
and (not v.address in updated_but_vers_not_found)
):
versions = versions[0] if len(versions) <= 1 else versions
include = False
if versions == "Version Not Found":
unknown += 1
if is_elected:
elected_unknown += 1
else:
not_updated += 1
if is_elected:
elected_not_updated += 1
if show:
display_check = f"\n\tWallet *- {check_wallet} -* Node Updated = NO!\t\nNode Version(s) = {versions}\n"
w = {
"Name": v.name,
"Address": v.address,
"Security Contact": v.security_contact,
"Website": v.website,
"Active Status": e.active_status,
"Epos Status": e.epos_status,
# "blskey",
"Version": versions,
}
else:
if include:
include = False
is_updated += 1
if is_elected:
elected_is_updated += 1
if show:
display_check = f"\n\tWallet *- {check_wallet} -* Node Updated = YES!\n\tNode Version(s) = {versions}\n"
if w:
ss_address, ss_blskeys = find_smartstakeid(
v.address, smartstake_validator_list
)
grouped, app = parse_contact_info(v)
grouped_data[app] += grouped
w.update(
{
"Shards": shards,
"Group": app,
"Smartstake Summary": ss_address,
"Smartstake BlsKeys": ss_blskeys,
}
)
if w not in csv_data:
(
grouped_data,
social_media_contacts,
) = parse_google_docs_contact_info(v, grouped_data)
w.update(social_media_contacts)
csv_data.append(w)
save_csv(
latest_version,
fn,
csv_data,
[x for x in csv_data[0].keys()],
)
display_stats = (
active_validators,
is_updated,
not_updated,
elected,
elected_is_updated,
elected_not_updated,
unknown,
elected_unknown,
display_check,
)
save_and_display(
latest_version,
result,
grouped_data,
display_stats,
display_blskey_stats,
save_json_data=save_json_data,
)
return True
if __name__ == "__main__":
latest_version = latest_node_version.split("-")[1]
create_folders_change_handler(latest_version)
c = 1
while 1:
log.info(f"{c}) Attempting to get data...")
res = validator_node_version(
node_version_fn,
latest_version,
grouped_data,
num_pages=100,
save_json_data=True,
check_wallet=check_wallet,
)
if res:
break
else:
log.error("Unable to connect. sleeping for 10 seconds then retrying.. ")
sleep(1)
c += 1