diff --git a/leo/cli/commands/deploy.rs b/leo/cli/commands/deploy.rs index f618335ea3..978398a2a6 100644 --- a/leo/cli/commands/deploy.rs +++ b/leo/cli/commands/deploy.rs @@ -116,11 +116,7 @@ fn handle_deploy, N: Network>( // Fetch the package from the directory. let package = SnarkVMPackage::::open(path)?; - if !command.fee_options.estimate_fee { - println!("📦 Creating deployment transaction for '{}'...\n", &name.bold()); - } else { - println!("📦 Estimating deployment cost for '{}'...\n", &name.bold()); - } + println!("📦 Creating deployment transaction for '{}'...\n", &name.bold()); // Generate the deployment let deployment = package.deploy::(None)?; @@ -134,17 +130,14 @@ fn handle_deploy, N: Network>( // Compute the minimum deployment cost. let (total_cost, (storage_cost, synthesis_cost, namespace_cost)) = deployment_cost(&deployment)?; - if command.fee_options.estimate_fee { - // Use `credit` denomination instead of `microcredit`. - deploy_cost_breakdown( - name, - total_cost as f64 / 1_000_000.0, - storage_cost as f64 / 1_000_000.0, - synthesis_cost as f64 / 1_000_000.0, - namespace_cost as f64 / 1_000_000.0, - ); - continue; - } + // Display the deployment cost breakdown using `credit` denomination. + deploy_cost_breakdown( + name, + total_cost as f64 / 1_000_000.0, + storage_cost as f64 / 1_000_000.0, + synthesis_cost as f64 / 1_000_000.0, + namespace_cost as f64 / 1_000_000.0, + ); // Initialize an RNG. let rng = &mut rand::thread_rng(); @@ -183,14 +176,16 @@ fn handle_deploy, N: Network>( println!("✅ Created deployment transaction for '{}'", name.bold()); // Determine if the transaction should be broadcast, stored, or displayed to the user. - handle_broadcast( - &format!("{}/{}/transaction/broadcast", command.options.endpoint, command.options.network), - transaction, - name, - )?; - - if index < all_paths.len() - 1 { - std::thread::sleep(std::time::Duration::from_secs(command.wait)); + if !command.fee_options.dry_run { + handle_broadcast( + &format!("{}/{}/transaction/broadcast", command.options.endpoint, command.options.network), + transaction, + name, + )?; + // Wait between successive deployments to prevent out of order deployments. + if index < all_paths.len() - 1 { + std::thread::sleep(std::time::Duration::from_secs(command.wait)); + } } } @@ -199,22 +194,20 @@ fn handle_deploy, N: Network>( // A helper function to display a cost breakdown of the deployment. fn deploy_cost_breakdown(name: &String, total_cost: f64, storage_cost: f64, synthesis_cost: f64, namespace_cost: f64) { - println!("✅ Estimated deployment cost for '{}' is {} credits.", name.bold(), total_cost); + println!("Base deployment cost for '{}' is {} credits.", name.bold(), total_cost); // Display the cost breakdown in a table. let data = [ - [name, "Cost (credits)", "Cost reduction tips"], - ["Storage", &format!("{:.6}", storage_cost), "Use less instructions"], + [name, "Cost (credits)"], + ["Transaction Storage", &format!("{:.6}", storage_cost)], [ - "Synthesis", + "Program Synthesis", &format!("{:.6}", synthesis_cost), - "Remove expensive operations (Ex: SHA3), or unnecessary imports", ], [ "Namespace", &format!("{:.6}", namespace_cost), - "Lengthen the program name (each additional character makes it 10x cheaper)", ], - ["Total", &format!("{:.6}", total_cost), ""], + ["Total", &format!("{:.6}", total_cost)], ]; let mut out = Vec::new(); text_tables::render(&mut out, data).unwrap(); diff --git a/leo/cli/commands/execute.rs b/leo/cli/commands/execute.rs index 3994ce1671..e40df6b49c 100644 --- a/leo/cli/commands/execute.rs +++ b/leo/cli/commands/execute.rs @@ -216,26 +216,26 @@ fn handle_execute(command: Execute, context: Context) -> Result<( // A helper function to display a cost breakdown of the execution. fn execution_cost_breakdown(name: &String, total_cost: f64, storage_cost: f64, finalize_cost: f64) { - println!("✅ Estimated execution cost for '{}' is {} credits.", name.bold(), total_cost); + println!("Base execution cost for '{}' is {} credits.", name.bold(), total_cost); // Display the cost breakdown in a table. let data = [ - [name, "Cost (credits)", "Cost reduction tips"], + [name, "Cost (credits)"], [ - "Storage", + "Transaction Storage", &format!("{:.6}", storage_cost), - "Use fewer nested transition functions and smaller input and output datatypes", ], [ - "On-chain", + "On-chain Execution", &format!("{:.6}", finalize_cost), - "Remove operations that are expensive computationally (Ex: hash functions) or storage-wise (Ex: Mapping insertions)", ], - ["Total", &format!("{:.6}", total_cost), ""], + ["Total", &format!("{:.6}", total_cost)], ]; let mut out = Vec::new(); text_tables::render(&mut out, data).unwrap(); diff --git a/leo/cli/commands/mod.rs b/leo/cli/commands/mod.rs index bf40457eca..b5344ecced 100644 --- a/leo/cli/commands/mod.rs +++ b/leo/cli/commands/mod.rs @@ -209,12 +209,8 @@ impl Default for BuildOptions { /// Used by Execute and Deploy commands. #[derive(Parser, Clone, Debug)] pub struct FeeOptions { - #[clap( - long, - help = "Estimate the deploy or execution fee without broadcasting to the network.", - default_value = "false" - )] - pub(crate) estimate_fee: bool, + #[clap(short, long, help = "Performs a dry-run of transaction generation")] + pub(crate) dry_run: bool, #[clap(long, help = "Priority fee in microcredits. Defaults to 0.", default_value = "0")] pub(crate) priority_fee: u64, #[clap(long, help = "Private key to authorize fee expenditure.")]