Skip to content

Refactor remove fee rate governor from bank#5388

Closed
tao-stones wants to merge 2 commits intoanza-xyz:masterfrom
tao-stones:refactor-remove-fee-rate-governor-from-bank
Closed

Refactor remove fee rate governor from bank#5388
tao-stones wants to merge 2 commits intoanza-xyz:masterfrom
tao-stones:refactor-remove-fee-rate-governor-from-bank

Conversation

@tao-stones
Copy link
Copy Markdown

@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
Copy Markdown
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks fine to me.

Comment thread runtime/src/bank/tests.rs
assert_eq!(bank6.non_vote_transaction_count_since_restart(), 1);
}

#[test]
Copy link
Copy Markdown
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

Comment thread runtime/src/bank/tests.rs
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
Copy Markdown
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
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
Copy Markdown
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().

Copy link
Copy Markdown

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.

Copy link
Copy Markdown

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
Copy Markdown

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 thread runtime/src/bank.rs
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(),
Copy link
Copy Markdown

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(),

Copy link
Copy Markdown

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 +?

Copy link
Copy Markdown

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.

Copy link
Copy Markdown

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
Copy Markdown

@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,
Copy link
Copy Markdown

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
8 tasks
@tao-stones tao-stones marked this pull request as draft April 11, 2025 23:34
@tao-stones
Copy link
Copy Markdown
Author

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

@apfitzge apfitzge removed their request for review July 8, 2025 14:36
@github-actions
Copy link
Copy Markdown

This pull request is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions Bot added the stale label Feb 16, 2026
@github-actions
Copy link
Copy Markdown

This pull request was closed because it has been stale for 7 days with no activity.

@github-actions github-actions Bot closed this Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants