Deprecate commitment variants (bp #14797) (#14858)

* 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

(cherry picked from commit ffa5c7dcc8)

* Fix 1.5 stake-o-matic

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2021-01-26 20:49:04 +00:00
committed by GitHub
parent d380b9cef7
commit 3c67f71695
37 changed files with 541 additions and 323 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

@@ -299,10 +299,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
{