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

Supports accounts lt hash in snapshots #3096

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

brooksprumo
Copy link

@brooksprumo brooksprumo commented Oct 7, 2024

Problem

The accounts lt hash is not in snapshots, so it must always be regenerated. While testing, this is kinda OK, but when the real feature is enabled, that won't be sufficient.

Summary of Changes

Serialize and deserialize the accounts lt hash from snapshots. But only if the CLI arg is passed in (as there's not a feature-gate yet). This let's us get testing/runtime on startup asap.

@brooksprumo brooksprumo self-assigned this Oct 7, 2024
@@ -546,7 +578,7 @@ mod tests {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "8hwm4YsQXJWGZdp762SkJnDok29LXKwFtmW9oQ2KSzrN")
frozen_abi(digest = "CKb4Lp4AEJKBCLqHCFSSsntQU3MpcphA38RcAXASeDuG")
Copy link
Author

@brooksprumo brooksprumo Oct 7, 2024

Choose a reason for hiding this comment

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

The digest changed here because we've added the accounts lt hash to the snapshot.

Here's a diff from the ABI export files:

[snipped; above is all the same]
                    field accounts_lt_hash: core::option::Option<solana_runtime::serde_snapshot::types::SerdeAccountsLtHash>
                        enum Option (variants = 2)
                            variant(0) None (unit)
                            variant(1) Some(solana_runtime::serde_snapshot::types::SerdeAccountsLtHash) (newtype)
                                struct SerdeAccountsLtHash(solana_runtime::serde_snapshot::types::_::<impl serde::ser::Serialize for solana_runtime::serde_snapshot::types::SerdeAccountsLtHash>::serialize::__SerializeWith) (newtype)
                                    tuple (elements = 1024)
                                        element serde_with::ser::SerializeAsWrap<u16, serde_with::Same>
                                            primitive u16
[snipped; this is repeated for all 1024 elements]

(Note: The digest in the PR now is different because the original/master digest has also changed. The changes in the ABI are still the same as described in this comment though.)

frozen abi diff
```
                    field accounts_lt_hash: core::option::Option<solana_runtime::serde_snapshot::types::SerdeAccountsLtHash>
                        enum Option (variants = 2)
                            variant(0) None (unit)
                            variant(1) Some(solana_runtime::serde_snapshot::types::SerdeAccountsLtHash) (newtype)
                                struct SerdeAccountsLtHash(solana_runtime::serde_snapshot::types::_::<impl serde::ser::Serialize for solana_runtime::serde_snapshot::types::SerdeAccountsLtHash>::serialize::__SerializeWith) (newtype)
                                    tuple (elements = 1024)
                                        element serde_with::ser::SerializeAsWrap<u16, serde_with::Same>
                                            primitive u16
```
Copy link

@jeffwashington jeffwashington left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -662,6 +666,7 @@ impl BankFieldsToSerialize {
is_delta: bool::default(),
accounts_data_len: u64::default(),
versioned_epoch_stakes: HashMap::default(),
accounts_lt_hash: Some(AccountsLtHash(LtHash([0x7E57; LtHash::NUM_ELEMENTS]))),

Choose a reason for hiding this comment

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

does it have any special meaning for 7e57?

Copy link
Author

Choose a reason for hiding this comment

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

This is my approximation for "TEST" 😸

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.

so, the plan is to include lt hash in snapshot when the feature is enabled?

@brooksprumo
Copy link
Author

so, the plan is to include lt hash in snapshot when the feature is enabled?

Yes, the lt hash will go in the snapshot. Both when the feature is enabled, or if the cli arg is set.

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.

lgtm

@brooksprumo brooksprumo merged commit 0d939c6 into anza-xyz:master Oct 29, 2024
40 checks passed
@brooksprumo brooksprumo deleted the lthash/3 branch October 29, 2024 16:04
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