@@ -114,19 +114,21 @@ const COMPUTE_UNIT_LIMIT_ARG: ArgConstant<'static> = ArgConstant {
114114 name : "compute_unit_limit" ,
115115 long : "--with-compute-unit-limit" ,
116116 help : "Set compute unit limit for transaction, in compute units; also accepts \
117- keyword SIMULATED to use compute units from transaction simulation prior \
118- to sending. Note that SIMULATED may fail if accounts are modified by another \
119- transaction between simulation and execution.",
117+ keyword DEFAULT to use the default compute unit limit, which is 200k per \
118+ top-level instruction, with a maximum of 1.4 million. \
119+ If nothing is set, transactions are simulated prior to sending, and the \
120+ compute units consumed are set as the limit. This may may fail if accounts \
121+ are modified by another transaction between simulation and execution.",
120122} ;
121123fn is_compute_unit_limit_or_simulated < T > ( string : T ) -> Result < ( ) , String >
122124where
123125 T : AsRef < str > + std:: fmt:: Display ,
124126{
125- if string. as_ref ( ) . parse :: < u32 > ( ) . is_ok ( ) || string. as_ref ( ) == "SIMULATED " {
127+ if string. as_ref ( ) . parse :: < u32 > ( ) . is_ok ( ) || string. as_ref ( ) == "DEFAULT " {
126128 Ok ( ( ) )
127129 } else {
128130 Err ( format ! (
129- "Unable to parse input compute unit limit as integer or SIMULATED , provided: {string}"
131+ "Unable to parse input compute unit limit as integer or DEFAULT , provided: {string}"
130132 ) )
131133 }
132134}
@@ -136,7 +138,7 @@ where
136138{
137139 match string. as_ref ( ) . parse :: < u32 > ( ) {
138140 Ok ( compute_unit_limit) => Ok ( ComputeUnitLimit :: Static ( compute_unit_limit) ) ,
139- Err ( _) if string. as_ref ( ) == "SIMULATED " => Ok ( ComputeUnitLimit :: Simulated ) ,
141+ Err ( _) if string. as_ref ( ) == "DEFAULT " => Ok ( ComputeUnitLimit :: Default ) ,
140142 _ => Err ( format ! (
141143 "Unable to parse compute unit limit, provided: {string}"
142144 ) ) ,
@@ -2040,7 +2042,7 @@ fn main() {
20402042 . global ( true )
20412043 . help ( "Transaction fee payer account [default: cli config keypair]" ) ,
20422044 )
2043- . arg ( compute_unit_price_arg ( ) . validator ( is_parsable :: < u64 > ) . requires ( COMPUTE_UNIT_LIMIT_ARG . name ) . global ( true ) )
2045+ . arg ( compute_unit_price_arg ( ) . validator ( is_parsable :: < u64 > ) . global ( true ) )
20442046 . arg (
20452047 Arg :: with_name ( COMPUTE_UNIT_LIMIT_ARG . name )
20462048 . long ( COMPUTE_UNIT_LIMIT_ARG . long )
@@ -2834,7 +2836,13 @@ fn main() {
28342836 let compute_unit_limit = matches
28352837 . value_of ( COMPUTE_UNIT_LIMIT_ARG . name )
28362838 . map ( |x| parse_compute_unit_limit ( x) . unwrap ( ) )
2837- . unwrap_or ( ComputeUnitLimit :: Default ) ;
2839+ . unwrap_or_else ( || {
2840+ if compute_unit_price. is_some ( ) {
2841+ ComputeUnitLimit :: Simulated
2842+ } else {
2843+ ComputeUnitLimit :: Default
2844+ }
2845+ } ) ;
28382846
28392847 Config {
28402848 rpc_client : RpcClient :: new_with_commitment ( json_rpc_url, CommitmentConfig :: confirmed ( ) ) ,
0 commit comments