Skip to content

Commit cfaf34b

Browse files
authored
Merge pull request #29 from ton-blockchain/dev
Merge Dev to Btc Teleport
2 parents 8e59023 + 673866d commit cfaf34b

File tree

6 files changed

+50
-36
lines changed

6 files changed

+50
-36
lines changed

mytoncore/functions.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,25 +318,35 @@ def get_ok_error(value: str):
318318
data['ls_queries']['error'] = int(k.split(':')[1])
319319
statistics = local.db.get("statistics", dict())
320320

321-
if time.time() - int(status.start_time) <= 60: # was node restart <60 sec ago, resetting node statistics
321+
# if time.time() - int(status.start_time) <= 60: # was node restart <60 sec ago, resetting node statistics
322+
# statistics['node'] = []
323+
324+
if 'node' not in statistics:
322325
statistics['node'] = []
323326

324-
# statistics['node'] = [stats_from_election_id, stats_from_prev_min, stats_now]
327+
if statistics['node']:
328+
if int(status.start_time) > statistics['node'][-1]['timestamp']:
329+
# node was restarted, reset node statistics
330+
statistics['node'] = []
331+
332+
# statistics['node']: [stats_from_election_id, stats_from_prev_min, stats_now]
325333

326-
election_id = ton.GetConfig34()['startWorkTime']
327-
if 'node' not in statistics or len(statistics['node']) == 0:
334+
election_id = ton.GetConfig34(no_cache=True)['startWorkTime']
335+
if len(statistics['node']) == 0:
328336
statistics['node'] = [None, data]
329337
elif len(statistics['node']) < 3:
330338
statistics['node'].append(data)
331-
if len(statistics['node']) == 3:
339+
elif len(statistics['node']) == 3:
332340
if statistics['node'][0] is None:
333341
if 0 < data['timestamp'] - election_id < 90:
334342
statistics['node'][0] = data
335343
elif statistics['node'][0]['timestamp'] < election_id:
336344
statistics['node'][0] = data
337-
statistics['node'] = statistics.get('node', []) + [data]
338-
statistics['node'].pop(1)
345+
temp = statistics.get('node', []) + [data]
346+
temp.pop(1)
347+
statistics['node'] = temp
339348
local.db["statistics"] = statistics
349+
local.save()
340350

341351

342352
def ReadTransData(local, scanner):

mytoncore/mytoncore.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -931,11 +931,11 @@ def GetConfig32(self):
931931
return config32
932932
#end define
933933

934-
def GetConfig34(self):
934+
def GetConfig34(self, no_cache: bool = False):
935935
# Get buffer
936936
bname = "config34"
937-
buff = self.GetFunctionBuffer(bname, timeout=60)
938-
if buff:
937+
buff = self.GetFunctionBuffer(bname, timeout=10)
938+
if buff and not no_cache:
939939
return buff
940940
#end if
941941

@@ -3062,17 +3062,17 @@ def get_node_statistics(self):
30623062
stats = self.local.db.get('statistics', {}).get('node')
30633063
result = {}
30643064
if stats is not None and len(stats) == 3 and stats[0] is not None:
3065-
for k in ['master', 'shard']:
3066-
result = {
3067-
'collated': {
3068-
'ok': 0,
3069-
'error': 0,
3070-
},
3071-
'validated': {
3072-
'ok': 0,
3073-
'error': 0,
3074-
}
3065+
result = {
3066+
'collated': {
3067+
'ok': 0,
3068+
'error': 0,
3069+
},
3070+
'validated': {
3071+
'ok': 0,
3072+
'error': 0,
30753073
}
3074+
}
3075+
for k in ['master', 'shard']:
30763076
collated_ok = stats[2]['collated_blocks'][k]['ok'] - stats[0]['collated_blocks'][k]['ok']
30773077
collated_error = stats[2]['collated_blocks'][k]['error'] - stats[0]['collated_blocks'][k]['error']
30783078
validated_ok = stats[2]['validated_blocks'][k]['ok'] - stats[0]['validated_blocks'][k]['ok']
@@ -3089,7 +3089,7 @@ def get_node_statistics(self):
30893089
result['collated']['error'] += collated_error
30903090
result['validated']['ok'] += validated_ok
30913091
result['validated']['error'] += validated_error
3092-
if stats is not None and len(stats) >= 2 and stats[0] is not None:
3092+
if stats is not None and len(stats) >= 2 and stats[-2] is not None and stats[-1] is not None:
30933093
result['ls_queries'] = {
30943094
'ok': stats[-1]['ls_queries']['ok'] - stats[-2]['ls_queries']['ok'],
30953095
'error': stats[-1]['ls_queries']['error'] - stats[-2]['ls_queries']['error'],

mytonctrl/mytonctrl.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -801,23 +801,25 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency,
801801

802802
active_validator_groups = None
803803

804-
if ton.using_validator() and validator_status.validator_groups_master and validator_status.validator_groups_shard:
804+
if ton.using_validator() and validator_status.validator_groups_master is not None and validator_status.validator_groups_shard is not None:
805805
active_validator_groups = local.translate("active_validator_groups").format(validator_status.validator_groups_master, validator_status.validator_groups_shard)
806806

807807
collated, validated = None, None
808808
ls_queries = None
809-
if ton.using_validator():
810-
node_stats = ton.get_node_statistics()
811-
if node_stats and 'collated' in node_stats and 'validated' in node_stats:
812-
collated = local.translate('collated_blocks').format(node_stats['collated']['ok'], node_stats['collated']['error'])
813-
validated = local.translate('validated_blocks').format(node_stats['validated']['ok'], node_stats['validated']['error'])
814-
else:
815-
collated = local.translate('collated_blocks').format('collecting data...', 'wait for the next validation round')
816-
validated = local.translate('validated_blocks').format('collecting data...', 'wait for the next validation round')
817-
if ton.using_liteserver():
818-
node_stats = ton.get_node_statistics()
819-
if node_stats and 'ls_queries' in node_stats:
820-
ls_queries = local.translate('ls_queries').format(node_stats['ls_queries']['time'], node_stats['ls_queries']['ok'], node_stats['ls_queries']['error'])
809+
node_stats = local.try_function(ton.get_node_statistics)
810+
if node_stats is not None:
811+
if ton.using_validator():
812+
if 'collated' in node_stats and 'validated' in node_stats:
813+
collated = local.translate('collated_blocks').format(node_stats['collated']['ok'], node_stats['collated']['error'])
814+
validated = local.translate('validated_blocks').format(node_stats['validated']['ok'], node_stats['validated']['error'])
815+
else:
816+
collated = local.translate('collated_blocks').format('collecting data...', 'wait for the next validation round')
817+
validated = local.translate('validated_blocks').format('collecting data...', 'wait for the next validation round')
818+
if ton.using_liteserver():
819+
if 'ls_queries' in node_stats:
820+
ls_queries = local.translate('ls_queries').format(node_stats['ls_queries']['time'], node_stats['ls_queries']['ok'], node_stats['ls_queries']['error'])
821+
else:
822+
local.add_log("Failed to get node statistics", "warning")
821823

822824
dbSize_text = GetColorInt(dbSize, 1000, logic="less", ending=" Gb")
823825
dbUsage_text = GetColorInt(dbUsage, 80, logic="less", ending="%")

mytonctrl/scripts/upgrade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export CCACHE_DISABLE=1
8383

8484
# Update binary
8585
cd ${bindir}/${repo}
86-
ls --hide=global.config.json | xargs -d '\n' rm -rf
86+
ls --hide="*.config.json" | xargs -d '\n' rm -rf
8787
rm -rf .ninja_*
8888
memory=$(cat /proc/meminfo | grep MemAvailable | awk '{print $2}')
8989
cpuNumber=$(cat /proc/cpuinfo | grep "processor" | wc -l)

mytoninstaller/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def FirstNodeSettings(local):
5353
if os.getenv('STATE_TTL'):
5454
state_ttl = int(os.getenv('STATE_TTL'))
5555
archive_ttl -= state_ttl
56+
if archive_ttl == 0:
57+
archive_ttl = 1 # todo: remove this when archive_ttl==0 will be allowed in node
5658

5759
# Проверить конфигурацию
5860
if os.path.isfile(vconfig_path):

scripts/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def run_install(answers: dict):
206206
os.environ['ADD_SHARD'] = add_shard
207207
if archive_blocks:
208208
os.environ['ARCHIVE_BLOCKS'] = archive_blocks
209-
command += ['-v', 'testnet']
209+
command += ['-v', 'master']
210210

211211
if validator_mode and validator_mode not in ('Skip', 'Validator wallet'):
212212
if validator_mode == 'Nominator pool':

0 commit comments

Comments
 (0)