Use a different counter for validator account not found errors. (#931)
* Use a different counter for validator account not found errors. This is a usefull signal of something going wrong with the ledger
This commit is contained in:
committed by
GitHub
parent
d4304eea28
commit
2318ffc704
25
src/bank.rs
25
src/bank.rs
@ -87,6 +87,10 @@ pub struct Bank {
|
|||||||
/// The number of transactions the bank has processed without error since the
|
/// The number of transactions the bank has processed without error since the
|
||||||
/// start of the ledger.
|
/// start of the ledger.
|
||||||
transaction_count: AtomicUsize,
|
transaction_count: AtomicUsize,
|
||||||
|
|
||||||
|
/// This bool allows us to submit metrics that are specific for leaders or validators
|
||||||
|
/// It is set to `true` by fullnode before creating the bank.
|
||||||
|
pub is_leader: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Bank {
|
impl Default for Bank {
|
||||||
@ -97,11 +101,18 @@ impl Default for Bank {
|
|||||||
last_ids: RwLock::new(VecDeque::new()),
|
last_ids: RwLock::new(VecDeque::new()),
|
||||||
last_ids_sigs: RwLock::new(HashMap::new()),
|
last_ids_sigs: RwLock::new(HashMap::new()),
|
||||||
transaction_count: AtomicUsize::new(0),
|
transaction_count: AtomicUsize::new(0),
|
||||||
|
is_leader: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bank {
|
impl Bank {
|
||||||
|
/// Create a default Bank
|
||||||
|
pub fn new_default(is_leader: bool) -> Self {
|
||||||
|
let mut bank = Bank::default();
|
||||||
|
bank.is_leader = is_leader;
|
||||||
|
bank
|
||||||
|
}
|
||||||
/// Create an Bank using a deposit.
|
/// Create an Bank using a deposit.
|
||||||
pub fn new_from_deposit(deposit: &Payment) -> Self {
|
pub fn new_from_deposit(deposit: &Payment) -> Self {
|
||||||
let bank = Self::default();
|
let bank = Self::default();
|
||||||
@ -224,7 +235,10 @@ impl Bank {
|
|||||||
{
|
{
|
||||||
let option = bals.get_mut(&tx.from);
|
let option = bals.get_mut(&tx.from);
|
||||||
if option.is_none() {
|
if option.is_none() {
|
||||||
if let Instruction::NewVote(_) = &tx.instruction {
|
// TODO: this is gnarly because the counters are static atomics
|
||||||
|
if !self.is_leader {
|
||||||
|
inc_new_counter_info!("bank-appy_debits-account_not_found-validator", 1);
|
||||||
|
} else if let Instruction::NewVote(_) = &tx.instruction {
|
||||||
inc_new_counter_info!("bank-appy_debits-vote_account_not_found", 1);
|
inc_new_counter_info!("bank-appy_debits-vote_account_not_found", 1);
|
||||||
} else {
|
} else {
|
||||||
inc_new_counter_info!("bank-appy_debits-generic_account_not_found", 1);
|
inc_new_counter_info!("bank-appy_debits-generic_account_not_found", 1);
|
||||||
@ -959,5 +973,14 @@ mod tests {
|
|||||||
let bank = Bank::default();
|
let bank = Bank::default();
|
||||||
assert!(bank.process_ledger(ledger).is_ok());
|
assert!(bank.process_ledger(ledger).is_ok());
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_new_default() {
|
||||||
|
let def_bank = Bank::default();
|
||||||
|
assert!(def_bank.is_leader);
|
||||||
|
let leader_bank = Bank::new_default(true);
|
||||||
|
assert!(leader_bank.is_leader);
|
||||||
|
let validator_bank = Bank::new_default(false);
|
||||||
|
assert!(!validator_bank.is_leader);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ impl FullNode {
|
|||||||
sigverify_disabled: bool,
|
sigverify_disabled: bool,
|
||||||
) -> FullNode {
|
) -> FullNode {
|
||||||
info!("creating bank...");
|
info!("creating bank...");
|
||||||
let bank = Bank::default();
|
let bank = Bank::new_default(leader);
|
||||||
|
|
||||||
let entries = read_ledger(ledger_path).expect("opening ledger");
|
let entries = read_ledger(ledger_path).expect("opening ledger");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user