11#!/usr/bin/env python3
22# -*- coding: utf_8 -*-
3+ import base64
34import subprocess
45import json
56import psutil
@@ -379,6 +380,14 @@ def Upgrade(ton, args):
379380 upgrade_script_path = pkg_resources .resource_filename ('mytonctrl' , 'scripts/upgrade.sh' )
380381 runArgs = ["bash" , upgrade_script_path , "-a" , author , "-r" , repo , "-b" , branch ]
381382 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}}" )
382391 if exitCode == 0 :
383392 text = "Upgrade - {green}OK{endc}"
384393 else :
@@ -460,6 +469,10 @@ def check_sync(local, ton):
460469#end define
461470
462471def check_validator_balance (local , ton ):
472+ validator_status = ton .GetValidatorStatus ()
473+ if not validator_status .is_working or validator_status .out_of_sync >= 20 :
474+ # Do not check the validator wallet balance if the node is not synchronized (via public lite-servers)
475+ return
463476 if ton .using_validator ():
464477 validator_wallet = ton .GetValidatorWallet ()
465478 validator_account = local .try_function (ton .GetAccount , args = [validator_wallet .addrB64 ])
@@ -475,6 +488,7 @@ def check_vps(local, ton):
475488 data = local .try_function (is_host_virtual )
476489 if data and data ["virtual" ]:
477490 color_print (f"Virtualization detected: { data ['product_name' ]} " )
491+ #end define
478492
479493def warnings (local , ton ):
480494 check_disk_usage (local , ton )
@@ -544,6 +558,13 @@ def PrintStatus(local, ton, args):
544558 disks_load_percent_avg = ton .GetStatistics ("disksLoadPercentAvg" , statistics )
545559
546560 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+
547568 if all_status :
548569 network_name = ton .GetNetworkName ()
549570 rootWorkchainEnabledTime_int = ton .GetRootWorkchainEnabledTime ()
@@ -581,7 +602,7 @@ def PrintStatus(local, ton, args):
581602 if all_status :
582603 PrintTonStatus (local , network_name , startWorkTime , totalValidators , onlineValidators , shardsNumber , offersNumber , complaintsNumber , tpsAvg )
583604 PrintLocalStatus (local , adnl_addr , validator_index , validator_efficiency , validator_wallet , validator_account , validator_status ,
584- 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 )
585606 if all_status :
586607 PrintTonConfig (local , fullConfigAddr , fullElectorAddr , config15 , config17 )
587608 PrintTimes (local , rootWorkchainEnabledTime_int , startWorkTime , oldStartWorkTime , config15 )
@@ -631,7 +652,7 @@ def PrintTonStatus(local, network_name, startWorkTime, totalValidators, onlineVa
631652 print ()
632653#end define
633654
634- 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 ):
635656 if validatorWallet is None :
636657 return
637658 walletAddr = validatorWallet .addrB64
@@ -650,6 +671,7 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
650671 validatorEfficiency_text = GetColorInt (validatorEfficiency , 10 , logic = "more" , ending = " %" )
651672 validatorEfficiency_text = local .translate ("local_status_validator_efficiency" ).format (validatorEfficiency_text )
652673 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 ))
653675 walletAddr_text = local .translate ("local_status_wallet_addr" ).format (bcolors .yellow_text (walletAddr ))
654676 walletBalance_text = local .translate ("local_status_wallet_balance" ).format (bcolors .green_text (walletBalance ))
655677
@@ -709,7 +731,9 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
709731 mytoncoreStatus_text = local .translate ("local_status_mytoncore_status" ).format (mytoncoreStatus_color , mytoncoreUptime_text )
710732 validatorStatus_text = local .translate ("local_status_validator_status" ).format (validatorStatus_color , validatorUptime_text )
711733 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" ))
712- 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+
713737 dbSize_text = GetColorInt (dbSize , 1000 , logic = "less" , ending = " Gb" )
714738 dbUsage_text = GetColorInt (dbUsage , 80 , logic = "less" , ending = "%" )
715739 dbStatus_text = local .translate ("local_status_db" ).format (dbSize_text , dbUsage_text )
@@ -735,6 +759,7 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
735759 print (validatorIndex_text )
736760 print (validatorEfficiency_text )
737761 print (adnlAddr_text )
762+ print (fullnode_adnl_text )
738763 print (walletAddr_text )
739764 print (walletBalance_text )
740765 print (cpuLoad_text )
0 commit comments