diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 7e692bb..8b6b4fc 100644 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -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') diff --git a/Cargo.lock b/Cargo.lock index 6eeca41..595d0cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8765,8 +8765,8 @@ dependencies = [ [[package]] name = "clap-markdown" -version = "0.1.4" -source = "git+https://github.com/ConnorGray/clap-markdown.git?rev=1e1ae469444604d5b9ee650232abc2d3a0fa723b#1e1ae469444604d5b9ee650232abc2d3a0fa723b" +version = "0.1.5" +source = "git+https://github.com/movementlabsxyz/clap-markdown.git?rev=514b18abd22d7e6bb4f40d33df35379d6ea6352c#514b18abd22d7e6bb4f40d33df35379d6ea6352c" dependencies = [ "clap 4.5.36", ] @@ -8774,7 +8774,7 @@ dependencies = [ [[package]] name = "clap-markdown-ext" version = "0.0.1" -source = "git+https://github.com/movementlabsxyz/clap-markdown-ext.git?rev=8f54fe424504bf37fb01dc69aaed8166e429fe6a#8f54fe424504bf37fb01dc69aaed8166e429fe6a" +source = "git+https://github.com/movementlabsxyz/clap-markdown-ext.git?rev=a4c6c00193baa50eefa214bd74b4a1d50c3255a0#a4c6c00193baa50eefa214bd74b4a1d50c3255a0" dependencies = [ "anyhow", "cargo_metadata 0.19.2", @@ -12777,7 +12777,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -15726,6 +15726,7 @@ dependencies = [ "orfile", "rand 0.7.3", "serde", + "slect", "sysinfo 0.34.2", "tokio", "tracing", @@ -15778,43 +15779,43 @@ dependencies = [ ] [[package]] -name = "mtma-migrator-matching-feature-flags" +name = "mtma-migrator-checks-pre-l1-merge" version = "0.0.1" dependencies = [ "anyhow", + "chrono", "kestrel", - "mtma-migrator-test-matching-feature-flags-criterion", + "movement-core", + "mtma-migrator-pre-l1-merge-core", + "mtma-migrator-test-accounts-equal-criterion", "mtma-migrator-test-types", "mtma-migrator-types", "mtma-node-null-core", + "mtma-node-preludes", + "mtma-node-replay-core", + "mtma-node-test-global-storage-includes-criterion", + "mtma-node-test-global-storage-injective-criterion", + "mtma-node-test-global-storage-not-empty-criterion", "mtma-node-test-types", + "mtma-types", + "rand 0.7.3", + "tempfile", "tokio", "tracing", "tracing-test", ] [[package]] -name = "mtma-migrator-checks-pre-l1-merge" +name = "mtma-migrator-matching-feature-flags" version = "0.0.1" dependencies = [ "anyhow", - "chrono", "kestrel", - "movement-core", - "mtma-migrator-pre-l1-merge-core", - "mtma-migrator-test-accounts-equal-criterion", + "mtma-migrator-test-matching-feature-flags-criterion", "mtma-migrator-test-types", "mtma-migrator-types", "mtma-node-null-core", - "mtma-node-preludes", - "mtma-node-replay-core", - "mtma-node-test-global-storage-includes-criterion", - "mtma-node-test-global-storage-injective-criterion", - "mtma-node-test-global-storage-not-empty-criterion", "mtma-node-test-types", - "mtma-types", - "rand 0.7.3", - "tempfile", "tokio", "tracing", "tracing-test", @@ -16874,7 +16875,7 @@ dependencies = [ [[package]] name = "orfile" version = "0.0.1" -source = "git+https://github.com/movementlabsxyz/orfile.git?rev=b49cb42495816fa00a1107be5bbf41aff3a8255d#b49cb42495816fa00a1107be5bbf41aff3a8255d" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" dependencies = [ "anyhow", "orfile-macro", @@ -16885,7 +16886,7 @@ dependencies = [ [[package]] name = "orfile-macro" version = "0.0.1" -source = "git+https://github.com/movementlabsxyz/orfile.git?rev=b49cb42495816fa00a1107be5bbf41aff3a8255d#b49cb42495816fa00a1107be5bbf41aff3a8255d" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" dependencies = [ "proc-macro-error", "proc-macro2", @@ -16896,7 +16897,7 @@ dependencies = [ [[package]] name = "orfile-util" version = "0.0.1" -source = "git+https://github.com/movementlabsxyz/orfile.git?rev=b49cb42495816fa00a1107be5bbf41aff3a8255d#b49cb42495816fa00a1107be5bbf41aff3a8255d" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" dependencies = [ "serde", "serde_json", @@ -20234,6 +20235,43 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slect" +version = "0.0.1" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" +dependencies = [ + "anyhow", + "once_cell", + "serde_json", + "slect-macro", + "slect-util", +] + +[[package]] +name = "slect-macro" +version = "0.0.1" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "slect-util" +version = "0.0.1" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" +dependencies = [ + "clap 4.5.36", + "once_cell", + "serde", + "serde_json", + "thiserror 1.0.69", + "tokio", +] + [[package]] name = "slug" version = "0.1.6" diff --git a/Cargo.toml b/Cargo.toml index ca47a5e..b30e246 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/migration/cli/migrate-node/Cargo.toml b/migration/cli/migrate-node/Cargo.toml index aec8821..394f605 100644 --- a/migration/cli/migrate-node/Cargo.toml +++ b/migration/cli/migrate-node/Cargo.toml @@ -32,6 +32,7 @@ futures = { workspace = true } sysinfo = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } +slect = { workspace = true } [lints] workspace = true diff --git a/migration/cli/migrate-node/docs/cli/README.md b/migration/cli/migrate-node/docs/cli/README.md index fd165d2..cc5447f 100644 --- a/migration/cli/migrate-node/docs/cli/README.md +++ b/migration/cli/migrate-node/docs/cli/README.md @@ -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` @@ -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: -* `using` — Run migrate with parameters from environment variables, config files, and CLI flags. See Orfile documentation for more details: +* `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: +Core migration over the node -**Usage:** `mtma-migrate-node migrate where --movement-state-db-path --movement-aptos-state-db-path ` +**Usage:** `mtma-migrate-node migrate core --movement-state-db-path --movement-aptos-state-db-path ` ###### **Options:** @@ -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: +Select migration over the node -**Usage:** `mtma-migrate-node migrate using [OPTIONS] [EXTRA_ARGS]...` +**Usage:** `mtma-migrate-node migrate select [OPTIONS] [-- ...]` ###### **Arguments:** -* `` — Extra arguments to be passed to the CLI +* `` — Extra arguments to be passed to selections ###### **Options:** -* `--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') + + diff --git a/migration/cli/migrate-node/src/cli.rs b/migration/cli/migrate-node/src/cli.rs index 128f034..53d41ab 100644 --- a/migration/cli/migrate-node/src/cli.rs +++ b/migration/cli/migrate-node/src/cli.rs @@ -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`. diff --git a/migration/cli/migrate-node/src/cli/migrate.rs b/migration/cli/migrate-node/src/cli/migrate.rs index 0a4c160..5d8b1f2 100644 --- a/migration/cli/migrate-node/src/cli/migrate.rs +++ b/migration/cli/migrate-node/src/cli/migrate.rs @@ -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, + } } } diff --git a/migration/cli/migrate-node/src/cli/migrate/core.rs b/migration/cli/migrate-node/src/cli/migrate/core.rs new file mode 100644 index 0000000..a6dbc66 --- /dev/null +++ b/migration/cli/migrate-node/src/cli/migrate/core.rs @@ -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 + } +} diff --git a/migration/cli/migrate-node/src/cli/migrate/select.rs b/migration/cli/migrate-node/src/cli/migrate/select.rs new file mode 100644 index 0000000..bafab57 --- /dev/null +++ b/migration/cli/migrate-node/src/cli/migrate/select.rs @@ -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, +} + +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(()) + } +}