Skip to content

Commit 9de8e61

Browse files
authored
Merge pull request #466 from ton-blockchain/dev
Dev
2 parents fb5af68 + ef02b02 commit 9de8e61

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

mytonctrl/mytonctrl.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,7 @@ def Upgrade(ton, args):
350350

351351
clang_version = get_clang_major_version()
352352
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"
353+
text = f"{{red}}WARNING: THIS UPGRADE WILL MOST PROBABLY FAIL DUE TO A WRONG CLANG VERSION: {clang_version}, REQUIRED VERSION IS 16. RECOMMENDED TO EXIT NOW AND UPGRADE CLANG AS PER INSTRUCTIONS: https://gist.github.com/neodix42/e4b1b68d2d5dd3dec75b5221657f05d7{{endc}}\n"
357354
color_print(text)
358355
if input("Continue with upgrade anyway? [Y/n]\n").strip().lower() not in ('y', ''):
359356
print('aborted.')
@@ -592,7 +589,7 @@ def PrintStatus(local, ton, args):
592589

593590
if all_status:
594591
network_name = ton.GetNetworkName()
595-
rootWorkchainEnabledTime_int = ton.GetRootWorkchainEnabledTime()
592+
rootWorkchainEnabledTime_int = local.try_function(ton.GetRootWorkchainEnabledTime)
596593
config34 = ton.GetConfig34()
597594
config36 = ton.GetConfig36()
598595
totalValidators = config34["totalValidators"]

mytonctrl/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66

77
def timestamp2utcdatetime(timestamp, format="%d.%m.%Y %H:%M:%S"):
8+
if timestamp is None:
9+
return "n/a"
810
datetime = time.gmtime(timestamp)
911
result = time.strftime(format, datetime) + ' UTC'
1012
return result

mytoninstaller/mytoninstaller.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def inject_globals(func):
6868
console.AddItem("status", inject_globals(Status), "Print TON component status")
6969
console.AddItem("set_node_argument", inject_globals(set_node_argument), "Set node argument")
7070
console.AddItem("enable", inject_globals(Enable), "Enable some function")
71-
console.AddItem("update", inject_globals(Enable), "Update some function: 'JR' - jsonrpc. Example: 'update JR'")
71+
console.AddItem("update", inject_globals(Enable), "Update some function: 'JR' - jsonrpc. Example: 'update JR'")
7272
console.AddItem("plsc", inject_globals(PrintLiteServerConfig), "Print lite-server config")
7373
console.AddItem("clcf", inject_globals(CreateLocalConfigFile), "Create lite-server config file")
7474
console.AddItem("print_ls_proxy_config", inject_globals(print_ls_proxy_config), "Print ls-proxy config")
@@ -133,6 +133,8 @@ def Status(local, args):
133133
node_args = get_node_args()
134134
color_print("{cyan}===[ Node arguments ]==={endc}")
135135
for key, value in node_args.items():
136+
if len(value) == 0:
137+
print(f"{key}")
136138
for v in value:
137139
print(f"{key}: {v}")
138140
#end define

mytoninstaller/node_args.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def get_node_args(start_command: str = None):
2525
for item in node_args:
2626
if item.startswith('-'):
2727
key = item
28-
result[key] = list()
28+
if key not in result:
29+
result[key] = []
2930
else:
3031
result[key].append(item)
3132
return result

mytoninstaller/settings.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,23 @@ def FirstNodeSettings(local):
120120
StartValidator(local)
121121
#end define
122122

123-
def download_blocks(local, bag: dict):
123+
def download_blocks(local, bag: dict, downloads_path: str):
124124
local.add_log(f"Downloading blocks from {bag['from']} to {bag['to']}", "info")
125-
if not download_bag(local, bag['bag']):
125+
if not download_bag(local, bag['bag'], downloads_path):
126126
local.add_log("Error downloading archive bag", "error")
127127
return
128128

129129

130-
def download_master_blocks(local, bag: dict):
130+
def download_master_blocks(local, bag: dict, downloads_path: str):
131131
local.add_log(f"Downloading master blocks from {bag['from']} to {bag['to']}", "info")
132-
if not download_bag(local, bag['bag'], download_all=False, download_file=lambda f: ':' not in f['name']):
132+
if not download_bag(local, bag['bag'], downloads_path, download_all=False, download_file=lambda f: ':' not in f['name']):
133133
local.add_log("Error downloading master bag", "error")
134134
return
135135

136136

137-
def download_bag(local, bag_id: str, download_all: bool = True, download_file: typing.Callable = None):
137+
def download_bag(local, bag_id: str, downloads_path: str, download_all: bool = True, download_file: typing.Callable = None):
138138
indexes = []
139139
local_ts_url = f"http://127.0.0.1:{local.buffer.ton_storage.api_port}"
140-
downloads_path = '/tmp/ts-downloads/'
141140

142141
resp = requests.post(local_ts_url + '/api/v1/add', json={'bag_id': bag_id, 'download_all': download_all, 'path': downloads_path})
143142
if not resp.json()['ok']:
@@ -201,6 +200,10 @@ def parse_block_value(local, block: str):
201200

202201
def download_archive_from_ts(local):
203202
archive_blocks = os.getenv('ARCHIVE_BLOCKS')
203+
downloads_path = '/var/ton-work/ts-downloads/'
204+
os.makedirs(downloads_path, exist_ok=True)
205+
subprocess.run(["chmod", "o+wx", downloads_path])
206+
204207
if archive_blocks is None:
205208
return
206209
block_from, block_to = archive_blocks, None
@@ -241,17 +244,18 @@ def download_archive_from_ts(local):
241244
return
242245

243246
local.add_log(f"Downloading blockchain state for block {state_bag['at_block']}", "info")
244-
if not download_bag(local, state_bag['bag']):
247+
if not download_bag(local, state_bag['bag'], downloads_path):
245248
local.add_log("Error downloading state bag", "error")
246249
return
247250

251+
248252
update_init_block(local, state_bag['at_block'])
249253
estimated_size = len(block_bags) * 4 * 2**30 + len(master_block_bags) * 4 * 2**30 * 0.2 # 4 GB per bag, 20% for master blocks
250254

251255
local.add_log(f"Downloading archive blocks. Rough estimate total blocks size is {int(estimated_size / 2**30)} GB", "info")
252256
with ThreadPoolExecutor(max_workers=4) as executor:
253-
futures = [executor.submit(download_blocks, local, bag) for bag in block_bags]
254-
futures += [executor.submit(download_master_blocks, local, bag) for bag in master_block_bags]
257+
futures = [executor.submit(download_blocks, local, bag, downloads_path) for bag in block_bags]
258+
futures += [executor.submit(download_master_blocks, local, bag, downloads_path) for bag in master_block_bags]
255259
for future in as_completed(futures):
256260
try:
257261
future.result()
@@ -265,7 +269,6 @@ def download_archive_from_ts(local):
265269
import_dir = local.buffer.ton_db_dir + 'import/'
266270
os.makedirs(import_dir, exist_ok=True)
267271
states_dir = archive_dir + '/states'
268-
downloads_path = '/tmp/ts-downloads/'
269272

270273
os.makedirs(states_dir, exist_ok=True)
271274
os.makedirs(import_dir, exist_ok=True)
@@ -275,7 +278,7 @@ def download_archive_from_ts(local):
275278
for bag in block_bags + master_block_bags:
276279
subprocess.run(f'mv {downloads_path}/{bag["bag"]}/*/*/* {import_dir}', shell=True)
277280
# subprocess.run(['rm', '-rf', f"{downloads_path}/{bag['bag']}"])
278-
subprocess.run(f'rm -rf {downloads_path}*', shell=True)
281+
subprocess.run(f'rm -rf {downloads_path}', shell=True)
279282

280283
stop_service(local, "ton_storage") # stop TS
281284
disable_service(local, "ton_storage")

0 commit comments

Comments
 (0)