Skip to content

Commit de9ee63

Browse files
committed
do not allow upgrade node if clang version is < 16
1 parent 72d4357 commit de9ee63

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

mytonctrl/mytonctrl.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,15 @@ def Upgrade(ton, args):
366366
validatorConsole["pubKeyPath"] = "/var/ton-work/keys/server.pub"
367367
ton.SetSettings("validatorConsole", validatorConsole)
368368

369+
clang_version = get_clang_major_version()
370+
if (clang_version is None or clang_version < 16) and ('--force' not in args):
371+
text = "{red}Error: clang version 16 or higher is required for TON Node software upgrade.{endc}\n"
372+
if clang_version is None:
373+
text += "Could not check clang version.\n If you are sure that clang version is 16 or higher, use --force option.\n"
374+
text += "For clang update check the following instructions: https://gist.github.com/neodix42/e4b1b68d2d5dd3dec75b5221657f05d7"
375+
color_print(text)
376+
return
377+
369378
# Run script
370379
upgrade_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/upgrade.sh')
371380
runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch]
@@ -377,6 +386,35 @@ def Upgrade(ton, args):
377386
color_print(text)
378387
#end define
379388

389+
def get_clang_major_version():
390+
try:
391+
process = subprocess.run(["clang", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
392+
text=True, timeout=3)
393+
if process.returncode != 0:
394+
return None
395+
396+
output = process.stdout
397+
398+
lines = output.strip().split('\n')
399+
if not lines:
400+
return None
401+
402+
first_line = lines[0]
403+
if "clang version" not in first_line:
404+
return None
405+
406+
version_part = first_line.split("clang version")[1].strip()
407+
major_version = version_part.split('.')[0]
408+
409+
major_version = ''.join(c for c in major_version if c.isdigit())
410+
411+
if not major_version:
412+
return None
413+
414+
return int(major_version)
415+
except Exception:
416+
return None
417+
380418
def rollback_to_mtc1(local, ton, args):
381419
color_print("{red}Warning: this is dangerous, please make sure you've backed up mytoncore's db.{endc}")
382420
a = input("Do you want to continue? [Y/n]\n")

0 commit comments

Comments
 (0)