Skip to content

Commit e7e0ba0

Browse files
committed
Merge branch 'mirage' into mirage-new-cmds
2 parents a1c51b6 + 856f956 commit e7e0ba0

24 files changed

Lines changed: 431 additions & 63 deletions

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ jobs:
7171
run: |
7272
scripts/build.sh test test normal
7373
74+
- name: Run redis
75+
run: |
76+
./helper-scripts/redis/run.sh
77+
7478
- name: Run tests
7579
run: |
7680
export PYTHONPATH=${PYTHONPATH}:/usr/lib/python3/dist-packages/

node_cli/cli/mirage_boot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919

2020
import click
2121

22-
from node_cli.core.node import get_node_signature, register_node as register, get_node_info
23-
from node_cli.core.mirage_boot import init, update
2422
from node_cli.configs import DEFAULT_NODE_BASE_PORT
25-
from node_cli.utils.helper import streamed_cmd, IP_TYPE, error_exit, abort_if_false
23+
from node_cli.core.node import get_node_info, get_node_signature
24+
from node_cli.core.node import register_node as register
25+
from node_cli.mirage.mirage_boot import init, update
26+
from node_cli.utils.helper import IP_TYPE, abort_if_false, error_exit, streamed_cmd
2627

2728

2829
@click.group()

node_cli/cli/mirage_node.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
import click
2121

2222
from node_cli.core.node import get_node_signature, backup, get_node_info
23-
from node_cli.core.mirage_node import migrate_from_boot, restore_mirage
23+
from node_cli.mirage.mirage_node import migrate_from_boot, request_repair, restore_mirage
2424
from node_cli.utils.helper import error_exit, streamed_cmd, abort_if_false
25+
from node_cli.utils.helper import URL_TYPE
26+
from node_cli.utils.texts import safe_load_texts
2527

28+
TEXTS = safe_load_texts()
2629

2730
@click.group()
2831
def mirage_node_cli():
@@ -108,3 +111,16 @@ def restore_node(backup_path, env_file, config_only):
108111
@streamed_cmd
109112
def migrate_node(env_filepath: str) -> None:
110113
migrate_from_boot(env_filepath=env_filepath)
114+
prompt=TEXTS['mirage']['node']['repair']['warning'],
115+
)
116+
117+
@node.command('repair', help='Toggle mirage chain repair mode')
118+
@click.option(
119+
'--snapshot-from',
120+
type=URL_TYPE,
121+
default='',
122+
hidden=True,
123+
help=TEXTS['mirage']['node']['repair']['snapshot_from'],
124+
)
125+
def repair(snapshot_from: str = '') -> None:
126+
request_repair(snapshot_from=snapshot_from)

node_cli/configs/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,5 @@ def _get_env():
169169

170170
UFW_CONFIG_PATH = '/etc/default/ufw'
171171
UFW_IPV6_BEFORE_INPUT_CHAIN = 'ufw6-before-input'
172+
173+
REDIS_URI: str = os.getenv('REDIS_URI', 'redis://@127.0.0.1:6379')

node_cli/core/checks.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
import docker # type: ignore
4747
import psutil # type: ignore
48-
import yaml
4948
from debian import debian_support
5049
from packaging.version import parse as version_parse
5150

@@ -55,11 +54,10 @@
5554
DOCKER_CONFIG_FILEPATH,
5655
DOCKER_DAEMON_HOSTS,
5756
REPORTS_PATH,
58-
STATIC_PARAMS_FILEPATH,
59-
MIRAGE_STATIC_PARAMS_FILEPATH,
6057
)
6158
from node_cli.core.host import is_ufw_ipv6_chain_exists, is_ufw_ipv6_option_enabled
6259
from node_cli.core.resources import get_disk_size
60+
from node_cli.core.static_config import get_static_params
6361
from node_cli.utils.docker_utils import NodeType
6462
from node_cli.utils.helper import run_cmd, safe_mkdir
6563

@@ -78,23 +76,6 @@
7876
FuncList = List[Func]
7977

8078

81-
def get_static_params(
82-
node_type: NodeType,
83-
env_type: str = 'mainnet',
84-
config_path: str = CONTAINER_CONFIG_PATH,
85-
) -> Dict:
86-
if node_type == NodeType.MIRAGE:
87-
static_params_base_filepath = MIRAGE_STATIC_PARAMS_FILEPATH
88-
else:
89-
static_params_base_filepath = STATIC_PARAMS_FILEPATH
90-
91-
static_params_filename = os.path.basename(static_params_base_filepath)
92-
static_params_filepath = os.path.join(config_path, static_params_filename)
93-
with open(static_params_filepath) as requirements_file:
94-
ydata = yaml.load(requirements_file, Loader=yaml.Loader)
95-
return ydata['envs'][env_type]
96-
97-
9879
def check_quietly(check: Func, *args, **kwargs) -> CheckResult:
9980
try:
10081
return check(*args, **kwargs)

node_cli/core/schains.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,57 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of node-cli
4+
#
5+
# Copyright (C) 2025 SKALE Labs
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Affero General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU Affero General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Affero General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
120
import glob
221
import logging
322
import os
423
import pprint
524
import shutil
625
import time
726
from pathlib import Path
8-
927
from typing import Dict, Optional
1028

29+
from lvmpy.src.core import mount, volume_mountpoint
1130
from node_cli.configs import (
1231
ALLOCATION_FILEPATH,
13-
NODE_CONFIG_PATH,
1432
NODE_CLI_STATUS_FILENAME,
33+
NODE_CONFIG_PATH,
1534
SCHAIN_NODE_DATA_PATH,
1635
SCHAINS_MNT_DIR_SINGLE_CHAIN,
1736
)
1837
from node_cli.configs.user import get_validated_user_config
19-
20-
from node_cli.utils.helper import get_request, error_exit, safe_load_yml
38+
from node_cli.utils.docker_utils import ensure_volume, is_volume_exists
2139
from node_cli.utils.exit_codes import CLIExitCodes
40+
from node_cli.utils.helper import (
41+
error_exit,
42+
get_request,
43+
read_json,
44+
run_cmd,
45+
safe_load_yml,
46+
save_json,
47+
)
48+
from node_cli.utils.node_type import NodeType
2249
from node_cli.utils.print_formatters import (
2350
print_dkg_statuses,
2451
print_firewall_rules,
2552
print_schain_info,
2653
print_schains,
2754
)
28-
from node_cli.utils.docker_utils import ensure_volume, is_volume_exists
29-
from node_cli.utils.helper import read_json, run_cmd, save_json
30-
from node_cli.utils.node_type import NodeType
31-
from lvmpy.src.core import mount, volume_mountpoint
32-
3355

3456
logger = logging.getLogger(__name__)
3557

node_cli/core/static_config.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of node-cli
4+
#
5+
# Copyright (C) 2025 SKALE Labs
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Affero General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU Affero General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Affero General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
20+
import os
21+
22+
import yaml
23+
24+
from node_cli.configs import (
25+
CONTAINER_CONFIG_PATH,
26+
MIRAGE_STATIC_PARAMS_FILEPATH,
27+
STATIC_PARAMS_FILEPATH,
28+
)
29+
from node_cli.utils.node_type import NodeType
30+
31+
32+
def get_static_params(
33+
node_type: NodeType,
34+
env_type: str = 'mainnet',
35+
config_path: str = CONTAINER_CONFIG_PATH,
36+
) -> dict:
37+
if node_type == NodeType.MIRAGE:
38+
static_params_base_filepath = MIRAGE_STATIC_PARAMS_FILEPATH
39+
else:
40+
static_params_base_filepath = STATIC_PARAMS_FILEPATH
41+
42+
static_params_filename = os.path.basename(static_params_base_filepath)
43+
static_params_filepath = os.path.join(config_path, static_params_filename)
44+
with open(static_params_filepath) as requirements_file:
45+
ydata = yaml.load(requirements_file, Loader=yaml.Loader)
46+
return ydata['envs'][env_type]

node_cli/mirage/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)