浏览代码

cli: Use `WithComputeUnitConfig` for compute unit limit (#1810)

* cli: Add `ComputeUnitConfig` and use it, no functional changes

* Use Option<u64> directly instead of ref

* Correct default compute unit limit comment
Jon C 1 年之前
父节点
当前提交
0acaece546
共有 10 个文件被更改,包括 221 次插入117 次删除
  1. 11 0
      clap-utils/src/compute_budget.rs
  2. 22 22
      cli/src/cli.rs
  3. 7 4
      cli/src/cluster_query.rs
  4. 17 21
      cli/src/compute_budget.rs
  5. 31 13
      cli/src/nonce.rs
  6. 33 14
      cli/src/program.rs
  7. 46 19
      cli/src/stake.rs
  8. 11 5
      cli/src/validator_info.rs
  9. 32 14
      cli/src/vote.rs
  10. 11 5
      cli/src/wallet.rs

+ 11 - 0
clap-utils/src/compute_budget.rs

@@ -32,3 +32,14 @@ pub fn compute_unit_limit_arg<'a, 'b>() -> Arg<'a, 'b> {
         .validator(is_parsable::<u32>)
         .validator(is_parsable::<u32>)
         .help(COMPUTE_UNIT_LIMIT_ARG.help)
         .help(COMPUTE_UNIT_LIMIT_ARG.help)
 }
 }
+
+pub enum ComputeUnitLimit {
+    /// Do not include a compute unit limit instruction, which will give the
+    /// transaction a compute unit limit of:
+    /// `min(1_400_000, 200_000 * (num_top_level_instructions - num_compute_budget_instructions))`
+    Default,
+    /// Use a static predefined limit
+    Static(u32),
+    /// Simulate the transaction to find out the compute unit usage
+    Simulated,
+}

+ 22 - 22
cli/src/cli.rs

@@ -996,7 +996,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
                 timeout,
                 timeout,
                 blockhash,
                 blockhash,
                 *print_timestamp,
                 *print_timestamp,
-                compute_unit_price.as_ref(),
+                *compute_unit_price,
                 &rpc_client,
                 &rpc_client,
             )
             )
         }
         }
@@ -1075,7 +1075,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             new_authority,
             new_authority,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         // Create nonce account
         // Create nonce account
         CliCommand::CreateNonceAccount {
         CliCommand::CreateNonceAccount {
@@ -1093,7 +1093,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             *amount,
             *amount,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         // Get the current nonce
         // Get the current nonce
         CliCommand::GetNonce(nonce_account_pubkey) => {
         CliCommand::GetNonce(nonce_account_pubkey) => {
@@ -1111,7 +1111,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             nonce_account,
             nonce_account,
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         // Show the contents of a nonce account
         // Show the contents of a nonce account
         CliCommand::ShowNonceAccount {
         CliCommand::ShowNonceAccount {
@@ -1139,7 +1139,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             memo.as_ref(),
             memo.as_ref(),
             destination_account_pubkey,
             destination_account_pubkey,
             *lamports,
             *lamports,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         // Upgrade nonce account out of blockhash domain.
         // Upgrade nonce account out of blockhash domain.
         CliCommand::UpgradeNonceAccount {
         CliCommand::UpgradeNonceAccount {
@@ -1151,7 +1151,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             config,
             config,
             *nonce_account,
             *nonce_account,
             memo.as_ref(),
             memo.as_ref(),
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
 
 
         // Program Deployment
         // Program Deployment
@@ -1209,7 +1209,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
             *from,
             *from,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::DeactivateStake {
         CliCommand::DeactivateStake {
             stake_account_pubkey,
             stake_account_pubkey,
@@ -1238,7 +1238,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             memo.as_ref(),
             memo.as_ref(),
             seed.as_ref(),
             seed.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::DelegateStake {
         CliCommand::DelegateStake {
             stake_account_pubkey,
             stake_account_pubkey,
@@ -1269,7 +1269,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
             *redelegation_stake_account,
             *redelegation_stake_account,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::SplitStake {
         CliCommand::SplitStake {
             stake_account_pubkey,
             stake_account_pubkey,
@@ -1301,7 +1301,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             seed,
             seed,
             *lamports,
             *lamports,
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
             rent_exempt_reserve.as_ref(),
             rent_exempt_reserve.as_ref(),
         ),
         ),
         CliCommand::MergeStake {
         CliCommand::MergeStake {
@@ -1329,7 +1329,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::ShowStakeAccount {
         CliCommand::ShowStakeAccount {
             pubkey: stake_account_pubkey,
             pubkey: stake_account_pubkey,
@@ -1375,7 +1375,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
             *no_wait,
             *no_wait,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::StakeSetLockup {
         CliCommand::StakeSetLockup {
             stake_account_pubkey,
             stake_account_pubkey,
@@ -1404,7 +1404,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::WithdrawStake {
         CliCommand::WithdrawStake {
             stake_account_pubkey,
             stake_account_pubkey,
@@ -1437,7 +1437,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             memo.as_ref(),
             memo.as_ref(),
             seed.as_ref(),
             seed.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::StakeMinimumDelegation { use_lamports_unit } => {
         CliCommand::StakeMinimumDelegation { use_lamports_unit } => {
             process_stake_minimum_delegation(&rpc_client, config, *use_lamports_unit)
             process_stake_minimum_delegation(&rpc_client, config, *use_lamports_unit)
@@ -1461,7 +1461,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             validator_info,
             validator_info,
             *force_keybase,
             *force_keybase,
             *info_pubkey,
             *info_pubkey,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
 
 
         // Vote Commands
         // Vote Commands
@@ -1498,7 +1498,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::ShowVoteAccount {
         CliCommand::ShowVoteAccount {
             pubkey: vote_account_pubkey,
             pubkey: vote_account_pubkey,
@@ -1540,7 +1540,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::CloseVoteAccount {
         CliCommand::CloseVoteAccount {
             vote_account_pubkey,
             vote_account_pubkey,
@@ -1557,7 +1557,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             destination_account_pubkey,
             destination_account_pubkey,
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::VoteAuthorize {
         CliCommand::VoteAuthorize {
             vote_account_pubkey,
             vote_account_pubkey,
@@ -1588,7 +1588,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::VoteUpdateValidator {
         CliCommand::VoteUpdateValidator {
             vote_account_pubkey,
             vote_account_pubkey,
@@ -1615,7 +1615,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         CliCommand::VoteUpdateCommission {
         CliCommand::VoteUpdateCommission {
             vote_account_pubkey,
             vote_account_pubkey,
@@ -1642,7 +1642,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *nonce_authority,
             *nonce_authority,
             memo.as_ref(),
             memo.as_ref(),
             *fee_payer,
             *fee_payer,
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
 
 
         // Wallet Commands
         // Wallet Commands
@@ -1706,7 +1706,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             *fee_payer,
             *fee_payer,
             derived_address_seed.clone(),
             derived_address_seed.clone(),
             derived_address_program_id.as_ref(),
             derived_address_program_id.as_ref(),
-            compute_unit_price.as_ref(),
+            *compute_unit_price,
         ),
         ),
         // Address Lookup Table Commands
         // Address Lookup Table Commands
         CliCommand::AddressLookupTable(subcommand) => {
         CliCommand::AddressLookupTable(subcommand) => {

+ 7 - 4
cli/src/cluster_query.rs

@@ -1,7 +1,7 @@
 use {
 use {
     crate::{
     crate::{
         cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
         cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
-        compute_budget::WithComputeUnitPrice,
+        compute_budget::{ComputeUnitConfig, WithComputeUnitConfig},
         feature::get_feature_activation_epoch,
         feature::get_feature_activation_epoch,
         spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
         spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
     },
     },
@@ -10,7 +10,7 @@ use {
     crossbeam_channel::unbounded,
     crossbeam_channel::unbounded,
     serde::{Deserialize, Serialize},
     serde::{Deserialize, Serialize},
     solana_clap_utils::{
     solana_clap_utils::{
-        compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
+        compute_budget::{compute_unit_price_arg, ComputeUnitLimit, COMPUTE_UNIT_PRICE_ARG},
         input_parsers::*,
         input_parsers::*,
         input_validators::*,
         input_validators::*,
         keypair::DefaultSigner,
         keypair::DefaultSigner,
@@ -1480,7 +1480,7 @@ pub fn process_ping(
     timeout: &Duration,
     timeout: &Duration,
     fixed_blockhash: &Option<Hash>,
     fixed_blockhash: &Option<Hash>,
     print_timestamp: bool,
     print_timestamp: bool,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
     rpc_client: &RpcClient,
     rpc_client: &RpcClient,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let (signal_sender, signal_receiver) = unbounded();
     let (signal_sender, signal_receiver) = unbounded();
@@ -1526,7 +1526,10 @@ pub fn process_ping(
                 &to,
                 &to,
                 lamports,
                 lamports,
             )]
             )]
-            .with_compute_unit_price(compute_unit_price);
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Default,
+            });
             Message::new(&ixs, Some(&config.signers[0].pubkey()))
             Message::new(&ixs, Some(&config.signers[0].pubkey()))
         };
         };
         let (message, _) = resolve_spend_tx_and_check_account_balance(
         let (message, _) = resolve_spend_tx_and_check_account_balance(

+ 17 - 21
cli/src/compute_budget.rs

@@ -1,4 +1,5 @@
 use {
 use {
+    solana_clap_utils::compute_budget::ComputeUnitLimit,
     solana_client::rpc_config::RpcSimulateTransactionConfig,
     solana_client::rpc_config::RpcSimulateTransactionConfig,
     solana_compute_budget::compute_budget_processor::MAX_COMPUTE_UNIT_LIMIT,
     solana_compute_budget::compute_budget_processor::MAX_COMPUTE_UNIT_LIMIT,
     solana_rpc_client::rpc_client::RpcClient,
     solana_rpc_client::rpc_client::RpcClient,
@@ -76,23 +77,9 @@ pub(crate) fn simulate_and_update_compute_unit_limit(
     ))
     ))
 }
 }
 
 
-pub(crate) trait WithComputeUnitPrice {
-    fn with_compute_unit_price(self, compute_unit_price: Option<&u64>) -> Self;
-}
-
-impl WithComputeUnitPrice for Vec<Instruction> {
-    fn with_compute_unit_price(mut self, compute_unit_price: Option<&u64>) -> Self {
-        if let Some(compute_unit_price) = compute_unit_price {
-            self.push(ComputeBudgetInstruction::set_compute_unit_price(
-                *compute_unit_price,
-            ));
-        }
-        self
-    }
-}
-
 pub(crate) struct ComputeUnitConfig {
 pub(crate) struct ComputeUnitConfig {
     pub(crate) compute_unit_price: Option<u64>,
     pub(crate) compute_unit_price: Option<u64>,
+    pub(crate) compute_unit_limit: ComputeUnitLimit,
 }
 }
 
 
 pub(crate) trait WithComputeUnitConfig {
 pub(crate) trait WithComputeUnitConfig {
@@ -105,12 +92,21 @@ impl WithComputeUnitConfig for Vec<Instruction> {
             self.push(ComputeBudgetInstruction::set_compute_unit_price(
             self.push(ComputeBudgetInstruction::set_compute_unit_price(
                 compute_unit_price,
                 compute_unit_price,
             ));
             ));
-
-            // Default to the max compute unit limit because later transactions will be
-            // simulated to get the exact compute units consumed.
-            self.push(ComputeBudgetInstruction::set_compute_unit_limit(
-                MAX_COMPUTE_UNIT_LIMIT,
-            ));
+            match config.compute_unit_limit {
+                ComputeUnitLimit::Default => {}
+                ComputeUnitLimit::Static(compute_unit_limit) => {
+                    self.push(ComputeBudgetInstruction::set_compute_unit_limit(
+                        compute_unit_limit,
+                    ));
+                }
+                ComputeUnitLimit::Simulated => {
+                    // Default to the max compute unit limit because later transactions will be
+                    // simulated to get the exact compute units consumed.
+                    self.push(ComputeBudgetInstruction::set_compute_unit_limit(
+                        MAX_COMPUTE_UNIT_LIMIT,
+                    ));
+                }
+            }
         }
         }
         self
         self
     }
     }

+ 31 - 13
cli/src/nonce.rs

@@ -5,13 +5,13 @@ use {
             log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
             log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
             ProcessResult,
             ProcessResult,
         },
         },
-        compute_budget::WithComputeUnitPrice,
+        compute_budget::{ComputeUnitConfig, WithComputeUnitConfig},
         memo::WithMemo,
         memo::WithMemo,
         spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
         spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
     },
     },
     clap::{App, Arg, ArgMatches, SubCommand},
     clap::{App, Arg, ArgMatches, SubCommand},
     solana_clap_utils::{
     solana_clap_utils::{
-        compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
+        compute_budget::{compute_unit_price_arg, ComputeUnitLimit, COMPUTE_UNIT_PRICE_ARG},
         input_parsers::*,
         input_parsers::*,
         input_validators::*,
         input_validators::*,
         keypair::{CliSigners, DefaultSigner, SignerIndex},
         keypair::{CliSigners, DefaultSigner, SignerIndex},
@@ -408,7 +408,7 @@ pub fn process_authorize_nonce_account(
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
     new_authority: &Pubkey,
     new_authority: &Pubkey,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let latest_blockhash = rpc_client.get_latest_blockhash()?;
     let latest_blockhash = rpc_client.get_latest_blockhash()?;
 
 
@@ -419,7 +419,10 @@ pub fn process_authorize_nonce_account(
         new_authority,
         new_authority,
     )]
     )]
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
     let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
     let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
     let mut tx = Transaction::new_unsigned(message);
     let mut tx = Transaction::new_unsigned(message);
     tx.try_sign(&config.signers, latest_blockhash)?;
     tx.try_sign(&config.signers, latest_blockhash)?;
@@ -443,7 +446,7 @@ pub fn process_create_nonce_account(
     nonce_authority: Option<Pubkey>,
     nonce_authority: Option<Pubkey>,
     memo: Option<&String>,
     memo: Option<&String>,
     amount: SpendAmount,
     amount: SpendAmount,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let nonce_account_pubkey = config.signers[nonce_account].pubkey();
     let nonce_account_pubkey = config.signers[nonce_account].pubkey();
     let nonce_account_address = if let Some(ref seed) = seed {
     let nonce_account_address = if let Some(ref seed) = seed {
@@ -470,7 +473,10 @@ pub fn process_create_nonce_account(
                 lamports,
                 lamports,
             )
             )
             .with_memo(memo)
             .with_memo(memo)
-            .with_compute_unit_price(compute_unit_price)
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Default,
+            })
         } else {
         } else {
             create_nonce_account(
             create_nonce_account(
                 &config.signers[0].pubkey(),
                 &config.signers[0].pubkey(),
@@ -479,7 +485,10 @@ pub fn process_create_nonce_account(
                 lamports,
                 lamports,
             )
             )
             .with_memo(memo)
             .with_memo(memo)
-            .with_compute_unit_price(compute_unit_price)
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Default,
+            })
         };
         };
         Message::new(&ixs, Some(&config.signers[0].pubkey()))
         Message::new(&ixs, Some(&config.signers[0].pubkey()))
     };
     };
@@ -540,7 +549,7 @@ pub fn process_new_nonce(
     nonce_account: &Pubkey,
     nonce_account: &Pubkey,
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     check_unique_pubkeys(
     check_unique_pubkeys(
         (&config.signers[0].pubkey(), "cli keypair".to_string()),
         (&config.signers[0].pubkey(), "cli keypair".to_string()),
@@ -560,7 +569,10 @@ pub fn process_new_nonce(
         &nonce_authority.pubkey(),
         &nonce_authority.pubkey(),
     )]
     )]
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
     let latest_blockhash = rpc_client.get_latest_blockhash()?;
     let latest_blockhash = rpc_client.get_latest_blockhash()?;
     let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
     let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
     let mut tx = Transaction::new_unsigned(message);
     let mut tx = Transaction::new_unsigned(message);
@@ -614,7 +626,7 @@ pub fn process_withdraw_from_nonce_account(
     memo: Option<&String>,
     memo: Option<&String>,
     destination_account_pubkey: &Pubkey,
     destination_account_pubkey: &Pubkey,
     lamports: u64,
     lamports: u64,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let latest_blockhash = rpc_client.get_latest_blockhash()?;
     let latest_blockhash = rpc_client.get_latest_blockhash()?;
 
 
@@ -626,7 +638,10 @@ pub fn process_withdraw_from_nonce_account(
         lamports,
         lamports,
     )]
     )]
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
     let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
     let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
     let mut tx = Transaction::new_unsigned(message);
     let mut tx = Transaction::new_unsigned(message);
     tx.try_sign(&config.signers, latest_blockhash)?;
     tx.try_sign(&config.signers, latest_blockhash)?;
@@ -646,12 +661,15 @@ pub(crate) fn process_upgrade_nonce_account(
     config: &CliConfig,
     config: &CliConfig,
     nonce_account: Pubkey,
     nonce_account: Pubkey,
     memo: Option<&String>,
     memo: Option<&String>,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let latest_blockhash = rpc_client.get_latest_blockhash()?;
     let latest_blockhash = rpc_client.get_latest_blockhash()?;
     let ixs = vec![upgrade_nonce_account(nonce_account)]
     let ixs = vec![upgrade_nonce_account(nonce_account)]
         .with_memo(memo)
         .with_memo(memo)
-        .with_compute_unit_price(compute_unit_price);
+        .with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Default,
+        });
     let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
     let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
     let mut tx = Transaction::new_unsigned(message);
     let mut tx = Transaction::new_unsigned(message);
     tx.try_sign(&config.signers, latest_blockhash)?;
     tx.try_sign(&config.signers, latest_blockhash)?;

+ 33 - 14
cli/src/program.rs

@@ -18,7 +18,7 @@ use {
     solana_bpf_loader_program::syscalls::create_program_runtime_environment_v1,
     solana_bpf_loader_program::syscalls::create_program_runtime_environment_v1,
     solana_clap_utils::{
     solana_clap_utils::{
         self,
         self,
-        compute_unit_price::compute_unit_price_arg,
+        compute_budget::{compute_unit_price_arg, ComputeUnitLimit},
         fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
         fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
         hidden_unless_forced,
         hidden_unless_forced,
         input_parsers::*,
         input_parsers::*,
@@ -2440,8 +2440,10 @@ fn do_process_program_deploy(
 
 
     let initial_message = if !initial_instructions.is_empty() {
     let initial_message = if !initial_instructions.is_empty() {
         Some(Message::new_with_blockhash(
         Some(Message::new_with_blockhash(
-            &initial_instructions
-                .with_compute_unit_config(&ComputeUnitConfig { compute_unit_price }),
+            &initial_instructions.with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Simulated,
+            }),
             Some(&fee_payer_signer.pubkey()),
             Some(&fee_payer_signer.pubkey()),
             &blockhash,
             &blockhash,
         ))
         ))
@@ -2458,8 +2460,10 @@ fn do_process_program_deploy(
             bytes,
             bytes,
         );
         );
 
 
-        let instructions =
-            vec![instruction].with_compute_unit_config(&ComputeUnitConfig { compute_unit_price });
+        let instructions = vec![instruction].with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Simulated,
+        });
         Message::new_with_blockhash(&instructions, Some(&fee_payer_signer.pubkey()), &blockhash)
         Message::new_with_blockhash(&instructions, Some(&fee_payer_signer.pubkey()), &blockhash)
     };
     };
 
 
@@ -2483,7 +2487,10 @@ fn do_process_program_deploy(
                 .get_minimum_balance_for_rent_exemption(UpgradeableLoaderState::size_of_program())?,
                 .get_minimum_balance_for_rent_exemption(UpgradeableLoaderState::size_of_program())?,
             program_data_max_len,
             program_data_max_len,
         )?
         )?
-        .with_compute_unit_config(&ComputeUnitConfig { compute_unit_price });
+        .with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Simulated,
+        });
 
 
         Some(Message::new_with_blockhash(
         Some(Message::new_with_blockhash(
             &instructions,
             &instructions,
@@ -2563,8 +2570,10 @@ fn do_process_write_buffer(
 
 
     let initial_message = if !initial_instructions.is_empty() {
     let initial_message = if !initial_instructions.is_empty() {
         Some(Message::new_with_blockhash(
         Some(Message::new_with_blockhash(
-            &initial_instructions
-                .with_compute_unit_config(&ComputeUnitConfig { compute_unit_price }),
+            &initial_instructions.with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Simulated,
+            }),
             Some(&fee_payer_signer.pubkey()),
             Some(&fee_payer_signer.pubkey()),
             &blockhash,
             &blockhash,
         ))
         ))
@@ -2581,8 +2590,10 @@ fn do_process_write_buffer(
             bytes,
             bytes,
         );
         );
 
 
-        let instructions =
-            vec![instruction].with_compute_unit_config(&ComputeUnitConfig { compute_unit_price });
+        let instructions = vec![instruction].with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Simulated,
+        });
         Message::new_with_blockhash(&instructions, Some(&fee_payer_signer.pubkey()), &blockhash)
         Message::new_with_blockhash(&instructions, Some(&fee_payer_signer.pubkey()), &blockhash)
     };
     };
 
 
@@ -2681,8 +2692,10 @@ fn do_process_program_upgrade(
 
 
         let initial_message = if !initial_instructions.is_empty() {
         let initial_message = if !initial_instructions.is_empty() {
             Some(Message::new_with_blockhash(
             Some(Message::new_with_blockhash(
-                &initial_instructions
-                    .with_compute_unit_config(&ComputeUnitConfig { compute_unit_price }),
+                &initial_instructions.with_compute_unit_config(&ComputeUnitConfig {
+                    compute_unit_price,
+                    compute_unit_limit: ComputeUnitLimit::Simulated,
+                }),
                 Some(&fee_payer_signer.pubkey()),
                 Some(&fee_payer_signer.pubkey()),
                 &blockhash,
                 &blockhash,
             ))
             ))
@@ -2699,7 +2712,10 @@ fn do_process_program_upgrade(
                 offset,
                 offset,
                 bytes,
                 bytes,
             )]
             )]
-            .with_compute_unit_config(&ComputeUnitConfig { compute_unit_price });
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Simulated,
+            });
             Message::new_with_blockhash(&instructions, Some(&fee_payer_signer.pubkey()), &blockhash)
             Message::new_with_blockhash(&instructions, Some(&fee_payer_signer.pubkey()), &blockhash)
         };
         };
 
 
@@ -2725,7 +2741,10 @@ fn do_process_program_upgrade(
         &upgrade_authority.pubkey(),
         &upgrade_authority.pubkey(),
         &fee_payer_signer.pubkey(),
         &fee_payer_signer.pubkey(),
     )]
     )]
-    .with_compute_unit_config(&ComputeUnitConfig { compute_unit_price });
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Simulated,
+    });
     let final_message = Message::new_with_blockhash(
     let final_message = Message::new_with_blockhash(
         &final_instructions,
         &final_instructions,
         Some(&fee_payer_signer.pubkey()),
         Some(&fee_payer_signer.pubkey()),

+ 46 - 19
cli/src/stake.rs

@@ -5,7 +5,7 @@ use {
             log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
             log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
             ProcessResult,
             ProcessResult,
         },
         },
-        compute_budget::WithComputeUnitPrice,
+        compute_budget::{ComputeUnitConfig, WithComputeUnitConfig},
         feature::get_feature_activation_epoch,
         feature::get_feature_activation_epoch,
         memo::WithMemo,
         memo::WithMemo,
         nonce::check_nonce_account,
         nonce::check_nonce_account,
@@ -13,7 +13,7 @@ use {
     },
     },
     clap::{value_t, App, Arg, ArgGroup, ArgMatches, SubCommand},
     clap::{value_t, App, Arg, ArgGroup, ArgMatches, SubCommand},
     solana_clap_utils::{
     solana_clap_utils::{
-        compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
+        compute_budget::{compute_unit_price_arg, ComputeUnitLimit, COMPUTE_UNIT_PRICE_ARG},
         fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
         fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
         hidden_unless_forced,
         hidden_unless_forced,
         input_parsers::*,
         input_parsers::*,
@@ -1420,7 +1420,7 @@ pub fn process_create_stake_account(
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
     from: SignerIndex,
     from: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let stake_account = config.signers[stake_account];
     let stake_account = config.signers[stake_account];
     let stake_account_address = if let Some(seed) = seed {
     let stake_account_address = if let Some(seed) = seed {
@@ -1478,7 +1478,10 @@ pub fn process_create_stake_account(
             ),
             ),
         }
         }
         .with_memo(memo)
         .with_memo(memo)
-        .with_compute_unit_price(compute_unit_price);
+        .with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Default,
+        });
         if let Some(nonce_account) = &nonce_account {
         if let Some(nonce_account) = &nonce_account {
             Message::new_with_nonce(
             Message::new_with_nonce(
                 ixs,
                 ixs,
@@ -1567,7 +1570,7 @@ pub fn process_stake_authorize(
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
     no_wait: bool,
     no_wait: bool,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let mut ixs = Vec::new();
     let mut ixs = Vec::new();
     let custodian = custodian.map(|index| config.signers[index]);
     let custodian = custodian.map(|index| config.signers[index]);
@@ -1635,7 +1638,10 @@ pub fn process_stake_authorize(
     }
     }
     ixs = ixs
     ixs = ixs
         .with_memo(memo)
         .with_memo(memo)
-        .with_compute_unit_price(compute_unit_price);
+        .with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Default,
+        });
 
 
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
 
 
@@ -1703,7 +1709,7 @@ pub fn process_deactivate_stake_account(
     memo: Option<&String>,
     memo: Option<&String>,
     seed: Option<&String>,
     seed: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
 
 
@@ -1780,7 +1786,10 @@ pub fn process_deactivate_stake_account(
         stake_instruction::deactivate_stake(&stake_account_address, &stake_authority.pubkey())
         stake_instruction::deactivate_stake(&stake_account_address, &stake_authority.pubkey())
     }]
     }]
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
 
 
     let nonce_authority = config.signers[nonce_authority];
     let nonce_authority = config.signers[nonce_authority];
     let fee_payer = config.signers[fee_payer];
     let fee_payer = config.signers[fee_payer];
@@ -1844,7 +1853,7 @@ pub fn process_withdraw_stake(
     memo: Option<&String>,
     memo: Option<&String>,
     seed: Option<&String>,
     seed: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let withdraw_authority = config.signers[withdraw_authority];
     let withdraw_authority = config.signers[withdraw_authority];
     let custodian = custodian.map(|index| config.signers[index]);
     let custodian = custodian.map(|index| config.signers[index]);
@@ -1869,7 +1878,10 @@ pub fn process_withdraw_stake(
             custodian.map(|signer| signer.pubkey()).as_ref(),
             custodian.map(|signer| signer.pubkey()).as_ref(),
         )]
         )]
         .with_memo(memo)
         .with_memo(memo)
-        .with_compute_unit_price(compute_unit_price);
+        .with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Default,
+        });
 
 
         if let Some(nonce_account) = &nonce_account {
         if let Some(nonce_account) = &nonce_account {
             Message::new_with_nonce(
             Message::new_with_nonce(
@@ -1942,7 +1954,7 @@ pub fn process_split_stake(
     split_stake_account_seed: &Option<String>,
     split_stake_account_seed: &Option<String>,
     lamports: u64,
     lamports: u64,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
     rent_exempt_reserve: Option<&u64>,
     rent_exempt_reserve: Option<&u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let split_stake_account = config.signers[split_stake_account];
     let split_stake_account = config.signers[split_stake_account];
@@ -2048,7 +2060,10 @@ pub fn process_split_stake(
                 seed,
                 seed,
             )
             )
             .with_memo(memo)
             .with_memo(memo)
-            .with_compute_unit_price(compute_unit_price),
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Default,
+            }),
         )
         )
     } else {
     } else {
         ixs.append(
         ixs.append(
@@ -2059,7 +2074,10 @@ pub fn process_split_stake(
                 &split_stake_account_address,
                 &split_stake_account_address,
             )
             )
             .with_memo(memo)
             .with_memo(memo)
-            .with_compute_unit_price(compute_unit_price),
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Default,
+            }),
         )
         )
     };
     };
 
 
@@ -2121,7 +2139,7 @@ pub fn process_merge_stake(
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let fee_payer = config.signers[fee_payer];
     let fee_payer = config.signers[fee_payer];
 
 
@@ -2167,7 +2185,10 @@ pub fn process_merge_stake(
         &stake_authority.pubkey(),
         &stake_authority.pubkey(),
     )
     )
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
 
 
     let nonce_authority = config.signers[nonce_authority];
     let nonce_authority = config.signers[nonce_authority];
 
 
@@ -2232,7 +2253,7 @@ pub fn process_stake_set_lockup(
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
     let custodian = config.signers[custodian];
     let custodian = config.signers[custodian];
@@ -2243,7 +2264,10 @@ pub fn process_stake_set_lockup(
         stake_instruction::set_lockup(stake_account_pubkey, lockup, &custodian.pubkey())
         stake_instruction::set_lockup(stake_account_pubkey, lockup, &custodian.pubkey())
     }]
     }]
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
     let nonce_authority = config.signers[nonce_authority];
     let nonce_authority = config.signers[nonce_authority];
     let fee_payer = config.signers[fee_payer];
     let fee_payer = config.signers[fee_payer];
 
 
@@ -2658,7 +2682,7 @@ pub fn process_delegate_stake(
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
     redelegation_stake_account: Option<SignerIndex>,
     redelegation_stake_account: Option<SignerIndex>,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     check_unique_pubkeys(
     check_unique_pubkeys(
         (&config.signers[0].pubkey(), "cli keypair".to_string()),
         (&config.signers[0].pubkey(), "cli keypair".to_string()),
@@ -2749,7 +2773,10 @@ pub fn process_delegate_stake(
         )]
         )]
     }
     }
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
 
 
     let nonce_authority = config.signers[nonce_authority];
     let nonce_authority = config.signers[nonce_authority];
     let fee_payer = config.signers[fee_payer];
     let fee_payer = config.signers[fee_payer];

+ 11 - 5
cli/src/validator_info.rs

@@ -1,7 +1,7 @@
 use {
 use {
     crate::{
     crate::{
         cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
         cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
-        compute_budget::WithComputeUnitPrice,
+        compute_budget::{ComputeUnitConfig, WithComputeUnitConfig},
         spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
         spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
     },
     },
     bincode::{deserialize, serialized_size},
     bincode::{deserialize, serialized_size},
@@ -12,7 +12,7 @@ use {
         self, ValidatorInfo, MAX_LONG_FIELD_LENGTH, MAX_SHORT_FIELD_LENGTH,
         self, ValidatorInfo, MAX_LONG_FIELD_LENGTH, MAX_SHORT_FIELD_LENGTH,
     },
     },
     solana_clap_utils::{
     solana_clap_utils::{
-        compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
+        compute_budget::{compute_unit_price_arg, ComputeUnitLimit, COMPUTE_UNIT_PRICE_ARG},
         hidden_unless_forced,
         hidden_unless_forced,
         input_parsers::{pubkey_of, value_of},
         input_parsers::{pubkey_of, value_of},
         input_validators::{is_pubkey, is_url},
         input_validators::{is_pubkey, is_url},
@@ -275,7 +275,7 @@ pub fn process_set_validator_info(
     validator_info: &Value,
     validator_info: &Value,
     force_keybase: bool,
     force_keybase: bool,
     info_pubkey: Option<Pubkey>,
     info_pubkey: Option<Pubkey>,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     // Validate keybase username
     // Validate keybase username
     if let Some(string) = validator_info.get("keybaseUsername") {
     if let Some(string) = validator_info.get("keybaseUsername") {
@@ -362,7 +362,10 @@ pub fn process_set_validator_info(
                 lamports,
                 lamports,
                 keys.clone(),
                 keys.clone(),
             )
             )
-            .with_compute_unit_price(compute_unit_price);
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Default,
+            });
             instructions.extend_from_slice(&[config_instruction::store(
             instructions.extend_from_slice(&[config_instruction::store(
                 &info_pubkey,
                 &info_pubkey,
                 true,
                 true,
@@ -382,7 +385,10 @@ pub fn process_set_validator_info(
                 keys,
                 keys,
                 &validator_info,
                 &validator_info,
             )]
             )]
-            .with_compute_unit_price(compute_unit_price);
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Default,
+            });
             Message::new(&instructions, Some(&config.signers[0].pubkey()))
             Message::new(&instructions, Some(&config.signers[0].pubkey()))
         }
         }
     };
     };

+ 32 - 14
cli/src/vote.rs

@@ -5,7 +5,7 @@ use {
             log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
             log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
             ProcessResult,
             ProcessResult,
         },
         },
-        compute_budget::WithComputeUnitPrice,
+        compute_budget::{ComputeUnitConfig, WithComputeUnitConfig},
         memo::WithMemo,
         memo::WithMemo,
         nonce::check_nonce_account,
         nonce::check_nonce_account,
         spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
         spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
@@ -13,7 +13,7 @@ use {
     },
     },
     clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand},
     clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand},
     solana_clap_utils::{
     solana_clap_utils::{
-        compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
+        compute_budget::{compute_unit_price_arg, ComputeUnitLimit, COMPUTE_UNIT_PRICE_ARG},
         fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
         fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
         input_parsers::*,
         input_parsers::*,
         input_validators::*,
         input_validators::*,
@@ -791,7 +791,7 @@ pub fn process_create_vote_account(
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let vote_account = config.signers[vote_account];
     let vote_account = config.signers[vote_account];
     let vote_account_pubkey = vote_account.pubkey();
     let vote_account_pubkey = vote_account.pubkey();
@@ -853,7 +853,10 @@ pub fn process_create_vote_account(
             create_vote_account_config,
             create_vote_account_config,
         )
         )
         .with_memo(memo)
         .with_memo(memo)
-        .with_compute_unit_price(compute_unit_price);
+        .with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Default,
+        });
 
 
         if let Some(nonce_account) = &nonce_account {
         if let Some(nonce_account) = &nonce_account {
             Message::new_with_nonce(
             Message::new_with_nonce(
@@ -939,7 +942,7 @@ pub fn process_vote_authorize(
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let authorized = config.signers[authorized];
     let authorized = config.signers[authorized];
     let new_authorized_signer = new_authorized.map(|index| config.signers[index]);
     let new_authorized_signer = new_authorized.map(|index| config.signers[index]);
@@ -1004,7 +1007,10 @@ pub fn process_vote_authorize(
     };
     };
     let ixs = vec![vote_ix]
     let ixs = vec![vote_ix]
         .with_memo(memo)
         .with_memo(memo)
-        .with_compute_unit_price(compute_unit_price);
+        .with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Default,
+        });
 
 
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
 
 
@@ -1067,7 +1073,7 @@ pub fn process_vote_update_validator(
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let authorized_withdrawer = config.signers[withdraw_authority];
     let authorized_withdrawer = config.signers[withdraw_authority];
     let new_identity_account = config.signers[new_identity_account];
     let new_identity_account = config.signers[new_identity_account];
@@ -1083,7 +1089,10 @@ pub fn process_vote_update_validator(
         &new_identity_pubkey,
         &new_identity_pubkey,
     )]
     )]
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
     let nonce_authority = config.signers[nonce_authority];
     let nonce_authority = config.signers[nonce_authority];
     let fee_payer = config.signers[fee_payer];
     let fee_payer = config.signers[fee_payer];
 
 
@@ -1143,7 +1152,7 @@ pub fn process_vote_update_commission(
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let authorized_withdrawer = config.signers[withdraw_authority];
     let authorized_withdrawer = config.signers[withdraw_authority];
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
@@ -1153,7 +1162,10 @@ pub fn process_vote_update_commission(
         commission,
         commission,
     )]
     )]
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
     let nonce_authority = config.signers[nonce_authority];
     let nonce_authority = config.signers[nonce_authority];
     let fee_payer = config.signers[fee_payer];
     let fee_payer = config.signers[fee_payer];
 
 
@@ -1302,7 +1314,7 @@ pub fn process_withdraw_from_vote_account(
     nonce_authority: SignerIndex,
     nonce_authority: SignerIndex,
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let withdraw_authority = config.signers[withdraw_authority];
     let withdraw_authority = config.signers[withdraw_authority];
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
     let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
@@ -1318,7 +1330,10 @@ pub fn process_withdraw_from_vote_account(
             destination_account_pubkey,
             destination_account_pubkey,
         )]
         )]
         .with_memo(memo)
         .with_memo(memo)
-        .with_compute_unit_price(compute_unit_price);
+        .with_compute_unit_config(&ComputeUnitConfig {
+            compute_unit_price,
+            compute_unit_limit: ComputeUnitLimit::Default,
+        });
 
 
         if let Some(nonce_account) = &nonce_account {
         if let Some(nonce_account) = &nonce_account {
             Message::new_with_nonce(
             Message::new_with_nonce(
@@ -1400,7 +1415,7 @@ pub fn process_close_vote_account(
     destination_account_pubkey: &Pubkey,
     destination_account_pubkey: &Pubkey,
     memo: Option<&String>,
     memo: Option<&String>,
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let vote_account_status =
     let vote_account_status =
         rpc_client.get_vote_accounts_with_config(RpcGetVoteAccountsConfig {
         rpc_client.get_vote_accounts_with_config(RpcGetVoteAccountsConfig {
@@ -1435,7 +1450,10 @@ pub fn process_close_vote_account(
         destination_account_pubkey,
         destination_account_pubkey,
     )]
     )]
     .with_memo(memo)
     .with_memo(memo)
-    .with_compute_unit_price(compute_unit_price);
+    .with_compute_unit_config(&ComputeUnitConfig {
+        compute_unit_price,
+        compute_unit_limit: ComputeUnitLimit::Default,
+    });
 
 
     let message = Message::new(&ixs, Some(&fee_payer.pubkey()));
     let message = Message::new(&ixs, Some(&fee_payer.pubkey()));
     let mut tx = Transaction::new_unsigned(message);
     let mut tx = Transaction::new_unsigned(message);

+ 11 - 5
cli/src/wallet.rs

@@ -4,7 +4,7 @@ use {
             log_instruction_custom_error, request_and_confirm_airdrop, CliCommand, CliCommandInfo,
             log_instruction_custom_error, request_and_confirm_airdrop, CliCommand, CliCommandInfo,
             CliConfig, CliError, ProcessResult,
             CliConfig, CliError, ProcessResult,
         },
         },
-        compute_budget::WithComputeUnitPrice,
+        compute_budget::{ComputeUnitConfig, WithComputeUnitConfig},
         memo::WithMemo,
         memo::WithMemo,
         nonce::check_nonce_account,
         nonce::check_nonce_account,
         spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
         spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
@@ -12,7 +12,7 @@ use {
     clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand},
     clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand},
     hex::FromHex,
     hex::FromHex,
     solana_clap_utils::{
     solana_clap_utils::{
-        compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
+        compute_budget::{compute_unit_price_arg, ComputeUnitLimit, COMPUTE_UNIT_PRICE_ARG},
         fee_payer::*,
         fee_payer::*,
         hidden_unless_forced,
         hidden_unless_forced,
         input_parsers::*,
         input_parsers::*,
@@ -879,7 +879,7 @@ pub fn process_transfer(
     fee_payer: SignerIndex,
     fee_payer: SignerIndex,
     derived_address_seed: Option<String>,
     derived_address_seed: Option<String>,
     derived_address_program_id: Option<&Pubkey>,
     derived_address_program_id: Option<&Pubkey>,
-    compute_unit_price: Option<&u64>,
+    compute_unit_price: Option<u64>,
 ) -> ProcessResult {
 ) -> ProcessResult {
     let from = config.signers[from];
     let from = config.signers[from];
     let mut from_pubkey = from.pubkey();
     let mut from_pubkey = from.pubkey();
@@ -922,11 +922,17 @@ pub fn process_transfer(
                 lamports,
                 lamports,
             )]
             )]
             .with_memo(memo)
             .with_memo(memo)
-            .with_compute_unit_price(compute_unit_price)
+            .with_compute_unit_config(&ComputeUnitConfig {
+                compute_unit_price,
+                compute_unit_limit: ComputeUnitLimit::Default,
+            })
         } else {
         } else {
             vec![system_instruction::transfer(&from_pubkey, to, lamports)]
             vec![system_instruction::transfer(&from_pubkey, to, lamports)]
                 .with_memo(memo)
                 .with_memo(memo)
-                .with_compute_unit_price(compute_unit_price)
+                .with_compute_unit_config(&ComputeUnitConfig {
+                    compute_unit_price,
+                    compute_unit_limit: ComputeUnitLimit::Default,
+                })
         };
         };
 
 
         if let Some(nonce_account) = &nonce_account {
         if let Some(nonce_account) = &nonce_account {