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
915 changes: 708 additions & 207 deletions Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config/internal_config_alerts.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ EscrowAddEventSelfOwner=true
EscrowAddEventSelfEscrow=true
EscrowReclaimEventSelfOwner=true
EscrowReclaimEventSelfEscrow=true
AllowanceChangeAlert=true
UnknownEventFound=true

[finalized_block_height_alerts_enabled_disabled]
Expand Down
23 changes: 20 additions & 3 deletions src/alerters/reactive/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def load_state(self, logger: logging.Logger) -> None:
'_debonding_balance=%s, _shares_balance=%s, _is_syncing=%s, '
'_no_of_peers=%s, _active=%s, _no_of_blocks_missed=%s, '
'_time_of_last_height_change=%s, '
'_time_of_last_height_check_activity, '
'_time_of_last_height_check_activity=%s, '
'_finalized_block_height=%s, '
'_no_change_in_height_warning_sent=%s, '
'_is_missing_blocks=%s ',
Expand All @@ -312,7 +312,7 @@ def save_state(self, logger: logging.Logger) -> None:
'_debonding_balance=%s, _shares_balance=%s, _is_syncing=%s, '
'_no_of_peers=%s, _active=%s, _no_of_blocks_missed=%s, '
'_time_of_last_height_change=%s, '
'_time_of_last_height_check_activity, '
'_time_of_last_height_check_activity=%s, '
'_finalized_block_height=%s, '
'_no_change_in_height_warning_sent=%s, '
'_is_missing_blocks=%s',
Expand Down Expand Up @@ -844,8 +844,25 @@ def process_event(self, event_height: str, event: dict,
tokens,
event_height,
source))

elif self._check_dict_path(event, 'allowance_change'):
if event['allowance_change']['owner'] == self.entity_public_key:
beneficiary = event['allowance_change']['beneficiary']
new_allowance = event['allowance_change']['allowance']
amount_change = event['allowance_change']['amount_change']
reduced = event['allowance_change']['negative']

logger.info('%s Node %s allowance_change %s tokens at height %s. New allowance %s, reduced: %s, beneficiary: %s',
self, self.name, amount_change, event_height, new_allowance, reduced, beneficiary)
channels.alert_critical(AllowanceChangeAlert(
self.name,
amount_change,
reduced,
beneficiary,
new_allowance,
event_height))
else:
logger.debug('%s Node received unknown event : %s', self, self.name,
logger.debug('%s Node %s received unknown event : %s', self, self.name,
event)
channels.alert_warning(UnknownEventFound(
self.name,
Expand Down
9 changes: 9 additions & 0 deletions src/alerts/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class AlertCode(Enum):
EscrowAddEventSelfEscrow = _next_id(),
EscrowReclaimEventSelfOwner = _next_id(),
EscrowReclaimEventSelfEscrow = _next_id(),
AllowanceChangeAlert = _next_id(),
UnknownEventFound = _next_id(),
DebondingBalanceIncreasedAlert = _next_id(),
DebondingBalanceDecreasedAlert = _next_id(),
Expand Down Expand Up @@ -700,6 +701,14 @@ def __init__(self, node: str, old_balance: float, new_balance: float) \
'{} total shares balance DECREASED by {} from {} to {}.'.format(
node, change, old_balance, new_balance))

class AllowanceChangeAlert(Alert):

def __init__(self, node: str, amount_change: float, reduced: bool, beneficiary: str, new_allowance: str, height: int) \
-> None:
super().__init__(
AlertCode.AllowanceChangeAlert,
'{} allowance changed by {}. Reduction: {}. New allowance: {}. Beneficiary: {}. Height: {}'.format(
node, amount_change, reduced, new_allowance, beneficiary, height))

class NewProcessCPUSecondsTotalAlert(Alert):

Expand Down
2 changes: 1 addition & 1 deletion src/monitors/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def save_state(self) -> None:
key_alive = Keys.get_node_monitor_alive(self.monitor_name)

self.logger.debug(
'Saving node monitor state: %s=%s', self._monitor_name,
'Saving node monitor state: %s=%s, _last_height_checked=%s', self._monitor_name,
key_lh, self._last_height_checked)

# Set last height checked key
Expand Down
10 changes: 5 additions & 5 deletions src/monitors/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def monitor(self) -> None:

process_memory_usage = float("{:.2f}".format(process_memory_usage))

self._logger.debug('%s process_memory_usage: %s%', self.system,
self._logger.debug('%s process_memory_usage: %s', self.system,
process_memory_usage)

self.system.set_process_memory_usage(process_memory_usage, \
Expand All @@ -111,7 +111,7 @@ def monitor(self) -> None:
open_file_descriptors = float("{:.2f}".format( \
open_file_descriptors))

self._logger.debug('%s open_file_descriptors: %s%', self.system,
self._logger.debug('%s open_file_descriptors: %s', self.system,
open_file_descriptors)

self.system.set_open_file_descriptors(open_file_descriptors, \
Expand All @@ -134,7 +134,7 @@ def monitor(self) -> None:

system_cpu_usage = float("{:.2f}".format(system_cpu_usage))

self._logger.debug('%s system_cpu_usage: %s%', self.system,
self._logger.debug('%s system_cpu_usage: %s', self.system,
system_cpu_usage)

self.system.set_system_cpu_usage(system_cpu_usage, \
Expand All @@ -151,7 +151,7 @@ def monitor(self) -> None:

system_ram_usage = float("{:.2f}".format(system_ram_usage))

self._logger.debug('%s system_ram_usage: %s%', self.system,
self._logger.debug('%s system_ram_usage: %s', self.system,
system_ram_usage)

self.system.set_system_ram_usage(system_ram_usage, \
Expand All @@ -178,7 +178,7 @@ def monitor(self) -> None:

system_storage_usage = float("{:.2f}".format(system_storage_usage))

self._logger.debug('%s system_storage_usage: %s%', self.system,
self._logger.debug('%s system_storage_usage: %s', self.system,
system_storage_usage)

self.system.set_system_storage_usage(system_storage_usage, \
Expand Down
1 change: 0 additions & 1 deletion src/web/ui/sessions/6SNN1tXtPi_uuoiqsJE4zVP5_dzuhnAF.json

This file was deleted.

1 change: 0 additions & 1 deletion src/web/ui/sessions/H9INBn2wk_ghcUAZKrXiQBl2LeMfDgA4.json

This file was deleted.

1 change: 0 additions & 1 deletion src/web/ui/sessions/M58GQsut-Sfc2mbRPY6cNJ_7H2ljvfHa.json

This file was deleted.

1 change: 0 additions & 1 deletion src/web/ui/sessions/tuJf7IfKZwryDarIBL5Meez6suTiibiP.json

This file was deleted.

1 change: 1 addition & 0 deletions src/web/ui/src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const ALERTS_CONFIG_ALERT_NAMES = {
EscrowAddEventSelfEscrow: 'Escrow add event when self is escrow',
EscrowReclaimEventSelfOwner: 'Escrow reclaim event when self is owner',
EscrowReclaimEventSelfEscrow: 'Escrow reclaim event when self is escrow',
AllowanceChangeAlert: 'Change of token allowance given to paratime',
UnknownEventFound: 'Unknown event has been found',
NodeFinalizedBlockHeightDidNotChangeInAlert: 'Finalized height not updating',
NodeFinalizedBlockHeightHasNowBeenUpdatedAlert: 'Finalized height updated',
Expand Down
1 change: 1 addition & 0 deletions test/test_internal_config_alerts.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ EscrowAddEventSelfOwner=true
EscrowAddEventSelfEscrow=true
EscrowReclaimEventSelfOwner=true
EscrowReclaimEventSelfEscrow=true
AllowanceChangeAlert=true
UnknownEventFound=true

[finalized_block_height_alerts_enabled_disabled]
Expand Down
1 change: 1 addition & 0 deletions test/test_internal_config_alerts_all_enabled.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ EscrowAddEventSelfOwner=true
EscrowAddEventSelfEscrow=true
EscrowReclaimEventSelfOwner=true
EscrowReclaimEventSelfEscrow=true
AllowanceChangeAlert=true
UnknownEventFound=true

[finalized_block_height_alerts_enabled_disabled]
Expand Down
1 change: 1 addition & 0 deletions test/test_internal_config_alerts_some_disabled.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ EscrowAddEventSelfOwner=true
EscrowAddEventSelfEscrow=true
EscrowReclaimEventSelfOwner=true
EscrowReclaimEventSelfEscrow=true
AllowanceChangeAlert=true
UnknownEventFound=true

[finalized_block_height_alerts_enabled_disabled]
Expand Down