Skip to content
Open
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
105 changes: 62 additions & 43 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ members = [
"util/movement/*",
"util/movement-aptos/*",
"util/bcs-ext",
"util/types"
"util/types",
"util/util"

]

Expand Down Expand Up @@ -149,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" }
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion checks/migrator/checks/pre-l1-merge/src/pre_l1_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions environments/core/box/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ clap = { workspace = true }
thiserror = { workspace = true }
mtma-migrator-types = { workspace = true }
mtma-environment-types = { workspace = true }
kestrel = { workspace = true }
tokio = { workspace = true }

[lints]
workspace = true
19 changes: 17 additions & 2 deletions environments/core/box/src/environment/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -16,13 +17,27 @@ 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.
#[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<PathBuf>,
}

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<BoxEnvironment, EnvironmentConfigError> {
Ok(BoxEnvironment::new())
Ok(BoxEnvironment::new(
self.rest_api_url.clone(),
self.db_dir.clone(),
self.snapshot_dir.clone(),
))
}
}
54 changes: 49 additions & 5 deletions environments/core/box/src/environment/environment.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -15,16 +20,55 @@ impl From<BoxEnvironmentError> 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<PathBuf>,
}

impl BoxEnvironment {
pub fn new() -> Self {
Self {}
pub fn new(rest_api_url: String, db_dir: PathBuf, snapshot_dir: Option<PathBuf>) -> Self {
Self { rest_api_url, db_dir, snapshot_dir }
}
}

impl Environmentish for BoxEnvironment {
async fn build_movement_migrator(&self) -> Result<MovementMigrator, EnvironmentError> {
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)
}
}
2 changes: 1 addition & 1 deletion migration/cli/migrate-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
8 changes: 6 additions & 2 deletions migration/cli/migrate-node/docs/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@ Options:
**Selection (2/4):** `environment-box`
The config for the [BoxEnvironment]

Usage: --environment-box.*
Usage: --environment-box.* [OPTIONS] --rest-api-url <REST_API_URL> --db-dir <DB_DIR>

Options:
-h, --help Print help (see more with '--help')
--rest-api-url <REST_API_URL> The rest api url of the box environment
--db-dir <DB_DIR> The db dir of the box environment
--snapshot-dir <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]
Expand Down
2 changes: 1 addition & 1 deletion migration/cli/migrate-node/src/cli/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading
Loading