Return root when bank not found (#11188)

* Return root when bank not found

* Apply suggestions from code review

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
This commit is contained in:
Greg Fitzgerald 2020-07-23 18:57:15 -06:00 committed by GitHub
parent 8ccce1e543
commit 7484202282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 1 deletions

View File

@ -133,7 +133,24 @@ impl JsonRpcRequestProcessor {
}
};
r_bank_forks.get(slot).cloned().unwrap()
r_bank_forks.get(slot).cloned().unwrap_or_else(|| {
// We log an error instead of returning an error, because all known error cases
// are due to known bugs that should be fixed instead.
//
// The slot may not be found as a result of a known bug in snapshot creation, where
// the bank at the given slot was not included in the snapshot.
// Also, it may occur after an old bank has been purged from BankForks and a new
// BlockCommitmentCache has not yet arrived. To make this case impossible,
// BlockCommitmentCache should hold an `Arc<Bank>` everywhere it currently holds
// a slot.
//
// For more information, see https://github.com/solana-labs/solana/issues/11078
error!(
"Bank with {:?} not found at slot: {:?}",
commitment_level, slot
);
r_bank_forks.root_bank().clone()
})
}
pub fn new(