-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
separate priority fee and transaction fee from fee calculation #34757
separate priority fee and transaction fee from fee calculation #34757
Conversation
2ae2a72
to
6725461
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #34757 +/- ##
=======================================
Coverage 81.6% 81.6%
=======================================
Files 830 830
Lines 224746 224757 +11
=======================================
+ Hits 183515 183547 +32
+ Misses 41231 41210 -21 |
can this wait for 1.19? should be able to cut 1.18 in ~1wk if all goes well with mb 1.17 adoption, making this mergeable into master |
1.19 sounds good, need time to test anyway. |
6725461
to
c877ee5
Compare
9cd885f
to
1f186d1
Compare
@@ -83,7 +96,7 @@ impl FeeStructure { | |||
_lamports_per_signature: u64, | |||
budget_limits: &FeeBudgetLimits, | |||
include_loaded_account_data_size_in_fee: bool, | |||
) -> u64 { | |||
) -> FeeDetails { |
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.
this is changing the signature of a public interface, which is technically against semver. who's consuming this?
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.
Direct callers (besides tests) are bank
(calculate tx fee for distribution) and accounts
(to validate payer account), both are updated in this PR. Don't think it is exposed to external 🤞🏼
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.
well it's exposed for sure 'cause sdk is a publicly consumable crate and this method is publicly exported. question is whether it's actually consumed by anyone, which we really ought not find out the hard way.
i suppose the most pedantic thing to do here would be to move this logic to a new method calculate_fee_details(...) -> FeeDetails
, then deprecate calculate_fee(...) -> u64
replacing its body with a call to calculate_fee_details(...).total_fees()
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.
I agree with Trent here, it's quite possible 3rd party code usees this function.
Though I'm not sure we need to actually deprecate calculate_fee
, so long as the impl is just calculate_fee_details(...).total_fees()
.
Seems reasonable there are many call-sites that don't care about the details, just the total fee. Might simplify this PR as well.
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.
Agree too. But does calculate_fee()
need to be exposed to external? Users use simulator to get tx fee, are they? github says this function was moved from runtime::bank
to sdk::fee_structure
not too long ago. Maybe entire fee_structure
belong to solana_runtime instead of sdk?
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 ship has sailed on whether it needs to be or not. we've already shipped releases with it exposed in the public api of a publicly consumable crate that we've promised to follow semver on. removing that symbol for public availability anytime but a major release will be a violation of semver
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.
033c98b for the sailed ship
033c98b
to
f7f85de
Compare
@@ -75,15 +88,32 @@ impl FeeStructure { | |||
.saturating_mul(heap_cost) | |||
} | |||
|
|||
/// Calculate fee for `SanitizedMessage` | |||
#[cfg(not(target_os = "solana"))] | |||
pub fn calculate_fee( |
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.
Keep this function live & active. @apfitzge has a good point that most use case just want total_fee. Doesn't need to deprecate it.
…e and priority fee separated
3f826ea
to
f2f33f5
Compare
transaction_fee: (signature_fee | ||
.saturating_add(write_lock_fee) | ||
.saturating_add(compute_fee) as f64) | ||
.round() as 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.
unrelated, but why do we round here even after removing congestion? these are all integers, right?
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.
Good catch! I'll patch it separately
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.
thanks!
solana-labs#34757)" This reverts commit 5ecc47e.
* Revert "refactor unused parameter (#34970)" This reverts commit 0838909. (cherry picked from commit 1542392) # Conflicts: # sdk/src/fee.rs * Revert "separate priority fee and transaction fee from fee calculation (#34757)" This reverts commit 5ecc47e. (cherry picked from commit df2ee12) # Conflicts: # sdk/src/fee.rs * Revert "Remove congestion multiplier from calculate fee (#34865)" This reverts commit 73d3973. (cherry picked from commit 0dcac3f) # Conflicts: # sdk/src/fee.rs * fix merge conflicts --------- Co-authored-by: Tao Zhu <[email protected]>
Problem
To reward priority fee differently from transaction fee (SIMD-0096), priority fee should be separated from return of
calculate_fee(...)
.Summary of Changes
calculate_fee()
return type fromu64
toFeeDetails
Fixes #