-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -217,6 +217,8 @@ mod tests { | |||||||||
|
|
||||||||||
| let versioned_epoch_stakes = mem::take(&mut bank_fields.versioned_epoch_stakes); | ||||||||||
| let accounts_lt_hash = bank_fields.accounts_lt_hash.clone().map(Into::into); | ||||||||||
| let (_last_hash, last_lamports_per_signature) = | ||||||||||
| bank2.last_blockhash_and_lamports_per_signature(); | ||||||||||
| serde_snapshot::serialize_bank_snapshot_into( | ||||||||||
| &mut writer, | ||||||||||
| bank_fields, | ||||||||||
|
|
@@ -225,7 +227,7 @@ mod tests { | |||||||||
| expected_accounts_hash, | ||||||||||
| &get_storages_to_serialize(&bank2.get_snapshot_storages(None)), | ||||||||||
| ExtraFieldsToSerialize { | ||||||||||
| lamports_per_signature: bank2.fee_rate_governor.lamports_per_signature, | ||||||||||
| lamports_per_signature: last_lamports_per_signature, | ||||||||||
| incremental_snapshot_persistence: expected_incremental_snapshot_persistence | ||||||||||
| .as_ref(), | ||||||||||
| epoch_accounts_hash: expected_epoch_accounts_hash, | ||||||||||
|
|
@@ -334,8 +336,6 @@ mod tests { | |||||||||
| (AccountsHash(Hash::new_unique()), u64::default()), | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| // Set extra fields | ||||||||||
| bank.fee_rate_governor.lamports_per_signature = 7000; | ||||||||||
| // Note that epoch_stakes already has two epoch stakes entries for epochs 0 and 1 | ||||||||||
| // which will also be serialized to the versioned epoch stakes extra field. Those | ||||||||||
| // entries are of type Stakes<StakeAccount> so add a new entry for Stakes<Stake>. | ||||||||||
|
|
@@ -394,10 +394,6 @@ mod tests { | |||||||||
| .unwrap(); | ||||||||||
|
|
||||||||||
| assert_eq!(bank.epoch_stakes, dbank.epoch_stakes); | ||||||||||
| assert_eq!( | ||||||||||
| bank.fee_rate_governor.lamports_per_signature, | ||||||||||
| dbank.fee_rate_governor.lamports_per_signature | ||||||||||
| ); | ||||||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does removing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks fine to me. |
||||||||||
| } | ||||||||||
|
|
||||||||||
| #[test] | ||||||||||
|
|
@@ -408,14 +404,11 @@ mod tests { | |||||||||
| activate_all_features(&mut genesis_config); | ||||||||||
|
|
||||||||||
| let bank0 = Arc::new(Bank::new_for_tests(&genesis_config)); | ||||||||||
| let mut bank = Bank::new_from_parent(bank0, &Pubkey::default(), 1); | ||||||||||
| let bank = Bank::new_from_parent(bank0, &Pubkey::default(), 1); | ||||||||||
| while !bank.is_complete() { | ||||||||||
| bank.fill_bank_with_ticks_for_tests(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Set extra field | ||||||||||
| bank.fee_rate_governor.lamports_per_signature = 7000; | ||||||||||
|
|
||||||||||
| let (_tmp_dir, accounts_dir) = create_tmp_accounts_dir_for_tests(); | ||||||||||
| let bank_snapshots_dir = TempDir::new().unwrap(); | ||||||||||
| let full_snapshot_archives_dir = TempDir::new().unwrap(); | ||||||||||
|
|
@@ -433,7 +426,7 @@ mod tests { | |||||||||
| .unwrap(); | ||||||||||
|
|
||||||||||
| // Deserialize | ||||||||||
| let (dbank, _) = snapshot_bank_utils::bank_from_snapshot_archives( | ||||||||||
| let (_dbank, _) = snapshot_bank_utils::bank_from_snapshot_archives( | ||||||||||
| &[accounts_dir], | ||||||||||
| bank_snapshots_dir.path(), | ||||||||||
| &snapshot_archive_info, | ||||||||||
|
|
@@ -452,11 +445,6 @@ mod tests { | |||||||||
| Arc::default(), | ||||||||||
| ) | ||||||||||
| .unwrap(); | ||||||||||
|
|
||||||||||
| assert_eq!( | ||||||||||
| bank.fee_rate_governor.lamports_per_signature, | ||||||||||
| dbank.fee_rate_governor.lamports_per_signature | ||||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| #[test_case(StorageAccess::Mmap)] | ||||||||||
|
|
@@ -467,7 +455,7 @@ mod tests { | |||||||||
|
|
||||||||||
| let bank0 = Arc::new(Bank::new_for_tests(&genesis_config)); | ||||||||||
| bank0.squash(); | ||||||||||
| let mut bank = Bank::new_from_parent(bank0.clone(), &Pubkey::default(), 1); | ||||||||||
| let bank = Bank::new_from_parent(bank0.clone(), &Pubkey::default(), 1); | ||||||||||
| bank.freeze(); | ||||||||||
| add_root_and_flush_write_cache(&bank0); | ||||||||||
| bank.rc | ||||||||||
|
|
@@ -479,9 +467,6 @@ mod tests { | |||||||||
| (AccountsHash(Hash::new_unique()), u64::default()), | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| // Set extra fields | ||||||||||
| bank.fee_rate_governor.lamports_per_signature = 7000; | ||||||||||
|
|
||||||||||
| // Serialize, but don't serialize the extra fields | ||||||||||
| let snapshot_storages = bank.get_snapshot_storages(None); | ||||||||||
| let mut buf = vec![]; | ||||||||||
|
|
@@ -525,9 +510,6 @@ mod tests { | |||||||||
| ) | ||||||||||
| .unwrap(); | ||||||||||
|
|
||||||||||
| // Defaults to 0 | ||||||||||
| assert_eq!(0, dbank.fee_rate_governor.lamports_per_signature); | ||||||||||
|
|
||||||||||
| // The snapshot epoch_reward_status always equals `None`, so the bank | ||||||||||
| // field should default to `Inactive` | ||||||||||
| assert_eq!(dbank.epoch_reward_status, EpochRewardStatus::Inactive); | ||||||||||
|
|
@@ -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, | ||||||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Comment on lines
+588
to
+589
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please import
Suggested change
Or alternatively, use |
||||||||||
| incremental_snapshot_persistence: Some(&incremental_snapshot_persistence), | ||||||||||
| epoch_accounts_hash: Some(EpochAccountsHash::new(Hash::new_unique())), | ||||||||||
| versioned_epoch_stakes, | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line was unnecessary at first place |
||
| let bank = Bank::new_for_tests(&genesis_config); | ||
| let key = solana_pubkey::new_rand(); | ||
|
|
||
| let mut transfer_instruction = system_instruction::transfer(&mint_keypair.pubkey(), &key, 0); | ||
|
|
@@ -4317,24 +4316,6 @@ fn test_bank_inherit_tx_count() { | |
| assert_eq!(bank6.non_vote_transaction_count_since_restart(), 1); | ||
| } | ||
|
|
||
| #[test] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test is obsoleted |
||
| fn test_bank_inherit_fee_rate_governor() { | ||
| let (mut genesis_config, _mint_keypair) = create_genesis_config(500); | ||
| genesis_config | ||
| .fee_rate_governor | ||
| .target_lamports_per_signature = 123; | ||
|
|
||
| let bank0 = Arc::new(Bank::new_for_tests(&genesis_config)); | ||
| let bank1 = Arc::new(new_from_parent(bank0.clone())); | ||
| assert_eq!( | ||
| bank0.fee_rate_governor.target_lamports_per_signature / 2, | ||
| bank1 | ||
| .fee_rate_governor | ||
| .create_fee_calculator() | ||
| .lamports_per_signature | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_bank_vote_accounts() { | ||
| let GenesisConfigInfo { | ||
|
|
||
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 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).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.
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 +?
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 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.
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 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.
Uh oh!
There was an error while loading. Please reload this page.
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.
we have not needed it since before I started working on solana 😆