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:
@ -139,16 +139,14 @@ pub struct JsonRpcRequestProcessor {
|
||||
impl Metadata for JsonRpcRequestProcessor {}
|
||||
|
||||
impl JsonRpcRequestProcessor {
|
||||
#[allow(deprecated)]
|
||||
fn bank(&self, commitment: Option<CommitmentConfig>) -> Arc<Bank> {
|
||||
debug!("RPC commitment_config: {:?}", commitment);
|
||||
let r_bank_forks = self.bank_forks.read().unwrap();
|
||||
|
||||
let commitment_level = match commitment {
|
||||
None => CommitmentLevel::Max,
|
||||
Some(config) => config.commitment,
|
||||
};
|
||||
let commitment = commitment.unwrap_or_default();
|
||||
|
||||
if commitment_level == CommitmentLevel::SingleGossip {
|
||||
if commitment.is_confirmed() {
|
||||
let bank = self
|
||||
.optimistically_confirmed_bank
|
||||
.read()
|
||||
@ -163,22 +161,26 @@ impl JsonRpcRequestProcessor {
|
||||
.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.slot_with_commitment(commitment_level);
|
||||
.slot_with_commitment(commitment.commitment);
|
||||
|
||||
match commitment_level {
|
||||
CommitmentLevel::Recent => {
|
||||
match commitment.commitment {
|
||||
// Recent variant is deprecated
|
||||
CommitmentLevel::Recent | CommitmentLevel::Processed => {
|
||||
debug!("RPC using the heaviest slot: {:?}", slot);
|
||||
}
|
||||
// Root variant is deprecated
|
||||
CommitmentLevel::Root => {
|
||||
debug!("RPC using node root: {:?}", slot);
|
||||
}
|
||||
// Single variant is deprecated
|
||||
CommitmentLevel::Single => {
|
||||
debug!("RPC using confirmed slot: {:?}", slot);
|
||||
}
|
||||
CommitmentLevel::Max => {
|
||||
// Max variant is deprecated
|
||||
CommitmentLevel::Max | CommitmentLevel::Finalized => {
|
||||
debug!("RPC using block: {:?}", slot);
|
||||
}
|
||||
CommitmentLevel::SingleGossip => unreachable!(),
|
||||
CommitmentLevel::SingleGossip | CommitmentLevel::Confirmed => unreachable!(), // SingleGossip variant is deprecated
|
||||
};
|
||||
|
||||
r_bank_forks.get(slot).cloned().unwrap_or_else(|| {
|
||||
@ -195,7 +197,7 @@ impl JsonRpcRequestProcessor {
|
||||
// For more information, see https://github.com/solana-labs/solana/issues/11078
|
||||
warn!(
|
||||
"Bank with {:?} not found at slot: {:?}",
|
||||
commitment_level, slot
|
||||
commitment.commitment, slot
|
||||
);
|
||||
r_bank_forks.root_bank()
|
||||
})
|
||||
@ -380,7 +382,7 @@ impl JsonRpcRequestProcessor {
|
||||
pub fn get_epoch_schedule(&self) -> EpochSchedule {
|
||||
// Since epoch schedule data comes from the genesis config, any commitment level should be
|
||||
// fine
|
||||
let bank = self.bank(Some(CommitmentConfig::root()));
|
||||
let bank = self.bank(Some(CommitmentConfig::finalized()));
|
||||
*bank.epoch_schedule()
|
||||
}
|
||||
|
||||
@ -873,7 +875,7 @@ impl JsonRpcRequestProcessor {
|
||||
let search_transaction_history = config
|
||||
.map(|x| x.search_transaction_history)
|
||||
.unwrap_or(false);
|
||||
let bank = self.bank(Some(CommitmentConfig::recent()));
|
||||
let bank = self.bank(Some(CommitmentConfig::processed()));
|
||||
|
||||
for signature in signatures {
|
||||
let status = if let Some(status) = self.get_transaction_status(signature, &bank) {
|
||||
@ -925,7 +927,7 @@ impl JsonRpcRequestProcessor {
|
||||
let (slot, status) = bank.get_signature_status_slot(&signature)?;
|
||||
let r_block_commitment_cache = self.block_commitment_cache.read().unwrap();
|
||||
|
||||
let optimistically_confirmed_bank = self.bank(Some(CommitmentConfig::single_gossip()));
|
||||
let optimistically_confirmed_bank = self.bank(Some(CommitmentConfig::confirmed()));
|
||||
let optimistically_confirmed =
|
||||
optimistically_confirmed_bank.get_signature_status_slot(&signature);
|
||||
|
||||
@ -5376,7 +5378,7 @@ pub mod tests {
|
||||
|
||||
let req = format!(
|
||||
r#"{{"jsonrpc":"2.0","id":1,"method":"getVoteAccounts","params":{}}}"#,
|
||||
json!([CommitmentConfig::recent()])
|
||||
json!([CommitmentConfig::processed()])
|
||||
);
|
||||
|
||||
let res = io.handle_request_sync(&req, meta.clone());
|
||||
@ -5422,7 +5424,7 @@ pub mod tests {
|
||||
{
|
||||
let req = format!(
|
||||
r#"{{"jsonrpc":"2.0","id":1,"method":"getVoteAccounts","params":{}}}"#,
|
||||
json!([CommitmentConfig::recent()])
|
||||
json!([CommitmentConfig::processed()])
|
||||
);
|
||||
|
||||
let res = io.handle_request_sync(&req, meta);
|
||||
@ -6110,7 +6112,8 @@ pub mod tests {
|
||||
let mut io = MetaIoHandler::default();
|
||||
io.extend_with(RpcSolImpl.to_delegate());
|
||||
|
||||
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment":"singleGossip"}]}"#;
|
||||
let req =
|
||||
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment":"confirmed"}]}"#;
|
||||
let res = io.handle_request_sync(req, meta.clone());
|
||||
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
||||
@ -6123,7 +6126,8 @@ pub mod tests {
|
||||
&subscriptions,
|
||||
&mut pending_optimistically_confirmed_banks,
|
||||
);
|
||||
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "singleGossip"}]}"#;
|
||||
let req =
|
||||
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "confirmed"}]}"#;
|
||||
let res = io.handle_request_sync(&req, meta.clone());
|
||||
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
||||
@ -6137,7 +6141,8 @@ pub mod tests {
|
||||
&subscriptions,
|
||||
&mut pending_optimistically_confirmed_banks,
|
||||
);
|
||||
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "singleGossip"}]}"#;
|
||||
let req =
|
||||
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "confirmed"}]}"#;
|
||||
let res = io.handle_request_sync(&req, meta.clone());
|
||||
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
||||
@ -6151,7 +6156,8 @@ pub mod tests {
|
||||
&subscriptions,
|
||||
&mut pending_optimistically_confirmed_banks,
|
||||
);
|
||||
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "singleGossip"}]}"#;
|
||||
let req =
|
||||
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "confirmed"}]}"#;
|
||||
let res = io.handle_request_sync(&req, meta.clone());
|
||||
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
||||
@ -6166,7 +6172,8 @@ pub mod tests {
|
||||
&subscriptions,
|
||||
&mut pending_optimistically_confirmed_banks,
|
||||
);
|
||||
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "singleGossip"}]}"#;
|
||||
let req =
|
||||
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "confirmed"}]}"#;
|
||||
let res = io.handle_request_sync(&req, meta);
|
||||
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
||||
|
Reference in New Issue
Block a user