|
|
@@ -344,7 +344,7 @@ impl JsonRpcRequestProcessor {
|
|
|
|
|
|
#[allow(deprecated)]
|
|
|
fn bank(&self, commitment: Option<CommitmentConfig>) -> Arc<Bank> {
|
|
|
- debug!("RPC commitment_config: {:?}", commitment);
|
|
|
+ debug!("RPC commitment_config: {commitment:?}");
|
|
|
|
|
|
let commitment = commitment.unwrap_or_default();
|
|
|
if commitment.is_confirmed() {
|
|
|
@@ -366,10 +366,10 @@ impl JsonRpcRequestProcessor {
|
|
|
|
|
|
match commitment.commitment {
|
|
|
CommitmentLevel::Processed => {
|
|
|
- debug!("RPC using the heaviest slot: {:?}", slot);
|
|
|
+ debug!("RPC using the heaviest slot: {slot:?}");
|
|
|
}
|
|
|
CommitmentLevel::Finalized => {
|
|
|
- debug!("RPC using block: {:?}", slot);
|
|
|
+ debug!("RPC using block: {slot:?}");
|
|
|
}
|
|
|
CommitmentLevel::Confirmed => unreachable!(), // SingleGossip variant is deprecated
|
|
|
};
|
|
|
@@ -1016,7 +1016,7 @@ impl JsonRpcRequestProcessor {
|
|
|
None => Err(Error::invalid_request()),
|
|
|
},
|
|
|
Err(err) => {
|
|
|
- warn!("slot_meta_iterator failed: {:?}", err);
|
|
|
+ warn!("slot_meta_iterator failed: {err:?}");
|
|
|
Err(Error::invalid_request())
|
|
|
}
|
|
|
}
|
|
|
@@ -1897,7 +1897,7 @@ impl JsonRpcRequestProcessor {
|
|
|
bigtable_before = None;
|
|
|
}
|
|
|
Err(err) => {
|
|
|
- warn!("Failed to query Bigtable: {:?}", err);
|
|
|
+ warn!("Failed to query Bigtable: {err:?}");
|
|
|
return Err(RpcCustomError::LongTermStorageUnreachable.into());
|
|
|
}
|
|
|
Ok(_) => {}
|
|
|
@@ -1929,7 +1929,7 @@ impl JsonRpcRequestProcessor {
|
|
|
}
|
|
|
Err(StorageError::SignatureNotFound) => {}
|
|
|
Err(err) => {
|
|
|
- warn!("Failed to query Bigtable: {:?}", err);
|
|
|
+ warn!("Failed to query Bigtable: {err:?}");
|
|
|
return Err(RpcCustomError::LongTermStorageUnreachable.into());
|
|
|
}
|
|
|
}
|
|
|
@@ -2538,7 +2538,10 @@ fn encode_account<T: ReadableAccount>(
|
|
|
.unwrap_or(account.data().len())
|
|
|
> MAX_BASE58_BYTES
|
|
|
{
|
|
|
- let message = format!("Encoded binary (base 58) data should be less than {MAX_BASE58_BYTES} bytes, please use Base64 encoding.");
|
|
|
+ let message = format!(
|
|
|
+ "Encoded binary (base 58) data should be less than {MAX_BASE58_BYTES} bytes, please \
|
|
|
+ use Base64 encoding."
|
|
|
+ );
|
|
|
Err(error::Error {
|
|
|
code: error::ErrorCode::InvalidRequest,
|
|
|
message,
|
|
|
@@ -2591,8 +2594,7 @@ fn get_spl_token_owner_filter(program_id: &Pubkey, filters: &[RpcFilterType]) ->
|
|
|
{
|
|
|
if let Some(incorrect_owner_len) = incorrect_owner_len {
|
|
|
info!(
|
|
|
- "Incorrect num bytes ({:?}) provided for spl_token_owner_filter",
|
|
|
- incorrect_owner_len
|
|
|
+ "Incorrect num bytes ({incorrect_owner_len:?}) provided for spl_token_owner_filter"
|
|
|
);
|
|
|
}
|
|
|
owner_key
|
|
|
@@ -2642,8 +2644,7 @@ fn get_spl_token_mint_filter(program_id: &Pubkey, filters: &[RpcFilterType]) ->
|
|
|
{
|
|
|
if let Some(incorrect_mint_len) = incorrect_mint_len {
|
|
|
info!(
|
|
|
- "Incorrect num bytes ({:?}) provided for spl_token_mint_filter",
|
|
|
- incorrect_mint_len
|
|
|
+ "Incorrect num bytes ({incorrect_mint_len:?}) provided for spl_token_mint_filter"
|
|
|
);
|
|
|
}
|
|
|
mint
|
|
|
@@ -2703,7 +2704,7 @@ fn _send_transaction(
|
|
|
);
|
|
|
meta.transaction_sender
|
|
|
.send(transaction_info)
|
|
|
- .unwrap_or_else(|err| warn!("Failed to enqueue transaction: {}", err));
|
|
|
+ .unwrap_or_else(|err| warn!("Failed to enqueue transaction: {err}"));
|
|
|
|
|
|
Ok(signature.to_string())
|
|
|
}
|
|
|
@@ -2792,7 +2793,7 @@ pub mod rpc_minimal {
|
|
|
pubkey_str: String,
|
|
|
config: Option<RpcContextConfig>,
|
|
|
) -> Result<RpcResponse<u64>> {
|
|
|
- debug!("get_balance rpc request received: {:?}", pubkey_str);
|
|
|
+ debug!("get_balance rpc request received: {pubkey_str:?}");
|
|
|
let pubkey = verify_pubkey(&pubkey_str)?;
|
|
|
meta.get_balance(&pubkey, config.unwrap_or_default())
|
|
|
}
|
|
|
@@ -2927,7 +2928,7 @@ pub mod rpc_minimal {
|
|
|
let slot = slot.unwrap_or_else(|| bank.slot());
|
|
|
let epoch = bank.epoch_schedule().get_epoch(slot);
|
|
|
|
|
|
- debug!("get_leader_schedule rpc request received: {:?}", slot);
|
|
|
+ debug!("get_leader_schedule rpc request received: {slot:?}");
|
|
|
|
|
|
Ok(meta
|
|
|
.leader_schedule_cache
|
|
|
@@ -3008,10 +3009,7 @@ pub mod rpc_bank {
|
|
|
data_len: usize,
|
|
|
commitment: Option<CommitmentConfig>,
|
|
|
) -> Result<u64> {
|
|
|
- debug!(
|
|
|
- "get_minimum_balance_for_rent_exemption rpc request received: {:?}",
|
|
|
- data_len
|
|
|
- );
|
|
|
+ debug!("get_minimum_balance_for_rent_exemption rpc request received: {data_len:?}");
|
|
|
if data_len as u64 > solana_system_interface::MAX_PERMITTED_DATA_LENGTH {
|
|
|
return Err(Error::invalid_request());
|
|
|
}
|
|
|
@@ -3052,10 +3050,7 @@ pub mod rpc_bank {
|
|
|
start_slot: Slot,
|
|
|
limit: u64,
|
|
|
) -> Result<Vec<String>> {
|
|
|
- debug!(
|
|
|
- "get_slot_leaders rpc request received (start: {} limit: {})",
|
|
|
- start_slot, limit
|
|
|
- );
|
|
|
+ debug!("get_slot_leaders rpc request received (start: {start_slot} limit: {limit})");
|
|
|
|
|
|
let limit = limit as usize;
|
|
|
if limit > MAX_GET_SLOT_LEADERS {
|
|
|
@@ -3223,7 +3218,7 @@ pub mod rpc_accounts {
|
|
|
pubkey_str: String,
|
|
|
config: Option<RpcAccountInfoConfig>,
|
|
|
) -> BoxFuture<Result<RpcResponse<Option<UiAccount>>>> {
|
|
|
- debug!("get_account_info rpc request received: {:?}", pubkey_str);
|
|
|
+ debug!("get_account_info rpc request received: {pubkey_str:?}");
|
|
|
async move {
|
|
|
let pubkey = verify_pubkey(&pubkey_str)?;
|
|
|
meta.get_account_info(pubkey, config).await
|
|
|
@@ -3275,10 +3270,7 @@ pub mod rpc_accounts {
|
|
|
pubkey_str: String,
|
|
|
commitment: Option<CommitmentConfig>,
|
|
|
) -> Result<RpcResponse<UiTokenAmount>> {
|
|
|
- debug!(
|
|
|
- "get_token_account_balance rpc request received: {:?}",
|
|
|
- pubkey_str
|
|
|
- );
|
|
|
+ debug!("get_token_account_balance rpc request received: {pubkey_str:?}");
|
|
|
let pubkey = verify_pubkey(&pubkey_str)?;
|
|
|
meta.get_token_account_balance(&pubkey, commitment)
|
|
|
}
|
|
|
@@ -3289,7 +3281,7 @@ pub mod rpc_accounts {
|
|
|
mint_str: String,
|
|
|
commitment: Option<CommitmentConfig>,
|
|
|
) -> Result<RpcResponse<UiTokenAmount>> {
|
|
|
- debug!("get_token_supply rpc request received: {:?}", mint_str);
|
|
|
+ debug!("get_token_supply rpc request received: {mint_str:?}");
|
|
|
let mint = verify_pubkey(&mint_str)?;
|
|
|
meta.get_token_supply(&mint, commitment)
|
|
|
}
|
|
|
@@ -3368,10 +3360,7 @@ pub mod rpc_accounts_scan {
|
|
|
program_id_str: String,
|
|
|
config: Option<RpcProgramAccountsConfig>,
|
|
|
) -> BoxFuture<Result<OptionalContext<Vec<RpcKeyedAccount>>>> {
|
|
|
- debug!(
|
|
|
- "get_program_accounts rpc request received: {:?}",
|
|
|
- program_id_str
|
|
|
- );
|
|
|
+ debug!("get_program_accounts rpc request received: {program_id_str:?}");
|
|
|
async move {
|
|
|
let program_id = verify_pubkey(&program_id_str)?;
|
|
|
let (config, filters, with_context, sort_results) = if let Some(config) = config {
|
|
|
@@ -3415,10 +3404,7 @@ pub mod rpc_accounts_scan {
|
|
|
mint_str: String,
|
|
|
commitment: Option<CommitmentConfig>,
|
|
|
) -> BoxFuture<Result<RpcResponse<Vec<RpcTokenAccountBalance>>>> {
|
|
|
- debug!(
|
|
|
- "get_token_largest_accounts rpc request received: {:?}",
|
|
|
- mint_str
|
|
|
- );
|
|
|
+ debug!("get_token_largest_accounts rpc request received: {mint_str:?}");
|
|
|
async move {
|
|
|
let mint = verify_pubkey(&mint_str)?;
|
|
|
meta.get_token_largest_accounts(mint, commitment).await
|
|
|
@@ -3433,10 +3419,7 @@ pub mod rpc_accounts_scan {
|
|
|
token_account_filter: RpcTokenAccountsFilter,
|
|
|
config: Option<RpcAccountInfoConfig>,
|
|
|
) -> BoxFuture<Result<RpcResponse<Vec<RpcKeyedAccount>>>> {
|
|
|
- debug!(
|
|
|
- "get_token_accounts_by_owner rpc request received: {:?}",
|
|
|
- owner_str
|
|
|
- );
|
|
|
+ debug!("get_token_accounts_by_owner rpc request received: {owner_str:?}");
|
|
|
async move {
|
|
|
let owner = verify_pubkey(&owner_str)?;
|
|
|
let token_account_filter = verify_token_account_filter(token_account_filter)?;
|
|
|
@@ -3453,10 +3436,7 @@ pub mod rpc_accounts_scan {
|
|
|
token_account_filter: RpcTokenAccountsFilter,
|
|
|
config: Option<RpcAccountInfoConfig>,
|
|
|
) -> BoxFuture<Result<RpcResponse<Vec<RpcKeyedAccount>>>> {
|
|
|
- debug!(
|
|
|
- "get_token_accounts_by_delegate rpc request received: {:?}",
|
|
|
- delegate_str
|
|
|
- );
|
|
|
+ debug!("get_token_accounts_by_delegate rpc request received: {delegate_str:?}");
|
|
|
async move {
|
|
|
let delegate = verify_pubkey(&delegate_str)?;
|
|
|
let token_account_filter = verify_token_account_filter(token_account_filter)?;
|
|
|
@@ -3653,7 +3633,7 @@ pub mod rpc_full {
|
|
|
.blockstore
|
|
|
.get_recent_perf_samples(limit)
|
|
|
.map_err(|err| {
|
|
|
- warn!("get_recent_performance_samples failed: {:?}", err);
|
|
|
+ warn!("get_recent_performance_samples failed: {err:?}");
|
|
|
Error::invalid_request()
|
|
|
})?
|
|
|
.into_iter()
|
|
|
@@ -3794,13 +3774,13 @@ pub mod rpc_full {
|
|
|
let transaction =
|
|
|
request_airdrop_transaction(&faucet_addr, &pubkey, lamports, blockhash).map_err(
|
|
|
|err| {
|
|
|
- info!("request_airdrop_transaction failed: {:?}", err);
|
|
|
+ info!("request_airdrop_transaction failed: {err:?}");
|
|
|
Error::internal_error()
|
|
|
},
|
|
|
)?;
|
|
|
|
|
|
let wire_transaction = serialize(&transaction).map_err(|err| {
|
|
|
- info!("request_airdrop: serialize error: {:?}", err);
|
|
|
+ info!("request_airdrop: serialize error: {err:?}");
|
|
|
Error::internal_error()
|
|
|
})?;
|
|
|
|
|
|
@@ -4096,7 +4076,7 @@ pub mod rpc_full {
|
|
|
slot: Slot,
|
|
|
config: Option<RpcEncodingConfigWrapper<RpcBlockConfig>>,
|
|
|
) -> BoxFuture<Result<Option<UiConfirmedBlock>>> {
|
|
|
- debug!("get_block rpc request received: {:?}", slot);
|
|
|
+ debug!("get_block rpc request received: {slot:?}");
|
|
|
Box::pin(async move { meta.get_block(slot, config).await })
|
|
|
}
|
|
|
|
|
|
@@ -4109,10 +4089,7 @@ pub mod rpc_full {
|
|
|
) -> BoxFuture<Result<Vec<Slot>>> {
|
|
|
let (end_slot, maybe_config) =
|
|
|
wrapper.map(|wrapper| wrapper.unzip()).unwrap_or_default();
|
|
|
- debug!(
|
|
|
- "get_blocks rpc request received: {}-{:?}",
|
|
|
- start_slot, end_slot
|
|
|
- );
|
|
|
+ debug!("get_blocks rpc request received: {start_slot}-{end_slot:?}");
|
|
|
Box::pin(async move {
|
|
|
meta.get_blocks(start_slot, end_slot, config.or(maybe_config))
|
|
|
.await
|
|
|
@@ -4126,10 +4103,7 @@ pub mod rpc_full {
|
|
|
limit: usize,
|
|
|
config: Option<RpcContextConfig>,
|
|
|
) -> BoxFuture<Result<Vec<Slot>>> {
|
|
|
- debug!(
|
|
|
- "get_blocks_with_limit rpc request received: {}-{}",
|
|
|
- start_slot, limit,
|
|
|
- );
|
|
|
+ debug!("get_blocks_with_limit rpc request received: {start_slot}-{limit}",);
|
|
|
Box::pin(async move { meta.get_blocks_with_limit(start_slot, limit, config).await })
|
|
|
}
|
|
|
|
|
|
@@ -4147,7 +4121,7 @@ pub mod rpc_full {
|
|
|
signature_str: String,
|
|
|
config: Option<RpcEncodingConfigWrapper<RpcTransactionConfig>>,
|
|
|
) -> BoxFuture<Result<Option<EncodedConfirmedTransactionWithStatusMeta>>> {
|
|
|
- debug!("get_transaction rpc request received: {:?}", signature_str);
|
|
|
+ debug!("get_transaction rpc request received: {signature_str:?}");
|
|
|
let signature = verify_signature(&signature_str);
|
|
|
if let Err(err) = signature {
|
|
|
return Box::pin(future::err(err));
|
|
|
@@ -4648,7 +4622,8 @@ pub mod tests {
|
|
|
if let Some(account) = bank.get_account(key) {
|
|
|
assert!(
|
|
|
*account.owner() != bpf_loader_upgradeable::id(),
|
|
|
- "LoaderV3 is not supported; to add it, parse the program account and add its programdata size.",
|
|
|
+ "LoaderV3 is not supported; to add it, parse the program account and add its \
|
|
|
+ programdata size.",
|
|
|
);
|
|
|
loaded_accounts_data_size +=
|
|
|
(account.data().len() + TRANSACTION_ACCOUNT_BASE_SIZE) as u32;
|
|
|
@@ -6467,11 +6442,10 @@ pub mod tests {
|
|
|
"id":1,
|
|
|
"method":"simulateTransaction",
|
|
|
"params":[
|
|
|
- "{}",
|
|
|
+ "{tx_serialized_encoded}",
|
|
|
{{ "encoding": "base64" }}
|
|
|
]
|
|
|
}}"#,
|
|
|
- tx_serialized_encoded,
|
|
|
);
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
let expected = json!({
|
|
|
@@ -6511,11 +6485,10 @@ pub mod tests {
|
|
|
"id":1,
|
|
|
"method":"simulateTransaction",
|
|
|
"params":[
|
|
|
- "{}",
|
|
|
+ "{tx_serialized_encoded}",
|
|
|
{{ "innerInstructions": false, "encoding": "base64" }}
|
|
|
]
|
|
|
}}"#,
|
|
|
- tx_serialized_encoded,
|
|
|
);
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
let expected = json!({
|
|
|
@@ -6555,11 +6528,10 @@ pub mod tests {
|
|
|
"id":1,
|
|
|
"method":"simulateTransaction",
|
|
|
"params":[
|
|
|
- "{}",
|
|
|
+ "{tx_serialized_encoded}",
|
|
|
{{ "innerInstructions": true, "encoding": "base64" }}
|
|
|
]
|
|
|
}}"#,
|
|
|
- tx_serialized_encoded,
|
|
|
);
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
let expected = json!({
|
|
|
@@ -7235,9 +7207,9 @@ pub mod tests {
|
|
|
let expected = (
|
|
|
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION,
|
|
|
String::from(
|
|
|
- "Transaction version (0) is not supported by the requesting client. \
|
|
|
- Please try the request again with the following configuration parameter: \
|
|
|
- \"maxSupportedTransactionVersion\": 0",
|
|
|
+ "Transaction version (0) is not supported by the requesting client. Please try \
|
|
|
+ the request again with the following configuration parameter: \
|
|
|
+ \"maxSupportedTransactionVersion\": 0",
|
|
|
),
|
|
|
);
|
|
|
assert_eq!(response, expected);
|
|
|
@@ -7264,7 +7236,8 @@ pub mod tests {
|
|
|
{
|
|
|
assert_eq!(
|
|
|
version, None,
|
|
|
- "requests which don't set max_supported_transaction_version shouldn't receive a version"
|
|
|
+ "requests which don't set max_supported_transaction_version shouldn't receive a \
|
|
|
+ version"
|
|
|
);
|
|
|
if let EncodedTransaction::Json(transaction) = transaction {
|
|
|
if transaction.signatures[0] == confirmed_block_signatures[0].to_string() {
|
|
|
@@ -7308,7 +7281,8 @@ pub mod tests {
|
|
|
{
|
|
|
assert_eq!(
|
|
|
version, None,
|
|
|
- "requests which don't set max_supported_transaction_version shouldn't receive a version"
|
|
|
+ "requests which don't set max_supported_transaction_version shouldn't receive a \
|
|
|
+ version"
|
|
|
);
|
|
|
if let EncodedTransaction::LegacyBinary(transaction) = transaction {
|
|
|
let decoded_transaction: Transaction =
|
|
|
@@ -8938,9 +8912,10 @@ pub mod tests {
|
|
|
decode_and_deserialize::<Transaction>(tx58, TransactionBinaryEncoding::Base58)
|
|
|
.unwrap_err(),
|
|
|
Error::invalid_params(format!(
|
|
|
- "base58 encoded solana_transaction::Transaction too large: {tx58_len} bytes (max: encoded/raw {MAX_BASE58_SIZE}/{PACKET_DATA_SIZE})",
|
|
|
- )
|
|
|
- ));
|
|
|
+ "base58 encoded solana_transaction::Transaction too large: {tx58_len} bytes (max: \
|
|
|
+ encoded/raw {MAX_BASE58_SIZE}/{PACKET_DATA_SIZE})",
|
|
|
+ ))
|
|
|
+ );
|
|
|
|
|
|
let tx64 = BASE64_STANDARD.encode(&tx_ser);
|
|
|
let tx64_len = tx64.len();
|
|
|
@@ -8948,9 +8923,10 @@ pub mod tests {
|
|
|
decode_and_deserialize::<Transaction>(tx64, TransactionBinaryEncoding::Base64)
|
|
|
.unwrap_err(),
|
|
|
Error::invalid_params(format!(
|
|
|
- "base64 encoded solana_transaction::Transaction too large: {tx64_len} bytes (max: encoded/raw {MAX_BASE64_SIZE}/{PACKET_DATA_SIZE})",
|
|
|
- )
|
|
|
- ));
|
|
|
+ "base64 encoded solana_transaction::Transaction too large: {tx64_len} bytes (max: \
|
|
|
+ encoded/raw {MAX_BASE64_SIZE}/{PACKET_DATA_SIZE})",
|
|
|
+ ))
|
|
|
+ );
|
|
|
|
|
|
let too_big = PACKET_DATA_SIZE + 1;
|
|
|
let tx_ser = vec![0x00u8; too_big];
|
|
|
@@ -8959,7 +8935,8 @@ pub mod tests {
|
|
|
decode_and_deserialize::<Transaction>(tx58, TransactionBinaryEncoding::Base58)
|
|
|
.unwrap_err(),
|
|
|
Error::invalid_params(format!(
|
|
|
- "decoded solana_transaction::Transaction too large: {too_big} bytes (max: {PACKET_DATA_SIZE} bytes)"
|
|
|
+ "decoded solana_transaction::Transaction too large: {too_big} bytes (max: \
|
|
|
+ {PACKET_DATA_SIZE} bytes)"
|
|
|
))
|
|
|
);
|
|
|
|
|
|
@@ -8968,7 +8945,8 @@ pub mod tests {
|
|
|
decode_and_deserialize::<Transaction>(tx64, TransactionBinaryEncoding::Base64)
|
|
|
.unwrap_err(),
|
|
|
Error::invalid_params(format!(
|
|
|
- "decoded solana_transaction::Transaction too large: {too_big} bytes (max: {PACKET_DATA_SIZE} bytes)"
|
|
|
+ "decoded solana_transaction::Transaction too large: {too_big} bytes (max: \
|
|
|
+ {PACKET_DATA_SIZE} bytes)"
|
|
|
))
|
|
|
);
|
|
|
|
|
|
@@ -8978,8 +8956,8 @@ pub mod tests {
|
|
|
decode_and_deserialize::<Transaction>(tx64.clone(), TransactionBinaryEncoding::Base64)
|
|
|
.unwrap_err(),
|
|
|
Error::invalid_params(
|
|
|
- "failed to deserialize solana_transaction::Transaction: invalid value: \
|
|
|
- continue signal on byte-three, expected a terminal signal on or before byte-three"
|
|
|
+ "failed to deserialize solana_transaction::Transaction: invalid value: continue \
|
|
|
+ signal on byte-three, expected a terminal signal on or before byte-three"
|
|
|
.to_string()
|
|
|
)
|
|
|
);
|
|
|
@@ -8996,8 +8974,8 @@ pub mod tests {
|
|
|
decode_and_deserialize::<Transaction>(tx58.clone(), TransactionBinaryEncoding::Base58)
|
|
|
.unwrap_err(),
|
|
|
Error::invalid_params(
|
|
|
- "failed to deserialize solana_transaction::Transaction: invalid value: \
|
|
|
- continue signal on byte-three, expected a terminal signal on or before byte-three"
|
|
|
+ "failed to deserialize solana_transaction::Transaction: invalid value: continue \
|
|
|
+ signal on byte-three, expected a terminal signal on or before byte-three"
|
|
|
.to_string()
|
|
|
)
|
|
|
);
|