Skip to content
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

feat: serialize new versioned epoch stakes bank snapshot field #2282

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

jstarry
Copy link

@jstarry jstarry commented Jul 25, 2024

Problem

In v2.0, the solana protocol added support for deserializing the new versioned epoch stakes bank snapshot field. Now in v2.1 we can start serializing that new field.

Summary of Changes

Implements phase 2 of solana-foundation/solana-improvement-documents#149

  • Add versioned_epoch_stakes as a new serializable extra field
  • Add logic to split off epoch stakes entries that can be serialized in the new field

Fixes #

Copy link

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

Generally, this looks good to me, but I'll defer to Brooks on the approach.

runtime/src/epoch_stakes.rs Outdated Show resolved Hide resolved
runtime/src/bank.rs Outdated Show resolved Hide resolved
@brooksprumo brooksprumo self-requested a review July 29, 2024 16:30
Copy link

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

:shipit:

@jstarry jstarry added the automerge automerge Merge this Pull Request automatically once CI passes label Jul 29, 2024
Copy link

mergify bot commented Jul 29, 2024

automerge label removed due to a CI failure

@mergify mergify bot removed the automerge automerge Merge this Pull Request automatically once CI passes label Jul 29, 2024
@jstarry jstarry merged commit f39eab1 into anza-xyz:master Jul 30, 2024
42 checks passed
@jstarry jstarry deleted the feat/epoch-stakes-new branch July 30, 2024 02:00
versioned_epoch_stakes.insert(
epoch,
VersionedEpochStakes::Current {
stakes: Stakes::<Stake>::from(stakes.clone()),
Copy link
Author

Choose a reason for hiding this comment

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

@brooksprumo as you pointed out, this is causing us to do a clone of all epoch stakes. I see a few workarounds:

  1. replace all of the bank epoch stakes entries with StakesEnum::Stakes when we compute them for snapshots
  2. when we save off bank epoch stakes during epoch boundaries, replace the StakesEnum::Accounts with StakesEnum::Stakes immediately
  3. do the custom serialization approach we do for the epoch_stakes field where we keep StakesEnum::Accounts in VersionedEpochStakes but when serializing, it gets serialized as a StakesEnum::Stakes

I'm going to explore the first one

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.

3 participants