Skip to content

Commit b36f125

Browse files
committed
chore: restructure environments; remove node and migrator distinction for now.
1 parent f23beec commit b36f125

File tree

27 files changed

+1205
-2
lines changed

27 files changed

+1205
-2
lines changed

Cargo.lock

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,22 @@ members = [
1010
"migration/core/node/*",
1111
"migration/core/migrator/*",
1212
"migration/util/*",
13-
# executor
13+
14+
# environments
15+
"environments/core/*",
16+
"environments/util/*",
17+
18+
# checks
19+
## node
1420
"checks/node/util/*",
1521
"checks/node/citeria/*",
1622
"checks/node/checks/*",
1723
"checks/node/preludes",
18-
# e2e
24+
## migrator
1925
"checks/migrator/util/*",
2026
"checks/migrator/citeria/*",
2127
"checks/migrator/checks/*",
28+
2229
# util
2330
"util/bcs-ext",
2431
"util/movement/*",

environments/core/box/Cargo.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[package]
2+
name = "mtma-box-environment"
3+
version = { workspace = true }
4+
edition = { workspace = true }
5+
license = { workspace = true }
6+
authors = { workspace = true }
7+
homepage = { workspace = true }
8+
publish = { workspace = true }
9+
rust-version = { workspace = true }
10+
11+
[dependencies]
12+
tokio = { workspace = true }
13+
serde = { workspace = true, features = ["derive"] }
14+
clap = { workspace = true, features = ["derive"] }
15+
dotenv = { workspace = true }
16+
anyhow = { workspace = true }
17+
clap-markdown-ext = { workspace = true }
18+
thiserror = { workspace = true }
19+
orfile = { workspace = true }
20+
mtma-node-types = { workspace = true }
21+
mtma-migrator-types = { workspace = true }
22+
mtma-node-null-core = { workspace = true }
23+
aptos-db = { workspace = true }
24+
aptos-storage-interface = { workspace = true }
25+
aptos-config = { workspace = true }
26+
aptos-executor = { workspace = true }
27+
aptos-vm = { workspace = true }
28+
chrono = { workspace = true }
29+
walkdir = { workspace = true }
30+
uuid = { workspace = true }
31+
tracing = { workspace = true }
32+
aptos-framework-pre-l1-merge-release = { workspace = true }
33+
movement-signer = { workspace = true }
34+
movement-signer-loader = { workspace = true }
35+
hex = { workspace = true }
36+
mtma-types = { workspace = true }
37+
movement-core = { workspace = true }
38+
39+
[lints]
40+
workspace = true

environments/core/box/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# `mtma-box-environment`
2+
The environment which provides a [Migrator](/README.md#migrator) constructed via access to state on the current node.

environments/core/box/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod migrate;
2+
pub use migrate::*;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// Contains the configuration structs and logic for the migration.
2+
pub mod config;
3+
/// Contains the logic for the migration.
4+
pub mod migrate;
5+
6+
pub use config::*;
7+
pub use migrate::*;
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
use crate::Migrate;
2+
use anyhow::Context;
3+
use aptos_framework_pre_l1_merge_release::maptos_framework_release_util::{
4+
LocalAccountReleaseSigner, OverrideAccountAddressReleaseSigner,
5+
};
6+
use clap::Parser;
7+
use movement_core::{
8+
movement::{Celestia, Eth},
9+
Config as MovementCoreConfig,
10+
};
11+
use mtma_node_null_core::Config as MtmaNodeNullConfig;
12+
use mtma_types::movement::aptos_sdk::types::{
13+
account_address::AccountAddress, account_config::aptos_test_root_address, LocalAccount,
14+
};
15+
use mtma_types::movement::movement_config::Config as MovementConfig;
16+
use serde::{Deserialize, Serialize};
17+
use std::fmt::Debug;
18+
19+
/// Errors thrown when working with the [Config].
20+
#[derive(Debug, thiserror::Error)]
21+
pub enum MigrateConfigError {
22+
#[error("failed to build from config: {0}")]
23+
Build(#[source] Box<dyn std::error::Error + Send + Sync>),
24+
}
25+
26+
/// The config for the migration.
27+
///
28+
/// All fields should be easily statically encodable to a CLI argument.
29+
/// This is the frontend for the core API.
30+
#[derive(Parser, Debug, Serialize, Deserialize, Clone)]
31+
#[clap(help_expected = true)]
32+
pub struct Config {
33+
/// The config for the mtma-node-null.
34+
#[clap(flatten)]
35+
mtma_node_null: MtmaNodeNullConfig,
36+
/// The movement config.
37+
#[clap(flatten)]
38+
movement_core: MovementCoreConfig,
39+
/// The account address override for the release signer.
40+
#[clap(long)]
41+
pub account_address: Option<AccountAddress>,
42+
}
43+
44+
impl Default for Config {
45+
fn default() -> Self {
46+
let mut movement_core = MovementCoreConfig {
47+
movement_config_string: None,
48+
setup: false,
49+
celestia: Celestia::Local,
50+
eth: Eth::Local,
51+
biarritz_rc1_to_pre_l1_merge: false,
52+
ping_rest_api: false,
53+
ping_faucet: false,
54+
};
55+
56+
// Create a default MovementConfig
57+
let movement_config = MovementConfig::default();
58+
59+
// Hard-code the core resources address
60+
let account_address = Some(aptos_test_root_address());
61+
62+
// Set the movement config
63+
movement_core.set_movement_config(movement_config);
64+
65+
Self { mtma_node_null: MtmaNodeNullConfig::default(), movement_core, account_address }
66+
}
67+
}
68+
69+
impl Config {
70+
/// Builds the release signer from the config.
71+
pub fn build_release_signer(&self) -> Result<LocalAccountReleaseSigner, MigrateConfigError> {
72+
// load the signer
73+
let raw_private_key = self
74+
.movement_core
75+
.try_movement_signer_identifier()
76+
.map_err(|e| MigrateConfigError::Build(e.into()))?
77+
.try_raw_private_key()
78+
.context("failed to load raw private key")
79+
.map_err(|e| MigrateConfigError::Build(e.into()))?;
80+
81+
// get the raw private key
82+
let private_key_hex = hex::encode(raw_private_key);
83+
let root_account = LocalAccount::from_private_key(private_key_hex.as_str(), 0)
84+
.context("failed to build root account")
85+
.map_err(|e| MigrateConfigError::Build(e.into()))?; // sequence number 0 is fine because the release API loads sequence numbers
86+
87+
Ok(LocalAccountReleaseSigner::new(root_account, None))
88+
}
89+
90+
/// Builds the [Migrate] struct from the config.
91+
pub fn build(
92+
&self,
93+
) -> Result<
94+
Migrate<OverrideAccountAddressReleaseSigner<LocalAccountReleaseSigner>>,
95+
MigrateConfigError,
96+
> {
97+
let mtma_node_null =
98+
self.mtma_node_null.build().map_err(|e| MigrateConfigError::Build(e.into()))?;
99+
let local_signer = self.build_release_signer()?;
100+
let signer = OverrideAccountAddressReleaseSigner::core_resource_account(local_signer);
101+
Ok(Migrate { release_signer: signer, mtma_node_null })
102+
}
103+
}

0 commit comments

Comments
 (0)