From 0871f671bcfef7fa642d21b1d8e90fcac54df704 Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Fri, 13 Jun 2025 15:54:40 +0800 Subject: [PATCH 01/11] feat: simplistic version of box environment for demonstration. --- Cargo.lock | 18 ++ Cargo.toml | 4 +- .../checks/pre-l1-merge/src/pre_l1_merge.rs | 2 +- migration/core/migrator/mtma-null/Cargo.toml | 1 + .../migrator/mtma-null/src/migrate/migrate.rs | 21 +- migration/core/node/mtma-null/Cargo.toml | 2 + .../node/mtma-null/src/migrate/migrate.rs | 21 +- migration/util/migrator-types/Cargo.toml | 2 + .../src/migrator/movement_migrator.rs | 37 ++++ .../src/migrator/movement_migrator/live.rs | 59 ++++++ migration/util/node-types/Cargo.toml | 1 + .../src/executor/movement_executor.rs | 146 +------------ util/movement/core/src/config.rs | 4 +- util/movement/core/src/movement.rs | 109 +++++++--- util/util/Cargo.toml | 21 ++ util/util/README.md | 2 + util/util/src/file.rs | 193 ++++++++++++++++++ util/util/src/lib.rs | 1 + 18 files changed, 443 insertions(+), 201 deletions(-) create mode 100644 migration/util/migrator-types/src/migrator/movement_migrator/live.rs create mode 100644 util/util/Cargo.toml create mode 100644 util/util/README.md create mode 100644 util/util/src/file.rs create mode 100644 util/util/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 96613bb..6fb9938 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15885,6 +15885,7 @@ dependencies = [ "dotenv", "mtma-node-types", "mtma-types", + "mtma-util", "orfile", "serde", "thiserror 1.0.69", @@ -16039,6 +16040,8 @@ dependencies = [ "movement-core", "mtma-node-types", "mtma-types", + "mtma-util", + "reqwest 0.12.15", "serde", "thiserror 1.0.69", "tracing", @@ -16101,6 +16104,7 @@ dependencies = [ "dotenv", "mtma-node-types", "mtma-types", + "mtma-util", "orfile", "serde", "thiserror 1.0.69", @@ -16230,6 +16234,7 @@ dependencies = [ "movement-aptos-core", "movement-util", "mtma-types", + "mtma-util", "serde", "tempfile", "thiserror 1.0.69", @@ -16374,6 +16379,19 @@ dependencies = [ "movement-core-util", ] +[[package]] +name = "mtma-util" +version = "0.0.1" +dependencies = [ + "anyhow", + "bcs 0.1.4", + "serde", + "thiserror 1.0.69", + "tokio", + "tracing", + "walkdir", +] + [[package]] name = "multer" version = "2.1.0" diff --git a/Cargo.toml b/Cargo.toml index 31c22fe..76b9104 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,8 @@ members = [ "util/movement/*", "util/movement-aptos/*", "util/bcs-ext", - "util/types" + "util/types", + "util/util" ] @@ -215,6 +216,7 @@ movement-aptos = { path = "util/movement-aptos/movement-aptos" } movement-aptos-core = { path = "util/movement-aptos/core" } movement-aptos-core-util = { path = "util/movement-aptos/core-util" } mtma-types = { path = "util/types" } +mtma-util = { path = "util/util" } ## Environments ### util diff --git a/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs b/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs index d756e6c..4e19dde 100644 --- a/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs +++ b/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs @@ -31,7 +31,7 @@ pub mod test { // Create a Movement instance with the config let movement = Movement::new( movement_config.clone(), - movement_core::MovementWorkspace::try_temp()?, + movement_core::MovementWorkspace::try_temp()?.into(), Overlays::default(), true, true, diff --git a/migration/core/migrator/mtma-null/Cargo.toml b/migration/core/migrator/mtma-null/Cargo.toml index 931b718..ce08e51 100644 --- a/migration/core/migrator/mtma-null/Cargo.toml +++ b/migration/core/migrator/mtma-null/Cargo.toml @@ -28,6 +28,7 @@ walkdir = { workspace = true } uuid = { workspace = true } tracing = { workspace = true } mtma-types = { workspace = true } +mtma-util = { workspace = true } [lints] workspace = true diff --git a/migration/core/migrator/mtma-null/src/migrate/migrate.rs b/migration/core/migrator/mtma-null/src/migrate/migrate.rs index ee1b607..f97e360 100644 --- a/migration/core/migrator/mtma-null/src/migrate/migrate.rs +++ b/migration/core/migrator/mtma-null/src/migrate/migrate.rs @@ -8,28 +8,9 @@ use mtma_types::movement_aptos::aptos_db::AptosDB; use mtma_types::movement_aptos::aptos_storage_interface::DbReaderWriter; use anyhow::Context; -use std::fs; +use mtma_util::file::copy_dir_recursive; use std::path::Path; use tracing::info; -use walkdir::WalkDir; - -/// Copies a directory recursively. -/// -/// todo: move this out of the migration module -fn copy_dir_recursive(src: &Path, dst: &Path) -> std::io::Result<()> { - for entry in WalkDir::new(src) { - let entry = entry?; - let rel_path = entry.path().strip_prefix(src).unwrap(); - let dest_path = dst.join(rel_path); - - if entry.file_type().is_dir() { - fs::create_dir_all(&dest_path)?; - } else { - fs::copy(entry.path(), &dest_path)?; - } - } - Ok(()) -} /// Errors thrown during the migration. #[derive(Debug, thiserror::Error)] diff --git a/migration/core/node/mtma-null/Cargo.toml b/migration/core/node/mtma-null/Cargo.toml index 779760c..16c8972 100644 --- a/migration/core/node/mtma-null/Cargo.toml +++ b/migration/core/node/mtma-null/Cargo.toml @@ -28,5 +28,7 @@ walkdir = { workspace = true } uuid = { workspace = true } tracing = { workspace = true } mtma-types = { workspace = true } +mtma-util = { workspace = true } + [lints] workspace = true diff --git a/migration/core/node/mtma-null/src/migrate/migrate.rs b/migration/core/node/mtma-null/src/migrate/migrate.rs index f2fc080..2d1eca3 100644 --- a/migration/core/node/mtma-null/src/migrate/migrate.rs +++ b/migration/core/node/mtma-null/src/migrate/migrate.rs @@ -7,28 +7,9 @@ use mtma_types::movement_aptos::aptos_db::AptosDB; use mtma_types::movement_aptos::aptos_storage_interface::DbReaderWriter; use anyhow::Context; -use std::fs; +use mtma_util::file::copy_dir_recursive; use std::path::Path; use tracing::info; -use walkdir::WalkDir; - -/// Copies a directory recursively. -/// -/// todo: move this out of the migration module -fn copy_dir_recursive(src: &Path, dst: &Path) -> std::io::Result<()> { - for entry in WalkDir::new(src) { - let entry = entry?; - let rel_path = entry.path().strip_prefix(src).unwrap(); - let dest_path = dst.join(rel_path); - - if entry.file_type().is_dir() { - fs::create_dir_all(&dest_path)?; - } else { - fs::copy(entry.path(), &dest_path)?; - } - } - Ok(()) -} /// Errors thrown during the migration. #[derive(Debug, thiserror::Error)] diff --git a/migration/util/migrator-types/Cargo.toml b/migration/util/migrator-types/Cargo.toml index b262d46..e57016b 100644 --- a/migration/util/migrator-types/Cargo.toml +++ b/migration/util/migrator-types/Cargo.toml @@ -28,6 +28,8 @@ movement-client = { workspace = true } aptos-rest-client = { workspace = true } aptos-config = { workspace = true } mtma-types = { workspace = true } +reqwest = { workspace = true } +mtma-util = { workspace = true } [lints] workspace = true diff --git a/migration/util/migrator-types/src/migrator/movement_migrator.rs b/migration/util/migrator-types/src/migrator/movement_migrator.rs index e460dbc..48ffef9 100644 --- a/migration/util/migrator-types/src/migrator/movement_migrator.rs +++ b/migration/util/migrator-types/src/migrator/movement_migrator.rs @@ -5,6 +5,11 @@ pub use movement_core::{Overlay, Overlays}; use mtma_node_types::executor::MovementNode; pub use mtma_types::movement::aptos_types::{chain_id::ChainId, state_store::TStateView}; use mtma_types::movement::movement_client::rest_client::Client as MovementRestClient; +pub mod live; +pub use live::LiveMigrator; +use mtma_util::file::copy_dir_recursive; +use std::path::PathBuf; +use tracing::warn; /// An enum supporting different types of runners. /// @@ -14,6 +19,8 @@ use mtma_types::movement::movement_client::rest_client::Client as MovementRestCl pub enum Runner { /// [Movement] runner. Movement(Movement), + /// [LiveMigrator] runner. + Live(LiveMigrator), } /// The Movement migration struct as would be presented in the criterion. @@ -35,6 +42,7 @@ impl MovementMigrator { pub async fn run(&self) -> Result<(), anyhow::Error> { match &self.runner { Runner::Movement(movement) => Ok(movement.run().await?), + Runner::Live(live) => Ok(live.run().await?), } } @@ -71,6 +79,7 @@ impl MovementMigrator { .context("failed to wait for Movement rest api")?; Ok(rest_api.listen_url().to_string()) } + Runner::Live(live) => live.wait_for_live_rest_api_url().await, } } @@ -94,6 +103,7 @@ impl MovementMigrator { Runner::Movement(movement) => { MovementNode::try_from_dir(movement.workspace_path().to_path_buf()).await } + Runner::Live(live) => MovementNode::try_from_dir(live.dir.clone()).await, } } @@ -101,6 +111,33 @@ impl MovementMigrator { pub fn set_overlays(&mut self, overlays: Overlays) { match &mut self.runner { Runner::Movement(movement) => movement.set_overlays(overlays), + Runner::Live(_live) => { + warn!("Setting overlays for live migrator is not supported as the runner is already live. If you want to set overlays consider snapshotting the live migrator and using that as a movement runner."); + } + } + } + + /// Gets the dir for the runner + pub fn dir(&self) -> PathBuf { + match &self.runner { + Runner::Movement(movement) => movement.workspace_path().to_path_buf(), + Runner::Live(live) => live.dir.clone(), } } + + /// Recursively copies the dir for the runner to the given path + pub async fn copy_dir(&self, path: PathBuf) -> Result<(), anyhow::Error> { + let dir = self.dir(); + copy_dir_recursive(&dir, &path).context("failed to copy dir for MovementMigrator")?; + Ok(()) + } + + /// Snapshots the migrator + /// + /// NOTE: this can be used to, for example, transition from a live migrator to a movement runner. + pub async fn snapshot(&self, path: PathBuf) -> Result { + self.copy_dir(path.clone()).await?; + + Ok(Self::new(Runner::Movement(Movement::try_from_dot_movement_dir(path)?))) + } } diff --git a/migration/util/migrator-types/src/migrator/movement_migrator/live.rs b/migration/util/migrator-types/src/migrator/movement_migrator/live.rs new file mode 100644 index 0000000..f35ed36 --- /dev/null +++ b/migration/util/migrator-types/src/migrator/movement_migrator/live.rs @@ -0,0 +1,59 @@ +use std::path::PathBuf; +use tracing::warn; + +#[derive(Debug, Clone)] +pub struct LiveMigrator { + pub rest_api_url: String, + pub dir: PathBuf, +} + +impl LiveMigrator { + pub fn new(rest_api_url: String, dir: PathBuf) -> Self { + Self { rest_api_url, dir } + } +} + +impl LiveMigrator { + pub async fn run(&self) -> Result<(), anyhow::Error> { + // checks for liveness by polling the rest api url + // once it becomes read the firs time, it should not later return an error + let mut ready = false; + loop { + match reqwest::get(self.rest_api_url.clone()).await { + Ok(response) => { + if response.status().is_success() { + ready = true; + continue; + } else if response.status().is_server_error() && ready { + return Err(anyhow::anyhow!("live migrator failed health check")); + } else { + warn!("live migrator not yet ready: response: {:?}", response); + } + } + Err(e) => { + warn!("failed to poll live migrator: {}", e); + if ready { + return Err(anyhow::anyhow!("live migrator failed health check")); + } + } + } + } + } + + pub async fn wait_for_live_rest_api_url(&self) -> Result { + // us request to poll the rest API url until is ready + loop { + match reqwest::get(self.rest_api_url.clone()).await { + Ok(response) => { + if response.status().is_success() { + return Ok(self.rest_api_url.clone()); + } + warn!("rest api url is not ready yet: response: {:?}", response); + } + Err(e) => { + warn!("failed to poll rest api url: {}", e); + } + } + } + } +} diff --git a/migration/util/node-types/Cargo.toml b/migration/util/node-types/Cargo.toml index f04bb45..513c726 100644 --- a/migration/util/node-types/Cargo.toml +++ b/migration/util/node-types/Cargo.toml @@ -27,6 +27,7 @@ movement-util = { workspace = true } uuid = { workspace = true } walkdir = { workspace = true } mtma-types = { workspace = true } +mtma-util = { workspace = true } [dev-dependencies] tempfile = { workspace = true } diff --git a/migration/util/node-types/src/executor/movement_executor.rs b/migration/util/node-types/src/executor/movement_executor.rs index f728a35..609210a 100644 --- a/migration/util/node-types/src/executor/movement_executor.rs +++ b/migration/util/node-types/src/executor/movement_executor.rs @@ -22,6 +22,7 @@ use std::sync::Arc; use tracing::info; pub use maptos_opt_executor; +use mtma_util::file::copy_dir_recursive_with_ignore; use tracing::debug; use uuid::Uuid; use walkdir::WalkDir; @@ -34,76 +35,6 @@ pub struct MovementNode { opt_executor: MovementOptExecutor, } -/// Copies a directory recursively while ignoring specified paths -fn copy_dir_recursive_with_ignore(src: &Path, ignore_paths: impl IntoIterator>, dst: &Path) -> Result<(), anyhow::Error> { - let ignore_paths: Vec<_> = ignore_paths.into_iter().collect(); - let mut errors: Vec> = Vec::new(); - - // Configure WalkDir to be more resilient - let walker = WalkDir::new(src) - .follow_links(false) - .same_file_system(true) - .into_iter() - .filter_entry(|entry| { - // Early filter for ignored paths to avoid permission errors - let path = entry.path(); - !ignore_paths.iter().any(|ignore| path.to_string_lossy().contains(ignore.as_ref().to_string_lossy().as_ref())) - }); - - for entry in walker { - let entry = match entry { - Ok(e) => e, - Err(e) => { - // Check if this is a permission error on an ignored path - if let Some(path) = e.path() { - if ignore_paths.iter().any(|ignore| path.to_string_lossy().contains(ignore.as_ref().to_string_lossy().as_ref())) { - debug!("Ignoring permission error on ignored path: {}", path.display()); - continue; - } - } - // For other errors, log with info for now and fail. - info!("Error accessing path: {:?}", e); - errors.push(Err(anyhow::anyhow!("failed to get entry: {:?}", e))); - continue; - } - }; - - debug!("Processing entry: {}", entry.path().display()); - - let path = entry.path(); - let dest_path = dst.join(path.strip_prefix(src).context("failed to strip prefix")?); - - if entry.file_type().is_dir() { - match fs::create_dir_all(&dest_path) { - Ok(_) => (), - Err(e) => errors.push(Err(e.into())), - } - } else { - if let Some(parent) = dest_path.parent() { - match fs::create_dir_all(parent) { - Ok(_) => (), - Err(e) => errors.push(Err(e.into())), - } - } - match fs::copy(path, &dest_path) { - Ok(_) => (), - Err(e) => errors.push(Err(e.into())), - } - } - } - - // Combine all results into one - if !errors.is_empty() { - let mut total_error_message = String::from("failed to copy directory with the following errors: "); - for error in errors { - total_error_message = total_error_message + &format!("{:?}\n", error); - } - return Err(anyhow::anyhow!(total_error_message)); - } - - Ok(()) -} - /// Sets all permission in a directory recursively. fn set_permissions_recursive(path: &Path, permissions: Permissions) -> std::io::Result<()> { for entry in WalkDir::new(path) { @@ -132,16 +63,23 @@ impl MovementNode { // set the permissions on the movement dir to 755 // Note: this would mess up celestia node permissions, but we don't care about that here. // We really only care about maptos db permissions. - fs::set_permissions(&movement_dir, Permissions::from_mode(0o755)).context(format!("failed to set permissions on the movement directory {}", movement_dir.display()))?; + fs::set_permissions(&movement_dir, Permissions::from_mode(0o755)).context(format!( + "failed to set permissions on the movement directory {}", + movement_dir.display() + ))?; // don't copy anything from the celestia directory - copy_dir_recursive_with_ignore(&movement_dir, [PathBuf::from("celestia")], &debug_dir).context("failed to copy movement dir")?; + copy_dir_recursive_with_ignore(&movement_dir, [PathBuf::from("celestia")], &debug_dir) + .context("failed to copy movement dir")?; // Set all permissions in the debug directory recursively // Note: this would mess up celestia node permissions, but we don't care about that here. // We really only care about maptos db permissions. // TODO: tighten the copying accordingly. - set_permissions_recursive(&debug_dir, Permissions::from_mode(0o755)).context(format!("failed to set permissions on the debug directory {}", debug_dir.display()))?; + set_permissions_recursive(&debug_dir, Permissions::from_mode(0o755)).context(format!( + "failed to set permissions on the debug directory {}", + debug_dir.display() + ))?; let movement_args = MovementArgs { movement_path: Some(debug_dir.display().to_string()) }; @@ -476,65 +414,3 @@ impl<'a> Iterator for AccountAddressIterator<'a> { self.get_next_address() } } - -#[cfg(test)] -mod test { - use super::*; - use tempfile::TempDir; - - #[test] - #[tracing_test::traced_test] - fn test_copy_dir_recursive_with_ignore() -> Result<(), anyhow::Error> { - // put some file in a temp dir - let temp_dir = TempDir::new()?; - - // write a file that should be copied - let file_path = temp_dir.path().join("maptos").join("test_file.txt"); - fs::create_dir_all(file_path.parent().context("failed to get parent directory for file that should be copied")?).context("failed to create directory")?; - fs::write(file_path, "test").context("failed to write file that should be copied")?; - - // write a file that should not be copied - let file_path = temp_dir.path().join("celestia").join("test_file2.txt"); - fs::create_dir_all(file_path.parent().context("failed to get parent directory for file that should not be copied")?).context("failed to create directory")?; - fs::write(file_path, "test").context("failed to write file that should not be copied")?; - - // create the target temp dir - let dst = TempDir::new()?; - - // copy the file to a new dir, ignoring celestia directory - copy_dir_recursive_with_ignore(&temp_dir.path(), [PathBuf::from("celestia")], &dst.path()).context("failed to copy directory")?; - - // check that the file was copied - assert!(dst.path().join("maptos").join("test_file.txt").exists()); - - // check that the celestia directory was not copied - assert!(!dst.path().join("celestia").join("test_file2.txt").exists()); - - Ok(()) - } - - // Somehow the following test is failing on CI: https://github.com/movementlabsxyz/movement-migration/actions/runs/15386989846/job/43287594343 - // This indicates that failure is not due to the inability to ignore copy, but rather some issue performing an oepration that requires permissions. - #[test] - fn test_are_you_kidding_me() -> Result<(), anyhow::Error> { - - let source_dir = TempDir::new()?; - let target_dir = TempDir::new()?; - - let path_that_must_be_ignored = source_dir.path().join(".movement/celestia/c1860ae680eb2d91927b/.celestia-app/keyring-test"); - - fs::create_dir_all(path_that_must_be_ignored.parent().context("failed to get parent directory for path that must be ignored")?).context("failed to create directory")?; - // write a file that must not be ignored - fs::write(path_that_must_be_ignored.clone(), "test").context("failed to write file that must not be ignored")?; - // set permissions to 000 on the file and then on the parent directory - fs::set_permissions(path_that_must_be_ignored.clone(), Permissions::from_mode(0o000)).context("failed to set permissions on file that must not be ignored")?; - fs::set_permissions(path_that_must_be_ignored.parent().context("failed to get parent directory for path that must be ignored")?, Permissions::from_mode(0o000)).context("failed to set permissions on parent directory that must not be ignored")?; - - copy_dir_recursive_with_ignore(source_dir.path(), ["celestia"], target_dir.path()).context("failed to copy directory")?; - - assert!(!target_dir.path().join("celestia").join("c1860ae680eb2d91927b").join(".celestia-app").join("keyring-test").exists()); - - Ok(()) - } - -} \ No newline at end of file diff --git a/util/movement/core/src/config.rs b/util/movement/core/src/config.rs index a66c8b0..31f6f1d 100644 --- a/util/movement/core/src/config.rs +++ b/util/movement/core/src/config.rs @@ -79,7 +79,9 @@ impl Config { pub fn build(&self) -> Result { Ok(Movement::new( self.movement_config().map_err(|e| ConfigError::Internal(e.into()))?, - MovementWorkspace::try_temp().map_err(|e| ConfigError::Internal(e.into()))?, + MovementWorkspace::try_temp() + .map_err(|e| ConfigError::Internal(e.into()))? + .into(), self.overlays(), self.ping_rest_api, self.ping_faucet, diff --git a/util/movement/core/src/movement.rs b/util/movement/core/src/movement.rs index 70de6f2..e6f5185 100644 --- a/util/movement/core/src/movement.rs +++ b/util/movement/core/src/movement.rs @@ -157,12 +157,39 @@ impl Default for Overlays { } } +#[derive(Debug, Clone)] +pub enum Workspace { + Vendor(Arc), + Path(PathBuf), +} + +impl Workspace { + pub fn get_workspace_path(&self) -> &Path { + match self { + Self::Vendor(workspace) => workspace.get_workspace_path(), + Self::Path(path) => path, + } + } +} + +impl From for Workspace { + fn from(workspace: MovementWorkspace) -> Self { + Self::Vendor(Arc::new(workspace)) + } +} + +impl From for Workspace { + fn from(path: PathBuf) -> Self { + Self::Path(path) + } +} + #[derive(Clone)] pub struct Movement { /// The config for the movement runner. movement_config: MovementConfig, /// The workspace in which [Movement] shall be run. - workspace: Arc, + workspace: Workspace, /// The overlays to apply to the movement runner. overlays: Overlays, /// Whether to ping the rest api to ensure it is responding to pings. @@ -186,14 +213,14 @@ impl Movement { /// Creates a new [Movement] with the given workspace and overlays. pub fn new( movement_config: MovementConfig, - workspace: MovementWorkspace, + workspace: Workspace, overlays: Overlays, ping_rest_api: bool, ping_faucet: bool, ) -> Self { Self { movement_config, - workspace: Arc::new(workspace), + workspace, overlays, ping_rest_api, rest_api: State::new(), @@ -202,25 +229,43 @@ impl Movement { } } + /// Tries to form a [Movement] from a well-formed `.movement` directory. + pub fn try_from_dot_movement_dir(path: PathBuf) -> Result { + // read the [MovementConfig] from the .movement/config.json file + let config_path = path.join(".movement/config.json"); + let config = + std::fs::read_to_string(config_path).map_err(|e| MovementError::Internal(e.into()))?; + let config: MovementConfig = + serde_json::from_str(&config).map_err(|e| MovementError::Internal(e.into()))?; + + // set the workspace to the path + let workspace = Workspace::Path(path); + + Ok(Self::new(config, workspace, BTreeSet::new().into(), true, true)) + } + /// Creates a new [Movement] with a temporary workspace. pub fn try_temp() -> Result { - let workspace = - MovementWorkspace::try_temp().map_err(|e| MovementError::Internal(e.into()))?; + let workspace = Workspace::Vendor(Arc::new( + MovementWorkspace::try_temp().map_err(|e| MovementError::Internal(e.into()))?, + )); Ok(Self::new(MovementConfig::default(), workspace, BTreeSet::new().into(), true, true)) } /// Creates a new [Movement] within a debug directory. pub fn try_debug() -> Result { - let workspace = - MovementWorkspace::try_debug().map_err(|e| MovementError::Internal(e.into()))?; + let workspace = Workspace::Vendor(Arc::new( + MovementWorkspace::try_debug().map_err(|e| MovementError::Internal(e.into()))?, + )); Ok(Self::new(MovementConfig::default(), workspace, BTreeSet::new().into(), true, true)) } /// Creates a new [Movement] within a debug home directory. pub fn try_debug_home() -> Result { - let workspace = - MovementWorkspace::try_debug_home().map_err(|e| MovementError::Internal(e.into()))?; + let workspace = Workspace::Vendor(Arc::new( + MovementWorkspace::try_debug_home().map_err(|e| MovementError::Internal(e.into()))?, + )); Ok(Self::new(MovementConfig::default(), workspace, BTreeSet::new().into(), true, true)) } @@ -373,22 +418,40 @@ impl Movement { ); // get the prepared command for the movement task - let mut command = Command::new( - self.workspace - .prepared_command( - "nix", - [ - "develop", - "--command", - "bash", - "-c", - &format!( + let mut command = match &self.workspace { + // if this is a vendor workspace, we can use the prepared command + Workspace::Vendor(workspace) => Command::new( + workspace + .prepared_command( + "nix", + [ + "develop", + "--command", + "bash", + "-c", + &format!( "echo '' > .env && just movement-full-node docker-compose {overlays}" ), - ], - ) - .map_err(|e| MovementError::Internal(e.into()))?, - ); + ], + ) + .map_err(|e| MovementError::Internal(e.into()))?, + ), + // otherwise the dir should already be prepared + Workspace::Path(path) => Command::line( + "nix", + [ + "develop", + "--command", + "bash", + "-c", + &format!("echo '' > .env && just movement-full-node docker-compose {overlays}"), + ], + Some(path), + false, + vec![], + vec![], + ), + }; info!( "Writing movement config to {:?}", diff --git a/util/util/Cargo.toml b/util/util/Cargo.toml new file mode 100644 index 0000000..d1b2232 --- /dev/null +++ b/util/util/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "mtma-util" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +authors = { workspace = true } +homepage = { workspace = true } +publish = { workspace = true } +rust-version = { workspace = true } + +[dependencies] +serde = { workspace = true } +bcs = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true } +walkdir = { workspace = true } +anyhow = { workspace = true } +tracing = { workspace = true } + +[lints] +workspace = true diff --git a/util/util/README.md b/util/util/README.md new file mode 100644 index 0000000..6368be5 --- /dev/null +++ b/util/util/README.md @@ -0,0 +1,2 @@ +# `mtma-util` +Various utilities for `mtma`. \ No newline at end of file diff --git a/util/util/src/file.rs b/util/util/src/file.rs new file mode 100644 index 0000000..7d34c99 --- /dev/null +++ b/util/util/src/file.rs @@ -0,0 +1,193 @@ +use anyhow::Context; +use std::fs; +use std::path::Path; +use tracing::{debug, info}; +use walkdir::WalkDir; + +/// Copies a directory recursively. +pub fn copy_dir_recursive(src: &Path, dst: &Path) -> std::io::Result<()> { + for entry in WalkDir::new(src) { + let entry = entry?; + let rel_path = entry.path().strip_prefix(src).unwrap(); + let dest_path = dst.join(rel_path); + + if entry.file_type().is_dir() { + fs::create_dir_all(&dest_path)?; + } else { + fs::copy(entry.path(), &dest_path)?; + } + } + Ok(()) +} + +/// Copies a directory recursively while ignoring specified paths. +pub fn copy_dir_recursive_with_ignore( + src: &Path, + ignore_paths: impl IntoIterator>, + dst: &Path, +) -> Result<(), anyhow::Error> { + let ignore_paths: Vec<_> = ignore_paths.into_iter().collect(); + let mut errors: Vec> = Vec::new(); + + // Configure WalkDir to be more resilient + let walker = WalkDir::new(src) + .follow_links(false) + .same_file_system(true) + .into_iter() + .filter_entry(|entry| { + // Early filter for ignored paths to avoid permission errors + let path = entry.path(); + !ignore_paths.iter().any(|ignore| { + path.to_string_lossy().contains(ignore.as_ref().to_string_lossy().as_ref()) + }) + }); + + for entry in walker { + let entry = match entry { + Ok(e) => e, + Err(e) => { + // Check if this is a permission error on an ignored path + if let Some(path) = e.path() { + if ignore_paths.iter().any(|ignore| { + path.to_string_lossy().contains(ignore.as_ref().to_string_lossy().as_ref()) + }) { + debug!("Ignoring permission error on ignored path: {}", path.display()); + continue; + } + } + // For other errors, log with info for now and fail. + info!("Error accessing path: {:?}", e); + errors.push(Err(anyhow::anyhow!("failed to get entry: {:?}", e))); + continue; + } + }; + + debug!("Processing entry: {}", entry.path().display()); + + let path = entry.path(); + let dest_path = dst.join(path.strip_prefix(src).context("failed to strip prefix")?); + + if entry.file_type().is_dir() { + match fs::create_dir_all(&dest_path) { + Ok(_) => (), + Err(e) => errors.push(Err(e.into())), + } + } else { + if let Some(parent) = dest_path.parent() { + match fs::create_dir_all(parent) { + Ok(_) => (), + Err(e) => errors.push(Err(e.into())), + } + } + match fs::copy(path, &dest_path) { + Ok(_) => (), + Err(e) => errors.push(Err(e.into())), + } + } + } + + // Combine all results into one + if !errors.is_empty() { + let mut total_error_message = + String::from("failed to copy directory with the following errors: "); + for error in errors { + total_error_message = total_error_message + &format!("{:?}\n", error); + } + return Err(anyhow::anyhow!(total_error_message)); + } + + Ok(()) +} + +#[cfg(test)] +mod test { + use super::*; + use tempfile::TempDir; + + #[test] + #[tracing_test::traced_test] + fn test_copy_dir_recursive_with_ignore() -> Result<(), anyhow::Error> { + // put some file in a temp dir + let temp_dir = TempDir::new()?; + + // write a file that should be copied + let file_path = temp_dir.path().join("maptos").join("test_file.txt"); + fs::create_dir_all( + file_path + .parent() + .context("failed to get parent directory for file that should be copied")?, + ) + .context("failed to create directory")?; + fs::write(file_path, "test").context("failed to write file that should be copied")?; + + // write a file that should not be copied + let file_path = temp_dir.path().join("celestia").join("test_file2.txt"); + fs::create_dir_all( + file_path + .parent() + .context("failed to get parent directory for file that should not be copied")?, + ) + .context("failed to create directory")?; + fs::write(file_path, "test").context("failed to write file that should not be copied")?; + + // create the target temp dir + let dst = TempDir::new()?; + + // copy the file to a new dir, ignoring celestia directory + copy_dir_recursive_with_ignore(&temp_dir.path(), [PathBuf::from("celestia")], &dst.path()) + .context("failed to copy directory")?; + + // check that the file was copied + assert!(dst.path().join("maptos").join("test_file.txt").exists()); + + // check that the celestia directory was not copied + assert!(!dst.path().join("celestia").join("test_file2.txt").exists()); + + Ok(()) + } + + // Somehow the following test is failing on CI: https://github.com/movementlabsxyz/movement-migration/actions/runs/15386989846/job/43287594343 + // This indicates that failure is not due to the inability to ignore copy, but rather some issue performing an oepration that requires permissions. + #[test] + fn test_are_you_kidding_me() -> Result<(), anyhow::Error> { + let source_dir = TempDir::new()?; + let target_dir = TempDir::new()?; + + let path_that_must_be_ignored = source_dir + .path() + .join(".movement/celestia/c1860ae680eb2d91927b/.celestia-app/keyring-test"); + + fs::create_dir_all( + path_that_must_be_ignored + .parent() + .context("failed to get parent directory for path that must be ignored")?, + ) + .context("failed to create directory")?; + // write a file that must not be ignored + fs::write(path_that_must_be_ignored.clone(), "test") + .context("failed to write file that must not be ignored")?; + // set permissions to 000 on the file and then on the parent directory + fs::set_permissions(path_that_must_be_ignored.clone(), Permissions::from_mode(0o000)) + .context("failed to set permissions on file that must not be ignored")?; + fs::set_permissions( + path_that_must_be_ignored + .parent() + .context("failed to get parent directory for path that must be ignored")?, + Permissions::from_mode(0o000), + ) + .context("failed to set permissions on parent directory that must not be ignored")?; + + copy_dir_recursive_with_ignore(source_dir.path(), ["celestia"], target_dir.path()) + .context("failed to copy directory")?; + + assert!(!target_dir + .path() + .join("celestia") + .join("c1860ae680eb2d91927b") + .join(".celestia-app") + .join("keyring-test") + .exists()); + + Ok(()) + } +} diff --git a/util/util/src/lib.rs b/util/util/src/lib.rs new file mode 100644 index 0000000..2e172cd --- /dev/null +++ b/util/util/src/lib.rs @@ -0,0 +1 @@ +pub mod file; From 56c6d970007cbc6ff6fde8b91d95e2ba864fa51e Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Fri, 13 Jun 2025 16:11:11 +0800 Subject: [PATCH 02/11] chore: clean up path types. --- .../util/migrator-types/src/migrator/movement_migrator.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/util/migrator-types/src/migrator/movement_migrator.rs b/migration/util/migrator-types/src/migrator/movement_migrator.rs index 48ffef9..e883847 100644 --- a/migration/util/migrator-types/src/migrator/movement_migrator.rs +++ b/migration/util/migrator-types/src/migrator/movement_migrator.rs @@ -8,7 +8,7 @@ use mtma_types::movement::movement_client::rest_client::Client as MovementRestCl pub mod live; pub use live::LiveMigrator; use mtma_util::file::copy_dir_recursive; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use tracing::warn; /// An enum supporting different types of runners. @@ -126,9 +126,9 @@ impl MovementMigrator { } /// Recursively copies the dir for the runner to the given path - pub async fn copy_dir(&self, path: PathBuf) -> Result<(), anyhow::Error> { + pub async fn copy_dir(&self, path: &Path) -> Result<(), anyhow::Error> { let dir = self.dir(); - copy_dir_recursive(&dir, &path).context("failed to copy dir for MovementMigrator")?; + copy_dir_recursive(&dir, path).context("failed to copy dir for MovementMigrator")?; Ok(()) } @@ -136,7 +136,7 @@ impl MovementMigrator { /// /// NOTE: this can be used to, for example, transition from a live migrator to a movement runner. pub async fn snapshot(&self, path: PathBuf) -> Result { - self.copy_dir(path.clone()).await?; + self.copy_dir(&path).await?; Ok(Self::new(Runner::Movement(Movement::try_from_dot_movement_dir(path)?))) } From 471acc6d4b02445d78641c970dc2f769b5e32d8c Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Fri, 13 Jun 2025 16:25:55 +0800 Subject: [PATCH 03/11] chore: add test for snapshotting. --- Cargo.lock | 2 + migration/util/migrator-types/Cargo.toml | 4 ++ .../src/migrator/movement_migrator.rs | 41 +++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 6fb9938..33741c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16043,7 +16043,9 @@ dependencies = [ "mtma-util", "reqwest 0.12.15", "serde", + "tempfile", "thiserror 1.0.69", + "tokio", "tracing", ] diff --git a/migration/util/migrator-types/Cargo.toml b/migration/util/migrator-types/Cargo.toml index e57016b..b7cbfe3 100644 --- a/migration/util/migrator-types/Cargo.toml +++ b/migration/util/migrator-types/Cargo.toml @@ -30,6 +30,10 @@ aptos-config = { workspace = true } mtma-types = { workspace = true } reqwest = { workspace = true } mtma-util = { workspace = true } +tokio = { workspace = true } + +[dev-dependencies] +tempfile = { workspace = true } [lints] workspace = true diff --git a/migration/util/migrator-types/src/migrator/movement_migrator.rs b/migration/util/migrator-types/src/migrator/movement_migrator.rs index e883847..6ee6f14 100644 --- a/migration/util/migrator-types/src/migrator/movement_migrator.rs +++ b/migration/util/migrator-types/src/migrator/movement_migrator.rs @@ -141,3 +141,44 @@ impl MovementMigrator { Ok(Self::new(Runner::Movement(Movement::try_from_dot_movement_dir(path)?))) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn test_snapshot() -> Result<(), anyhow::Error> { + let mut migrator = MovementMigrator::try_temp()?; + migrator.set_overlays(Overlays::default()); + + let migrator_for_task = migrator.clone(); + let migrator_task = kestrel::task(async move { migrator_for_task.run().await }); + + // wait for the rest api to be ready + let _rest_api_url = + migrator.wait_for_rest_api_url(tokio::time::Duration::from_secs(300)).await?; + + // end the migrator task + kestrel::end!(migrator_task)?; + + // snapshot the migrator + let snapshot_dir = tempfile::tempdir()?; + let mut snapshot_migrator = migrator.snapshot(snapshot_dir.path().to_path_buf()).await?; + snapshot_migrator.set_overlays(Overlays::default()); + + // run the snapshot migrator + let snapshot_migrator_for_task = snapshot_migrator.clone(); + let snapshot_migrator_task = + kestrel::task(async move { snapshot_migrator_for_task.run().await }); + + // wait for the rest api to be ready + let _rest_api_url = snapshot_migrator + .wait_for_rest_api_url(tokio::time::Duration::from_secs(300)) + .await?; + + // end the snapshot migrator task + kestrel::end!(snapshot_migrator_task)?; + + Ok(()) + } +} From 8d33063a6dd57510f5b68aee9aeff0e5c45ce912 Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Fri, 13 Jun 2025 16:40:31 +0800 Subject: [PATCH 04/11] chore: snapshotting transition. --- .../core/box/src/environment/config.rs | 16 +++++- .../core/box/src/environment/environment.rs | 54 +++++++++++++++++-- migration/cli/migrate-node/docs/cli/README.md | 8 ++- 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/environments/core/box/src/environment/config.rs b/environments/core/box/src/environment/config.rs index e383436..c8af6e1 100644 --- a/environments/core/box/src/environment/config.rs +++ b/environments/core/box/src/environment/config.rs @@ -2,6 +2,7 @@ use crate::BoxEnvironment; use clap::Parser; use serde::{Deserialize, Serialize}; use std::fmt::Debug; +use std::path::PathBuf; /// Errors thrown when working with the [Config]. #[derive(Debug, thiserror::Error)] @@ -16,13 +17,24 @@ pub enum EnvironmentConfigError { /// This is the frontend for the core API. #[derive(Parser, Debug, Serialize, Deserialize, Clone, Default)] #[clap(help_expected = true)] -pub struct Config {} +pub struct Config { + /// The rest api url of the box environment. + pub rest_api_url: String, + /// The db dir of the box environment. + pub db_dir: PathBuf, + /// Whether to isolate the box environment by snapshotting the movement runner and where to store the snapshot. + pub snapshot_dir: Option, +} impl Config { /// Builds the [BoxEnvironment] struct from the config. /// /// Note: preserving faillibility here because we may add debug path configuration to the [BoxEnvironment] soon. pub fn build(&self) -> Result { - Ok(BoxEnvironment::new()) + Ok(BoxEnvironment::new( + self.rest_api_url.clone(), + self.db_dir.clone(), + self.snapshot_dir.clone(), + )) } } diff --git a/environments/core/box/src/environment/environment.rs b/environments/core/box/src/environment/environment.rs index 9462687..3b1044c 100644 --- a/environments/core/box/src/environment/environment.rs +++ b/environments/core/box/src/environment/environment.rs @@ -1,6 +1,11 @@ +use anyhow::Context; use mtma_environment_types::{EnvironmentError, Environmentish}; -use mtma_migrator_types::migrator::MovementMigrator; +use mtma_migrator_types::migrator::{ + movement_migrator::{LiveMigrator, Runner}, + MovementMigrator, +}; use std::fmt::Debug; +use std::path::PathBuf; /// Errors thrown when using the [BoxEnvironment]. #[derive(Debug, thiserror::Error)] @@ -15,16 +20,55 @@ impl From for EnvironmentError { } } -pub struct BoxEnvironment {} +pub struct BoxEnvironment { + /// The rest api url of the box environment. + pub rest_api_url: String, + /// The db dir of the box environment. + pub db_dir: PathBuf, + /// Whether to isolate the box environment by snapshotting the movement runner and where to store the snapshot. + pub snapshot_dir: Option, +} impl BoxEnvironment { - pub fn new() -> Self { - Self {} + pub fn new(rest_api_url: String, db_dir: PathBuf, snapshot_dir: Option) -> Self { + Self { rest_api_url, db_dir, snapshot_dir } } } impl Environmentish for BoxEnvironment { async fn build_movement_migrator(&self) -> Result { - Err(BoxEnvironmentError::Internal(anyhow::anyhow!("not implemented").into()).into()) + // construct the live migrator + let movement_migrator = MovementMigrator::new(Runner::Live(LiveMigrator::new( + self.rest_api_url.clone(), + self.db_dir.clone(), + ))); + + // make sure the live migrator is ready + let movement_migrator_for_task = movement_migrator.clone(); + let migrator_task = kestrel::task(async move { movement_migrator_for_task.run().await }); + + // wait for the rest api to be ready + let _rest_api_url = movement_migrator + .wait_for_rest_api_url(tokio::time::Duration::from_secs(300)) + .await + .context("failed to wait for the rest api to be ready") + .map_err(|e| BoxEnvironmentError::Internal(e.into()))?; + + // end the migrator task + kestrel::end!(migrator_task) + .context("failed to end the migrator task") + .map_err(|e| BoxEnvironmentError::Internal(e.into()))?; + + // if we're snapshotting the movement_migrator should be a snapshot of the live migrator + let movement_migrator = match &self.snapshot_dir { + Some(snapshot_dir) => movement_migrator + .snapshot(snapshot_dir.clone()) + .await + .context("failed to snapshot the movement migrator") + .map_err(|e| BoxEnvironmentError::Internal(e.into()))?, + None => movement_migrator, + }; + + Ok(movement_migrator) } } diff --git a/migration/cli/migrate-node/docs/cli/README.md b/migration/cli/migrate-node/docs/cli/README.md index 95ea71a..f24821a 100644 --- a/migration/cli/migrate-node/docs/cli/README.md +++ b/migration/cli/migrate-node/docs/cli/README.md @@ -140,7 +140,13 @@ Options: **Selection (2/4):** `environment-box` The config for the [BoxEnvironment] -Usage: --environment-box.* +Usage: --environment-box.* [SNAPSHOT_DIR] + +Arguments: + The rest api url of the box environment + The db dir of the box environment + [SNAPSHOT_DIR] Whether to isolate the box environment by snapshotting the movement runner and where to store the + snapshot Options: -h, --help Print help (see more with '--help') From 77dcbbffa193f701200974059e6d0f6286268e14 Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Fri, 13 Jun 2025 16:49:22 +0800 Subject: [PATCH 05/11] chore: upgrade migate-node select to allow use of the box environment. --- .../migrate-node/src/cli/migrate/select.rs | 53 ++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/migration/cli/migrate-node/src/cli/migrate/select.rs b/migration/cli/migrate-node/src/cli/migrate/select.rs index 404fc5e..a1468a5 100644 --- a/migration/cli/migrate-node/src/cli/migrate/select.rs +++ b/migration/cli/migrate-node/src/cli/migrate/select.rs @@ -3,6 +3,7 @@ use clap::Parser; use mtma_box_environment::Config as BoxEnvironmentConfig; use mtma_environment_types::Environmentish; use mtma_migrator_types::migration::Migrationish; +use mtma_migrator_types::migrator::MovementMigrator; use mtma_node_null_core::Config as NullConfig; use mtma_provisioner_environment::Config as ProvisionerEnvironmentConfig; use mtma_testing_environment::Config as TestingEnvironmentConfig; @@ -19,12 +20,12 @@ pub struct Select { } impl select::Select { - pub async fn execute(&self) -> Result<(), anyhow::Error> { + pub async fn get_movement_migrator(&self) -> Result { let ( maybe_environment_testing, maybe_environment_box, maybe_environment_provisioner, - maybe_null, + _maybe_null, ) = self.select().map_err(|e| anyhow::anyhow!("{}", e))?; // if more than one environment is provided, we need to error @@ -38,11 +39,51 @@ impl select::Select { )); } - let environment_config = maybe_environment_testing.context( - "--environment-testing is the only supported environment; it must be provided", - )?; + match maybe_environment_testing { + Some(environment_testing) => { + let environment_config = environment_testing.build()?; + return environment_config + .build_movement_migrator() + .await + .map_err(|e| anyhow::anyhow!("{}", e)); + } + None => {} + } + + match maybe_environment_box { + Some(environment_box) => { + let environment_config = environment_box.build()?; + return environment_config + .build_movement_migrator() + .await + .map_err(|e| anyhow::anyhow!("{}", e)); + } + None => {} + } + + match maybe_environment_provisioner { + Some(environment_provisioner) => { + let environment_config = environment_provisioner.build()?; + return environment_config + .build_movement_migrator() + .await + .map_err(|e| anyhow::anyhow!("{}", e)); + } + None => {} + } + + return Err(anyhow::anyhow!("no environment provided")); + } + + pub async fn execute(&self) -> Result<(), anyhow::Error> { + let ( + _maybe_environment_testing, + _maybe_environment_box, + _maybe_environment_provisioner, + maybe_null, + ) = self.select().map_err(|e| anyhow::anyhow!("{}", e))?; - let movement_migrator = environment_config.build()?.build_movement_migrator().await?; + let movement_migrator = self.get_movement_migrator().await?; if let Some(null) = maybe_null { let null_migration = null.build()?; From 3c0fd388a5b1e6206554ffcef7e639d91e021c2d Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Fri, 13 Jun 2025 17:12:42 +0800 Subject: [PATCH 06/11] chore: fix unusued deps. --- Cargo.lock | 8 ++------ migration/core/migrator/mtma-null/Cargo.toml | 1 - migration/core/node/mtma-null/Cargo.toml | 1 - util/util/Cargo.toml | 8 ++++---- util/util/src/file.rs | 3 +++ 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a5b51d..81d7784 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15711,7 +15711,6 @@ dependencies = [ "thiserror 1.0.69", "tracing", "uuid", - "walkdir", ] [[package]] @@ -15880,7 +15879,6 @@ dependencies = [ "thiserror 1.0.69", "tracing", "uuid", - "walkdir", ] [[package]] @@ -16051,11 +16049,9 @@ name = "mtma-util" version = "0.0.1" dependencies = [ "anyhow", - "bcs 0.1.4", - "serde", - "thiserror 1.0.69", - "tokio", + "tempfile", "tracing", + "tracing-test", "walkdir", ] diff --git a/migration/core/migrator/mtma-null/Cargo.toml b/migration/core/migrator/mtma-null/Cargo.toml index e3edfe4..e6cafdb 100644 --- a/migration/core/migrator/mtma-null/Cargo.toml +++ b/migration/core/migrator/mtma-null/Cargo.toml @@ -15,7 +15,6 @@ anyhow = { workspace = true } thiserror = { workspace = true } mtma-node-types = { workspace = true } chrono = { workspace = true } -walkdir = { workspace = true } uuid = { workspace = true } tracing = { workspace = true } mtma-types = { workspace = true } diff --git a/migration/core/node/mtma-null/Cargo.toml b/migration/core/node/mtma-null/Cargo.toml index cd9f1e3..7199c83 100644 --- a/migration/core/node/mtma-null/Cargo.toml +++ b/migration/core/node/mtma-null/Cargo.toml @@ -15,7 +15,6 @@ anyhow = { workspace = true } thiserror = { workspace = true } mtma-node-types = { workspace = true } chrono = { workspace = true } -walkdir = { workspace = true } uuid = { workspace = true } tracing = { workspace = true } mtma-types = { workspace = true } diff --git a/util/util/Cargo.toml b/util/util/Cargo.toml index d1b2232..22d2ac3 100644 --- a/util/util/Cargo.toml +++ b/util/util/Cargo.toml @@ -9,13 +9,13 @@ publish = { workspace = true } rust-version = { workspace = true } [dependencies] -serde = { workspace = true } -bcs = { workspace = true } -thiserror = { workspace = true } -tokio = { workspace = true } walkdir = { workspace = true } anyhow = { workspace = true } tracing = { workspace = true } +[dev-dependencies] +tracing-test = { workspace = true } +tempfile = { workspace = true } + [lints] workspace = true diff --git a/util/util/src/file.rs b/util/util/src/file.rs index 7d34c99..c9c3223 100644 --- a/util/util/src/file.rs +++ b/util/util/src/file.rs @@ -102,6 +102,9 @@ pub fn copy_dir_recursive_with_ignore( #[cfg(test)] mod test { use super::*; + use std::fs::Permissions; + use std::os::unix::fs::PermissionsExt; + use std::path::PathBuf; use tempfile::TempDir; #[test] From 2fd5dac0f0da8fbb3d8031cb1c085a8d9a4ecee1 Mon Sep 17 00:00:00 2001 From: Liam Monninger Date: Mon, 16 Jun 2025 10:25:43 +0800 Subject: [PATCH 07/11] fix: config fields should be #[clap(long)] --- environments/core/box/src/environment/config.rs | 3 +++ migration/cli/migrate-node/docs/cli/README.md | 14 ++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/environments/core/box/src/environment/config.rs b/environments/core/box/src/environment/config.rs index c8af6e1..b3c1552 100644 --- a/environments/core/box/src/environment/config.rs +++ b/environments/core/box/src/environment/config.rs @@ -19,10 +19,13 @@ pub enum EnvironmentConfigError { #[clap(help_expected = true)] pub struct Config { /// The rest api url of the box environment. + #[clap(long)] pub rest_api_url: String, /// The db dir of the box environment. + #[clap(long)] pub db_dir: PathBuf, /// Whether to isolate the box environment by snapshotting the movement runner and where to store the snapshot. + #[clap(long)] pub snapshot_dir: Option, } diff --git a/migration/cli/migrate-node/docs/cli/README.md b/migration/cli/migrate-node/docs/cli/README.md index f24821a..74f11cd 100644 --- a/migration/cli/migrate-node/docs/cli/README.md +++ b/migration/cli/migrate-node/docs/cli/README.md @@ -140,16 +140,14 @@ Options: **Selection (2/4):** `environment-box` The config for the [BoxEnvironment] -Usage: --environment-box.* [SNAPSHOT_DIR] - -Arguments: - The rest api url of the box environment - The db dir of the box environment - [SNAPSHOT_DIR] Whether to isolate the box environment by snapshotting the movement runner and where to store the - snapshot +Usage: --environment-box.* [OPTIONS] --rest-api-url --db-dir Options: - -h, --help Print help (see more with '--help') + --rest-api-url The rest api url of the box environment + --db-dir The db dir of the box environment + --snapshot-dir Whether to isolate the box environment by snapshotting the movement runner and + where to store the snapshot + -h, --help Print help (see more with '--help') **Selection (3/4):** `environment-provisioner` The config for the [ProvisionerEnvironment] From 3e767090cb5be77a9a0b56f5b585b58c132b2012 Mon Sep 17 00:00:00 2001 From: Liam Monninger Date: Mon, 16 Jun 2025 10:39:21 +0800 Subject: [PATCH 08/11] debug: permissions error while snapshotting in ci. --- migration/cli/migrate-node/docs/cli/README.md | 4 ++-- util/util/src/file.rs | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/migration/cli/migrate-node/docs/cli/README.md b/migration/cli/migrate-node/docs/cli/README.md index 74f11cd..a3e5c6d 100644 --- a/migration/cli/migrate-node/docs/cli/README.md +++ b/migration/cli/migrate-node/docs/cli/README.md @@ -145,8 +145,8 @@ Usage: --environment-box.* [OPTIONS] --rest-api-url --db-dir The rest api url of the box environment --db-dir The db dir of the box environment - --snapshot-dir Whether to isolate the box environment by snapshotting the movement runner and - where to store the snapshot + --snapshot-dir Whether to isolate the box environment by snapshotting the movement runner and where to + store the snapshot -h, --help Print help (see more with '--help') **Selection (3/4):** `environment-provisioner` diff --git a/util/util/src/file.rs b/util/util/src/file.rs index c9c3223..a2f4ff7 100644 --- a/util/util/src/file.rs +++ b/util/util/src/file.rs @@ -5,16 +5,26 @@ use tracing::{debug, info}; use walkdir::WalkDir; /// Copies a directory recursively. -pub fn copy_dir_recursive(src: &Path, dst: &Path) -> std::io::Result<()> { +pub fn copy_dir_recursive(src: &Path, dst: &Path) -> Result<(), anyhow::Error> { for entry in WalkDir::new(src) { let entry = entry?; let rel_path = entry.path().strip_prefix(src).unwrap(); let dest_path = dst.join(rel_path); if entry.file_type().is_dir() { - fs::create_dir_all(&dest_path)?; + let permissions = fs::metadata(&entry.path()).context(format!( + "failed to get permissions while copying directory recursively from {src:?} {entry:?} to {dst:?}" + ))?; + fs::create_dir_all(&dest_path).context(format!( + "failed to create directory while copying directory recursively from {src:?} {entry:?} {permissions:?} to {dst:?}" + ))?; } else { - fs::copy(entry.path(), &dest_path)?; + let permissions = fs::metadata(&entry.path()).context(format!( + "failed to get permissions while copying file recursively from {src:?} {entry:?} to {dst:?}" + ))?; + fs::copy(entry.path(), &dest_path).context(format!( + "failed to copy file while copying directory recursively from {src:?} {entry:?} {permissions:?} to {dst:?}" + ))?; } } Ok(()) From 865374a89097b172b4cada85cc9d319aea2c3cf7 Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Tue, 17 Jun 2025 14:53:35 +0800 Subject: [PATCH 09/11] chore: try_debug_home may resolve permissions errors by moving movement-core workspace nix shell outside of current nix shell. --- checks/migrator/checks/balances-equal/src/balances_equal.rs | 2 +- .../matching-feature-flags/src/matching_feature_flags.rs | 2 +- checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs | 2 +- checks/migrator/checks/sketchpad/src/accounts_equal.rs | 2 +- checks/migrator/checks/transacting/src/transacting.rs | 2 +- environments/core/testing/src/environment/environment.rs | 2 +- migration/cli/migrate-node/docs/cli/README.md | 4 ++-- .../util/migrator-types/src/migrator/movement_migrator.rs | 2 +- util/movement/core/src/config.rs | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/checks/migrator/checks/balances-equal/src/balances_equal.rs b/checks/migrator/checks/balances-equal/src/balances_equal.rs index ebce5fa..1ce9d48 100644 --- a/checks/migrator/checks/balances-equal/src/balances_equal.rs +++ b/checks/migrator/checks/balances-equal/src/balances_equal.rs @@ -15,7 +15,7 @@ pub mod test { // use a scope to ensure everything is dropped { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_temp()?; + let mut movement_migrator = MovementMigrator::try_debug_home()?; movement_migrator.set_overlays(Overlays::default()); // Start the migrator so that it's running in the background. diff --git a/checks/migrator/checks/matching-feature-flags/src/matching_feature_flags.rs b/checks/migrator/checks/matching-feature-flags/src/matching_feature_flags.rs index e830efe..38ec3a0 100644 --- a/checks/migrator/checks/matching-feature-flags/src/matching_feature_flags.rs +++ b/checks/migrator/checks/matching-feature-flags/src/matching_feature_flags.rs @@ -11,7 +11,7 @@ pub mod test { #[ignore = "activate when runtime problems are solved"] async fn test_matching_feature_flags() -> Result<(), anyhow::Error> { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_temp()?; + let mut movement_migrator = MovementMigrator::try_debug_home()?; // TODO: use `MovementMigrator::try_debug_home()` // let mut movement_migrator = MovementMigrator::try_debug_home()?; movement_migrator.set_overlays(Overlays::default()); diff --git a/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs b/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs index 4e19dde..fa52837 100644 --- a/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs +++ b/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs @@ -31,7 +31,7 @@ pub mod test { // Create a Movement instance with the config let movement = Movement::new( movement_config.clone(), - movement_core::MovementWorkspace::try_temp()?.into(), + movement_core::MovementWorkspace::try_debug_home()?.into(), Overlays::default(), true, true, diff --git a/checks/migrator/checks/sketchpad/src/accounts_equal.rs b/checks/migrator/checks/sketchpad/src/accounts_equal.rs index 810351c..9af479a 100644 --- a/checks/migrator/checks/sketchpad/src/accounts_equal.rs +++ b/checks/migrator/checks/sketchpad/src/accounts_equal.rs @@ -15,7 +15,7 @@ pub mod test { // use a scope to ensure everything is dropped { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_temp()?; + let mut movement_migrator = MovementMigrator::try_debug_home()?; movement_migrator.set_overlays(Overlays::default()); // Start the migrator so that it's running in the background. diff --git a/checks/migrator/checks/transacting/src/transacting.rs b/checks/migrator/checks/transacting/src/transacting.rs index caab19a..c779938 100644 --- a/checks/migrator/checks/transacting/src/transacting.rs +++ b/checks/migrator/checks/transacting/src/transacting.rs @@ -12,7 +12,7 @@ pub mod test { #[ignore = "activate when runtime problems are solved"] async fn test_transacting() -> Result<(), anyhow::Error> { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_temp()?; + let mut movement_migrator = MovementMigrator::try_debug_home()?; // TODO: use `MovementMigrator::try_debug_home()` // let mut movement_migrator = MovementMigrator::try_debug_home()?; movement_migrator.set_overlays(Overlays::default()); diff --git a/environments/core/testing/src/environment/environment.rs b/environments/core/testing/src/environment/environment.rs index 86d97bc..96cbc2d 100644 --- a/environments/core/testing/src/environment/environment.rs +++ b/environments/core/testing/src/environment/environment.rs @@ -29,7 +29,7 @@ impl TestingEnvironment { impl Environmentish for TestingEnvironment { async fn build_movement_migrator(&self) -> Result { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_temp() + let mut movement_migrator = MovementMigrator::try_debug_home() .map_err(|e| TestingEnvironmentError::Internal(e.into()))?; movement_migrator.set_overlays(Overlays::default()); diff --git a/migration/cli/migrate-node/docs/cli/README.md b/migration/cli/migrate-node/docs/cli/README.md index a3e5c6d..03f09e1 100644 --- a/migration/cli/migrate-node/docs/cli/README.md +++ b/migration/cli/migrate-node/docs/cli/README.md @@ -145,8 +145,8 @@ Usage: --environment-box.* [OPTIONS] --rest-api-url --db-dir The rest api url of the box environment --db-dir The db dir of the box environment - --snapshot-dir Whether to isolate the box environment by snapshotting the movement runner and where to - store the snapshot + --snapshot-dir Whether to isolate the box environment by snapshotting the movement + runner and where to store the snapshot -h, --help Print help (see more with '--help') **Selection (3/4):** `environment-provisioner` diff --git a/migration/util/migrator-types/src/migrator/movement_migrator.rs b/migration/util/migrator-types/src/migrator/movement_migrator.rs index 6ee6f14..2141034 100644 --- a/migration/util/migrator-types/src/migrator/movement_migrator.rs +++ b/migration/util/migrator-types/src/migrator/movement_migrator.rs @@ -148,7 +148,7 @@ mod tests { #[tokio::test] async fn test_snapshot() -> Result<(), anyhow::Error> { - let mut migrator = MovementMigrator::try_temp()?; + let mut migrator = MovementMigrator::try_debug_home()?; migrator.set_overlays(Overlays::default()); let migrator_for_task = migrator.clone(); diff --git a/util/movement/core/src/config.rs b/util/movement/core/src/config.rs index 31f6f1d..00c530a 100644 --- a/util/movement/core/src/config.rs +++ b/util/movement/core/src/config.rs @@ -79,7 +79,7 @@ impl Config { pub fn build(&self) -> Result { Ok(Movement::new( self.movement_config().map_err(|e| ConfigError::Internal(e.into()))?, - MovementWorkspace::try_temp() + MovementWorkspace::try_debug_home() .map_err(|e| ConfigError::Internal(e.into()))? .into(), self.overlays(), From cfe07a69d42622d22c9d7f0387f156e53741f1ca Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Tue, 17 Jun 2025 20:14:49 +0800 Subject: [PATCH 10/11] fix: debug ownership. --- checks/migrator/checks/balances-equal/src/balances_equal.rs | 2 +- .../checks/matching-feature-flags/src/matching_feature_flags.rs | 2 +- checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs | 2 +- checks/migrator/checks/sketchpad/src/accounts_equal.rs | 2 +- checks/migrator/checks/transacting/src/transacting.rs | 2 +- environments/core/testing/src/environment/environment.rs | 2 +- migration/util/migrator-types/src/migrator/movement_migrator.rs | 2 +- util/movement/core/src/config.rs | 2 +- util/movement/core/src/movement.rs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/checks/migrator/checks/balances-equal/src/balances_equal.rs b/checks/migrator/checks/balances-equal/src/balances_equal.rs index 1ce9d48..ebce5fa 100644 --- a/checks/migrator/checks/balances-equal/src/balances_equal.rs +++ b/checks/migrator/checks/balances-equal/src/balances_equal.rs @@ -15,7 +15,7 @@ pub mod test { // use a scope to ensure everything is dropped { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_debug_home()?; + let mut movement_migrator = MovementMigrator::try_temp()?; movement_migrator.set_overlays(Overlays::default()); // Start the migrator so that it's running in the background. diff --git a/checks/migrator/checks/matching-feature-flags/src/matching_feature_flags.rs b/checks/migrator/checks/matching-feature-flags/src/matching_feature_flags.rs index 38ec3a0..e830efe 100644 --- a/checks/migrator/checks/matching-feature-flags/src/matching_feature_flags.rs +++ b/checks/migrator/checks/matching-feature-flags/src/matching_feature_flags.rs @@ -11,7 +11,7 @@ pub mod test { #[ignore = "activate when runtime problems are solved"] async fn test_matching_feature_flags() -> Result<(), anyhow::Error> { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_debug_home()?; + let mut movement_migrator = MovementMigrator::try_temp()?; // TODO: use `MovementMigrator::try_debug_home()` // let mut movement_migrator = MovementMigrator::try_debug_home()?; movement_migrator.set_overlays(Overlays::default()); diff --git a/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs b/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs index fa52837..4e19dde 100644 --- a/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs +++ b/checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs @@ -31,7 +31,7 @@ pub mod test { // Create a Movement instance with the config let movement = Movement::new( movement_config.clone(), - movement_core::MovementWorkspace::try_debug_home()?.into(), + movement_core::MovementWorkspace::try_temp()?.into(), Overlays::default(), true, true, diff --git a/checks/migrator/checks/sketchpad/src/accounts_equal.rs b/checks/migrator/checks/sketchpad/src/accounts_equal.rs index 9af479a..810351c 100644 --- a/checks/migrator/checks/sketchpad/src/accounts_equal.rs +++ b/checks/migrator/checks/sketchpad/src/accounts_equal.rs @@ -15,7 +15,7 @@ pub mod test { // use a scope to ensure everything is dropped { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_debug_home()?; + let mut movement_migrator = MovementMigrator::try_temp()?; movement_migrator.set_overlays(Overlays::default()); // Start the migrator so that it's running in the background. diff --git a/checks/migrator/checks/transacting/src/transacting.rs b/checks/migrator/checks/transacting/src/transacting.rs index c779938..caab19a 100644 --- a/checks/migrator/checks/transacting/src/transacting.rs +++ b/checks/migrator/checks/transacting/src/transacting.rs @@ -12,7 +12,7 @@ pub mod test { #[ignore = "activate when runtime problems are solved"] async fn test_transacting() -> Result<(), anyhow::Error> { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_debug_home()?; + let mut movement_migrator = MovementMigrator::try_temp()?; // TODO: use `MovementMigrator::try_debug_home()` // let mut movement_migrator = MovementMigrator::try_debug_home()?; movement_migrator.set_overlays(Overlays::default()); diff --git a/environments/core/testing/src/environment/environment.rs b/environments/core/testing/src/environment/environment.rs index 96cbc2d..86d97bc 100644 --- a/environments/core/testing/src/environment/environment.rs +++ b/environments/core/testing/src/environment/environment.rs @@ -29,7 +29,7 @@ impl TestingEnvironment { impl Environmentish for TestingEnvironment { async fn build_movement_migrator(&self) -> Result { // Form the migrator. - let mut movement_migrator = MovementMigrator::try_debug_home() + let mut movement_migrator = MovementMigrator::try_temp() .map_err(|e| TestingEnvironmentError::Internal(e.into()))?; movement_migrator.set_overlays(Overlays::default()); diff --git a/migration/util/migrator-types/src/migrator/movement_migrator.rs b/migration/util/migrator-types/src/migrator/movement_migrator.rs index 2141034..6ee6f14 100644 --- a/migration/util/migrator-types/src/migrator/movement_migrator.rs +++ b/migration/util/migrator-types/src/migrator/movement_migrator.rs @@ -148,7 +148,7 @@ mod tests { #[tokio::test] async fn test_snapshot() -> Result<(), anyhow::Error> { - let mut migrator = MovementMigrator::try_debug_home()?; + let mut migrator = MovementMigrator::try_temp()?; migrator.set_overlays(Overlays::default()); let migrator_for_task = migrator.clone(); diff --git a/util/movement/core/src/config.rs b/util/movement/core/src/config.rs index 00c530a..31f6f1d 100644 --- a/util/movement/core/src/config.rs +++ b/util/movement/core/src/config.rs @@ -79,7 +79,7 @@ impl Config { pub fn build(&self) -> Result { Ok(Movement::new( self.movement_config().map_err(|e| ConfigError::Internal(e.into()))?, - MovementWorkspace::try_debug_home() + MovementWorkspace::try_temp() .map_err(|e| ConfigError::Internal(e.into()))? .into(), self.overlays(), diff --git a/util/movement/core/src/movement.rs b/util/movement/core/src/movement.rs index e6f5185..d0f1231 100644 --- a/util/movement/core/src/movement.rs +++ b/util/movement/core/src/movement.rs @@ -444,7 +444,7 @@ impl Movement { "--command", "bash", "-c", - &format!("echo '' > .env && just movement-full-node docker-compose {overlays}"), + &format!("echo $USER && ls -al .movement && echo '' > .env && just movement-full-node docker-compose {overlays}"), ], Some(path), false, From 600ab439a34d664db65d599848215eabb8938fa8 Mon Sep 17 00:00:00 2001 From: Liam Makena Monninger Date: Wed, 18 Jun 2025 10:29:32 +0800 Subject: [PATCH 11/11] chore: upate slect to select naming. --- Cargo.lock | 82 +++++++++---------- Cargo.toml | 4 +- migration/cli/migrate-node/Cargo.toml | 2 +- migration/cli/migrate-node/docs/cli/README.md | 4 +- migration/cli/migrate-node/src/cli/migrate.rs | 2 +- .../migrate-node/src/cli/migrate/select.rs | 10 +-- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81d7784..6ee2e9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15617,8 +15617,8 @@ dependencies = [ "mtma-provisioner-environment", "mtma-testing-environment", "orfile", + "select", "serde", - "slect", "tokio", "tracing", "tracing-subscriber 0.3.19", @@ -16672,7 +16672,7 @@ dependencies = [ [[package]] name = "orfile" version = "0.0.1" -source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac#e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac" dependencies = [ "anyhow", "orfile-macro", @@ -16683,7 +16683,7 @@ dependencies = [ [[package]] name = "orfile-macro" version = "0.0.1" -source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac#e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac" dependencies = [ "proc-macro-error", "proc-macro2", @@ -16694,7 +16694,7 @@ dependencies = [ [[package]] name = "orfile-util" version = "0.0.1" -source = "git+https://github.com/movementlabsxyz/orfile.git?rev=f02851242af77791b905efc19aef6af21918fb1e#f02851242af77791b905efc19aef6af21918fb1e" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac#e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac" dependencies = [ "serde", "serde_json", @@ -19472,6 +19472,43 @@ dependencies = [ "libc", ] +[[package]] +name = "select" +version = "0.0.1" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac#e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac" +dependencies = [ + "anyhow", + "once_cell", + "select-macro", + "select-util", + "serde_json", +] + +[[package]] +name = "select-macro" +version = "0.0.1" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac#e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "select-util" +version = "0.0.1" +source = "git+https://github.com/movementlabsxyz/orfile.git?rev=e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac#e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac" +dependencies = [ + "clap 4.5.36", + "once_cell", + "serde", + "serde_json", + "thiserror 1.0.69", + "tokio", +] + [[package]] name = "self-replace" version = "1.5.0" @@ -20032,43 +20069,6 @@ 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 76b9104..2c90550 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -150,8 +150,8 @@ 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 = "f02851242af77791b905efc19aef6af21918fb1e" } -slect = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "f02851242af77791b905efc19aef6af21918fb1e" } +orfile = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac" } +select = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "e3279f2fe4a9bafe1197e4d4f1c769d7255b94ac" } # docs clap-markdown-ext = { git = "https://github.com/movementlabsxyz/clap-markdown-ext.git", rev = "a4c6c00193baa50eefa214bd74b4a1d50c3255a0" } diff --git a/migration/cli/migrate-node/Cargo.toml b/migration/cli/migrate-node/Cargo.toml index 8b28793..dfab126 100644 --- a/migration/cli/migrate-node/Cargo.toml +++ b/migration/cli/migrate-node/Cargo.toml @@ -21,7 +21,7 @@ jemallocator = { workspace = true } mtma-node-null-core = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } -slect = { workspace = true } +select = { workspace = true } mtma-testing-environment = { workspace = true } mtma-box-environment = { workspace = true } mtma-provisioner-environment = { workspace = true } diff --git a/migration/cli/migrate-node/docs/cli/README.md b/migration/cli/migrate-node/docs/cli/README.md index 03f09e1..74f11cd 100644 --- a/migration/cli/migrate-node/docs/cli/README.md +++ b/migration/cli/migrate-node/docs/cli/README.md @@ -145,8 +145,8 @@ Usage: --environment-box.* [OPTIONS] --rest-api-url --db-dir The rest api url of the box environment --db-dir The db dir of the box environment - --snapshot-dir Whether to isolate the box environment by snapshotting the movement - runner and where to store the snapshot + --snapshot-dir Whether to isolate the box environment by snapshotting the movement runner and + where to store the snapshot -h, --help Print help (see more with '--help') **Selection (3/4):** `environment-provisioner` diff --git a/migration/cli/migrate-node/src/cli/migrate.rs b/migration/cli/migrate-node/src/cli/migrate.rs index 5d8b1f2..2ae9564 100644 --- a/migration/cli/migrate-node/src/cli/migrate.rs +++ b/migration/cli/migrate-node/src/cli/migrate.rs @@ -10,7 +10,7 @@ pub enum Migrate { /// Core migration over the node. Core(core::Core), /// Select migration over the node. - Select(select::select::Select), + Select(select::select_command::Select), } impl Migrate { diff --git a/migration/cli/migrate-node/src/cli/migrate/select.rs b/migration/cli/migrate-node/src/cli/migrate/select.rs index 61687bb..8c4681a 100644 --- a/migration/cli/migrate-node/src/cli/migrate/select.rs +++ b/migration/cli/migrate-node/src/cli/migrate/select.rs @@ -6,19 +6,19 @@ use mtma_migrator_types::migrator::MovementMigrator; use mtma_node_null_core::Config as NullConfig; use mtma_provisioner_environment::Config as ProvisionerEnvironmentConfig; use mtma_testing_environment::Config as TestingEnvironmentConfig; +use select::Select; use serde::{Deserialize, Serialize}; -use slect::Slect; /// Select migration over the node. -#[derive(Parser, Slect, Deserialize, Serialize, Debug, Clone)] +#[derive(Parser, Select, Deserialize, Serialize, Debug, Clone)] #[clap(help_expected = true)] pub struct Select { - /// Extra args to pass to slect API - #[slect(environment_testing = TestingEnvironmentConfig, environment_box = BoxEnvironmentConfig, environment_provisioner = ProvisionerEnvironmentConfig, null = NullConfig)] + /// Extra args to pass to select API + #[select(environment_testing = TestingEnvironmentConfig, environment_box = BoxEnvironmentConfig, environment_provisioner = ProvisionerEnvironmentConfig, null = NullConfig)] extra_args: Vec, } -impl select::Select { +impl select_command::Select { pub async fn get_movement_migrator(&self) -> Result { let ( maybe_environment_testing,