Deprecate commitment variants (#14797)

* Deprecate commitment variants

* Add new CommitmentConfig builders

* Add helpers to avoid allowing deprecated variants

* Remove deprecated transaction-status code

* Include new commitment variants in runtime commitment; allow deprecated as long as old variants persist

* Remove deprecated banks code

* Remove deprecated variants in core; allow deprecated in rpc/rpc-subscriptions for now

* Heavier hand with rpc/rpc-subscription commitment

* Remove deprecated variants from local-cluster

* Remove deprecated variants from various tools

* Remove deprecated variants from validator

* Update docs

* Remove deprecated client code

* Add new variants to cli; remove deprecated variants as possible

* Don't send new commitment variants to old clusters

* Retain deprecated method in test_validator_saves_tower

* Fix clippy matches! suggestion for BPF solana-sdk legacy compile test

* Refactor node version check to handle commitment variants and transaction encoding

* Hide deprecated variants from cli help

* Add cli App comments
This commit is contained in:
Tyera Eulberg
2021-01-26 12:23:07 -07:00
committed by GitHub
parent e08d2e6fcc
commit ffa5c7dcc8
37 changed files with 540 additions and 322 deletions

View File

@ -437,7 +437,7 @@ impl CliConfig<'_> {
}
fn default_commitment() -> CommitmentConfig {
CommitmentConfig::single_gossip()
CommitmentConfig::confirmed()
}
fn first_nonempty_setting(
@ -532,10 +532,10 @@ impl CliConfig<'_> {
pub fn recent_for_tests() -> Self {
Self {
commitment: CommitmentConfig::recent(),
commitment: CommitmentConfig::processed(),
send_transaction_config: RpcSendTransactionConfig {
skip_preflight: true,
preflight_commitment: Some(CommitmentConfig::recent().commitment),
preflight_commitment: Some(CommitmentConfig::processed().commitment),
..RpcSendTransactionConfig::default()
},
..Self::default()
@ -558,7 +558,7 @@ impl Default for CliConfig<'_> {
rpc_timeout: Duration::from_secs(u64::from_str(DEFAULT_RPC_TIMEOUT_SECONDS).unwrap()),
verbose: false,
output_format: OutputFormat::Display,
commitment: CommitmentConfig::single_gossip(),
commitment: CommitmentConfig::confirmed(),
send_transaction_config: RpcSendTransactionConfig::default(),
address_labels: HashMap::new(),
}

View File

@ -902,7 +902,7 @@ pub fn process_get_block(
let slot = if let Some(slot) = slot {
slot
} else {
rpc_client.get_slot_with_commitment(CommitmentConfig::max())?
rpc_client.get_slot_with_commitment(CommitmentConfig::finalized())?
};
let mut block =
@ -980,7 +980,7 @@ pub fn process_get_block_time(
let slot = if let Some(slot) = slot {
slot
} else {
rpc_client.get_slot_with_commitment(CommitmentConfig::max())?
rpc_client.get_slot_with_commitment(CommitmentConfig::finalized())?
};
let timestamp = rpc_client.get_block_time(slot)?;
let block_time = CliBlockTime { slot, timestamp };
@ -1029,7 +1029,7 @@ pub fn process_show_block_production(
slot_limit: Option<u64>,
) -> ProcessResult {
let epoch_schedule = rpc_client.get_epoch_schedule()?;
let epoch_info = rpc_client.get_epoch_info_with_commitment(CommitmentConfig::max())?;
let epoch_info = rpc_client.get_epoch_info_with_commitment(CommitmentConfig::finalized())?;
let epoch = epoch.unwrap_or(epoch_info.epoch);
if epoch > epoch_info.epoch {
@ -1088,7 +1088,7 @@ pub fn process_show_block_production(
progress_bar.set_message(&format!("Fetching leader schedule for epoch {}...", epoch));
let leader_schedule = rpc_client
.get_leader_schedule_with_commitment(Some(start_slot), CommitmentConfig::root())?;
.get_leader_schedule_with_commitment(Some(start_slot), CommitmentConfig::finalized())?;
if leader_schedule.is_none() {
return Err(format!("Unable to fetch leader schedule for slot {}", start_slot).into());
}

View File

@ -300,10 +300,20 @@ fn main() -> Result<(), Box<dyn error::Error>> {
Arg::with_name("commitment")
.long("commitment")
.takes_value(true)
.possible_values(&["recent", "single", "singleGossip", "root", "max"])
.possible_values(&[
"processed",
"confirmed",
"finalized",
"recent", // Deprecated as of v1.5.5
"single", // Deprecated as of v1.5.5
"singleGossip", // Deprecated as of v1.5.5
"root", // Deprecated as of v1.5.5
"max", // Deprecated as of v1.5.5
])
.value_name("COMMITMENT_LEVEL")
.hide_possible_values(true)
.global(true)
.help("Return information at the selected commitment level"),
.help("Return information at the selected commitment level [possible values: processed, confirmed, finalized]"),
)
.arg(
Arg::with_name("verbose")

View File

@ -5,7 +5,7 @@ use std::{thread::sleep, time::Duration};
pub fn check_recent_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
(0..5).for_each(|tries| {
let balance = client
.get_balance_with_commitment(pubkey, CommitmentConfig::recent())
.get_balance_with_commitment(pubkey, CommitmentConfig::processed())
.unwrap()
.value;
if balance == expected_balance {
@ -20,7 +20,7 @@ pub fn check_recent_balance(expected_balance: u64, client: &RpcClient, pubkey: &
pub fn check_ready(rpc_client: &RpcClient) {
while rpc_client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.unwrap()
< 5
{

View File

@ -64,7 +64,7 @@ fn full_battery_tests(
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let json_rpc_url = test_validator.rpc_url();
let mut config_payer = CliConfig::recent_for_tests();
@ -230,7 +230,7 @@ fn test_create_account_with_seed() {
// Setup accounts
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
request_and_confirm_airdrop(
&rpc_client,
&faucet_addr,
@ -280,7 +280,7 @@ fn test_create_account_with_seed() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_address,
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()

View File

@ -34,7 +34,7 @@ fn test_cli_program_deploy_non_upgradeable() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
@ -155,7 +155,7 @@ fn test_cli_program_deploy_no_authority() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
@ -243,7 +243,7 @@ fn test_cli_program_deploy_with_authority() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
@ -574,7 +574,7 @@ fn test_cli_program_write_buffer() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
@ -829,7 +829,7 @@ fn test_cli_program_set_buffer_authority() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();

View File

@ -32,7 +32,7 @@ fn test_cli_request_airdrop() {
sig_response.unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let balance = rpc_client
.get_balance(&bob_config.signers[0].pubkey())

View File

@ -33,7 +33,7 @@ fn test_stake_delegation_force() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let default_signer = Keypair::new();
let mut config = CliConfig::recent_for_tests();
@ -122,7 +122,7 @@ fn test_seed_stake_delegation_and_deactivation() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let validator_keypair = keypair_from_seed(&[0u8; 32]).unwrap();
let mut config_validator = CliConfig::recent_for_tests();
@ -202,7 +202,7 @@ fn test_stake_delegation_and_deactivation() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let validator_keypair = Keypair::new();
let mut config_validator = CliConfig::recent_for_tests();
@ -278,7 +278,7 @@ fn test_offline_stake_delegation_and_deactivation() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let mut config_validator = CliConfig::recent_for_tests();
config_validator.json_rpc_url = test_validator.rpc_url();
@ -411,7 +411,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let config_keypair = keypair_from_seed(&[0u8; 32]).unwrap();
let mut config = CliConfig::recent_for_tests();
@ -465,7 +465,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -493,7 +493,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -526,7 +526,7 @@ fn test_stake_authorize() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let default_signer = Keypair::new();
let mut config = CliConfig::recent_for_tests();
@ -706,7 +706,7 @@ fn test_stake_authorize() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -756,7 +756,7 @@ fn test_stake_authorize() {
let new_nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -776,7 +776,7 @@ fn test_stake_authorize_with_fee_payer() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let default_signer = Keypair::new();
let default_pubkey = default_signer.pubkey();
@ -898,7 +898,7 @@ fn test_stake_split() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let default_signer = Keypair::new();
let offline_signer = Keypair::new();
@ -975,7 +975,7 @@ fn test_stake_split() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -1042,7 +1042,7 @@ fn test_stake_set_lockup() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let default_signer = Keypair::new();
let offline_signer = Keypair::new();
@ -1227,7 +1227,7 @@ fn test_stake_set_lockup() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -1294,7 +1294,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let mut config = CliConfig::recent_for_tests();
let default_signer = keypair_from_seed(&[1u8; 32]).unwrap();
config.signers = vec![&default_signer];
@ -1342,7 +1342,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -1397,7 +1397,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -1445,7 +1445,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()

View File

@ -30,7 +30,7 @@ fn test_transfer() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let default_signer = Keypair::new();
let default_offline_signer = Keypair::new();
@ -145,7 +145,7 @@ fn test_transfer() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -173,7 +173,7 @@ fn test_transfer() {
let new_nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -194,7 +194,7 @@ fn test_transfer() {
let nonce_hash = nonce_utils::get_account_with_commitment(
&rpc_client,
&nonce_account.pubkey(),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.and_then(|ref a| nonce_utils::data_from_account(a))
.unwrap()
@ -255,7 +255,7 @@ fn test_transfer_multisession_signing() {
// Setup accounts
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
request_and_confirm_airdrop(
&rpc_client,
&faucet_addr,
@ -365,7 +365,7 @@ fn test_transfer_all() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let default_signer = Keypair::new();

View File

@ -26,7 +26,7 @@ fn test_vote_authorize_and_withdraw() {
let faucet_addr = receiver.recv().unwrap();
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::recent());
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let default_signer = Keypair::new();
let mut config = CliConfig::recent_for_tests();