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

Add test_bank_forks_incremental_snapshot() #18565

Merged
merged 2 commits into from
Jul 29, 2021

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Jul 9, 2021

This commit builds on PR #18504 by adding a test to core/tests/snapshot.rs for Incremental Snapshots. The test adds banks to bank forks in a loop and takes both full snapshots and incremental snapshots at intervals, and validates they are rebuild-able.

For background info about Incremental Snapshots, see #17088.

@brooksprumo brooksprumo force-pushed the iss-v3-snapshot-tests branch from 2d001a3 to d0c3f66 Compare July 9, 2021 22:19
@codecov
Copy link

codecov bot commented Jul 12, 2021

Codecov Report

Merging #18565 (ba0f6dc) into master (d2d5f36) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##           master   #18565   +/-   ##
=======================================
  Coverage    82.8%    82.8%           
=======================================
  Files         443      443           
  Lines      126301   126318   +17     
=======================================
+ Hits       104675   104694   +19     
+ Misses      21626    21624    -2     

@brooksprumo brooksprumo marked this pull request as ready for review July 12, 2021 15:59
@brooksprumo brooksprumo marked this pull request as draft July 12, 2021 16:01
@brooksprumo brooksprumo force-pushed the iss-v3-snapshot-tests branch from 7c86926 to b1eb040 Compare July 12, 2021 18:36
@stale
Copy link

stale bot commented Jul 20, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Jul 20, 2021
@brooksprumo brooksprumo force-pushed the iss-v3-snapshot-tests branch from b1eb040 to d13bf96 Compare July 20, 2021 14:59
@stale stale bot removed the stale [bot only] Added to stale content; results in auto-close after a week. label Jul 20, 2021
@brooksprumo brooksprumo force-pushed the iss-v3-snapshot-tests branch from d13bf96 to aafec57 Compare July 21, 2021 22:45
@brooksprumo brooksprumo linked an issue Jul 21, 2021 that may be closed by this pull request
@brooksprumo brooksprumo force-pushed the iss-v3-snapshot-tests branch from f8ed393 to 87a7667 Compare July 23, 2021 15:32
@brooksprumo brooksprumo marked this pull request as ready for review July 24, 2021 14:22
@brooksprumo
Copy link
Contributor Author

@ryoqun @carllin @lijunwangs Here's the next PR for incremental snapshots. This one is just a test, and should be much easier to review. Thanks in advance!

core/tests/snapshots.rs Outdated Show resolved Hide resolved
false,
None,
accounts_db::AccountShrinkThreshold::default(),
false,
Copy link
Contributor

Choose a reason for hiding this comment

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

This flag to not check the hash was introduced here: https://github.com/solana-labs/solana/pull/17939/files#diff-b5dead0a38e5f63447595bbeda1428d3aa851d33954343bb1bc38b4b00add5fdR149, not sure why it's not safe to check the hash here.

Maybe the hash is verified elsewhere already? Would be good to check the accounts state is being verified to match the snapshot hash somewhere in the test.

Copy link
Contributor

@carllin carllin Jul 27, 2021

Choose a reason for hiding this comment

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

heh, looks like in the normal path, the hash is verified after the call to bank_from_snapshot_archives()

if let Some(shrink_paths) = shrink_paths {
deserialized_bank.set_shrink_paths(shrink_paths);
}
let deserialized_bank_slot_and_hash = (
deserialized_bank.slot(),
deserialized_bank.get_accounts_hash(),
);
if deserialized_bank_slot_and_hash
!= (
*full_snapshot_archive_info.slot(),
*full_snapshot_archive_info.hash(),
)
{
error!(
"Snapshot has mismatch:\narchive: {:?}\ndeserialized: {:?}",
(
full_snapshot_archive_info.slot(),
full_snapshot_archive_info.hash()
),
deserialized_bank_slot_and_hash
);
.

Can we extract this piece of logic (the unpacking and the hash verify), into a separate function like deserialize_and_verify_bank and call that function from here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@carllin Sure thing. Can I break this out into a separate PR/issue instead of fixing inside this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

If extracting the above logic into a function and calling it from the test works, I think it makes sense to include in this PR, as testing the accounts hash seems important to the snapshot tests.

If somethings broken/hash doesn't verify, then a separate PR makes sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Carl and I talked. I've created a new issue to track this request: #18973.

@brooksprumo
Copy link
Contributor Author

@carllin I refactored the functions for package, process, and archive as per our call (and issue #18972). I'll handle the "verify" stuff (issue #18973) in a separate PR. So this PR should be good-to-go!

@brooksprumo brooksprumo requested a review from carllin July 29, 2021 19:19
Copy link
Contributor

@carllin carllin left a comment

Choose a reason for hiding this comment

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

Thanks, looks much cleaner!

@brooksprumo brooksprumo merged commit b05fb87 into solana-labs:master Jul 29, 2021
@brooksprumo brooksprumo deleted the iss-v3-snapshot-tests branch July 29, 2021 21:47
brooksprumo added a commit to brooksprumo/solana that referenced this pull request Jul 29, 2021
While reviewing PR solana-labs#18565, as issue was brought up to refactor some code
around verifying the bank after rebuilding from snapshots.  A new
top-level function has been added to get the latest snapshot archives
and load the bank then verify.  Additionally, new tests have been
written and existing tests have been updated to use this new function.

Fixes solana-labs#18973

While resolving the issue, it became clear there was some additional
low-hanging fruit this change enabled.  Specifically, the functions
`bank_to_xxx_snapshot_archive()` now return their respective
`SnapshotArchiveInfo`.  And on the flip side,
`bank_from_snapshot_archives()` now takes `SnapshotArchiveInfo`s instead
of separate paths and archive formats.  This bundling simplifies bank
rebuilding.
brooksprumo added a commit to brooksprumo/solana that referenced this pull request Jul 29, 2021
While reviewing PR solana-labs#18565, as issue was brought up to refactor some code
around verifying the bank after rebuilding from snapshots.  A new
top-level function has been added to get the latest snapshot archives
and load the bank then verify.  Additionally, new tests have been
written and existing tests have been updated to use this new function.

Fixes solana-labs#18973

While resolving the issue, it became clear there was some additional
low-hanging fruit this change enabled.  Specifically, the functions
`bank_to_xxx_snapshot_archive()` now return their respective
`SnapshotArchiveInfo`.  And on the flip side,
`bank_from_snapshot_archives()` now takes `SnapshotArchiveInfo`s instead
of separate paths and archive formats.  This bundling simplifies bank
rebuilding.
brooksprumo added a commit to brooksprumo/solana that referenced this pull request Jul 29, 2021
While reviewing PR solana-labs#18565, as issue was brought up to refactor some code
around verifying the bank after rebuilding from snapshots.  A new
top-level function has been added to get the latest snapshot archives
and load the bank then verify.  Additionally, new tests have been
written and existing tests have been updated to use this new function.

Fixes solana-labs#18973

While resolving the issue, it became clear there was some additional
low-hanging fruit this change enabled.  Specifically, the functions
`bank_to_xxx_snapshot_archive()` now return their respective
`SnapshotArchiveInfo`.  And on the flip side,
`bank_from_snapshot_archives()` now takes `SnapshotArchiveInfo`s instead
of separate paths and archive formats.  This bundling simplifies bank
rebuilding.
brooksprumo added a commit to brooksprumo/solana that referenced this pull request Aug 4, 2021
While reviewing PR solana-labs#18565, as issue was brought up to refactor some code
around verifying the bank after rebuilding from snapshots.  A new
top-level function has been added to get the latest snapshot archives
and load the bank then verify.  Additionally, new tests have been
written and existing tests have been updated to use this new function.

Fixes solana-labs#18973

While resolving the issue, it became clear there was some additional
low-hanging fruit this change enabled.  Specifically, the functions
`bank_to_xxx_snapshot_archive()` now return their respective
`SnapshotArchiveInfo`.  And on the flip side,
`bank_from_snapshot_archives()` now takes `SnapshotArchiveInfo`s instead
of separate paths and archive formats.  This bundling simplifies bank
rebuilding.
brooksprumo added a commit to brooksprumo/solana that referenced this pull request Aug 6, 2021
While reviewing PR solana-labs#18565, as issue was brought up to refactor some code
around verifying the bank after rebuilding from snapshots.  A new
top-level function has been added to get the latest snapshot archives
and load the bank then verify.  Additionally, new tests have been
written and existing tests have been updated to use this new function.

Fixes solana-labs#18973

While resolving the issue, it became clear there was some additional
low-hanging fruit this change enabled.  Specifically, the functions
`bank_to_xxx_snapshot_archive()` now return their respective
`SnapshotArchiveInfo`.  And on the flip side,
`bank_from_snapshot_archives()` now takes `SnapshotArchiveInfo`s instead
of separate paths and archive formats.  This bundling simplifies bank
rebuilding.
brooksprumo added a commit that referenced this pull request Aug 7, 2021
While reviewing PR #18565, as issue was brought up to refactor some code
around verifying the bank after rebuilding from snapshots.  A new
top-level function has been added to get the latest snapshot archives
and load the bank then verify.  Additionally, new tests have been
written and existing tests have been updated to use this new function.

Fixes #18973

While resolving the issue, it became clear there was some additional
low-hanging fruit this change enabled.  Specifically, the functions
`bank_to_xxx_snapshot_archive()` now return their respective
`SnapshotArchiveInfo`.  And on the flip side,
`bank_from_snapshot_archives()` now takes `SnapshotArchiveInfo`s instead
of separate paths and archive formats.  This bundling simplifies bank
rebuilding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants