Skip to content

Commit 5be2554

Browse files
authored
Merge pull request #461 from ton-blockchain/dev
2 parents 8accb47 + 4f66db8 commit 5be2554

File tree

7 files changed

+51
-8
lines changed

7 files changed

+51
-8
lines changed

modules/alert_bot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def setup_alert_bot(self, args):
279279
self.send_welcome_message()
280280
self.ton.local.db['BotToken'] = args[0]
281281
self.ton.local.db['ChatId'] = args[1]
282+
self.ton.local.save()
282283
color_print("setup_alert_bot - {green}OK{endc}")
283284
except Exception as e:
284285
self.local.add_log(f"Error while sending welcome message: {e}", "error")
@@ -322,7 +323,7 @@ def check_validator_wallet_balance(self):
322323
return
323324
validator_wallet = self.ton.GetValidatorWallet()
324325
validator_account = self.ton.GetAccount(validator_wallet.addrB64)
325-
if validator_account.balance < 10:
326+
if validator_account.status != "empty" and validator_account.balance < 10:
326327
self.send_alert("low_wallet_balance", wallet=validator_wallet.addrB64, balance=validator_account.balance)
327328

328329
def check_efficiency(self):

mytoncore/functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ def Telemetry(local, ton):
458458
data["vprocess"] = GetValidatorProcessInfo()
459459
data["dbStats"] = local.try_function(get_db_stats)
460460
data["nodeArgs"] = local.try_function(get_node_args)
461+
data["modes"] = local.try_function(ton.get_modes)
461462
data["cpuInfo"] = {'cpuName': local.try_function(get_cpu_name), 'virtual': local.try_function(is_host_virtual)}
462463
data["validatorDiskName"] = local.try_function(get_validator_disk_name)
463464
data["pings"] = local.try_function(get_pings_values)

mytoncore/liteclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def Run(self, cmd, **kwargs):
2222
if index is not None:
2323
index = str(index)
2424
args += ["-i", index]
25-
elif useLocalLiteServer and self.pubkeyPath and validator_status.out_of_sync and validator_status.out_of_sync < 20:
25+
elif useLocalLiteServer and self.pubkeyPath and validator_status.out_of_sync is not None and validator_status.out_of_sync < 20:
2626
args = [self.appPath, "--addr", self.addr, "--pub", self.pubkeyPath, "--verbosity", "0", "--cmd", cmd]
2727
else:
2828
liteServers = self.local.db.get("liteServers")

mytoncore/mytoncore.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def GetSeqno(self, wallet):
178178
seqno = seqno.replace(' ', '')
179179
seqno = parse(seqno, '[', ']')
180180
seqno = int(seqno)
181+
self.local.add_log(f"GetSeqno: seqno is {seqno}", "debug")
181182
return seqno
182183
#end define
183184

@@ -2384,9 +2385,8 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
23842385
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint info was not found, probably it's wrong", "info")
23852386
continue
23862387

2387-
if (vload["id"] >= config32['mainValidators'] and
2388-
vload["masterBlocksCreated"] + vload["workBlocksCreated"] > 0):
2389-
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint created for non masterchain validator that created more than zero blocks", "info")
2388+
if vload["id"] >= config32['mainValidators']:
2389+
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint created for non masterchain validator", "info")
23902390
continue
23912391

23922392
# check complaint fine value
@@ -2587,7 +2587,7 @@ def CheckValidators(self, start, end):
25872587
pseudohash = pubkey + str(electionId)
25882588
if pseudohash in valid_complaints or pseudohash in voted_complaints_pseudohashes: # do not create complaints that already created or voted by ourself
25892589
continue
2590-
if item['id'] >= config['mainValidators'] and item["masterBlocksCreated"] + item["workBlocksCreated"] > 0: # create complaints for non-masterchain validators only if they created 0 blocks
2590+
if item['id'] >= config['mainValidators']: # do not create complaints for non-masterchain validators
25912591
continue
25922592
# Create complaint
25932593
fileName = self.remove_proofs_from_complaint(fileName)

mytoncore/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ def parse_db_stats(path: str):
100100
# end define
101101

102102
def get_hostname():
103-
return subprocess.run(["hostname", "-f"], stdout=subprocess.PIPE).stdout.decode().strip()
103+
return subprocess.run(["hostname"], stdout=subprocess.PIPE).stdout.decode().strip()

mytonctrl/mytonctrl.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,17 @@ def Upgrade(ton, args):
348348
validatorConsole["pubKeyPath"] = "/var/ton-work/keys/server.pub"
349349
ton.SetSettings("validatorConsole", validatorConsole)
350350

351+
clang_version = get_clang_major_version()
352+
if clang_version is None or clang_version < 16:
353+
text = "{yellow}Warning: clang version 16 or higher is required for TON Node software upgrade.{endc}\n"
354+
if clang_version is None:
355+
text += "Could not check clang version.\n If you are sure that clang version is 16 or higher, use --force option.\n"
356+
text += "For clang update check the following instructions: https://gist.github.com/neodix42/e4b1b68d2d5dd3dec75b5221657f05d7\n"
357+
color_print(text)
358+
if input("Continue with upgrade anyway? [Y/n]\n").strip().lower() not in ('y', ''):
359+
print('aborted.')
360+
return
361+
351362
# Run script
352363
upgrade_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/upgrade.sh')
353364
runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch]
@@ -359,6 +370,36 @@ def Upgrade(ton, args):
359370
color_print(text)
360371
#end define
361372

373+
def get_clang_major_version():
374+
try:
375+
process = subprocess.run(["clang", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
376+
text=True, timeout=3)
377+
if process.returncode != 0:
378+
return None
379+
380+
output = process.stdout
381+
382+
lines = output.strip().split('\n')
383+
if not lines:
384+
return None
385+
386+
first_line = lines[0]
387+
if "clang version" not in first_line:
388+
return None
389+
390+
version_part = first_line.split("clang version")[1].strip()
391+
major_version = version_part.split('.')[0]
392+
393+
major_version = ''.join(c for c in major_version if c.isdigit())
394+
395+
if not major_version:
396+
return None
397+
398+
return int(major_version)
399+
except Exception as e:
400+
print(f"Error checking clang version: {type(e)}: {e}")
401+
return None
402+
362403
def rollback_to_mtc1(local, ton, args):
363404
color_print("{red}Warning: this is dangerous, please make sure you've backed up mytoncore's db.{endc}")
364405
a = input("Do you want to continue? [Y/n]\n")

mytonctrl/scripts/upgrade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ memory=$(cat /proc/meminfo | grep MemAvailable | awk '{print $2}')
8989
cpuNumber=$(cat /proc/cpuinfo | grep "processor" | wc -l)
9090

9191
cmake -DCMAKE_BUILD_TYPE=Release ${srcdir}/${repo} -GNinja -DTON_USE_JEMALLOC=ON -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$opensslPath/include -DOPENSSL_CRYPTO_LIBRARY=$opensslPath/libcrypto.a
92-
ninja -j ${cpuNumber} fift validator-engine lite-client pow-miner validator-engine-console generate-random-id dht-server func tonlibjson rldp-http-proxy
92+
ninja -j ${cpuNumber} fift validator-engine lite-client validator-engine-console generate-random-id dht-server func tonlibjson rldp-http-proxy
9393
systemctl restart validator
9494

9595
# Конец

0 commit comments

Comments
 (0)