Skip to content

Commit

Permalink
Config Migration (#1024)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikhail Zabaluev <[email protected]>
  • Loading branch information
l-monninger and mzabaluev authored Jan 28, 2025
1 parent bc40426 commit 2b62a93
Show file tree
Hide file tree
Showing 38 changed files with 979 additions and 143 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ hyper = "1.4"
hyper-util = { version = "0.1.4" }
tower = { version = "0.5" }
http-body-util = "0.1"
tap = "1.0.1"

# trying to pin diesel
diesel = { version = "2.2.4", features = ["postgres", "numeric", "r2d2"] }
Expand Down
8 changes: 7 additions & 1 deletion networks/movement/faucet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ async fn main() -> Result<()> {
let connection_url = format!("http://{}:{}", connection_host, connection_port);

// get the key
let private_key = config.execution_config.maptos_config.chain.maptos_private_key.clone();
let raw_private_key = config
.execution_config
.maptos_config
.chain
.maptos_private_key_signer_identifier
.try_raw_private_key()?;
let private_key = Ed25519PrivateKey::try_from(raw_private_key.as_slice())?;

// get the chain id
let chain_id = config.execution_config.maptos_config.chain.maptos_chain_id.clone();
Expand Down
19 changes: 9 additions & 10 deletions networks/movement/movement-client/src/bin/e2e/whitelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::Context;
use movement_client::crypto::ValidCryptoMaterialStringExt;
use movement_client::{
coin_client::CoinClient,
crypto::ed25519::Ed25519PrivateKey,
move_types::identifier::Identifier,
move_types::language_storage::ModuleId,
rest_client::{Client, FaucetClient},
Expand Down Expand Up @@ -74,16 +75,14 @@ async fn main() -> Result<(), anyhow::Error> {

// Create two accounts locally, Alice and Bob.
// :!:>section_2
let mut genesis = LocalAccount::from_private_key(
SUZUKA_CONFIG
.execution_config
.maptos_config
.chain
.maptos_private_key
.to_encoded_string()?
.as_str(),
0,
)?;
let raw_private_key = SUZUKA_CONFIG
.execution_config
.maptos_config
.chain
.maptos_private_key_signer_identifier
.try_raw_private_key()?;
let private_key = Ed25519PrivateKey::try_from(raw_private_key.as_slice())?;
let mut genesis = LocalAccount::from_private_key(private_key.to_encoded_string()?.as_str(), 0)?;
let mut alice = LocalAccount::generate(&mut rand::rngs::OsRng);
let bob = LocalAccount::generate(&mut rand::rngs::OsRng); // <:!:section_2

Expand Down
5 changes: 5 additions & 0 deletions networks/movement/movement-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ godfig = { workspace = true }
syncup = { workspace = true }
movement-types = { workspace = true }
dot-movement = { workspace = true }
thiserror = { workspace = true }
serde_json = { workspace = true }
movement-signer-loader = { workspace = true }
tracing-test = { workspace = true }
tap = { workspace = true }
47 changes: 3 additions & 44 deletions networks/movement/movement-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,45 +1,4 @@
pub mod da_db;
pub mod execution_extension;
pub mod syncing;
pub mod migrations;
pub mod releases;

use serde::{Deserialize, Serialize};

use maptos_execution_util::config::MaptosConfig;
use mcr_settlement_config::Config as McrConfig;
use movement_da_util::config::CelestiaDaLightNodeConfig;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
#[serde(flatten)]
#[serde(default)]
pub execution_config: MaptosConfig,

#[serde(flatten)]
#[serde(default)]
pub celestia_da_light_node: CelestiaDaLightNodeConfig,

#[serde(default)]
pub mcr: McrConfig,

#[serde(default)]
pub da_db: da_db::Config,

#[serde(default)]
pub execution_extension: execution_extension::Config,

#[serde(default)]
pub syncing: syncing::Config,
}

impl Default for Config {
fn default() -> Self {
Self {
execution_config: MaptosConfig::default(),
celestia_da_light_node: CelestiaDaLightNodeConfig::default(),
mcr: McrConfig::default(),
da_db: da_db::Config::default(),
execution_extension: execution_extension::Config::default(),
syncing: syncing::Config::default(),
}
}
}
pub use releases::biarritz_rc1::*;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::migrations::elsa_to_biarritz_rc1::{
ElsaToBiarritzRc1, ElsaToBiarritzRc1Error, MigrateElsaToBiarritzRc1,
};
use crate::releases::biarritz_rc1::Config;
use dot_movement::DotMovement;

impl MigrateElsaToBiarritzRc1 for DotMovement {
async fn migrate_elsa_to_biarritz_rc1(&self) -> Result<Config, ElsaToBiarritzRc1Error> {
// get the value
let value = self
.try_load_value()
.await
.map_err(|e| ElsaToBiarritzRc1Error::MigrationFailed(e.into()))?;

// migrate the value
let migrated_config = ElsaToBiarritzRc1::migrate(value)?;

// write the migrated value
self.try_overwrite_config_to_json(&migrated_config)
.map_err(|e| ElsaToBiarritzRc1Error::MigrationFailed(e.into()))?;

Ok(migrated_config)
}
}
Loading

0 comments on commit 2b62a93

Please sign in to comment.