Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTurner committed Jan 10, 2025
1 parent 659d8e0 commit 7b5f0ac
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
5 changes: 5 additions & 0 deletions crates/services/gas_price_service/simulation/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ pub enum SimulationArgs {
#[arg(short, long)]
start_gas_price: u64,
},
Optimization {
/// Number of iterations to run the optimization for
#[arg(short, long)]
iterations: u64,
},
}

#[derive(Parser, Debug)]
Expand Down
60 changes: 31 additions & 29 deletions crates/services/gas_price_service/simulation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,6 @@ pub mod service;
pub mod simulation;
pub mod tracing;

pub async fn run_single_simulation(data: Data) -> anyhow::Result<SimulationResults> {
let starting_height = data.starting_height();
let config_values = ConfigValues {
min_da_gas_price: 1000,
max_da_gas_price: u64::MAX,
da_p_component: 50_000_000__000_000_000,
da_d_component: 100_000__000_000_000,
};
let metadata_values = MetadataValues::new(starting_height, 18_963);
let mut service_controller =
get_service_controller(config_values, metadata_values).await?;
let results = single_simulation(&data, &mut service_controller).await?;
Ok(results)
}

pub async fn run_a_simulation(
args: SimulationArgs,
data: Data,
Expand All @@ -54,29 +39,46 @@ pub async fn run_a_simulation(
d_component,
start_gas_price,
} => {
let starting_height = data.starting_height();
let config_values = ConfigValues {
min_da_gas_price: 1000,
max_da_gas_price: u64::MAX,
da_p_component: p_component,
da_d_component: d_component,
};
let metadata_values = MetadataValues::new(starting_height, start_gas_price);
let mut service_controller =
get_service_controller(config_values, metadata_values).await?;
let results = single_simulation(&data, &mut service_controller).await?;
Ok(results)
run_single_simulation(&data, p_component, d_component, start_gas_price).await
}
SimulationArgs::Optimization { iterations } => {
optimization(data, iterations).await
}
}
}

async fn run_single_simulation(
data: &Data,
p_component: i64,
d_component: i64,
start_gas_price: u64,
) -> anyhow::Result<SimulationResults> {
let starting_height = data.starting_height();
let config_values = ConfigValues {
min_da_gas_price: 1000,
max_da_gas_price: u64::MAX,
da_p_component: p_component,
da_d_component: d_component,
};
let metadata_values = MetadataValues::new(starting_height, start_gas_price);
let mut service_controller =
get_service_controller(config_values, metadata_values).await?;
single_simulation(&data, &mut service_controller).await
}

pub async fn optimization(
_data: Data,
_iterations: u64,
) -> anyhow::Result<SimulationResults> {
todo!()
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
configure_tracing();

let args = Args::parse();
let data = get_data(&args.file_path)?;
let results = run_single_simulation(data).await?;
let results = run_a_simulation(args.simulation, data).await?;
display_results(results)?;
Ok(())
}

0 comments on commit 7b5f0ac

Please sign in to comment.