From 70111feac724f813e1abd1c6cf5873cac06d5707 Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Tue, 30 Jan 2024 21:59:34 +0000 Subject: [PATCH] Revert "Remove congestion multiplier from calculate fee (#34865)" This reverts commit 73d3973c7c26848c50522396962daf520be4536e. (cherry picked from commit 0dcac3fe7c4832fc6f358f010ddba8a116da70ab) # Conflicts: # sdk/src/fee.rs --- runtime/src/bank.rs | 11 ----------- runtime/src/bank/tests.rs | 1 + sdk/src/fee.rs | 17 ++++++++++++++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 38de7ff18de594..bccfa595ac33f7 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6660,17 +6660,6 @@ impl Bank { &self.runtime_config.compute_budget.unwrap_or_default(), false, /* debugging_features */ )); - - // genesis_config loaded by accounts_db::open_genesis_config() from ledger - // has it's lamports_per_signature set to zero; bank sets its value correctly - // after the first block with a transaction in it. This is a hack to mimic - // the process. - let derived_fee_rate_governor = - FeeRateGovernor::new_derived(&genesis_config.fee_rate_governor, 0); - // new bank's fee_structure.lamports_per_signature should be inline with - // what's configured in GenesisConfig - self.fee_structure.lamports_per_signature = - derived_fee_rate_governor.lamports_per_signature; } pub fn set_inflation(&self, inflation: Inflation) { diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index efe8b1970dfeff..0a8309bdd37cb5 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -3335,6 +3335,7 @@ fn test_bank_parent_account_spend() { let key2 = Keypair::new(); let (parent, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let amount = genesis_config.rent.minimum_balance(0); + println!("==== amount {}", amount); let tx = system_transaction::transfer(&mint_keypair, &key1.pubkey(), amount, genesis_config.hash()); diff --git a/sdk/src/fee.rs b/sdk/src/fee.rs index 9f9074ce1de9dd..2adeaaebb33b61 100644 --- a/sdk/src/fee.rs +++ b/sdk/src/fee.rs @@ -81,6 +81,7 @@ impl FeeStructure { &self, message: &SanitizedMessage, <<<<<<< HEAD +<<<<<<< HEAD <<<<<<< HEAD _lamports_per_signature: u64, budget_limits: &FeeBudgetLimits, @@ -116,6 +117,19 @@ impl FeeStructure { include_loaded_account_data_size_in_fee: bool, ) -> u64 { >>>>>>> df2ee120e9 (Revert "separate priority fee and transaction fee from fee calculation (#34757)") +======= + lamports_per_signature: u64, + budget_limits: &FeeBudgetLimits, + include_loaded_account_data_size_in_fee: bool, + ) -> u64 { + // Fee based on compute units and signatures + let congestion_multiplier = if lamports_per_signature == 0 { + 0.0 // test only + } else { + 1.0 // multiplier that has no effect + }; + +>>>>>>> 0dcac3fe7c (Revert "Remove congestion multiplier from calculate fee (#34865)") let signature_fee = message .num_signatures() .saturating_mul(self.lamports_per_signature); @@ -147,11 +161,12 @@ impl FeeStructure { .unwrap_or_default() }); - (budget_limits + ((budget_limits .prioritization_fee .saturating_add(signature_fee) .saturating_add(write_lock_fee) .saturating_add(compute_fee) as f64) + * congestion_multiplier) .round() as u64 } }