Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove congestion multiplier from calculate fee #34865

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6661,6 +6661,17 @@ 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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently behavior:

  1. genesis_config either have fee_rate_gonervor set to 0 (or any other value) lamports_per_signature for test or 5_000 in production;
  2. fee_structure is always default to 5_000 lamports_per_signature regardless.

This change is to initialize fee_structure to have same lamports_per_signature as in fee_rate_governor.

}

pub fn set_inflation(&self, inflation: Inflation) {
Expand Down
1 change: 0 additions & 1 deletion runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3335,7 +3335,6 @@ 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());
Expand Down
12 changes: 2 additions & 10 deletions sdk/src/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,10 @@ impl FeeStructure {
pub fn calculate_fee(
&self,
message: &SanitizedMessage,
lamports_per_signature: u64,
_lamports_per_signature: u64,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove this parameter in separate PR involving removing fetching nonce lamports_per_signature.

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
};

let signature_fee = message
.num_signatures()
.saturating_mul(self.lamports_per_signature);
Expand Down Expand Up @@ -122,12 +115,11 @@ 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
}
}
Expand Down