Skip to content
Merged

dev #280

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
1 change: 1 addition & 0 deletions modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Setting:
'fift_timeout': Setting(None, 3, 'Fift default timeout'),
'useDefaultCustomOverlays': Setting(None, True, 'Participate in default custom overlays node eligible to'),
'defaultCustomOverlaysUrl': Setting(None, 'https://ton-blockchain.github.io/fallback_custom_overlays.json', 'Default custom overlays config url'),
'debug': Setting(None, False, 'Debug mtc console mode. Prints Traceback on errors'),
}


Expand Down
5 changes: 3 additions & 2 deletions modules/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ def print_controllers_list(self, args):
old_controllers = self.ton.GetSettings("old_controllers")
user_controllers_list = self.ton.GetSettings("user_controllers_list")
print("using controllers:")
self.print_controllers_list_process(using_controllers)
if new_controllers != using_controllers:
if using_controllers is not None:
self.print_controllers_list_process(using_controllers)
if new_controllers is not None and new_controllers != using_controllers:
print()
print("new controllers:")
self.print_controllers_list_process(new_controllers)
Expand Down
32 changes: 25 additions & 7 deletions mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf_8 -*-
import base64
import subprocess
import json
import psutil
Expand Down Expand Up @@ -293,13 +294,11 @@ def check_vport(local, ton):
#end define


def check_git(input_args, default_repo, text):
def check_git(input_args, default_repo, text, default_branch='master'):
src_dir = "/usr/src"
git_path = f"{src_dir}/{default_repo}"
fix_git_config(git_path)
default_author = "ton-blockchain"
# default_branch = "master"
default_branch = "mytonctrl2"

# Get author, repo, branch
local_author, local_repo = get_git_author_and_repo(git_path)
Expand Down Expand Up @@ -341,7 +340,7 @@ def check_branch_exists(author, repo, branch):

def Update(local, args):
repo = "mytonctrl"
author, repo, branch = check_git(args, repo, "update")
author, repo, branch = check_git(args, repo, "update", default_branch='mytonctrl2')

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

all_status = validator_status.is_working == True and validator_status.out_of_sync < 20

try:
vconfig = ton.GetValidatorConfig()
fullnode_adnl = base64.b64decode(vconfig.fullnode).hex().upper()
except:
fullnode_adnl = 'n/a'

if all_status:
network_name = ton.GetNetworkName()
rootWorkchainEnabledTime_int = ton.GetRootWorkchainEnabledTime()
Expand Down Expand Up @@ -588,7 +602,7 @@ def PrintStatus(local, ton, args):
if all_status:
PrintTonStatus(local, network_name, startWorkTime, totalValidators, onlineValidators, shardsNumber, offersNumber, complaintsNumber, tpsAvg)
PrintLocalStatus(local, adnl_addr, validator_index, validator_efficiency, validator_wallet, validator_account, validator_status,
db_size, db_usage, memory_info, swap_info, net_load_avg, disks_load_avg, disks_load_percent_avg)
db_size, db_usage, memory_info, swap_info, net_load_avg, disks_load_avg, disks_load_percent_avg, fullnode_adnl)
if all_status:
PrintTonConfig(local, fullConfigAddr, fullElectorAddr, config15, config17)
PrintTimes(local, rootWorkchainEnabledTime_int, startWorkTime, oldStartWorkTime, config15)
Expand Down Expand Up @@ -638,7 +652,7 @@ def PrintTonStatus(local, network_name, startWorkTime, totalValidators, onlineVa
print()
#end define

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

Expand Down Expand Up @@ -716,7 +731,9 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
mytoncoreStatus_text = local.translate("local_status_mytoncore_status").format(mytoncoreStatus_color, mytoncoreUptime_text)
validatorStatus_text = local.translate("local_status_validator_status").format(validatorStatus_color, validatorUptime_text)
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"))
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"))

validator_out_of_ser_text = local.translate("local_status_validator_out_of_ser").format(f'{validator_status.out_of_ser} blocks ago')

dbSize_text = GetColorInt(dbSize, 1000, logic="less", ending=" Gb")
dbUsage_text = GetColorInt(dbUsage, 80, logic="less", ending="%")
dbStatus_text = local.translate("local_status_db").format(dbSize_text, dbUsage_text)
Expand All @@ -742,6 +759,7 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
print(validatorIndex_text)
print(validatorEfficiency_text)
print(adnlAddr_text)
print(fullnode_adnl_text)
print(walletAddr_text)
print(walletBalance_text)
print(cpuLoad_text)
Expand Down
11 changes: 8 additions & 3 deletions mytonctrl/resources/translate.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@
"ru": "ADNL адрес локального валидатора: {0}",
"zh_TW": "本地驗證者的 ADNL 地址: {0}"
},
"local_status_fullnode_adnl": {
"en": "Public ADNL address of node: {0}",
"ru": "Публичный ADNL адрес ноды: {0}",
"zh_TW": "節點的公共 ADNL 地址: {0}"
},
"local_status_wallet_addr": {
"en": "Local validator wallet address: {0}",
"ru": "Адрес кошелька локального валидатора: {0}",
Expand Down Expand Up @@ -330,9 +335,9 @@
"zh_TW": "本地驗證者不同步: {0}"
},
"local_status_validator_out_of_ser": {
"en": "Local validator out of ser: {0}",
"ru": "Рассериализация локального валидатора: {0}",
"zh_TW": "本地驗證者不同步: {0}"
"en": "Local validator last state serialization: {0}",
"ru": "Серализация стейта локального валидатора была: {0}",
"zh_TW": "本地驗證者最後一次狀態序列化: {0}"
},
"local_status_db": {
"en": "Local validator database size: {0}, {1}",
Expand Down
2 changes: 1 addition & 1 deletion mytoninstaller/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def FirstNodeSettings(local):

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

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