|
2 | 2 | super::Bank, |
3 | 3 | crate::bank::CollectorFeeDetails, |
4 | 4 | log::{debug, warn}, |
5 | | - solana_feature_set::reward_full_priority_fee, |
6 | 5 | solana_fee::FeeFeatures, |
7 | 6 | solana_runtime_transaction::transaction_with_meta::TransactionWithMeta, |
8 | 7 | solana_sdk::{ |
@@ -44,19 +43,6 @@ impl Bank { |
44 | 43 | // On the other hand, rent fees are distributed under slightly different philosophy, while |
45 | 44 | // still being stake-weighted. |
46 | 45 | // Ref: distribute_rent_to_validators |
47 | | - pub(super) fn distribute_transaction_fees(&self) { |
48 | | - let collector_fees = self.collector_fees.load(Relaxed); |
49 | | - if collector_fees != 0 { |
50 | | - let (deposit, mut burn) = self.calculate_reward_and_burn_fees(collector_fees); |
51 | | - if deposit > 0 { |
52 | | - self.deposit_or_burn_fee(deposit, &mut burn); |
53 | | - } |
54 | | - self.capitalization.fetch_sub(burn, Relaxed); |
55 | | - } |
56 | | - } |
57 | | - |
58 | | - // Replace `distribute_transaction_fees()` after Feature Gate: Reward full priority fee to |
59 | | - // validators #34731; |
60 | 46 | pub(super) fn distribute_transaction_fee_details(&self) { |
61 | 47 | let fee_details = self.collector_fee_details.read().unwrap(); |
62 | 48 | if fee_details.total() == 0 { |
@@ -84,19 +70,11 @@ impl Bank { |
84 | 70 | fee_budget_limits.prioritization_fee, |
85 | 71 | FeeFeatures::from(self.feature_set.as_ref()), |
86 | 72 | ); |
87 | | - let (reward, _burn) = if self.feature_set.is_active(&reward_full_priority_fee::id()) { |
88 | | - self.calculate_reward_and_burn_fee_details(&CollectorFeeDetails::from(fee_details)) |
89 | | - } else { |
90 | | - let fee = fee_details.total_fee(); |
91 | | - self.calculate_reward_and_burn_fees(fee) |
92 | | - }; |
| 73 | + let (reward, _burn) = |
| 74 | + self.calculate_reward_and_burn_fee_details(&CollectorFeeDetails::from(fee_details)); |
93 | 75 | reward |
94 | 76 | } |
95 | 77 |
|
96 | | - fn calculate_reward_and_burn_fees(&self, fee: u64) -> (u64, u64) { |
97 | | - self.fee_rate_governor.burn(fee) |
98 | | - } |
99 | | - |
100 | 78 | fn calculate_reward_and_burn_fee_details( |
101 | 79 | &self, |
102 | 80 | fee_details: &CollectorFeeDetails, |
@@ -185,7 +163,7 @@ impl Bank { |
185 | 163 | // The reason is that rent fee doesn't need to be incentivized for throughput unlike transaction |
186 | 164 | // fees |
187 | 165 | // |
188 | | - // Ref: distribute_transaction_fees |
| 166 | + // Ref: distribute_transaction_fee_details |
189 | 167 | fn distribute_rent_to_validators( |
190 | 168 | &self, |
191 | 169 | vote_accounts: &VoteAccountsHashMap, |
@@ -430,119 +408,6 @@ pub mod tests { |
430 | 408 | } |
431 | 409 | } |
432 | 410 |
|
433 | | - #[test] |
434 | | - fn test_distribute_transaction_fees_normal() { |
435 | | - let genesis = create_genesis_config(0); |
436 | | - let bank = Bank::new_for_tests(&genesis.genesis_config); |
437 | | - let transaction_fees = 100; |
438 | | - bank.collector_fees.fetch_add(transaction_fees, Relaxed); |
439 | | - assert_eq!(transaction_fees, bank.collector_fees.load(Relaxed)); |
440 | | - let (expected_collected_fees, burn_amount) = bank.fee_rate_governor.burn(transaction_fees); |
441 | | - |
442 | | - let initial_capitalization = bank.capitalization(); |
443 | | - let initial_collector_id_balance = bank.get_balance(bank.collector_id()); |
444 | | - bank.distribute_transaction_fees(); |
445 | | - let new_collector_id_balance = bank.get_balance(bank.collector_id()); |
446 | | - |
447 | | - assert_eq!( |
448 | | - initial_collector_id_balance + expected_collected_fees, |
449 | | - new_collector_id_balance |
450 | | - ); |
451 | | - assert_eq!(initial_capitalization - burn_amount, bank.capitalization()); |
452 | | - let locked_rewards = bank.rewards.read().unwrap(); |
453 | | - assert_eq!( |
454 | | - locked_rewards.len(), |
455 | | - 1, |
456 | | - "There should be one reward distributed" |
457 | | - ); |
458 | | - |
459 | | - let reward_info = &locked_rewards[0]; |
460 | | - assert_eq!( |
461 | | - reward_info.1.lamports, expected_collected_fees as i64, |
462 | | - "The reward amount should match the expected deposit" |
463 | | - ); |
464 | | - assert_eq!( |
465 | | - reward_info.1.reward_type, |
466 | | - RewardType::Fee, |
467 | | - "The reward type should be Fee" |
468 | | - ); |
469 | | - } |
470 | | - |
471 | | - #[test] |
472 | | - fn test_distribute_transaction_fees_zero() { |
473 | | - let genesis = create_genesis_config(0); |
474 | | - let bank = Bank::new_for_tests(&genesis.genesis_config); |
475 | | - assert_eq!(bank.collector_fees.load(Relaxed), 0); |
476 | | - |
477 | | - let initial_capitalization = bank.capitalization(); |
478 | | - let initial_collector_id_balance = bank.get_balance(bank.collector_id()); |
479 | | - bank.distribute_transaction_fees(); |
480 | | - let new_collector_id_balance = bank.get_balance(bank.collector_id()); |
481 | | - |
482 | | - assert_eq!(initial_collector_id_balance, new_collector_id_balance); |
483 | | - assert_eq!(initial_capitalization, bank.capitalization()); |
484 | | - let locked_rewards = bank.rewards.read().unwrap(); |
485 | | - assert!( |
486 | | - locked_rewards.is_empty(), |
487 | | - "There should be no rewards distributed" |
488 | | - ); |
489 | | - } |
490 | | - |
491 | | - #[test] |
492 | | - fn test_distribute_transaction_fees_burn_all() { |
493 | | - let mut genesis = create_genesis_config(0); |
494 | | - genesis.genesis_config.fee_rate_governor.burn_percent = 100; |
495 | | - let bank = Bank::new_for_tests(&genesis.genesis_config); |
496 | | - let transaction_fees = 100; |
497 | | - bank.collector_fees.fetch_add(transaction_fees, Relaxed); |
498 | | - assert_eq!(transaction_fees, bank.collector_fees.load(Relaxed)); |
499 | | - |
500 | | - let initial_capitalization = bank.capitalization(); |
501 | | - let initial_collector_id_balance = bank.get_balance(bank.collector_id()); |
502 | | - bank.distribute_transaction_fees(); |
503 | | - let new_collector_id_balance = bank.get_balance(bank.collector_id()); |
504 | | - |
505 | | - assert_eq!(initial_collector_id_balance, new_collector_id_balance); |
506 | | - assert_eq!( |
507 | | - initial_capitalization - transaction_fees, |
508 | | - bank.capitalization() |
509 | | - ); |
510 | | - let locked_rewards = bank.rewards.read().unwrap(); |
511 | | - assert!( |
512 | | - locked_rewards.is_empty(), |
513 | | - "There should be no rewards distributed" |
514 | | - ); |
515 | | - } |
516 | | - |
517 | | - #[test] |
518 | | - fn test_distribute_transaction_fees_overflow_failure() { |
519 | | - let genesis = create_genesis_config(0); |
520 | | - let bank = Bank::new_for_tests(&genesis.genesis_config); |
521 | | - let transaction_fees = 100; |
522 | | - bank.collector_fees.fetch_add(transaction_fees, Relaxed); |
523 | | - assert_eq!(transaction_fees, bank.collector_fees.load(Relaxed)); |
524 | | - |
525 | | - // ensure that account balance will overflow and fee distribution will fail |
526 | | - let account = AccountSharedData::new(u64::MAX, 0, &system_program::id()); |
527 | | - bank.store_account(bank.collector_id(), &account); |
528 | | - |
529 | | - let initial_capitalization = bank.capitalization(); |
530 | | - let initial_collector_id_balance = bank.get_balance(bank.collector_id()); |
531 | | - bank.distribute_transaction_fees(); |
532 | | - let new_collector_id_balance = bank.get_balance(bank.collector_id()); |
533 | | - |
534 | | - assert_eq!(initial_collector_id_balance, new_collector_id_balance); |
535 | | - assert_eq!( |
536 | | - initial_capitalization - transaction_fees, |
537 | | - bank.capitalization() |
538 | | - ); |
539 | | - let locked_rewards = bank.rewards.read().unwrap(); |
540 | | - assert!( |
541 | | - locked_rewards.is_empty(), |
542 | | - "There should be no rewards distributed" |
543 | | - ); |
544 | | - } |
545 | | - |
546 | 411 | #[test] |
547 | 412 | fn test_deposit_fees() { |
548 | 413 | let initial_balance = 1_000_000_000; |
|
0 commit comments