Skip to content

Commit 7d46dc7

Browse files
authored
Merge pull request #280 from yungwine/mytonctrl2_dev
dev
2 parents 69a87e6 + f511780 commit 7d46dc7

File tree

5 files changed

+38
-13
lines changed

5 files changed

+38
-13
lines changed

modules/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Setting:
5252
'fift_timeout': Setting(None, 3, 'Fift default timeout'),
5353
'useDefaultCustomOverlays': Setting(None, True, 'Participate in default custom overlays node eligible to'),
5454
'defaultCustomOverlaysUrl': Setting(None, 'https://ton-blockchain.github.io/fallback_custom_overlays.json', 'Default custom overlays config url'),
55+
'debug': Setting(None, False, 'Debug mtc console mode. Prints Traceback on errors'),
5556
}
5657

5758

modules/controller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ def print_controllers_list(self, args):
4848
old_controllers = self.ton.GetSettings("old_controllers")
4949
user_controllers_list = self.ton.GetSettings("user_controllers_list")
5050
print("using controllers:")
51-
self.print_controllers_list_process(using_controllers)
52-
if new_controllers != using_controllers:
51+
if using_controllers is not None:
52+
self.print_controllers_list_process(using_controllers)
53+
if new_controllers is not None and new_controllers != using_controllers:
5354
print()
5455
print("new controllers:")
5556
self.print_controllers_list_process(new_controllers)

mytonctrl/mytonctrl.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf_8 -*-
3+
import base64
34
import subprocess
45
import json
56
import psutil
@@ -293,13 +294,11 @@ def check_vport(local, ton):
293294
#end define
294295

295296

296-
def check_git(input_args, default_repo, text):
297+
def check_git(input_args, default_repo, text, default_branch='master'):
297298
src_dir = "/usr/src"
298299
git_path = f"{src_dir}/{default_repo}"
299300
fix_git_config(git_path)
300301
default_author = "ton-blockchain"
301-
# default_branch = "master"
302-
default_branch = "mytonctrl2"
303302

304303
# Get author, repo, branch
305304
local_author, local_repo = get_git_author_and_repo(git_path)
@@ -341,7 +340,7 @@ def check_branch_exists(author, repo, branch):
341340

342341
def Update(local, args):
343342
repo = "mytonctrl"
344-
author, repo, branch = check_git(args, repo, "update")
343+
author, repo, branch = check_git(args, repo, "update", default_branch='mytonctrl2')
345344

346345
# Run script
347346
update_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/update.sh')
@@ -381,6 +380,14 @@ def Upgrade(ton, args):
381380
upgrade_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/upgrade.sh')
382381
runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch]
383382
exitCode = run_as_root(runArgs)
383+
if ton.using_validator():
384+
try:
385+
from mytoninstaller.mytoninstaller import set_node_argument, get_node_args
386+
node_args = get_node_args()
387+
if node_args['--state-ttl'] == '604800':
388+
set_node_argument(ton.local, ["--state-ttl", "-d"])
389+
except Exception as e:
390+
color_print(f"{{red}}Failed to set node argument: {e} {{endc}}")
384391
if exitCode == 0:
385392
text = "Upgrade - {green}OK{endc}"
386393
else:
@@ -551,6 +558,13 @@ def PrintStatus(local, ton, args):
551558
disks_load_percent_avg = ton.GetStatistics("disksLoadPercentAvg", statistics)
552559

553560
all_status = validator_status.is_working == True and validator_status.out_of_sync < 20
561+
562+
try:
563+
vconfig = ton.GetValidatorConfig()
564+
fullnode_adnl = base64.b64decode(vconfig.fullnode).hex().upper()
565+
except:
566+
fullnode_adnl = 'n/a'
567+
554568
if all_status:
555569
network_name = ton.GetNetworkName()
556570
rootWorkchainEnabledTime_int = ton.GetRootWorkchainEnabledTime()
@@ -588,7 +602,7 @@ def PrintStatus(local, ton, args):
588602
if all_status:
589603
PrintTonStatus(local, network_name, startWorkTime, totalValidators, onlineValidators, shardsNumber, offersNumber, complaintsNumber, tpsAvg)
590604
PrintLocalStatus(local, adnl_addr, validator_index, validator_efficiency, validator_wallet, validator_account, validator_status,
591-
db_size, db_usage, memory_info, swap_info, net_load_avg, disks_load_avg, disks_load_percent_avg)
605+
db_size, db_usage, memory_info, swap_info, net_load_avg, disks_load_avg, disks_load_percent_avg, fullnode_adnl)
592606
if all_status:
593607
PrintTonConfig(local, fullConfigAddr, fullElectorAddr, config15, config17)
594608
PrintTimes(local, rootWorkchainEnabledTime_int, startWorkTime, oldStartWorkTime, config15)
@@ -638,7 +652,7 @@ def PrintTonStatus(local, network_name, startWorkTime, totalValidators, onlineVa
638652
print()
639653
#end define
640654

641-
def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, validatorWallet, validatorAccount, validator_status, dbSize, dbUsage, memoryInfo, swapInfo, netLoadAvg, disksLoadAvg, disksLoadPercentAvg):
655+
def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, validatorWallet, validatorAccount, validator_status, dbSize, dbUsage, memoryInfo, swapInfo, netLoadAvg, disksLoadAvg, disksLoadPercentAvg, fullnode_adnl):
642656
if validatorWallet is None:
643657
return
644658
walletAddr = validatorWallet.addrB64
@@ -657,6 +671,7 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
657671
validatorEfficiency_text = GetColorInt(validatorEfficiency, 10, logic="more", ending=" %")
658672
validatorEfficiency_text = local.translate("local_status_validator_efficiency").format(validatorEfficiency_text)
659673
adnlAddr_text = local.translate("local_status_adnl_addr").format(bcolors.yellow_text(adnlAddr))
674+
fullnode_adnl_text = local.translate("local_status_fullnode_adnl").format(bcolors.yellow_text(fullnode_adnl))
660675
walletAddr_text = local.translate("local_status_wallet_addr").format(bcolors.yellow_text(walletAddr))
661676
walletBalance_text = local.translate("local_status_wallet_balance").format(bcolors.green_text(walletBalance))
662677

@@ -716,7 +731,9 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
716731
mytoncoreStatus_text = local.translate("local_status_mytoncore_status").format(mytoncoreStatus_color, mytoncoreUptime_text)
717732
validatorStatus_text = local.translate("local_status_validator_status").format(validatorStatus_color, validatorUptime_text)
718733
validator_out_of_sync_text = local.translate("local_status_validator_out_of_sync").format(GetColorInt(validator_status.out_of_sync, 20, logic="less", ending=" s"))
719-
validator_out_of_ser_text = local.translate("local_status_validator_out_of_ser").format(GetColorInt(validator_status.out_of_ser, 20, logic="less", ending=" blocks"))
734+
735+
validator_out_of_ser_text = local.translate("local_status_validator_out_of_ser").format(f'{validator_status.out_of_ser} blocks ago')
736+
720737
dbSize_text = GetColorInt(dbSize, 1000, logic="less", ending=" Gb")
721738
dbUsage_text = GetColorInt(dbUsage, 80, logic="less", ending="%")
722739
dbStatus_text = local.translate("local_status_db").format(dbSize_text, dbUsage_text)
@@ -742,6 +759,7 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
742759
print(validatorIndex_text)
743760
print(validatorEfficiency_text)
744761
print(adnlAddr_text)
762+
print(fullnode_adnl_text)
745763
print(walletAddr_text)
746764
print(walletBalance_text)
747765
print(cpuLoad_text)

mytonctrl/resources/translate.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@
284284
"ru": "ADNL адрес локального валидатора: {0}",
285285
"zh_TW": "本地驗證者的 ADNL 地址: {0}"
286286
},
287+
"local_status_fullnode_adnl": {
288+
"en": "Public ADNL address of node: {0}",
289+
"ru": "Публичный ADNL адрес ноды: {0}",
290+
"zh_TW": "節點的公共 ADNL 地址: {0}"
291+
},
287292
"local_status_wallet_addr": {
288293
"en": "Local validator wallet address: {0}",
289294
"ru": "Адрес кошелька локального валидатора: {0}",
@@ -330,9 +335,9 @@
330335
"zh_TW": "本地驗證者不同步: {0}"
331336
},
332337
"local_status_validator_out_of_ser": {
333-
"en": "Local validator out of ser: {0}",
334-
"ru": "Рассериализация локального валидатора: {0}",
335-
"zh_TW": "本地驗證者不同步: {0}"
338+
"en": "Local validator last state serialization: {0}",
339+
"ru": "Серализация стейта локального валидатора была: {0}",
340+
"zh_TW": "本地驗證者最後一次狀態序列化: {0}"
336341
},
337342
"local_status_db": {
338343
"en": "Local validator database size: {0}, {1}",

mytoninstaller/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def FirstNodeSettings(local):
5858

5959
# Прописать автозагрузку
6060
cpus = psutil.cpu_count() - 1
61-
cmd = f"{validatorAppPath} --threads {cpus} --daemonize --global-config {globalConfigPath} --db {ton_db_dir} --logname {tonLogPath} --state-ttl 604800 --archive-ttl {archive_ttl} --verbosity 1"
61+
cmd = f"{validatorAppPath} --threads {cpus} --daemonize --global-config {globalConfigPath} --db {ton_db_dir} --logname {tonLogPath} --archive-ttl {archive_ttl} --verbosity 1"
6262
add2systemd(name="validator", user=vuser, start=cmd) # post="/usr/bin/python3 /usr/src/mytonctrl/mytoncore.py -e \"validator down\""
6363

6464
# Получить внешний ip адрес

0 commit comments

Comments
 (0)