Serialize lamports per signature in snapshots#25181
Serialize lamports per signature in snapshots#25181AshwinSekar merged 2 commits intosolana-labs:masterfrom
Conversation
9cc9c78 to
857e0ba
Compare
Codecov Report
@@ Coverage Diff @@
## master #25181 +/- ##
=========================================
Coverage 82.0% 82.1%
=========================================
Files 598 610 +12
Lines 165882 168250 +2368
=========================================
+ Hits 136125 138143 +2018
- Misses 29757 30107 +350 |
brooksprumo
left a comment
There was a problem hiding this comment.
Looks good. One nit/comment below, and then also posted over in the main issue about the direction for this fix.
| pub fn copy_with_new_lamports_per_signature( | ||
| old: FeeRateGovernor, | ||
| lamports_per_signature: u64, | ||
| ) -> FeeRateGovernor { | ||
| FeeRateGovernor { | ||
| lamports_per_signature, | ||
| target_lamports_per_signature: old.target_lamports_per_signature, | ||
| target_signatures_per_slot: old.target_signatures_per_slot, | ||
| min_lamports_per_signature: old.min_lamports_per_signature, | ||
| max_lamports_per_signature: old.max_lamports_per_signature, | ||
| burn_percent: old.burn_percent, | ||
| } | ||
| } |
There was a problem hiding this comment.
Minor nits/suggestions here:
- How about building off of a self reference instead of consuming the old governor?
- Should be able to use the
..syntax to construct the new governor - Rename the fn to use clone instead of copy (since the type itself doesn't implement Copy)
| pub fn copy_with_new_lamports_per_signature( | |
| old: FeeRateGovernor, | |
| lamports_per_signature: u64, | |
| ) -> FeeRateGovernor { | |
| FeeRateGovernor { | |
| lamports_per_signature, | |
| target_lamports_per_signature: old.target_lamports_per_signature, | |
| target_signatures_per_slot: old.target_signatures_per_slot, | |
| min_lamports_per_signature: old.min_lamports_per_signature, | |
| max_lamports_per_signature: old.max_lamports_per_signature, | |
| burn_percent: old.burn_percent, | |
| } | |
| } | |
| pub fn clone_with_lamports_per_signature( | |
| &self, | |
| lamports_per_signature: u64, | |
| ) -> Self { | |
| Self { | |
| lamports_per_signature, | |
| ..self | |
| } | |
| } |
(Note: I haven't tried compiling this to ensure it works heh 😅)
There was a problem hiding this comment.
Spot on 😄 , just had to dereference that last self
* Serialize lamports per signature * pr comments (cherry picked from commit 35d2a0f) # Conflicts: # runtime/src/serde_snapshot/newer.rs # runtime/src/serde_snapshot/tests.rs
|
@AshwinSekar It'll probably be valuable to add tests to ensure compatibility between snapshots with and without the new |
Problem
The
FeeRateGovernorin a bank does not serialize its currentlamports_per_signatureon snapshot. This causes issues if the block that we start a snapshot from is lined up with a fee increase, it is possible for thislamports_per_signatureto be invalid.Summary of Changes
Serialize and deserialize this field by accessing it from the
FeeRateGovernorFixes #23545