Port counting vote CUs to block cost to v1.9

This commit is contained in:
Tao Zhu
2022-01-12 18:31:50 -06:00
committed by Tao Zhu
parent 2ef0b85829
commit 7a421fe602
13 changed files with 217 additions and 143 deletions

View File

@ -991,8 +991,8 @@ impl BankingStage {
bank.prepare_sanitized_batch_with_results(txs, transactions_qos_results.into_iter());
lock_time.stop();
// retryable_txs includes AccountInUse, WouldExceedMaxBlockCostLimit and
// WouldExceedMaxAccountCostLimit
// retryable_txs includes AccountInUse, WouldExceedMaxBlockCostLimit,
// WouldExceedMaxVoteCostLimit and WouldExceedMaxAccountCostLimit
let (result, mut retryable_txs) = Self::process_and_record_transactions_locked(
bank,
poh,

View File

@ -128,6 +128,10 @@ impl QosService {
self.metrics.retried_txs_per_block_limit_count.fetch_add(1, Ordering::Relaxed);
Err(TransactionError::WouldExceedMaxBlockCostLimit)
}
CostTrackerError::WouldExceedVoteMaxLimit => {
self.metrics.retried_txs_per_vote_limit_count.fetch_add(1, Ordering::Relaxed);
Err(TransactionError::WouldExceedMaxVoteCostLimit)
}
CostTrackerError::WouldExceedAccountMaxLimit => {
self.metrics.retried_txs_per_account_limit_count.fetch_add(1, Ordering::Relaxed);
Err(TransactionError::WouldExceedMaxAccountCostLimit)
@ -163,6 +167,7 @@ struct QosServiceMetrics {
cost_tracking_time: AtomicU64,
selected_txs_count: AtomicU64,
retried_txs_per_block_limit_count: AtomicU64,
retried_txs_per_vote_limit_count: AtomicU64,
retried_txs_per_account_limit_count: AtomicU64,
}
@ -197,6 +202,12 @@ impl QosServiceMetrics {
.swap(0, Ordering::Relaxed) as i64,
i64
),
(
"retried_txs_per_vote_limit_count",
self.retried_txs_per_vote_limit_count
.swap(0, Ordering::Relaxed) as i64,
i64
),
(
"retried_txs_per_account_limit_count",
self.retried_txs_per_account_limit_count
@ -292,6 +303,7 @@ mod tests {
.unwrap()
.calculate_cost(&transfer_tx)
.sum();
let vote_tx_cost = cost_model.read().unwrap().calculate_cost(&vote_tx).sum();
// make a vec of txs
let txs = vec![transfer_tx.clone(), vote_tx.clone(), transfer_tx, vote_tx];
@ -299,19 +311,19 @@ mod tests {
let qos_service = QosService::new(cost_model);
let txs_costs = qos_service.compute_transaction_costs(txs.iter());
// set cost tracker limit to fit 1 transfer tx, vote tx bypasses limit check
let cost_limit = transfer_tx_cost;
// set cost tracker limit to fit 1 transfer tx and 1 vote tx
let cost_limit = transfer_tx_cost + vote_tx_cost;
bank.write_cost_tracker()
.unwrap()
.set_limits(cost_limit, cost_limit);
.set_limits(cost_limit, cost_limit, cost_limit);
let results = qos_service.select_transactions_per_cost(txs.iter(), txs_costs.iter(), &bank);
// verify that first transfer tx and all votes are allowed
// verify that first transfer tx and first votes are allowed
assert_eq!(results.len(), txs.len());
assert!(results[0].is_ok());
assert!(results[1].is_ok());
assert!(results[2].is_err());
assert!(results[3].is_ok());
assert!(results[3].is_err());
}
#[test]