Skip to content
Open
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
125 changes: 0 additions & 125 deletions .env

This file was deleted.

6 changes: 3 additions & 3 deletions alerter/Alerter_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ COPY ./ ./
WORKDIR ./alerter

# Install app dependencies
RUN pip3 install pipenv
RUN pipenv install --deploy --ignore-pipfile
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt

# Tool which waits for dependent containers
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait

CMD /wait && pipenv run python run_alerter.py
CMD /wait && python run_alerter.py
6 changes: 3 additions & 3 deletions alerter/Health_Checker_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ COPY ./ ./
WORKDIR ./alerter

# Install app dependencies
RUN pip3 install pipenv
RUN pipenv install --deploy --ignore-pipfile
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt

# Tool which waits for dependent containers
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait

CMD /wait && pipenv run python run_health_checker.py
CMD /wait && python run_health_checker.py
69 changes: 69 additions & 0 deletions alerter/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
setuptools
aiohttp==3.8.1
aiosignal==1.2.0
apscheduler==3.6.3
async-timeout==4.0.2
attrs==21.4.0
base58==2.1.1
bech32==1.2.0
bitarray==1.2.2
cachetools==4.2.2
certifi==2021.10.8
charset-normalizer==2.0.12
configparser==5.2.0
contextlib2==21.6.0
cytoolz==0.11.2
deprecated==1.2.13
eth-abi==2.1.1
eth-account==0.5.7
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.4
eth-rlp==0.2.1
eth-typing==2.3.0
eth-utils==1.10.0
frozenlist==1.3.0
hexbytes==0.2.2
idna==3.3
ipfshttpclient==0.8.0a2
jsonschema==3.2.0
lru-dict==1.1.7
multiaddr==0.0.9
multidict==6.0.2
netaddr==0.8.0
opsgenie-sdk==2.1.5
packaging==21.3
parsimonious==0.8.1
pdpyras==4.5.0
pika==1.2.0
prometheus-client==0.13.1
protobuf==3.19.4
pycryptodome==3.14.1
pyjwt==2.3.0
pymongo==3.12.1
pyparsing==3.0.7
pyrsistent==0.18.1
python-dateutil==2.8.2
python-telegram-bot==13.11
pytz==2021.3
pytz-deprecation-shim==0.1.0.post0
redis==4.1.4
requests==2.27.1
rlp==2.0.1
schema==0.7.5
six==1.16.0
slack-bolt==1.11.6
slack-sdk==3.15.2
tenacity==8.0.1
toolz==0.11.2
tornado==6.1
twilio==7.7.1
tzdata==2021.5
tzlocal==4.1
urllib3==1.26.8
varint==1.0.2
watchdog==2.1.6
web3==5.28.0
websockets==9.1
wrapt==1.14.0
yarl==1.7.2
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update inline documentation due to the fact that we are now supporting v50

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly between lines 14 and 24

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)
Comment on lines 30 to 40

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always tried to keep PANIC backwards compatible. I suggest that we follow a similar implementation to get_staking_validators where multiple versions are supported.


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