diff --git a/stake-pool/cli/src/main.rs b/stake-pool/cli/src/main.rs index c695f351120..a7bd4cfa5cb 100644 --- a/stake-pool/cli/src/main.rs +++ b/stake-pool/cli/src/main.rs @@ -114,19 +114,21 @@ const COMPUTE_UNIT_LIMIT_ARG: ArgConstant<'static> = ArgConstant { name: "compute_unit_limit", long: "--with-compute-unit-limit", help: "Set compute unit limit for transaction, in compute units; also accepts \ - keyword SIMULATED to use compute units from transaction simulation prior \ - to sending. Note that SIMULATED may fail if accounts are modified by another \ - transaction between simulation and execution.", + keyword DEFAULT to use the default compute unit limit, which is 200k per \ + top-level instruction, with a maximum of 1.4 million. \ + If nothing is set, transactions are simulated prior to sending, and the \ + compute units consumed are set as the limit. This may may fail if accounts \ + are modified by another transaction between simulation and execution.", }; fn is_compute_unit_limit_or_simulated(string: T) -> Result<(), String> where T: AsRef + std::fmt::Display, { - if string.as_ref().parse::().is_ok() || string.as_ref() == "SIMULATED" { + if string.as_ref().parse::().is_ok() || string.as_ref() == "DEFAULT" { Ok(()) } else { Err(format!( - "Unable to parse input compute unit limit as integer or SIMULATED, provided: {string}" + "Unable to parse input compute unit limit as integer or DEFAULT, provided: {string}" )) } } @@ -136,7 +138,7 @@ where { match string.as_ref().parse::() { Ok(compute_unit_limit) => Ok(ComputeUnitLimit::Static(compute_unit_limit)), - Err(_) if string.as_ref() == "SIMULATED" => Ok(ComputeUnitLimit::Simulated), + Err(_) if string.as_ref() == "DEFAULT" => Ok(ComputeUnitLimit::Default), _ => Err(format!( "Unable to parse compute unit limit, provided: {string}" )), @@ -2040,7 +2042,7 @@ fn main() { .global(true) .help("Transaction fee payer account [default: cli config keypair]"), ) - .arg(compute_unit_price_arg().validator(is_parsable::).requires(COMPUTE_UNIT_LIMIT_ARG.name).global(true)) + .arg(compute_unit_price_arg().validator(is_parsable::).global(true)) .arg( Arg::with_name(COMPUTE_UNIT_LIMIT_ARG.name) .long(COMPUTE_UNIT_LIMIT_ARG.long) @@ -2834,7 +2836,13 @@ fn main() { let compute_unit_limit = matches .value_of(COMPUTE_UNIT_LIMIT_ARG.name) .map(|x| parse_compute_unit_limit(x).unwrap()) - .unwrap_or(ComputeUnitLimit::Default); + .unwrap_or_else(|| { + if compute_unit_price.is_some() { + ComputeUnitLimit::Simulated + } else { + ComputeUnitLimit::Default + } + }); Config { rpc_client: RpcClient::new_with_commitment(json_rpc_url, CommitmentConfig::confirmed()),