Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
# CLAP CLI
##########
CLAP_LIST_FILE="clap-markdown-list"
export SLECT_TOOL_MARKDOWN="true"

# Form a markdown string that will be used to capture an index of documented CLIs
workspace_root=$(cargo metadata --no-deps --format-version 1 | jq -r '.workspace_root')
Expand Down
82 changes: 60 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ include-vendor = { git = "https://github.com/movementlabsxyz/kestrel.git", rev =
ready-docker = { git = "https://github.com/movementlabsxyz/kestrel.git", rev = "3220d704df7e06d1dcc5266e15eaf05db86fdb07" }

# orfile
orfile = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "b49cb42495816fa00a1107be5bbf41aff3a8255d" }
orfile = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "f02851242af77791b905efc19aef6af21918fb1e" }
slect = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "f02851242af77791b905efc19aef6af21918fb1e" }

# docs
clap-markdown-ext = { git = "https://github.com/movementlabsxyz/clap-markdown-ext.git", rev = "8f54fe424504bf37fb01dc69aaed8166e429fe6a" }
clap-markdown-ext = { git = "https://github.com/movementlabsxyz/clap-markdown-ext.git", rev = "a4c6c00193baa50eefa214bd74b4a1d50c3255a0" }

# internal
## migration
Expand Down
1 change: 1 addition & 0 deletions migration/cli/migrate-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ futures = { workspace = true }
sysinfo = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
slect = { workspace = true }

[lints]
workspace = true
34 changes: 22 additions & 12 deletions migration/cli/migrate-node/docs/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This document contains the help content for the `mtma-migrate-node` command-line
* [`mtma-migrate-node markdown print`↴](#mtma-migrate-node-markdown-print)
* [`mtma-migrate-node markdown workspace`↴](#mtma-migrate-node-markdown-workspace)
* [`mtma-migrate-node migrate`↴](#mtma-migrate-node-migrate)
* [`mtma-migrate-node migrate where`↴](#mtma-migrate-node-migrate-where)
* [`mtma-migrate-node migrate using`↴](#mtma-migrate-node-migrate-using)
* [`mtma-migrate-node migrate core`↴](#mtma-migrate-node-migrate-core)
* [`mtma-migrate-node migrate select`↴](#mtma-migrate-node-migrate-select)

## `mtma-migrate-node`

Expand Down Expand Up @@ -94,16 +94,16 @@ Migrate from Movement to MovementAptos

###### **Subcommands:**

* `where` — Run migrate with all parameters passed explicitly as CLI flags. See Orfile documentation for more details: <https://github.com/movementlabsxyz/orfile>
* `using` — Run migrate with parameters from environment variables, config files, and CLI flags. See Orfile documentation for more details: <https://github.com/movementlabsxyz/orfile>
* `core` — Core migration over the node
* `select` — Select migration over the node



## `mtma-migrate-node migrate where`
## `mtma-migrate-node migrate core`

Run migrate with all parameters passed explicitly as CLI flags. See Orfile documentation for more details: <https://github.com/movementlabsxyz/orfile>
Core migration over the node

**Usage:** `mtma-migrate-node migrate where --movement-state-db-path <MOVEMENT_STATE_DB_PATH> --movement-aptos-state-db-path <MOVEMENT_APTOS_STATE_DB_PATH>`
**Usage:** `mtma-migrate-node migrate core --movement-state-db-path <MOVEMENT_STATE_DB_PATH> --movement-aptos-state-db-path <MOVEMENT_APTOS_STATE_DB_PATH>`

###### **Options:**

Expand All @@ -112,19 +112,29 @@ Run migrate with all parameters passed explicitly as CLI flags. See Orfile docum



## `mtma-migrate-node migrate using`
## `mtma-migrate-node migrate select`

Run migrate with parameters from environment variables, config files, and CLI flags. See Orfile documentation for more details: <https://github.com/movementlabsxyz/orfile>
Select migration over the node

**Usage:** `mtma-migrate-node migrate using [OPTIONS] [EXTRA_ARGS]...`
**Usage:** `mtma-migrate-node migrate select [OPTIONS] [-- <EXTRA_ARGS>...]`

###### **Arguments:**

* `<EXTRA_ARGS>` — Extra arguments to be passed to the CLI
* `<EXTRA_ARGS>` — Extra arguments to be passed to selections

###### **Options:**

* `--config-path <CONFIG_PATH>` — Path to the config file for migrate
* `--null` — Enable the null selection

**Selection (1/1):** `null`
The config for the migration

Usage: --null.*

Options:
-h, --help Print help (see more with '--help')





Expand Down
2 changes: 1 addition & 1 deletion migration/cli/migrate-node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum MtmaMigrateNodeSubcommand {
Markdown(Markdown),
/// Migrate from Movement to MovementAptos.
#[clap(subcommand)]
Migrate(migrate::or_file::Migrate),
Migrate(migrate::Migrate),
}

/// Implement the `From` trait for `MtmaMigrateNode` to convert it into a `MtmaMigrateNodeSubcommand`.
Expand Down
32 changes: 13 additions & 19 deletions migration/cli/migrate-node/src/cli/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
pub mod core;
pub mod select;

use clap::Parser;
use mtma_core::Config;
use orfile::Orfile;
use serde::{Deserialize, Serialize};

/// Migrates the node.
#[derive(Parser, Serialize, Deserialize, Debug, Clone, Orfile)]
#[derive(Parser, Debug)]
#[clap(help_expected = true)]
pub struct Migrate {
/// The core config to use.
#[orfile(config)]
#[clap(flatten)]
pub config: Config,
pub enum Migrate {
/// Core migration over the node.
Core(core::Core),
/// Select migration over the node.
Select(select::select::Select),
}

impl Migrate {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
let migrate = self.config.build()?;
migrate.run().await?; // we unwrap the error as an easy way to do marshalling from [MigrateError] to [anyhow::Error]
Ok(())
}
}

impl or_file::Migrate {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
let inner = self.clone().resolve().await?;
inner.execute().await
match self {
Migrate::Core(core) => core.execute().await,
Migrate::Select(select) => select.execute().await,
}
}
}
29 changes: 29 additions & 0 deletions migration/cli/migrate-node/src/cli/migrate/core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use clap::Parser;
use mtma_core::Config;
use orfile::Orfile;
use serde::{Deserialize, Serialize};

/// Core migration over the node.
#[derive(Parser, Serialize, Deserialize, Debug, Clone, Orfile)]
#[clap(help_expected = true)]
pub struct Core {
/// The core config to use.
#[orfile(config)]
#[clap(flatten)]
pub config: Config,
}

impl Core {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
let migrate = self.config.build()?;
migrate.run().await?; // we unwrap the error as an easy way to do marshalling from [CoreError] to [anyhow::Error]
Ok(())
}
}

impl or_file::Core {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
let inner = self.clone().resolve().await?;
inner.execute().await
}
}
28 changes: 28 additions & 0 deletions migration/cli/migrate-node/src/cli/migrate/select.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use clap::Parser;
use mtma_node_null_core::Config as NullConfig;
use serde::{Deserialize, Serialize};
use slect::Slect;

/// Select migration over the node.
#[derive(Parser, Slect, Deserialize, Serialize, Debug, Clone)]
#[clap(help_expected = true)]
pub struct Select {
/// Extra args to pass to slect API
#[slect(null = NullConfig)]
extra_args: Vec<String>,
}

impl select::Select {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
let maybe_null = self.select().map_err(|e| anyhow::anyhow!("{}", e))?;

if let Some(null) = maybe_null {
let _build = null.build()?;

// needs an environment for the node to run.
// How we load this environment is in process of being abstraced.
}

Ok(())
}
}
Loading