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

startup shrink all slots has to avoid the snapshot slot #2339

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

jeffwashington
Copy link

Problem

If we shrink away zero lamport accounts with 1 ref count and 1 slot list at startup, then we could affect the startup bank hash calculation and cause the validator to fail to start.

Summary of Changes

Don't force shrink the storage/slot we're loading a snapshot from.

Fixes #

@jeffwashington jeffwashington marked this pull request as ready for review July 29, 2024 19:12
Copy link

@HaoranYi HaoranYi left a comment

Choose a reason for hiding this comment

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

Nice catch. lgtm!

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.

This would only affect the incremental accounts hash, right? Regular full accounts hash should not be affected since it does not include zero lamport accounts.

@HaoranYi
Copy link

HaoranYi commented Jul 30, 2024

This would only affect the incremental accounts hash, right? Regular full accounts hash should not be affected since it does not include zero lamport accounts.

By incremental accounts hash, you mean the accounts delta hashes part of the bank hash?
If yes, then I think so.

@brooksprumo
Copy link

By incremental accounts hash, you mean the accounts delta hashes part of the bank hash?

I mean the incremental accounts hash that happens for incremental snapshots. This one: solana-labs#30819

(sorry for editing your comment! that was a mistake)

@jeffwashington
Copy link
Author

By incremental accounts hash, you mean the accounts delta hashes part of the bank hash?

I mean the incremental accounts hash that happens for incremental snapshots. This one: solana-labs#30819

(sorry for editing your comment! that was a mistake)

i think this could affect starting from a full or full + inc.

After untarring and building the index, we sometimes run shrink and clean before starting replay. We calculate the bank hash for the slot that was in the snapshot (whether full or incremental). The accounts delta hash is part of the bank hash. The accounts delta hash is all accounts in the storage for the bank's slot. This includes zero lamport accounts. Zero lamport accounts ARE included in the accounts delta hash. Changes coming soon to shrink can cause us to shrink a slot and remove accounts which are zero lamport and have 1 slot list entry and 1 ref count. If such an account gets removed from the storage for the bank's slot by shrink_all_slots here, then when we go through the storage and build the accounts delta hash, we will NOT have the zero lamport account anymore. This will mean we get a different accounts delta hash.

To differentiate: a full hash of all accounts skips zero lamport accounts. So, the existence or obliteration of a zero lamport account has no impact on a full hash of all accounts. But, a full snapshot can absolutely contain zero lamport accounts and even must (for the bank's slot at least). So much nuance and details here.

@brooksprumo
Copy link

Ah, yes, I forgot about the verification of the bank hash itself at startup, which recalculates the accounts delta hash. Thanks for that reminder.

So:

  • for accounts delta hash: cannot shrink the snapshot slot (can shrink one slot older though)
  • for incremental accounts hash: cannot remove zero lamport accounts in shrink (or anywhere) past the last full snapshot slot

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:

@jeffwashington jeffwashington merged commit 83e967a into anza-xyz:master Jul 30, 2024
41 checks passed
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