Add RPC notify and banking keys debug (#12396)

This commit is contained in:
sakridge
2020-09-23 18:46:42 -07:00
committed by GitHub
parent 7cab638297
commit 68e5a2ef56
11 changed files with 112 additions and 19 deletions

View File

@ -36,7 +36,7 @@ fn bench_has_duplicates(bencher: &mut Bencher) {
#[bench]
fn test_accounts_create(bencher: &mut Bencher) {
let (genesis_config, _) = create_genesis_config(10_000);
let bank0 = Bank::new_with_paths(&genesis_config, vec![PathBuf::from("bench_a0")], &[]);
let bank0 = Bank::new_with_paths(&genesis_config, vec![PathBuf::from("bench_a0")], &[], None);
bencher.iter(|| {
let mut pubkeys: Vec<Pubkey> = vec![];
deposit_many(&bank0, &mut pubkeys, 1000);
@ -50,6 +50,7 @@ fn test_accounts_squash(bencher: &mut Bencher) {
&genesis_config,
vec![PathBuf::from("bench_a1")],
&[],
None,
));
let mut pubkeys: Vec<Pubkey> = vec![];
deposit_many(&bank1, &mut pubkeys, 250_000);

View File

@ -516,6 +516,8 @@ pub struct Bank {
/// Cached executors
cached_executors: Arc<RwLock<CachedExecutors>>,
transaction_debug_keys: Option<Arc<HashSet<Pubkey>>>,
}
impl Default for BlockhashQueue {
@ -526,15 +528,17 @@ impl Default for BlockhashQueue {
impl Bank {
pub fn new(genesis_config: &GenesisConfig) -> Self {
Self::new_with_paths(&genesis_config, Vec::new(), &[])
Self::new_with_paths(&genesis_config, Vec::new(), &[], None)
}
pub fn new_with_paths(
genesis_config: &GenesisConfig,
paths: Vec<PathBuf>,
frozen_account_pubkeys: &[Pubkey],
debug_keys: Option<Arc<HashSet<Pubkey>>>,
) -> Self {
let mut bank = Self::default();
bank.transaction_debug_keys = debug_keys;
bank.cluster_type = Some(genesis_config.cluster_type);
bank.ancestors.insert(bank.slot(), 0);
@ -636,6 +640,7 @@ impl Bank {
lazy_rent_collection: AtomicBool::new(parent.lazy_rent_collection.load(Relaxed)),
rewards_pool_pubkeys: parent.rewards_pool_pubkeys.clone(),
cached_executors: parent.cached_executors.clone(),
transaction_debug_keys: parent.transaction_debug_keys.clone(),
};
datapoint_info!(
@ -688,6 +693,7 @@ impl Bank {
bank_rc: BankRc,
genesis_config: &GenesisConfig,
fields: BankFieldsToDeserialize,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
) -> Self {
fn new<T: Default>() -> T {
T::default()
@ -738,6 +744,7 @@ impl Bank {
lazy_rent_collection: new(),
rewards_pool_pubkeys: new(),
cached_executors: Arc::new(RwLock::new(CachedExecutors::new(MAX_CACHED_EXECUTORS))),
transaction_debug_keys: debug_keys,
};
bank.finish_init(genesis_config);
@ -2015,6 +2022,14 @@ impl Bank {
let mut tx_count: u64 = 0;
let err_count = &mut error_counters.total;
for ((r, _hash_age_kind), tx) in executed.iter().zip(txs.iter()) {
if let Some(debug_keys) = &self.transaction_debug_keys {
for key in &tx.message.account_keys {
if debug_keys.contains(key) {
info!("slot: {} result: {:?} tx: {:?}", self.slot, r, tx);
break;
}
}
}
if r.is_ok() {
tx_count += 1;
} else {

View File

@ -29,7 +29,7 @@ use {
pubkey::Pubkey,
},
std::{
collections::HashMap,
collections::{HashMap, HashSet},
io::{BufReader, BufWriter, Read, Write},
path::{Path, PathBuf},
result::Result,
@ -124,6 +124,7 @@ pub(crate) fn bank_from_stream<R, P>(
account_paths: &[PathBuf],
genesis_config: &GenesisConfig,
frozen_account_pubkeys: &[Pubkey],
debug_keys: Option<Arc<HashSet<Pubkey>>>,
) -> std::result::Result<Bank, Error>
where
R: Read,
@ -140,6 +141,7 @@ where
frozen_account_pubkeys,
account_paths,
append_vecs_path,
debug_keys,
)?;
Ok(bank)
}};
@ -224,6 +226,7 @@ fn reconstruct_bank_from_fields<E, P>(
frozen_account_pubkeys: &[Pubkey],
account_paths: &[PathBuf],
append_vecs_path: P,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
) -> Result<Bank, Error>
where
E: Into<AccountStorageEntry>,
@ -238,7 +241,7 @@ where
accounts_db.freeze_accounts(&bank_fields.ancestors, frozen_account_pubkeys);
let bank_rc = BankRc::new(Accounts::new_empty(accounts_db), bank_fields.slot);
let bank = Bank::new_from_fields(bank_rc, genesis_config, bank_fields);
let bank = Bank::new_from_fields(bank_rc, genesis_config, bank_fields, debug_keys);
Ok(bank)
}

View File

@ -211,6 +211,7 @@ fn test_bank_serialize_style(serde_style: SerdeStyle) {
&dbank_paths,
&genesis_config,
&[],
None,
)
.unwrap();
dbank.src = ref_sc;

View File

@ -20,6 +20,8 @@ use solana_sdk::{
hash::Hash,
pubkey::Pubkey,
};
use std::collections::HashSet;
use std::sync::Arc;
use std::{
cmp::Ordering,
fmt,
@ -571,6 +573,7 @@ pub fn bank_from_archive<P: AsRef<Path>>(
snapshot_tar: P,
compression: CompressionType,
genesis_config: &GenesisConfig,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
) -> Result<Bank> {
// Untar the snapshot into a temp directory under `snapshot_config.snapshot_path()`
let unpack_dir = tempfile::tempdir_in(snapshot_path)?;
@ -591,6 +594,7 @@ pub fn bank_from_archive<P: AsRef<Path>>(
&unpacked_snapshots_dir,
unpacked_accounts_dir,
genesis_config,
debug_keys,
)?;
if !bank.verify_snapshot_bank() {
@ -748,6 +752,7 @@ fn rebuild_bank_from_snapshots<P>(
unpacked_snapshots_dir: &PathBuf,
append_vecs_path: P,
genesis_config: &GenesisConfig,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
) -> Result<Bank>
where
P: AsRef<Path>,
@ -779,6 +784,7 @@ where
account_paths,
genesis_config,
frozen_account_pubkeys,
debug_keys,
),
}?)
})?;