Skip to content

Add mirage migrate command#865

Merged
dmytrotkk merged 27 commits into
miragefrom
mirage-new-cmds
Jun 24, 2025
Merged

Add mirage migrate command#865
dmytrotkk merged 27 commits into
miragefrom
mirage-new-cmds

Conversation

@badrogger

@badrogger badrogger commented Jun 10, 2025

Copy link
Copy Markdown
Contributor

This pull request introduces several enhancements and refactors to the node_cli project, focusing on improving configuration management, adding a new migration command, and replacing older environment-based configuration handling with a more structured user configuration system. The changes also include updates to dependencies and some minor code cleanups.

New Features:

  • Added migrate command: Introduced a new CLI command to migrate from a boot node to a regular Mirage node. This includes the migrate_from_boot function and its integration into the CLI (node_cli/cli/mirage_node.py, node_cli/core/mirage_node.py). [1] [2]

Configuration Refactor:

  • Replaced env.py with user.py: The old environment-based configuration system (env.py) was removed and replaced with a more structured and type-safe user configuration system (user.py). This includes the introduction of configuration classes like BaseUserConfig, MirageUserConfig, and SkaleUserConfig. Functions such as get_validated_env_config were replaced with get_validated_user_config. [1] [2]
  • Updated imports and references: All references to env.py were updated to use the new user.py module across multiple files. [1] [2] [3] [4]

Code Refactoring:

  • Replaced get_meta_info with CliMetaManager: Refactored the code to use CliMetaManager for retrieving metadata instead of the older get_meta_info function. [1] [2] [3]
  • Renamed validate_env_alias_or_address to validate_alias_or_address: Simplified function naming for better readability and consistency.

Cleanup:

  • Removed env.py: Deleted the now-obsolete env.py file, along with its associated logic for environment variable management.

These changes collectively improve the maintainability, readability, and extensibility of the node_cli codebase.

@badrogger badrogger changed the base branch from develop to mirage June 10, 2025 16:19
@badrogger badrogger marked this pull request as ready for review June 11, 2025 10:19
Comment thread node_cli/configs/user.py Outdated
error_exit(f'Extra parameters: {extra_params}')

params = to_lower_keys(params)
user_config = user_config_type(**params)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe let's rename to user_config_class and get_user_config_class to avoid confusion?

Comment thread node_cli/configs/user.py Outdated
contract_alias_or_address = user_config.manager_contracts
endpoint = user_config.endpoint

validate_alias_or_address(contract_alias_or_address, ContractType.MANAGER, endpoint)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should be removed for node type mirage

Comment thread node_cli/core/mirage_node.py Outdated
def migrate_from_boot(
env_filepath: str,
) -> None:
logger.info('Node update started')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the log messge

Comment thread node_cli/core/mirage_node.py Outdated
print_node_cmd_error()
return
else:
logger.info('Mirgration from boot to mirage completed successfully')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo -> Mirgration + should it be printed to the user too?

Comment thread node_cli/operations/base.py Outdated
docker_cleanup()

update_meta(
meta_manager.update_meta(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we're using CliMetaManager and not MirageCliMetaManager for migrate mirage boot and init mirage boot?

Comment thread node_cli/utils/meta.py Outdated
self,
version: str,
config_stream: str,
docker_lvmpy_stream: Optional[str],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be marked as optional in the parent class or marked as required in this class:

Argument of type "str | None" cannot be assigned to parameter "docker_lvmpy_stream" of type "str" in function "__init__"
  Type "str | None" is not assignable to type "str"
    "None" is not assignable to "str"Pylance[reportArgumentType](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportArgumentType.md)
(parameter) docker_lvmpy_stream: str | None

Comment thread node_cli/configs/user.py Outdated
def validate_user_config(user_config: BaseUserConfig) -> None:
validate_env_type(env_type=user_config.env_type)

if isinstance(user_config, MirageUserConfig):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove redundant check for mirage

@dmytrotkk dmytrotkk merged commit 27fb3ca into mirage Jun 24, 2025
2 checks passed
@dmytrotkk dmytrotkk deleted the mirage-new-cmds branch June 24, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants