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

@@ -49,11 +49,14 @@ pub fn spend_and_verify_all_nodes<S: ::std::hash::BuildHasher>(
let random_keypair = Keypair::new();
let client = create_client(ingress_node.client_facing_addr(), VALIDATOR_PORT_RANGE);
let bal = client
.poll_get_balance_with_commitment(&funding_keypair.pubkey(), CommitmentConfig::recent())
.poll_get_balance_with_commitment(
&funding_keypair.pubkey(),
CommitmentConfig::processed(),
)
.expect("balance in source");
assert!(bal > 0);
let (blockhash, _fee_calculator, _last_valid_slot) = client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap();
let mut transaction =
system_transaction::transfer(&funding_keypair, &random_keypair.pubkey(), 1, blockhash);
@@ -78,7 +81,7 @@ pub fn verify_balances<S: ::std::hash::BuildHasher>(
let client = create_client(node.client_facing_addr(), VALIDATOR_PORT_RANGE);
for (pk, b) in expected_balances {
let bal = client
.poll_get_balance_with_commitment(&pk, CommitmentConfig::recent())
.poll_get_balance_with_commitment(&pk, CommitmentConfig::processed())
.expect("balance in source");
assert_eq!(bal, b);
}
@@ -95,11 +98,14 @@ pub fn send_many_transactions(
for _ in 0..num_txs {
let random_keypair = Keypair::new();
let bal = client
.poll_get_balance_with_commitment(&funding_keypair.pubkey(), CommitmentConfig::recent())
.poll_get_balance_with_commitment(
&funding_keypair.pubkey(),
CommitmentConfig::processed(),
)
.expect("balance in source");
assert!(bal > 0);
let (blockhash, _fee_calculator, _last_valid_slot) = client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap();
let transfer_amount = thread_rng().gen_range(1, max_tokens_per_transfer);
@@ -195,7 +201,7 @@ pub fn kill_entry_and_spend_and_verify_rest(
for ingress_node in &cluster_nodes {
client
.poll_get_balance_with_commitment(&ingress_node.id, CommitmentConfig::recent())
.poll_get_balance_with_commitment(&ingress_node.id, CommitmentConfig::processed())
.unwrap_or_else(|err| panic!("Node {} has no balance: {}", ingress_node.id, err));
}
@@ -219,7 +225,10 @@ pub fn kill_entry_and_spend_and_verify_rest(
let client = create_client(ingress_node.client_facing_addr(), VALIDATOR_PORT_RANGE);
let balance = client
.poll_get_balance_with_commitment(&funding_keypair.pubkey(), CommitmentConfig::recent())
.poll_get_balance_with_commitment(
&funding_keypair.pubkey(),
CommitmentConfig::processed(),
)
.expect("balance in source");
assert_ne!(balance, 0);
@@ -233,7 +242,7 @@ pub fn kill_entry_and_spend_and_verify_rest(
let random_keypair = Keypair::new();
let (blockhash, _fee_calculator, _last_valid_slot) = client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap();
let mut transaction = system_transaction::transfer(
&funding_keypair,
@@ -311,7 +320,7 @@ pub fn check_no_new_roots(
.unwrap_or_else(|_| panic!("get_slot for {} failed", ingress_node.id));
roots[i] = initial_root;
client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.unwrap_or_else(|_| panic!("get_slot for {} failed", ingress_node.id))
})
.max()
@@ -325,7 +334,7 @@ pub fn check_no_new_roots(
for contact_info in contact_infos {
let client = create_client(contact_info.client_facing_addr(), VALIDATOR_PORT_RANGE);
current_slot = client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.unwrap_or_else(|_| panic!("get_slot for {} failed", contact_infos[0].id));
if current_slot > end_slot {
reached_end_slot = true;

View File

@@ -435,7 +435,7 @@ impl LocalCluster {
) -> u64 {
trace!("getting leader blockhash");
let (blockhash, _fee_calculator, _last_valid_slot) = client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap();
let mut tx =
system_transaction::transfer(&source_keypair, dest_pubkey, lamports, blockhash);
@@ -452,7 +452,7 @@ impl LocalCluster {
.wait_for_balance_with_commitment(
dest_pubkey,
Some(lamports),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.expect("get balance")
}
@@ -474,7 +474,7 @@ impl LocalCluster {
// Create the vote account if necessary
if client
.poll_get_balance_with_commitment(&vote_account_pubkey, CommitmentConfig::recent())
.poll_get_balance_with_commitment(&vote_account_pubkey, CommitmentConfig::processed())
.unwrap_or(0)
== 0
{
@@ -496,7 +496,7 @@ impl LocalCluster {
&[from_account.as_ref(), vote_account],
message,
client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap()
.0,
);
@@ -507,7 +507,7 @@ impl LocalCluster {
.wait_for_balance_with_commitment(
&vote_account_pubkey,
Some(amount),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.expect("get balance");
@@ -524,7 +524,7 @@ impl LocalCluster {
&[from_account.as_ref(), &stake_account_keypair],
message,
client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap()
.0,
);
@@ -541,7 +541,7 @@ impl LocalCluster {
.wait_for_balance_with_commitment(
&stake_account_pubkey,
Some(amount),
CommitmentConfig::recent(),
CommitmentConfig::processed(),
)
.expect("get balance");
} else {
@@ -552,8 +552,9 @@ impl LocalCluster {
}
info!("Checking for vote account registration of {}", node_pubkey);
match (
client.get_account_with_commitment(&stake_account_pubkey, CommitmentConfig::recent()),
client.get_account_with_commitment(&vote_account_pubkey, CommitmentConfig::recent()),
client
.get_account_with_commitment(&stake_account_pubkey, CommitmentConfig::processed()),
client.get_account_with_commitment(&vote_account_pubkey, CommitmentConfig::processed()),
) {
(Ok(Some(stake_account)), Ok(Some(vote_account))) => {
match (

View File

@@ -168,7 +168,7 @@ fn test_local_cluster_signature_subscribe() {
VALIDATOR_PORT_RANGE,
);
let (blockhash, _fee_calculator, _last_valid_slot) = tx_client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap();
let mut transaction = system_transaction::transfer(
@@ -182,7 +182,7 @@ fn test_local_cluster_signature_subscribe() {
&format!("ws://{}", &non_bootstrap_info.rpc_pubsub.to_string()),
&transaction.signatures[0],
Some(RpcSignatureSubscribeConfig {
commitment: Some(CommitmentConfig::recent()),
commitment: Some(CommitmentConfig::processed()),
enable_received_notification: Some(true),
}),
)
@@ -791,7 +791,7 @@ fn test_mainnet_beta_cluster_type() {
(
program_id,
client
.get_account_with_commitment(program_id, CommitmentConfig::recent())
.get_account_with_commitment(program_id, CommitmentConfig::processed())
.unwrap()
),
(_program_id, Some(_))
@@ -809,7 +809,7 @@ fn test_mainnet_beta_cluster_type() {
(
program_id,
client
.get_account_with_commitment(program_id, CommitmentConfig::recent())
.get_account_with_commitment(program_id, CommitmentConfig::processed())
.unwrap()
),
(program_id, None)
@@ -826,7 +826,7 @@ fn generate_frozen_account_panic(mut cluster: LocalCluster, frozen_account: Arc<
trace!(
"validator slot: {}",
client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.expect("get slot")
);
@@ -838,7 +838,7 @@ fn generate_frozen_account_panic(mut cluster: LocalCluster, frozen_account: Arc<
while !solana_runtime::accounts_db::FROZEN_ACCOUNT_PANIC.load(Ordering::Relaxed) {
// Transfer from frozen account
let (blockhash, _fee_calculator, _last_valid_slot) = client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap();
client
.async_transfer(
@@ -1222,7 +1222,7 @@ fn test_snapshots_blockstore_floor() {
let target_slot = slot_floor + 40;
while current_slot <= target_slot {
trace!("current_slot: {}", current_slot);
if let Ok(slot) = validator_client.get_slot_with_commitment(CommitmentConfig::recent()) {
if let Ok(slot) = validator_client.get_slot_with_commitment(CommitmentConfig::processed()) {
current_slot = slot;
} else {
continue;
@@ -1402,7 +1402,7 @@ fn test_no_voting() {
.unwrap();
loop {
let last_slot = client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.expect("Couldn't get slot");
if last_slot > 4 * VOTE_THRESHOLD_DEPTH as u64 {
break;
@@ -1460,7 +1460,7 @@ fn test_optimistic_confirmation_violation_detection() {
let mut prev_voted_slot = 0;
loop {
let last_voted_slot = client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.unwrap();
if last_voted_slot > 50 {
if prev_voted_slot == 0 {
@@ -1498,7 +1498,7 @@ fn test_optimistic_confirmation_violation_detection() {
let client = cluster.get_validator_client(&entry_point_id).unwrap();
loop {
let last_root = client
.get_slot_with_commitment(CommitmentConfig::max())
.get_slot_with_commitment(CommitmentConfig::finalized())
.unwrap();
if last_root > prev_voted_slot {
break;
@@ -1561,7 +1561,7 @@ fn test_validator_saves_tower() {
// Wait for some votes to be generated
let mut last_replayed_root;
loop {
if let Ok(slot) = validator_client.get_slot_with_commitment(CommitmentConfig::recent()) {
if let Ok(slot) = validator_client.get_slot_with_commitment(CommitmentConfig::processed()) {
trace!("current slot: {}", slot);
if slot > 2 {
// this will be the root next time a validator starts
@@ -1584,6 +1584,9 @@ fn test_validator_saves_tower() {
// Wait for the first root
loop {
#[allow(deprecated)]
// This test depends on knowing the immediate root, without any delay from the commitment
// service, so the deprecated CommitmentConfig::root() is retained
if let Ok(root) = validator_client.get_slot_with_commitment(CommitmentConfig::root()) {
trace!("current root: {}", root);
if root > last_replayed_root + 1 {
@@ -1596,7 +1599,7 @@ fn test_validator_saves_tower() {
// Stop validator, and check saved tower
let recent_slot = validator_client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.unwrap();
let validator_info = cluster.exit_node(&validator_id);
let tower2 = Tower::restore(&ledger_path, &validator_id).unwrap();
@@ -1613,6 +1616,9 @@ fn test_validator_saves_tower() {
// Wait for a new root, demonstrating the validator was able to make progress from the older `tower1`
loop {
#[allow(deprecated)]
// This test depends on knowing the immediate root, without any delay from the commitment
// service, so the deprecated CommitmentConfig::root() is retained
if let Ok(root) = validator_client.get_slot_with_commitment(CommitmentConfig::root()) {
trace!(
"current root: {}, last_replayed_root: {}",
@@ -1642,10 +1648,10 @@ fn test_validator_saves_tower() {
// Wait for a couple more slots to pass so another vote occurs
let current_slot = validator_client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.unwrap();
loop {
if let Ok(slot) = validator_client.get_slot_with_commitment(CommitmentConfig::recent()) {
if let Ok(slot) = validator_client.get_slot_with_commitment(CommitmentConfig::processed()) {
trace!("current_slot: {}, slot: {}", current_slot, slot);
if slot > current_slot + 1 {
break;
@@ -2157,13 +2163,13 @@ fn test_optimistic_confirmation_violation_without_tower() {
#[test]
#[serial]
fn test_run_test_load_program_accounts_root() {
run_test_load_program_accounts(CommitmentConfig::root());
run_test_load_program_accounts(CommitmentConfig::finalized());
}
#[test]
#[serial]
fn test_run_test_load_program_accounts_partition_root() {
run_test_load_program_accounts_partition(CommitmentConfig::root());
run_test_load_program_accounts_partition(CommitmentConfig::finalized());
}
fn run_test_load_program_accounts_partition(scan_commitment: CommitmentConfig) {
@@ -2245,7 +2251,7 @@ fn setup_transfer_scan_threads(
return;
}
let (blockhash, _fee_calculator, _last_valid_slot) = client
.get_recent_blockhash_with_commitment(CommitmentConfig::recent())
.get_recent_blockhash_with_commitment(CommitmentConfig::processed())
.unwrap();
for i in 0..starting_keypairs_.len() {
client
@@ -2388,7 +2394,7 @@ fn wait_for_next_snapshot(
.get_validator_client(&cluster.entry_point_info.id)
.unwrap();
let last_slot = client
.get_slot_with_commitment(CommitmentConfig::recent())
.get_slot_with_commitment(CommitmentConfig::processed())
.expect("Couldn't get slot");
// Wait for a snapshot for a bank >= last_slot to be made so we know that the snapshot