Skip to content

Commit 4da8daf

Browse files
authored
Merge pull request #1 from VogonAnthology/master
COSMOS SDK v0.50.1
2 parents 6e8c4fc + 235007e commit 4da8daf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+8575
-7316
lines changed

.env

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,57 @@
88
# make sure that it obeys the subnet rules inside the docker-compose.yml file
99

1010
# UI IP configuration
11-
UI_ACCESS_IP=X.X.X.X
11+
UI_ACCESS_IP=1.1.1.1
1212

1313
# Development configuration
14-
DEV_MODE=false
14+
DEV_MODE=true
1515

1616
# Mongo configuration
1717
DB_NAME=panicdb
1818

1919
DB_PORT=27017
2020

2121
DB_IP_REPLICA_1=172.18.0.2
22-
DB_IP_REPLICA_1_TEST=172.19.0.2
22+
DB_IP_REPLICA_1_TEST=172.18.0.2
2323

2424
DB_IP_REPLICA_2=172.18.0.3
25-
DB_IP_REPLICA_2_TEST=172.19.0.3
25+
DB_IP_REPLICA_2_TEST=172.18.0.3
2626

2727
DB_IP_REPLICA_3=172.18.0.4
28-
DB_IP_REPLICA_3_TEST=172.19.0.4
28+
DB_IP_REPLICA_3_TEST=172.18.0.4
2929

3030
DB_IP_REPLICA_STARTUP=172.18.0.5
31-
DB_IP_REPLICA_STARTUP_TEST=172.19.0.5
31+
DB_IP_REPLICA_STARTUP_TEST=172.18.0.5
3232

3333
# Alerter configuration
3434
ALERTER_IP=172.18.0.7
3535
UNIQUE_ALERTER_IDENTIFIER=panic_alerter
3636

3737
# Redis configuration
3838
REDIS_IP=172.18.0.8
39-
REDIS_IP_TEST=172.19.0.8
39+
REDIS_IP_TEST=172.18.0.8
4040
REDIS_PORT=6379
4141
REDIS_DB=10
4242
REDIS_DB_TEST=11
4343

4444
# RabbitMQ configuration
4545
RABBIT_IP=172.18.0.9
46-
RABBIT_IP_TEST=172.19.0.9
46+
RABBIT_IP_TEST=172.18.0.9
4747
RABBIT_PORT=5672
4848

4949
# Health Checker configuration
5050
HEALTH_CHECKER_IP=172.18.0.10
5151

5252
# Tests configuration
53-
TESTS_IP=172.19.0.11
53+
TESTS_IP=172.18.0.11
5454

5555
# UI configuration
5656
UI_DASHBOARD_IP=172.18.0.12
5757
UI_DASHBOARD_PORT=3333
5858

5959
# API configuration
6060
API_IP=172.18.0.13
61-
API_IP_TEST=172.19.0.13
61+
API_IP_TEST=172.18.0.13
6262
API_PORT=9000
6363
API_PORT_TEST=9001
6464

@@ -122,4 +122,4 @@ ENABLE_LOG_ALERTS=True
122122

123123
# Twilio Preferences
124124
TWIML=<Response><Reject/></Response>
125-
TWIML_IS_URL=false
125+
TWIML_IS_URL=false

alerter/src/alerter/alerts/network/cosmos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def __init__(self, origin_name: str, proposal_id: int, title: str,
4242
"No votes: {}\n"
4343
"No with veto votes: {}\n"
4444
).format(proposal_id, status, origin_name, title,
45-
final_tally_result['yes'], final_tally_result['abstain'],
46-
final_tally_result['no'], final_tally_result['no_with_veto'])
45+
final_tally_result['yes_count'], final_tally_result['abstain_count'],
46+
final_tally_result['no_count'], final_tally_result['no_with_veto_count'])
4747
super().__init__(
4848
AlertCode.ProposalConcludedAlert, alert_msg,
4949
severity, timestamp, parent_id, origin_id,

alerter/src/api_wrappers/cosmos.py

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ def __init__(self, logger: logging.Logger, verify: bool = False,
3030
def get_syncing(self, cosmos_rest_url: str) -> Dict:
3131
"""
3232
This function retrieves data from the cosmos_rest_url/syncing endpoint,
33-
and is compatible with both v0.39.2 and v0.42.6 of the Cosmos SDK
33+
and is *NOT* compatible with both v0.39.2 and v0.42.6,
34+
but *ONLY* compatible with v0.50.1 of the Cosmos SDK
3435
:param cosmos_rest_url: The Cosmos REST url of the data source
3536
:return: Retrieves data from the cosmos_rest_url/syncing endpoint
3637
"""
37-
endpoint = cosmos_rest_url + '/syncing'
38+
endpoint = cosmos_rest_url + '/cosmos/base/tendermint/v1beta1/syncing'
3839
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
3940
verify=self.verify, timeout=self.timeout)
4041

@@ -87,6 +88,34 @@ def get_staking_validators_v0_42_6(
8788
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
8889
params=params, verify=self.verify,
8990
timeout=self.timeout)
91+
92+
def get_staking_validators_v0_50_1(
93+
self, cosmos_rest_url: str, validator_address: str = None,
94+
params: Dict = None) -> Dict:
95+
"""
96+
This function retrieves data from the
97+
cosmos_rest_url/cosmos/staking/v1beta1/validators and
98+
cosmos_rest_url/cosmos/staking/v1beta1/validators/{validatorAddr}
99+
endpoints, depending on the inputted function parameters. Note that this
100+
function is only compatible with v0.50.1 of the Cosmos SDK, for other
101+
versions unexpected behaviour might occur.
102+
:param cosmos_rest_url: The Cosmos REST url of the data source
103+
:param params: Parameters that need to be added to the endpoint
104+
:param validator_address: The address of the validator you want to query
105+
:return: Retrieves data from the
106+
: cosmos_rest_url/cosmos/staking/v1beta1/validators or
107+
: cosmos_rest_url/cosmos/staking/v1beta1/validators/{
108+
: validatorAddr} endpoints
109+
"""
110+
cosmos_fn = (
111+
'/cosmos/staking/v1beta1/validators' if validator_address is None
112+
else '/cosmos/staking/v1beta1/validators/{}'.format(
113+
validator_address)
114+
)
115+
endpoint = cosmos_rest_url + cosmos_fn
116+
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
117+
params=params, verify=self.verify,
118+
timeout=self.timeout)
90119

91120
def get_proposals_v0_39_2(
92121
self, cosmos_rest_url: str, proposal_id: int = None,
@@ -137,6 +166,34 @@ def get_proposals_v0_42_6(
137166
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
138167
params=params, verify=self.verify,
139168
timeout=self.timeout)
169+
170+
def get_proposals_v0_50_1(
171+
self, cosmos_rest_url: str, proposal_id: int = None,
172+
params: Dict = None) -> Dict:
173+
"""
174+
This function retrieves data from the
175+
cosmos_rest_url/cosmos/gov/v1beta1/proposals and
176+
cosmos_rest_url/cosmos/gov/v1beta1/proposals/{proposalId}
177+
endpoints, depending on the inputted function parameters. Note that this
178+
function is only compatible with v0.50.1 of the Cosmos SDK, for other
179+
versions unexpected behaviour might occur.
180+
:param cosmos_rest_url: The Cosmos REST url of the data source
181+
:param params: Parameters that need to be added to the endpoint
182+
:param proposal_id: The ID of the proposal you want to query
183+
:return: Retrieves data from the
184+
: cosmos_rest_url/cosmos/gov/v1beta1/proposals or
185+
: cosmos_rest_url/cosmos/gov/v1beta1/proposals/{
186+
: proposalId} endpoints
187+
"""
188+
cosmos_fn = (
189+
'/cosmos/gov/v1/proposals' if proposal_id is None
190+
else '/cosmos/gov/v1/proposals/{}'.format(
191+
proposal_id)
192+
)
193+
endpoint = cosmos_rest_url + cosmos_fn
194+
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
195+
params=params, verify=self.verify,
196+
timeout=self.timeout)
140197

141198
def execute_with_checks(self, function, args: List[Any],
142199
node_name: str, sdk_version: str) -> Any:

alerter/src/monitorables/networks/cosmos.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ def _are_new_proposals_valid(new_proposals: List[Dict]) -> bool:
3131
'description': str,
3232
'status': str,
3333
'final_tally_result': {
34-
'yes': Or(float, None),
35-
'abstain': Or(float, None),
36-
'no': Or(float, None),
37-
'no_with_veto': Or(float, None),
34+
'yes_count': Or(float, None),
35+
'abstain_count': Or(float, None),
36+
'no_count': Or(float, None),
37+
'no_with_veto_count': Or(float, None),
3838
},
3939
'submit_time': float,
4040
'deposit_end_time': float,

alerter/src/monitors/cosmos.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
_REST_VERSION_COSMOS_SDK_0_39_2 = 'v0.39.2'
2727
_REST_VERSION_COSMOS_SDK_0_42_6 = 'v0.42.6'
28+
_REST_VERSION_COSMOS_SDK_0_50_1 = 'v0.50.1'
2829
_VERSION_INCOMPATIBILITY_EXCEPTIONS = [
2930
IncorrectJSONRetrievedException, CosmosSDKVersionIncompatibleException,
3031
TendermintRPCIncompatibleException
@@ -48,7 +49,7 @@ def __init__(self, monitor_name: str, data_sources: List[CosmosNodeConfig],
4849

4950
# This variable stores the latest REST version used to retrieve the
5051
# data. By default, it is set to v0.42.6 of the Cosmos SDK.
51-
self._last_rest_retrieval_version = _REST_VERSION_COSMOS_SDK_0_42_6
52+
self._last_rest_retrieval_version = _REST_VERSION_COSMOS_SDK_0_50_1
5253

5354
@property
5455
def data_sources(self) -> List[CosmosNodeConfig]:

0 commit comments

Comments
 (0)