Skip to content

Commit

Permalink
Merge pull request #28330 from ungaro/alp/number-of-variables-in-depl…
Browse files Browse the repository at this point in the history
…oyment

[Feature] Add deployment summary with comma-formatted variables and constraints counts.
  • Loading branch information
d0cd authored Sep 3, 2024
2 parents 0fdf601 + 48bd831 commit 73632ba
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions leo/cli/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use super::*;
use aleo_std::StorageMode;
use dialoguer::{theme::ColorfulTheme, Confirm};
use leo_retriever::NetworkName;
use num_format::{Locale, ToFormattedString};
use snarkvm::{
circuit::{Aleo, AleoCanaryV0, AleoTestnetV0, AleoV0},
ledger::query::Query as SnarkVMQuery,
Expand Down Expand Up @@ -121,14 +122,24 @@ fn handle_deploy<A: Aleo<Network = N, BaseField = N::Field>, N: Network>(
// Generate the deployment
let deployment = package.deploy::<A>(None)?;

let variables = deployment.num_combined_variables()?;
let constraints = deployment.num_combined_constraints()?;

// Check if the number of variables and constraints are within the limits.
if deployment.num_combined_variables()? > N::MAX_DEPLOYMENT_VARIABLES {
if variables > N::MAX_DEPLOYMENT_VARIABLES {
return Err(CliError::variable_limit_exceeded(name, N::MAX_DEPLOYMENT_VARIABLES, network).into());
}
if deployment.num_combined_constraints()? > N::MAX_DEPLOYMENT_CONSTRAINTS {
if constraints > N::MAX_DEPLOYMENT_CONSTRAINTS {
return Err(CliError::constraint_limit_exceeded(name, N::MAX_DEPLOYMENT_CONSTRAINTS, network).into());
}

// Print deployment summary
println!(
"📊 Deployment Summary:\n Total Variables: {:>10}\n Total Constraints: {:>10}",
variables.to_formatted_string(&Locale::en),
constraints.to_formatted_string(&Locale::en)
);

let deployment_id = deployment.to_deployment_id()?;

let store = ConsensusStore::<N, ConsensusMemory<N>>::open(StorageMode::Production)?;
Expand Down

0 comments on commit 73632ba

Please sign in to comment.