Skip to content

Commit

Permalink
Merge pull request #794 from skalenetwork/develop
Browse files Browse the repository at this point in the history
Remove --catchup option (beta)
  • Loading branch information
dmytrotkk authored Oct 28, 2024
2 parents 057e5a9 + d46b55c commit 4b8ed28
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 27 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@ Options:

- `--archive` - Run sync node in an archive node (disable block rotation)
- `--historic-state` - Enable historic state (works only in pair with --archive flag)
- `--catchup` - Add a flag to start sync node in catchup mode

#### Sync node update

Expand Down
16 changes: 2 additions & 14 deletions node_cli/cli/sync_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ def sync_node():
help=TEXTS['init']['archive'],
is_flag=True
)
@click.option(
'--catchup',
help=TEXTS['init']['catchup'],
is_flag=True
)
@click.option(
'--historic-state',
help=TEXTS['init']['historic_state'],
Expand All @@ -71,13 +66,13 @@ def sync_node():
help='Ip of the node from to download snapshot from'
)
@streamed_cmd
def _init_sync(env_file, archive, catchup, historic_state, snapshot_from: Optional[str]):
def _init_sync(env_file, archive, historic_state, snapshot_from: Optional[str]):
if historic_state and not archive:
error_exit(
'--historic-state can be used only is combination with --archive',
exit_code=CLIExitCodes.FAILURE
)
init_sync(env_file, archive, catchup, historic_state, snapshot_from)
init_sync(env_file, archive, historic_state, snapshot_from)


@sync_node.command('update', help='Update sync node from .env file')
Expand Down Expand Up @@ -106,11 +101,6 @@ def _update_sync(env_file, unsafe_ok):
help=TEXTS['init']['archive'],
is_flag=True
)
@click.option(
'--catchup',
help=TEXTS['init']['catchup'],
is_flag=True
)
@click.option(
'--historic-state',
help=TEXTS['init']['historic_state'],
Expand All @@ -126,13 +116,11 @@ def _update_sync(env_file, unsafe_ok):
@streamed_cmd
def _repair_sync(
archive: str,
catchup: str,
historic_state: str,
snapshot_from: Optional[str] = None
) -> None:
repair_sync(
archive=archive,
catchup=catchup,
historic_state=historic_state,
snapshot_from=snapshot_from
)
4 changes: 0 additions & 4 deletions node_cli/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def restore(backup_path, env_filepath, no_snapshot=False, config_only=False):
def init_sync(
env_filepath: str,
archive: bool,
catchup: bool,
historic_state: bool,
snapshot_from: str
) -> None:
Expand All @@ -198,7 +197,6 @@ def init_sync(
env_filepath,
env,
archive,
catchup,
historic_state,
snapshot_from
)
Expand Down Expand Up @@ -239,7 +237,6 @@ def update_sync(env_filepath: str, unsafe_ok: bool = False) -> None:
@check_user
def repair_sync(
archive: bool,
catchup: bool,
historic_state: bool,
snapshot_from: str
) -> None:
Expand All @@ -249,7 +246,6 @@ def repair_sync(
repair_sync_op(
schain_name=schain_name,
archive=archive,
catchup=catchup,
historic_state=historic_state,
snapshot_from=snapshot_from
)
Expand Down
8 changes: 4 additions & 4 deletions node_cli/operations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ def init_sync(
env_filepath: str,
env: dict,
archive: bool,
catchup: bool,
historic_state: bool,
snapshot_from: Optional[str]
) -> bool:
Expand All @@ -208,7 +207,8 @@ def init_sync(

node_options = NodeOptions()
node_options.archive = archive
node_options.catchup = catchup
if archive:
node_options.catchup = True
node_options.historic_state = historic_state

ensure_filestorage_mapping()
Expand Down Expand Up @@ -352,7 +352,6 @@ def restore(env, backup_path, config_only=False):
def repair_sync(
schain_name: str,
archive: bool,
catchup: bool,
historic_state: bool,
snapshot_from: Optional[str]
) -> None:
Expand All @@ -365,7 +364,8 @@ def repair_sync(
logger.info('Updating node options')
node_options = NodeOptions()
node_options.archive = archive
node_options.catchup = catchup
if archive:
node_options.catchup = True
node_options.historic_state = historic_state

logger.info('Updating cli status')
Expand Down
10 changes: 8 additions & 2 deletions tests/cli/sync_node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ def test_init_sync(mocked_g_config):
'node_cli.utils.decorators.is_node_inited', return_value=False
):
result = run_command(_init_sync, ['./tests/test-env'])

node_options = NodeOptions()
assert not node_options.archive
assert not node_options.catchup
assert not node_options.historic_state

assert result.exit_code == 0


def test_init_sync_archive_catchup(mocked_g_config, clean_node_options):
def test_init_sync_archive(mocked_g_config, clean_node_options):
pathlib.Path(NODE_DATA_PATH).mkdir(parents=True, exist_ok=True)
# with mock.patch('subprocess.run', new=subprocess_run_mock), \
with mock.patch('node_cli.core.node.is_base_containers_alive', return_value=True), mock.patch(
Expand All @@ -70,7 +76,7 @@ def test_init_sync_archive_catchup(mocked_g_config, clean_node_options):
'node_cli.utils.decorators.is_node_inited', return_value=False
):
result = run_command(
_init_sync, ['./tests/test-env', '--archive', '--catchup', '--historic-state']
_init_sync, ['./tests/test-env', '--archive', '--historic-state']
)
node_options = NodeOptions()

Expand Down
2 changes: 1 addition & 1 deletion tests/core/core_node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,4 @@ def test_repair_sync(tmp_sync_datadir, mocked_g_config, resource_file):
with mock.patch('node_cli.core.schains.rm_btrfs_subvolume'), \
mock.patch('node_cli.utils.docker_utils.stop_container'), \
mock.patch('node_cli.utils.docker_utils.start_container'):
repair_sync(archive=True, catchup=True, historic_state=True, snapshot_from='127.0.0.1')
repair_sync(archive=True, historic_state=True, snapshot_from='127.0.0.1')
1 change: 0 additions & 1 deletion text.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ sync_node:
help: Initialize sync SKALE node
archive: Run sync node in an archive node (disable block rotation)
historic_state: Enable historic state (works only in pair with --archive flag)
catchup: Add a flag to start sync node in catchup mode

lvmpy:
help: Lvmpy commands
Expand Down

0 comments on commit 4b8ed28

Please sign in to comment.