Skip to content

Commit

Permalink
fix: dot movement path internals.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-monninger committed Nov 16, 2024
1 parent b0783d2 commit f7e14a3
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
Empty file added config.json
Empty file.
14 changes: 9 additions & 5 deletions networks/suzuka/suzuka-full-node/src/admin/force_commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::Context;
use clap::Parser;
use maptos_dof_execution::DynOptFinExecutor;
use mcr_settlement_client::{McrSettlementClient, McrSettlementClientOperations};
use tracing::info;

#[derive(Debug, Parser, Clone)]
#[clap(
Expand All @@ -18,21 +19,24 @@ pub struct ForceCommitment {

impl ForceCommitment {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
info!("Forcing commitment");
let config = self.movement_args.config().await?;
info!("Loaded config {:?}", config);
let settlement_client = McrSettlementClient::build_with_config(&config.mcr)
.await
.context("Failed to build MCR settlement client with config")?;
let node = SuzukaPartialNode::try_from_config(config)
info!("Built settlement client");
let executor = SuzukaPartialNode::try_executor_from_config(config)
.await
.context("Failed to create the executor")?;

let height = match self.height {
Some(height) => height,
None => node.executor().get_block_head_height()?,
None => executor.get_block_head_height()?,
};

node.executor().revert_block_head_to(height).await?;
let commitment = node.executor().get_block_commitment_by_height(height).await?;
info!("Forcing commmitment at height {}", height);
executor.revert_block_head_to(height).await?;
let commitment = executor.get_block_commitment_by_height(height).await?;

settlement_client.force_block_commitment(commitment).await?;

Expand Down
3 changes: 2 additions & 1 deletion networks/suzuka/suzuka-full-node/src/common_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ impl MovementArgs {
/// Get the DotMovement struct from the args.
pub fn dot_movement(&self) -> Result<DotMovement, anyhow::Error> {
let movement_path = self.movement_path.clone().unwrap_or_else(|| {
std::env::var("DOT_MOVEMENT_PATH").unwrap_or_else(|_| ".".to_string())
std::env::var("DOT_MOVEMENT_PATH").unwrap_or_else(|_| "./.movement".to_string())
});
std::env::set_var("DOT_MOVEMENT_PATH", movement_path.clone());
Ok(DotMovement::new(movement_path.as_str()))
}

Expand Down
6 changes: 6 additions & 0 deletions networks/suzuka/suzuka-full-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

use clap::*;
use suzuka_full_node::SuzukaFullNode;
const TIMING_LOG_ENV: &str = "SUZUKA_TIMING_LOG";
use std::env;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let tracing_config =
movement_tracing::Config { timing_log_path: env::var_os(TIMING_LOG_ENV).map(Into::into) };
let _guard = movement_tracing::init_tracing_subscriber(tracing_config);

let suzuka_util = SuzukaFullNode::parse();

suzuka_util.execute().await?;
Expand Down
6 changes: 6 additions & 0 deletions networks/suzuka/suzuka-full-node/src/node/partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ where
}

impl SuzukaPartialNode<Executor> {
pub async fn try_executor_from_config(config: Config) -> Result<Executor, anyhow::Error> {
let executor = Executor::try_from_config(config.execution_config.maptos_config.clone())
.context("Failed to create the inner executor")?;
Ok(executor)
}

pub async fn try_from_config(config: Config) -> Result<Self, anyhow::Error> {
let light_node_connection_protocol = config
.m1_da_light_node
Expand Down
12 changes: 1 addition & 11 deletions networks/suzuka/suzuka-full-node/src/run/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
use crate::node::manager::Manager;

use std::env;

use crate::common_args::MovementArgs;
use crate::node::manager::Manager;
use clap::Parser;

const TIMING_LOG_ENV: &str = "SUZUKA_TIMING_LOG";

#[derive(Debug, Parser, Clone)]
#[clap(rename_all = "kebab-case", about = "Runs the Suzuka Full Node")]
pub struct Run {
Expand All @@ -16,11 +11,6 @@ pub struct Run {

impl Run {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
let tracing_config = movement_tracing::Config {
timing_log_path: env::var_os(TIMING_LOG_ENV).map(Into::into),
};
let _guard = movement_tracing::init_tracing_subscriber(tracing_config);

// get the config file
let dot_movement = self.movement_args.dot_movement()?;
let config_file = dot_movement.try_get_or_create_config_file().await?;
Expand Down
2 changes: 1 addition & 1 deletion process-compose/suzuka-full-node/process-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ processes:

suzuka-full-node:
command: |
suzuka-full-node
suzuka-full-node run
depends_on:
m1-da-light-node:
condition: process_healthy
Expand Down
2 changes: 2 additions & 0 deletions protocol-units/settlement/mcr/client/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::BTreeMap;
use std::sync::{Arc, Mutex};
use tokio::sync::{mpsc, RwLock};
use tokio_stream::wrappers::ReceiverStream;
use tracing::info;

#[derive(Clone)]
pub struct McrSettlementClient {
Expand All @@ -30,6 +31,7 @@ impl McrSettlementClient {
}

pub async fn build_with_config(_config: &Config) -> Result<Self, anyhow::Error> {
info!("Building with config.");
Ok(Self::new())
}

Expand Down

0 comments on commit f7e14a3

Please sign in to comment.