Simplify BlockCommitmentCache slot info (#11106)

* Refactor BlockCommitmentCache, store a CacheSlotInfo

* Comma
This commit is contained in:
Tyera Eulberg
2020-07-17 09:24:51 -06:00
committed by GitHub
parent 25728baeac
commit fdff681bcc
5 changed files with 170 additions and 101 deletions

View File

@ -1,12 +1,9 @@
use crate::{ use crate::{consensus::Stake, rpc_subscriptions::RpcSubscriptions};
consensus::Stake,
rpc_subscriptions::{CacheSlotInfo, RpcSubscriptions},
};
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::datapoint_info; use solana_metrics::datapoint_info;
use solana_runtime::{ use solana_runtime::{
bank::Bank, bank::Bank,
commitment::{BlockCommitment, BlockCommitmentCache, VOTE_THRESHOLD_SIZE}, commitment::{BlockCommitment, BlockCommitmentCache, CacheSlotInfo, VOTE_THRESHOLD_SIZE},
}; };
use solana_sdk::clock::Slot; use solana_sdk::clock::Slot;
use solana_vote_program::vote_state::VoteState; use solana_vote_program::vote_state::VoteState;
@ -114,14 +111,16 @@ impl AggregateCommitmentService {
let mut new_block_commitment = BlockCommitmentCache::new( let mut new_block_commitment = BlockCommitmentCache::new(
block_commitment, block_commitment,
highest_confirmed_root,
aggregation_data.total_stake, aggregation_data.total_stake,
aggregation_data.bank.slot(), CacheSlotInfo {
aggregation_data.root, slot: aggregation_data.bank.slot(),
aggregation_data.root, root: aggregation_data.root,
highest_confirmed_slot: aggregation_data.root,
highest_confirmed_root,
},
); );
new_block_commitment.highest_confirmed_slot = let highest_confirmed_slot = new_block_commitment.calculate_highest_confirmed_slot();
new_block_commitment.calculate_highest_confirmed_slot(); new_block_commitment.set_highest_confirmed_slot(highest_confirmed_slot);
let mut w_block_commitment_cache = block_commitment_cache.write().unwrap(); let mut w_block_commitment_cache = block_commitment_cache.write().unwrap();
@ -136,12 +135,10 @@ impl AggregateCommitmentService {
) )
); );
subscriptions.notify_subscribers(CacheSlotInfo { // Triggers rpc_subscription notifications as soon as new commitment data is available,
current_slot: w_block_commitment_cache.slot(), // sending just the commitment cache slot information that the notifications thread
node_root: w_block_commitment_cache.root(), // needs
highest_confirmed_root: w_block_commitment_cache.highest_confirmed_root(), subscriptions.notify_subscribers(w_block_commitment_cache.slot_info());
highest_confirmed_slot: w_block_commitment_cache.highest_confirmed_slot(),
});
} }
} }

View File

@ -27,7 +27,7 @@ use solana_runtime::{
accounts::AccountAddressFilter, accounts::AccountAddressFilter,
bank::Bank, bank::Bank,
bank_forks::BankForks, bank_forks::BankForks,
commitment::{BlockCommitmentArray, BlockCommitmentCache}, commitment::{BlockCommitmentArray, BlockCommitmentCache, CacheSlotInfo},
log_collector::LogCollector, log_collector::LogCollector,
send_transaction_service::{SendTransactionService, TransactionInfo}, send_transaction_service::{SendTransactionService, TransactionInfo},
}; };
@ -192,10 +192,12 @@ impl JsonRpcRequestProcessor {
block_commitment_cache: Arc::new(RwLock::new(BlockCommitmentCache::new( block_commitment_cache: Arc::new(RwLock::new(BlockCommitmentCache::new(
HashMap::new(), HashMap::new(),
0, 0,
0, CacheSlotInfo {
bank.slot(), slot: bank.slot(),
0, root: 0,
0, highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
))), ))),
blockstore, blockstore,
validator_exit: create_validator_exit(&exit), validator_exit: create_validator_exit(&exit),
@ -1816,11 +1818,13 @@ pub mod tests {
block_commitment.entry(1).or_insert(commitment_slot1); block_commitment.entry(1).or_insert(commitment_slot1);
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new( let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new(
block_commitment, block_commitment,
0,
10, 10,
bank.slot(), CacheSlotInfo {
0, slot: bank.slot(),
0, root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
))); )));
// Add timestamp vote to blockstore // Add timestamp vote to blockstore
@ -3329,11 +3333,13 @@ pub mod tests {
.or_insert_with(|| commitment_slot1.clone()); .or_insert_with(|| commitment_slot1.clone());
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new( let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new(
block_commitment, block_commitment,
0,
42, 42,
bank_forks.read().unwrap().highest_slot(), CacheSlotInfo {
0, slot: bank_forks.read().unwrap().highest_slot(),
0, root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
))); )));
let mut config = JsonRpcConfig::default(); let mut config = JsonRpcConfig::default();
@ -3856,11 +3862,13 @@ pub mod tests {
let highest_confirmed_root = 1; let highest_confirmed_root = 1;
let block_commitment_cache = BlockCommitmentCache::new( let block_commitment_cache = BlockCommitmentCache::new(
block_commitment, block_commitment,
highest_confirmed_root,
50, 50,
bank.slot(), CacheSlotInfo {
0, slot: bank.slot(),
0, root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root,
},
); );
assert!(is_confirmed_rooted( assert!(is_confirmed_rooted(

View File

@ -349,7 +349,7 @@ mod tests {
use super::*; use super::*;
use crate::{ use crate::{
cluster_info_vote_listener::{ClusterInfoVoteListener, VoteTracker}, cluster_info_vote_listener::{ClusterInfoVoteListener, VoteTracker},
rpc_subscriptions::{tests::robust_poll_or_panic, CacheSlotInfo}, rpc_subscriptions::tests::robust_poll_or_panic,
}; };
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use jsonrpc_core::{futures::sync::mpsc, Response}; use jsonrpc_core::{futures::sync::mpsc, Response};
@ -359,7 +359,7 @@ mod tests {
use solana_runtime::{ use solana_runtime::{
bank::Bank, bank::Bank,
bank_forks::BankForks, bank_forks::BankForks,
commitment::BlockCommitmentCache, commitment::{BlockCommitmentCache, CacheSlotInfo},
genesis_utils::{ genesis_utils::{
create_genesis_config, create_genesis_config_with_vote_accounts, GenesisConfigInfo, create_genesis_config, create_genesis_config_with_vote_accounts, GenesisConfigInfo,
ValidatorVoteKeypairs, ValidatorVoteKeypairs,
@ -393,7 +393,7 @@ mod tests {
.unwrap() .unwrap()
.process_transaction(tx)?; .process_transaction(tx)?;
let mut cache_slot_info = CacheSlotInfo::default(); let mut cache_slot_info = CacheSlotInfo::default();
cache_slot_info.current_slot = current_slot; cache_slot_info.slot = current_slot;
subscriptions.notify_subscribers(cache_slot_info); subscriptions.notify_subscribers(cache_slot_info);
Ok(()) Ok(())
} }
@ -733,14 +733,14 @@ mod tests {
.process_transaction(&tx) .process_transaction(&tx)
.unwrap(); .unwrap();
let mut cache_slot_info = CacheSlotInfo::default(); let mut cache_slot_info = CacheSlotInfo::default();
cache_slot_info.current_slot = 1; cache_slot_info.slot = 1;
rpc.subscriptions.notify_subscribers(cache_slot_info); rpc.subscriptions.notify_subscribers(cache_slot_info);
let cache_slot_info = CacheSlotInfo { let cache_slot_info = CacheSlotInfo {
current_slot: 2, slot: 2,
node_root: 1, root: 1,
highest_confirmed_root: 1,
highest_confirmed_slot: 1, highest_confirmed_slot: 1,
highest_confirmed_root: 1,
}; };
rpc.subscriptions.notify_subscribers(cache_slot_info); rpc.subscriptions.notify_subscribers(cache_slot_info);
let expected = json!({ let expected = json!({

View File

@ -11,7 +11,11 @@ use solana_account_decoder::{UiAccount, UiAccountEncoding};
use solana_client::rpc_response::{ use solana_client::rpc_response::{
Response, RpcKeyedAccount, RpcResponseContext, RpcSignatureResult, Response, RpcKeyedAccount, RpcResponseContext, RpcSignatureResult,
}; };
use solana_runtime::{bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache}; use solana_runtime::{
bank::Bank,
bank_forks::BankForks,
commitment::{BlockCommitmentCache, CacheSlotInfo},
};
use solana_sdk::{ use solana_sdk::{
account::Account, account::Account,
clock::{Slot, UnixTimestamp}, clock::{Slot, UnixTimestamp},
@ -43,14 +47,6 @@ pub struct SlotInfo {
pub root: Slot, pub root: Slot,
} }
#[derive(Default)]
pub struct CacheSlotInfo {
pub current_slot: Slot,
pub node_root: Slot,
pub highest_confirmed_root: Slot,
pub highest_confirmed_slot: Slot,
}
// A more human-friendly version of Vote, with the bank state signature base58 encoded. // A more human-friendly version of Vote, with the bank state signature base58 encoded.
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct RpcVote { pub struct RpcVote {
@ -75,11 +71,9 @@ impl std::fmt::Debug for NotificationEntry {
NotificationEntry::Frozen(slot) => write!(f, "Frozen({})", slot), NotificationEntry::Frozen(slot) => write!(f, "Frozen({})", slot),
NotificationEntry::Vote(vote) => write!(f, "Vote({:?})", vote), NotificationEntry::Vote(vote) => write!(f, "Vote({:?})", vote),
NotificationEntry::Slot(slot_info) => write!(f, "Slot({:?})", slot_info), NotificationEntry::Slot(slot_info) => write!(f, "Slot({:?})", slot_info),
NotificationEntry::Bank(cache_slot_info) => write!( NotificationEntry::Bank(cache_slot_info) => {
f, write!(f, "Bank({{slot: {:?}}})", cache_slot_info.slot)
"Bank({{current_slot: {:?}}})", }
cache_slot_info.current_slot
),
NotificationEntry::Gossip(slot) => write!(f, "Gossip({:?})", slot), NotificationEntry::Gossip(slot) => write!(f, "Gossip({:?})", slot),
} }
} }
@ -180,8 +174,8 @@ where
{ {
let slot = match commitment.commitment { let slot = match commitment.commitment {
CommitmentLevel::Max => cache_slot_info.highest_confirmed_root, CommitmentLevel::Max => cache_slot_info.highest_confirmed_root,
CommitmentLevel::Recent => cache_slot_info.current_slot, CommitmentLevel::Recent => cache_slot_info.slot,
CommitmentLevel::Root => cache_slot_info.node_root, CommitmentLevel::Root => cache_slot_info.root,
CommitmentLevel::Single | CommitmentLevel::SingleGossip => { CommitmentLevel::Single | CommitmentLevel::SingleGossip => {
cache_slot_info.highest_confirmed_slot cache_slot_info.highest_confirmed_slot
} }
@ -995,7 +989,7 @@ pub(crate) mod tests {
.process_transaction(&tx) .process_transaction(&tx)
.unwrap(); .unwrap();
let mut cache_slot_info = CacheSlotInfo::default(); let mut cache_slot_info = CacheSlotInfo::default();
cache_slot_info.current_slot = 1; cache_slot_info.slot = 1;
subscriptions.notify_subscribers(cache_slot_info); subscriptions.notify_subscribers(cache_slot_info);
let (response, _) = robust_poll_or_panic(transport_receiver); let (response, _) = robust_poll_or_panic(transport_receiver);
let expected = json!({ let expected = json!({
@ -1156,8 +1150,16 @@ pub(crate) mod tests {
let mut block_commitment = HashMap::new(); let mut block_commitment = HashMap::new();
block_commitment.entry(0).or_insert(cache0); block_commitment.entry(0).or_insert(cache0);
block_commitment.entry(1).or_insert(cache1); block_commitment.entry(1).or_insert(cache1);
let block_commitment_cache = let block_commitment_cache = BlockCommitmentCache::new(
BlockCommitmentCache::new(block_commitment, 0, 10, bank1.slot(), 0, 0); block_commitment,
10,
CacheSlotInfo {
slot: bank1.slot(),
root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
);
let exit = Arc::new(AtomicBool::new(false)); let exit = Arc::new(AtomicBool::new(false));
let subscriptions = RpcSubscriptions::new( let subscriptions = RpcSubscriptions::new(
@ -1209,7 +1211,7 @@ pub(crate) mod tests {
assert!(sig_subs.contains_key(&processed_tx.signatures[0])); assert!(sig_subs.contains_key(&processed_tx.signatures[0]));
} }
let mut cache_slot_info = CacheSlotInfo::default(); let mut cache_slot_info = CacheSlotInfo::default();
cache_slot_info.current_slot = 1; cache_slot_info.slot = 1;
subscriptions.notify_subscribers(cache_slot_info); subscriptions.notify_subscribers(cache_slot_info);
let expected_res = RpcSignatureResult { err: None }; let expected_res = RpcSignatureResult { err: None };

View File

@ -35,15 +35,17 @@ impl BlockCommitment {
} }
} }
/// A node's view of cluster commitment as per a particular bank
#[derive(Default)] #[derive(Default)]
pub struct BlockCommitmentCache { pub struct BlockCommitmentCache {
/// Map of all commitment levels of current ancestor slots, aggregated from the vote account
/// data in the bank
block_commitment: HashMap<Slot, BlockCommitment>, block_commitment: HashMap<Slot, BlockCommitment>,
highest_confirmed_root: Slot, /// Cache slot details. Cluster data is calculated from the block_commitment map, and cached in
/// the struct to avoid the expense of recalculating on every call.
slot_info: CacheSlotInfo,
/// Total stake active during the bank's epoch
total_stake: u64, total_stake: u64,
/// The slot of the bank from which all other slots were calculated.
slot: Slot,
root: Slot,
pub highest_confirmed_slot: Slot,
} }
impl std::fmt::Debug for BlockCommitmentCache { impl std::fmt::Debug for BlockCommitmentCache {
@ -53,9 +55,9 @@ impl std::fmt::Debug for BlockCommitmentCache {
.field("total_stake", &self.total_stake) .field("total_stake", &self.total_stake)
.field( .field(
"bank", "bank",
&format_args!("Bank({{current_slot: {:?}}})", self.slot), &format_args!("Bank({{current_slot: {:?}}})", self.slot_info.slot),
) )
.field("root", &self.root) .field("root", &self.slot_info.root)
.finish() .finish()
} }
} }
@ -63,19 +65,13 @@ impl std::fmt::Debug for BlockCommitmentCache {
impl BlockCommitmentCache { impl BlockCommitmentCache {
pub fn new( pub fn new(
block_commitment: HashMap<Slot, BlockCommitment>, block_commitment: HashMap<Slot, BlockCommitment>,
highest_confirmed_root: Slot,
total_stake: u64, total_stake: u64,
slot: Slot, slot_info: CacheSlotInfo,
root: Slot,
highest_confirmed_slot: Slot,
) -> Self { ) -> Self {
Self { Self {
block_commitment, block_commitment,
highest_confirmed_root,
total_stake, total_stake,
slot, slot_info,
root,
highest_confirmed_slot,
} }
} }
@ -83,24 +79,28 @@ impl BlockCommitmentCache {
self.block_commitment.get(&slot) self.block_commitment.get(&slot)
} }
pub fn highest_confirmed_root(&self) -> Slot {
self.highest_confirmed_root
}
pub fn total_stake(&self) -> u64 { pub fn total_stake(&self) -> u64 {
self.total_stake self.total_stake
} }
pub fn slot(&self) -> Slot { pub fn slot(&self) -> Slot {
self.slot self.slot_info.slot
} }
pub fn root(&self) -> Slot { pub fn root(&self) -> Slot {
self.root self.slot_info.root
} }
pub fn highest_confirmed_slot(&self) -> Slot { pub fn highest_confirmed_slot(&self) -> Slot {
self.highest_confirmed_slot self.slot_info.highest_confirmed_slot
}
pub fn highest_confirmed_root(&self) -> Slot {
self.slot_info.highest_confirmed_root
}
pub fn slot_info(&self) -> CacheSlotInfo {
self.slot_info
} }
fn highest_slot_with_confirmation_count(&self, confirmation_count: usize) -> Slot { fn highest_slot_with_confirmation_count(&self, confirmation_count: usize) -> Slot {
@ -112,7 +112,7 @@ impl BlockCommitmentCache {
} }
} }
} }
self.root self.slot_info.root
} }
pub fn calculate_highest_confirmed_slot(&self) -> Slot { pub fn calculate_highest_confirmed_slot(&self) -> Slot {
@ -155,16 +155,34 @@ impl BlockCommitmentCache {
Self { Self {
block_commitment, block_commitment,
total_stake: 42, total_stake: 42,
highest_confirmed_root: root, slot_info: CacheSlotInfo {
slot, slot,
root, root,
highest_confirmed_slot: root, highest_confirmed_slot: root,
highest_confirmed_root: root,
},
} }
} }
pub fn set_highest_confirmed_root(&mut self, root: Slot) { pub fn set_highest_confirmed_slot(&mut self, slot: Slot) {
self.highest_confirmed_root = root; self.slot_info.highest_confirmed_slot = slot;
} }
pub fn set_highest_confirmed_root(&mut self, root: Slot) {
self.slot_info.highest_confirmed_root = root;
}
}
#[derive(Default, Clone, Copy)]
pub struct CacheSlotInfo {
/// The slot of the bank from which all other slots were calculated.
pub slot: Slot,
/// The current node root
pub root: Slot,
/// Highest cluster-confirmed slot
pub highest_confirmed_slot: Slot,
/// Highest cluster-confirmed root
pub highest_confirmed_root: Slot,
} }
#[cfg(test)] #[cfg(test)]
@ -200,7 +218,11 @@ mod tests {
block_commitment.entry(0).or_insert(cache0); block_commitment.entry(0).or_insert(cache0);
block_commitment.entry(1).or_insert(cache1); block_commitment.entry(1).or_insert(cache1);
block_commitment.entry(2).or_insert(cache2); block_commitment.entry(2).or_insert(cache2);
let block_commitment_cache = BlockCommitmentCache::new(block_commitment, 0, 50, 0, 0, 0); let block_commitment_cache = BlockCommitmentCache {
block_commitment,
total_stake: 50,
..BlockCommitmentCache::default()
};
assert_eq!(block_commitment_cache.get_confirmation_count(0), Some(2)); assert_eq!(block_commitment_cache.get_confirmation_count(0), Some(2));
assert_eq!(block_commitment_cache.get_confirmation_count(1), Some(1)); assert_eq!(block_commitment_cache.get_confirmation_count(1), Some(1));
@ -232,8 +254,16 @@ mod tests {
block_commitment.entry(1).or_insert_with(|| cache0.clone()); // Slot 1, conf 2 block_commitment.entry(1).or_insert_with(|| cache0.clone()); // Slot 1, conf 2
block_commitment.entry(2).or_insert_with(|| cache1.clone()); // Slot 2, conf 1 block_commitment.entry(2).or_insert_with(|| cache1.clone()); // Slot 2, conf 1
block_commitment.entry(3).or_insert_with(|| cache2.clone()); // Slot 3, conf 0 block_commitment.entry(3).or_insert_with(|| cache2.clone()); // Slot 3, conf 0
let block_commitment_cache = let block_commitment_cache = BlockCommitmentCache::new(
BlockCommitmentCache::new(block_commitment, 0, total_stake, bank_slot_5, 0, 0); block_commitment,
total_stake,
CacheSlotInfo {
slot: bank_slot_5,
root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
);
assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 2); assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 2);
@ -242,8 +272,16 @@ mod tests {
block_commitment.entry(1).or_insert_with(|| cache1.clone()); // Slot 1, conf 1 block_commitment.entry(1).or_insert_with(|| cache1.clone()); // Slot 1, conf 1
block_commitment.entry(2).or_insert_with(|| cache1.clone()); // Slot 2, conf 1 block_commitment.entry(2).or_insert_with(|| cache1.clone()); // Slot 2, conf 1
block_commitment.entry(3).or_insert_with(|| cache2.clone()); // Slot 3, conf 0 block_commitment.entry(3).or_insert_with(|| cache2.clone()); // Slot 3, conf 0
let block_commitment_cache = let block_commitment_cache = BlockCommitmentCache::new(
BlockCommitmentCache::new(block_commitment, 0, total_stake, bank_slot_5, 0, 0); block_commitment,
total_stake,
CacheSlotInfo {
slot: bank_slot_5,
root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
);
assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 2); assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 2);
@ -252,8 +290,16 @@ mod tests {
block_commitment.entry(1).or_insert_with(|| cache1.clone()); // Slot 1, conf 1 block_commitment.entry(1).or_insert_with(|| cache1.clone()); // Slot 1, conf 1
block_commitment.entry(3).or_insert(cache1); // Slot 3, conf 1 block_commitment.entry(3).or_insert(cache1); // Slot 3, conf 1
block_commitment.entry(5).or_insert_with(|| cache2.clone()); // Slot 5, conf 0 block_commitment.entry(5).or_insert_with(|| cache2.clone()); // Slot 5, conf 0
let block_commitment_cache = let block_commitment_cache = BlockCommitmentCache::new(
BlockCommitmentCache::new(block_commitment, 0, total_stake, bank_slot_5, 0, 0); block_commitment,
total_stake,
CacheSlotInfo {
slot: bank_slot_5,
root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
);
assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 3); assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 3);
@ -262,8 +308,16 @@ mod tests {
block_commitment.entry(1).or_insert(cache0); // Slot 1, conf 2 block_commitment.entry(1).or_insert(cache0); // Slot 1, conf 2
block_commitment.entry(2).or_insert_with(|| cache2.clone()); // Slot 2, conf 0 block_commitment.entry(2).or_insert_with(|| cache2.clone()); // Slot 2, conf 0
block_commitment.entry(3).or_insert_with(|| cache2.clone()); // Slot 3, conf 0 block_commitment.entry(3).or_insert_with(|| cache2.clone()); // Slot 3, conf 0
let block_commitment_cache = let block_commitment_cache = BlockCommitmentCache::new(
BlockCommitmentCache::new(block_commitment, 0, total_stake, bank_slot_5, 0, 0); block_commitment,
total_stake,
CacheSlotInfo {
slot: bank_slot_5,
root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
);
assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 1); assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 1);
@ -272,8 +326,16 @@ mod tests {
block_commitment.entry(1).or_insert_with(|| cache2.clone()); // Slot 1, conf 0 block_commitment.entry(1).or_insert_with(|| cache2.clone()); // Slot 1, conf 0
block_commitment.entry(2).or_insert_with(|| cache2.clone()); // Slot 2, conf 0 block_commitment.entry(2).or_insert_with(|| cache2.clone()); // Slot 2, conf 0
block_commitment.entry(3).or_insert(cache2); // Slot 3, conf 0 block_commitment.entry(3).or_insert(cache2); // Slot 3, conf 0
let block_commitment_cache = let block_commitment_cache = BlockCommitmentCache::new(
BlockCommitmentCache::new(block_commitment, 0, total_stake, bank_slot_5, 0, 0); block_commitment,
total_stake,
CacheSlotInfo {
slot: bank_slot_5,
root: 0,
highest_confirmed_slot: 0,
highest_confirmed_root: 0,
},
);
assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 0); assert_eq!(block_commitment_cache.calculate_highest_confirmed_slot(), 0);
} }