From 5bf19e453cd2ff5fbfea07e6e82b4fa2d5b94b2c Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 1 Jul 2025 10:11:26 +0900 Subject: [PATCH 1/4] fix displaying active_validator_groups when they are 0 --- mytonctrl/mytonctrl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index b9fc178a..be3d5e0d 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -774,7 +774,7 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, active_validator_groups = None - if ton.using_validator() and validator_status.validator_groups_master and validator_status.validator_groups_shard: + if ton.using_validator() and validator_status.validator_groups_master is not None and validator_status.validator_groups_shard is not None: active_validator_groups = local.translate("active_validator_groups").format(validator_status.validator_groups_master, validator_status.validator_groups_shard) collated, validated = None, None From 871c095a765ee2041fe137cc0445098fbdb5c5bb Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 1 Jul 2025 12:27:52 +0900 Subject: [PATCH 2/4] fix getting node stats --- mytoncore/mytoncore.py | 22 +++++++++++----------- mytonctrl/mytonctrl.py | 26 ++++++++++++++------------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 514e17bb..8bcd30f9 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -3061,17 +3061,17 @@ def get_node_statistics(self): stats = self.local.db.get('statistics', {}).get('node') result = {} if stats is not None and len(stats) == 3 and stats[0] is not None: - for k in ['master', 'shard']: - result = { - 'collated': { - 'ok': 0, - 'error': 0, - }, - 'validated': { - 'ok': 0, - 'error': 0, - } + result = { + 'collated': { + 'ok': 0, + 'error': 0, + }, + 'validated': { + 'ok': 0, + 'error': 0, } + } + for k in ['master', 'shard']: collated_ok = stats[2]['collated_blocks'][k]['ok'] - stats[0]['collated_blocks'][k]['ok'] collated_error = stats[2]['collated_blocks'][k]['error'] - stats[0]['collated_blocks'][k]['error'] validated_ok = stats[2]['validated_blocks'][k]['ok'] - stats[0]['validated_blocks'][k]['ok'] @@ -3088,7 +3088,7 @@ def get_node_statistics(self): result['collated']['error'] += collated_error result['validated']['ok'] += validated_ok result['validated']['error'] += validated_error - if stats is not None and len(stats) >= 2 and stats[0] is not None: + if stats is not None and len(stats) >= 2 and stats[-2] is not None and stats[-1] is not None: result['ls_queries'] = { 'ok': stats[-1]['ls_queries']['ok'] - stats[-2]['ls_queries']['ok'], 'error': stats[-1]['ls_queries']['error'] - stats[-2]['ls_queries']['error'], diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index be3d5e0d..7165ebe5 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -779,18 +779,20 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, collated, validated = None, None ls_queries = None - if ton.using_validator(): - node_stats = ton.get_node_statistics() - if node_stats and 'collated' in node_stats and 'validated' in node_stats: - collated = local.translate('collated_blocks').format(node_stats['collated']['ok'], node_stats['collated']['error']) - validated = local.translate('validated_blocks').format(node_stats['validated']['ok'], node_stats['validated']['error']) - else: - collated = local.translate('collated_blocks').format('collecting data...', 'wait for the next validation round') - validated = local.translate('validated_blocks').format('collecting data...', 'wait for the next validation round') - if ton.using_liteserver(): - node_stats = ton.get_node_statistics() - if node_stats and 'ls_queries' in node_stats: - ls_queries = local.translate('ls_queries').format(node_stats['ls_queries']['time'], node_stats['ls_queries']['ok'], node_stats['ls_queries']['error']) + node_stats = local.try_function(ton.get_node_statistics) + if node_stats is not None: + if ton.using_validator(): + if 'collated' in node_stats and 'validated' in node_stats: + collated = local.translate('collated_blocks').format(node_stats['collated']['ok'], node_stats['collated']['error']) + validated = local.translate('validated_blocks').format(node_stats['validated']['ok'], node_stats['validated']['error']) + else: + collated = local.translate('collated_blocks').format('collecting data...', 'wait for the next validation round') + validated = local.translate('validated_blocks').format('collecting data...', 'wait for the next validation round') + if ton.using_liteserver(): + if 'ls_queries' in node_stats: + ls_queries = local.translate('ls_queries').format(node_stats['ls_queries']['time'], node_stats['ls_queries']['ok'], node_stats['ls_queries']['error']) + else: + local.add_log("Failed to get node statistics", "warning") dbSize_text = GetColorInt(dbSize, 1000, logic="less", ending=" Gb") dbUsage_text = GetColorInt(dbUsage, 80, logic="less", ending="%") From 9550d3bdcfa178306fbf41d9a4a7f477e147fc79 Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 2 Jul 2025 11:35:32 +0900 Subject: [PATCH 3/4] reduce config34 cache, add no_cache config34 in node stats --- mytoncore/functions.py | 2 +- mytoncore/mytoncore.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mytoncore/functions.py b/mytoncore/functions.py index 8899e4d3..947e3287 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -317,7 +317,7 @@ def get_ok_error(value: str): # statistics['node'] = [stats_from_election_id, stats_from_prev_min, stats_now] - election_id = ton.GetConfig34()['startWorkTime'] + election_id = ton.GetConfig34(no_cache=True)['startWorkTime'] if 'node' not in statistics or len(statistics['node']) == 0: statistics['node'] = [None, data] elif len(statistics['node']) < 3: diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 8bcd30f9..1240b311 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -930,11 +930,11 @@ def GetConfig32(self): return config32 #end define - def GetConfig34(self): + def GetConfig34(self, no_cache: bool = False): # Get buffer bname = "config34" - buff = self.GetFunctionBuffer(bname, timeout=60) - if buff: + buff = self.GetFunctionBuffer(bname, timeout=10) + if buff and not no_cache: return buff #end if From 0cafaf874745d8549b1cc0a233997055d4654383 Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 2 Jul 2025 21:17:03 +0900 Subject: [PATCH 4/4] improve saving node stats --- mytoncore/functions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mytoncore/functions.py b/mytoncore/functions.py index 947e3287..72dc273e 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -328,9 +328,11 @@ def get_ok_error(value: str): statistics['node'][0] = data elif statistics['node'][0]['timestamp'] < election_id: statistics['node'][0] = data - statistics['node'] = statistics.get('node', []) + [data] - statistics['node'].pop(1) + temp = statistics.get('node', []) + [data] + temp.pop(1) + statistics['node'] = temp local.db["statistics"] = statistics + local.save() def ReadTransData(local, scanner):