Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0: Remove deprecated RpcClient methods (backport of #1899) #1922

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Release channels have their own copy of this changelog:
getConfirmedTransaction, getConfirmedSignaturesForAddress2, getRecentBlockhash, getFees,
getFeeCalculatorForBlockhash, getFeeRateGovernor, getSnapshotSlot
* `--enable-rpc-obsolete_v1_7` flag removed
* Deprecated methods are removed from `RpcClient` and `RpcClient::nonblocking`
* Changes
* `central-scheduler` as default option for `--block-production-method` (#34891)
* `solana-rpc-client-api`: `RpcFilterError` depends on `base64` version 0.22, so users may need to upgrade to `base64` version 0.22
Expand Down
10 changes: 0 additions & 10 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ pub enum CliCommand {
ClusterVersion,
Feature(FeatureCliCommand),
Inflation(InflationCliCommand),
Fees {
blockhash: Option<Hash>,
},
FindProgramDerivedAddress {
seeds: Vec<Vec<u8>>,
program_id: Pubkey,
Expand Down Expand Up @@ -640,12 +637,6 @@ pub fn parse_command(
("feature", Some(matches)) => {
parse_feature_subcommand(matches, default_signer, wallet_manager)
}
("fees", Some(matches)) => {
let blockhash = value_of::<Hash>(matches, "blockhash");
Ok(CliCommandInfo::without_signers(CliCommand::Fees {
blockhash,
}))
}
("first-available-block", Some(_matches)) => Ok(CliCommandInfo::without_signers(
CliCommand::FirstAvailableBlock,
)),
Expand Down Expand Up @@ -911,7 +902,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
seed,
program_id,
} => process_create_address_with_seed(config, from_pubkey.as_ref(), seed, program_id),
CliCommand::Fees { ref blockhash } => process_fees(&rpc_client, config, blockhash.as_ref()),
CliCommand::Feature(feature_subcommand) => {
process_feature_subcommand(&rpc_client, config, feature_subcommand)
}
Expand Down
69 changes: 0 additions & 69 deletions cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,6 @@ impl ClusterQuerySubCommands for App<'_, '_> {
SubCommand::with_name("cluster-version")
.about("Get the version of the cluster entrypoint"),
)
// Deprecated in v1.8.0
.subcommand(
SubCommand::with_name("fees")
.about("Display current cluster fees (Deprecated in v1.8.0)")
.arg(
Arg::with_name("blockhash")
.long("blockhash")
.takes_value(true)
.value_name("BLOCKHASH")
.validator(is_hash)
.help("Query fees for BLOCKHASH instead of the most recent blockhash"),
),
)
.subcommand(
SubCommand::with_name("first-available-block")
.about("Get the first available block in the storage"),
Expand Down Expand Up @@ -982,42 +969,6 @@ pub fn process_cluster_version(rpc_client: &RpcClient, config: &CliConfig) -> Pr
}
}

pub fn process_fees(
rpc_client: &RpcClient,
config: &CliConfig,
blockhash: Option<&Hash>,
) -> ProcessResult {
let fees = if let Some(recent_blockhash) = blockhash {
#[allow(deprecated)]
let result = rpc_client.get_fee_calculator_for_blockhash_with_commitment(
recent_blockhash,
config.commitment,
)?;
if let Some(fee_calculator) = result.value {
CliFees::some(
result.context.slot,
*recent_blockhash,
fee_calculator.lamports_per_signature,
None,
None,
)
} else {
CliFees::none()
}
} else {
#[allow(deprecated)]
let result = rpc_client.get_fees_with_commitment(config.commitment)?;
CliFees::some(
result.context.slot,
result.value.blockhash,
result.value.fee_calculator.lamports_per_signature,
None,
Some(result.value.last_valid_block_height),
)
};
Ok(config.output_format.formatted_string(&fees))
}

pub fn process_first_available_block(rpc_client: &RpcClient) -> ProcessResult {
let first_available_block = rpc_client.get_first_available_block()?;
Ok(format!("{first_available_block}"))
Expand Down Expand Up @@ -2373,26 +2324,6 @@ mod tests {
CliCommandInfo::without_signers(CliCommand::ClusterVersion)
);

let test_fees = test_commands.clone().get_matches_from(vec!["test", "fees"]);
assert_eq!(
parse_command(&test_fees, &default_signer, &mut None).unwrap(),
CliCommandInfo::without_signers(CliCommand::Fees { blockhash: None })
);

let blockhash = Hash::new_unique();
let test_fees = test_commands.clone().get_matches_from(vec![
"test",
"fees",
"--blockhash",
&blockhash.to_string(),
]);
assert_eq!(
parse_command(&test_fees, &default_signer, &mut None).unwrap(),
CliCommandInfo::without_signers(CliCommand::Fees {
blockhash: Some(blockhash)
})
);

let slot = 100;
let test_get_block_time =
test_commands
Expand Down
76 changes: 4 additions & 72 deletions rpc-client-api/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use {

#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum RpcRequest {
Custom {
method: &'static str,
},
Custom { method: &'static str },
DeregisterNode,
GetAccountInfo,
GetBalance,
Expand All @@ -21,43 +19,9 @@ pub enum RpcRequest {
GetBlocksWithLimit,
GetBlockTime,
GetClusterNodes,
#[deprecated(since = "1.7.0", note = "Please use RpcRequest::GetBlock instead")]
GetConfirmedBlock,
#[deprecated(since = "1.7.0", note = "Please use RpcRequest::GetBlocks instead")]
GetConfirmedBlocks,
#[deprecated(
since = "1.7.0",
note = "Please use RpcRequest::GetBlocksWithLimit instead"
)]
GetConfirmedBlocksWithLimit,
#[deprecated(
since = "1.7.0",
note = "Please use RpcRequest::GetSignaturesForAddress instead"
)]
GetConfirmedSignaturesForAddress2,
#[deprecated(
since = "1.7.0",
note = "Please use RpcRequest::GetTransaction instead"
)]
GetConfirmedTransaction,
GetEpochInfo,
GetEpochSchedule,
#[deprecated(
since = "1.9.0",
note = "Please use RpcRequest::GetFeeForMessage instead"
)]
GetFeeCalculatorForBlockhash,
GetFeeForMessage,
#[deprecated(
since = "1.9.0",
note = "Please do not use, will no longer be available in the future"
)]
GetFeeRateGovernor,
#[deprecated(
since = "1.9.0",
note = "Please use RpcRequest::GetFeeForMessage instead"
)]
GetFees,
GetFirstAvailableBlock,
GetGenesisHash,
GetHealth,
Expand All @@ -73,19 +37,9 @@ pub enum RpcRequest {
GetMinimumBalanceForRentExemption,
GetMultipleAccounts,
GetProgramAccounts,
#[deprecated(
since = "1.9.0",
note = "Please use RpcRequest::GetLatestBlockhash instead"
)]
GetRecentBlockhash,
GetRecentPerformanceSamples,
GetRecentPrioritizationFees,
GetHighestSnapshotSlot,
#[deprecated(
since = "1.9.0",
note = "Please use RpcRequest::GetHighestSnapshotSlot instead"
)]
GetSnapshotSlot,
GetSignaturesForAddress,
GetSignatureStatuses,
GetSlot,
Expand Down Expand Up @@ -131,17 +85,9 @@ impl fmt::Display for RpcRequest {
RpcRequest::GetBlocksWithLimit => "getBlocksWithLimit",
RpcRequest::GetBlockTime => "getBlockTime",
RpcRequest::GetClusterNodes => "getClusterNodes",
RpcRequest::GetConfirmedBlock => "getConfirmedBlock",
RpcRequest::GetConfirmedBlocks => "getConfirmedBlocks",
RpcRequest::GetConfirmedBlocksWithLimit => "getConfirmedBlocksWithLimit",
RpcRequest::GetConfirmedSignaturesForAddress2 => "getConfirmedSignaturesForAddress2",
RpcRequest::GetConfirmedTransaction => "getConfirmedTransaction",
RpcRequest::GetEpochInfo => "getEpochInfo",
RpcRequest::GetEpochSchedule => "getEpochSchedule",
RpcRequest::GetFeeCalculatorForBlockhash => "getFeeCalculatorForBlockhash",
RpcRequest::GetFeeForMessage => "getFeeForMessage",
RpcRequest::GetFeeRateGovernor => "getFeeRateGovernor",
RpcRequest::GetFees => "getFees",
RpcRequest::GetFirstAvailableBlock => "getFirstAvailableBlock",
RpcRequest::GetGenesisHash => "getGenesisHash",
RpcRequest::GetHealth => "getHealth",
Expand All @@ -157,11 +103,9 @@ impl fmt::Display for RpcRequest {
RpcRequest::GetMinimumBalanceForRentExemption => "getMinimumBalanceForRentExemption",
RpcRequest::GetMultipleAccounts => "getMultipleAccounts",
RpcRequest::GetProgramAccounts => "getProgramAccounts",
RpcRequest::GetRecentBlockhash => "getRecentBlockhash",
RpcRequest::GetRecentPerformanceSamples => "getRecentPerformanceSamples",
RpcRequest::GetRecentPrioritizationFees => "getRecentPrioritizationFees",
RpcRequest::GetHighestSnapshotSlot => "getHighestSnapshotSlot",
RpcRequest::GetSnapshotSlot => "getSnapshotSlot",
RpcRequest::GetSignaturesForAddress => "getSignaturesForAddress",
RpcRequest::GetSignatureStatuses => "getSignatureStatuses",
RpcRequest::GetSlot => "getSlot",
Expand Down Expand Up @@ -303,20 +247,9 @@ mod tests {
let request = test_request.build_request_json(1, Value::Null);
assert_eq!(request["method"], "getEpochInfo");

#[allow(deprecated)]
let test_request = RpcRequest::GetRecentBlockhash;
let request = test_request.build_request_json(1, Value::Null);
assert_eq!(request["method"], "getRecentBlockhash");

#[allow(deprecated)]
let test_request = RpcRequest::GetFeeCalculatorForBlockhash;
let request = test_request.build_request_json(1, json!([addr]));
assert_eq!(request["method"], "getFeeCalculatorForBlockhash");

#[allow(deprecated)]
let test_request = RpcRequest::GetFeeRateGovernor;
let test_request = RpcRequest::GetLatestBlockhash;
let request = test_request.build_request_json(1, Value::Null);
assert_eq!(request["method"], "getFeeRateGovernor");
assert_eq!(request["method"], "getLatestBlockhash");

let test_request = RpcRequest::GetSlot;
let request = test_request.build_request_json(1, Value::Null);
Expand Down Expand Up @@ -347,8 +280,7 @@ mod tests {
let addr = json!("deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx");

// Test request with CommitmentConfig and no params
#[allow(deprecated)]
let test_request = RpcRequest::GetRecentBlockhash;
let test_request = RpcRequest::GetLatestBlockhash;
let request = test_request.build_request_json(1, json!([commitment_config]));
assert_eq!(request["params"], json!([commitment_config.clone()]));

Expand Down
Loading