Skip to content

Refactor remove fee rate governor from bank #5388

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tao-stones
Copy link

@tao-stones tao-stones commented Mar 20, 2025

Problem

How bank checks is_zero_fees_for_test, and how bank burns transaction fee have been refactored in previous PRs that contribute to #3303, bank.fee_rate_governor has become obsoleted.

Summary of Changes

  • remove fee_rate_governor from bank.

Note: this PR does not remove fee_rate_governor from snapshot, which can be done in followup PR

Fixes #

@tao-stones tao-stones marked this pull request as draft March 20, 2025 10:09
assert_eq!(
bank.fee_rate_governor.lamports_per_signature,
dbank.fee_rate_governor.lamports_per_signature
);
Copy link
Author

@tao-stones tao-stones Mar 20, 2025

Choose a reason for hiding this comment

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

does removing fee_rate_governor as extra modified fields break the test integrity? wdyt @brooksprumo

Choose a reason for hiding this comment

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

Looks fine to me.

@@ -4317,24 +4316,6 @@ fn test_bank_inherit_tx_count() {
assert_eq!(bank6.non_vote_transaction_count_since_restart(), 1);
}

#[test]
Copy link
Author

Choose a reason for hiding this comment

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

this test is obsoleted

@@ -4180,8 +4180,7 @@ fn test_bank_epoch_vote_accounts() {
fn test_zero_signatures() {
solana_logger::setup();
let (genesis_config, mint_keypair) = create_genesis_config(500);
let mut bank = Bank::new_for_tests(&genesis_config);
bank.fee_rate_governor.lamports_per_signature = 2;
Copy link
Author

Choose a reason for hiding this comment

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

this line was unnecessary at first place

@tao-stones tao-stones force-pushed the refactor-remove-fee-rate-governor-from-bank branch from 1c57657 to 24be257 Compare March 20, 2025 10:45
@@ -603,7 +585,8 @@ mod tests {
AccountsHash(Hash::new_unique()),
&get_storages_to_serialize(&snapshot_storages),
ExtraFieldsToSerialize {
lamports_per_signature: bank.fee_rate_governor.lamports_per_signature,
lamports_per_signature: solana_sdk::fee_calculator::FeeRateGovernor::default()
.lamports_per_signature,
Copy link
Author

@tao-stones tao-stones Mar 20, 2025

Choose a reason for hiding this comment

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

bank is created as default_for_tests(), effectively same as FeeRateGovernor::default().

Choose a reason for hiding this comment

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

do we not have this constant anywhere else? if we don't maybe we just add it in fee crate instead of continue to use FeeRateGovernor code.

Choose a reason for hiding this comment

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

The value doesn't matter for this test, we can just write a constant here too.

lamports_per_signature: 123, // actual value is not important

@tao-stones tao-stones force-pushed the refactor-remove-fee-rate-governor-from-bank branch from 24be257 to 4acf88a Compare March 20, 2025 21:51
@tao-stones tao-stones marked this pull request as ready for review March 20, 2025 21:51
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.3%. Comparing base (d0c88d5) to head (4acf88a).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5388   +/-   ##
=======================================
  Coverage    83.3%    83.3%           
=======================================
  Files         818      818           
  Lines      371732   371664   -68     
=======================================
- Hits       309938   309889   -49     
+ Misses      61794    61775   -19     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +1941 to +1943
// Bank no longer has fee-rate-governor, it can be removed from snapshot in followup
// refactoring.
fee_rate_governor: FeeRateGovernor::default(),

Choose a reason for hiding this comment

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

This struct, BankFieldsToSerialize, should reflect all the fields in Bank that should be serialized in the snapshot. Since we no longer have a fee rate governor in Bank, we can (and should) remove it here as well.

Note that we can't change the actual snapshot format, so we'll keep writing FeeRateGovernor::default(), but that'll be handled by the actual snapshot code later. This is intended to make it clearer which fields are actually needed or not (from the POV of either the Bank or the Snapshot).

Suggested change
// Bank no longer has fee-rate-governor, it can be removed from snapshot in followup
// refactoring.
fee_rate_governor: FeeRateGovernor::default(),

Choose a reason for hiding this comment

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

maybe a dumb question - do we actually need to serialize this specific struct anymore? can we just serialize [0u8; core::mem::size_of<FeeRateGovernor>()]?

maybe we because validators could still be deserializing (checking structure is correct) until all are whatever version this lands in +?

Choose a reason for hiding this comment

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

This is a good point. In what version is FeeRateGovernor not needed? If we still need is in v2.2, then we cannot remove it from the snapshot here in v2.3 (master). We must wait until v2.4 instead.

Choose a reason for hiding this comment

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

The other point, we cannot remove fields/bytes from the actual snapshot. We can write zeroes and ignore them if the field is not needed anymore.

Copy link

@apfitzge apfitzge Mar 21, 2025

Choose a reason for hiding this comment

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

we have not needed it since before I started working on solana 😆

Comment on lines +588 to +589
lamports_per_signature: solana_sdk::fee_calculator::FeeRateGovernor::default()
.lamports_per_signature,

Choose a reason for hiding this comment

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

Please import FeeRateGovernor at the top of this module.

Suggested change
lamports_per_signature: solana_sdk::fee_calculator::FeeRateGovernor::default()
.lamports_per_signature,
// at the top of the module: use solana_sdk::fee_calculator::FeeRateGovernor
lamports_per_signature: FeeRateGovernor::default().lamports_per_signature,

Or alternatively, use bank.last_blockhash_and_lamports_per_signature() instead. The actual values aren't important for this "test", just the types.

@tao-stones tao-stones mentioned this pull request Mar 7, 2025
7 tasks
@tao-stones tao-stones marked this pull request as draft April 11, 2025 23:34
@tao-stones
Copy link
Author

Convert to draft - can't remove it from bank until #5749 is activated. It is tracked at Issue #3303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants