Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,57 @@
# make sure that it obeys the subnet rules inside the docker-compose.yml file

# UI IP configuration
UI_ACCESS_IP=X.X.X.X
UI_ACCESS_IP=1.1.1.1

# Development configuration
DEV_MODE=false
DEV_MODE=true

# Mongo configuration
DB_NAME=panicdb

DB_PORT=27017

DB_IP_REPLICA_1=172.18.0.2
DB_IP_REPLICA_1_TEST=172.19.0.2
DB_IP_REPLICA_1_TEST=172.18.0.2

DB_IP_REPLICA_2=172.18.0.3
DB_IP_REPLICA_2_TEST=172.19.0.3
DB_IP_REPLICA_2_TEST=172.18.0.3

DB_IP_REPLICA_3=172.18.0.4
DB_IP_REPLICA_3_TEST=172.19.0.4
DB_IP_REPLICA_3_TEST=172.18.0.4

DB_IP_REPLICA_STARTUP=172.18.0.5
DB_IP_REPLICA_STARTUP_TEST=172.19.0.5
DB_IP_REPLICA_STARTUP_TEST=172.18.0.5

# Alerter configuration
ALERTER_IP=172.18.0.7
UNIQUE_ALERTER_IDENTIFIER=panic_alerter

# Redis configuration
REDIS_IP=172.18.0.8
REDIS_IP_TEST=172.19.0.8
REDIS_IP_TEST=172.18.0.8
REDIS_PORT=6379
REDIS_DB=10
REDIS_DB_TEST=11

# RabbitMQ configuration
RABBIT_IP=172.18.0.9
RABBIT_IP_TEST=172.19.0.9
RABBIT_IP_TEST=172.18.0.9
RABBIT_PORT=5672

# Health Checker configuration
HEALTH_CHECKER_IP=172.18.0.10

# Tests configuration
TESTS_IP=172.19.0.11
TESTS_IP=172.18.0.11

# UI configuration
UI_DASHBOARD_IP=172.18.0.12
UI_DASHBOARD_PORT=3333

# API configuration
API_IP=172.18.0.13
API_IP_TEST=172.19.0.13
API_IP_TEST=172.18.0.13
API_PORT=9000
API_PORT_TEST=9001

Expand Down Expand Up @@ -122,4 +122,4 @@ ENABLE_LOG_ALERTS=True

# Twilio Preferences
TWIML=<Response><Reject/></Response>
TWIML_IS_URL=false
TWIML_IS_URL=false
4 changes: 2 additions & 2 deletions alerter/src/alerter/alerts/network/cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def __init__(self, origin_name: str, proposal_id: int, title: str,
"No votes: {}\n"
"No with veto votes: {}\n"
).format(proposal_id, status, origin_name, title,
final_tally_result['yes'], final_tally_result['abstain'],
final_tally_result['no'], final_tally_result['no_with_veto'])
final_tally_result['yes_count'], final_tally_result['abstain_count'],
final_tally_result['no_count'], final_tally_result['no_with_veto_count'])
super().__init__(
AlertCode.ProposalConcludedAlert, alert_msg,
severity, timestamp, parent_id, origin_id,
Expand Down
61 changes: 59 additions & 2 deletions alerter/src/api_wrappers/cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ def __init__(self, logger: logging.Logger, verify: bool = False,
def get_syncing(self, cosmos_rest_url: str) -> Dict:
"""
This function retrieves data from the cosmos_rest_url/syncing endpoint,
and is compatible with both v0.39.2 and v0.42.6 of the Cosmos SDK
and is *NOT* compatible with both v0.39.2 and v0.42.6,
but *ONLY* compatible with v0.50.1 of the Cosmos SDK
:param cosmos_rest_url: The Cosmos REST url of the data source
:return: Retrieves data from the cosmos_rest_url/syncing endpoint
"""
endpoint = cosmos_rest_url + '/syncing'
endpoint = cosmos_rest_url + '/cosmos/base/tendermint/v1beta1/syncing'
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
verify=self.verify, timeout=self.timeout)

Expand Down Expand Up @@ -87,6 +88,34 @@ def get_staking_validators_v0_42_6(
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
params=params, verify=self.verify,
timeout=self.timeout)

def get_staking_validators_v0_50_1(
self, cosmos_rest_url: str, validator_address: str = None,
params: Dict = None) -> Dict:
"""
This function retrieves data from the
cosmos_rest_url/cosmos/staking/v1beta1/validators and
cosmos_rest_url/cosmos/staking/v1beta1/validators/{validatorAddr}
endpoints, depending on the inputted function parameters. Note that this
function is only compatible with v0.50.1 of the Cosmos SDK, for other
versions unexpected behaviour might occur.
:param cosmos_rest_url: The Cosmos REST url of the data source
:param params: Parameters that need to be added to the endpoint
:param validator_address: The address of the validator you want to query
:return: Retrieves data from the
: cosmos_rest_url/cosmos/staking/v1beta1/validators or
: cosmos_rest_url/cosmos/staking/v1beta1/validators/{
: validatorAddr} endpoints
"""
cosmos_fn = (
'/cosmos/staking/v1beta1/validators' if validator_address is None
else '/cosmos/staking/v1beta1/validators/{}'.format(
validator_address)
)
endpoint = cosmos_rest_url + cosmos_fn
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
params=params, verify=self.verify,
timeout=self.timeout)

def get_proposals_v0_39_2(
self, cosmos_rest_url: str, proposal_id: int = None,
Expand Down Expand Up @@ -137,6 +166,34 @@ def get_proposals_v0_42_6(
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
params=params, verify=self.verify,
timeout=self.timeout)

def get_proposals_v0_50_1(
self, cosmos_rest_url: str, proposal_id: int = None,
params: Dict = None) -> Dict:
"""
This function retrieves data from the
cosmos_rest_url/cosmos/gov/v1beta1/proposals and
cosmos_rest_url/cosmos/gov/v1beta1/proposals/{proposalId}
endpoints, depending on the inputted function parameters. Note that this
function is only compatible with v0.50.1 of the Cosmos SDK, for other
versions unexpected behaviour might occur.
:param cosmos_rest_url: The Cosmos REST url of the data source
:param params: Parameters that need to be added to the endpoint
:param proposal_id: The ID of the proposal you want to query
:return: Retrieves data from the
: cosmos_rest_url/cosmos/gov/v1beta1/proposals or
: cosmos_rest_url/cosmos/gov/v1beta1/proposals/{
: proposalId} endpoints
"""
cosmos_fn = (
'/cosmos/gov/v1/proposals' if proposal_id is None
else '/cosmos/gov/v1/proposals/{}'.format(
proposal_id)
)
endpoint = cosmos_rest_url + cosmos_fn
return get_cosmos_json(endpoint=endpoint, logger=self.logger,
params=params, verify=self.verify,
timeout=self.timeout)

def execute_with_checks(self, function, args: List[Any],
node_name: str, sdk_version: str) -> Any:
Expand Down
8 changes: 4 additions & 4 deletions alerter/src/monitorables/networks/cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def _are_new_proposals_valid(new_proposals: List[Dict]) -> bool:
'description': str,
'status': str,
'final_tally_result': {
'yes': Or(float, None),
'abstain': Or(float, None),
'no': Or(float, None),
'no_with_veto': Or(float, None),
'yes_count': Or(float, None),
'abstain_count': Or(float, None),
'no_count': Or(float, None),
'no_with_veto_count': Or(float, None),
},
'submit_time': float,
'deposit_end_time': float,
Expand Down
3 changes: 2 additions & 1 deletion alerter/src/monitors/cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

_REST_VERSION_COSMOS_SDK_0_39_2 = 'v0.39.2'
_REST_VERSION_COSMOS_SDK_0_42_6 = 'v0.42.6'
_REST_VERSION_COSMOS_SDK_0_50_1 = 'v0.50.1'
_VERSION_INCOMPATIBILITY_EXCEPTIONS = [
IncorrectJSONRetrievedException, CosmosSDKVersionIncompatibleException,
TendermintRPCIncompatibleException
Expand All @@ -48,7 +49,7 @@ def __init__(self, monitor_name: str, data_sources: List[CosmosNodeConfig],

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

@property
def data_sources(self) -> List[CosmosNodeConfig]:
Expand Down
Loading