Skip to content

Feature Gated: remove obsoleted FeeRateGovernor from fee calculation #5749

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tao-stones
Copy link

@tao-stones tao-stones commented Apr 10, 2025

Problem

Understanding lamports_per_signature in blockhash_queue

The lamports_per_signature value stored in blockhash_queue (and also in nonce accounts) is not used for transaction fee calculation. Instead, transaction fees are determined by bank.fee_structure.lamport_per_signature, which is a constant 5_000.

The primary function of lamports_per_signature in the blockhash_queue is to enable the zero_fees_for_test mode—this happens when its value is set to zero.

In tests, "zero-fee" mode is expressed by setting target_lamports_per_signature = 0 in genesis_config (reference).

Current Behavior of fee_rate_governor in Bank wrt blockhash_queue

The bank currently uses fee_rate_governor to adjust lamports_per_signature dynamically for each block based on cluster throughput. This adjustment stays within 50% to 1000% of target_lamports_per_signature.

A key property of fee_rate_governor's adjustment is:

  • If target_lamports_per_signature is zero, then all future banks will have lamports_per_signature = 0.
  • Otherwise, lamports_per_signature will never be zero.

Tests rely on this behavior to ensure zero transaction fees in specific scenarios.

Proposed Change

The current logic of deriving fee_rate_governor from the parent bank and storing it with blockhash to determine if lamports_per_signature == 0 is unnecessary. Instead, we can:

  • Store the target_lamports_per_signature from genesis_config in the blockhash, when creating genesis bank;
  • Copy lamports_per_signature from the parent bank when deriving a new bank.

This preserves the existing behavior while simplifying fee tracking and allowing the eventual removal of fee_rate_governor (#3303).

Feature gated

Changing what's stored into RecentBlockHash account changes account-delta-hash, which is part of BankHash for now. #5454 describes a testnet occurrence when divergence happened. So it is necessary to feature gate this change.

Summary of Changes

  • Clarify that lamports_per_signature in blockhash_queue and nonce_account is not used for fee calculation but only for determining zero_fees_for_test mode (lamports_per_signature == 0).
  • When creating a bank from genesis_config, store its target_lamports_per_signature in the blockhash.
  • For non-genesis banks, copy the parent's lamports_per_signature into the blockhash queue.
  • Update tests accordingly.
  • Feature gated.

Fixes #5782

@tao-stones tao-stones added the feature-gate Pull Request adds or modifies a runtime feature gate label Apr 10, 2025
@tao-stones tao-stones marked this pull request as draft April 10, 2025 17:01
@tao-stones tao-stones force-pushed the feat-remove-fee-rate-governor-from-bank branch from 7860020 to b08383b Compare April 11, 2025 18:04
@codecov-commenter
Copy link

codecov-commenter commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 86.44068% with 8 lines in your changes missing coverage. Please review.

Project coverage is 82.9%. Comparing base (41e9a25) to head (b1a1a77).
Report is 19 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5749   +/-   ##
=======================================
  Coverage    82.9%    82.9%           
=======================================
  Files         825      825           
  Lines      375444   375403   -41     
=======================================
- Hits       311541   311531   -10     
+ Misses      63903    63872   -31     
🚀 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.

@tao-stones tao-stones changed the title Feature Gated: remove obsoleted FeeRateGovernor from Bank Feature Gated: remove obsoleted FeeRateGovernor from fee calculation Apr 11, 2025
@tao-stones tao-stones marked this pull request as ready for review April 12, 2025 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-gate Pull Request adds or modifies a runtime feature gate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Gate: remove fee-rate-governor from fee calculation path
2 participants