v1.1: backport commitment max changes (#9775)

* Add largest_confirmed_root to BlockCommitmentCache (#9640)

* Add largest_confirmed_root to BlockCommitmentCache

* clippy

* Add blockstore to BlockCommitmentCache to check root

* Add rooted_stake helper fn and test

* Nodes that are behind should correctly id confirmed roots

* Simplify rooted_stake collector

* Cache banks in BankForks until optional largest_confirmed_root (#9678)

automerge

* Rpc: Use cluster largest_confirmed_root as commitment max (#9750)

automerge
This commit is contained in:
Tyera Eulberg
2020-04-28 15:04:41 -06:00
committed by GitHub
parent ac538d0395
commit 59446d5c50
16 changed files with 530 additions and 143 deletions

View File

@@ -169,6 +169,7 @@ impl BankForks {
&mut self,
root: Slot,
snapshot_package_sender: &Option<SnapshotPackageSender>,
largest_confirmed_root: Option<Slot>,
) {
let old_epoch = self.root_bank().epoch();
self.root = root;
@@ -243,7 +244,7 @@ impl BankForks {
}
let new_tx_count = root_bank.transaction_count();
self.prune_non_root(root);
self.prune_non_root(root, largest_confirmed_root);
inc_new_counter_info!(
"bank-forks_set_root_ms",
@@ -314,10 +315,19 @@ impl BankForks {
Ok(())
}
fn prune_non_root(&mut self, root: Slot) {
fn prune_non_root(&mut self, root: Slot, largest_confirmed_root: Option<Slot>) {
let descendants = self.descendants();
self.banks
.retain(|slot, _| slot == &root || descendants[&root].contains(slot));
self.banks.retain(|slot, _| {
*slot == root
|| descendants[&root].contains(slot)
|| (*slot < root
&& *slot >= largest_confirmed_root.unwrap_or(root)
&& descendants[slot].contains(&root))
});
datapoint_debug!(
"bank_forks_purge_non_root",
("num_banks_retained", self.banks.len(), i64),
);
}
pub fn set_snapshot_config(&mut self, snapshot_config: Option<SnapshotConfig>) {