Check bank capitalization (#11927)
* Check bank capitalization * Simplify and unify capitalization calculation * Improve and add tests * Avoid overflow and inhibit automatic restart * Fix test * Tweak checked sum for cap. and add tests * Fix broken build after merge conflicts.. * Rename to ClusterType * Rename confusing method * Clarify comment * Verify cap. in rent and inflation tests Co-authored-by: Stephen Akridge <sakridge@gmail.com>
This commit is contained in:
@ -44,7 +44,7 @@ use solana_vote_program::{
|
||||
};
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
|
||||
convert::{TryFrom, TryInto},
|
||||
convert::TryInto,
|
||||
ffi::OsStr,
|
||||
fs::{self, File},
|
||||
io::{self, stdout, BufRead, BufReader, Write},
|
||||
@ -708,16 +708,7 @@ fn open_genesis_config_by(ledger_path: &Path, matches: &ArgMatches<'_>) -> Genes
|
||||
}
|
||||
|
||||
fn assert_capitalization(bank: &Bank) {
|
||||
let calculated_capitalization = bank.calculate_capitalization();
|
||||
assert_eq!(
|
||||
bank.capitalization(),
|
||||
calculated_capitalization,
|
||||
"Capitalization mismatch!?: +/-{}",
|
||||
Sol(u64::try_from(
|
||||
(i128::from(calculated_capitalization) - i128::from(bank.capitalization())).abs()
|
||||
)
|
||||
.unwrap()),
|
||||
);
|
||||
assert!(bank.calculate_and_verify_capitalization());
|
||||
}
|
||||
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
@ -1695,7 +1686,7 @@ fn main() {
|
||||
|
||||
if remove_stake_accounts {
|
||||
for (address, mut account) in bank
|
||||
.get_program_accounts(Some(&solana_stake_program::id()))
|
||||
.get_program_accounts(&solana_stake_program::id())
|
||||
.into_iter()
|
||||
{
|
||||
account.lamports = 0;
|
||||
@ -1723,7 +1714,7 @@ fn main() {
|
||||
|
||||
// Delete existing vote accounts
|
||||
for (address, mut account) in bank
|
||||
.get_program_accounts(Some(&solana_vote_program::id()))
|
||||
.get_program_accounts(&solana_vote_program::id())
|
||||
.into_iter()
|
||||
{
|
||||
account.lamports = 0;
|
||||
|
Reference in New Issue
Block a user