-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Remove congestion multiplier from calculate_fee function #34537
Remove congestion multiplier from calculate_fee function #34537
Conversation
@@ -4058,22 +4055,6 @@ impl Bank { | |||
.verification_complete() | |||
} | |||
|
|||
pub fn get_fee_for_message_with_lamports_per_signature( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fee_structure.calculate_fee() doesn't take lamports_per_signature
anymore, this function can be fold into above bank.get_fee_for_message()
.
}) | ||
})?; | ||
Some(self.get_fee_for_message_with_lamports_per_signature(message, lamports_per_signature)) | ||
pub fn get_fee_for_message(&self, message: &SanitizedMessage) -> u64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the return type changed from option<u64>
to u64
, that leads to many updates on callsite
@@ -52,7 +51,6 @@ pub(super) fn load_accounts( | |||
ancestors: &Ancestors, | |||
txs: &[SanitizedTransaction], | |||
lock_results: Vec<TransactionCheckResult>, | |||
hash_queue: &BlockhashQueue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hash_queue
was used to resolve lamports_per_signature
, which is no longer needed.
cec0ec8
to
068db48
Compare
let genesis = create_genesis_config(10); | ||
// Fund payer account with minimal transaction fee for one signature, plus some extra. | ||
let mint_lamports = 10 + solana_sdk::fee::FeeStructure::default().lamports_per_signature; | ||
let genesis = create_genesis_config(mint_lamports); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, load_accounts()
read BlockHashQueue for fee_calculator.lamports_per_signature, then use it as "congestion_multiplier". fee_calculator
perhaps should not be used anymore. In any case, fee_calculator.lamports_per_signature would be zero in this test, therefore would have set transaction fee to 0
.
With the change in this PR, eg removing congestion_multiplier all together, this transaction transaction will have fee of 1 signature (eg 5000 lamports). Account this in mint account corrects the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of other tests, including those form local-cluster tests, might have been broken for the same reason:
- genesis is configured with 0 lamports_per_signature in fee_calculator.
- it is read in as congestion_multipler, that effectively set transaction fee to 0.
- tests were setup with low balance since transaction has zero fee.
- with changes in this PR, transaction will have 5000 lamports per signature fee, that fails transactions with low payer balance.
One option is to initialize bank.fee_structure from blockhash_queue.fee_calculate.lamport_per_signature, instead of default, that should keep all exist tests success without further changes. But that itself has risk, should be in its own pr.
3238dcf
to
e3d9b1a
Compare
I agree that this code is messy but I'm not sure that this is the right way to clean it up. I believe the reason that the |
was this supposed to be a line comment? where's "here"? |
} else { | ||
1.0 // multiplier that has no effect | ||
}; | ||
|
||
let signature_fee = message | ||
.num_signatures() | ||
.saturating_mul(self.lamports_per_signature); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while removing "no-longer necessary" congestion_multipler
, realized there might be a bug in this line 88 above. The signature_fee is always calculated with current bank's fee_structure's lamports_per_signature, it should be using passed in parameter lamports_per_signature
, which is determined differently for nonce tx and normal tx.
Isn't this a bug? @t-nelson @jstarry
I traced it back to #23095 where behavior seems changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm, i don't remember the intent of this "congestion" fee. lamports_per_signature
already contains the signature rate based congestion fee. it's calculated at the start of the slot, https://github.com/jackcmay/solana/blob/176ef5aeb25d7b3f331a12655654e801fed06235/runtime/src/bank.rs#L1563-L1578.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@t-nelson can you comment on why durable nonces store lamports_per_signature
and if we still intend to use that value in the future. The main thing we need to figure out to accept or reject this PR is whether or not we should be using the nonce-stored lamports_per_signature
value from a previous bank here instead of the one calculated by the current bank.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
durable nonces store lamports_per_signature
because some opinionated people were very adamant about preserving the "fee-payer pays deterministic fees" meme. afaik we've already unhooked them and just use fee rate from time of execution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"here" is It suppose to be an innocent PR to remove unused stuff 😇 But it revealed few issues. The first one is: have we been wrong in calculating nonce tx signature fee? line commente here. |
2. simply bank.get_fee_for_message(), no need to resolve lamports_per_signature before calling; 3. remove a dead test that was for congestion multiplier;
e3d9b1a
to
2743154
Compare
Convert this PR to Draft, going to break it into smaller and separated PRs:
|
Problem
bank.calculate_fee()
takes a parameter with misleading name (lamports_per_signature
) for testing congestion multiplier to be zero, which has been removed everywhere. That parameter should also be removed.Due to legacy or perhaps misleading name of the parameter, call sites are calling extra code to resolve
lamports_per_signature
before callingcalculate_fee()
, in some instances, it locks hash_queue to do so. All of these are not necessary.Summary of Changes
congestion_multiplier
withincalculate_fee()
lamports_per_signature
input parameter ofcalculate_fee()
, durable transaction also uses fee rate from time of execution.lamports_per_signature
from nonce account leading to call ofcalculate_fee()
Fixes #